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