Commit 4b36f81f authored by Mike Dougherty's avatar Mike Dougherty Committed by Commit Bot

[iOS] Fix resend post request FormsTestCases

With SlimNavigationManager enabled, the resent post request dialog is
presented while the load is still ongoing. On iPad, this displays a
loading spinner on the tab UI which interferes with EarlGrey
synchronization.

Disable synchronization while the dialog is shown if
SlimNavigationManager is enabled.

Bug: 968296
Change-Id: Ib67693a451dd8170746b4f2329ca4eed82fc254e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1645434Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Commit-Queue: Mike Dougherty <michaeldo@chromium.org>
Auto-Submit: Mike Dougherty <michaeldo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#666439}
parent 32281535
......@@ -12,13 +12,13 @@
#import "base/test/ios/wait_util.h"
#include "components/strings/grit/components_strings.h"
#import "ios/chrome/browser/ui/popup_menu/popup_menu_constants.h"
#include "ios/chrome/browser/ui/util/ui_util.h"
#import "ios/chrome/test/app/chrome_test_util.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h"
#import "ios/chrome/test/earl_grey/chrome_error_util.h"
#import "ios/chrome/test/earl_grey/chrome_matchers.h"
#import "ios/chrome/test/earl_grey/chrome_test_case.h"
#import "ios/chrome/test/scoped_eg_synchronization_disabler.h"
#import "ios/testing/earl_grey/matchers.h"
#import "ios/web/public/test/earl_grey/web_view_actions.h"
#import "ios/web/public/test/earl_grey/web_view_matchers.h"
......@@ -206,11 +206,6 @@ id<GREYMatcher> ResendPostButtonMatcher() {
// Tests that a POST followed by reloading the destination page resends data.
- (void)testRepostFormAfterReload {
if (IsIPadIdiom() && web::GetWebClient()->IsSlimNavigationManagerEnabled()) {
// TODO(crbug.com/968296): Re-enable this test on iPad.
EARL_GREY_TEST_DISABLED(@"Test disabled with Slim Navigation.");
}
[self setUpFormTestSimpleHttpServer];
const GURL destinationURL = GetDestinationUrl();
......@@ -231,7 +226,22 @@ id<GREYMatcher> ResendPostButtonMatcher() {
// loading stops.
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey reload]);
}
[self confirmResendWarning];
{
// When slim navigation manager is enabled, synchronization must be disabled
// until after the repost confirmation is dismissed because it is presented
// during the load. It is always disabled, but immediately re-enabled if
// slim navigation manger is not enabled. This is necessary in order to keep
// the correct scope of ScopedSynchronizationDisabler which ensures
// synchronization is not left disabled if the test fails.
std::unique_ptr<ScopedSynchronizationDisabler> disabler =
std::make_unique<ScopedSynchronizationDisabler>();
if (!web::GetWebClient()->IsSlimNavigationManagerEnabled()) {
disabler.reset();
}
[self confirmResendWarning];
}
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey waitForWebStateContainingText:kDestinationText]);
......@@ -242,11 +252,6 @@ id<GREYMatcher> ResendPostButtonMatcher() {
// Tests that a POST followed by navigating to a new page and then tapping back
// to the form result page resends data.
- (void)testRepostFormAfterTappingBack {
// TODO(crbug.com/968296): Test is failing on iPad for slim nav.
if (IsIPadIdiom() && web::GetWebClient()->IsSlimNavigationManagerEnabled()) {
EARL_GREY_TEST_DISABLED(@"Test disabled on iPad.");
}
[self setUpFormTestSimpleHttpServer];
const GURL destinationURL = GetDestinationUrl();
......@@ -270,7 +275,22 @@ id<GREYMatcher> ResendPostButtonMatcher() {
[chrome_test_util::BrowserCommandDispatcherForMainBVC() reload];
}
[self confirmResendWarning];
{
// When slim navigation manager is enabled, synchronization must be disabled
// until after the repost confirmation is dismissed because it is presented
// during the load. It is always disabled, but immediately re-enabled if
// slim navigation manger is not enabled. This is necessary in order to keep
// the correct scope of ScopedSynchronizationDisabler which ensures
// synchronization is not left disabled if the test fails.
std::unique_ptr<ScopedSynchronizationDisabler> disabler =
std::make_unique<ScopedSynchronizationDisabler>();
if (!web::GetWebClient()->IsSlimNavigationManagerEnabled()) {
disabler.reset();
}
[self confirmResendWarning];
}
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey waitForWebStateContainingText:kDestinationText]);
[[EarlGrey selectElementWithMatcher:OmniboxText(destinationURL.GetContent())]
......@@ -280,11 +300,6 @@ id<GREYMatcher> ResendPostButtonMatcher() {
// Tests that a POST followed by tapping back to the form page and then tapping
// forward to the result page resends data.
- (void)testRepostFormAfterTappingBackAndForward {
// TODO(crbug.com/968296): Test is failing on iPad for slim nav.
if (IsIPadIdiom() && web::GetWebClient()->IsSlimNavigationManagerEnabled()) {
EARL_GREY_TEST_DISABLED(@"Test disabled on iPad.");
}
[self setUpFormTestSimpleHttpServer];
const GURL destinationURL = GetDestinationUrl();
......@@ -307,7 +322,22 @@ id<GREYMatcher> ResendPostButtonMatcher() {
[chrome_test_util::BrowserCommandDispatcherForMainBVC() reload];
}
[self confirmResendWarning];
{
// When slim navigation manager is enabled, synchronization must be disabled
// until after the repost confirmation is dismissed because it is presented
// during the load. It is always disabled, but immediately re-enabled if
// slim navigation manger is not enabled. This is necessary in order to keep
// the correct scope of ScopedSynchronizationDisabler which ensures
// synchronization is not left disabled if the test fails.
std::unique_ptr<ScopedSynchronizationDisabler> disabler =
std::make_unique<ScopedSynchronizationDisabler>();
if (!web::GetWebClient()->IsSlimNavigationManagerEnabled()) {
disabler.reset();
}
[self confirmResendWarning];
}
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey waitForWebStateContainingText:kDestinationText]);
[[EarlGrey selectElementWithMatcher:OmniboxText(destinationURL.GetContent())]
......@@ -373,8 +403,23 @@ id<GREYMatcher> ResendPostButtonMatcher() {
[chrome_test_util::BrowserCommandDispatcherForMainBVC() reload];
}
[[EarlGrey selectElementWithMatcher:ElementToDismissAlert(@"Cancel")]
performAction:grey_tap()];
{
// When slim navigation manager is enabled, synchronization must be disabled
// until after the repost confirmation is dismissed because it is presented
// during the load. It is always disabled, but immediately re-enabled if
// slim navigation manger is not enabled. This is necessary in order to keep
// the correct scope of ScopedSynchronizationDisabler which ensures
// synchronization is not left disabled if the test fails.
std::unique_ptr<ScopedSynchronizationDisabler> disabler =
std::make_unique<ScopedSynchronizationDisabler>();
if (!web::GetWebClient()->IsSlimNavigationManagerEnabled()) {
disabler.reset();
}
[[EarlGrey selectElementWithMatcher:ElementToDismissAlert(@"Cancel")]
performAction:grey_tap()];
}
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey waitForPageToFinishLoading]);
// Expected behavior is different between the two navigation manager
......@@ -425,6 +470,18 @@ id<GREYMatcher> ResendPostButtonMatcher() {
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey reload]);
}
// When slim navigation manager is enabled, synchronization must be disabled
// until after the repost confirmation is dismissed because it is presented
// during the load. It is always disabled, but immediately re-enabled if
// slim navigation manger is not enabled. This is necessary in order to keep
// the correct scope of ScopedSynchronizationDisabler which ensures
// synchronization is not left disabled if the test fails.
std::unique_ptr<ScopedSynchronizationDisabler> disabler =
std::make_unique<ScopedSynchronizationDisabler>();
if (!web::GetWebClient()->IsSlimNavigationManagerEnabled()) {
disabler.reset();
}
// Repost confirmation box should be visible.
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey
waitForSufficientlyVisibleElementWithMatcher:ResendPostButtonMatcher()]);
......
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