Commit 7a8f6d46 authored by Moe Ahmadi's avatar Moe Ahmadi Committed by Commit Bot

[PR] Fixes the flaky PaymentRequestShowEGTest.testBuyWithResolvingPromise

-As EG synchronization is disabled, manually waits until payment screen
 shows.
-Clears profiles before starting each test, so that each test starts with
 a clean state.

Bug:833562

Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: I4e21537e91e57a7f38ff3715f4999ad73481eb56
Reviewed-on: https://chromium-review.googlesource.com/1059654Reviewed-by: default avatarMoe Ahmadi <mahmadi@chromium.org>
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#559444}
parent 39a0856c
...@@ -67,6 +67,12 @@ const NSTimeInterval kPDMMaxDelaySeconds = 10.0; ...@@ -67,6 +67,12 @@ const NSTimeInterval kPDMMaxDelaySeconds = 10.0;
_personalDataManager = _personalDataManager =
autofill::PersonalDataManagerFactory::GetForBrowserState( autofill::PersonalDataManagerFactory::GetForBrowserState(
chrome_test_util::GetOriginalBrowserState()); chrome_test_util::GetOriginalBrowserState());
// Before starting, clear existing profiles.
for (const auto* profile : _personalDataManager->GetProfiles()) {
[self personalDataManager]->RemoveByGUID(profile->guid());
}
_personalDataManager->SetSyncingForTest(true); _personalDataManager->SetSyncingForTest(true);
} }
......
...@@ -90,9 +90,17 @@ id<GREYMatcher> PriceCellMatcher(NSString* accessibilityLabel) { ...@@ -90,9 +90,17 @@ id<GREYMatcher> PriceCellMatcher(NSString* accessibilityLabel) {
[ChromeEarlGrey tapWebViewElementWithID:@"buyWithResolvingPromise"]; [ChromeEarlGrey tapWebViewElementWithID:@"buyWithResolvingPromise"];
// Confirm that the Payment Request UI is showing. // Wait until the payment request view shows.
[[EarlGrey selectElementWithMatcher:chrome_test_util::PaymentRequestView()] ConditionBlock condition = ^{
assertWithMatcher:grey_notNil()]; NSError* error = nil;
[[EarlGrey selectElementWithMatcher:chrome_test_util::PaymentRequestView()]
assertWithMatcher:grey_notNil()
error:&error];
return error == nil;
};
GREYAssert(
testing::WaitUntilConditionOrTimeout(kShowPromiseTimeout, condition),
@"Payment request view failed to show.");
// Verify that the Buy button is not enabled. // Verify that the Buy button is not enabled.
[[EarlGrey selectElementWithMatcher:ButtonWithAccessibilityLabelId( [[EarlGrey selectElementWithMatcher:ButtonWithAccessibilityLabelId(
...@@ -100,7 +108,7 @@ id<GREYMatcher> PriceCellMatcher(NSString* accessibilityLabel) { ...@@ -100,7 +108,7 @@ id<GREYMatcher> PriceCellMatcher(NSString* accessibilityLabel) {
assertWithMatcher:grey_not(grey_enabled())]; assertWithMatcher:grey_not(grey_enabled())];
// Wait until the Buy button becomes enabled. // Wait until the Buy button becomes enabled.
ConditionBlock condition = ^{ condition = ^{
NSError* error = nil; NSError* error = nil;
[[EarlGrey selectElementWithMatcher:ButtonWithAccessibilityLabelId( [[EarlGrey selectElementWithMatcher:ButtonWithAccessibilityLabelId(
IDS_PAYMENTS_PAY_BUTTON)] IDS_PAYMENTS_PAY_BUTTON)]
......
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