Java Code Examples for android.support.test.espresso.ViewInteraction#check()

The following examples show how to use android.support.test.espresso.ViewInteraction#check() . 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 MathView with Apache License 2.0 6 votes vote down vote up
@Test
public void mainActivityTest() throws Throwable {
  ViewInteraction webView = onView(
    allOf(childAtPosition(
      allOf(withId(R.id.activity_main),
        childAtPosition(
          withId(android.R.id.content),
          0)),
      0),
      isDisplayed()));
  webView.check(matches(isDisplayed()));

  ViewInteraction editText = onView(
    allOf(withId(R.id.input_view),
      childAtPosition(
        allOf(withId(R.id.activity_main),
          childAtPosition(
            withId(android.R.id.content),
            0)),
        1),
      isDisplayed()));
  editText.check(matches(isDisplayed()));
}
 
Example 2
Source File: InfoActivityTest.java    From open_flood with MIT License 6 votes vote down vote up
@Test
public void infoActivityTest() {
    // Launch the Info Activity
    ViewInteraction infoActivityButton = onView(
            allOf(withId(R.id.infoButton), isDisplayed()));
    infoActivityButton.perform(click());

    // Click the back button
    ViewInteraction appCompatButton = onView(
            allOf(withId(R.id.backButton), withText("Back")));
    appCompatButton.perform(scrollTo(), click());

    // Verify that we are now back in the GameActivity by checking that the FloodView is displayed
    ViewInteraction view = onView(
            allOf(withId(R.id.floodView)));
    view.check(matches(isDisplayed()));
}
 
Example 3
Source File: HelpTest.java    From go-bees with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void helpTest() {
    ViewInteraction appCompatImageButton = onView(
            allOf(withContentDescription("Navigate up"),
                    withParent(withId(R.id.toolbar)),
                    isDisplayed()));
    appCompatImageButton.perform(click());

    ViewInteraction appCompatCheckedTextView = onView(
            allOf(withId(R.id.design_menu_item_text), withText("Help"), isDisplayed()));
    appCompatCheckedTextView.perform(click());

    ViewInteraction webView = onView(
            allOf(childAtPosition(
                    allOf(withId(R.id.linear_layout),
                            childAtPosition(
                                    withId(R.id.contentFrame),
                                    0)),
                    0),
                    isDisplayed()));
    webView.check(matches(isDisplayed()));
}
 
Example 4
Source File: CustomAssertions.java    From Minitask with Apache License 2.0 5 votes vote down vote up
public static void shouldDisplayNewTaskInTheList(String taskName) {
    ViewInteraction textView = onView(
            allOf(withId(R.id.todoContent),
                    childAtPosition(
                            allOf(withId(R.id.taskList),
                                    childAtPosition(
                                            withId(R.id.todoList),
                                            0)),
                            1),
                    isDisplayed()));
    textView.check(matches(withText(taskName)));
}
 
Example 5
Source File: MainActivityTest.java    From marvel with MIT License 5 votes vote down vote up
@Test
public void shouldBeAbleToCacheTestCharacter() {
    // Launch the activity
    mainActivity.launchActivity(new Intent());

    // search for Test Character
    ViewInteraction appCompatAutoCompleteTextView = onView(
            allOf(withId(R.id.character), isDisplayed()));
    appCompatAutoCompleteTextView.perform(replaceText(TEST_CHARACTER_NAME));

    ViewInteraction appCompatButton = onView(
            allOf(withId(R.id.show), isDisplayed()));
    appCompatButton.perform(click());

    pressBack();

    // Check view is loaded as we expect it to be
    ViewInteraction cachedName = onView(
            allOf(withId(R.id.name), withText(TEST_CHARACTER_NAME),
                    childAtPosition(
                            childAtPosition(
                                    IsInstanceOf.instanceOf(android.widget.FrameLayout.class),
                                    0),
                            1),
                    isDisplayed()));
    cachedName.check(matches(withText(TEST_CHARACTER_NAME)));
}
 
