Commit 7b459a69 authored by Eric Aleshire's avatar Eric Aleshire Committed by Commit Bot

Introduce ASSERT_IF_ERROR, used test-side to wrap methods that return NSError*.

As part of the EG2 migration, app-side helpers that used to GREYAssert now
return NSError*, which are asserted on in test-side code. ASSERT_IF_ERROR
simplifies the modification required for test code that call these app-side
helpers, while preserving the line number of the failure.

This CL aligns the test code in these 4 CLs to use ASSERT_IF_ERROR:
http://crrev.com/c/1562756
http://crrev.com/c/1553085
http://crrev.com/c/1558155
http://crrev.com/c/1559889

Bug: 922813
Change-Id: I2d82dd9cd6a9eab6913418d357649c1f13f3699f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1574954
Commit-Queue: ericale <ericale@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#652855}
parent 287e77d7
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#import "ios/chrome/test/earl_grey/chrome_actions.h" #import "ios/chrome/test/earl_grey/chrome_actions.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey.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_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_matchers.h"
#import "ios/chrome/test/earl_grey/chrome_test_case.h" #import "ios/chrome/test/earl_grey/chrome_test_case.h"
#import "ios/web/public/test/earl_grey/web_view_matchers.h" #import "ios/web/public/test/earl_grey/web_view_matchers.h"
...@@ -150,16 +151,13 @@ void CloseTabAtIndexAndSync(NSUInteger i) { ...@@ -150,16 +151,13 @@ void CloseTabAtIndexAndSync(NSUInteger i) {
kSelectedTabHistogramName, TabUsageRecorder::IN_MEMORY, 1, failureBlock); kSelectedTabHistogramName, TabUsageRecorder::IN_MEMORY, 1, failureBlock);
// Evict the tab. // Evict the tab.
NSError* openError = OpenNewIncognitoTabUsingUIAndEvictMainTabs(); CHROME_EG_ASSERT_ON_ERROR(OpenNewIncognitoTabUsingUIAndEvictMainTabs());
GREYAssertNil(openError, openError.localizedDescription);
GREYAssertTrue(chrome_test_util::IsIncognitoMode(), GREYAssertTrue(chrome_test_util::IsIncognitoMode(),
@"Failed to switch to incognito mode"); @"Failed to switch to incognito mode");
// Switch back to the normal tabs. Should be on tab one. // Switch back to the normal tabs. Should be on tab one.
CHROME_EG_ASSERT_ON_ERROR(SwitchToNormalMode());
NSError* switchError = SwitchToNormalMode();
GREYAssertNil(switchError, switchError.localizedDescription);
[ChromeEarlGrey waitForWebViewContainingText:kURL1FirstWord]; [ChromeEarlGrey waitForWebViewContainingText:kURL1FirstWord];
...@@ -221,13 +219,11 @@ void CloseTabAtIndexAndSync(NSUInteger i) { ...@@ -221,13 +219,11 @@ void CloseTabAtIndexAndSync(NSUInteger i) {
// Evict the tab. Create a dummy tab so that switching back to normal mode // Evict the tab. Create a dummy tab so that switching back to normal mode
// does not trigger a reload immediately. // does not trigger a reload immediately.
[ChromeEarlGrey openNewTab]; [ChromeEarlGrey openNewTab];
NSError* openError = OpenNewIncognitoTabUsingUIAndEvictMainTabs(); CHROME_EG_ASSERT_ON_ERROR(OpenNewIncognitoTabUsingUIAndEvictMainTabs());
GREYAssertNil(openError, openError.localizedDescription);
[ChromeEarlGrey waitForIncognitoTabCount:1]; [ChromeEarlGrey waitForIncognitoTabCount:1];
// Switch back to the normal tabs. Should be on tab one. // Switch back to the normal tabs. Should be on tab one.
NSError* switchError = SwitchToNormalMode(); CHROME_EG_ASSERT_ON_ERROR(SwitchToNormalMode());
GREYAssertNil(switchError, switchError.localizedDescription);
chrome_test_util::SelectTabAtIndexInCurrentMode(0); chrome_test_util::SelectTabAtIndexInCurrentMode(0);
[ChromeEarlGrey waitForWebViewContainingText:kURL1FirstWord]; [ChromeEarlGrey waitForWebViewContainingText:kURL1FirstWord];
...@@ -262,16 +258,13 @@ void CloseTabAtIndexAndSync(NSUInteger i) { ...@@ -262,16 +258,13 @@ void CloseTabAtIndexAndSync(NSUInteger i) {
@"Fail to state tabs as cold start tabs"); @"Fail to state tabs as cold start tabs");
// Open two incognito tabs with urls, clearing normal tabs from memory. // Open two incognito tabs with urls, clearing normal tabs from memory.
NSError* firstTabError = OpenNewIncognitoTabUsingUIAndEvictMainTabs(); CHROME_EG_ASSERT_ON_ERROR(OpenNewIncognitoTabUsingUIAndEvictMainTabs());
GREYAssertNil(firstTabError, firstTabError.localizedDescription); CHROME_EG_ASSERT_ON_ERROR(OpenNewIncognitoTabUsingUIAndEvictMainTabs());
NSError* secondTabError = OpenNewIncognitoTabUsingUIAndEvictMainTabs();
GREYAssertNil(secondTabError, secondTabError.localizedDescription);
[ChromeEarlGrey waitForIncognitoTabCount:2]; [ChromeEarlGrey waitForIncognitoTabCount:2];
// Switch back to the normal tabs. // Switch back to the normal tabs.
NSError* switchError = SwitchToNormalMode(); CHROME_EG_ASSERT_ON_ERROR(SwitchToNormalMode());
GREYAssertNil(switchError, switchError.localizedDescription);
[ChromeEarlGrey waitForWebViewContainingText:kURL2FirstWord]; [ChromeEarlGrey waitForWebViewContainingText:kURL2FirstWord];
...@@ -321,15 +314,13 @@ void CloseTabAtIndexAndSync(NSUInteger i) { ...@@ -321,15 +314,13 @@ void CloseTabAtIndexAndSync(NSUInteger i) {
@"Fail to simulate tab backgrounding."); @"Fail to simulate tab backgrounding.");
// Open incognito and clear normal tabs from memory. // Open incognito and clear normal tabs from memory.
NSError* openError = OpenNewIncognitoTabUsingUIAndEvictMainTabs(); CHROME_EG_ASSERT_ON_ERROR(OpenNewIncognitoTabUsingUIAndEvictMainTabs());
GREYAssertNil(openError, openError.localizedDescription);
GREYAssertTrue(chrome_test_util::IsIncognitoMode(), GREYAssertTrue(chrome_test_util::IsIncognitoMode(),
@"Failed to switch to incognito mode"); @"Failed to switch to incognito mode");
histogramTester.ExpectTotalCount(kEvictedTabReloadTime, 0, failureBlock); histogramTester.ExpectTotalCount(kEvictedTabReloadTime, 0, failureBlock);
// Switch back to the normal tabs. // Switch back to the normal tabs.
NSError* switchError = SwitchToNormalMode(); CHROME_EG_ASSERT_ON_ERROR(SwitchToNormalMode());
GREYAssertNil(switchError, switchError.localizedDescription);
[ChromeEarlGrey waitForWebViewContainingText:kURL2FirstWord]; [ChromeEarlGrey waitForWebViewContainingText:kURL2FirstWord];
...@@ -361,11 +352,8 @@ void CloseTabAtIndexAndSync(NSUInteger i) { ...@@ -361,11 +352,8 @@ void CloseTabAtIndexAndSync(NSUInteger i) {
[ChromeEarlGrey closeAllTabsInCurrentMode]; [ChromeEarlGrey closeAllTabsInCurrentMode];
GURL URL = web::test::HttpServer::MakeUrl(kTestUrl1); GURL URL = web::test::HttpServer::MakeUrl(kTestUrl1);
NewMainTabWithURL(URL, kURL1FirstWord); NewMainTabWithURL(URL, kURL1FirstWord);
NSError* openError = OpenNewIncognitoTabUsingUIAndEvictMainTabs(); CHROME_EG_ASSERT_ON_ERROR(OpenNewIncognitoTabUsingUIAndEvictMainTabs());
GREYAssertNil(openError, openError.localizedDescription); CHROME_EG_ASSERT_ON_ERROR(SwitchToNormalMode());
NSError* switchError = SwitchToNormalMode();
GREYAssertNil(switchError, switchError.localizedDescription);
[ChromeEarlGrey waitForWebViewContainingText:kURL1FirstWord]; [ChromeEarlGrey waitForWebViewContainingText:kURL1FirstWord];
[ChromeEarlGrey waitForMainTabCount:1]; [ChromeEarlGrey waitForMainTabCount:1];
...@@ -398,8 +386,7 @@ void CloseTabAtIndexAndSync(NSUInteger i) { ...@@ -398,8 +386,7 @@ void CloseTabAtIndexAndSync(NSUInteger i) {
[ChromeEarlGrey openNewTab]; [ChromeEarlGrey openNewTab];
[ChromeEarlGrey openNewTab]; [ChromeEarlGrey openNewTab];
chrome_test_util::LoadUrl(slowURL); chrome_test_util::LoadUrl(slowURL);
NSError* openError = OpenNewIncognitoTabUsingUIAndEvictMainTabs(); CHROME_EG_ASSERT_ON_ERROR(OpenNewIncognitoTabUsingUIAndEvictMainTabs());
GREYAssertNil(openError, openError.localizedDescription);
web::test::SetUpHttpServer(std::make_unique<web::DelayedResponseProvider>( web::test::SetUpHttpServer(std::make_unique<web::DelayedResponseProvider>(
std::make_unique<HtmlResponseProvider>(responses), kSlowURLDelay)); std::make_unique<HtmlResponseProvider>(responses), kSlowURLDelay));
...@@ -451,8 +438,7 @@ void CloseTabAtIndexAndSync(NSUInteger i) { ...@@ -451,8 +438,7 @@ void CloseTabAtIndexAndSync(NSUInteger i) {
NewMainTabWithURL(slowURL, "Slow"); NewMainTabWithURL(slowURL, "Slow");
NSError* openError = OpenNewIncognitoTabUsingUIAndEvictMainTabs(); CHROME_EG_ASSERT_ON_ERROR(OpenNewIncognitoTabUsingUIAndEvictMainTabs());
GREYAssertNil(openError, openError.localizedDescription);
web::test::SetUpHttpServer(std::make_unique<web::DelayedResponseProvider>( web::test::SetUpHttpServer(std::make_unique<web::DelayedResponseProvider>(
std::make_unique<HtmlResponseProvider>(responses), kSlowURLDelay)); std::make_unique<HtmlResponseProvider>(responses), kSlowURLDelay));
...@@ -502,11 +488,8 @@ void CloseTabAtIndexAndSync(NSUInteger i) { ...@@ -502,11 +488,8 @@ void CloseTabAtIndexAndSync(NSUInteger i) {
}; };
NewMainTabWithURL(slowURL, responses[slowURL]); NewMainTabWithURL(slowURL, responses[slowURL]);
NSError* openError = OpenNewIncognitoTabUsingUIAndEvictMainTabs(); CHROME_EG_ASSERT_ON_ERROR(OpenNewIncognitoTabUsingUIAndEvictMainTabs());
GREYAssertNil(openError, openError.localizedDescription); CHROME_EG_ASSERT_ON_ERROR(SwitchToNormalMode());
NSError* switchError = SwitchToNormalMode();
GREYAssertNil(switchError, switchError.localizedDescription);
[ChromeEarlGreyUI openSettingsMenu]; [ChromeEarlGreyUI openSettingsMenu];
[ChromeEarlGreyUI tapSettingsMenuButton:SettingsMenuPrivacyButton()]; [ChromeEarlGreyUI tapSettingsMenuButton:SettingsMenuPrivacyButton()];
...@@ -535,8 +518,7 @@ void CloseTabAtIndexAndSync(NSUInteger i) { ...@@ -535,8 +518,7 @@ void CloseTabAtIndexAndSync(NSUInteger i) {
[ChromeEarlGrey openNewTab]; [ChromeEarlGrey openNewTab];
chrome_test_util::LoadUrl(slowURL); chrome_test_util::LoadUrl(slowURL);
NSError* openError = OpenNewIncognitoTabUsingUIAndEvictMainTabs(); CHROME_EG_ASSERT_ON_ERROR(OpenNewIncognitoTabUsingUIAndEvictMainTabs());
GREYAssertNil(openError, openError.localizedDescription);
web::test::SetUpHttpServer(std::make_unique<web::DelayedResponseProvider>( web::test::SetUpHttpServer(std::make_unique<web::DelayedResponseProvider>(
std::make_unique<HtmlResponseProvider>(responses), kSlowURLDelay)); std::make_unique<HtmlResponseProvider>(responses), kSlowURLDelay));
...@@ -626,11 +608,8 @@ void CloseTabAtIndexAndSync(NSUInteger i) { ...@@ -626,11 +608,8 @@ void CloseTabAtIndexAndSync(NSUInteger i) {
NSUInteger tabIndex = chrome_test_util::GetMainTabCount() - 1; NSUInteger tabIndex = chrome_test_util::GetMainTabCount() - 1;
[ChromeEarlGrey openNewTab]; [ChromeEarlGrey openNewTab];
NSError* openError = OpenNewIncognitoTabUsingUIAndEvictMainTabs(); CHROME_EG_ASSERT_ON_ERROR(OpenNewIncognitoTabUsingUIAndEvictMainTabs());
GREYAssertNil(openError, openError.localizedDescription); CHROME_EG_ASSERT_ON_ERROR(SwitchToNormalMode());
NSError* switchError = SwitchToNormalMode();
GREYAssertNil(switchError, switchError.localizedDescription);
chrome_test_util::SelectTabAtIndexInCurrentMode(tabIndex); chrome_test_util::SelectTabAtIndexInCurrentMode(tabIndex);
[ChromeEarlGrey waitForWebViewContainingText:"arrived"]; [ChromeEarlGrey waitForWebViewContainingText:"arrived"];
...@@ -677,11 +656,8 @@ void CloseTabAtIndexAndSync(NSUInteger i) { ...@@ -677,11 +656,8 @@ void CloseTabAtIndexAndSync(NSUInteger i) {
[ChromeEarlGrey waitForWebViewContainingText:"Whee"]; [ChromeEarlGrey waitForWebViewContainingText:"Whee"];
NSUInteger tabIndex = chrome_test_util::GetMainTabCount() - 1; NSUInteger tabIndex = chrome_test_util::GetMainTabCount() - 1;
[ChromeEarlGrey openNewTab]; [ChromeEarlGrey openNewTab];
NSError* openError = OpenNewIncognitoTabUsingUIAndEvictMainTabs(); CHROME_EG_ASSERT_ON_ERROR(OpenNewIncognitoTabUsingUIAndEvictMainTabs());
GREYAssertNil(openError, openError.localizedDescription); CHROME_EG_ASSERT_ON_ERROR(SwitchToNormalMode());
NSError* switchError = SwitchToNormalMode();
GREYAssertNil(switchError, switchError.localizedDescription);
chrome_test_util::SelectTabAtIndexInCurrentMode(tabIndex); chrome_test_util::SelectTabAtIndexInCurrentMode(tabIndex);
[ChromeEarlGrey waitForWebViewContainingText:"Whee"]; [ChromeEarlGrey waitForWebViewContainingText:"Whee"];
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#import "ios/chrome/test/earl_grey/chrome_actions.h" #import "ios/chrome/test/earl_grey/chrome_actions.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey.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_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_matchers.h"
#import "ios/chrome/test/earl_grey/chrome_test_case.h" #import "ios/chrome/test/earl_grey/chrome_test_case.h"
#import "ios/public/provider/chrome/browser/signin/fake_chrome_identity.h" #import "ios/public/provider/chrome/browser/signin/fake_chrome_identity.h"
...@@ -199,8 +200,7 @@ void SignOut() { ...@@ -199,8 +200,7 @@ void SignOut() {
[[EarlGrey selectElementWithMatcher:SettingsDoneButton()] [[EarlGrey selectElementWithMatcher:SettingsDoneButton()]
performAction:grey_tap()]; performAction:grey_tap()];
NSError* signedOutError = [SigninEarlGreyUtils checkSignedOut]; CHROME_EG_ASSERT_ON_ERROR([SigninEarlGreyUtils checkSignedOut]);
GREYAssertNil(signedOutError, signedOutError.localizedDescription);
} }
} // namespace } // namespace
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "ios/chrome/grit/ios_chromium_strings.h" #include "ios/chrome/grit/ios_chromium_strings.h"
#include "ios/chrome/grit/ios_strings.h" #include "ios/chrome/grit/ios_strings.h"
#import "ios/chrome/test/app/chrome_test_util.h" #import "ios/chrome/test/app/chrome_test_util.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_matchers.h"
#import "ios/chrome/test/earl_grey/chrome_test_case.h" #import "ios/chrome/test/earl_grey/chrome_test_case.h"
#import "ios/public/provider/chrome/browser/signin/fake_chrome_identity.h" #import "ios/public/provider/chrome/browser/signin/fake_chrome_identity.h"
...@@ -221,9 +222,8 @@ void WaitForMatcher(id<GREYMatcher> matcher) { ...@@ -221,9 +222,8 @@ void WaitForMatcher(id<GREYMatcher> matcher) {
[[EarlGrey selectElementWithMatcher:AccountConsistencySetupSigninButton()] [[EarlGrey selectElementWithMatcher:AccountConsistencySetupSigninButton()]
performAction:grey_tap()]; performAction:grey_tap()];
NSError* signedInError = CHROME_EG_ASSERT_ON_ERROR(
[SigninEarlGreyUtils checkSignedInWithIdentity:identity]; [SigninEarlGreyUtils checkSignedInWithIdentity:identity]);
GREYAssertNil(signedInError, signedInError.localizedDescription);
// Undo the sign-in and dismiss the Sign In screen. // Undo the sign-in and dismiss the Sign In screen.
[[EarlGrey selectElementWithMatcher:UndoAccountConsistencyButton()] [[EarlGrey selectElementWithMatcher:UndoAccountConsistencyButton()]
...@@ -232,8 +232,7 @@ void WaitForMatcher(id<GREYMatcher> matcher) { ...@@ -232,8 +232,7 @@ void WaitForMatcher(id<GREYMatcher> matcher) {
performAction:grey_tap()]; performAction:grey_tap()];
// |identity| shouldn't be signed in. // |identity| shouldn't be signed in.
NSError* signedOutError = [SigninEarlGreyUtils checkSignedOut]; CHROME_EG_ASSERT_ON_ERROR([SigninEarlGreyUtils checkSignedOut]);
GREYAssertNil(signedOutError, signedOutError.localizedDescription);
} }
// Signs in to an account and then taps the Advanced link to go to settings. // Signs in to an account and then taps the Advanced link to go to settings.
...@@ -276,9 +275,8 @@ void WaitForMatcher(id<GREYMatcher> matcher) { ...@@ -276,9 +275,8 @@ void WaitForMatcher(id<GREYMatcher> matcher) {
[[EarlGrey selectElementWithMatcher:SettingsDoneButton()] [[EarlGrey selectElementWithMatcher:SettingsDoneButton()]
performAction:grey_tap()]; performAction:grey_tap()];
NSError* signedInError2 = CHROME_EG_ASSERT_ON_ERROR(
[SigninEarlGreyUtils checkSignedInWithIdentity:identity]; [SigninEarlGreyUtils checkSignedInWithIdentity:identity]);
GREYAssertNil(signedInError2, signedInError2.localizedDescription);
GREYAssertTrue(sync_service->HasFinishedInitialSetup(), GREYAssertTrue(sync_service->HasFinishedInitialSetup(),
@"Sync should have finished its original setup"); @"Sync should have finished its original setup");
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#import "ios/chrome/test/app/web_view_interaction_test_util.h" #import "ios/chrome/test/app/web_view_interaction_test_util.h"
#import "ios/chrome/test/earl_grey/accessibility_util.h" #import "ios/chrome/test/earl_grey/accessibility_util.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey.h" #import "ios/chrome/test/earl_grey/chrome_earl_grey.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_matchers.h"
#import "ios/web/public/test/http_server/http_server.h" #import "ios/web/public/test/http_server/http_server.h"
#include "third_party/libaddressinput/messages.h" #include "third_party/libaddressinput/messages.h"
...@@ -102,17 +103,14 @@ id<GREYMatcher> RequiredSelectorEditorFieldMatcher(int string_id) { ...@@ -102,17 +103,14 @@ id<GREYMatcher> RequiredSelectorEditorFieldMatcher(int string_id) {
[super setUp]; [super setUp];
_profile = autofill::test::GetFullProfile(); _profile = autofill::test::GetFullProfile();
NSError* profileError = [self addAutofillProfile:_profile]; CHROME_EG_ASSERT_ON_ERROR([self addAutofillProfile:_profile]);
GREYAssertNil(profileError, profileError.localizedDescription);
_creditCard1 = autofill::test::GetCreditCard(); _creditCard1 = autofill::test::GetCreditCard();
_creditCard1.set_billing_address_id(_profile.guid()); _creditCard1.set_billing_address_id(_profile.guid());
NSError* card1Error = [self addCreditCard:_creditCard1]; CHROME_EG_ASSERT_ON_ERROR([self addCreditCard:_creditCard1]);
GREYAssertNil(card1Error, card1Error.localizedDescription);
_creditCard2 = autofill::test::GetCreditCard2(); _creditCard2 = autofill::test::GetCreditCard2();
NSError* card2Error = [self addCreditCard:_creditCard2]; CHROME_EG_ASSERT_ON_ERROR([self addCreditCard:_creditCard2]);
GREYAssertNil(card2Error, card2Error.localizedDescription);
[ChromeEarlGrey [ChromeEarlGrey
loadURL:web::test::HttpServer::MakeUrl(kPaymentRequestDemoPage)]; loadURL:web::test::HttpServer::MakeUrl(kPaymentRequestDemoPage)];
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#import "ios/chrome/test/app/chrome_test_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.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h" #import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h"
#import "ios/chrome/test/earl_grey/chrome_error_util.h"
#import "ios/web/public/test/http_server/http_server.h" #import "ios/web/public/test/http_server/http_server.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
...@@ -55,9 +56,8 @@ const char kCanMakePaymentMethodIdentifierPage[] = ...@@ -55,9 +56,8 @@ const char kCanMakePaymentMethodIdentifierPage[] =
// Tests canMakePayment() when visa is required and user has a visa instrument. // Tests canMakePayment() when visa is required and user has a visa instrument.
- (void)testCanMakePaymentIsSupported { - (void)testCanMakePaymentIsSupported {
NSError* creditCardError = CHROME_EG_ASSERT_ON_ERROR(
[self addCreditCard:autofill::test::GetCreditCard()]; // visa. [self addCreditCard:autofill::test::GetCreditCard()]); // visa.
GREYAssertNil(creditCardError, creditCardError.localizedDescription);
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kCanMakePaymentPage)]; [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kCanMakePaymentPage)];
[ChromeEarlGrey tapWebViewElementWithID:@"buy"]; [ChromeEarlGrey tapWebViewElementWithID:@"buy"];
...@@ -68,9 +68,8 @@ const char kCanMakePaymentMethodIdentifierPage[] = ...@@ -68,9 +68,8 @@ const char kCanMakePaymentMethodIdentifierPage[] =
// Tests canMakePayment() when visa is required, user has a visa instrument, and // Tests canMakePayment() when visa is required, user has a visa instrument, and
// user is in incognito mode. // user is in incognito mode.
- (void)testCanMakePaymentIsSupportedInIncognitoMode { - (void)testCanMakePaymentIsSupportedInIncognitoMode {
NSError* creditCardError = CHROME_EG_ASSERT_ON_ERROR(
[self addCreditCard:autofill::test::GetCreditCard()]; // visa. [self addCreditCard:autofill::test::GetCreditCard()]); // visa.
GREYAssertNil(creditCardError, creditCardError.localizedDescription);
// Open an Incognito tab. // Open an Incognito tab.
[ChromeEarlGreyUI openToolsMenu]; [ChromeEarlGreyUI openToolsMenu];
[[EarlGrey selectElementWithMatcher:grey_accessibilityID( [[EarlGrey selectElementWithMatcher:grey_accessibilityID(
...@@ -120,9 +119,8 @@ const char kCanMakePaymentMethodIdentifierPage[] = ...@@ -120,9 +119,8 @@ const char kCanMakePaymentMethodIdentifierPage[] =
PrefService* prefs = chrome_test_util::GetOriginalBrowserState()->GetPrefs(); PrefService* prefs = chrome_test_util::GetOriginalBrowserState()->GetPrefs();
prefs->SetBoolean(payments::kCanMakePaymentEnabled, false); prefs->SetBoolean(payments::kCanMakePaymentEnabled, false);
NSError* creditCardError = CHROME_EG_ASSERT_ON_ERROR(
[self addCreditCard:autofill::test::GetCreditCard()]; // visa. [self addCreditCard:autofill::test::GetCreditCard()]); // visa.
GREYAssertNil(creditCardError, creditCardError.localizedDescription);
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kCanMakePaymentPage)]; [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kCanMakePaymentPage)];
...@@ -139,9 +137,8 @@ const char kCanMakePaymentMethodIdentifierPage[] = ...@@ -139,9 +137,8 @@ const char kCanMakePaymentMethodIdentifierPage[] =
PrefService* prefs = chrome_test_util::GetOriginalBrowserState()->GetPrefs(); PrefService* prefs = chrome_test_util::GetOriginalBrowserState()->GetPrefs();
prefs->SetBoolean(payments::kCanMakePaymentEnabled, false); prefs->SetBoolean(payments::kCanMakePaymentEnabled, false);
NSError* creditCardError = CHROME_EG_ASSERT_ON_ERROR(
[self addCreditCard:autofill::test::GetCreditCard()]; // visa. [self addCreditCard:autofill::test::GetCreditCard()]); // visa.
GREYAssertNil(creditCardError, creditCardError.localizedDescription);
// Open an Incognito tab. // Open an Incognito tab.
[ChromeEarlGreyUI openToolsMenu]; [ChromeEarlGreyUI openToolsMenu];
...@@ -206,9 +203,8 @@ const char kCanMakePaymentMethodIdentifierPage[] = ...@@ -206,9 +203,8 @@ const char kCanMakePaymentMethodIdentifierPage[] =
waitForWebViewContainingTexts: waitForWebViewContainingTexts:
{"NotAllowedError", "Not allowed to check whether can make payment"}]; {"NotAllowedError", "Not allowed to check whether can make payment"}];
NSError* creditCardError = CHROME_EG_ASSERT_ON_ERROR(
[self addCreditCard:autofill::test::GetCreditCard()]; // visa. [self addCreditCard:autofill::test::GetCreditCard()]); // visa.
GREYAssertNil(creditCardError, creditCardError.localizedDescription);
// Query visa payment method. // Query visa payment method.
[ChromeEarlGrey tapWebViewElementWithID:@"buy"]; [ChromeEarlGrey tapWebViewElementWithID:@"buy"];
...@@ -273,9 +269,8 @@ const char kCanMakePaymentMethodIdentifierPage[] = ...@@ -273,9 +269,8 @@ const char kCanMakePaymentMethodIdentifierPage[] =
waitForWebViewContainingTexts: waitForWebViewContainingTexts:
{"NotAllowedError", "Not allowed to check whether can make payment"}]; {"NotAllowedError", "Not allowed to check whether can make payment"}];
NSError* creditCardError = CHROME_EG_ASSERT_ON_ERROR(
[self addCreditCard:autofill::test::GetCreditCard()]; // visa. [self addCreditCard:autofill::test::GetCreditCard()]); // visa.
GREYAssertNil(creditCardError, creditCardError.localizedDescription);
// Query basic-card payment method with "supportedNetworks": ["visa"] in the // Query basic-card payment method with "supportedNetworks": ["visa"] in the
// payment method specific data. // payment method specific data.
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#import "ios/chrome/browser/ui/settings/autofill/autofill_profile_table_view_controller.h" #import "ios/chrome/browser/ui/settings/autofill/autofill_profile_table_view_controller.h"
#import "ios/chrome/test/app/chrome_test_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.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_matchers.h"
#import "ios/web/public/test/http_server/http_server.h" #import "ios/web/public/test/http_server/http_server.h"
#import "ios/web/public/test/web_view_interaction_test_util.h" #import "ios/web/public/test/web_view_interaction_test_util.h"
...@@ -168,13 +169,11 @@ const char kNoShippingPage[] = ...@@ -168,13 +169,11 @@ const char kNoShippingPage[] =
// Promise returned by response.complete() with an appropriate response message. // Promise returned by response.complete() with an appropriate response message.
- (void)testOpenAndPay { - (void)testOpenAndPay {
autofill::AutofillProfile profile = autofill::test::GetFullProfile(); autofill::AutofillProfile profile = autofill::test::GetFullProfile();
NSError* profileError = [self addAutofillProfile:profile]; CHROME_EG_ASSERT_ON_ERROR([self addAutofillProfile:profile]);
GREYAssertNil(profileError, profileError.localizedDescription);
autofill::CreditCard card = autofill::test::GetCreditCard(); autofill::CreditCard card = autofill::test::GetCreditCard();
card.set_billing_address_id(profile.guid()); card.set_billing_address_id(profile.guid());
NSError* creditCardError = [self addCreditCard:card]; CHROME_EG_ASSERT_ON_ERROR([self addCreditCard:card]);
GREYAssertNil(creditCardError, creditCardError.localizedDescription);
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kNoShippingPage)]; [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kNoShippingPage)];
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#import "ios/chrome/browser/ui/payments/payment_request_egtest_base.h" #import "ios/chrome/browser/ui/payments/payment_request_egtest_base.h"
#import "ios/chrome/test/app/chrome_test_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.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_matchers.h"
#import "ios/web/public/test/http_server/http_server.h" #import "ios/web/public/test/http_server/http_server.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
...@@ -76,9 +77,7 @@ std::unique_ptr<autofill::AutofillProfile> _profile; ...@@ -76,9 +77,7 @@ std::unique_ptr<autofill::AutofillProfile> _profile;
[super setUp]; [super setUp];
_profile = std::make_unique<autofill::AutofillProfile>( _profile = std::make_unique<autofill::AutofillProfile>(
autofill::test::GetFullProfile()); autofill::test::GetFullProfile());
NSError* autofillProfileError = [self addAutofillProfile:*_profile]; CHROME_EG_ASSERT_ON_ERROR([self addAutofillProfile:*_profile]);
GREYAssertNil(autofillProfileError,
autofillProfileError.localizedDescription);
// Allow canMakePayment to return a truthful value by default. // Allow canMakePayment to return a truthful value by default.
PrefService* prefs = chrome_test_util::GetOriginalBrowserState()->GetPrefs(); PrefService* prefs = chrome_test_util::GetOriginalBrowserState()->GetPrefs();
...@@ -182,8 +181,7 @@ std::unique_ptr<autofill::AutofillProfile> _profile; ...@@ -182,8 +181,7 @@ std::unique_ptr<autofill::AutofillProfile> _profile;
// All local cards have "unknown" card type by design. // All local cards have "unknown" card type by design.
autofill::CreditCard card = autofill::test::GetCreditCard(); autofill::CreditCard card = autofill::test::GetCreditCard();
card.set_billing_address_id(_profile->guid()); card.set_billing_address_id(_profile->guid());
NSError* creditCardError = [self addCreditCard:card]; CHROME_EG_ASSERT_ON_ERROR([self addCreditCard:card]);
GREYAssertNil(creditCardError, creditCardError.localizedDescription);
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kDebitPage)]; [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kDebitPage)];
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#import "ios/chrome/browser/ui/payments/payment_request_egtest_base.h" #import "ios/chrome/browser/ui/payments/payment_request_egtest_base.h"
#import "ios/chrome/test/app/histogram_test_util.h" #import "ios/chrome/test/app/histogram_test_util.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey.h" #import "ios/chrome/test/earl_grey/chrome_earl_grey.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_matchers.h"
#if !defined(__has_feature) || !__has_feature(objc_arc) #if !defined(__has_feature) || !__has_feature(objc_arc)
...@@ -37,26 +38,22 @@ using payments::JourneyLogger; ...@@ -37,26 +38,22 @@ using payments::JourneyLogger;
- (void)addProfiles { - (void)addProfiles {
_profile1 = autofill::test::GetFullProfile(); _profile1 = autofill::test::GetFullProfile();
NSError* profile1Error = [self addAutofillProfile:_profile1]; CHROME_EG_ASSERT_ON_ERROR([self addAutofillProfile:_profile1]);
GREYAssertNil(profile1Error, profile1Error.localizedDescription);
_profile2 = autofill::test::GetFullProfile2(); _profile2 = autofill::test::GetFullProfile2();
NSError* profile2Error = [self addAutofillProfile:_profile2]; CHROME_EG_ASSERT_ON_ERROR([self addAutofillProfile:_profile2]);
GREYAssertNil(profile2Error, profile2Error.localizedDescription);
} }
- (void)addCard1 { - (void)addCard1 {
_creditCard1 = autofill::test::GetCreditCard(); _creditCard1 = autofill::test::GetCreditCard();
_creditCard1.set_billing_address_id(_profile1.guid()); _creditCard1.set_billing_address_id(_profile1.guid());
NSError* creditCardError = [self addCreditCard:_creditCard1]; CHROME_EG_ASSERT_ON_ERROR([self addCreditCard:_creditCard1]);
GREYAssertNil(creditCardError, creditCardError.localizedDescription);
} }
- (void)addCard2 { - (void)addCard2 {
_creditCard2 = autofill::test::GetCreditCard2(); _creditCard2 = autofill::test::GetCreditCard2();
_creditCard2.set_billing_address_id(_profile2.guid()); _creditCard2.set_billing_address_id(_profile2.guid());
NSError* creditCardError = [self addCreditCard:_creditCard2]; CHROME_EG_ASSERT_ON_ERROR([self addCreditCard:_creditCard2]);
GREYAssertNil(creditCardError, creditCardError.localizedDescription);
} }
#pragma mark - Tests #pragma mark - Tests
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#import "ios/chrome/browser/ui/payments/payment_request_egtest_base.h" #import "ios/chrome/browser/ui/payments/payment_request_egtest_base.h"
#import "ios/chrome/test/app/chrome_test_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.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_matchers.h"
#import "ios/web/public/test/http_server/http_server.h" #import "ios/web/public/test/http_server/http_server.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
...@@ -80,16 +81,13 @@ id<GREYMatcher> PaymentMethodCellMatcher( ...@@ -80,16 +81,13 @@ id<GREYMatcher> PaymentMethodCellMatcher(
- (void)addProfile { - (void)addProfile {
_profile = autofill::test::GetFullProfile(); _profile = autofill::test::GetFullProfile();
NSError* autofillProfileError = [self addAutofillProfile:_profile]; CHROME_EG_ASSERT_ON_ERROR([self addAutofillProfile:_profile]);
GREYAssertNil(autofillProfileError,
autofillProfileError.localizedDescription);
} }
- (void)addLocalCard { - (void)addLocalCard {
_localCard = autofill::test::GetCreditCard(); // Visa. _localCard = autofill::test::GetCreditCard(); // Visa.
_localCard.set_billing_address_id(_profile.guid()); _localCard.set_billing_address_id(_profile.guid());
NSError* creditCardError = [self addCreditCard:_localCard]; CHROME_EG_ASSERT_ON_ERROR([self addCreditCard:_localCard]);
GREYAssertNil(creditCardError, creditCardError.localizedDescription);
} }
- (void)addServerCardWithType:(autofill::CreditCard::CardType)cardType { - (void)addServerCardWithType:(autofill::CreditCard::CardType)cardType {
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#import "ios/chrome/browser/ui/payments/payment_request_egtest_base.h" #import "ios/chrome/browser/ui/payments/payment_request_egtest_base.h"
#import "ios/chrome/test/app/chrome_test_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.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_matchers.h"
#import "ios/web/public/test/http_server/http_server.h" #import "ios/web/public/test/http_server/http_server.h"
#import "ios/web/public/test/web_view_interaction_test_util.h" #import "ios/web/public/test/web_view_interaction_test_util.h"
...@@ -62,12 +63,10 @@ const char kRequestEmailPage[] = ...@@ -62,12 +63,10 @@ const char kRequestEmailPage[] =
- (void)testPaymentResponseNoShipping { - (void)testPaymentResponseNoShipping {
// Create a billing address and a card that uses it. // Create a billing address and a card that uses it.
autofill::AutofillProfile billingAddress = autofill::test::GetFullProfile(); autofill::AutofillProfile billingAddress = autofill::test::GetFullProfile();
NSError* billingAddressError = [self addAutofillProfile:billingAddress]; CHROME_EG_ASSERT_ON_ERROR([self addAutofillProfile:billingAddress]);
GREYAssertNil(billingAddressError, billingAddressError.localizedDescription);
autofill::CreditCard card = autofill::test::GetCreditCard(); // visa autofill::CreditCard card = autofill::test::GetCreditCard(); // visa
card.set_billing_address_id(billingAddress.guid()); card.set_billing_address_id(billingAddress.guid());
NSError* creditCardError = [self addCreditCard:card]; CHROME_EG_ASSERT_ON_ERROR([self addCreditCard:card]);
GREYAssertNil(creditCardError, creditCardError.localizedDescription);
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kNoShippingPage)]; [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kNoShippingPage)];
...@@ -125,20 +124,16 @@ const char kRequestEmailPage[] = ...@@ -125,20 +124,16 @@ const char kRequestEmailPage[] =
- (void)testPaymentResponseFreeShipping { - (void)testPaymentResponseFreeShipping {
// Create a billing address and a card that uses it. // Create a billing address and a card that uses it.
autofill::AutofillProfile billingAddress = autofill::test::GetFullProfile(); autofill::AutofillProfile billingAddress = autofill::test::GetFullProfile();
NSError* billingAddressError = [self addAutofillProfile:billingAddress]; CHROME_EG_ASSERT_ON_ERROR([self addAutofillProfile:billingAddress]);
GREYAssertNil(billingAddressError, billingAddressError.localizedDescription);
autofill::CreditCard card = autofill::test::GetCreditCard(); // visa autofill::CreditCard card = autofill::test::GetCreditCard(); // visa
card.set_billing_address_id(billingAddress.guid()); card.set_billing_address_id(billingAddress.guid());
NSError* creditCardError = [self addCreditCard:card]; CHROME_EG_ASSERT_ON_ERROR([self addCreditCard:card]);
GREYAssertNil(creditCardError, creditCardError.localizedDescription);
// Create a shipping address with a higher frecency score, so that it is // Create a shipping address with a higher frecency score, so that it is
// selected as the default shipping address. // selected as the default shipping address.
autofill::AutofillProfile shippingAddress = autofill::test::GetFullProfile2(); autofill::AutofillProfile shippingAddress = autofill::test::GetFullProfile2();
shippingAddress.set_use_count(2000); shippingAddress.set_use_count(2000);
NSError* shippingAddressError = [self addAutofillProfile:shippingAddress]; CHROME_EG_ASSERT_ON_ERROR([self addAutofillProfile:shippingAddress]);
GREYAssertNil(shippingAddressError,
shippingAddressError.localizedDescription);
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kFreeShippingPage)]; [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kFreeShippingPage)];
...@@ -188,13 +183,11 @@ const char kRequestEmailPage[] = ...@@ -188,13 +183,11 @@ const char kRequestEmailPage[] =
- (void)testPaymentResponseAllContactDetails { - (void)testPaymentResponseAllContactDetails {
// Create a billing address and a card that uses it. // Create a billing address and a card that uses it.
autofill::AutofillProfile billingAddress = autofill::test::GetFullProfile(); autofill::AutofillProfile billingAddress = autofill::test::GetFullProfile();
NSError* billingAddressError = [self addAutofillProfile:billingAddress]; CHROME_EG_ASSERT_ON_ERROR([self addAutofillProfile:billingAddress]);
GREYAssertNil(billingAddressError, billingAddressError.localizedDescription);
autofill::CreditCard card = autofill::test::GetCreditCard(); // visa autofill::CreditCard card = autofill::test::GetCreditCard(); // visa
card.set_billing_address_id(billingAddress.guid()); card.set_billing_address_id(billingAddress.guid());
NSError* creditCardError = [self addCreditCard:card]; CHROME_EG_ASSERT_ON_ERROR([self addCreditCard:card]);
GREYAssertNil(creditCardError, creditCardError.localizedDescription);
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kContactDetailsPage)]; [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kContactDetailsPage)];
...@@ -226,13 +219,11 @@ const char kRequestEmailPage[] = ...@@ -226,13 +219,11 @@ const char kRequestEmailPage[] =
- (void)testPaymentResponseOneContactDetail { - (void)testPaymentResponseOneContactDetail {
// Create a billing address and a card that uses it. // Create a billing address and a card that uses it.
autofill::AutofillProfile billingAddress = autofill::test::GetFullProfile(); autofill::AutofillProfile billingAddress = autofill::test::GetFullProfile();
NSError* billingAddressError = [self addAutofillProfile:billingAddress]; CHROME_EG_ASSERT_ON_ERROR([self addAutofillProfile:billingAddress]);
GREYAssertNil(billingAddressError, billingAddressError.localizedDescription);
autofill::CreditCard card = autofill::test::GetCreditCard(); // visa autofill::CreditCard card = autofill::test::GetCreditCard(); // visa
card.set_billing_address_id(billingAddress.guid()); card.set_billing_address_id(billingAddress.guid());
NSError* creditCardError = [self addCreditCard:card]; CHROME_EG_ASSERT_ON_ERROR([self addCreditCard:card]);
GREYAssertNil(creditCardError, creditCardError.localizedDescription);
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kRequestEmailPage)]; [ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kRequestEmailPage)];
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#import "ios/chrome/browser/ui/payments/payment_request_egtest_base.h" #import "ios/chrome/browser/ui/payments/payment_request_egtest_base.h"
#import "ios/chrome/browser/ui/payments/payment_request_error_view_controller.h" #import "ios/chrome/browser/ui/payments/payment_request_error_view_controller.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey.h" #import "ios/chrome/test/earl_grey/chrome_earl_grey.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_matchers.h"
#import "ios/web/public/test/http_server/http_server.h" #import "ios/web/public/test/http_server/http_server.h"
...@@ -49,13 +50,11 @@ id<GREYMatcher> PriceCellMatcher(NSString* accessibilityLabel) { ...@@ -49,13 +50,11 @@ id<GREYMatcher> PriceCellMatcher(NSString* accessibilityLabel) {
[super setUp]; [super setUp];
autofill::AutofillProfile profile = autofill::test::GetFullProfile(); autofill::AutofillProfile profile = autofill::test::GetFullProfile();
NSError* profileError = [self addAutofillProfile:profile]; CHROME_EG_ASSERT_ON_ERROR([self addAutofillProfile:profile]);
GREYAssertNil(profileError, profileError.localizedDescription);
autofill::CreditCard localCard = autofill::test::GetCreditCard(); // Visa. autofill::CreditCard localCard = autofill::test::GetCreditCard(); // Visa.
localCard.set_billing_address_id(profile.guid()); localCard.set_billing_address_id(profile.guid());
NSError* creditCardError = [self addCreditCard:localCard]; CHROME_EG_ASSERT_ON_ERROR([self addCreditCard:localCard]);
GREYAssertNil(creditCardError, creditCardError.localizedDescription);
} }
#pragma mark - Tests #pragma mark - Tests
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#import "ios/chrome/browser/ui/payments/payment_request_egtest_base.h" #import "ios/chrome/browser/ui/payments/payment_request_egtest_base.h"
#import "ios/chrome/test/app/chrome_test_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.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_matchers.h"
#import "ios/web/public/test/http_server/http_server.h" #import "ios/web/public/test/http_server/http_server.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
...@@ -58,12 +59,10 @@ const char kContactDetailsFreeShippingPage[] = ...@@ -58,12 +59,10 @@ const char kContactDetailsFreeShippingPage[] =
// Sets up a credit card with an associated billing address. // Sets up a credit card with an associated billing address.
- (void)setUpCreditCard { - (void)setUpCreditCard {
autofill::AutofillProfile billingAddress = autofill::test::GetFullProfile(); autofill::AutofillProfile billingAddress = autofill::test::GetFullProfile();
NSError* billingAddressError = [self addAutofillProfile:billingAddress]; CHROME_EG_ASSERT_ON_ERROR([self addAutofillProfile:billingAddress]);
GREYAssertNil(billingAddressError, billingAddressError.localizedDescription);
autofill::CreditCard card = autofill::test::GetCreditCard(); // visa autofill::CreditCard card = autofill::test::GetCreditCard(); // visa
card.set_billing_address_id(billingAddress.guid()); card.set_billing_address_id(billingAddress.guid());
NSError* creditCardError = [self addCreditCard:card]; CHROME_EG_ASSERT_ON_ERROR([self addCreditCard:card]);
GREYAssertNil(creditCardError, creditCardError.localizedDescription);
} }
// Completes the Payment Request. // Completes the Payment Request.
...@@ -97,13 +96,11 @@ const char kContactDetailsFreeShippingPage[] = ...@@ -97,13 +96,11 @@ const char kContactDetailsFreeShippingPage[] =
// Setup a credit card with an associated billing address. // Setup a credit card with an associated billing address.
autofill::AutofillProfile billingAddress = autofill::test::GetFullProfile(); autofill::AutofillProfile billingAddress = autofill::test::GetFullProfile();
NSError* billingAddressError = [self addAutofillProfile:billingAddress]; CHROME_EG_ASSERT_ON_ERROR([self addAutofillProfile:billingAddress]);
GREYAssertNil(billingAddressError, billingAddressError.localizedDescription);
autofill::CreditCard card = autofill::test::GetCreditCard(); // visa autofill::CreditCard card = autofill::test::GetCreditCard(); // visa
card.set_billing_address_id(billingAddress.guid()); card.set_billing_address_id(billingAddress.guid());
NSError* creditCardError = [self addCreditCard:card]; CHROME_EG_ASSERT_ON_ERROR([self addCreditCard:card]);
GREYAssertNil(creditCardError, creditCardError.localizedDescription);
// Check that the initial use stats were set correctly. // Check that the initial use stats were set correctly.
autofill::CreditCard* initialCard = autofill::CreditCard* initialCard =
...@@ -146,9 +143,7 @@ const char kContactDetailsFreeShippingPage[] = ...@@ -146,9 +143,7 @@ const char kContactDetailsFreeShippingPage[] =
// selected as the default shipping address. // selected as the default shipping address.
autofill::AutofillProfile shippingAddress = autofill::test::GetFullProfile2(); autofill::AutofillProfile shippingAddress = autofill::test::GetFullProfile2();
shippingAddress.set_use_count(3); shippingAddress.set_use_count(3);
NSError* shippingAddressError = [self addAutofillProfile:shippingAddress]; CHROME_EG_ASSERT_ON_ERROR([self addAutofillProfile:shippingAddress]);
GREYAssertNil(shippingAddressError,
shippingAddressError.localizedDescription);
// Check that the initial use stats were set correctly. // Check that the initial use stats were set correctly.
autofill::AutofillProfile* initialShipping = autofill::AutofillProfile* initialShipping =
...@@ -180,8 +175,7 @@ const char kContactDetailsFreeShippingPage[] = ...@@ -180,8 +175,7 @@ const char kContactDetailsFreeShippingPage[] =
// selected as the default shipping address. // selected as the default shipping address.
autofill::AutofillProfile contactAddress = autofill::test::GetFullProfile2(); autofill::AutofillProfile contactAddress = autofill::test::GetFullProfile2();
contactAddress.set_use_count(3); contactAddress.set_use_count(3);
NSError* contactAddressError = [self addAutofillProfile:contactAddress]; CHROME_EG_ASSERT_ON_ERROR([self addAutofillProfile:contactAddress]);
GREYAssertNil(contactAddressError, contactAddressError.localizedDescription);
// Check that the initial use stats were set correctly. // Check that the initial use stats were set correctly.
autofill::AutofillProfile* initialContact = autofill::AutofillProfile* initialContact =
...@@ -213,8 +207,7 @@ const char kContactDetailsFreeShippingPage[] = ...@@ -213,8 +207,7 @@ const char kContactDetailsFreeShippingPage[] =
// the default shipping and contact address. // the default shipping and contact address.
autofill::AutofillProfile multiAddress = autofill::test::GetFullProfile2(); autofill::AutofillProfile multiAddress = autofill::test::GetFullProfile2();
multiAddress.set_use_count(3); multiAddress.set_use_count(3);
NSError* multiAddressError = [self addAutofillProfile:multiAddress]; CHROME_EG_ASSERT_ON_ERROR([self addAutofillProfile:multiAddress]);
GREYAssertNil(multiAddressError, multiAddressError.localizedDescription);
// Check that the initial use stats were set correctly. // Check that the initial use stats were set correctly.
autofill::AutofillProfile* initialAddress = autofill::AutofillProfile* initialAddress =
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "ios/chrome/grit/ios_strings.h" #include "ios/chrome/grit/ios_strings.h"
#import "ios/chrome/test/app/chrome_test_util.h" #import "ios/chrome/test/app/chrome_test_util.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.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_matchers.h"
#import "ios/chrome/test/earl_grey/chrome_test_case.h" #import "ios/chrome/test/earl_grey/chrome_test_case.h"
#import "ios/public/provider/chrome/browser/signin/fake_chrome_identity.h" #import "ios/public/provider/chrome/browser/signin/fake_chrome_identity.h"
...@@ -78,8 +79,7 @@ id<GREYMatcher> ButtonWithIdentity(ChromeIdentity* identity) { ...@@ -78,8 +79,7 @@ id<GREYMatcher> ButtonWithIdentity(ChromeIdentity* identity) {
[[EarlGrey selectElementWithMatcher:PrimarySignInButton()] [[EarlGrey selectElementWithMatcher:PrimarySignInButton()]
assertWithMatcher:grey_sufficientlyVisible()]; assertWithMatcher:grey_sufficientlyVisible()];
NSError* signedOutError = [SigninEarlGreyUtils checkSignedOut]; CHROME_EG_ASSERT_ON_ERROR([SigninEarlGreyUtils checkSignedOut]);
GREYAssertNil(signedOutError, signedOutError.localizedDescription);
[[EarlGrey selectElementWithMatcher:SettingsDoneButton()] [[EarlGrey selectElementWithMatcher:SettingsDoneButton()]
performAction:grey_tap()]; performAction:grey_tap()];
...@@ -105,8 +105,7 @@ id<GREYMatcher> ButtonWithIdentity(ChromeIdentity* identity) { ...@@ -105,8 +105,7 @@ id<GREYMatcher> ButtonWithIdentity(ChromeIdentity* identity) {
[[EarlGrey selectElementWithMatcher:PrimarySignInButton()] [[EarlGrey selectElementWithMatcher:PrimarySignInButton()]
assertWithMatcher:grey_sufficientlyVisible()]; assertWithMatcher:grey_sufficientlyVisible()];
NSError* signedOutError = [SigninEarlGreyUtils checkSignedOut]; CHROME_EG_ASSERT_ON_ERROR([SigninEarlGreyUtils checkSignedOut]);
GREYAssertNil(signedOutError, signedOutError.localizedDescription);
[[EarlGrey selectElementWithMatcher:SettingsDoneButton()] [[EarlGrey selectElementWithMatcher:SettingsDoneButton()]
performAction:grey_tap()]; performAction:grey_tap()];
...@@ -139,9 +138,8 @@ id<GREYMatcher> ButtonWithIdentity(ChromeIdentity* identity) { ...@@ -139,9 +138,8 @@ id<GREYMatcher> ButtonWithIdentity(ChromeIdentity* identity) {
grey_accessibilityLabel(identity2.userEmail), grey_accessibilityLabel(identity2.userEmail),
grey_sufficientlyVisible(), nil)] grey_sufficientlyVisible(), nil)]
assertWithMatcher:grey_nil()]; assertWithMatcher:grey_nil()];
NSError* signedInError = CHROME_EG_ASSERT_ON_ERROR(
[SigninEarlGreyUtils checkSignedInWithIdentity:identity1]; [SigninEarlGreyUtils checkSignedInWithIdentity:identity1]);
GREYAssertNil(signedInError, signedInError.localizedDescription);
[[EarlGrey selectElementWithMatcher:SettingsDoneButton()] [[EarlGrey selectElementWithMatcher:SettingsDoneButton()]
performAction:grey_tap()]; performAction:grey_tap()];
...@@ -180,9 +178,8 @@ id<GREYMatcher> ButtonWithIdentity(ChromeIdentity* identity) { ...@@ -180,9 +178,8 @@ id<GREYMatcher> ButtonWithIdentity(ChromeIdentity* identity) {
grey_accessibilityLabel(identity2.userEmail), grey_accessibilityLabel(identity2.userEmail),
grey_sufficientlyVisible(), nil)] grey_sufficientlyVisible(), nil)]
assertWithMatcher:grey_nil()]; assertWithMatcher:grey_nil()];
NSError* signedInError = CHROME_EG_ASSERT_ON_ERROR(
[SigninEarlGreyUtils checkSignedInWithIdentity:identity1]; [SigninEarlGreyUtils checkSignedInWithIdentity:identity1]);
GREYAssertNil(signedInError, signedInError.localizedDescription);
[[EarlGrey selectElementWithMatcher:SettingsDoneButton()] [[EarlGrey selectElementWithMatcher:SettingsDoneButton()]
performAction:grey_tap()]; performAction:grey_tap()];
...@@ -208,8 +205,7 @@ id<GREYMatcher> ButtonWithIdentity(ChromeIdentity* identity) { ...@@ -208,8 +205,7 @@ id<GREYMatcher> ButtonWithIdentity(ChromeIdentity* identity) {
// Check that the user is signed out and the Main Settings screen is shown. // Check that the user is signed out and the Main Settings screen is shown.
[[EarlGrey selectElementWithMatcher:PrimarySignInButton()] [[EarlGrey selectElementWithMatcher:PrimarySignInButton()]
assertWithMatcher:grey_sufficientlyVisible()]; assertWithMatcher:grey_sufficientlyVisible()];
NSError* signedOutError = [SigninEarlGreyUtils checkSignedOut]; CHROME_EG_ASSERT_ON_ERROR([SigninEarlGreyUtils checkSignedOut]);
GREYAssertNil(signedOutError, signedOutError.localizedDescription);
[[EarlGrey selectElementWithMatcher:SettingsDoneButton()] [[EarlGrey selectElementWithMatcher:SettingsDoneButton()]
performAction:grey_tap()]; performAction:grey_tap()];
...@@ -238,9 +234,8 @@ id<GREYMatcher> ButtonWithIdentity(ChromeIdentity* identity) { ...@@ -238,9 +234,8 @@ id<GREYMatcher> ButtonWithIdentity(ChromeIdentity* identity) {
[[EarlGrey selectElementWithMatcher:chrome_test_util:: [[EarlGrey selectElementWithMatcher:chrome_test_util::
SettingsAccountsCollectionView()] SettingsAccountsCollectionView()]
assertWithMatcher:grey_sufficientlyVisible()]; assertWithMatcher:grey_sufficientlyVisible()];
NSError* signedInError = CHROME_EG_ASSERT_ON_ERROR(
[SigninEarlGreyUtils checkSignedInWithIdentity:identity]; [SigninEarlGreyUtils checkSignedInWithIdentity:identity]);
GREYAssertNil(signedInError, signedInError.localizedDescription);
[[EarlGrey selectElementWithMatcher:SettingsDoneButton()] [[EarlGrey selectElementWithMatcher:SettingsDoneButton()]
performAction:grey_tap()]; performAction:grey_tap()];
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "ios/chrome/grit/ios_strings.h" #include "ios/chrome/grit/ios_strings.h"
#import "ios/chrome/test/app/chrome_test_util.h" #import "ios/chrome/test/app/chrome_test_util.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.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_matchers.h"
#import "ios/chrome/test/earl_grey/chrome_test_case.h" #import "ios/chrome/test/earl_grey/chrome_test_case.h"
#import "ios/public/provider/chrome/browser/signin/fake_chrome_identity.h" #import "ios/public/provider/chrome/browser/signin/fake_chrome_identity.h"
...@@ -62,9 +63,8 @@ using chrome_test_util::ButtonWithAccessibilityLabelId; ...@@ -62,9 +63,8 @@ using chrome_test_util::ButtonWithAccessibilityLabelId;
[SigninEarlGreyUI confirmSigninConfirmationDialog]; [SigninEarlGreyUI confirmSigninConfirmationDialog];
// User signed in. // User signed in.
NSError* signedInError = CHROME_EG_ASSERT_ON_ERROR(
[SigninEarlGreyUtils checkSignedInWithIdentity:identity]; [SigninEarlGreyUtils checkSignedInWithIdentity:identity]);
GREYAssertNil(signedInError, signedInError.localizedDescription);
[SigninEarlGreyUI checkSigninPromoNotVisible]; [SigninEarlGreyUI checkSigninPromoNotVisible];
[[EarlGrey selectElementWithMatcher:SettingsAccountButton()] [[EarlGrey selectElementWithMatcher:SettingsAccountButton()]
assertWithMatcher:grey_interactable()]; assertWithMatcher:grey_interactable()];
...@@ -84,9 +84,8 @@ using chrome_test_util::ButtonWithAccessibilityLabelId; ...@@ -84,9 +84,8 @@ using chrome_test_util::ButtonWithAccessibilityLabelId;
[SigninEarlGreyUI confirmSigninConfirmationDialog]; [SigninEarlGreyUI confirmSigninConfirmationDialog];
// User signed in. // User signed in.
NSError* signedInError = CHROME_EG_ASSERT_ON_ERROR(
[SigninEarlGreyUtils checkSignedInWithIdentity:identity]; [SigninEarlGreyUtils checkSignedInWithIdentity:identity]);
GREYAssertNil(signedInError, signedInError.localizedDescription);
[SigninEarlGreyUI checkSigninPromoNotVisible]; [SigninEarlGreyUI checkSigninPromoNotVisible];
[[EarlGrey selectElementWithMatcher:SettingsAccountButton()] [[EarlGrey selectElementWithMatcher:SettingsAccountButton()]
assertWithMatcher:grey_interactable()]; assertWithMatcher:grey_interactable()];
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "ios/chrome/grit/ios_strings.h" #include "ios/chrome/grit/ios_strings.h"
#import "ios/chrome/test/app/chrome_test_util.h" #import "ios/chrome/test/app/chrome_test_util.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.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_matchers.h"
#import "ios/chrome/test/earl_grey/chrome_test_case.h" #import "ios/chrome/test/earl_grey/chrome_test_case.h"
#import "ios/public/provider/chrome/browser/signin/fake_chrome_identity.h" #import "ios/public/provider/chrome/browser/signin/fake_chrome_identity.h"
...@@ -86,9 +87,8 @@ void WaitForMatcher(id<GREYMatcher> matcher) { ...@@ -86,9 +87,8 @@ void WaitForMatcher(id<GREYMatcher> matcher) {
[SigninEarlGreyUI signinWithIdentity:identity]; [SigninEarlGreyUI signinWithIdentity:identity];
// Check |identity| is signed-in. // Check |identity| is signed-in.
NSError* signedInError = CHROME_EG_ASSERT_ON_ERROR(
[SigninEarlGreyUtils checkSignedInWithIdentity:identity]; [SigninEarlGreyUtils checkSignedInWithIdentity:identity]);
GREYAssertNil(signedInError, signedInError.localizedDescription);
} }
// Tests signing in with one account, switching sync account to a second and // Tests signing in with one account, switching sync account to a second and
...@@ -123,9 +123,8 @@ void WaitForMatcher(id<GREYMatcher> matcher) { ...@@ -123,9 +123,8 @@ void WaitForMatcher(id<GREYMatcher> matcher) {
[[EarlGrey selectElementWithMatcher:matcher] performAction:grey_tap()]; [[EarlGrey selectElementWithMatcher:matcher] performAction:grey_tap()];
// Check the signed-in user did change. // Check the signed-in user did change.
NSError* signedInError = CHROME_EG_ASSERT_ON_ERROR(
[SigninEarlGreyUtils checkSignedInWithIdentity:identity2]; [SigninEarlGreyUtils checkSignedInWithIdentity:identity2]);
GREYAssertNil(signedInError, signedInError.localizedDescription);
[[EarlGrey selectElementWithMatcher:SettingsDoneButton()] [[EarlGrey selectElementWithMatcher:SettingsDoneButton()]
performAction:grey_tap()]; performAction:grey_tap()];
...@@ -164,9 +163,8 @@ void WaitForMatcher(id<GREYMatcher> matcher) { ...@@ -164,9 +163,8 @@ void WaitForMatcher(id<GREYMatcher> matcher) {
performAction:grey_tap()]; performAction:grey_tap()];
// Check the signed-in user did change. // Check the signed-in user did change.
NSError* signedInError = CHROME_EG_ASSERT_ON_ERROR(
[SigninEarlGreyUtils checkSignedInWithIdentity:identity2]; [SigninEarlGreyUtils checkSignedInWithIdentity:identity2]);
GREYAssertNil(signedInError, signedInError.localizedDescription);
[[EarlGrey selectElementWithMatcher:SettingsDoneButton()] [[EarlGrey selectElementWithMatcher:SettingsDoneButton()]
performAction:grey_tap()]; performAction:grey_tap()];
...@@ -196,9 +194,8 @@ void WaitForMatcher(id<GREYMatcher> matcher) { ...@@ -196,9 +194,8 @@ void WaitForMatcher(id<GREYMatcher> matcher) {
SetEarlGreySynchronizationEnabled(YES); SetEarlGreySynchronizationEnabled(YES);
[SigninEarlGreyUI confirmSigninConfirmationDialog]; [SigninEarlGreyUI confirmSigninConfirmationDialog];
NSError* signedInError = CHROME_EG_ASSERT_ON_ERROR(
[SigninEarlGreyUtils checkSignedInWithIdentity:managed_identity]; [SigninEarlGreyUtils checkSignedInWithIdentity:managed_identity]);
GREYAssertNil(signedInError, signedInError.localizedDescription);
// Switch Sync account to |identity|. // Switch Sync account to |identity|.
[[EarlGrey selectElementWithMatcher:chrome_test_util::SettingsAccountButton()] [[EarlGrey selectElementWithMatcher:chrome_test_util::SettingsAccountButton()]
...@@ -214,9 +211,8 @@ void WaitForMatcher(id<GREYMatcher> matcher) { ...@@ -214,9 +211,8 @@ void WaitForMatcher(id<GREYMatcher> matcher) {
TapButtonWithLabelId(IDS_IOS_MANAGED_SWITCH_ACCEPT_BUTTON); TapButtonWithLabelId(IDS_IOS_MANAGED_SWITCH_ACCEPT_BUTTON);
SetEarlGreySynchronizationEnabled(YES); SetEarlGreySynchronizationEnabled(YES);
NSError* signedInError2 = CHROME_EG_ASSERT_ON_ERROR(
[SigninEarlGreyUtils checkSignedInWithIdentity:identity]; [SigninEarlGreyUtils checkSignedInWithIdentity:identity]);
GREYAssertNil(signedInError2, signedInError2.localizedDescription);
[[EarlGrey selectElementWithMatcher:SettingsDoneButton()] [[EarlGrey selectElementWithMatcher:SettingsDoneButton()]
performAction:grey_tap()]; performAction:grey_tap()];
...@@ -250,8 +246,7 @@ void WaitForMatcher(id<GREYMatcher> matcher) { ...@@ -250,8 +246,7 @@ void WaitForMatcher(id<GREYMatcher> matcher) {
performAction:grey_tap()]; performAction:grey_tap()];
// Check that there is no signed in user. // Check that there is no signed in user.
NSError* signedOutError = [SigninEarlGreyUtils checkSignedOut]; CHROME_EG_ASSERT_ON_ERROR([SigninEarlGreyUtils checkSignedOut]);
GREYAssertNil(signedOutError, signedOutError.localizedDescription);
} }
// Tests that signing out of a managed account from the Settings works // Tests that signing out of a managed account from the Settings works
...@@ -274,9 +269,8 @@ void WaitForMatcher(id<GREYMatcher> matcher) { ...@@ -274,9 +269,8 @@ void WaitForMatcher(id<GREYMatcher> matcher) {
SetEarlGreySynchronizationEnabled(YES); SetEarlGreySynchronizationEnabled(YES);
[SigninEarlGreyUI confirmSigninConfirmationDialog]; [SigninEarlGreyUI confirmSigninConfirmationDialog];
NSError* signedInError = CHROME_EG_ASSERT_ON_ERROR(
[SigninEarlGreyUtils checkSignedInWithIdentity:identity]; [SigninEarlGreyUtils checkSignedInWithIdentity:identity]);
GREYAssertNil(signedInError, signedInError.localizedDescription);
// Go to Accounts Settings and tap the sign out button. // Go to Accounts Settings and tap the sign out button.
[[EarlGrey selectElementWithMatcher:chrome_test_util::SettingsAccountButton()] [[EarlGrey selectElementWithMatcher:chrome_test_util::SettingsAccountButton()]
...@@ -296,8 +290,7 @@ void WaitForMatcher(id<GREYMatcher> matcher) { ...@@ -296,8 +290,7 @@ void WaitForMatcher(id<GREYMatcher> matcher) {
performAction:grey_tap()]; performAction:grey_tap()];
// Check that there is no signed in user. // Check that there is no signed in user.
NSError* signedOutError = [SigninEarlGreyUtils checkSignedOut]; CHROME_EG_ASSERT_ON_ERROR([SigninEarlGreyUtils checkSignedOut]);
GREYAssertNil(signedOutError, signedOutError.localizedDescription);
} }
// Tests that signing in, tapping the Settings link on the confirmation screen // Tests that signing in, tapping the Settings link on the confirmation screen
...@@ -330,9 +323,8 @@ void WaitForMatcher(id<GREYMatcher> matcher) { ...@@ -330,9 +323,8 @@ void WaitForMatcher(id<GREYMatcher> matcher) {
IDS_IOS_SETTINGS_TITLE); IDS_IOS_SETTINGS_TITLE);
[[EarlGrey selectElementWithMatcher:settings_matcher] [[EarlGrey selectElementWithMatcher:settings_matcher]
assertWithMatcher:grey_notVisible()]; assertWithMatcher:grey_notVisible()];
NSError* signedInError = CHROME_EG_ASSERT_ON_ERROR(
[SigninEarlGreyUtils checkSignedInWithIdentity:identity]; [SigninEarlGreyUtils checkSignedInWithIdentity:identity]);
GREYAssertNil(signedInError, signedInError.localizedDescription);
} }
// Opens the sign in screen and then cancel it by opening a new tab. Ensures // Opens the sign in screen and then cancel it by opening a new tab. Ensures
...@@ -444,8 +436,7 @@ void WaitForMatcher(id<GREYMatcher> matcher) { ...@@ -444,8 +436,7 @@ void WaitForMatcher(id<GREYMatcher> matcher) {
onElementWithMatcher:chrome_test_util::SettingsAccountsCollectionView()] onElementWithMatcher:chrome_test_util::SettingsAccountsCollectionView()]
performAction:grey_tap()]; performAction:grey_tap()];
TapButtonWithLabelId(IDS_IOS_DISCONNECT_DIALOG_CONTINUE_BUTTON_MOBILE); TapButtonWithLabelId(IDS_IOS_DISCONNECT_DIALOG_CONTINUE_BUTTON_MOBILE);
NSError* signedOutError = [SigninEarlGreyUtils checkSignedOut]; CHROME_EG_ASSERT_ON_ERROR([SigninEarlGreyUtils checkSignedOut]);
GREYAssertNil(signedOutError, signedOutError.localizedDescription);
[[EarlGrey selectElementWithMatcher:SecondarySignInButton()] [[EarlGrey selectElementWithMatcher:SecondarySignInButton()]
performAction:grey_tap()]; performAction:grey_tap()];
[SigninEarlGreyUI selectIdentityWithEmail:identity1.userEmail]; [SigninEarlGreyUI selectIdentityWithEmail:identity1.userEmail];
...@@ -470,8 +461,7 @@ void WaitForMatcher(id<GREYMatcher> matcher) { ...@@ -470,8 +461,7 @@ void WaitForMatcher(id<GREYMatcher> matcher) {
TapButtonWithLabelId(IDS_IOS_ACCOUNT_CONSISTENCY_SETUP_SKIP_BUTTON); TapButtonWithLabelId(IDS_IOS_ACCOUNT_CONSISTENCY_SETUP_SKIP_BUTTON);
[[EarlGrey selectElementWithMatcher:SettingsDoneButton()] [[EarlGrey selectElementWithMatcher:SettingsDoneButton()]
performAction:grey_tap()]; performAction:grey_tap()];
NSError* signedOutError2 = [SigninEarlGreyUtils checkSignedOut]; CHROME_EG_ASSERT_ON_ERROR([SigninEarlGreyUtils checkSignedOut]);
GREYAssertNil(signedOutError2, signedOutError2.localizedDescription);
} }
// Opens the sign in screen from the bookmarks and then cancel it by tapping on // Opens the sign in screen from the bookmarks and then cancel it by tapping on
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#import "ios/chrome/test/app/web_view_interaction_test_util.h" #import "ios/chrome/test/app/web_view_interaction_test_util.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey.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_earl_grey_ui.h"
#import "ios/chrome/test/earl_grey/chrome_error_util.h"
#import "ios/chrome/test/earl_grey/chrome_test_case.h" #import "ios/chrome/test/earl_grey/chrome_test_case.h"
#import "ios/third_party/material_components_ios/src/components/ProgressView/src/MaterialProgressView.h" #import "ios/third_party/material_components_ios/src/components/ProgressView/src/MaterialProgressView.h"
#include "ios/web/public/test/http_server/html_response_provider.h" #include "ios/web/public/test/http_server/html_response_provider.h"
...@@ -196,8 +197,7 @@ class InfinitePendingResponseProvider : public HtmlResponseProvider { ...@@ -196,8 +197,7 @@ class InfinitePendingResponseProvider : public HtmlResponseProvider {
[[EarlGrey selectElementWithMatcher:ProgressViewWithProgress(0.5)] [[EarlGrey selectElementWithMatcher:ProgressViewWithProgress(0.5)]
assertWithMatcher:grey_sufficientlyVisible()]; assertWithMatcher:grey_sufficientlyVisible()];
NSError* visibleError = [ChromeEarlGreyUI waitForToolbarVisible:YES]; CHROME_EG_ASSERT_ON_ERROR([ChromeEarlGreyUI waitForToolbarVisible:YES]);
GREYAssertNil(visibleError, visibleError.localizedDescription);
infinitePendingProvider->Abort(); infinitePendingProvider->Abort();
} }
...@@ -237,8 +237,7 @@ class InfinitePendingResponseProvider : public HtmlResponseProvider { ...@@ -237,8 +237,7 @@ class InfinitePendingResponseProvider : public HtmlResponseProvider {
[[EarlGrey selectElementWithMatcher:ProgressViewWithProgress(0.5)] [[EarlGrey selectElementWithMatcher:ProgressViewWithProgress(0.5)]
assertWithMatcher:grey_sufficientlyVisible()]; assertWithMatcher:grey_sufficientlyVisible()];
NSError* visibleError = [ChromeEarlGreyUI waitForToolbarVisible:YES]; CHROME_EG_ASSERT_ON_ERROR([ChromeEarlGreyUI waitForToolbarVisible:YES]);
GREYAssertNil(visibleError, visibleError.localizedDescription);
infinitePendingProvider->Abort(); infinitePendingProvider->Abort();
} }
......
...@@ -8,6 +8,18 @@ ...@@ -8,6 +8,18 @@
@class NSError; @class NSError;
@class NSString; @class NSString;
// Wraps an expression that returns an NSError*, asserting if an error is
// returned. Used in EG test code to assert if app helpers fail. For example:
// CHROME_EG_ASSERT_ON_ERROR(helperReturningNSError());
// CHROME_EG_ASSERT_ON_ERROR([ChromeEarlGrey helperReturningNSError]);
#define CHROME_EG_ASSERT_ON_ERROR(expression) \
{ \
NSError* error = expression; \
GREYAssert(error == nil || [error isKindOfClass:[NSError class]], \
@"Expression did not return an object of type NSError"); \
GREYAssertNil(error, error.localizedDescription); \
}
namespace chrome_test_util { namespace chrome_test_util {
// Returns a NSError with generic domain and error code, and the provided string // Returns a NSError with generic domain and error code, and the provided string
......
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