本文整理汇总了Java中com.google.android.apps.common.testing.ui.espresso.NoMatchingViewException类的典型用法代码示例。如果您正苦于以下问题:Java NoMatchingViewException类的具体用法?Java NoMatchingViewException怎么用?Java NoMatchingViewException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NoMatchingViewException类属于com.google.android.apps.common.testing.ui.espresso包,在下文中一共展示了NoMatchingViewException类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: matches
import com.google.android.apps.common.testing.ui.espresso.NoMatchingViewException; //导入依赖的package包/类
/**
* Returns a generic {@link ViewAssertion} that asserts that a view exists in the view hierarchy
* and is matched by the given view matcher.
*/
public static ViewAssertion matches(final Matcher<? super View> viewMatcher) {
checkNotNull(viewMatcher);
return new ViewAssertion() {
@Override
public void check(Optional<View> view, Optional<NoMatchingViewException> noViewException) {
StringDescription description = new StringDescription();
description.appendText("'");
viewMatcher.describeTo(description);
if (noViewException.isPresent()) {
description.appendText(String.format(
"' check could not be performed because view '%s' was not found.\n", viewMatcher));
Log.e(TAG, description.toString());
throw noViewException.get();
} else {
// TODO(user): ideally, we should append the matcher used to find the view
// This can be done in DefaultFailureHandler (just like we currently to with
// PerformException)
description.appendText("' doesn't match the selected view.");
assertThat(description.toString(), view.get(), viewMatcher);
}
}
};
}
示例2: pressCancelButton
import com.google.android.apps.common.testing.ui.espresso.NoMatchingViewException; //导入依赖的package包/类
public RecorderWindowPage pressCancelButton(){
try {
onLimeLightView(R.id.cancel)
.perform(click());
} catch (NoMatchingViewException ex){
Assert.fail("Cancel button was not found. Did you press the 'edit' button before pressing the Act?");
}
return new RecorderWindowPage(getTestCase());
}
示例3: pressSaveButton
import com.google.android.apps.common.testing.ui.espresso.NoMatchingViewException; //导入依赖的package包/类
public RecorderWindowPage pressSaveButton(){
try {
onLimeLightView(R.id.save)
.perform(click());
} catch (NoMatchingViewException ex){
Assert.fail("Save button was not found. Did you press the 'edit' button before pressing the Act?");
}
return new RecorderWindowPage(getTestCase());
}
示例4: pressNextArrow
import com.google.android.apps.common.testing.ui.espresso.NoMatchingViewException; //导入依赖的package包/类
public ActEditorPage pressNextArrow(){
try {
onLimeLightView(R.id.next_menu)
.perform(click());
} catch (NoMatchingViewException ex){
Assert.fail("Next arrow was not found. Did you press the 'edit' button before pressing the Act?");
}
return this;
}
示例5: pressPreviousArrow
import com.google.android.apps.common.testing.ui.espresso.NoMatchingViewException; //导入依赖的package包/类
public ActEditorPage pressPreviousArrow(){
try {
onLimeLightView(R.id.previous_menu)
.perform(click());
} catch (NoMatchingViewException ex){
Assert.fail("Next arrow was not found. Did you press the 'edit' button before pressing the Act?");
}
return this;
}
示例6: handle
import com.google.android.apps.common.testing.ui.espresso.NoMatchingViewException; //导入依赖的package包/类
@Override
public void handle(Throwable error, Matcher<View> viewMatcher) {
try {
delegate.handle(error, viewMatcher);
} catch (NoMatchingViewException e) {
throw new MySpecialException(e);
}
}
示例7: doesNotExist
import com.google.android.apps.common.testing.ui.espresso.NoMatchingViewException; //导入依赖的package包/类
/**
* Returns an assert that ensures the view matcher does not find any matching view in the
* hierarchy.
*/
public static ViewAssertion doesNotExist() {
return new ViewAssertion() {
@Override
public void check(Optional<View> view, Optional<NoMatchingViewException> noView) {
if (view.isPresent()) {
assertThat("View is present in the hierarchy: " + HumanReadables.describe(view.get()),
true, is(false));
}
}
};
}
示例8: selectedDescendantsMatch
import com.google.android.apps.common.testing.ui.espresso.NoMatchingViewException; //导入依赖的package包/类
/**
* Returns a generic {@link ViewAssertion} that asserts that the descendant views selected by the
* selector match the specified matcher.
*
* Example: onView(rootView).check(selectedDescendantsMatch(
* not(isAssignableFrom(TextView.class)), hasContentDescription()));
*/
public static ViewAssertion selectedDescendantsMatch(
final Matcher<View> selector, final Matcher<View> matcher) {
return new ViewAssertion() {
@SuppressWarnings("unchecked")
@Override
public void check(Optional<View> view, Optional<NoMatchingViewException> noViewException) {
Preconditions.checkArgument(view.isPresent());
View rootView = view.get();
final Predicate<View> viewPredicate = new Predicate<View>() {
@Override
public boolean apply(View input) {
return selector.matches(input);
}
};
Iterator<View> selectedViewIterator =
Iterables.filter(breadthFirstViewTraversal(rootView), viewPredicate).iterator();
List<View> nonMatchingViews = new ArrayList<View>();
while (selectedViewIterator.hasNext()) {
View selectedView = selectedViewIterator.next();
if (!matcher.matches(selectedView)) {
nonMatchingViews.add(selectedView);
}
}
if (nonMatchingViews.size() > 0) {
String errorMessage = HumanReadables.getViewHierarchyErrorMessage(Collections.singletonList(rootView),
Optional.of(nonMatchingViews),
String.format("At least one view did not match the required matcher: %s", matcher),
Optional.of("****DOES NOT MATCH****"));
throw new AssertionFailedError(errorMessage);
}
}
};
}
示例9: testCustomAssertionError
import com.google.android.apps.common.testing.ui.espresso.NoMatchingViewException; //导入依赖的package包/类
public void testCustomAssertionError() {
try {
onView(isRoot()).check(new ViewAssertion() {
@Override
public void check(
Optional<View> view, Optional<NoMatchingViewException> noViewFoundException) {
assertFalse(true);
}
});
fail("Previous call expected to fail");
} catch (AssertionFailedError e) {
assertFailureStackContainsThisClass(e);
}
}
示例10: testNoMatchingViewException
import com.google.android.apps.common.testing.ui.espresso.NoMatchingViewException; //导入依赖的package包/类
public void testNoMatchingViewException() {
try {
onView(withMatchesThatReturns(false)).check(matches(not(isDisplayed())));
fail("Previous call expected to fail");
} catch (NoMatchingViewException e) {
assertFailureStackContainsThisClass(e);
}
}
示例11: testGetView_missing
import com.google.android.apps.common.testing.ui.espresso.NoMatchingViewException; //导入依赖的package包/类
@UiThreadTest
public void testGetView_missing() {
ViewFinder finder = new ViewFinderImpl(Matchers.<View>nullValue(), testViewProvider);
try {
finder.getView();
fail("No children should pass that matcher!");
} catch (NoMatchingViewException expected) {}
}
示例12: setUp
import com.google.android.apps.common.testing.ui.espresso.NoMatchingViewException; //导入依赖的package包/类
@Override
public void setUp() throws Exception {
super.setUp();
presentView = Optional.of(new View(getInstrumentation().getTargetContext()));
absentView = Optional.absent();
absentException = Optional.absent();
alwaysAccepts = is(presentView.get());
alwaysFails = not(is(presentView.get()));
nullViewMatcher = nullValue();
presentException = Optional.of(new NoMatchingViewException.Builder()
.withViewMatcher(alwaysFails)
.withRootView(new View(getInstrumentation().getTargetContext()))
.build());
}
示例13: testViewAbsent_Unexpectedly
import com.google.android.apps.common.testing.ui.espresso.NoMatchingViewException; //导入依赖的package包/类
public void testViewAbsent_Unexpectedly() {
try {
matches(alwaysAccepts).check(absentView, presentException);
} catch (NoMatchingViewException expected) {
return;
}
fail("should not accept, view not present.");
}
示例14: testViewAbsent_AndThatsWhatIWant
import com.google.android.apps.common.testing.ui.espresso.NoMatchingViewException; //导入依赖的package包/类
public void testViewAbsent_AndThatsWhatIWant() {
try {
matches(nullViewMatcher).check(absentView, presentException);
} catch (NoMatchingViewException expected) {
return;
}
fail("should not accept, view not present.");
}