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


Java ViewAction类代码示例

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


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

示例1: clickNoConstraints

import android.support.test.espresso.ViewAction; //导入依赖的package包/类
static ViewAction clickNoConstraints() {
    return new ViewAction() {
        @Override
        public Matcher<View> getConstraints() {
            return isEnabled(); // No constraints, isEnabled and isClickable are checked
        }

        @Override
        public String getDescription() {
            return "Click a view with no constraints.";
        }

        @Override
        public void perform(UiController uiController, View view) {
            view.performClick();
        }
    };
}
 
开发者ID:dev-labs-bg,项目名称:fullscreen-video-view,代码行数:19,代码来源:CustomChecks.java

示例2: clickChildViewWithId

import android.support.test.espresso.ViewAction; //导入依赖的package包/类
public static ViewAction clickChildViewWithId(final int id) {
    return new ViewAction() {
        @Override
        public Matcher<View> getConstraints() {
            return null;
        }

        @Override
        public String getDescription() {
            return "Click on a child view with specified id.";
        }

        @Override
        public void perform(UiController uiController, View view) {
            View v = view.findViewById(id);
            v.performClick();
        }
    };
}
 
开发者ID:hernandazevedo,项目名称:starwarsshop,代码行数:20,代码来源:MyViewAction.java

示例3: closeSoftKeyboard

