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


Java ViewAsserts类代码示例

本文整理汇总了Java中android.test.ViewAsserts的典型用法代码示例。如果您正苦于以下问题:Java ViewAsserts类的具体用法?Java ViewAsserts怎么用?Java ViewAsserts使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: checkViewsCreatedAndVisible

import android.test.ViewAsserts; //导入依赖的package包/类
/**
 * Test the view creation and visibility.
 */
private void checkViewsCreatedAndVisible() {
    showCoachMark(getInstrumentation(), mCoachMark);

    final View container = mCoachMark.getContentView();

    // Check the creation
    assertNotNull(getActivity());
    assertNotNull(mCoachMark);
    assertNotNull(container);
    assertNotNull(mTextView);

    // Check the visibility
    ViewAsserts.assertOnScreen(container, mTextView);
    ViewAsserts.assertHorizontalCenterAligned(container, mTextView);

    // Check the resources which passed by builder
    assertEquals(MESSAGE, mTextView.getText().toString());
}
 
开发者ID:TouchType,项目名称:CornedBeef,代码行数:22,代码来源:PunchHoleCoachMarkTestCase.java

示例2: testNoAccountUi

import android.test.ViewAsserts; //导入依赖的package包/类
public void testNoAccountUi() throws Throwable {
  getActivity();
  ListView userList = (ListView) getActivity().findViewById(R.id.user_list);
  TextView enterPinPrompt = (TextView) getActivity().findViewById(R.id.enter_pin_prompt);
  Button howItWorksButton = (Button) getActivity().findViewById(R.id.how_it_works_button);
  Button addAccountButton = (Button) getActivity().findViewById(R.id.add_account_button);
  View contentWhenNoAccounts = getActivity().findViewById(R.id.content_no_accounts);

  // check existence of fields
  assertNotNull(userList);
  assertNotNull(enterPinPrompt);
  assertNotNull(howItWorksButton);
  assertNotNull(addAccountButton);
  assertNotNull(contentWhenNoAccounts);

  // check visibility
  View origin = getActivity().getWindow().getDecorView();
  ViewAsserts.assertOnScreen(origin, enterPinPrompt);
  ViewAsserts.assertOnScreen(origin, howItWorksButton);
  ViewAsserts.assertOnScreen(origin, addAccountButton);
  ViewAsserts.assertOnScreen(origin, contentWhenNoAccounts);
  assertFalse(userList.isShown());
}
 
开发者ID:ocdtrekkie,项目名称:authenticator,代码行数:24,代码来源:AuthenticatorActivityTest.java

示例3: testWithCounterBasedAccount

import android.test.ViewAsserts; //导入依赖的package包/类
public void testWithCounterBasedAccount() {
  setActivityIntent(new Intent(Intent.ACTION_MAIN).putExtra("user", "[email protected]"));
  CheckCodeActivity mActivity = getActivity();
  TextView mCodeTextView = (TextView) mActivity.findViewById(R.id.code_value);
  TextView mCheckCodeTextView = (TextView) mActivity.findViewById(R.id.check_code);
  TextView mCounterValue = (TextView) mActivity.findViewById(R.id.counter_value);

  // check existence of fields
  assertNotNull(mCheckCodeTextView);
  assertNotNull(mCodeTextView);
  assertNotNull(mCounterValue);

  // check visibility
  View origin = mActivity.getWindow().getDecorView();
  ViewAsserts.assertOnScreen(origin, mCheckCodeTextView);
  ViewAsserts.assertOnScreen(origin, mCodeTextView);
  ViewAsserts.assertOnScreen(origin, mCounterValue);
  assertTrue(mActivity.findViewById(R.id.code_area).isShown()); // layout area
  assertTrue(mActivity.findViewById(R.id.counter_area).isShown());  // layout area

  // check values
  MoreAsserts.assertContainsRegex("[email protected]", mCheckCodeTextView.getText().toString());
  assertEquals("724477", mCodeTextView.getText().toString());
  assertEquals("0", mCounterValue.getText().toString());
}
 
开发者ID:ocdtrekkie,项目名称:authenticator,代码行数:26,代码来源:CheckCodeActivityTest.java

示例4: testDisplayReplies

import android.test.ViewAsserts; //导入依赖的package包/类
@UiThreadTest
// Use Case #3 : View replies
public void testDisplayReplies() {
	Post question = new Post(new User(context), "Question 1");
	Reply reply = new Reply(new User(context), "reply");
	PostController pc = new PostController(question);
	pc.addReply(reply);
	thread = new QuestionThread(question);

	Intent intent = new Intent();
	intent.putExtra("Selected Thread", thread);

	setActivityIntent(intent);

	ta = getActivity();

	assertEquals(2, ta.getAdapter().getGroupCount());
	assertEquals(1, ta.getAdapter().getChildrenCount(0));

	((CheckBox) ta.findViewById(com.team09.qanda.R.id.repliesButton)).performClick();


	ViewAsserts.assertOnScreen(ta.getWindow().getDecorView(), ta.findViewById(com.team09.qanda.R.id.replyAuthor));
	ViewAsserts.assertOnScreen(ta.getWindow().getDecorView(), ta.findViewById(com.team09.qanda.R.id.reply));
	//ViewAsserts.assertGroupContains((ViewGroup) ta.findViewById(com.team09.qanda.R.id.ThreadPostsView), ta.findViewById(com.team09.qanda.R.id.postText));
}
 
