當前位置: 首頁>>代碼示例>>Java>>正文


Java NoMatchingViewException類代碼示例

本文整理匯總了Java中android.support.test.espresso.NoMatchingViewException的典型用法代碼示例。如果您正苦於以下問題:Java NoMatchingViewException類的具體用法?Java NoMatchingViewException怎麽用?Java NoMatchingViewException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


NoMatchingViewException類屬於android.support.test.espresso包,在下文中一共展示了NoMatchingViewException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: searchCityAndClick

import android.support.test.espresso.NoMatchingViewException; //導入依賴的package包/類
@Test
    public void searchCityAndClick() throws Exception {
        List<Election> unfilteredList = electionActivity.getAdapter().getList();

        onView(withId(R.id.search)).perform(click());

        final Election toClick = unfilteredList.get(0);
        onView(withId(android.support.design.R.id.search_src_text)).perform(typeText(toClick.getPlace()));

        onView (withId (R.id.election_list)).check (ViewAssertions.matches (new Matchers().withListSize (1)));

        onData(instanceOf(Election.class))
                .inAdapterView(withId(R.id.election_list))
                .atPosition(0)
                .perform(click());
//        intended(hasComponent(MainActivity.class.getName()));
        onView(withId(R.id.app_bar)).check(new ViewAssertion() {
            @Override
            public void check(View view, NoMatchingViewException noViewFoundException) {
                assertEquals(((Toolbar) view).getTitle(), toClick.getKind());
                assertEquals(((Toolbar) view).getSubtitle(), toClick.getPlace());
            }
        });
    }
 
開發者ID:digital-voting-pass,項目名稱:polling-station-app,代碼行數:25,代碼來源:TestElectionChoice.java

示例2: hasHolderItem