Example 6
Source File: ListRecordingsTest.java    From go-bees with GNU General Public License v3.0 4 votes vote down vote up
@Test
public void listRecordingsTest() {

    ViewInteraction appCompatImageButton2 = onView(
            allOf(withContentDescription("Navigate up"),
                    withParent(withId(R.id.toolbar)),
                    isDisplayed()));
    appCompatImageButton2.perform(click());

    ViewInteraction appCompatCheckedTextView = onView(
            allOf(withId(R.id.design_menu_item_text), withText("Settings"), isDisplayed()));
    appCompatCheckedTextView.perform(click());

    ViewInteraction linearLayout = onView(
            allOf(childAtPosition(
                    withId(android.R.id.list),
                    3),
                    isDisplayed()));
    linearLayout.perform(click());

    ViewInteraction recyclerView = onView(
            allOf(withId(R.id.apiaries_list),
                    withParent(allOf(withId(R.id.apiariesLL),
                            withParent(withId(R.id.apiariesContainer)))),
                    isDisplayed()));
    recyclerView.perform(actionOnItemAtPosition(0, click()));

    ViewInteraction recyclerView2 = onView(
            allOf(withId(R.id.hives_list),
                    withParent(allOf(withId(R.id.hivesLL),
                            withParent(withId(R.id.hivesContainer)))),
                    isDisplayed()));
    recyclerView2.perform(actionOnItemAtPosition(0, click()));

    ViewInteraction frameLayout = onView(
            allOf(withId(R.id.card),
                    childAtPosition(
                            allOf(withId(R.id.recordings_list),
                                    childAtPosition(
                                            withId(R.id.recordingsLL),
                                            0)),
                            0),
                    isDisplayed()));
    frameLayout.check(matches(isDisplayed()));

    ViewInteraction frameLayout2 = onView(
            allOf(withId(R.id.card),
                    childAtPosition(
                            allOf(withId(R.id.recordings_list),
                                    childAtPosition(
                                            withId(R.id.recordingsLL),
                                            0)),
                            1),
                    isDisplayed()));
    frameLayout2.check(matches(isDisplayed()));

    ViewInteraction frameLayout3 = onView(
            allOf(withId(R.id.card),
                    childAtPosition(
                            allOf(withId(R.id.recordings_list),
                                    childAtPosition(
                                            withId(R.id.recordingsLL),
                                            0)),
                            2),
                    isDisplayed()));
    frameLayout3.check(matches(isDisplayed()));
}
 
Example 7
Source File: AddApiaryTest.java    From go-bees with GNU General Public License v3.0 4 votes vote down vote up
@Test
public void addApiaryTest() {
    ViewInteraction floatingActionButton = onView(
            allOf(withId(R.id.fab_add_apiary),
                    withParent(withId(R.id.coordinatorLayout)),
                    isDisplayed()));
    floatingActionButton.perform(click());

    ViewInteraction appCompatEditText = onView(
            withId(R.id.add_apiary_name));
    appCompatEditText.perform(scrollTo(), click());

    ViewInteraction appCompatEditText2 = onView(
            withId(R.id.add_apiary_name));
    appCompatEditText2.perform(scrollTo(), replaceText("Apiary"), closeSoftKeyboard());

    ViewInteraction floatingActionButton2 = onView(
            allOf(withId(R.id.fab_add_apiary),
                    withParent(withId(R.id.coordinatorLayout)),
                    isDisplayed()));
    floatingActionButton2.perform(click());

    ViewInteraction textView = onView(
            allOf(withId(R.id.apiary_name), withText("Apiary"),
                    childAtPosition(
                            childAtPosition(
                                    withId(R.id.card),
                                    0),
                            1),
                    isDisplayed()));
    textView.check(matches(withText("Apiary")));

    ViewInteraction textView2 = onView(
            allOf(withId(R.id.num_hives), withText("0"),
                    childAtPosition(
                            childAtPosition(
                                    withId(R.id.card),
                                    0),
                            4),
                    isDisplayed()));
    textView2.check(matches(withText("0")));
}
 
Example 8
Source File: MainActivityTest.java    From YaMvp with MIT License 4 votes vote down vote up
@Test
public void mainActivityTest() throws Exception {
    ConditionWatcher.waitForCondition(new FragmentResumedInstruction());

    ViewInteraction textView = onView(
            allOf(withId(R.id.mVerifyResult), withText("invalid phone number"),
                    childAtPosition(
                            childAtPosition(
                                    withId(android.R.id.content),
                                    0),
                            1),
                    isDisplayed()));
    textView.check(matches(withText("invalid phone number")));

    ViewInteraction appCompatEditText = onView(
            allOf(withId(R.id.mEtPhone), isDisplayed()));
    appCompatEditText.perform(click());

    ViewInteraction appCompatEditText2 = onView(
            allOf(withId(R.id.mEtPhone), isDisplayed()));
    appCompatEditText2.perform(replaceText("+86"), closeSoftKeyboard());

    Thread.sleep(BuildConfig.TEST_WAIT_BEFORE_VERIFY);

    ViewInteraction textView2 = onView(
            allOf(withId(R.id.mVerifyResult), withText("invalid phone number"),
                    childAtPosition(
                            childAtPosition(
                                    withId(android.R.id.content),
                                    0),
                            1),
                    isDisplayed()));
    textView2.check(matches(withText("invalid phone number")));

    ViewInteraction appCompatEditText3 = onView(
            allOf(withId(R.id.mEtPhone), isDisplayed()));
    appCompatEditText3.perform(replaceText("+8613312345678"), closeSoftKeyboard());

    Thread.sleep(BuildConfig.TEST_WAIT_BEFORE_VERIFY);

    ViewInteraction textView3 = onView(
            allOf(withId(R.id.mVerifyResult), withText("valid phone number"),
                    childAtPosition(
                            childAtPosition(
                                    withId(android.R.id.content),
                                    0),
                            1),
                    isDisplayed()));
    textView3.check(matches(withText("valid phone number")));
}
 