开发者ID:CMPUT301F14T09,项目名称:Team09Project,代码行数:27,代码来源:QuestionThreadActivityTest.java

示例5: testAlignedParentCenterCertical

import android.test.ViewAsserts; //导入依赖的package包/类
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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:6,代码来源:TestLayoutPropertiesCase.java

示例6: testClickMeButton_layout

import android.test.ViewAsserts; //导入依赖的package包/类
@MediumTest
public void testClickMeButton_layout() {
    final View decorView = mActivity.getWindow().getDecorView();
    ViewAsserts.assertOnScreen(decorView, mBtn);
    final ViewGroup.LayoutParams layoutParams = mBtn.getLayoutParams();
    assertNotNull(layoutParams);
    assertEquals(layoutParams.width, RelativeLayout.LayoutParams.WRAP_CONTENT);
    assertEquals(layoutParams.height, WindowManager.LayoutParams.WRAP_CONTENT);
}
 
开发者ID:XinRan5312,项目名称:QxGradleConfig,代码行数:10,代码来源:MyFirstTestActivityTest.java

示例7: testFirstImageDataLoaded

import android.test.ViewAsserts; //导入依赖的package包/类
public void testFirstImageDataLoaded() throws Exception {
    final View decorView = mActivity.getWindow().getDecorView();
    ViewAsserts.assertOnScreen(decorView, mRecyclerView);
    ImageAdapter mImageAdapter = ImageDataManager.getInstance().getImageAdapter();
    Thread.sleep(5000); // sleep to wait for request for image data to finish

    // Test First round of ImageData is retrieved
    int initialItemCount = mImageAdapter.getItemCount();
    assertTrue(initialItemCount > 0);
    Log.d("Test", "initialItemCount = " + initialItemCount);
}
 
开发者ID:bilbo7833,项目名称:shutterstock-image-browser,代码行数:12,代码来源:ImageDataManagerTest.java

示例8: testEditText

import android.test.ViewAsserts; //导入依赖的package包/类
@UiThreadTest
public void testEditText() {
    assertEquals(nameEditText.getText().toString(), "");

    nameEditText.setText("Jana Moudra");
    assertEquals(nameEditText.getText().toString(), "Jana Moudra");

    View origin = mainActivity.getWindow().getDecorView();
    ViewAsserts.assertOnScreen(origin, nameEditText);
}
 
开发者ID:Janamou,项目名称:android-testing,代码行数:11,代码来源:MainActivityTest.java

示例9: testMessageBox

import android.test.ViewAsserts; //导入依赖的package包/类
@MediumTest
public void testMessageBox() {
    //Retrieve the top-level window decor view
    final View decorView = mUserActivity.getWindow().getDecorView();

    //Verify that the mMessage is on screen and is not visible
    ViewAsserts.assertOnScreen(decorView, mMessage);
    assertTrue(View.VISIBLE == mMessage.getVisibility());
}
 
开发者ID:dcf82,项目名称:TwitterRestfulAPI,代码行数:10,代码来源:AppTest.java

示例10: testWithTimeBasedAccount

import android.test.ViewAsserts; //导入依赖的package包/类
public void testWithTimeBasedAccount() {
  // For TOTP accounts, AuthenticatorActivity never calls CheckCodeActivity, however, the
  // code exists and we check its behavior here.
  setActivityIntent(new Intent(Intent.ACTION_MAIN).putExtra("user", "[email protected]"));
  CheckCodeActivity mActivity = getActivity();
  TextView mCodeTextView = (TextView) mActivity.findViewById(R.id.code_value);
  TextView mCheckCodeTextView = (TextView) mActivity.findViewById(R.id.check_code);
  TextView mCounterValue = (TextView) mActivity.findViewById(R.id.counter_value);

  // check existence of fields
  assertNotNull(mActivity);
  assertNotNull(mCheckCodeTextView);
  assertNotNull(mCodeTextView);
  assertNotNull(mCounterValue);

  // check visibility
  View origin = mActivity.getWindow().getDecorView();
  ViewAsserts.assertOnScreen(origin, mCheckCodeTextView);
  ViewAsserts.assertOnScreen(origin, mCodeTextView);
  assertTrue(mActivity.findViewById(R.id.code_area).isShown()); // layout area
  assertFalse(mCounterValue.isShown());  // TOTP has no counter value to show.
  assertFalse(mActivity.findViewById(R.id.counter_area).isShown());  // layout area

  // check values
  MoreAsserts.assertContainsRegex("[email protected]", mCheckCodeTextView.getText().toString());
  assertEquals("724477", mCodeTextView.getText().toString());
}
 
开发者ID:ocdtrekkie,项目名称:authenticator,代码行数:28,代码来源:CheckCodeActivityTest.java

