Skip to content

Commit

Permalink
[iOS] Mark some bubble_presenter_egtest as not flaky
Browse files Browse the repository at this point in the history
As a follow up of crrev.com/c/5660862, re-enable all disabled IPH tests.

Also fixes a bug that the test checks for PTR IPH before the page
is fully reloaded from an omnibox reload.

To gardener: If any of the tests are still flaky, please disable the
flaky test and re-open the related bug, instead of reverting this CL.

Thanks!

Bug: 40278143,329078389,328732643
Change-Id: I175a33242310b98bcd375544b92d8a49f4465918
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5661038
Reviewed-by: Nicolas MacBeth <nicolasmacbeth@google.com>
Commit-Queue: Ginny Huang <ginnyhuang@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1320636}
  • Loading branch information
ginnnnnnny authored and pull[bot] committed Jun 28, 2024
1 parent 1826a76 commit 0817d50
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 53 deletions.
104 changes: 52 additions & 52 deletions ios/chrome/browser/bubble/ui_bundled/bubble_presenter_egtest.mm
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,24 @@
return grey_kindOfClassName(@"SecondaryToolbarView");
}

// Open split screen. Should only be invoked for iPad.
void OpenSplitScreen() {
if (![ChromeEarlGrey areMultipleWindowsSupported]) {
EARL_GREY_TEST_SKIPPED(@"Skipped for iPad without multiwindow support.");
}
[ChromeEarlGrey openNewWindow];
[ChromeEarlGrey waitForForegroundWindowCount:2];
[EarlGrey setRootMatcherForSubsequentInteractions:chrome_test_util::
WindowWithNumber(0)];
}

// Reload the current page from omnibox.
void ReloadFromOmnibox() {
[ChromeEarlGreyUI focusOmnibox];
[ChromeEarlGrey simulatePhysicalKeyboardEvent:@"\n" flags:0];
[ChromeEarlGrey waitForPageToFinishLoading];
}

} // namespace

@interface BubblePresenterTestCase : ChromeTestCase
Expand All @@ -53,6 +71,7 @@ - (void)openURLFromOmniboxWithIsAfterNewAppLaunch:(BOOL)isAfterNewAppLaunch {
// TODO(crbug.com/40916974): Use simulatePhysicalKeyboardEvent until
// replaceText can properly handle \n.
[ChromeEarlGrey simulatePhysicalKeyboardEvent:@"\n" flags:0];
[ChromeEarlGrey waitForPageToFinishLoading];
}

#pragma mark - Tests
Expand All @@ -63,19 +82,14 @@ - (void)setUp {
}

- (void)tearDown {
[ChromeEarlGrey closeAllExtraWindows];
[BaseEarlGreyTestCaseAppInterface enableFastAnimation];
ResetFirstRunRecency();
[super tearDown];
}