Example 9
Source File: EditApiaryTest.java    From go-bees with GNU General Public License v3.0 4 votes vote down vote up
@Test
public void editApiaryTest() {
    ViewInteraction floatingActionButton = onView(
            allOf(withId(R.id.fab_add_apiary),
                    withParent(withId(R.id.coordinatorLayout)),
                    isDisplayed()));
    floatingActionButton.perform(click());

    ViewInteraction appCompatEditText = onView(
            withId(R.id.add_apiary_name));
    appCompatEditText.perform(scrollTo(), replaceText("Apiary"), closeSoftKeyboard());

    ViewInteraction floatingActionButton2 = onView(
            allOf(withId(R.id.fab_add_apiary),
                    withParent(withId(R.id.coordinatorLayout)),
                    isDisplayed()));
    floatingActionButton2.perform(click());

    ViewInteraction appCompatImageView = onView(
            allOf(withId(R.id.more_icon), withContentDescription("More…"), isDisplayed()));
    appCompatImageView.perform(click());

    ViewInteraction appCompatTextView = onView(
            allOf(withId(android.R.id.title), withText("Edit"), isDisplayed()));
    appCompatTextView.perform(click());

    ViewInteraction appCompatEditText2 = onView(
            allOf(withId(R.id.add_apiary_name), withText("Apiary")));
    appCompatEditText2.perform(scrollTo(), click());

    ViewInteraction appCompatEditText3 = onView(
            withId(R.id.add_apiary_name));
    appCompatEditText3.perform(scrollTo(), replaceText("Apiary Edited"), closeSoftKeyboard());

    ViewInteraction floatingActionButton3 = onView(
            allOf(withId(R.id.fab_add_apiary),
                    withParent(withId(R.id.coordinatorLayout)),
                    isDisplayed()));
    floatingActionButton3.perform(click());

    ViewInteraction textView = onView(
            allOf(withId(R.id.apiary_name), withText("Apiary Edited"),
                    childAtPosition(
                            childAtPosition(
                                    withId(R.id.card),
                                    0),
                            1),
                    isDisplayed()));
    textView.check(matches(withText("Apiary Edited")));

}
 
Example 10
Source File: ViewApiaryTest.java    From go-bees with GNU General Public License v3.0 4 votes vote down vote up
@Test
public void viewApiaryTest() {
    ViewInteraction floatingActionButton = onView(
            allOf(withId(R.id.fab_add_apiary),
                    withParent(withId(R.id.coordinatorLayout)),
                    isDisplayed()));
    floatingActionButton.perform(click());

    ViewInteraction appCompatEditText = onView(
            withId(R.id.add_apiary_name));
    appCompatEditText.perform(scrollTo(), replaceText("Apiary"), closeSoftKeyboard());

    ViewInteraction appCompatEditText2 = onView(
            withId(R.id.add_apiary_notes));
    appCompatEditText2.perform(scrollTo(), replaceText("Notes"), closeSoftKeyboard());

    ViewInteraction floatingActionButton2 = onView(
            allOf(withId(R.id.fab_add_apiary),
                    withParent(withId(R.id.coordinatorLayout)),
                    isDisplayed()));
    floatingActionButton2.perform(click());

    ViewInteraction recyclerView = onView(
            allOf(withId(R.id.apiaries_list),
                    withParent(allOf(withId(R.id.apiariesLL),
                            withParent(withId(R.id.apiariesContainer)))),
                    isDisplayed()));
    recyclerView.perform(actionOnItemAtPosition(0, click()));

    ViewInteraction textView = onView(
            withText("Apiary"));
    textView.check(matches(withText("Apiary")));

    ViewInteraction appCompatTextView = onView(
            allOf(withText("Info"), isDisplayed()));
    appCompatTextView.perform(click());

    ViewInteraction textView2 = onView(
            allOf(withId(R.id.notes_content), withText("Notes"),
                    childAtPosition(
                            childAtPosition(
                                    IsInstanceOf.<View>instanceOf(
                                            android.widget.LinearLayout.class), 1),
                            0),
                    isDisplayed()));
    textView2.check(matches(withText("Notes")));

}
 