示例11: testFieldsAreOnScreen

import android.test.ViewAsserts; //导入依赖的package包/类
public void testFieldsAreOnScreen() {
  Window window = mActivity.getWindow();
  View origin = window.getDecorView();
  ViewAsserts.assertOnScreen(origin, mAccountName);
  ViewAsserts.assertOnScreen(origin, mKeyEntryField);
  ViewAsserts.assertOnScreen(origin, mType);
  ViewAsserts.assertOnScreen(origin, mSubmitButton);
}
 
开发者ID:ocdtrekkie,项目名称:authenticator,代码行数:9,代码来源:EnterKeyActivityTest.java

示例12: testTextViewLayout

import android.test.ViewAsserts; //导入依赖的package包/类
public void testTextViewLayout(){
    final View decorView = connectionsActivity.getWindow().getDecorView();

    ViewAsserts.assertOnScreen(decorView, textView);

    final ViewGroup.LayoutParams layoutParams = textView.getLayoutParams();
    assertNotNull(layoutParams);
    assertEquals(layoutParams.width, layoutParams.WRAP_CONTENT);
    assertEquals(layoutParams.height, layoutParams.WRAP_CONTENT);
}
 
开发者ID:cfudge,项目名称:ClassDiscuss,代码行数:11,代码来源:ConnectionsActivityTest.java

示例13: testAddButtonLayout

import android.test.ViewAsserts; //导入依赖的package包/类
public void testAddButtonLayout(){
    final View decorView = myChannelsActivity.getWindow().getDecorView();

    ViewAsserts.assertOnScreen(decorView, addButton);

    final ViewGroup.LayoutParams layoutParams = addButton.getLayoutParams();
    assertNotNull(layoutParams);
    assertEquals(layoutParams.width, 135);
    assertEquals(layoutParams.height, 135);

}
 
开发者ID:cfudge,项目名称:ClassDiscuss,代码行数:12,代码来源:MyChannelsActivityTest.java

示例14: testCommentView

import android.test.ViewAsserts; //导入依赖的package包/类
public void testCommentView(){
	try {
		runTestOnUiThread(new Runnable() {
		     @Override
		     public void run() {
		    	 
		    	TopLevelActivity activity = getActivity();
		 		CommentListModel clm = activity.clm;
		 		
		 		clm.clearList();
		 		CommentModel comment = new CommentModel("1", "1", "Body", "Author", null, "Title");
		 		clm.add(comment);
		 		activity.update(comment);
		 		
		 		View view = activity.getWindow().getDecorView();
		 		
		 		//Find the views we want to assert exist
		 		TextView title = (TextView)activity.findViewById(R.id.top_level_title_list_item);
		 		TextView author = (TextView)activity.findViewById(R.id.top_level_author_list_item);
		 		TextView body = (TextView)activity.findViewById(R.id.top_level_body_list_item);
		 		TextView date = (TextView)activity.findViewById(R.id.top_level_date_list_item);
		 		TextView time = (TextView)activity.findViewById(R.id.top_level_time_list_item);
		 		ImageView picture = (ImageView)activity.findViewById(R.id.top_level_thumbnail);
		 		//Assert the views show up on screen.
		 		ViewAsserts.assertOnScreen(view, title);
		 		ViewAsserts.assertOnScreen(view, author);
		 		ViewAsserts.assertOnScreen(view, body);
		 		ViewAsserts.assertOnScreen(view, date);
		 		ViewAsserts.assertOnScreen(view, time);
		 		ViewAsserts.assertOnScreen(view, picture);
		    }
		});
	} catch (Throwable e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}	
}
 
开发者ID:CMPUT301W14T05,项目名称:Team5GeoTopics,代码行数:38,代码来源:BrowseTopLevelTests.java

示例15: testViewFavourite

import android.test.ViewAsserts; //导入依赖的package包/类
public void testViewFavourite() {
	ForumEntryController fec = new ForumEntryController(testActivity);
	ArrayList<ForumEntry> testList = new ArrayList<ForumEntry>();
	ForumEntry exampleEntry = new ForumEntry("subject","What is life?","Kibbles");
	exampleEntry.setId("[email protected]$#WFSVXCZv");
	ArrayList<ForumEntry> compareList = new ArrayList<ForumEntry>();

	// sets the entry to be a favourite in both our copy and the original activity
	testList.add(exampleEntry);
	datamanager.setFavourites(testList);
	 
	compareList = datamanager.getFavourites();
	assertEquals(testList.get(0), compareList.get(0));
	
	try {
		runTestOnUiThread(new Runnable() {
			@Override
			public void run() {

				assertNotNull(testActivity.getWindow().getDecorView());
				
				ViewAsserts.assertOnScreen(testActivity.getWindow().getDecorView(), getActivity().getView());

				
			}
		});
	} catch (Throwable e) {
		e.printStackTrace();
	}
	
}
 
开发者ID:CMPUT301F14T07,项目名称:Team7-301Project,代码行数:32,代码来源:FavouriteTest.java


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