/** * 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()); }
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()); }
@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)); }
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); }
@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); }
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); }
@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); }
@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()); }
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); }
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); }
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); }
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(); } }
@MediumTest public void testClickMeButton_layout() { // Retrieve the top-level window decor view final View decorView = mClickFunActivity.getWindow() .getDecorView(); // Verify that the mClickMeButton is on screen ViewAsserts.assertOnScreen(decorView, mClickMeButton); // Verify width and heights final ViewGroup.LayoutParams layoutParams = mClickMeButton.getLayoutParams(); assertNotNull(layoutParams); assertEquals(layoutParams.width, WindowManager.LayoutParams.MATCH_PARENT); assertEquals(layoutParams.height, WindowManager.LayoutParams.WRAP_CONTENT); }
@MediumTest public void testInfoTextView_layout() { // Retrieve the top-level window decor view final View decorView = mClickFunActivity.getWindow() .getDecorView(); // Verify that the mInfoTextView is on screen and is not visible ViewAsserts.assertOnScreen(decorView, mInfoTextView); assertTrue(View.GONE == mInfoTextView.getVisibility()); }
@UiThreadTest public void testListQuestions() { MainActivity ma = getActivity(); ViewAsserts.assertOnScreen(ma.getWindow().getDecorView(), ma.findViewById(com.team09.qanda.R.id.MainListView)); ViewAsserts.assertOnScreen(ma.getWindow().getDecorView(), ma.findViewById(com.team09.qanda.R.id.authorMain)); }
/** * Testing views on UserLists View exist and can be seen. <br> Also tests that * the title at top of the activity is * correct. */ @UiThreadTest public void testItemsOnList() { UserListsActivity activity = (UserListsActivity) getActivity(); ListView userListView; TextView title; userListView = (ListView) activity .findViewById(R.id.user_question_list); title = (TextView) activity.findViewById(R.id.user_list_title); // Assert that none of the views are null assertNotNull("Item not created for question view", userListView); assertNotNull("Item not created for question view", title); View mainView = (View) activity.getWindow().getDecorView() .findViewById(android.R.id.content); // Assert that all of the views are displayed on screen assertNotNull(mainView); ViewAsserts.assertOnScreen(mainView, userListView); ViewAsserts.assertOnScreen(mainView, title); // making sure that the title is correct assertEquals("Title is not the same", "F A V O R I T E S", title.getText()); }
/** * Test to make sure that View items in the layout are not null and can be * seen on the display. */ public void testUIviewsShowUp() { TextView title; TextView description; Button favoriteb; Button cacheb; Button toReadb; Button qButton; title = (TextView) activity.findViewById(R.id.user_home_title); description = (TextView) activity .findViewById(R.id.user_home_description); favoriteb = (Button) activity.findViewById(R.id.user_fav_button); cacheb = (Button) activity.findViewById(R.id.user_cached_button); toReadb = (Button) activity.findViewById(R.id.user_toRead_button); qButton = (Button) activity.findViewById(R.id.user_questions_button); assertNotNull("Title not created for question view", title); assertNotNull("Description not created for question view", description); assertNotNull("Favorite button not created for question view", favoriteb); assertNotNull("Cache button not created for question view", cacheb); assertNotNull("ToRead button not created for question view", toReadb); assertNotNull("question button not created for question view", qButton); View mainView = (View) activity.getWindow().getDecorView() .findViewById(android.R.id.content); // Assert that all of the views are displayed on screen assertNotNull(mainView); ViewAsserts.assertOnScreen(mainView, title); ViewAsserts.assertOnScreen(mainView, description); ViewAsserts.assertOnScreen(mainView, favoriteb); ViewAsserts.assertOnScreen(mainView, cacheb); ViewAsserts.assertOnScreen(mainView, toReadb); ViewAsserts.assertOnScreen(mainView, qButton); }
/** This test sees if the items are on screen. * * Part of UC13: Comment on a question */ public void testView(){ PostController pc = new PostController(getInstrumentation().getTargetContext()); PushController pushCtrl = new PushController(getInstrumentation().getTargetContext()); String qTitle = "Title"; String qBody = "Body"; String qAuthor = "Author"; Question q = new Question(qTitle,qBody,qAuthor); pushCtrl.addQuestionToServer(q); pc.getQuestionsInstance().add(q); Intent intent = new Intent(); intent.putExtra(ViewQuestion.SET_COMMENT_TYPE,ViewQuestion.COMMENT_ON_QUESTION_KEY); intent.putExtra(ViewQuestion.QUESTION_ID_KEY, q.getId()); setActivityIntent(intent); ViewComment vc = getActivity(); TextView title = (TextView) vc.findViewById(R.id.comment_title); TextView timeStamp = (TextView) vc.findViewById(R.id.comment_post_timestamp); TextView author = (TextView) vc.findViewById(R.id.comment_post_author); ListView lv = (ListView) vc.findViewById(R.id.commentListView); Button b = (Button)vc.findViewById(R.id.comment_button); ViewAsserts.assertOnScreen(vc.getWindow().getDecorView(), lv); ViewAsserts.assertOnScreen(vc.getWindow().getDecorView(), title); ViewAsserts.assertOnScreen(vc.getWindow().getDecorView(), timeStamp); ViewAsserts.assertOnScreen(vc.getWindow().getDecorView(), author); ViewAsserts.assertOnScreen(vc.getWindow().getDecorView(), b); }
/** * Making sure ListView is showing up on the screen * and not null */ public void testListView(){ //testing that the listview is actually visible on the screen ListView questionList; questionList = (ListView) activity.findViewById(R.id.activity_main_question_list); assertNotNull("ListView not created for question view", questionList); Intent intent = new Intent(); setActivityIntent(intent); View view = (View) this.activity.getWindow().getDecorView(); ViewAsserts.assertOnScreen(view, listview); }
public void testContentLayout() { // Get the activity's content view FrameLayout cv = (FrameLayout)activity.findViewById( android.R.id.content ); FrameLayout frameLayout = (FrameLayout)cv.getChildAt(0); // Get the QRCameraView and overlay assertEquals( 2, frameLayout.getChildCount() ); assertTrue( frameLayout.getChildAt(0) instanceof QRCameraView ); assertTrue( frameLayout.getChildAt(1) instanceof QRCameraActivity.OverlayView ); // test that QRCameraView is displayed on the screen ViewAsserts.assertOnScreen( cv, frameLayout.getChildAt(0) ); }
public void testClickSaveButton_layout(){ final View decorView = listViewCheckboxTagsActivity.getWindow().getDecorView(); ViewAsserts.assertOnScreen(decorView, saveButtonTest); final ViewGroup.LayoutParams layoutParams = saveButtonTest.getLayoutParams(); assertNotNull(layoutParams); assertEquals(layoutParams.width, WindowManager.LayoutParams.MATCH_PARENT); assertEquals(layoutParams.height, WindowManager.LayoutParams.WRAP_CONTENT); }
/** * test view exists */ public void testView() { EditText edittext = (EditText) activity.findViewById(R.id.editText1); ViewAsserts.assertOnScreen(activity.getWindow().getDecorView(), edittext); }
/** * testing tags button */ public void testTagDone() { Button button = (Button) activity.findViewById(R.id.tagbutton2); ViewAsserts.assertOnScreen(activity.getWindow().getDecorView(), button); }
/** * testing tag enter button */ public void testTagEnter() { Button button = (Button) activity.findViewById(R.id.tagbutton1); ViewAsserts.assertOnScreen(activity.getWindow().getDecorView(), button); }