android.test.ViewAsserts Java Examples

The following examples show how to use android.test.ViewAsserts. 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 Inside_Android_Testing with Apache License 2.0 5 votes vote down vote up
public void testTextViewPosition() {
	RelativeLayout relativeLayoutContainer = (RelativeLayout)mainActivity.findViewById(R.id.rl_container);

	TextView textViewTitle = (TextView)mainActivity.findViewById(R.id.tv_title);
	TextView textViewDescription = (TextView)mainActivity.findViewById(R.id.tv_description);

	ViewAsserts.assertGroupContains(relativeLayoutContainer, textViewTitle);
	ViewAsserts.assertGroupContains(relativeLayoutContainer, textViewDescription);
}
 
Example #2
Source File: TestLayoutPropertiesCase.java    From json2view with MIT License 4 votes vote down vote up
public void testAlignedParentRight() {
    final View view = createContainer(container, createViewWithProperty(jsonObj0, ID0, NAME.LAYOUT_ALIGNPARENTRIGHT, ID0, TEXT0), null);
    Holder h = (Holder) view.getTag();
    ViewAsserts.assertRightAligned(h.v0, h.container);
}
 
Example #3
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());
}
 
Example #4
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 #5
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 #6
Source File: TestLayoutPropertiesCase.java    From json2view with MIT License 4 votes vote down vote up
public void testAlignedParentCenter() {
    final View view = createContainer(container, createViewWithProperty(jsonObj0, ID0, NAME.LAYOUT_CENTERINPARENT, ID0, TEXT0), null);
    Holder h = (Holder) view.getTag();
    ViewAsserts.assertHorizontalCenterAligned(h.container, h.v0);
    ViewAsserts.assertVerticalCenterAligned(h.container, h.v0);
}
 
Example #7
Source File: TestLayoutPropertiesCase.java    From json2view with MIT License 4 votes vote down vote up
public void testAlignedParentCenterCertical() {
    final View view = createContainer(container, createViewWithProperty(jsonObj0, ID0, NAME.LAYOUT_CENTERVERTICAL, ID0, TEXT0), null);
    Holder h = (Holder) view.getTag();
    ViewAsserts.assertVerticalCenterAligned(h.container, h.v0);
}
 
Example #8
Source File: TestLayoutPropertiesCase.java    From json2view with MIT License 4 votes vote down vote up
public void testAlignedParentCenterHorizontal() {
    final View view = createContainer(container, createViewWithProperty(jsonObj0, ID0, NAME.LAYOUT_CENTERHORIZONTAL, ID0, TEXT0), null);
    Holder h = (Holder) view.getTag();
    ViewAsserts.assertHorizontalCenterAligned(h.container, h.v0);
}
 
Example #9
Source File: TestLayoutPropertiesCase.java    From json2view with MIT License 4 votes vote down vote up
public void testAlignedParentBottom() {
    final View view = createContainer(container, createViewWithProperty(jsonObj0, ID0, NAME.LAYOUT_ALIGNPARENTBOTTOM, ID0, TEXT0), null);
    Holder h = (Holder) view.getTag();
    ViewAsserts.assertBottomAligned(h.v0, h.container);
}
 
Example #10
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 #11
Source File: TestLayoutPropertiesCase.java    From json2view with MIT License 4 votes vote down vote up
public void testAlignedParentTop() {
    final View view = createContainer(container, createViewWithProperty(jsonObj0, ID0, NAME.LAYOUT_ALIGNPARENTTOP, ID0, TEXT0), null);
    Holder h = (Holder) view.getTag();
    ViewAsserts.assertTopAligned(h.v0, h.container);
}
 
Example #12
Source File: TestLayoutPropertiesCase.java    From json2view with MIT License 4 votes vote down vote up
public void testAlignedParentLeft() {
    final View view = createContainer(container, createViewWithProperty(jsonObj0, ID0, NAME.LAYOUT_ALIGNPARENTLEFT, ID0, TEXT0), null);
    Holder h = (Holder) view.getTag();
    ViewAsserts.assertLeftAligned(h.v0, h.container);
}
 
Example #13
Source File: TestLayoutPropertiesCase.java    From json2view with MIT License 4 votes vote down vote up
public void testAlignedBaselineTo() {
    final View view = createContainer(container, createViewWithId(jsonObj0, ID0, TEXT0), createViewWithProperty(jsonObj1, ID1, NAME.LAYOUT_ALIGNBASELINE, ID0, TEXT1));
    Holder h = (Holder) view.getTag();
    ViewAsserts.assertBaselineAligned(h.v0, h.v1);
}
 
Example #14
Source File: TestLayoutPropertiesCase.java    From json2view with MIT License 4 votes vote down vote up
public void testAlignedBottomTo() {
    final View view = createContainer(container, createViewWithId(jsonObj0, ID0, TEXT0), createViewWithProperty(jsonObj1, ID1, NAME.LAYOUT_ALIGNBOTTOM, ID0, TEXT1));
    Holder h = (Holder) view.getTag();
    ViewAsserts.assertBottomAligned(h.v0, h.v1);
}
 
Example #15
Source File: TestLayoutPropertiesCase.java    From json2view with MIT License 4 votes vote down vote up
public void testAlignedTopTo() {
    final View view = createContainer(container, createViewWithId(jsonObj0, ID0, TEXT0), createViewWithProperty(jsonObj1, ID1, NAME.LAYOUT_ALIGNTOP, ID0, TEXT1));
    Holder h = (Holder) view.getTag();
    ViewAsserts.assertTopAligned(h.v0, h.v1);
}
 
Example #16
Source File: TestLayoutPropertiesCase.java    From json2view with MIT License 4 votes vote down vote up
public void testAlignedRightTo() {
    final View view = createContainer(container, createViewWithId(jsonObj0, ID0, TEXT0), createViewWithProperty(jsonObj1, ID1, NAME.LAYOUT_ALIGNRIGHT, ID0, TEXT1));
    Holder h = (Holder) view.getTag();
    ViewAsserts.assertRightAligned(h.v0, h.v1);
}
 
Example #17
Source File: TestLayoutPropertiesCase.java    From json2view with MIT License 4 votes vote down vote up
public void testAlignedLeftTo() {
    final View view = createContainer(container, createViewWithId(jsonObj0, ID0, TEXT0), createViewWithProperty(jsonObj1, ID1, NAME.LAYOUT_ALIGNLEFT, ID0, TEXT1));
    Holder h = (Holder) view.getTag();
    ViewAsserts.assertLeftAligned(h.v0, h.v1);
}