Java Code Examples for android.test.ViewAsserts#assertOnScreen()

The following examples show how to use android.test.ViewAsserts#assertOnScreen() . 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: MainActivityTest.java    From otp-authenticator with MIT License 4 votes vote down vote up
public void testStart(){
    ViewAsserts.assertOnScreen(mActivity.getWindow().getDecorView(), mActivity.findViewById(R.id.listView));
}
 
Example 2
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);
}
 
Example 3
Source File: MainActivityTest.java    From NYU-BusTracker-Android with Apache License 2.0 4 votes vote down vote up
public void testStartText_layout() {
    ViewAsserts.assertOnScreen(decorView, startText);
    assertTrue(View.VISIBLE == startText.getVisibility());
}
 
Example 4
Source File: MainActivityTest.java    From NYU-BusTracker-Android with Apache License 2.0 4 votes vote down vote up
public void testEndText_layout() {
    ViewAsserts.assertOnScreen(decorView, endText);
    assertTrue(View.VISIBLE == endText.getVisibility());
}