Commit 4ad662c7 authored by Michael van Ouwerkerk's avatar Michael van Ouwerkerk Committed by Commit Bot

Take some more and better cards catalogue screenshots.

* Capture the default thumbnail.
* Scroll down to first card.
* Scroll down to more button.

Bug: 761813
Change-Id: I168833ee7abb3519504eb6ec93465257ecaffc2c
Reviewed-on: https://chromium-review.googlesource.com/681476
Commit-Queue: Michael van Ouwerkerk <mvanouwerkerk@chromium.org>
Reviewed-by: default avatarBernhard Bauer <bauerb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#504330}
parent 8b86a19d
......@@ -1676,6 +1676,7 @@ chrome_test_java_sources = [
"javatests/src/org/chromium/chrome/browser/snackbar/SnackbarTest.java",
"javatests/src/org/chromium/chrome/browser/snackbar/undo/UndoBarControllerTest.java",
"javatests/src/org/chromium/chrome/browser/suggestions/ContentSuggestionsTest.java",
"javatests/src/org/chromium/chrome/browser/suggestions/HomeSheetCardsUiCaptureTest.java",
"javatests/src/org/chromium/chrome/browser/suggestions/HomeSheetTilesUiCaptureTest.java",
"javatests/src/org/chromium/chrome/browser/suggestions/HomeSheetUiCaptureTest.java",
"javatests/src/org/chromium/chrome/browser/suggestions/NavigationRecorderTest.java",
......
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.chrome.browser.suggestions;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.longClick;
import static android.support.test.espresso.contrib.RecyclerViewActions.actionOnItemAtPosition;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static org.chromium.chrome.test.BottomSheetTestRule.waitForWindowUpdates;
import android.support.test.filters.MediumTest;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.chromium.base.test.util.Feature;
import org.chromium.base.test.util.Restriction;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.ntp.NtpUiCaptureTestData;
import org.chromium.chrome.browser.ntp.cards.ItemViewType;
import org.chromium.chrome.browser.preferences.ChromePreferenceManager;
import org.chromium.chrome.browser.test.ScreenShooter;
import org.chromium.chrome.browser.widget.bottomsheet.BottomSheet;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.chrome.test.util.browser.suggestions.FakeSuggestionsSource;
import org.chromium.chrome.test.util.browser.suggestions.SuggestionsDependenciesRule;
import org.chromium.ui.test.util.UiRestriction;
/**
* Tests for the appearance of the card suggestions in the home sheet.
*/
@RunWith(ChromeJUnit4ClassRunner.class)
@Restriction(UiRestriction.RESTRICTION_TYPE_PHONE) // ChromeHome is only enabled on phones
public class HomeSheetCardsUiCaptureTest {
@Rule
public SuggestionsBottomSheetTestRule mActivityRule = new SuggestionsBottomSheetTestRule();
@Rule
public SuggestionsDependenciesRule setupSuggestions() {
SuggestionsDependenciesRule.TestFactory depsFactory = NtpUiCaptureTestData.createFactory();
FakeSuggestionsSource suggestionsSource = new FakeSuggestionsSource();
NtpUiCaptureTestData.registerArticleSamples(suggestionsSource);
depsFactory.suggestionsSource = suggestionsSource;
return new SuggestionsDependenciesRule(depsFactory);
}
@Rule
public ScreenShooter mScreenShooter = new ScreenShooter();
@Before
public void setup() throws InterruptedException {
ChromePreferenceManager.getInstance().setNewTabPageGenericSigninPromoDismissed(true);
mActivityRule.startMainActivityOnBlankPage();
}
@Test
@MediumTest
@Feature({"UiCatalogue"})
@ScreenShooter.Directory("HomeSheetCards")
public void testContextMenu() throws Exception {
mActivityRule.setSheetState(BottomSheet.SHEET_STATE_FULL, false);
waitForWindowUpdates();
int position = mActivityRule.getFirstPositionForType(ItemViewType.SNIPPET);
onView(withId(R.id.recycler_view)).perform(actionOnItemAtPosition(position, longClick()));
mScreenShooter.shoot("ContextMenu");
}
@Test
@MediumTest
@Feature({"UiCatalogue"})
@ScreenShooter.Directory("HomeSheetCards")
public void testScrolling() throws Exception {
mActivityRule.setSheetState(BottomSheet.SHEET_STATE_FULL, false);
waitForWindowUpdates();
mActivityRule.scrollToFirstItemOfType(ItemViewType.ACTION);
waitForWindowUpdates();
mScreenShooter.shoot("ScrolledToMoreButton");
mActivityRule.scrollToFirstItemOfType(ItemViewType.SNIPPET);
waitForWindowUpdates();
mScreenShooter.shoot("ScrolledToFirstCard");
}
}
......@@ -30,7 +30,7 @@ import org.chromium.chrome.test.util.browser.suggestions.SuggestionsDependencies
import org.chromium.ui.test.util.UiRestriction;
/**
* Tests for the appearance of the tiles in the home sheet.
* Tests for the appearance of the tile suggestions in the home sheet.
*/
@RunWith(ChromeJUnit4ClassRunner.class)
@Restriction(UiRestriction.RESTRICTION_TYPE_PHONE) // ChromeHome is only enabled on phones
......
......@@ -4,11 +4,6 @@
package org.chromium.chrome.browser.suggestions;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.longClick;
import static android.support.test.espresso.contrib.RecyclerViewActions.actionOnItemAtPosition;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static org.chromium.chrome.test.BottomSheetTestRule.waitForWindowUpdates;
import android.support.test.filters.MediumTest;
......@@ -20,9 +15,7 @@ import org.junit.runner.RunWith;
import org.chromium.base.test.util.Feature;
import org.chromium.base.test.util.Restriction;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.ntp.NtpUiCaptureTestData;
import org.chromium.chrome.browser.ntp.cards.ItemViewType;
import org.chromium.chrome.browser.preferences.ChromePreferenceManager;
import org.chromium.chrome.browser.test.ScreenShooter;
import org.chromium.chrome.browser.widget.bottomsheet.BottomSheet;
......@@ -32,7 +25,7 @@ import org.chromium.chrome.test.util.browser.suggestions.SuggestionsDependencies
import org.chromium.ui.test.util.UiRestriction;
/**
* Tests for the appearance of Article Suggestions.
* Tests for the appearance of the home sheet in different bottom sheet states.
*/
@RunWith(ChromeJUnit4ClassRunner.class)
@Restriction(UiRestriction.RESTRICTION_TYPE_PHONE) // ChromeHome is only enabled on phones
......@@ -75,18 +68,4 @@ public class SuggestionsBottomSheetUiCaptureTest {
waitForWindowUpdates();
mScreenShooter.shoot("Peek");
}
@Test
@MediumTest
@Feature({"UiCatalogue"})
@ScreenShooter.Directory("SuggestionsContextMenu")
public void testContextMenu() throws Exception {
// Needs to be "Full" to for this to work on small screens in landscape.
mActivityRule.setSheetState(BottomSheet.SHEET_STATE_FULL, false);
waitForWindowUpdates();
int position = mActivityRule.getFirstPositionForType(ItemViewType.SNIPPET);
onView(withId(R.id.recycler_view)).perform(actionOnItemAtPosition(position, longClick()));
waitForWindowUpdates();
mScreenShooter.shoot("ContextMenu");
}
}
......@@ -39,6 +39,11 @@ public final class RecyclerViewTestUtils {
return false;
}
if (!viewHolder.itemView.isShown()) {
updateFailureReason("The view is not visible for position " + position + ".");
return false;
}
return true;
}
});
......@@ -89,6 +94,16 @@ public final class RecyclerViewTestUtils {
return false;
}
if (recyclerView.isDirty()) {
updateFailureReason("The recycler view is dirty.");
return false;
}
if (recyclerView.isLayoutRequested()) {
updateFailureReason("The recycler view has layout requested.");
return false;
}
return true;
}
});
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment