当前位置: 首页>>代码示例>>Java>>正文


Java SWTBotText.selectAll方法代码示例

本文整理汇总了Java中org.eclipse.swtbot.swt.finder.widgets.SWTBotText.selectAll方法的典型用法代码示例。如果您正苦于以下问题:Java SWTBotText.selectAll方法的具体用法?Java SWTBotText.selectAll怎么用?Java SWTBotText.selectAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.swtbot.swt.finder.widgets.SWTBotText的用法示例。


在下文中一共展示了SWTBotText.selectAll方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkTextRejectsInvalidInput

import org.eclipse.swtbot.swt.finder.widgets.SWTBotText; //导入方法依赖的package包/类
/**
 * Checks that the widget denies changes when the spinner's associated text
 * widget is set to an invalid time.
 */
@Test
public void checkTextRejectsInvalidInput() {

	// Get the text widget. We will try feeding it invalid times.
	SWTBotText widget = getTimeText();

	// Create a list of invalid times.
	List<String> invalidTimes = new ArrayList<String>();
	invalidTimes.add("");
	invalidTimes.add("infinite improbability");
	invalidTimes.add("    ");

	// Get the initial time.
	final AtomicReference<Double> time = new AtomicReference<Double>();
	getDisplay().syncExec(new Runnable() {
		@Override
		public void run() {
			time.set(timeComposite.getTime());
		}
	});
	final double initialTime = time.get();

	for (String invalidTime : invalidTimes) {
		// Try setting an invalid time string.
		widget.selectAll();
		widget.typeText(invalidTime + SWT.CR + SWT.LF);
		getDisplay().syncExec(new Runnable() {
			@Override
			public void run() {
				time.set(timeComposite.getTime());
			}
		});
		// Ensure that the time did not change.
		assertEquals(initialTime, time.get(), epsilon);
	}

	return;
}
 
开发者ID:eclipse,项目名称:eavp,代码行数:43,代码来源:TimeSliderCompositeTester.java

示例2: checkPauseOnNewSelectionByWidget

import org.eclipse.swtbot.swt.finder.widgets.SWTBotText; //导入方法依赖的package包/类
/**
 * Checks that, when any of the time widgets are updated, the active play
 * action is cancelled.
 */
@Test
public void checkPauseOnNewSelectionByWidget() {

	SWTBotButton playButton = getPlayPauseButton();

	SWTBotText text = getTimeText();
	String firstTime = text.getText();

	// Set the framerate to 1 frame every 10 seconds.
	getDisplay().syncExec(new Runnable() {
		@Override
		public void run() {
			timeComposite.setFPS(0.1);
		}
	});

	// Pause by clicking the play button.
	playButton.click();
	assertTrue(isPlaying());
	playButton.click();
	assertFalse(isPlaying());

	// Pause by clicking the time scale.
	playButton.click();
	assertTrue(isPlaying());
	getTimeScale().setValue(1);
	assertFalse(isPlaying());

	// Pause by typing text.
	playButton.click();
	assertTrue(isPlaying());
	text.selectAll();
	text.typeText(firstTime + SWT.CR + SWT.LF);
	assertFalse(isPlaying());

	// Pause by clicking the next button.
	playButton.click();
	assertTrue(isPlaying());
	getNextButton().click();
	assertFalse(isPlaying());

	// Pause by clicking the previous button.
	playButton.click();
	assertTrue(isPlaying());
	getPrevButton().click();
	assertFalse(isPlaying());

	return;
}
 
开发者ID:eclipse,项目名称:eavp,代码行数:54,代码来源:TimeSliderCompositeTester.java

示例3: checkTextNotifiesSelectionListeners

import org.eclipse.swtbot.swt.finder.widgets.SWTBotText; //导入方法依赖的package包/类
/**
 * Checks that listeners are updated when the spinner's associated text
 * widget changes.
 */
@Test
public void checkTextNotifiesSelectionListeners() {

	/*
	 * IMPORTANT NOTE ABOUT THIS TEST!
	 * 
	 * Simulating input into a Text widget with SWTBot is tricky.
	 * widget.setText(String) does not notify listeners, so you must use
	 * widget.selectAll() [highlights all the text] and
	 * widget.typeText(String) [replaces the text].
	 * 
	 * However, this can be finicky and fail if you are touching the
	 * keyboard or the mouse, so try running this test again when you are
	 * not actively using your computer's input. :)
	 */

	// Get the first and last time.
	Double firstTime = testTimes.get(0);
	Double lastTime = testTimes.get(testTimes.size() - 1);

	// Get the specific widget that will be used to set the time.
	SWTBotText widget = getTimeText();

	// Register the second fake listener.
	getDisplay().syncExec(new Runnable() {
		@Override
		public void run() {
			timeComposite.addSelectionListener(fakeListener2);
		}
	});

	// They should both be notified when the widget is used to change the
	// values.
	widget.selectAll();
	widget.typeText(lastTime.toString() + SWT.CR + SWT.LF);
	assertTrue(fakeListener1.wasNotified());
	assertTrue(fakeListener2.wasNotified());

	// Unregister this listener.
	getDisplay().syncExec(new Runnable() {
		@Override
		public void run() {
			timeComposite.removeSelectionListener(fakeListener2);
		}
	});

	// It should not be notified when the widget changes, but the other
	// should still be notified.
	widget.selectAll();
	widget.typeText(firstTime.toString() + SWT.CR + SWT.LF);
	assertFalse(fakeListener2.wasNotified()); // Test this one first!
	assertTrue(fakeListener1.wasNotified());

	return;
}
 
开发者ID:eclipse,项目名称:eavp,代码行数:60,代码来源:TimeSliderCompositeTester.java


注:本文中的org.eclipse.swtbot.swt.finder.widgets.SWTBotText.selectAll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。