Java 类com.facebook.testing.screenshot.ViewHelpers 实例源码
项目:apps-android-wikipedia
文件:ViewTest.java
protected void snap(@NonNull View subject, @Nullable String... dataPoints) {
int rtl = layoutDirection == LayoutDirection.RTL
? View.LAYOUT_DIRECTION_RTL
: TextUtilsCompat.getLayoutDirectionFromLocale(locale);
//noinspection WrongConstant
subject.setLayoutDirection(rtl);
ViewHelpers viewHelpers = ViewHelpers.setupView(subject).setExactWidthDp(widthDp);
if (heightDp != null) {
viewHelpers.setExactHeightDp(heightDp);
}
viewHelpers.layout();
List<String> list = new ArrayList<>();
String byHeight = heightDp == null ? "" : ("x" + heightDp);
list.add(widthDp + byHeight + "dp");
list.add(locale.toString());
list.add(layoutDirection == LayoutDirection.RTL ? "rtl" : "ltr");
list.add("font" + fontScale.multiplier() + "x");
list.add(theme.toString().toLowerCase(Locale.ENGLISH));
list.addAll(Arrays.asList(ArrayUtils.nullToEmpty(dataPoints)));
Screenshot.snap(subject).setName(testName(list)).record();
}
项目:Shot
文件:ScreenshotTest.java
protected void compareScreenshot(View view, int height) {
Context context = getInstrumentation().getTargetContext();
WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
DisplayMetrics metrics = new DisplayMetrics();
windowManager.getDefaultDisplay().getMetrics(metrics);
ViewHelpers.setupView(view)
.setExactHeightPx(context.getResources().getDimensionPixelSize(height))
.setExactWidthPx(metrics.widthPixels)
.layout();
Screenshot.snap(view).record();
}
项目:Isometric
文件:ScreenshotHelper.java
public static void measureAndScreenshotView(View view, int width, int height) {
ViewHelpers.setupView(view)
.setExactWidthPx(width)
.setExactHeightPx(height)
.layout();
Screenshot.snap(view)
.record();
}
项目:KataScreenshotAndroid
文件:ScreenshotTest.java
protected void compareScreenshot(View view, int height) {
Context context = getInstrumentation().getTargetContext();
WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
DisplayMetrics metrics = new DisplayMetrics();
windowManager.getDefaultDisplay().getMetrics(metrics);
ViewHelpers.setupView(view)
.setExactHeightPx(context.getResources().getDimensionPixelSize(height))
.setExactWidthPx(metrics.widthPixels)
.layout();
Screenshot.snap(view).record();
}
项目:screenshot-tests-for-android
文件:ExampleScreenshotTest.java
@Test
public void testDefault() {
Context targetContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
LayoutInflater inflater = LayoutInflater.from(targetContext);
LithoView view = (LithoView) inflater.inflate(R.layout.litho_view, null, false);
view.setComponent(Example.create(view.getComponentContext()).build());
ViewHelpers.setupView(view).setExactWidthDp(300).layout();
Screenshot.snap(view).record();
}
项目:screenshot-tests-for-android
文件:ImageRowScreenshotTest.java
@Test
public void testDefault() {
Context targetContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
LayoutInflater inflater = LayoutInflater.from(targetContext);
LithoView view = (LithoView) inflater.inflate(R.layout.litho_view, null, false);
view.setComponent(ImageRow.create(view.getComponentContext()).build());
ViewHelpers.setupView(view).setExactWidthDp(300).layout();
Screenshot.snap(view).record();
}
项目:screenshot-tests-for-android
文件:LayoutHierarchyDumperTest.java
@Test
public void testBasicCoordinateCheck() throws Throwable {
ViewHelpers.setupView(mView).setExactHeightPx(1000).setExactWidthPx(20000).layout();
ParsedViewDetail node = ParsedViewDetail.convert(mView);
assertEquals(0, node.absoluteRect.top);
assertEquals(0, node.absoluteRect.left);
assertEquals(node.childAt(0).absoluteRect.bottom, node.childAt(1).absoluteRect.top);
assertTrue(node.childAt(0).absoluteRect.bottom != 0);
}
项目:screenshot-tests-for-android
文件:LayoutHierarchyDumperTest.java
@Test
public void testNestedAbsoluteCoordinates() throws Throwable {
ViewHelpers.setupView(mView).setExactHeightPx(1000).setExactWidthPx(20000).layout();
ParsedViewDetail node = ParsedViewDetail.convert(mView);
int textViewHeight = ((ViewGroup) mView).getChildAt(0).getHeight();
assertEquals(3 * textViewHeight, node.childAt(2).childAt(1).absoluteRect.top);
}
项目:screenshot-tests-for-android
文件:LayoutHierarchyDumperTest.java
@Test
public void testDumpHierarchyOnNestedNode() throws Throwable {
ViewHelpers.setupView(mView).setExactHeightPx(1000).setExactWidthPx(20000).layout();
ParsedViewDetail node = ParsedViewDetail.convert(((ViewGroup) mView).getChildAt(2));
assertEquals(0, node.absoluteRect.top);
assertEquals(0, node.absoluteRect.left);
int textViewHeight = ((ViewGroup) mView).getChildAt(0).getHeight();
assertEquals(textViewHeight, node.childAt(1).absoluteRect.top);
}
项目:screenshot-tests-for-android
文件:LayoutHierarchyDumperTest.java
@Test
public void testPluginDumps() throws Throwable {
ViewHelpers.setupView(mView).setExactHeightPx(1000).setExactWidthPx(20000).layout();
LayoutHierarchyDumper dumper =
LayoutHierarchyDumper.createWith(
Collections.<HierarchyPlugin>emptyList(), Collections.singletonList(mAttributePlugin));
JSONObject root = dumper.dumpHierarchy(mView);
assertEquals("bar", root.getString("foo:foo"));
}
项目:screenshot-tests-for-android
文件:LayoutHierarchyDumperTest.java
@Test
public void testPluginDumpsRecursively() throws Throwable {
ViewHelpers.setupView(mView).setExactHeightPx(1000).setExactWidthPx(20000).layout();
LayoutHierarchyDumper dumper =
LayoutHierarchyDumper.createWith(
Collections.<HierarchyPlugin>emptyList(),
Collections.singletonList(mTextAttributePlugin));
JSONObject node = dumper.dumpHierarchy(mView);
List<String> allText = new ArrayList<>();
Queue<JSONObject> toCheck = new ArrayDeque<>();
toCheck.offer(node);
while (!toCheck.isEmpty()) {
JSONObject object = toCheck.poll();
String maybeText = object.optString("Text:text");
if (!TextUtils.isEmpty(maybeText)) {
allText.add(maybeText);
}
JSONArray children = object.optJSONArray(BaseViewHierarchyPlugin.KEY_CHILDREN);
if (children == null) {
continue;
}
for (int i = 0; i < children.length(); ++i) {
toCheck.offer(children.getJSONObject(i));
}
}
List<String> expected = new ArrayList<>();
expected.add("foobar");
expected.add("foobar2");
expected.add("foobar3");
expected.add("foobar4");
assertEquals(expected, allText);
}
项目:the-blue-alliance-android
文件:MatchViewTest.java
@Test
public void testRenderUnplayed() {
View view = createView(RED_TEAMS_3, BLUE_TEAMS_3, "?", "?", "blue", 1463883886L, null, MATCH_16);
ViewHelpers.setupView(view)
.setExactWidthDp(WIDTH_DP)
.layout();
Screenshot.snap(view)
.record();
}
项目:the-blue-alliance-android
文件:MatchViewTest.java
@Test
public void testRenderBlueWin() {
View view = createView(RED_TEAMS_3, BLUE_TEAMS_3, "20", "30", "blue", 1463883886L, VID, MATCH_16);
ViewHelpers.setupView(view)
.setExactWidthDp(WIDTH_DP)
.layout();
Screenshot.snap(view)
.record();
}
项目:the-blue-alliance-android
文件:MatchViewTest.java
@Test
public void testRenderRedWin() {
View view = createView(RED_TEAMS_3, BLUE_TEAMS_3, "40", "30", "blue", 1463883886L, VID, MATCH_16);
ViewHelpers.setupView(view)
.setExactWidthDp(WIDTH_DP)
.layout();
Screenshot.snap(view)
.record();
}
项目:the-blue-alliance-android
文件:MatchViewTest.java
@Test
public void testRenderTie() {
View view = createView(RED_TEAMS_3, BLUE_TEAMS_3, "20", "20", "blue", 1463883886L, VID, MATCH_16);
ViewHelpers.setupView(view)
.setExactWidthDp(WIDTH_DP)
.layout();
Screenshot.snap(view)
.record();
}
项目:the-blue-alliance-android
文件:MatchViewTest.java
@Test
public void testRender2Team() {
View view = createView(RED_TEAMS_2, BLUE_TEAMS_2, "20", "30", "blue", 1463883886L, VID, MATCH_16);
ViewHelpers.setupView(view)
.setExactWidthDp(WIDTH_DP)
.layout();
Screenshot.snap(view)
.record();
}
项目:the-blue-alliance-android
文件:MatchViewTest.java
@Test
public void testRenderNoTime() {
View view = createView(RED_TEAMS_3, BLUE_TEAMS_3, "20", "30", "blue", 0, VID, MATCH_16);
ViewHelpers.setupView(view)
.setExactWidthDp(WIDTH_DP)
.layout();
Screenshot.snap(view)
.record();
}
项目:the-blue-alliance-android
文件:MatchViewTest.java
@Test
public void testRenderNoVideo() {
View view = createView(RED_TEAMS_3, BLUE_TEAMS_3, "20", "30", "blue", 1463883886L, null, MATCH_16);
ViewHelpers.setupView(view)
.setExactWidthDp(WIDTH_DP)
.layout();
Screenshot.snap(view)
.record();
}
项目:the-blue-alliance-android
文件:MatchViewTest.java
@Test
public void testNoWinnersIn2015() {
View view = createView(RED_TEAMS_3, BLUE_TEAMS_3, "20", "30", "", 1463883886L, VID, MATCH_15_Q);
ViewHelpers.setupView(view)
.setExactWidthDp(WIDTH_DP)
.layout();
Screenshot.snap(view)
.record();
}
项目:the-blue-alliance-android
文件:MatchViewTest.java
@Test
public void testWinnersIn2015Finals() {
View view = createView(RED_TEAMS_3, BLUE_TEAMS_3, "20", "30", "blue", 1463883886L, VID,
MATCH_15_F);
ViewHelpers.setupView(view)
.setExactWidthDp(WIDTH_DP)
.layout();
Screenshot.snap(view)
.record();
}
项目:the-blue-alliance-android
文件:MatchBreakdownView2017Test.java
@Test
public void testRenderQualMatch() throws Exception {
View view = getView("2017week0_qm7");
ViewHelpers.setupView(view)
.setExactWidthDp(WIDTH_DP)
.layout();
Screenshot.snap(view)
.record();
}
项目:the-blue-alliance-android
文件:MatchBreakdownView2016Test.java
@Test
public void testRenderQualMatch() throws Exception {
View view = getView("2016necmp_qm1");
ViewHelpers.setupView(view)
.setExactWidthDp(WIDTH_DP)
.layout();
Screenshot.snap(view)
.record();
}
项目:the-blue-alliance-android
文件:MatchBreakdownView2016Test.java
@Test
public void testRenderPlayoffMatch() throws Exception {
View view = getView("2016necmp_f1m1");
ViewHelpers.setupView(view)
.setExactWidthDp(WIDTH_DP)
.layout();
Screenshot.snap(view)
.record();
}
项目:the-blue-alliance-android
文件:MatchBreakdownView2015Test.java
@Test
public void testRenderQualMatch() throws Exception {
View view = getView("2014necmp_qm1");
ViewHelpers.setupView(view)
.setExactWidthDp(WIDTH_DP)
.layout();
Screenshot.snap(view)
.record();
}
项目:the-blue-alliance-android
文件:MatchBreakdownView2015Test.java
@Test
public void testRenderPlayoffMatch() throws Exception {
View view = getView("2014necmp_f1m1");
ViewHelpers.setupView(view)
.setExactWidthDp(WIDTH_DP)
.layout();
Screenshot.snap(view)
.record();
}
项目:the-blue-alliance-android
文件:AllianceListElementTest.java
@Test
public void testRender3Team() {
View view = getView("2016test", "Alliance 1", 1, TEAM_LIST_3, PlayoffAdvancement.SEMI);
ViewHelpers.setupView(view)
.setExactWidthDp(WIDTH_DP)
.layout();
Screenshot.snap(view)
.record();
}
项目:the-blue-alliance-android
文件:AllianceListElementTest.java
@Test
public void testRender4Team() {
View view = getView("2016test", "Alliance 1", 1, TEAM_LIST_4, PlayoffAdvancement.QUARTER);
ViewHelpers.setupView(view)
.setExactWidthDp(WIDTH_DP)
.layout();
Screenshot.snap(view)
.record();
}
项目:the-blue-alliance-android
文件:WebcastListElementTest.java
@Test
public void testRender(){
View view = getView("2016test", "Test Event", WEBCAST, 1);
ViewHelpers.setupView(view)
.setExactWidthDp(WIDTH_DP)
.layout();
Screenshot.snap(view)
.record();
}
项目:the-blue-alliance-android
文件:ModelListElementTest.java
@Test
public void testRender() {
View view = getView("Test Model", "test", ModelType.TEAM);
ViewHelpers.setupView(view)
.setExactWidthDp(WIDTH_DP)
.layout();
Screenshot.snap(view)
.record();
}
项目:the-blue-alliance-android
文件:CardedAwardListElementTest.java
@Test
public void testRenderSingleTeam() {
View view = getView(null, "Test Award", "2016test", SINGLE_TEAM, TEAM_MAP, null);
ViewHelpers.setupView(view)
.setExactWidthDp(WIDTH_DP)
.layout();
Screenshot.snap(view)
.record();
}
项目:the-blue-alliance-android
文件:CardedAwardListElementTest.java
@Test
public void testRenderSelectedTeam() {
View view = getView(null, "Test Award", "2016test", SINGLE_TEAM, TEAM_MAP, "1124");
ViewHelpers.setupView(view)
.setExactWidthDp(WIDTH_DP)
.layout();
Screenshot.snap(view)
.record();
}
项目:the-blue-alliance-android
文件:CardedAwardListElementTest.java
@Test
public void testRenderMultiWinner() {
View view = getView(null, "Test Award", "2016test", MULTI_TEAM, TEAM_MAP, null);
ViewHelpers.setupView(view)
.setExactWidthDp(WIDTH_DP)
.layout();
Screenshot.snap(view)
.record();
}
项目:the-blue-alliance-android
文件:CardedAwardListElementTest.java
@Test
public void testRenderIndividual() {
View view = getView(null, "Test Award", "2016test", INDIVIDUAL, TEAM_MAP, null);
ViewHelpers.setupView(view)
.setExactWidthDp(WIDTH_DP)
.layout();
Screenshot.snap(view)
.record();
}
项目:the-blue-alliance-android
文件:CardedAwardListElementTest.java
@Test
public void testRenderIndividualNoTeam() {
View view = getView(null, "Test Award", "2016test", INDIVIDUAL_NO_TEAM, TEAM_MAP, null);
ViewHelpers.setupView(view)
.setExactWidthDp(WIDTH_DP)
.layout();
Screenshot.snap(view)
.record();
}
项目:the-blue-alliance-android
文件:CardedAwardListElementTest.java
@Test
public void testRenderMultiIndividual() {
View view = getView(null, "Test Award", "2016test", MULTI_INDIVIDUAL, TEAM_MAP, null);
ViewHelpers.setupView(view)
.setExactWidthDp(WIDTH_DP)
.layout();
Screenshot.snap(view)
.record();
}
项目:the-blue-alliance-android
文件:EventTypeHeaderTest.java
@Test
public void testRender() {
View view = getView("Test Events");
ViewHelpers.setupView(view)
.setExactWidthDp(WIDTH_DP)
.layout();
Screenshot.snap(view)
.record();
}
项目:the-blue-alliance-android
文件:DistrictListElementTest.java
@Test
public void testRenderWithMyTba() {
View view = getView(DISTRICT, 4, true);
ViewHelpers.setupView(view)
.setExactWidthDp(WIDTH_DP)
.layout();
Screenshot.snap(view)
.record();
}
项目:the-blue-alliance-android
文件:DistrictListElementTest.java
@Test
public void testRenderWithoutMyTba() {
View view = getView(DISTRICT, 4, false);
ViewHelpers.setupView(view)
.setExactWidthDp(WIDTH_DP)
.layout();
Screenshot.snap(view)
.record();
}
项目:the-blue-alliance-android
文件:DistrictTeamListElementTest.java
@Test
public void testRender() {
View view = getView("frc1124", "2016ne", "UberBots", 2, 120);
ViewHelpers.setupView(view)
.setExactWidthDp(WIDTH_DP)
.layout();
Screenshot.snap(view)
.record();
}
项目:the-blue-alliance-android
文件:DistrictTeamListElementTest.java
@Test
public void testRenderNoName() {
View view = getView("frc1124", "2016ne", "", 2, 120);
ViewHelpers.setupView(view)
.setExactWidthDp(WIDTH_DP)
.layout();
Screenshot.snap(view)
.record();
}