import android.support.test.espresso.NoMatchingViewException; //導入依賴的package包/類
@NonNull
public static ViewAssertion hasHolderItem(final Matcher<RecyclerView.ViewHolder> viewHolderMatcher) {
	return new ViewAssertion() {
		@Override public void check(View view, NoMatchingViewException e) {
			if (!(view instanceof RecyclerView)) {
				throw e;
			}

			boolean hasMatch = false;
			RecyclerView rv = (RecyclerView) view;
			for (int i = 0; i < rv.getChildCount(); i++) {
				RecyclerView.ViewHolder vh = rv.findViewHolderForAdapterPosition(i);
				hasMatch |= viewHolderMatcher.matches(vh);
			}
			Assert.assertTrue(hasMatch);
		}
	};
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:19,代碼來源:ConnectbotMatchers.java

示例3: testAutoFocus

import android.support.test.espresso.NoMatchingViewException; //導入依賴的package包/類
@Test
public void testAutoFocus() {
    onView(withId(R.id.camera))
            .check(new ViewAssertion() {
                @Override
                public void check(View view, NoMatchingViewException noViewFoundException) {
                    CameraView cameraView = (CameraView) view;
                    // This can fail on devices without auto-focus support
                    assertThat(cameraView.getAutoFocus(), is(true));
                    cameraView.setAutoFocus(false);
                    assertThat(cameraView.getAutoFocus(), is(false));
                    cameraView.setAutoFocus(true);
                    assertThat(cameraView.getAutoFocus(), is(true));
                }
            });
}
 
開發者ID:vshkl,項目名稱:PXLSRT,代碼行數:17,代碼來源:CameraViewTest.java

示例4: showingPreview

import android.support.test.espresso.NoMatchingViewException; //導入依賴的package包/類
private static ViewAssertion showingPreview() {
    return new ViewAssertion() {
        @Override
        public void check(View view, NoMatchingViewException noViewFoundException) {
            if (android.os.Build.VERSION.SDK_INT < 14) {
                return;
            }
            CameraView cameraView = (CameraView) view;
            TextureView textureView = (TextureView) cameraView.findViewById(R.id.texture_view);
            Bitmap bitmap = textureView.getBitmap();
            int topLeft = bitmap.getPixel(0, 0);
            int center = bitmap.getPixel(bitmap.getWidth() / 2, bitmap.getHeight() / 2);
            int bottomRight = bitmap.getPixel(
                    bitmap.getWidth() - 1, bitmap.getHeight() - 1);
            assertFalse("Preview possibly blank: " + Integer.toHexString(topLeft),
                    topLeft == center && center == bottomRight);
        }
    };
}
 
開發者ID:vshkl,項目名稱:PXLSRT,代碼行數:20,代碼來源:CameraViewTest.java

示例5: performAction

import android.support.test.espresso.NoMatchingViewException; //導入依賴的package包/類
public Act performAction(Act origin) throws NoViewEnabledException {

        Act performedAction = null;

        for(ViewManager.ViewTarget target: getTargets(origin)) {
             try {
                 performedAction = performAction(origin, target);
                 if (performedAction != null) {
                     return performedAction;
                 }
             } catch (NoMatchingViewException e) {
                 Log.i(tag("performAction"),"Attempted " + target.toString() + " and failed: " + e.toString());
             }
        }

        Log.e(tag("performAction"),"Exhausted all action targets.");

        throw new NoViewEnabledException(tag("performAction") + ": exhausted all action targets");

    }
 
開發者ID:cuplv,項目名稱:ChimpCheck,代碼行數:21,代碼來源:Performer.java

示例6: clickOnElection

import android.support.test.espresso.NoMatchingViewException; //導入依賴的package包/類
@Test
    public void clickOnElection() throws Exception {
        final Election e = electionActivity.getAdapter().getItem(1);

        onData(instanceOf(Election.class)) // We are using the position so don't need to specify a data matcher
                .inAdapterView(withId(R.id.election_list)) // Specify the explicit id of the ListView
                .atPosition(1) // Explicitly specify the adapter item to use
                .perform(click());
//        intended(hasComponent(MainActivity.class.getName()));
        onView(withId(R.id.app_bar)).check(new ViewAssertion() {
            @Override
            public void check(View view, NoMatchingViewException noViewFoundException) {
                assertEquals(((Toolbar) view).getTitle(), e.getKind());
                assertEquals(((Toolbar) view).getSubtitle(), e.getPlace());
            }
        });
    }
 
開發者ID:digital-voting-pass,項目名稱:polling-station-app,代碼行數:18,代碼來源:TestElectionChoice.java

示例7: checkToolbar

import android.support.test.espresso.NoMatchingViewException; //導入依賴的package包/類
@Test
public void checkToolbar() throws Exception {
    //Test with the string title
    mTestActivity.runOnUiThread(() -> mTestActivity.setToolbar(R.id.toolbar, ACTIVITY_TITLE, true));
    CustomMatchers.matchToolbarTitle(ACTIVITY_TITLE).check(matches(isDisplayed()));
    Espresso.onView(withContentDescription("Navigate up")).check(matches(isDisplayed()));

    //Test with the string resource title
    mTestActivity.runOnUiThread(() -> mTestActivity.setToolbar(R.id.toolbar, R.string.app_name, true));
    CustomMatchers.matchToolbarTitle(mTestActivity.getString(R.string.app_name)).check(matches(isDisplayed()));
    Espresso.onView(withContentDescription("Navigate up")).check(matches(isDisplayed()));

    //Hide home button
    mTestActivity.runOnUiThread(() -> mTestActivity.setToolbar(R.id.toolbar, ACTIVITY_TITLE, false));
    try {
        Espresso.onView(withContentDescription("Navigate up")).perform(click());
        Assert.fail();
    } catch (NoMatchingViewException e) {
        //Pass
    }
}
 
開發者ID:kevalpatel2106,項目名稱:smart-lens,代碼行數:22,代碼來源:BaseActivityTest.java

示例8: encrypt

import android.support.test.espresso.NoMatchingViewException; //導入依賴的package包/類
private String encrypt(String text) throws InterruptedException {
    final String[] result = new String[1];

    onView(withId(R.id.editText4)).perform(scrollTo(), replaceText(text), closeSoftKeyboard());
    onView(allOf(withId(R.id.button2), withText("Encrypt"))).perform(scrollTo(), click());
    onView(withId(R.id.editText5)).check(new ViewAssertion() {
        @Override
        public void check(View view, NoMatchingViewException noViewFoundException) {
            result[0] = String.valueOf(((EditText) view).getText());
        }
    });
    onView(allOf(withId(R.id.button3), withText("Test Decrypt"))).perform(scrollTo(), click());
    onView(withId(R.id.textView5)).check(matches(withText(text)));
    onView(allOf(withId(R.id.button4), withText("Copy"))).perform(scrollTo(), click());

    return result[0];
}
 
開發者ID:tresorit,項目名稱:ZeroKit-Android-SDK,代碼行數:18,代碼來源:SampleAppTest.java

示例9: addContact

import android.support.test.espresso.NoMatchingViewException; //導入依賴的package包/類
@Test
public void addContact() throws Exception {
    onView(withId(R.id.action_add_friends)).perform(click());
    onView(withId(R.id.add_username)).check(matches(isDisplayed()));

    onView(withId(R.id.add_username)).perform(clearText(), typeText("tes"));
    onView(withText(mActivityRule.getActivity().getString(R.string.add))).perform(click());
    onView(withId(R.id.add_friend_status)).check(matches(isDisplayed()));

    onView(withText(mActivityRule.getActivity().getString(R.string.cancel))).perform(click());
    // expecting to fail as view doesn't exist
    try {
        onView(withId(R.id.add_username)).check(matches(isDisplayed()));
    } catch (NoMatchingViewException e) {
        return;
    }
    assertTrue(false);
}
 
開發者ID:Q115,項目名稱:Goalie_Android,代碼行數:19,代碼來源:FriendActivityInstrumentedTest.java

示例10: noDecksMessageShown

import android.support.test.espresso.NoMatchingViewException; //導入依賴的package包/類
@Test
public void noDecksMessageShown() {
    waitView(() -> onView(withId(R.id.fab)).check(matches(isDisplayed())));

    // Delete all existing decks.
    try {
        while (true) {
            onView(first(withId(R.id.deck_popup_menu))).perform(click());
            deleteSelectedDeck();
        }
    } catch (NoMatchingViewException e) {
        // Finished deleting all decks.
    }

    waitView(() -> onView(allOf(withId(R.id.empty_recyclerview_message),
            withText(R.string.empty_decks_message))).check(matches(isDisplayed())));
}
 
開發者ID:dasfoo,項目名稱:delern,代碼行數:18,代碼來源:DeckOperationsTest.java

示例11: assertExist

import android.support.test.espresso.NoMatchingViewException; //導入依賴的package包/類
/**
 * Check that this item exist.
 *
 * Is true when adapter has matching item ignores the display state.
 *
 * @since Espresso Macchiato 0.6
 */

public void assertExist() {
    findRecyclerView().check(new ViewAssertion() {
        @Override
        public void check(View view, NoMatchingViewException noViewFoundException) {
            if (noViewFoundException != null) {
                throw noViewFoundException;
            }

            RecyclerView recyclerView = (RecyclerView) view;
            if (index >= recyclerView.getAdapter().getItemCount()) {
                throw new AssertionFailedError("Requested item should exist.");
            }
        }
    });
}
 
開發者ID:nenick,項目名稱:espresso-macchiato,代碼行數:24,代碼來源:EspRecyclerViewItem.java

示例12: check

import android.support.test.espresso.NoMatchingViewException; //導入依賴的package包/類
@Override
public void check(View view, NoMatchingViewException noViewFoundException) {
    if (noViewFoundException != null) {
        throw noViewFoundException;
    }

    RecyclerView recyclerView = (RecyclerView) view;
    if (recyclerView.getLayoutManager() instanceof GridLayoutManager) {
        GridLayoutManager gridLayoutManager = (GridLayoutManager) recyclerView.getLayoutManager();
        int spanCount = gridLayoutManager.getSpanCount();
        if (spanCount != expectedColumnCount) {
            String errorMessage = "expected column count " + expectedColumnCount
                    + " but was " + spanCount;
            throw new AssertionError(errorMessage);
        }
    } else {
        throw new IllegalStateException("no grid layout manager");
    }
}
 
開發者ID:nenick,項目名稱:espresso-macchiato,代碼行數:20,代碼來源:GridLayoutManagerColumnCountAssertion.java

示例13: check

import android.support.test.espresso.NoMatchingViewException; //導入依賴的package包/類
@Override
public void check(View view, NoMatchingViewException noViewFoundException) {
    if (noViewFoundException != null) {
        throw noViewFoundException;
    }

    RecyclerView recyclerView = (RecyclerView) view;
    if (recyclerView.getLayoutManager() instanceof LinearLayoutManager) {
        LinearLayoutManager layoutManager = (LinearLayoutManager) recyclerView.getLayoutManager();
        int firstVisibleItem = layoutManager.findFirstVisibleItemPosition();
        int lastVisibleItem = layoutManager.findLastVisibleItemPosition();

        boolean indexInRange = firstVisibleItem <= index && index <= lastVisibleItem;
        if ((shouldBeVisible && !indexInRange) || (!shouldBeVisible && indexInRange)) {
            String errorMessage = "expected item " + index + " to " +
                    (shouldBeVisible ? "" : "not") + " be visible, but was" +
                    (indexInRange ? "" : " not") + " visible";
            throw new AssertionError(errorMessage);

        }
    }
}
 
開發者ID:nenick,項目名稱:espresso-macchiato,代碼行數:23,代碼來源:LayoutManagerItemVisibilityAssertion.java

示例14: testAutoFocus

import android.support.test.espresso.NoMatchingViewException; //導入依賴的package包/類
@Test
public void testAutoFocus() {
    onView(withId(com.google.android.cameraview.test.R.id.camera))
            .check(new ViewAssertion() {
                @Override
                public void check(View view, NoMatchingViewException noViewFoundException) {
                    CameraView cameraView = (CameraView) view;
                    // This can fail on devices without auto-focus support
                    assertThat(cameraView.getAutoFocus(), is(true));
                    cameraView.setAutoFocus(false);
                    assertThat(cameraView.getAutoFocus(), is(false));
                    cameraView.setAutoFocus(true);
                    assertThat(cameraView.getAutoFocus(), is(true));
                }
            });
}
 
開發者ID:TheAndroidMaster,項目名稱:SimpleCamera,代碼行數:17,代碼來源:CameraViewTest.java

示例15: showingPreview

import android.support.test.espresso.NoMatchingViewException; //導入依賴的package包/類
private static ViewAssertion showingPreview() {
    return new ViewAssertion() {
        @Override
        public void check(View view, NoMatchingViewException noViewFoundException) {
            if (android.os.Build.VERSION.SDK_INT < 14) {
                return;
            }
            CameraView cameraView = (CameraView) view;
            TextureView textureView = (TextureView) cameraView.findViewById(com.google.android.cameraview.test.R.id.texture_view);
            Bitmap bitmap = textureView.getBitmap();
            int topLeft = bitmap.getPixel(0, 0);
            int center = bitmap.getPixel(bitmap.getWidth() / 2, bitmap.getHeight() / 2);
            int bottomRight = bitmap.getPixel(
                    bitmap.getWidth() - 1, bitmap.getHeight() - 1);
            assertFalse("Preview possibly blank: " + Integer.toHexString(topLeft),
                    topLeft == center && center == bottomRight);
        }
    };
}
 
開發者ID:TheAndroidMaster,項目名稱:SimpleCamera,代碼行數:20,代碼來源:CameraViewTest.java


注:本文中的android.support.test.espresso.NoMatchingViewException類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。