Example 11
Source File: DeleteApiaryTest.java    From go-bees with GNU General Public License v3.0 4 votes vote down vote up
@Test
public void deleteApiaryTest() {
    ViewInteraction floatingActionButton = onView(
            allOf(withId(R.id.fab_add_apiary),
                    withParent(withId(R.id.coordinatorLayout)),
                    isDisplayed()));
    floatingActionButton.perform(click());

    ViewInteraction appCompatEditText = onView(
            withId(R.id.add_apiary_name));
    appCompatEditText.perform(scrollTo(), replaceText("Apiary"), closeSoftKeyboard());

    ViewInteraction floatingActionButton2 = onView(
            allOf(withId(R.id.fab_add_apiary),
                    withParent(withId(R.id.coordinatorLayout)),
                    isDisplayed()));
    floatingActionButton2.perform(click());

    ViewInteraction textView = onView(
            allOf(withId(R.id.apiary_name), withText("Apiary"),
                    childAtPosition(
                            childAtPosition(
                                    withId(R.id.card),
                                    0),
                            1),
                    isDisplayed()));
    textView.check(matches(withText("Apiary")));

    ViewInteraction appCompatImageView = onView(
            allOf(withId(R.id.more_icon), withContentDescription("More…"), isDisplayed()));
    appCompatImageView.perform(click());

    ViewInteraction appCompatTextView = onView(
            allOf(withId(android.R.id.title), withText("Delete"), isDisplayed()));
    appCompatTextView.perform(click());

    ViewInteraction frameLayout = onView(
            allOf(withId(R.id.card),
                    childAtPosition(
                            allOf(withId(R.id.apiaries_list),
                                    childAtPosition(
                                            withId(R.id.apiariesLL),
                                            0)),
                            0),
                    isDisplayed()));
    frameLayout.check(doesNotExist());

    ViewInteraction textView2 = onView(
            withId(R.id.no_apiaries_text));
    textView2.check(matches(isDisplayed()));

}
 
Example 12
Source File: AboutTest.java    From go-bees with GNU General Public License v3.0 4 votes vote down vote up
@Test
public void aboutTest() {
    ViewInteraction appCompatImageButton = onView(
            allOf(withContentDescription("Navigate up"),
                    withParent(withId(R.id.toolbar)),
                    isDisplayed()));
    appCompatImageButton.perform(click());

    ViewInteraction appCompatCheckedTextView = onView(
            allOf(withId(R.id.design_menu_item_text), withText("About GoBees"), isDisplayed()));
    appCompatCheckedTextView.perform(click());

    ViewInteraction textView = onView(
            allOf(withId(R.id.app_name), withText("GoBees App"),
                    childAtPosition(
                            allOf(withId(R.id.linear_layout),
                                    childAtPosition(
                                            withId(R.id.contentFrame),
                                            0)),
                            1),
                    isDisplayed()));
    textView.check(matches(withText("GoBees App")));

    ViewInteraction button = onView(
            allOf(withId(R.id.website_btn),
                    childAtPosition(
                            childAtPosition(
                                    withId(R.id.linear_layout),
                                    3),
                            0),
                    isDisplayed()));
    button.check(matches(isDisplayed()));

    ViewInteraction button2 = onView(
            allOf(withId(R.id.license_btn),
                    childAtPosition(
                            childAtPosition(
                                    withId(R.id.linear_layout),
                                    3),
                            1),
                    isDisplayed()));
    button2.check(matches(isDisplayed()));

    ViewInteraction button3 = onView(
            allOf(withId(R.id.changelog_btn),
                    childAtPosition(
                            childAtPosition(
                                    withId(R.id.linear_layout),
                                    3),
                            2),
                    isDisplayed()));
    button3.check(matches(isDisplayed()));
}
 
Example 13
Source File: AddRecordingTest.java    From go-bees with GNU General Public License v3.0 4 votes vote down vote up
@Test
public void addRecordingTest() {
    ViewInteraction floatingActionButton = onView(
            allOf(withId(R.id.fab_add_apiary),
                    withParent(withId(R.id.coordinatorLayout)),
                    isDisplayed()));
    floatingActionButton.perform(click());

    ViewInteraction appCompatEditText = onView(
            withId(R.id.add_apiary_name));
    appCompatEditText.perform(scrollTo(), replaceText("Apiary"), closeSoftKeyboard());

    ViewInteraction floatingActionButton2 = onView(
            allOf(withId(R.id.fab_add_apiary),
                    withParent(withId(R.id.coordinatorLayout)),
                    isDisplayed()));
    floatingActionButton2.perform(click());

    ViewInteraction recyclerView = onView(
            allOf(withId(R.id.apiaries_list),
                    withParent(allOf(withId(R.id.apiariesLL),
                            withParent(withId(R.id.apiariesContainer)))),
                    isDisplayed()));
    recyclerView.perform(actionOnItemAtPosition(0, click()));

    ViewInteraction floatingActionButton3 = onView(
            allOf(withId(R.id.fab_add_hive),
                    withParent(withId(R.id.coordinatorLayout)),
                    isDisplayed()));
    floatingActionButton3.perform(click());

    ViewInteraction appCompatEditText2 = onView(
            withId(R.id.add_hive_name));
    appCompatEditText2.perform(scrollTo(), replaceText("Hive"), closeSoftKeyboard());

    ViewInteraction floatingActionButton4 = onView(
            allOf(withId(R.id.fab_add_hive),
                    withParent(withId(R.id.coordinatorLayout)),
                    isDisplayed()));
    floatingActionButton4.perform(click());

    ViewInteraction recyclerView2 = onView(
            allOf(withId(R.id.hives_list),
                    withParent(allOf(withId(R.id.hivesLL),
                            withParent(withId(R.id.hivesContainer)))),
                    isDisplayed()));
    recyclerView2.perform(actionOnItemAtPosition(0, click()));

    ViewInteraction floatingActionButton5 = onView(
            allOf(withId(R.id.fab_new_recording),
                    withParent(withId(R.id.coordinatorLayout)),
                    isDisplayed()));
    floatingActionButton5.perform(click());

    ViewInteraction appCompatImageView = onView(
            withId(R.id.record_icon));
    appCompatImageView.perform(click());

    SystemClock.sleep(20000);

    ViewInteraction appCompatImageView2 = onView(
            withId(R.id.record_icon));
    appCompatImageView2.perform(click());

    ViewInteraction frameLayout = onView(
            allOf(withId(R.id.card),
                    childAtPosition(
                            allOf(withId(R.id.recordings_list),
                                    childAtPosition(
                                            withId(R.id.recordingsLL),
                                            0)),
                            0),
                    isDisplayed()));
    frameLayout.check(matches(isDisplayed()));
}
 
