Commit 79151652 authored by Marti Wong's avatar Marti Wong Committed by Commit Bot

Fix egtests for the new iOS bookmarks flag.

After crrev.com/c/757887, there are still some broken egtests when new
iOS bookmarks feature flag is enabled (some only broken on iPad iOS 11).
This CL fixes them or adds scoped feature list to them so that they will
not break for the new iOS bookmarks.

Bug: 782127
Change-Id: Ic830fdc8d096c22a953bd13eb1c47446ac88c4c8
Reviewed-on: https://chromium-review.googlesource.com/765407
Commit-Queue: Sylvain Defresne <sdefresne@chromium.org>
Reviewed-by: default avatarSylvain Defresne <sdefresne@chromium.org>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#516255}
parent 962e2634
......@@ -117,7 +117,6 @@ source_set("eg_tests") {
":content_suggestions_constant",
":content_suggestions_util",
"//base",
"//base/test:test_support",
"//components/keyed_service/ios",
"//components/ntp_snippets",
"//components/ntp_snippets:test_support",
......@@ -130,6 +129,8 @@ source_set("eg_tests") {
"//ios/chrome/browser/reading_list",
"//ios/chrome/browser/ui",
"//ios/chrome/browser/ui/content_suggestions/cells:cells_ui",
"//ios/chrome/browser/ui/ntp:modal_ntp",
"//ios/chrome/browser/ui/ntp:ntp_controller",
"//ios/chrome/test/app:test_support",
"//ios/chrome/test/earl_grey:test_support",
"//ios/testing:ios_test_support",
......
......@@ -29,6 +29,7 @@
#import "ios/chrome/browser/ui/content_suggestions/ntp_home_constant.h"
#import "ios/chrome/browser/ui/content_suggestions/ntp_home_provider_test_singleton.h"
#import "ios/chrome/browser/ui/content_suggestions/ntp_home_test_utils.h"
#import "ios/chrome/browser/ui/ntp/modal_ntp.h"
#include "ios/chrome/browser/ui/ui_util.h"
#include "ios/chrome/grit/ios_strings.h"
#import "ios/chrome/test/app/chrome_test_util.h"
......@@ -130,8 +131,10 @@ GREYElementInteraction* CellWithMatcher(id<GREYMatcher> matcher) {
+ (void)setUp {
[super setUp];
if (IsIPadIdiom()) {
// Make sure we are on the Home panel on iPad.
// TODO(crbug.com/753599): When old bookmark is removed, NTP panel will always
// be shown modally. Clean up the non-modal code below.
if (!PresentNTPPanelModally()) {
// Make sure we are on the Home panel on iPad when NTP is shown modally.
chrome_test_util::OpenNewTab();
[[EarlGrey selectElementWithMatcher:chrome_test_util::Omnibox()]
performAction:grey_typeText(@"chrome://newtab/#most_visited\n")];
......@@ -181,7 +184,9 @@ GREYElementInteraction* CellWithMatcher(id<GREYMatcher> matcher) {
ReadingListModelFactory::GetForBrowserState(self.browserState);
readingListModel->DeleteAllEntries();
[super setUp];
if (IsIPadIdiom()) {
// TODO(crbug.com/753599): When old bookmark is removed, NTP panel will always
// be shown modally. Clean up the non-modal code below.
if (!PresentNTPPanelModally()) {
[[EarlGrey selectElementWithMatcher:
chrome_test_util::ButtonWithAccessibilityLabelId(
IDS_IOS_NEW_TAB_HOME)] performAction:grey_tap()];
......
......@@ -5,6 +5,7 @@
#import <EarlGrey/EarlGrey.h>
#import <XCTest/XCTest.h>
#include "base/ios/ios_util.h"
#include "base/strings/sys_string_conversions.h"
#include "base/test/scoped_command_line.h"
#include "components/reading_list/core/reading_list_model.h"
......@@ -21,6 +22,8 @@
#import "ios/chrome/browser/ui/content_suggestions/ntp_home_constant.h"
#import "ios/chrome/browser/ui/content_suggestions/ntp_home_provider_test_singleton.h"
#import "ios/chrome/browser/ui/content_suggestions/ntp_home_test_utils.h"
#import "ios/chrome/browser/ui/ntp/modal_ntp.h"
#import "ios/chrome/browser/ui/ntp/new_tab_page_controller.h"
#include "ios/chrome/browser/ui/ui_util.h"
#import "ios/chrome/browser/ui/uikit_ui_util.h"
#include "ios/chrome/grit/ios_strings.h"
......@@ -83,11 +86,17 @@ std::unique_ptr<net::test_server::HttpResponse> StandardResponse(
+ (void)setUp {
[super setUp];
if (IsIPadIdiom()) {
// Make sure we are on the Home panel on iPad.
// TODO(crbug.com/753599): When old bookmark is removed, NTP panel will always
// be shown modally. Clean up the non-modal code below.
if (!PresentNTPPanelModally()) {
// Make sure we are on the Home panel on iPad when NTP is shown modally.
chrome_test_util::OpenNewTab();
[[EarlGrey selectElementWithMatcher:chrome_test_util::Omnibox()]
performAction:grey_typeText(@"chrome://newtab/#most_visited\n")];
NewTabPageController* ntp_controller =
chrome_test_util::GetCurrentNewTabPageController();
[ntp_controller selectPanel:ntp_home::HOME_PANEL];
[[GREYUIThreadExecutor sharedInstance] drainUntilIdle];
}
// Clear the pasteboard in case there is a URL copied, triggering an omnibox
......@@ -390,6 +399,11 @@ std::unique_ptr<net::test_server::HttpResponse> StandardResponse(
// Tests that tapping the fake omnibox focuses the real omnibox.
- (void)testTapFakeOmnibox {
// TODO(crbug.com/753098): Re-enable this test on iOS 11 iPad once
// grey_typeText works on iOS 11.
if (IsIPadIdiom() && base::ios::IsRunningOnIOS11OrLater()) {
EARL_GREY_TEST_DISABLED(@"Test disabled on iOS 11.");
}
// Setup the server.
self.testServer->RegisterRequestHandler(base::Bind(&StandardResponse));
GREYAssertTrue(self.testServer->Start(), @"Test server failed to start.");
......
......@@ -175,9 +175,8 @@ const CGFloat kScrollDisplacement = 50.0;
// Tests that keyboard commands are not registered when the Bookmarks UI is
// shown on iPhone and registered on iPad.
// TODO(crbug.com/695749): Check if we need to rewrite this test for the new
// Bookmarks UI.
- (void)testKeyboardCommandsNotRegistered_BookmarksPresented {
// TODO(crbug.com/782551): Rewrite this test for the new Bookmarks UI.
base::test::ScopedFeatureList scoped_feature_list;
scoped_feature_list.InitAndDisableFeature(kBookmarkNewGeneration);
......
......@@ -298,6 +298,7 @@ source_set("eg_tests") {
"new_tab_page_egtest.mm",
]
deps = [
":modal_ntp",
":ntp_controller",
":ntp_internal",
"//components/strings",
......
......@@ -13,6 +13,7 @@
#include "ios/chrome/browser/chrome_switches.h"
#import "ios/chrome/browser/ui/commands/browser_commands.h"
#import "ios/chrome/browser/ui/content_suggestions/ntp_home_constant.h"
#import "ios/chrome/browser/ui/ntp/modal_ntp.h"
#import "ios/chrome/browser/ui/ntp/new_tab_page_controller.h"
#include "ios/chrome/browser/ui/ui_util.h"
#include "ios/chrome/grit/ios_strings.h"
......@@ -134,9 +135,8 @@ void AssertNTPScrolledToTop(bool scrolledToTop) {
}
// Tests that all items are accessible on the bookmarks page.
// TODO(crbug.com/695749): Check if we need to rewrite this test for the new
// Bookmarks UI.
- (void)testAccessibilityOnBookmarks {
// TODO(crbug.com/782551): Rewrite this test for the new Bookmarks UI.
base::test::ScopedFeatureList scoped_feature_list;
scoped_feature_list.InitAndDisableFeature(kBookmarkNewGeneration);
......@@ -234,6 +234,15 @@ void AssertNTPScrolledToTop(bool scrolledToTop) {
// Tests focusing and defocusing the NTP's omnibox.
- (void)testOmnibox {
// TODO(crbug.com/782551): Rewrite this test for the new Bookmarks UI.
base::test::ScopedFeatureList scoped_feature_list;
scoped_feature_list.InitAndDisableFeature(kBookmarkNewGeneration);
// TODO(crbug.com/782551): Remove the following when this test is rewritten.
// Re-open tabs so that scoped_feature_list will take effect on the NTP.
chrome_test_util::CloseAllTabs();
chrome_test_util::OpenNewTab();
// Empty the pasteboard: if it contains a link the Google Landing will not be
// interactable.
[UIPasteboard generalPasteboard].string = @"";
......
......@@ -84,8 +84,10 @@ source_set("eg_tests") {
"recent_tabs_table_egtest.mm",
]
deps = [
"//base/test:test_support",
"//components/strings",
"//ios/chrome/app/strings",
"//ios/chrome/browser/bookmarks:features",
"//ios/chrome/browser/ui",
"//ios/chrome/browser/ui/tools_menu",
"//ios/chrome/test/app:test_support",
......
......@@ -8,7 +8,9 @@
#import <map>
#import <string>
#include "base/test/scoped_feature_list.h"
#include "components/strings/grit/components_strings.h"
#include "ios/chrome/browser/bookmarks/bookmark_new_generation_features.h"
#include "ios/chrome/browser/ui/tools_menu/tools_menu_constants.h"
#include "ios/chrome/browser/ui/ui_util.h"
#include "ios/chrome/grit/ios_strings.h"
......@@ -104,6 +106,10 @@ id<GREYMatcher> RecentlyClosedLabelMatcher() {
// Tests that a closed tab appears in the Recent Tabs panel, and that tapping
// the entry in the Recent Tabs panel re-opens the closed tab.
- (void)testClosedTabAppearsInRecentTabsPanel {
// TODO(crbug.com/782551): Rewrite this egtest for the new bookmark.
base::test::ScopedFeatureList scoped_feature_list;
scoped_feature_list.InitAndDisableFeature(kBookmarkNewGeneration);
const GURL testPageURL = web::test::HttpServer::MakeUrl(kURLOfTestPage);
// Open the test page in a new tab.
......@@ -154,6 +160,10 @@ id<GREYMatcher> RecentlyClosedLabelMatcher() {
// Tests that tapping "Show Full History" open the history.
- (void)testOpenHistory {
// TODO(crbug.com/782551): Rewrite this egtest for the new bookmark.
base::test::ScopedFeatureList scoped_feature_list;
scoped_feature_list.InitAndDisableFeature(kBookmarkNewGeneration);
OpenRecentTabsPanel();
// Tap "Show Full History"
......
......@@ -465,9 +465,8 @@ void WaitForMatcher(id<GREYMatcher> matcher) {
// Opens the sign in screen from the bookmarks and then cancel it by opening a
// new tab. Ensures that the sign in screen is correctly dismissed.
// Regression test for crbug.com/596029.
// TODO(crbug.com/695749): Check if we need to rewrite this test for the new
// Bookmarks UI.
- (void)testSignInCancelFromBookmarks {
// TODO(crbug.com/782551): Rewrite this test for the new Bookmarks UI.
base::test::ScopedFeatureList scoped_feature_list;
scoped_feature_list.InitAndDisableFeature(kBookmarkNewGeneration);
......
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