Java Code Examples for android.test.TouchUtils#clickView()

The following examples show how to use android.test.TouchUtils#clickView() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DocumentCentricAppsInstrumentationTest.java    From user-interface-samples with Apache License 2.0 5 votes vote down vote up
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());
}
 
Example 2
Source File: SampleTests.java    From user-interface-samples with Apache License 2.0 5 votes vote down vote up
/**
 * 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());
}
 
Example 3
Source File: DocumentCentricAppsInstrumentationTest.java    From android-DocumentCentricApps with Apache License 2.0 5 votes vote down vote up
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());
}
 
Example 4
Source File: SampleTests.java    From android-ClippingBasic with Apache License 2.0 5 votes vote down vote up
/**
 * 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());
}
 
Example 5
Source File: SampleTest.java    From androidtestdebug with MIT License 5 votes vote down vote up
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);
}
 
Example 6
Source File: PdfRendererBasicFragmentTests.java    From android-PdfRendererBasic with Apache License 2.0 4 votes vote down vote up
/**
 * 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);
    }
}
 
Example 7
Source File: MainActivityFunctionalTest.java    From codeexamples-android with Eclipse Public License 1.0 4 votes vote down vote up
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);
}