Example 14
Source File: ListHivesTest.java    From go-bees with GNU General Public License v3.0 4 votes vote down vote up
@Test
public void listHivesTest() {
    ViewInteraction floatingActionButton = onView(
            allOf(withId(R.id.fab_add_apiary),
                    withParent(withId(R.id.coordinatorLayout)),
                    isDisplayed()));
    floatingActionButton.perform(click());

    ViewInteraction appCompatEditText = onView(
            withId(R.id.add_apiary_name));
    appCompatEditText.perform(scrollTo(), replaceText("Apiary"), closeSoftKeyboard());

    ViewInteraction floatingActionButton2 = onView(
            allOf(withId(R.id.fab_add_apiary),
                    withParent(withId(R.id.coordinatorLayout)),
                    isDisplayed()));
    floatingActionButton2.perform(click());

    ViewInteraction recyclerView = onView(
            allOf(withId(R.id.apiaries_list),
                    withParent(allOf(withId(R.id.apiariesLL),
                            withParent(withId(R.id.apiariesContainer)))),
                    isDisplayed()));
    recyclerView.perform(actionOnItemAtPosition(0, click()));

    ViewInteraction floatingActionButton3 = onView(
            allOf(withId(R.id.fab_add_hive),
                    withParent(withId(R.id.coordinatorLayout)),
                    isDisplayed()));
    floatingActionButton3.perform(click());

    ViewInteraction appCompatEditText2 = onView(
            withId(R.id.add_hive_name));
    appCompatEditText2.perform(scrollTo(), replaceText("H1"), closeSoftKeyboard());

    ViewInteraction floatingActionButton4 = onView(
            allOf(withId(R.id.fab_add_hive),
                    withParent(withId(R.id.coordinatorLayout)),
                    isDisplayed()));
    floatingActionButton4.perform(click());

    ViewInteraction floatingActionButton5 = onView(
            allOf(withId(R.id.fab_add_hive),
                    withParent(withId(R.id.coordinatorLayout)),
                    isDisplayed()));
    floatingActionButton5.perform(click());

    ViewInteraction appCompatEditText3 = onView(
            withId(R.id.add_hive_name));
    appCompatEditText3.perform(scrollTo(), replaceText("H2"), closeSoftKeyboard());

    ViewInteraction floatingActionButton6 = onView(
            allOf(withId(R.id.fab_add_hive),
                    withParent(withId(R.id.coordinatorLayout)),
                    isDisplayed()));
    floatingActionButton6.perform(click());

    ViewInteraction floatingActionButton7 = onView(
            allOf(withId(R.id.fab_add_hive),
                    withParent(withId(R.id.coordinatorLayout)),
                    isDisplayed()));
    floatingActionButton7.perform(click());

    ViewInteraction appCompatEditText4 = onView(
            withId(R.id.add_hive_name));
    appCompatEditText4.perform(scrollTo(), replaceText("H3"), closeSoftKeyboard());

    ViewInteraction floatingActionButton8 = onView(
            allOf(withId(R.id.fab_add_hive),
                    withParent(withId(R.id.coordinatorLayout)),
                    isDisplayed()));
    floatingActionButton8.perform(click());

    ViewInteraction textView = onView(
            withText("H1"));
    textView.check(matches(isDisplayed()));
    textView = onView(
            withText("H2"));
    textView.check(matches(isDisplayed()));
    textView = onView(
            withText("H3"));
    textView.check(matches(isDisplayed()));
}
 