// Tests that the New Tab IPH can be displayed when opening an URL from omnibox.
// TODO(crbug.com/40278143): Test is flaky on device. Re-enable the test.
#if !TARGET_OS_SIMULATOR
#define MAYBE_testNewTabIPH FLAKY_testNewTabIPH
#else
#define MAYBE_testNewTabIPH testNewTabIPH
#endif
- (void)MAYBE_testNewTabIPH {
- (void)testNewTabIPH {
RelaunchWithIPHFeature(@"IPH_iOSNewTabToolbarItemFeature",
/*safari_switcher=*/YES);
[self openURLFromOmniboxWithIsAfterNewAppLaunch:YES];
Expand All @@ -87,13 +101,7 @@ - (void)MAYBE_testNewTabIPH {

// Tests that the Tab Grid IPH can be displayed when opening a new tab and there
// are multiple tabs.
// TODO(crbug.com/40278143): Test is flaky on device. Re-enable the test.
#if !TARGET_OS_SIMULATOR
#define MAYBE_testTabGridIPH FLAKY_testTabGridIPH
#else
#define MAYBE_testTabGridIPH testTabGridIPH
#endif
- (void)MAYBE_testTabGridIPH {
- (void)testTabGridIPH {
RelaunchWithIPHFeature(@"IPH_iOSTabGridToolbarItemFeature",
/*safari_switcher=*/YES);
[ChromeEarlGrey openNewTab];
Expand All @@ -105,28 +113,21 @@ - (void)MAYBE_testTabGridIPH {

// Tests that the pull-to-refresh IPH is atttempted when user taps the omnibox
// to reload the same page, and disappears after the user navigates away.
// TODO(crbug.com/329078389): This test is flaky on simulator.
#if TARGET_IPHONE_SIMULATOR
#define MAYBE_testPullToRefreshIPHAfterReloadFromOmniboxAndDisappearsAfterNavigation \
FLAKY_testPullToRefreshIPHAfterReloadFromOmniboxAndDisappearsAfterNavigation
#else
#define MAYBE_testPullToRefreshIPHAfterReloadFromOmniboxAndDisappearsAfterNavigation \
testPullToRefreshIPHAfterReloadFromOmniboxAndDisappearsAfterNavigation
#endif
- (void)
MAYBE_testPullToRefreshIPHAfterReloadFromOmniboxAndDisappearsAfterNavigation {
- (void)testPullToRefreshIPHAfterReloadFromOmniboxAndDisappearsAfterNavigation {
RelaunchWithIPHFeature(@"IPH_iOSPullToRefreshFeature",
/*safari_switcher=*/YES);
if ([ChromeEarlGrey isIPadIdiom]) {
OpenSplitScreen();
}
[BaseEarlGreyTestCaseAppInterface disableFastAnimation];

GREYAssertTrue(self.testServer->Start(), @"Server did not start.");
const GURL destinationUrl1 = self.testServer->GetURL("/pony.html");
const GURL destinationUrl2 =
self.testServer->GetURL("/chromium_logo_page.html");
[ChromeEarlGrey loadURL:destinationUrl1];
[ChromeEarlGrey loadURL:destinationUrl2];
[ChromeEarlGreyUI focusOmnibox];
[ChromeEarlGrey simulatePhysicalKeyboardEvent:@"\n" flags:0];
[ChromeEarlGrey loadURL:destinationUrl1 inWindowWithNumber:0];
[ChromeEarlGrey loadURL:destinationUrl2 inWindowWithNumber:0];
ReloadFromOmnibox();
AssertGestureIPHVisibleWithDismissAction(
@"Pull to refresh IPH did not appear after reloading from omnibox.", ^{
[[EarlGrey selectElementWithMatcher:BackButton()]
Expand All @@ -139,22 +140,23 @@ - (void)MAYBE_testTabGridIPH {
// Tests that the pull-to-refresh IPH is attempted when user reloads the page
// using context menu.
- (void)testPullToRefreshIPHAfterReloadFromContextMenuAndDisappearsOnSwitchTab {
if ([ChromeEarlGrey isIPadIdiom]) {
EARL_GREY_TEST_SKIPPED(@"Skipped for iPad (no reload in context menu)");
}
RelaunchWithIPHFeature(@"IPH_iOSPullToRefreshFeature",
/*safari_switcher=*/YES);
if ([ChromeEarlGrey isIPadIdiom]) {
EARL_GREY_TEST_SKIPPED(@"Skipped for iPad.");
}
[BaseEarlGreyTestCaseAppInterface disableFastAnimation];

GREYAssertTrue(self.testServer->Start(), @"Server did not start.");
const GURL destinationUrl1 = self.testServer->GetURL("/pony.html");
const GURL destinationUrl2 =
self.testServer->GetURL("/chromium_logo_page.html");
[ChromeEarlGrey loadURL:destinationUrl1];
[ChromeEarlGrey loadURL:destinationUrl1 inWindowWithNumber:0];
[ChromeEarlGrey openNewTab];
[ChromeEarlGrey loadURL:destinationUrl2];
[ChromeEarlGrey loadURL:destinationUrl2 inWindowWithNumber:0];
// Reload using context menu.
[ChromeEarlGreyUI reload];
[ChromeEarlGrey waitForPageToFinishLoading];
AssertGestureIPHVisibleWithDismissAction(
@"Pull to refresh IPH did not appear after reloading from context menu.",
^{
Expand All @@ -170,13 +172,15 @@ - (void)testPullToRefreshIPHAfterReloadFromContextMenuAndDisappearsOnSwitchTab {
- (void)testPullToRefreshIPHShouldDisappearOnEnteringTabGrid {
RelaunchWithIPHFeature(@"IPH_iOSPullToRefreshFeature",
/*safari_switcher=*/YES);
if ([ChromeEarlGrey isIPadIdiom]) {
OpenSplitScreen();
}
[BaseEarlGreyTestCaseAppInterface disableFastAnimation];

GREYAssertTrue(self.testServer->Start(), @"Server did not start.");
const GURL destinationUrl = self.testServer->GetURL("/pony.html");
[ChromeEarlGrey loadURL:destinationUrl];
[ChromeEarlGreyUI focusOmnibox];
[ChromeEarlGrey simulatePhysicalKeyboardEvent:@"\n" flags:0];
[ChromeEarlGrey loadURL:destinationUrl inWindowWithNumber:0];
ReloadFromOmnibox();
AssertGestureIPHVisibleWithDismissAction(
@"Pull to refresh IPH did not appear after reloading from omnibox.", ^{
[ChromeEarlGreyUI openTabGrid];
Expand All @@ -195,31 +199,25 @@ - (void)testPullToRefreshIPHShouldDisappearOnEnteringTabGrid {
- (void)testPullToRefreshIPHShouldNotShowOnPageLoadFail {
RelaunchWithIPHFeature(@"IPH_iOSPullToRefreshFeature",
/*safari_switcher=*/YES);
if ([ChromeEarlGrey isIPadIdiom]) {
OpenSplitScreen();
}
[BaseEarlGreyTestCaseAppInterface disableFastAnimation];

GREYAssertTrue(self.testServer->Start(), @"Server did not start.");
const GURL destinationUrl = self.testServer->GetURL("/pony.html");
[ChromeEarlGrey loadURL:destinationUrl];
[ChromeEarlGrey loadURL:destinationUrl inWindowWithNumber:0];
// Cut off server.
GREYAssertTrue(self.testServer->ShutdownAndWaitUntilComplete(),
@"Server did not shut down.");
[ChromeEarlGreyUI focusOmnibox];
[ChromeEarlGrey simulatePhysicalKeyboardEvent:@"\n" flags:0];
ReloadFromOmnibox();
AssertGestureIPHInvisible(
@"Pull to refresh IPH still appeared despite loading fails.");
}

// Tests that the swipe back/forward IPH is attempted on navigation, and
// disappears when user leaves the page.
// TODO(crbug.com/328732643): This test is flaky on simulator.
#if TARGET_IPHONE_SIMULATOR
#define MAYBE_testSwipeBackForwardIPHShowsOnNavigationAndHidesOnNavigation \
FLAKY_testSwipeBackForwardIPHShowsOnNavigationAndHidesOnNavigation
#else
#define MAYBE_testSwipeBackForwardIPHShowsOnNavigationAndHidesOnNavigation \
testSwipeBackForwardIPHShowsOnNavigationAndHidesOnNavigation
#endif
- (void)MAYBE_testSwipeBackForwardIPHShowsOnNavigationAndHidesOnNavigation {
- (void)testSwipeBackForwardIPHShowsOnNavigationAndHidesOnNavigation {
RelaunchWithIPHFeature(@"IPH_iOSSwipeBackForward", /*safari_switcher=*/NO);
[BaseEarlGreyTestCaseAppInterface disableFastAnimation];

Expand All @@ -246,17 +244,19 @@ - (void)MAYBE_testSwipeBackForwardIPHShowsOnNavigationAndHidesOnNavigation {
- (void)testPullToRefreshPerformAction {
RelaunchWithIPHFeature(@"IPH_iOSPullToRefreshFeature",
/*safari_switcher=*/YES);
if ([ChromeEarlGrey isIPadIdiom]) {
OpenSplitScreen();
}
[BaseEarlGreyTestCaseAppInterface disableFastAnimation];

// Trigger pull-to-refresh IPH.
GREYAssertTrue(self.testServer->Start(), @"Server did not start.");
const GURL destinationUrl1 = self.testServer->GetURL("/pony.html");
const GURL destinationUrl2 =
self.testServer->GetURL("/chromium_logo_page.html");
[ChromeEarlGrey loadURL:destinationUrl1];
[ChromeEarlGrey loadURL:destinationUrl2];
[ChromeEarlGreyUI focusOmnibox];
[ChromeEarlGrey simulatePhysicalKeyboardEvent:@"\n" flags:0];
[ChromeEarlGrey loadURL:destinationUrl1 inWindowWithNumber:0];
[ChromeEarlGrey loadURL:destinationUrl2 inWindowWithNumber:0];
ReloadFromOmnibox();
AssertGestureIPHVisibleWithDismissAction(
@"Pull to refresh IPH did not appear after reloading from omnibox.", ^{
// Swipe down.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ void RelaunchWithIPHFeature(NSString* feature, BOOL safari_switcher);
void AssertGestureIPHVisibleWithDismissAction(NSString* description,
void (^action)(void));

// Checks if it disappears within a reasonable wait time or is never visible.
// Asserts that the gesture IPH is invisible. If it is visible when this
// function is called, asserts that it is dismissed within a reasonable wait
// time.
void AssertGestureIPHInvisible(NSString* description);

// Taps "Dismiss" button with animation running.
Expand Down

0 comments on commit 0817d50

Please sign in to comment.