android.test.TouchUtils#clickView ( )源码实例Demo

下面列出了android.test.TouchUtils#clickView ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

public void testNewDocument_CreatesOverviewEntry() {
    // Given a initialized Activity
    assertNotNull("mDocumentCentricActivity is null", mDocumentCentricActivity);
    final Button createNewDocumentButton = (Button) mDocumentCentricActivity
            .findViewById(R.id.new_document_button);
    assertNotNull(createNewDocumentButton);

    // When "Create new Document" Button is clicked
    TouchUtils.clickView(this, createNewDocumentButton);

    // Then a entry in overview app tasks is created.
    List<ActivityManager.AppTask> recentAppTasks = getRecentAppTasks();
    assertEquals("# of recentAppTasks does not match", 2, recentAppTasks.size());
}
 
源代码2 项目: user-interface-samples   文件: SampleTests.java
/**
 * Triggers a click on the button and tests if the view is clipped afterwards.
 */
public void testClipping() {
    View clippedView = mTestActivity.findViewById(R.id.frame);

    // Initially, the view is not clipped.
    assertFalse(clippedView.getClipToOutline());

    // Trigger a click on the button to activate clipping.
    TouchUtils.clickView(this, mTestActivity.findViewById(R.id.button));

    // Check that the view has been clipped.
    assertTrue(clippedView.getClipToOutline());
}
 
public void testNewDocument_CreatesOverviewEntry() {
    // Given a initialized Activity
    assertNotNull("mDocumentCentricActivity is null", mDocumentCentricActivity);
    final Button createNewDocumentButton = (Button) mDocumentCentricActivity
            .findViewById(R.id.new_document_button);
    assertNotNull(createNewDocumentButton);

    // When "Create new Document" Button is clicked
    TouchUtils.clickView(this, createNewDocumentButton);

    // Then a entry in overview app tasks is created.
    List<ActivityManager.AppTask> recentAppTasks = getRecentAppTasks();
    assertEquals("# of recentAppTasks does not match", 2, recentAppTasks.size());
}
 
源代码4 项目: android-ClippingBasic   文件: SampleTests.java
/**
 * Triggers a click on the button and tests if the view is clipped afterwards.
 */
public void testClipping() {
    View clippedView = mTestActivity.findViewById(R.id.frame);

    // Initially, the view is not clipped.
    assertFalse(clippedView.getClipToOutline());

    // Trigger a click on the button to activate clipping.
    TouchUtils.clickView(this, mTestActivity.findViewById(R.id.button));

    // Check that the view has been clipped.
    assertTrue(clippedView.getClipToOutline());
}
 
源代码5 项目: androidtestdebug   文件: SampleTest.java
public void test点击链接() {
	final Instrumentation inst = getInstrumentation();
	IntentFilter intentFilter = new IntentFilter(Intent.ACTION_VIEW);
	intentFilter.addDataScheme("http");
	intentFilter.addCategory(Intent.CATEGORY_BROWSABLE);
	View link = this.getActivity().findViewById(R.id.link);
	ActivityMonitor monitor = inst.addMonitor(
			intentFilter, null, false);
	assertEquals(0, monitor.getHits());
	TouchUtils.clickView(this, link);
	monitor.waitForActivityWithTimeout(5000);
	assertEquals(1, monitor.getHits());
	inst.removeMonitor(monitor);
}
 
/**
 * Click the "Next" button to turn the pages.
 *
 * @param count The number of times to turn pages.
 */
private void turnPages(int count) {
    for (int i = 0; i < count; ++i) {
        TouchUtils.clickView(this, mButtonNext);
    }
}
 
public void testStartSecondActivity() throws Exception {
	final EditText editText = (EditText) activity
			.findViewById(R.id.editText1);

	
	activity.runOnUiThread(new Runnable() {

		@Override
		public void run() {
			editText.setText(INPUT);
		}
	});
	// Add monitor to check for the second activity
	ActivityMonitor monitor = getInstrumentation().addMonitor(
			SecondActivity.class.getName(), null, false);

	// Find button and click it
	Button view = (Button) activity.findViewById(R.id.button1);
	TouchUtils.clickView(this, view);

	// To click on a click, e.g. in a listview
	// listView.getChildAt(0);

	// Wait 2 seconds for the start of the activity
	SecondActivity startedActivity = (SecondActivity) monitor
			.waitForActivityWithTimeout(2000);
	assertNotNull(startedActivity);

	// Search for the textView
	TextView textView = (TextView) startedActivity
			.findViewById(R.id.resultText);

	// Check that the TextView is on the screen
	ViewAsserts.assertOnScreen(startedActivity.getWindow().getDecorView(),
			textView);
	// Validate the text on the TextView
	assertEquals("Text incorrect", INPUT, textView.getText().toString());
	// Press back and click again
	this.sendKeys(KeyEvent.KEYCODE_BACK);
	TouchUtils.clickView(this, view);
}