Example 15
Source File: DayNightModeTest.java    From Android-Developer-Fundamentals-Version-2 with GNU General Public License v3.0 4 votes vote down vote up
@Test
    public void dayNightModeTest() {
        openActionBarOverflowOrOptionsMenu(getInstrumentation().getTargetContext());
        
        ViewInteraction appCompatTextView = onView(
allOf(withId(R.id.title), withText("Night Mode"),
childAtPosition(
childAtPosition(
withId(R.id.content),
0),
0),
isDisplayed()));
        appCompatTextView.perform(click());
        
        openActionBarOverflowOrOptionsMenu(getInstrumentation().getTargetContext());
        
        ViewInteraction textView = onView(
allOf(withId(R.id.title), withText("Day Mode"),
childAtPosition(
childAtPosition(
withId(R.id.content),
0),
0),
isDisplayed()));
        textView.check(matches(withText("Day Mode")));
        
        ViewInteraction appCompatTextView2 = onView(
allOf(withId(R.id.title), withText("Day Mode"),
childAtPosition(
childAtPosition(
withId(R.id.content),
0),
0),
isDisplayed()));
        appCompatTextView2.perform(click());
        
        openActionBarOverflowOrOptionsMenu(getInstrumentation().getTargetContext());
        
        ViewInteraction textView2 = onView(
allOf(withId(R.id.title), withText("Night Mode"),
childAtPosition(
childAtPosition(
withId(R.id.content),
0),
0),
isDisplayed()));
        textView2.check(matches(withText("Night Mode")));
        }
 
Example 16
Source File: DeleteRecordingTest.java    From go-bees with GNU General Public License v3.0 4 votes vote down vote up
@Test
public void deleteRecordingTest() {
    ViewInteraction floatingActionButton = onView(
            allOf(withId(R.id.fab_add_apiary),
                    withParent(withId(R.id.coordinatorLayout)),
                    isDisplayed()));
    floatingActionButton.perform(click());

    ViewInteraction appCompatEditText = onView(
            withId(R.id.add_apiary_name));
    appCompatEditText.perform(scrollTo(), replaceText("Apiary"), closeSoftKeyboard());

    ViewInteraction floatingActionButton2 = onView(
            allOf(withId(R.id.fab_add_apiary),
                    withParent(withId(R.id.coordinatorLayout)),
                    isDisplayed()));
    floatingActionButton2.perform(click());

    ViewInteraction recyclerView = onView(
            allOf(withId(R.id.apiaries_list),
                    withParent(allOf(withId(R.id.apiariesLL),
                            withParent(withId(R.id.apiariesContainer)))),
                    isDisplayed()));
    recyclerView.perform(actionOnItemAtPosition(0, click()));

    ViewInteraction floatingActionButton3 = onView(
            allOf(withId(R.id.fab_add_hive),
                    withParent(withId(R.id.coordinatorLayout)),
                    isDisplayed()));
    floatingActionButton3.perform(click());

    ViewInteraction appCompatEditText2 = onView(
            withId(R.id.add_hive_name));
    appCompatEditText2.perform(scrollTo(), replaceText("Hive"), closeSoftKeyboard());

    ViewInteraction floatingActionButton4 = onView(
            allOf(withId(R.id.fab_add_hive),
                    withParent(withId(R.id.coordinatorLayout)),
                    isDisplayed()));
    floatingActionButton4.perform(click());

    ViewInteraction recyclerView2 = onView(
            allOf(withId(R.id.hives_list),
                    withParent(allOf(withId(R.id.hivesLL),
                            withParent(withId(R.id.hivesContainer)))),
                    isDisplayed()));
    recyclerView2.perform(actionOnItemAtPosition(0, click()));

    ViewInteraction floatingActionButton5 = onView(
            allOf(withId(R.id.fab_new_recording),
                    withParent(withId(R.id.coordinatorLayout)),
                    isDisplayed()));
    floatingActionButton5.perform(click());

    ViewInteraction appCompatImageView = onView(
            withId(R.id.record_icon));
    appCompatImageView.perform(click());

    SystemClock.sleep(20000);

    ViewInteraction appCompatImageView2 = onView(
            withId(R.id.record_icon));
    appCompatImageView2.perform(click());

    ViewInteraction appCompatImageView3 = onView(
            allOf(withId(R.id.more_icon), withContentDescription("More…"), isDisplayed()));
    appCompatImageView3.perform(click());

    ViewInteraction appCompatTextView = onView(
            allOf(withId(android.R.id.title), withText("Delete"), isDisplayed()));
    appCompatTextView.perform(click());

    ViewInteraction textView = onView(
            withId(R.id.no_recordings_text));
    textView.check(matches(isDisplayed()));
}
 
Example 17
Source File: SettingsTest.java    From go-bees with GNU General Public License v3.0 4 votes vote down vote up
@Test
public void settingsTest() {
    ViewInteraction appCompatImageButton = onView(
            allOf(withContentDescription("Navigate up"),
                    withParent(withId(R.id.toolbar)),
                    isDisplayed()));
    appCompatImageButton.perform(click());

    ViewInteraction appCompatCheckedTextView = onView(
            allOf(withId(R.id.design_menu_item_text), withText("Settings"), isDisplayed()));
    appCompatCheckedTextView.perform(click());

    ViewInteraction linearLayout = onView(
            allOf(childAtPosition(
                    withId(android.R.id.list),
                    1),
                    isDisplayed()));
    linearLayout.perform(click());

    ViewInteraction appCompatCheckedTextView2 = onView(
            allOf(withId(android.R.id.text1), withText("Metric (°C, km/h…)"),
                    childAtPosition(
                            allOf(withClassName(is(
                                    "com.android.internal.app." +
                                            "AlertController$RecycleListView")),
                                    withParent(withClassName(
                                            is("android.widget.FrameLayout")))),
                            0),
                    isDisplayed()));
    appCompatCheckedTextView2.perform(click());

    ViewInteraction textView = onView(
            withText("Metric (°C, km/h…)"));
    textView.check(matches(isDisplayed()));

    ViewInteraction linearLayout2 = onView(
            allOf(childAtPosition(
                    withId(android.R.id.list),
                    1),
                    isDisplayed()));
    linearLayout2.perform(click());

    ViewInteraction appCompatCheckedTextView3 = onView(
            allOf(withId(android.R.id.text1), withText("Imperial (°F, mph…)"),
                    childAtPosition(
                            allOf(withClassName(
                                    is("com.android.internal.app." +
                                            "AlertController$RecycleListView")),
                                    withParent(withClassName(
                                            is("android.widget.FrameLayout")))),
                            1),
                    isDisplayed()));
    appCompatCheckedTextView3.perform(click());

    textView = onView(
            withText("Imperial (°F, mph…)"));
    textView.check(matches(isDisplayed()));
}
 
Example 18
Source File: ViewHiveTest.java    From go-bees with GNU General Public License v3.0 4 votes vote down vote up
@Test
public void viewHiveTest() {
    ViewInteraction floatingActionButton = onView(
            allOf(withId(R.id.fab_add_apiary),
                    withParent(withId(R.id.coordinatorLayout)),
                    isDisplayed()));
    floatingActionButton.perform(click());

    ViewInteraction appCompatEditText = onView(
            withId(R.id.add_apiary_name));
    appCompatEditText.perform(scrollTo(), replaceText("Apiary"), closeSoftKeyboard());

    ViewInteraction floatingActionButton2 = onView(
            allOf(withId(R.id.fab_add_apiary),
                    withParent(withId(R.id.coordinatorLayout)),
                    isDisplayed()));
    floatingActionButton2.perform(click());

    ViewInteraction recyclerView = onView(
            allOf(withId(R.id.apiaries_list),
                    withParent(allOf(withId(R.id.apiariesLL),
                            withParent(withId(R.id.apiariesContainer)))),
                    isDisplayed()));
    recyclerView.perform(actionOnItemAtPosition(0, click()));

    ViewInteraction floatingActionButton3 = onView(
            allOf(withId(R.id.fab_add_hive),
                    withParent(withId(R.id.coordinatorLayout)),
                    isDisplayed()));
    floatingActionButton3.perform(click());

    ViewInteraction appCompatEditText2 = onView(
            withId(R.id.add_hive_name));
    appCompatEditText2.perform(scrollTo(), replaceText("Hive"), closeSoftKeyboard());

    ViewInteraction appCompatEditText3 = onView(
            withId(R.id.add_hive_notes));
    appCompatEditText3.perform(scrollTo(), replaceText("Notes"), closeSoftKeyboard());

    ViewInteraction floatingActionButton4 = onView(
            allOf(withId(R.id.fab_add_hive),
                    withParent(withId(R.id.coordinatorLayout)),
                    isDisplayed()));
    floatingActionButton4.perform(click());

    ViewInteraction recyclerView2 = onView(
            allOf(withId(R.id.hives_list),
                    withParent(allOf(withId(R.id.hivesLL),
                            withParent(withId(R.id.hivesContainer)))),
                    isDisplayed()));
    recyclerView2.perform(actionOnItemAtPosition(0, click()));

    ViewInteraction textView = onView(
            withText("Hive"));
    textView.check(matches(isDisplayed()));

    ViewInteraction appCompatTextView = onView(
            allOf(withText("Info"), isDisplayed()));
    appCompatTextView.perform(click());

    ViewInteraction textView2 = onView(
            allOf(withId(R.id.notes_content), withText("Notes"),
                    childAtPosition(
                            childAtPosition(
                                    IsInstanceOf.<View>instanceOf(
                                            android.widget.LinearLayout.class),
                                    1),
                            0),
                    isDisplayed()));
    textView2.check(matches(withText("Notes")));

}
 
