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(); }
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(); }
public static void measureAndScreenshotView(View view, int width, int height) { ViewHelpers.setupView(view) .setExactWidthPx(width) .setExactHeightPx(height) .layout(); Screenshot.snap(view) .record(); }
@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(); }
@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(); }
@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(); }
@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(); }
@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(); }
@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(); }
@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(); }
@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(); }
@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(); }
@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(); }
@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(); }
@Test public void testRenderQualMatch() throws Exception { View view = getView("2017week0_qm7"); ViewHelpers.setupView(view) .setExactWidthDp(WIDTH_DP) .layout(); Screenshot.snap(view) .record(); }
@Test public void testRenderQualMatch() throws Exception { View view = getView("2016necmp_qm1"); ViewHelpers.setupView(view) .setExactWidthDp(WIDTH_DP) .layout(); Screenshot.snap(view) .record(); }
@Test public void testRenderPlayoffMatch() throws Exception { View view = getView("2016necmp_f1m1"); ViewHelpers.setupView(view) .setExactWidthDp(WIDTH_DP) .layout(); Screenshot.snap(view) .record(); }
@Test public void testRenderQualMatch() throws Exception { View view = getView("2014necmp_qm1"); ViewHelpers.setupView(view) .setExactWidthDp(WIDTH_DP) .layout(); Screenshot.snap(view) .record(); }
@Test public void testRenderPlayoffMatch() throws Exception { View view = getView("2014necmp_f1m1"); ViewHelpers.setupView(view) .setExactWidthDp(WIDTH_DP) .layout(); Screenshot.snap(view) .record(); }
@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(); }
@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(); }
@Test public void testRender(){ View view = getView("2016test", "Test Event", WEBCAST, 1); ViewHelpers.setupView(view) .setExactWidthDp(WIDTH_DP) .layout(); Screenshot.snap(view) .record(); }
@Test public void testRender() { View view = getView("Test Model", "test", ModelType.TEAM); ViewHelpers.setupView(view) .setExactWidthDp(WIDTH_DP) .layout(); Screenshot.snap(view) .record(); }
@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(); }
@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(); }
@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(); }
@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(); }
@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(); }
@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(); }
@Test public void testRender() { View view = getView("Test Events"); ViewHelpers.setupView(view) .setExactWidthDp(WIDTH_DP) .layout(); Screenshot.snap(view) .record(); }
@Test public void testRenderWithMyTba() { View view = getView(DISTRICT, 4, true); ViewHelpers.setupView(view) .setExactWidthDp(WIDTH_DP) .layout(); Screenshot.snap(view) .record(); }
@Test public void testRenderWithoutMyTba() { View view = getView(DISTRICT, 4, false); ViewHelpers.setupView(view) .setExactWidthDp(WIDTH_DP) .layout(); Screenshot.snap(view) .record(); }
@Test public void testRender() { View view = getView("frc1124", "2016ne", "UberBots", 2, 120); ViewHelpers.setupView(view) .setExactWidthDp(WIDTH_DP) .layout(); Screenshot.snap(view) .record(); }
@Test public void testRenderNoName() { View view = getView("frc1124", "2016ne", "", 2, 120); ViewHelpers.setupView(view) .setExactWidthDp(WIDTH_DP) .layout(); Screenshot.snap(view) .record(); }
@Test public void testRenderWithMyTba() { View view = getView("frc1124", 1124, "UberBots", "Avon, CT", true, false); ViewHelpers.setupView(view) .setExactWidthDp(WIDTH_DP) .layout(); Screenshot.snap(view) .record(); }
@Test public void testRenderWithoutMyTba() { View view = getView("frc1124", 1124, "UberBots", "Avon, CT", false, true); ViewHelpers.setupView(view) .setExactWidthDp(WIDTH_DP) .layout(); Screenshot.snap(view) .record(); }
@Test public void testRender() { View view = getView("frc1124", "1124", "UberBots", "11.24", 1.2, 3.4, 5.6); ViewHelpers.setupView(view) .setExactWidthDp(WIDTH_DP) .layout(); Screenshot.snap(view) .record(); }
@Test public void testRender() { View view = getView("Test", "foobar"); ViewHelpers.setupView(view) .setExactWidthDp(WIDTH_DP) .layout(); Screenshot.snap(view) .record(); }
@Test public void testRenderWithMyTba() { View view = getView("2016test", 2016, "Test Event", "Apr 27, 2016", "New York, NY", true); ViewHelpers.setupView(view) .setExactWidthDp(WIDTH_DP) .layout(); Screenshot.snap(view) .record(); }