import android.support.test.espresso.ViewAction; //导入依赖的package包/类
public static ViewAction closeSoftKeyboard() {
	return new ViewAction() {
		/**
		 * The real {@link CloseKeyboardAction} instance.
		 */
		private final ViewAction mCloseSoftKeyboard = new CloseKeyboardAction();

		@Override
		public Matcher<View> getConstraints() {
			return mCloseSoftKeyboard.getConstraints();
		}

		@Override
		public String getDescription() {
			return mCloseSoftKeyboard.getDescription();
		}

		@Override
		public void perform(final UiController uiController, final View view) {
			mCloseSoftKeyboard.perform(uiController, view);
			uiController.loopMainThreadForAtLeast(KEYBOARD_DISMISSAL_DELAY_MILLIS);
		}
	};
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:25,代码来源:StartupTest.java

示例4: loopMainThreadFor

import android.support.test.espresso.ViewAction; //导入依赖的package包/类
public static ViewAction loopMainThreadFor(final long millis) {
	return new ViewAction() {

		@Override
		public Matcher<View> getConstraints() {
			return isEnabled();
		}

		@Override
		public String getDescription() {
			return "Rturns an action that loops the main thread for at least " + millis +"ms.";
		}

		@Override
		public void perform(final UiController uiController, final View view) {
			uiController.loopMainThreadForAtLeast(millis);
		}
	};
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:StartupTest.java

示例5: fillEntropy

import android.support.test.espresso.ViewAction; //导入依赖的package包/类
private ViewAction fillEntropy() {
	return new ViewAction() {
		@Override
		public Matcher<View> getConstraints() {
			return allOf(isDisplayed(), isAssignableFrom(EntropyView.class));
		}

		@Override
		public String getDescription() {
			return "Dismisses the 'Gathering entropy...' dialog";
		}

		@Override
		public void perform(final UiController uiController, final View view) {
			((EntropyView) view).notifyListeners();
		}
	};
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:PubkeyListActivityTest.java

示例6: clickDescendantViewWithId

import android.support.test.espresso.ViewAction; //导入依赖的package包/类
/**
 * Returns an action that clicks a descendant of the view matched with the given resource id.
 *
 * @param id resource id of the view to click.
 * @return an action that clicks a descendant of the view matched with the given resource id.
 */
public static ViewAction clickDescendantViewWithId(@IdRes final int id) {
    return new ViewAction() {

        @Override
        public Matcher<View> getConstraints() {
            return hasDescendant(withId(id));
        }

        @Override
        public String getDescription() {
            return "Click on a descendant view with id: " + id;
        }

        @Override
        public void perform(UiController uiController, View view) {
            GeneralClickAction action = new GeneralClickAction(Tap.SINGLE, GeneralLocation.VISIBLE_CENTER, Press.FINGER);
            View target = view.findViewById(id);
            // getConstraints() guarantees that the target never be null.
            action.perform(uiController, target);
        }
    };
}
 
开发者ID:sumio,项目名称:espresso-commons,代码行数:29,代码来源:RecyclerViewUtils.java

示例7: showControls

import android.support.test.espresso.ViewAction; //导入依赖的package包/类
private static ViewAction showControls() {
    return new ViewAction() {
        @Override
        public Matcher<View> getConstraints() {
            return isAssignableFrom(MovieView.class);
        }

        @Override
        public String getDescription() {
            return "Show controls of MovieView";
        }

        @Override
        public void perform(UiController uiController, View view) {
            uiController.loopMainThreadUntilIdle();
            ((MovieView) view).showControls();
            uiController.loopMainThreadUntilIdle();
        }
    };
}
 
开发者ID:googlesamples,项目名称:android-PictureInPicture,代码行数:21,代码来源:MediaSessionPlaybackActivityTest.java

示例8: withCustomConstraints

import android.support.test.espresso.ViewAction; //导入依赖的package包/类
/**
 * From: http://stackoverflow.com/questions/33505953/espresso-how-to-test-swiperefreshlayout/33516360#33516360
 * <p>
 * ViewPager will throw an error if not 90% of it is displayed. This reduces the restriction.
 *
 * @param action      Action to be done.
 * @param constraints Restrictions on the view.
 * @return Performs an action on the view.
 */
public static ViewAction withCustomConstraints(final ViewAction action, final Matcher<View> constraints)
{
    return new ViewAction()
    {
        @Override
        public Matcher<View> getConstraints()
        {
            return constraints;
        }

        @Override
        public String getDescription()
        {
            return action.getDescription();
        }

        @Override
        public void perform(UiController uiController, View view)
        {
            action.perform(uiController, view);
        }
    };
}
 
开发者ID:jbmlaird,项目名称:DiscogsBrowser,代码行数:33,代码来源:TestUtils.java

示例9: setOrientation

import android.support.test.espresso.ViewAction; //导入依赖的package包/类
static ViewAction setOrientation(final int orientation) {
    return new ViewAction() {
        @Override
        public Matcher<View> getConstraints() {
            return isRoot();
        }

        @Override
        public String getDescription() {
            return "Change orientation";
        }

        @Override
        public void perform(UiController uiController, View view) {
            uiController.loopMainThreadUntilIdle();
            changeOrientation(view, orientation);
        }
    };
}
 
开发者ID:dev-labs-bg,项目名称:fullscreen-video-view,代码行数:20,代码来源:CustomChecks.java

示例10: setAspectRatio

import android.support.test.espresso.ViewAction; //导入依赖的package包/类
static ViewAction setAspectRatio(@NonNull final AspectRatio ratio) {
    return new ViewAction() {

        @Override
        public Matcher<View> getConstraints() {
            return isAssignableFrom(CameraView.class);
        }

        @Override
        public String getDescription() {
            return "Set aspect ratio to " + ratio;
        }

        @Override
        public void perform(UiController controller, View view) {
            ((CameraView) view).setAspectRatio(ratio);
        }
    };
}
 
开发者ID:vshkl,项目名称:PXLSRT,代码行数:20,代码来源:CameraViewActions.java

示例11: swipeOnCoord

import android.support.test.espresso.ViewAction; //导入依赖的package包/类
public static ViewAction swipeOnCoord(final float fromX, final float fromY, final float toX, final float toY) {
    return new ViewAction() {
        @Override
        public Matcher<View> getConstraints() {
            return isRoot();
        }

        @Override
        public String getDescription() {

            return "Swipe from" + fromX + ", " + fromY + " to " + toX + ", " + toY;
        }

        @Override
        public void perform(UiController uiController, final View view) {
            drag(fromX, fromY, toX, toY);
        }
    };
}
 
开发者ID:cuplv,项目名称:ChimpCheck,代码行数:20,代码来源:FingerGestures.java

示例12: waitFor

import android.support.test.espresso.ViewAction; //导入依赖的package包/类
public static ViewAction waitFor(final long millis) {
    return new ViewAction() {
        @Override
        public Matcher<View> getConstraints() {
            return isRoot();
        }

        @Override
        public String getDescription() {
            return "Wait for " + millis + " milliseconds.";
        }

        @Override
        public void perform(UiController uiController, final View view) {
            uiController.loopMainThreadForAtLeast(millis);
        }
    };
}
 
开发者ID:d4rken,项目名称:ommvplib,代码行数:19,代码来源:TestHelper.java

示例13: testGoToManual

import android.support.test.espresso.ViewAction; //导入依赖的package包/类
/**
 * Test if the manual input activity opens.
 */
@Test
public void testGoToManual() {
    onView(withId(R.id.manual_input_button)).check(matches(allOf( isEnabled(), isClickable()))).perform(
            new ViewAction() {
                @Override
                public Matcher<View> getConstraints() {
                    return isEnabled(); // no constraints, they are checked above
                }

                @Override
                public String getDescription() {
                    return "click manual input button";
                }

                @Override
                public void perform(UiController uiController, View view) {
                    view.performClick();
                }
            }
    );
    intended(hasComponent(ManualInputActivity.class.getName()));
}
 
开发者ID:digital-voting-pass,项目名称:polling-station-app,代码行数:26,代码来源:TestMainActivity.java

示例14: setNumber

import android.support.test.espresso.ViewAction; //导入依赖的package包/类
/**
 * Set value for {@link NumberPicker}
 */
public static ViewAction setNumber(final int n) {
    return new ViewAction() {
        @Override
        public void perform(UiController uiController, View view) {
            ((NumberPicker) view).setValue(n);
        }

        @Override
        public String getDescription() {
            return "Set NumberPicker value";
        }

        @Override
        public Matcher<View> getConstraints() {
            return ViewMatchers.isAssignableFrom(NumberPicker.class);
        }
    };
}
 
开发者ID:orgzly,项目名称:orgzly-android,代码行数:22,代码来源:EspressoUtils.java

示例15: smoothScrollToPosition_ScrollItemIsNotVisible_FirstVisiblePositionsEqualsScrollingTarget

import android.support.test.espresso.ViewAction; //导入依赖的package包/类
@Test
public synchronized void smoothScrollToPosition_ScrollItemIsNotVisible_FirstVisiblePositionsEqualsScrollingTarget() throws Exception {
    //arrange
    InstrumentalUtil.waitForIdle();

    //act
    ViewAction scrollAction = smoothScrollToPosition(18);
    //noinspection SynchronizationOnLocalVariableOrMethodParameter
    synchronized (scrollAction) {
        recyclerView.perform(scrollAction);
        //wait for completion of SmoothScrollAction
        scrollAction.wait();
    }

    //assert
    int actual = layoutManager.findFirstCompletelyVisibleItemPosition();
    assertEquals(18, actual);
}
 
开发者ID:sathishmscict,项目名称:ChipsLayoutManager,代码行数:19,代码来源:ColumnTest.java


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