Example 19
Source File: ScorePlusMinus.java    From Android-Developer-Fundamentals-Version-2 with GNU General Public License v3.0 4 votes vote down vote up
@Test
public void mainActivityTest() {
    ViewInteraction appCompatImageButton = onView(
            allOf(withId(R.id.increaseTeam1), withContentDescription("Plus Button"),
                    childAtPosition(
                            childAtPosition(
                                    withClassName(is("android.widget.LinearLayout")),
                                    0),
                            3),
                    isDisplayed()));
    appCompatImageButton.perform(click());

    ViewInteraction textView = onView(
            allOf(withId(R.id.score_1), withText("1"),
                    childAtPosition(
                            childAtPosition(
                                    IsInstanceOf.<View>instanceOf(android.widget.LinearLayout.class),
                                    0),
                            2),
                    isDisplayed()));
    textView.check(matches(withText("1")));

    ViewInteraction appCompatImageButton2 = onView(
            allOf(withId(R.id.decreaseTeam1), withContentDescription("Minus Button"),
                    childAtPosition(
                            childAtPosition(
                                    withClassName(is("android.widget.LinearLayout")),
                                    0),
                            1),
                    isDisplayed()));
    appCompatImageButton2.perform(click());

    ViewInteraction textView2 = onView(
            allOf(withId(R.id.score_1), withText("0"),
                    childAtPosition(
                            childAtPosition(
                                    IsInstanceOf.<View>instanceOf(android.widget.LinearLayout.class),
                                    0),
                            2),
                    isDisplayed()));
    textView2.check(matches(withText("0")));
}
 
Example 20
Source File: EditHiveTest.java    From go-bees with GNU General Public License v3.0 4 votes vote down vote up
@Test
public void editHiveTest() {
    ViewInteraction floatingActionButton = onView(
            allOf(withId(R.id.fab_add_apiary),
                    withParent(withId(R.id.coordinatorLayout)),
                    isDisplayed()));
    floatingActionButton.perform(click());

    ViewInteraction appCompatEditText = onView(
            withId(R.id.add_apiary_name));
    appCompatEditText.perform(scrollTo(), replaceText("Apiary"), closeSoftKeyboard());

    ViewInteraction floatingActionButton2 = onView(
            allOf(withId(R.id.fab_add_apiary),
                    withParent(withId(R.id.coordinatorLayout)),
                    isDisplayed()));
    floatingActionButton2.perform(click());

    ViewInteraction recyclerView = onView(
            allOf(withId(R.id.apiaries_list),
                    withParent(allOf(withId(R.id.apiariesLL),
                            withParent(withId(R.id.apiariesContainer)))),
                    isDisplayed()));
    recyclerView.perform(actionOnItemAtPosition(0, click()));

    ViewInteraction floatingActionButton3 = onView(
            allOf(withId(R.id.fab_add_hive),
                    withParent(withId(R.id.coordinatorLayout)),
                    isDisplayed()));
    floatingActionButton3.perform(click());

    ViewInteraction appCompatEditText2 = onView(
            withId(R.id.add_hive_name));
    appCompatEditText2.perform(scrollTo(), replaceText("Hive"), closeSoftKeyboard());

    ViewInteraction floatingActionButton4 = onView(
            allOf(withId(R.id.fab_add_hive),
                    withParent(withId(R.id.coordinatorLayout)),
                    isDisplayed()));
    floatingActionButton4.perform(click());

    ViewInteraction appCompatImageView = onView(
            allOf(withId(R.id.more_icon), withContentDescription("More…"), isDisplayed()));
    appCompatImageView.perform(click());

    ViewInteraction appCompatTextView = onView(
            allOf(withId(android.R.id.title), withText("Edit"), isDisplayed()));
    appCompatTextView.perform(click());

    ViewInteraction appCompatEditText3 = onView(
            allOf(withId(R.id.add_hive_name), withText("Hive")));
    appCompatEditText3.perform(scrollTo(), click());

    ViewInteraction appCompatEditText4 = onView(
            withId(R.id.add_hive_name));
    appCompatEditText4.perform(scrollTo(), replaceText("Hive Edited"), closeSoftKeyboard());

    ViewInteraction floatingActionButton5 = onView(
            allOf(withId(R.id.fab_add_hive),
                    withParent(withId(R.id.coordinatorLayout)),
                    isDisplayed()));
    floatingActionButton5.perform(click());

    ViewInteraction textView = onView(
            allOf(withId(R.id.hive_name), withText("Hive Edited"),
                    childAtPosition(
                            childAtPosition(
                                    withId(R.id.card),
                                    0),
                            1),
                    isDisplayed()));
    textView.check(matches(withText("Hive Edited")));

}