Commit ef7c03f3 authored by Matt Jones's avatar Matt Jones Committed by Commit Bot

Remove obsolete BottomSheetTestRule tests

Bug: 805160
Change-Id: Ic15b71f86c68bb3ffad5d2a08996637aa9a93729
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1849269Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Commit-Queue: Matthew Jones <mdjones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#705623}
parent 3fc39c7f
...@@ -438,14 +438,7 @@ chrome_test_java_sources = [ ...@@ -438,14 +438,7 @@ chrome_test_java_sources = [
"javatests/src/org/chromium/chrome/browser/status_indicator/StatusIndicatorTest.java", "javatests/src/org/chromium/chrome/browser/status_indicator/StatusIndicatorTest.java",
"javatests/src/org/chromium/chrome/browser/status_indicator/StatusIndicatorViewBinderTest.java", "javatests/src/org/chromium/chrome/browser/status_indicator/StatusIndicatorViewBinderTest.java",
"javatests/src/org/chromium/chrome/browser/suggestions/ContentSuggestionsTest.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/HomeSheetNoTilesUiCaptureTest.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", "javatests/src/org/chromium/chrome/browser/suggestions/NavigationRecorderTest.java",
"javatests/src/org/chromium/chrome/browser/suggestions/SuggestionsBottomSheetTest.java",
"javatests/src/org/chromium/chrome/browser/suggestions/SuggestionsBottomSheetTestRule.java",
"javatests/src/org/chromium/chrome/browser/suggestions/SuggestionsBottomSheetUiCaptureTest.java",
"javatests/src/org/chromium/chrome/browser/suggestions/tile/TileGridLayoutTest.java", "javatests/src/org/chromium/chrome/browser/suggestions/tile/TileGridLayoutTest.java",
"javatests/src/org/chromium/chrome/browser/suggestions/tile/TileGroupTest.java", "javatests/src/org/chromium/chrome/browser/suggestions/tile/TileGroupTest.java",
"javatests/src/org/chromium/chrome/browser/sync/AutofillTest.java", "javatests/src/org/chromium/chrome/browser/sync/AutofillTest.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.DisabledTest;
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.ntp.snippets.CategoryStatus;
import org.chromium.chrome.browser.ntp.snippets.KnownCategories;
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.chrome.test.util.browser.suggestions.SuggestionsDependenciesRule.TestFactory;
import org.chromium.ui.test.util.UiRestriction;
import java.util.Collections;
/**
* Tests for the appearance of the card suggestions in the home sheet.
*/
@DisabledTest(message = "https://crbug.com/805160")
@RunWith(ChromeJUnit4ClassRunner.class)
@Restriction(UiRestriction.RESTRICTION_TYPE_PHONE) // ChromeHome is only enabled on phones
public class HomeSheetCardsUiCaptureTest {
@Rule
public SuggestionsBottomSheetTestRule mActivityRule = new SuggestionsBottomSheetTestRule();
private final TestFactory mDepsFactory = NtpUiCaptureTestData.createFactory();
@Rule
public SuggestionsDependenciesRule setupSuggestions() {
return new SuggestionsDependenciesRule(mDepsFactory);
}
@Rule
public ScreenShooter mScreenShooter = new ScreenShooter();
@Before
public void setup() throws InterruptedException {
ChromePreferenceManager.getInstance().writeBoolean(
ChromePreferenceManager.NTP_SIGNIN_PROMO_DISMISSED, true);
mActivityRule.startMainActivityOnBottomSheet(BottomSheet.SheetState.PEEK);
}
@Test
@MediumTest
@Feature({"UiCatalogue"})
public void testContextMenu() {
mActivityRule.setSheetState(BottomSheet.SheetState.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"})
public void testScrolling() {
mActivityRule.setSheetState(BottomSheet.SheetState.FULL, false);
waitForWindowUpdates();
// When scrolling to a View, we wait until the View is no longer updating - when it is no
// longer dirty. If scroll to load is triggered, the animated progress spinner will keep
// the RecyclerView dirty as it is constantly updating. In addition for the UiCaptureTest
// we would like to get to the bottom of the CardsUI.
// We do not want to disable the Scroll to Load feature entirely because its presence
// effects other elements of the UI - it moves the Learn More link into the Context Menu.
// Removing the ScrollToLoad listener from the RecyclerView allows us to prevent scroll to
// load triggering while maintaining the UI otherwise.
mActivityRule.getRecyclerView().clearScrollToLoadListener();
mActivityRule.scrollToFirstItemOfType(ItemViewType.ACTION);
waitForWindowUpdates();
mScreenShooter.shoot("ScrolledToMoreButton");
mActivityRule.scrollToFirstItemOfType(ItemViewType.SNIPPET);
waitForWindowUpdates();
mScreenShooter.shoot("ScrolledToFirstCard");
}
@Test
@MediumTest
@Feature({"UiCatalogue"})
public void testContentSuggestionPlaceholder() {
FakeSuggestionsSource source = (FakeSuggestionsSource) mDepsFactory.suggestionsSource;
source.setSuggestionsForCategory(KnownCategories.ARTICLES, Collections.emptyList());
source.setStatusForCategory(KnownCategories.ARTICLES, CategoryStatus.AVAILABLE_LOADING);
mActivityRule.setSheetState(BottomSheet.SheetState.FULL, false);
waitForWindowUpdates();
mScreenShooter.shoot("ContentSuggestionsPlaceholder");
}
}
// 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 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.DisabledTest;
import org.chromium.base.test.util.Feature;
import org.chromium.base.test.util.Restriction;
import org.chromium.chrome.browser.ntp.NtpUiCaptureTestData;
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.SuggestionsDependenciesRule;
import org.chromium.chrome.test.util.browser.suggestions.mostvisited.FakeMostVisitedSites;
import org.chromium.ui.test.util.UiRestriction;
/**
* Tests for the appearance of the home sheet when there are no tiles.
*/
@DisabledTest(message = "https://crbug.com/805160")
@RunWith(ChromeJUnit4ClassRunner.class)
@Restriction(UiRestriction.RESTRICTION_TYPE_PHONE) // ChromeHome is only enabled on phones
public class HomeSheetNoTilesUiCaptureTest {
@Rule
public SuggestionsBottomSheetTestRule mActivityRule = new SuggestionsBottomSheetTestRule();
@Rule
public SuggestionsDependenciesRule setupSuggestions() {
SuggestionsDependenciesRule.TestFactory depsFactory = NtpUiCaptureTestData.createFactory();
((FakeMostVisitedSites) depsFactory.mostVisitedSites).setTileSuggestions(new String[] {});
return new SuggestionsDependenciesRule(depsFactory);
}
@Rule
public ScreenShooter mScreenShooter = new ScreenShooter();
@Before
public void setup() throws InterruptedException {
ChromePreferenceManager.getInstance().writeBoolean(
ChromePreferenceManager.NTP_SIGNIN_PROMO_DISMISSED, true);
mActivityRule.startMainActivityOnBlankPage();
}
@Test
@MediumTest
@Feature({"UiCatalogue"})
public void testNoTiles() {
mActivityRule.setSheetState(BottomSheet.SheetState.FULL, false);
waitForWindowUpdates();
mScreenShooter.shoot("NoTiles");
}
}
// 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.matcher.ViewMatchers.withText;
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.DisabledTest;
import org.chromium.base.test.util.Feature;
import org.chromium.base.test.util.Restriction;
import org.chromium.chrome.browser.ntp.NtpUiCaptureTestData;
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.BottomSheetTestRule;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.chrome.test.util.browser.suggestions.SuggestionsDependenciesRule;
import org.chromium.ui.test.util.UiRestriction;
/**
* Tests for the appearance of the tile suggestions in the home sheet.
*/
@DisabledTest(message = "https://crbug.com/805160")
@RunWith(ChromeJUnit4ClassRunner.class)
@Restriction(UiRestriction.RESTRICTION_TYPE_PHONE) // ChromeHome is only enabled on phones
public class HomeSheetTilesUiCaptureTest {
@Rule
public BottomSheetTestRule mActivityRule = new BottomSheetTestRule();
@Rule
public SuggestionsDependenciesRule setupSuggestions() {
return new SuggestionsDependenciesRule(NtpUiCaptureTestData.createFactory());
}
@Rule
public ScreenShooter mScreenShooter = new ScreenShooter();
@Before
public void setup() throws InterruptedException {
ChromePreferenceManager.getInstance().writeBoolean(
ChromePreferenceManager.NTP_SIGNIN_PROMO_DISMISSED, true);
mActivityRule.startMainActivityOnBlankPage();
}
@Test
@MediumTest
@Feature({"UiCatalogue"})
public void testAppearance() {
mActivityRule.setSheetState(BottomSheet.SheetState.FULL, false);
waitForWindowUpdates();
mScreenShooter.shoot("Appearance");
}
@Test
@MediumTest
@Feature({"UiCatalogue"})
public void testContextMenu() {
mActivityRule.setSheetState(BottomSheet.SheetState.FULL, false);
waitForWindowUpdates();
onView(withText(NtpUiCaptureTestData.getSiteSuggestions().get(0).title))
.perform(longClick());
mScreenShooter.shoot("ContextMenu");
}
}
// 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 org.chromium.chrome.test.BottomSheetTestRule.waitForWindowUpdates;
import android.support.test.InstrumentationRegistry;
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.DisabledTest;
import org.chromium.base.test.util.Feature;
import org.chromium.base.test.util.Restriction;
import org.chromium.chrome.browser.ntp.NtpUiCaptureTestData;
import org.chromium.chrome.browser.ntp.cards.ItemViewType;
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.MenuUtils;
import org.chromium.chrome.test.util.browser.suggestions.SuggestionsDependenciesRule;
import org.chromium.ui.test.util.UiRestriction;
/**
* Tests for the appearance of the special states of the home sheet.
*/
@DisabledTest(message = "https://crbug.com/805160")
@RunWith(ChromeJUnit4ClassRunner.class)
@Restriction(UiRestriction.RESTRICTION_TYPE_PHONE) // ChromeHome is only enabled on phones
public class HomeSheetUiCaptureTest {
@Rule
public SuggestionsBottomSheetTestRule mActivityRule = new SuggestionsBottomSheetTestRule();
@Rule
public SuggestionsDependenciesRule setupSuggestions() {
return new SuggestionsDependenciesRule(NtpUiCaptureTestData.createFactory());
}
@Rule
public ScreenShooter mScreenShooter = new ScreenShooter();
@Before
public void setup() throws InterruptedException {
mActivityRule.startMainActivityOnBlankPage();
}
@Test
@MediumTest
@Feature({"UiCatalogue"})
public void testSignInPromo() {
// Needs to be "Full" to for this to work on small screens in landscape.
mActivityRule.setSheetState(BottomSheet.SheetState.FULL, false);
waitForWindowUpdates();
mActivityRule.scrollToFirstItemOfType(ItemViewType.PROMO);
mScreenShooter.shoot("SignInPromo_new");
}
@Test
@MediumTest
@Feature({"UiCatalogue"})
public void testNewTab() {
// Select "New tab" from the menu.
MenuUtils.invokeCustomMenuActionSync(InstrumentationRegistry.getInstrumentation(),
mActivityRule.getActivity(), org.chromium.chrome.R.id.new_tab_menu_id);
waitForWindowUpdates();
mScreenShooter.shoot("NewTab");
}
}
// 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 org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import android.os.SystemClock;
import android.support.test.InstrumentationRegistry;
import android.support.test.filters.MediumTest;
import android.support.v7.widget.RecyclerView.ViewHolder;
import android.view.MotionEvent;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.chromium.base.test.util.DisabledTest;
import org.chromium.base.test.util.Restriction;
import org.chromium.base.test.util.RetryOnFailure;
import org.chromium.chrome.browser.ntp.NtpUiCaptureTestData;
import org.chromium.chrome.browser.ntp.cards.ItemViewType;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.chrome.test.util.browser.suggestions.SuggestionsDependenciesRule;
import org.chromium.content_public.browser.test.util.TestThreadUtils;
import org.chromium.content_public.browser.test.util.TestTouchUtils;
import org.chromium.ui.test.util.UiRestriction;
import java.util.concurrent.ExecutionException;
/**
* Instrumentation tests for {@link SuggestionsBottomSheetContent}.
*/
@DisabledTest(message = "https://crbug.com/805160")
@RunWith(ChromeJUnit4ClassRunner.class)
@Restriction(UiRestriction.RESTRICTION_TYPE_PHONE) // ChromeHome is only enabled on phones
public class SuggestionsBottomSheetTest {
@Rule
public SuggestionsBottomSheetTestRule mActivityRule = new SuggestionsBottomSheetTestRule();
@Rule
public SuggestionsDependenciesRule createSuggestions() {
return new SuggestionsDependenciesRule(NtpUiCaptureTestData.createFactory());
}
@Before
public void setUp() throws InterruptedException {
mActivityRule.startMainActivityOnBlankPage();
}
@Test
@RetryOnFailure
@MediumTest
public void testContextMenu() throws ExecutionException {
ViewHolder suggestionViewHolder =
mActivityRule.scrollToFirstItemOfType(ItemViewType.SNIPPET);
assertFalse(mActivityRule.getBottomSheet().onInterceptTouchEvent(createTapEvent()));
TestTouchUtils.performLongClickOnMainSync(
InstrumentationRegistry.getInstrumentation(), suggestionViewHolder.itemView);
assertTrue(mActivityRule.getBottomSheet().onInterceptTouchEvent(createTapEvent()));
TestThreadUtils.runOnUiThreadBlocking(mActivityRule.getActivity()::closeContextMenu);
assertFalse(mActivityRule.getBottomSheet().onInterceptTouchEvent(createTapEvent()));
}
private static MotionEvent createTapEvent() {
return MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(),
MotionEvent.ACTION_DOWN, 0f, 0f, 0);
}
}
// 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 org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import android.support.v7.widget.RecyclerView;
import org.chromium.chrome.browser.ntp.cards.ItemViewType;
import org.chromium.chrome.browser.ntp.cards.NewTabPageAdapter;
import org.chromium.chrome.test.BottomSheetTestRule;
import org.chromium.chrome.test.util.browser.RecyclerViewTestUtils;
import org.chromium.chrome.test.util.browser.suggestions.ContentSuggestionsTestUtils;
/**
* Junit4 rule for testing suggestions in the Chrome Home "Home" sheet.
*/
public class SuggestionsBottomSheetTestRule extends BottomSheetTestRule {
/**
* @return The {@link SuggestionsRecyclerView} for this sheet.
*/
public SuggestionsRecyclerView getRecyclerView() {
SuggestionsRecyclerView recyclerView =
getBottomSheetContent().getContentView().findViewById(
org.chromium.chrome.R.id.recycler_view);
assertNotNull(recyclerView);
return recyclerView;
}
/**
* @return The {@link NewTabPageAdapter} for this sheet.
*/
public NewTabPageAdapter getAdapter() {
return getRecyclerView().getNewTabPageAdapter();
}
/**
* @param itemViewType The type of item to find.
* @return The position of the first item of the given type.
*/
public int getFirstPositionForType(@ItemViewType int itemViewType) {
return getAdapter().getFirstPositionForType(itemViewType);
}
/**
* Finds and scrolls to the first item of the given type.
* @param type The type of item to find and scroll to.
* @return the ViewHolder for the given {@code position}.
*/
public RecyclerView.ViewHolder scrollToFirstItemOfType(@ItemViewType int type) {
int position = getFirstPositionForType(type);
assertNotEquals("Scroll target of type " + type + " not found\n"
+ ContentSuggestionsTestUtils.stringify(getAdapter().getRootForTesting()),
RecyclerView.NO_POSITION, position);
return RecyclerViewTestUtils.scrollToView(getRecyclerView(), position);
}
}
// 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 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.DisabledTest;
import org.chromium.base.test.util.Feature;
import org.chromium.base.test.util.Restriction;
import org.chromium.chrome.browser.ntp.NtpUiCaptureTestData;
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.SuggestionsDependenciesRule;
import org.chromium.ui.test.util.UiRestriction;
/**
* Tests for the appearance of the home sheet in different bottom sheet states.
*/
@DisabledTest
@RunWith(ChromeJUnit4ClassRunner.class)
@Restriction(UiRestriction.RESTRICTION_TYPE_PHONE) // ChromeHome is only enabled on phones
public class SuggestionsBottomSheetUiCaptureTest {
@Rule
public SuggestionsBottomSheetTestRule mActivityRule = new SuggestionsBottomSheetTestRule();
@Rule
public SuggestionsDependenciesRule createSuggestions() {
return new SuggestionsDependenciesRule(NtpUiCaptureTestData.createFactory());
}
@Rule
public ScreenShooter mScreenShooter = new ScreenShooter();
@Before
public void setup() throws InterruptedException {
ChromePreferenceManager.getInstance().writeBoolean(
ChromePreferenceManager.NTP_SIGNIN_PROMO_DISMISSED, true);
mActivityRule.startMainActivityOnBlankPage();
}
@Test
@MediumTest
@Feature({"UiCatalogue"})
public void testBottomSheetPosition() {
mActivityRule.setSheetState(BottomSheet.SheetState.HALF, false);
waitForWindowUpdates();
mScreenShooter.shoot("Half");
mActivityRule.setSheetState(BottomSheet.SheetState.FULL, false);
waitForWindowUpdates();
mScreenShooter.shoot("Full");
mActivityRule.setSheetState(BottomSheet.SheetState.PEEK, false);
waitForWindowUpdates();
mScreenShooter.shoot("Peek");
}
}
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