Commit 400cafac authored by Eugene But's avatar Eugene But Committed by Commit Bot

Remove CHROME_EG_ASSERT_NO_ERROR macro used in some eg tests.

CHROME_EG_ASSERT_NO_ERROR is unnecessary anymore, because helpes can
assert with correct file name and line number.

This CL was prepared with automated script.

TBR=rohitrao@chromium.org

Bug: 963613
Change-Id: Ic63ed8c679f5282ecf84072c96c13617ad88ee43
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1649343Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Commit-Queue: Eugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#667355}
parent 84dbd22b
......@@ -133,9 +133,8 @@ void ClearBrowsingData() {
void OpenNewIncognitoTab() {
NSUInteger incognito_tab_count = [ChromeEarlGrey incognitoTabCount];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey openNewIncognitoTab]);
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey waitForIncognitoTabCount:(incognito_tab_count + 1)]);
[ChromeEarlGrey openNewIncognitoTab];
[ChromeEarlGrey waitForIncognitoTabCount:(incognito_tab_count + 1)];
GREYAssert([ChromeEarlGrey isIncognitoMode],
@"Failed to switch to incognito mode.");
}
......@@ -143,13 +142,12 @@ void OpenNewIncognitoTab() {
void CloseCurrentIncognitoTab() {
NSUInteger incognito_tab_count = [ChromeEarlGrey incognitoTabCount];
[ChromeEarlGrey closeCurrentTab];
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey waitForIncognitoTabCount:(incognito_tab_count - 1)]);
[ChromeEarlGrey waitForIncognitoTabCount:(incognito_tab_count - 1)];
}
void CloseAllIncognitoTabs() {
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey closeAllIncognitoTabs]);
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey waitForIncognitoTabCount:0]);
[ChromeEarlGrey closeAllIncognitoTabs];
[ChromeEarlGrey waitForIncognitoTabCount:0];
// The user is dropped into the tab grid after closing the last incognito tab.
// Therefore this test must manually switch back to showing the normal tabs.
......@@ -164,9 +162,8 @@ void CloseAllIncognitoTabs() {
void OpenNewRegularTab() {
NSUInteger tab_count = [ChromeEarlGrey mainTabCount];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey openNewTab]);
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey waitForMainTabCount:(tab_count + 1)]);
[ChromeEarlGrey openNewTab];
[ChromeEarlGrey waitForMainTabCount:(tab_count + 1)];
}
// Grant/revoke metrics consent and update MetricsServicesManager.
......@@ -217,16 +214,14 @@ void SignOut() {
- (void)setUp {
[super setUp];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey
waitForSyncInitialized:NO
syncTimeout:kSyncUKMOperationsTimeout]);
[ChromeEarlGrey waitForSyncInitialized:NO
syncTimeout:kSyncUKMOperationsTimeout];
AssertUKMEnabled(false);
// Enable sync.
[SigninEarlGreyUI signinWithIdentity:[SigninEarlGreyUtils fakeIdentity1]];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey
waitForSyncInitialized:YES
syncTimeout:kSyncUKMOperationsTimeout]);
[ChromeEarlGrey waitForSyncInitialized:YES
syncTimeout:kSyncUKMOperationsTimeout];
// Grant metrics consent and update MetricsServicesManager.
GREYAssert(!g_metrics_enabled, @"Unpaired set/reset of user consent.");
......@@ -239,9 +234,8 @@ void SignOut() {
}
- (void)tearDown {
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey
waitForSyncInitialized:YES
syncTimeout:kSyncUKMOperationsTimeout]);
[ChromeEarlGrey waitForSyncInitialized:YES
syncTimeout:kSyncUKMOperationsTimeout];
AssertUKMEnabled(true);
// Revoke metrics consent and update MetricsServicesManager.
......@@ -255,9 +249,8 @@ void SignOut() {
// Disable sync.
SignOut();
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey
waitForSyncInitialized:NO
syncTimeout:kSyncUKMOperationsTimeout]);
[ChromeEarlGrey waitForSyncInitialized:NO
syncTimeout:kSyncUKMOperationsTimeout];
[ChromeEarlGrey clearSyncServerData];
[super tearDown];
......@@ -295,7 +288,7 @@ void SignOut() {
- (void)testIncognitoPlusRegular {
uint64_t original_client_id = metrics::UkmEGTestHelper::client_id();
[ChromeEarlGrey closeAllTabs];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey waitForMainTabCount:(0)]);
[ChromeEarlGrey waitForMainTabCount:0];
OpenNewIncognitoTab();
AssertUKMEnabled(false);
......@@ -304,8 +297,8 @@ void SignOut() {
OpenNewRegularTab();
AssertUKMEnabled(false);
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey closeAllIncognitoTabs]);
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey waitForIncognitoTabCount:0]);
[ChromeEarlGrey closeAllIncognitoTabs];
[ChromeEarlGrey waitForIncognitoTabCount:0];
AssertUKMEnabled(true);
// Client ID should not have been reset.
......
......@@ -10,7 +10,6 @@
#include "ios/chrome/grit/ios_strings.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/testing/earl_grey/earl_grey_test.h"
......@@ -85,8 +84,7 @@ id<GREYMatcher> ShareMenuCollectionView() {
web::test::SetUpHttpServer(std::move(provider));
// Open a page with an error.
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey loadURL:ErrorPageResponseProvider::GetDnsFailureUrl()]);
[ChromeEarlGrey loadURL:ErrorPageResponseProvider::GetDnsFailureUrl()];
// Verify that you can share, but that the Print action is not available.
[ChromeEarlGreyUI openShareMenu];
......@@ -110,7 +108,7 @@ id<GREYMatcher> ShareMenuCollectionView() {
- (void)testActivityServiceControllerIsDisabled {
// Open an un-shareable page.
GURL kURL("chrome://version");
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey loadURL:kURL]);
[ChromeEarlGrey loadURL:kURL];
// Verify that the share button is disabled.
id<GREYMatcher> share_button = chrome_test_util::ShareButton();
[[EarlGrey selectElementWithMatcher:share_button]
......@@ -130,7 +128,7 @@ id<GREYMatcher> ShareMenuCollectionView() {
web::test::SetUpSimpleHttpServer(responses);
// Open page and open the share menu.
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey loadURL:url]);
[ChromeEarlGrey loadURL:url];
[ChromeEarlGreyUI openShareMenu];
// Verify that the share menu is up and contains a Copy action.
......
......@@ -37,7 +37,6 @@
#import "ios/chrome/test/app/chrome_test_util.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h"
#import "ios/chrome/test/earl_grey/chrome_error_util.h"
#import "ios/chrome/test/earl_grey/chrome_matchers.h"
#import "ios/chrome/test/earl_grey/chrome_test_case.h"
#include "net/test/embedded_test_server/http_request.h"
......@@ -225,7 +224,7 @@ GREYElementInteraction* CellWithMatcher(id<GREYMatcher> matcher) {
// Open a new Tab.
ScrollUp();
[ChromeEarlGreyUI openNewTab];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey waitForMainTabCount:2]);
[ChromeEarlGrey waitForMainTabCount:2];
// Go back to the previous tab.
[ChromeEarlGrey selectTabAtIndex:0];
......@@ -296,13 +295,12 @@ GREYElementInteraction* CellWithMatcher(id<GREYMatcher> matcher) {
performAction:grey_tap()];
// Check that the page has been opened.
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey waitForWebStateContainingText:kPageLoadedString]);
[ChromeEarlGrey waitForWebStateContainingText:kPageLoadedString];
[[EarlGrey selectElementWithMatcher:chrome_test_util::OmniboxText(
pageURL.GetContent())]
assertWithMatcher:grey_notNil()];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey waitForMainTabCount:1]);
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey waitForIncognitoTabCount:0]);
[ChromeEarlGrey waitForMainTabCount:1];
[ChromeEarlGrey waitForIncognitoTabCount:0];
// Go back.
[[EarlGrey selectElementWithMatcher:chrome_test_util::BackButton()]
......@@ -349,8 +347,8 @@ GREYElementInteraction* CellWithMatcher(id<GREYMatcher> matcher) {
performAction:grey_tap()];
// Check a new page in normal model is opened.
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey waitForMainTabCount:2]);
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey waitForIncognitoTabCount:0]);
[ChromeEarlGrey waitForMainTabCount:2];
[ChromeEarlGrey waitForIncognitoTabCount:0];
// Check that the tab has been opened in background.
ConditionBlock condition = ^{
......@@ -367,8 +365,7 @@ GREYElementInteraction* CellWithMatcher(id<GREYMatcher> matcher) {
// Check the page has been correctly opened.
[ChromeEarlGrey selectTabAtIndex:1];
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey waitForWebStateContainingText:kPageLoadedString]);
[ChromeEarlGrey waitForWebStateContainingText:kPageLoadedString];
[[EarlGrey selectElementWithMatcher:chrome_test_util::OmniboxText(
pageURL.GetContent())]
assertWithMatcher:grey_notNil()];
......@@ -386,12 +383,11 @@ GREYElementInteraction* CellWithMatcher(id<GREYMatcher> matcher) {
IDS_IOS_CONTENT_CONTEXT_OPENLINKNEWINCOGNITOTAB)]
performAction:grey_tap()];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey waitForMainTabCount:1]);
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey waitForIncognitoTabCount:1]);
[ChromeEarlGrey waitForMainTabCount:1];
[ChromeEarlGrey waitForIncognitoTabCount:1];
// Check that the tab has been opened in foreground.
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey waitForWebStateContainingText:kPageLoadedString]);
[ChromeEarlGrey waitForWebStateContainingText:kPageLoadedString];
[[EarlGrey selectElementWithMatcher:chrome_test_util::OmniboxText(
pageURL.GetContent())]
assertWithMatcher:grey_notNil()];
......@@ -499,16 +495,15 @@ GREYElementInteraction* CellWithMatcher(id<GREYMatcher> matcher) {
// Clear history and verify that the tile does not exist.
[ChromeEarlGrey clearBrowsingHistory];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey loadURL:pageURL]);
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey waitForWebStateContainingText:kPageLoadedString]);
[ChromeEarlGrey loadURL:pageURL];
[ChromeEarlGrey waitForWebStateContainingText:kPageLoadedString];
// After loading URL, need to do another action before opening a new tab
// with the icon present.
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey goBack]);
[ChromeEarlGrey goBack];
[[self class] closeAllTabs];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey openNewTab]);
[ChromeEarlGrey openNewTab];
[[EarlGrey selectElementWithMatcher:
chrome_test_util::StaticTextWithAccessibilityLabel(pageTitle)]
......
......@@ -42,7 +42,6 @@
#include "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_ui.h"
#import "ios/chrome/test/earl_grey/chrome_error_util.h"
#import "ios/chrome/test/earl_grey/chrome_matchers.h"
#import "ios/chrome/test/earl_grey/chrome_test_case.h"
#import "ios/chrome/test/scoped_eg_synchronization_disabler.h"
......@@ -429,9 +428,8 @@ std::unique_ptr<net::test_server::HttpResponse> StandardResponse(
chrome_test_util::StaticTextWithAccessibilityLabel(
base::SysUTF8ToNSString(kPageTitle))]
performAction:grey_tap()];
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey waitForWebStateContainingText:kPageLoadedString]);
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey goBack]);
[ChromeEarlGrey waitForWebStateContainingText:kPageLoadedString];
[ChromeEarlGrey goBack];
// Check that the new position is the same.
omnibox = ntp_home::FakeOmnibox();
......@@ -468,9 +466,8 @@ std::unique_ptr<net::test_server::HttpResponse> StandardResponse(
chrome_test_util::StaticTextWithAccessibilityLabel(
base::SysUTF8ToNSString(kPageTitle))]
performAction:grey_tap()];
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey waitForWebStateContainingText:kPageLoadedString]);
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey goBack]);
[ChromeEarlGrey waitForWebStateContainingText:kPageLoadedString];
[ChromeEarlGrey goBack];
// Check that the new position is the same.
omnibox = ntp_home::FakeOmnibox();
......@@ -499,8 +496,7 @@ std::unique_ptr<net::test_server::HttpResponse> StandardResponse(
performAction:grey_typeText([URL stringByAppendingString:@"\n"])];
// Check that the page is loaded.
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey waitForWebStateContainingText:kPageLoadedString]);
[ChromeEarlGrey waitForWebStateContainingText:kPageLoadedString];
}
// Tests that tapping the omnibox search button logs correctly.
......@@ -631,9 +627,8 @@ std::unique_ptr<net::test_server::HttpResponse> StandardResponse(
[[EarlGrey selectElementWithMatcher:grey_accessibilityID(
kToolbarOmniboxButtonIdentifier)]
performAction:grey_tap()];
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey waitForSufficientlyVisibleElementWithMatcher:
chrome_test_util::Omnibox()]);
[ChromeEarlGrey
waitForSufficientlyVisibleElementWithMatcher:chrome_test_util::Omnibox()];
}
- (void)testOpeningNewTab {
......@@ -722,24 +717,22 @@ std::unique_ptr<net::test_server::HttpResponse> StandardResponse(
// Clear history to ensure the tile will be shown.
[ChromeEarlGrey clearBrowsingHistory];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey loadURL:pageURL]);
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey waitForWebStateContainingText:kPageLoadedString]);
[ChromeEarlGrey loadURL:pageURL];
[ChromeEarlGrey waitForWebStateContainingText:kPageLoadedString];
// After loading URL, need to do another action before opening a new tab
// with the icon present.
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey goBack]);
[ChromeEarlGrey goBack];
[[self class] closeAllTabs];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey openNewTab]);
[ChromeEarlGrey openNewTab];
}
// Taps the fake omnibox and waits for the real omnibox to be visible.
- (void)focusFakebox {
[[EarlGrey selectElementWithMatcher:chrome_test_util::FakeOmnibox()]
performAction:grey_tap()];
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey waitForSufficientlyVisibleElementWithMatcher:
chrome_test_util::Omnibox()]);
[ChromeEarlGrey
waitForSufficientlyVisibleElementWithMatcher:chrome_test_util::Omnibox()];
}
@end
......@@ -111,10 +111,10 @@ id<GREYMatcher> RequiredSelectorEditorFieldMatcher(int string_id) {
_creditCard2 = autofill::test::GetCreditCard2();
CHROME_EG_ASSERT_NO_ERROR([self addCreditCard:_creditCard2]);
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey
loadURL:web::test::HttpServer::MakeUrl(kPaymentRequestDemoPage)]);
[ChromeEarlGrey
loadURL:web::test::HttpServer::MakeUrl(kPaymentRequestDemoPage)];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey tapWebStateElementWithID:@"buy"]);
[ChromeEarlGrey tapWebStateElementWithID:@"buy"];
}
#pragma mark - Tests
......
......@@ -58,10 +58,9 @@ const char kCanMakePaymentMethodIdentifierPage[] =
- (void)testCanMakePaymentIsSupported {
CHROME_EG_ASSERT_NO_ERROR(
[self addCreditCard:autofill::test::GetCreditCard()]); // visa.
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey
loadURL:web::test::HttpServer::MakeUrl(kCanMakePaymentPage)]);
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kCanMakePaymentPage)];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey tapWebStateElementWithID:@"buy"]);
[ChromeEarlGrey tapWebStateElementWithID:@"buy"];
[self waitForWebViewContainingTexts:{"true"}];
}
......@@ -76,25 +75,22 @@ const char kCanMakePaymentMethodIdentifierPage[] =
[[EarlGrey selectElementWithMatcher:grey_accessibilityID(
kToolsMenuNewIncognitoTabId)]
performAction:grey_tap()];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey waitForIncognitoTabCount:1]);
[ChromeEarlGrey waitForIncognitoTabCount:1];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey
loadURL:web::test::HttpServer::MakeUrl(kCanMakePaymentPage)]);
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kCanMakePaymentPage)];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey
loadURL:web::test::HttpServer::MakeUrl(kCanMakePaymentPage)]);
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kCanMakePaymentPage)];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey tapWebStateElementWithID:@"buy"]);
[ChromeEarlGrey tapWebStateElementWithID:@"buy"];
[self waitForWebViewContainingTexts:{"true"}];
}
// Tests canMakePayment() when visa is required, but user doesn't have one.
- (void)testCanMakePaymentIsNotSupported {
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey
loadURL:web::test::HttpServer::MakeUrl(kCanMakePaymentPage)]);
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kCanMakePaymentPage)];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey tapWebStateElementWithID:@"buy"]);
[ChromeEarlGrey tapWebStateElementWithID:@"buy"];
[self waitForWebViewContainingTexts:{"false"}];
}
......@@ -107,12 +103,11 @@ const char kCanMakePaymentMethodIdentifierPage[] =
[[EarlGrey selectElementWithMatcher:grey_accessibilityID(
kToolsMenuNewIncognitoTabId)]
performAction:grey_tap()];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey waitForIncognitoTabCount:1]);
[ChromeEarlGrey waitForIncognitoTabCount:1];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey
loadURL:web::test::HttpServer::MakeUrl(kCanMakePaymentPage)]);
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kCanMakePaymentPage)];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey tapWebStateElementWithID:@"buy"]);
[ChromeEarlGrey tapWebStateElementWithID:@"buy"];
[self waitForWebViewContainingTexts:{"false"}];
}
......@@ -127,10 +122,9 @@ const char kCanMakePaymentMethodIdentifierPage[] =
CHROME_EG_ASSERT_NO_ERROR(
[self addCreditCard:autofill::test::GetCreditCard()]); // visa.
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey
loadURL:web::test::HttpServer::MakeUrl(kCanMakePaymentPage)]);
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kCanMakePaymentPage)];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey tapWebStateElementWithID:@"buy"]);
[ChromeEarlGrey tapWebStateElementWithID:@"buy"];
[self waitForWebViewContainingTexts:{"false"}];
}
......@@ -151,15 +145,13 @@ const char kCanMakePaymentMethodIdentifierPage[] =
[[EarlGrey selectElementWithMatcher:grey_accessibilityID(
kToolsMenuNewIncognitoTabId)]
performAction:grey_tap()];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey waitForIncognitoTabCount:1]);
[ChromeEarlGrey waitForIncognitoTabCount:1];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey
loadURL:web::test::HttpServer::MakeUrl(kCanMakePaymentPage)]);
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kCanMakePaymentPage)];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey
loadURL:web::test::HttpServer::MakeUrl(kCanMakePaymentPage)]);
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kCanMakePaymentPage)];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey tapWebStateElementWithID:@"buy"]);
[ChromeEarlGrey tapWebStateElementWithID:@"buy"];
[self waitForWebViewContainingTexts:{"false"}];
}
......@@ -194,18 +186,17 @@ const char kCanMakePaymentMethodIdentifierPage[] =
@"available.");
}
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey
loadURL:web::test::HttpServer::MakeUrl(kCanMakePaymentCreditCardPage)]);
[ChromeEarlGrey
loadURL:web::test::HttpServer::MakeUrl(kCanMakePaymentCreditCardPage)];
// Query visa payment method.
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey tapWebStateElementWithID:@"buy"]);
[ChromeEarlGrey tapWebStateElementWithID:@"buy"];
// User does not have a visa card.
[self waitForWebViewContainingTexts:{"false"}];
// Query Mastercard payment method.
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey tapWebStateElementWithID:@"other-buy"]);
[ChromeEarlGrey tapWebStateElementWithID:@"other-buy"];
// Query quota exceeded.
[self
......@@ -216,14 +207,13 @@ const char kCanMakePaymentMethodIdentifierPage[] =
[self addCreditCard:autofill::test::GetCreditCard()]); // visa.
// Query visa payment method.
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey tapWebStateElementWithID:@"buy"]);
[ChromeEarlGrey tapWebStateElementWithID:@"buy"];
// User has a visa card. While the query is cached, result is always fresh.
[self waitForWebViewContainingTexts:{"true"}];
// Query Mastercard payment method.
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey tapWebStateElementWithID:@"other-buy"]);
[ChromeEarlGrey tapWebStateElementWithID:@"other-buy"];
// Query quota exceeded.
[self
......@@ -261,21 +251,18 @@ const char kCanMakePaymentMethodIdentifierPage[] =
@"available.");
}
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(
kCanMakePaymentMethodIdentifierPage)]);
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(
kCanMakePaymentMethodIdentifierPage)];
// Query basic-card payment method with "supportedNetworks": ["visa"] in the
// payment method specific data.
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey tapWebStateElementWithID:@"checkBasicVisa"]);
[ChromeEarlGrey tapWebStateElementWithID:@"checkBasicVisa"];
// User does not have a visa card.
[self waitForWebViewContainingTexts:{"false"}];
// Query basic-card payment method without "supportedNetworks" parameter.
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey tapWebStateElementWithID:@"checkBasicCard"]);
[ChromeEarlGrey tapWebStateElementWithID:@"checkBasicCard"];
// Query quota exceeded.
[self
......@@ -287,15 +274,13 @@ const char kCanMakePaymentMethodIdentifierPage[] =
// Query basic-card payment method with "supportedNetworks": ["visa"] in the
// payment method specific data.
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey tapWebStateElementWithID:@"checkBasicVisa"]);
[ChromeEarlGrey tapWebStateElementWithID:@"checkBasicVisa"];
// User has a visa card. While the query is cached, result is always fresh.
[self waitForWebViewContainingTexts:{"true"}];
// Query basic-card payment method without "supportedNetworks" parameter.
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey tapWebStateElementWithID:@"checkBasicCard"]);
[ChromeEarlGrey tapWebStateElementWithID:@"checkBasicCard"];
// Query quota exceeded.
[self
......
......@@ -51,17 +51,15 @@ const char kNoShippingPage[] =
// Tests that navigating to a URL closes the Payment Request UI.
- (void)testOpenAndNavigateToURL {
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kAbortPage)]);
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kAbortPage)];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey tapWebStateElementWithID:@"buy"]);
[ChromeEarlGrey tapWebStateElementWithID:@"buy"];
// Confirm that the Payment Request UI is showing.
[[EarlGrey selectElementWithMatcher:chrome_test_util::PaymentRequestView()]
assertWithMatcher:grey_notNil()];
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kNoShippingPage)]);
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kNoShippingPage)];
// Confirm that the Payment Request UI is not showing.
[[EarlGrey selectElementWithMatcher:chrome_test_util::PaymentRequestView()]
......@@ -70,16 +68,15 @@ const char kNoShippingPage[] =
// Tests that reloading the page closes the Payment Request UI.
- (void)testOpenAndReload {
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kAbortPage)]);
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kAbortPage)];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey tapWebStateElementWithID:@"buy"]);
[ChromeEarlGrey tapWebStateElementWithID:@"buy"];
// Confirm that the Payment Request UI is showing.
[[EarlGrey selectElementWithMatcher:chrome_test_util::PaymentRequestView()]
assertWithMatcher:grey_notNil()];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey reload]);
[ChromeEarlGrey reload];
// Confirm that the Payment Request UI is not showing.
[[EarlGrey selectElementWithMatcher:chrome_test_util::PaymentRequestView()]
......@@ -88,16 +85,15 @@ const char kNoShippingPage[] =
// Tests that navigating to the previous page closes the Payment Request UI.
- (void)testOpenAndNavigateBack {
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kAbortPage)]);
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kAbortPage)];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey tapWebStateElementWithID:@"buy"]);
[ChromeEarlGrey tapWebStateElementWithID:@"buy"];
// Confirm that the Payment Request UI is showing.
[[EarlGrey selectElementWithMatcher:chrome_test_util::PaymentRequestView()]
assertWithMatcher:grey_notNil()];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey goBack]);
[ChromeEarlGrey goBack];
// Confirm that the Payment Request UI is not showing.
[[EarlGrey selectElementWithMatcher:chrome_test_util::PaymentRequestView()]
......@@ -113,10 +109,9 @@ const char kNoShippingPage[] =
@"available.");
}
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kAbortPage)]);
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kAbortPage)];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey tapWebStateElementWithID:@"buy"]);
[ChromeEarlGrey tapWebStateElementWithID:@"buy"];
// Confirm that the Payment Request UI is showing.
[[EarlGrey selectElementWithMatcher:chrome_test_util::PaymentRequestView()]
......@@ -144,10 +139,9 @@ const char kNoShippingPage[] =
@"available.");
}
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kAbortPage)]);
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kAbortPage)];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey tapWebStateElementWithID:@"buy"]);
[ChromeEarlGrey tapWebStateElementWithID:@"buy"];
// Confirm that the Payment Request UI is showing.
[[EarlGrey selectElementWithMatcher:chrome_test_util::PaymentRequestView()]
......@@ -180,10 +174,9 @@ const char kNoShippingPage[] =
card.set_billing_address_id(profile.guid());
CHROME_EG_ASSERT_NO_ERROR([self addCreditCard:card]);
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kNoShippingPage)]);
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kNoShippingPage)];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey tapWebStateElementWithID:@"buy"]);
[ChromeEarlGrey tapWebStateElementWithID:@"buy"];
// Confirm that the Payment Request UI is showing.
[[EarlGrey selectElementWithMatcher:chrome_test_util::PaymentRequestView()]
......@@ -217,16 +210,15 @@ const char kNoShippingPage[] =
// Tests that calling request.abort() successfully aborts the Payment Request.
- (void)testAbort {
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kAbortPage)]);
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kAbortPage)];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey tapWebStateElementWithID:@"buy"]);
[ChromeEarlGrey tapWebStateElementWithID:@"buy"];
// Confirm that the Payment Request UI is showing.
[[EarlGrey selectElementWithMatcher:chrome_test_util::PaymentRequestView()]
assertWithMatcher:grey_notNil()];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey tapWebStateElementWithID:@"abort"]);
[ChromeEarlGrey tapWebStateElementWithID:@"abort"];
// Confirm that the error confirmation UI is showing.
[[EarlGrey
......
......@@ -7,7 +7,6 @@
#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"
#include "testing/gtest/include/gtest/gtest.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
......@@ -25,7 +24,7 @@
// Tests that PaymentRequest's constructor throws a SecurityError.
- (void)testSecurityError {
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey
[ChromeEarlGrey
loadURL:GURL("data:text/html,<html><head><meta name=\"viewport\" "
"content=\"width=device-width, initial-scale=1, "
"maximum-scale=1\"></head><body><button id=\"buy\" "
......@@ -35,9 +34,9 @@
"'1.00'}}})).show(); } "
"catch(e) { document.getElementById('result').innerHTML = "
"e; }\">Data URL Test</button><div "
"id='result'></div></body></html>")]);
"id='result'></div></body></html>")];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey tapWebStateElementWithID:@"buy"]);
[ChromeEarlGrey tapWebStateElementWithID:@"buy"];
[self waitForWebViewContainingTexts:{"SecurityError",
"Failed to construct 'PaymentRequest': "
......
......@@ -99,13 +99,11 @@ std::unique_ptr<autofill::AutofillProfile> _profile;
featureList.InitAndEnableFeature(
payments::features::kReturnGooglePayInBasicCard);
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kDebitPage)]);
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kDebitPage)];
[self addServerCardWithType:DEBIT];
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey tapWebStateElementWithID:@"canMakePayment"]);
[ChromeEarlGrey tapWebStateElementWithID:@"canMakePayment"];
[self waitForWebViewContainingTexts:{"true"}];
}
......@@ -116,27 +114,23 @@ std::unique_ptr<autofill::AutofillProfile> _profile;
featureList.InitAndEnableFeature(
payments::features::kReturnGooglePayInBasicCard);
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kDebitPage)]);
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kDebitPage)];
[self addServerCardWithType:UNKNOWN];
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey tapWebStateElementWithID:@"canMakePayment"]);
[ChromeEarlGrey tapWebStateElementWithID:@"canMakePayment"];
[self waitForWebViewContainingTexts:{"true"}];
}
// Tests that canMakePayment() resolves with false with credit or prepaid cards.
- (void)testCannotMakePaymentWithCreditAndPrepaidCard {
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kDebitPage)]);
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kDebitPage)];
[self addServerCardWithType:CREDIT];
[self addServerCardWithType:PREPAID];
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey tapWebStateElementWithID:@"canMakePayment"]);
[ChromeEarlGrey tapWebStateElementWithID:@"canMakePayment"];
[self waitForWebViewContainingTexts:{"false"}];
}
......@@ -147,12 +141,11 @@ std::unique_ptr<autofill::AutofillProfile> _profile;
featureList.InitAndEnableFeature(
payments::features::kReturnGooglePayInBasicCard);
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kDebitPage)]);
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kDebitPage)];
[self addServerCardWithType:DEBIT];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey tapWebStateElementWithID:@"buy"]);
[ChromeEarlGrey tapWebStateElementWithID:@"buy"];
// Confirm that the Payment Request UI is showing.
[[EarlGrey selectElementWithMatcher:chrome_test_util::PaymentRequestView()]
......@@ -166,12 +159,11 @@ std::unique_ptr<autofill::AutofillProfile> _profile;
// Tests that an "unknown" card is not preselected.
- (void)testUnknownCardTypeIsNotPreselected {
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kDebitPage)]);
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kDebitPage)];
[self addServerCardWithType:UNKNOWN];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey tapWebStateElementWithID:@"buy"]);
[ChromeEarlGrey tapWebStateElementWithID:@"buy"];
// Confirm that the Payment Request UI is showing.
[[EarlGrey selectElementWithMatcher:chrome_test_util::PaymentRequestView()]
......@@ -191,10 +183,9 @@ std::unique_ptr<autofill::AutofillProfile> _profile;
card.set_billing_address_id(_profile->guid());
CHROME_EG_ASSERT_NO_ERROR([self addCreditCard:card]);
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kDebitPage)]);
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kDebitPage)];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey tapWebStateElementWithID:@"buy"]);
[ChromeEarlGrey tapWebStateElementWithID:@"buy"];
// Confirm that the Payment Request UI is showing.
[[EarlGrey selectElementWithMatcher:chrome_test_util::PaymentRequestView()]
......
......@@ -73,7 +73,7 @@ using payments::JourneyLogger;
[self addCard1];
[self loadTestPage:"payment_request_no_shipping_test.html"];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey tapWebStateElementWithID:@"buy"]);
[ChromeEarlGrey tapWebStateElementWithID:@"buy"];
[self payWithCreditCardUsingCVC:@"123"];
// Make sure the correct events were logged.
......@@ -130,7 +130,7 @@ using payments::JourneyLogger;
[self addCard1];
[self loadTestPage:"payment_request_bobpay_test.html"];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey tapWebStateElementWithID:@"buy"]);
[ChromeEarlGrey tapWebStateElementWithID:@"buy"];
[self waitForWebViewContainingTexts:{"rejected"}];
FailureBlock failureBlock = ^(NSString* error) {
......@@ -195,9 +195,8 @@ using payments::JourneyLogger;
[self addCard1];
[self loadTestPage:"payment_request_multiple_show_test.html"];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey tapWebStateElementWithID:@"buy"]);
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey tapWebStateElementWithID:@"showAgain"]);
[ChromeEarlGrey tapWebStateElementWithID:@"buy"];
[ChromeEarlGrey tapWebStateElementWithID:@"showAgain"];
[self payWithCreditCardUsingCVC:@"123"];
// Trying to show the same request twice is not considered a concurrent
......@@ -271,7 +270,7 @@ using payments::JourneyLogger;
[self loadTestPage:
"payment_request_contact_details_and_free_shipping_test.html"];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey tapWebStateElementWithID:@"buy"]);
[ChromeEarlGrey tapWebStateElementWithID:@"buy"];
[self payWithCreditCardUsingCVC:@"123"];
FailureBlock failureBlock = ^(NSString* error) {
......@@ -345,7 +344,7 @@ using payments::JourneyLogger;
[self loadTestPage:
"payment_request_contact_details_and_free_shipping_test.html"];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey tapWebStateElementWithID:@"buy"]);
[ChromeEarlGrey tapWebStateElementWithID:@"buy"];
[[EarlGrey
selectElementWithMatcher:chrome_test_util::ButtonWithAccessibilityLabelId(
IDS_CANCEL)] performAction:grey_tap()];
......@@ -423,7 +422,7 @@ using payments::JourneyLogger;
[self addCard1];
[self loadTestPage:"payment_request_contact_details_test.html"];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey tapWebStateElementWithID:@"buy"]);
[ChromeEarlGrey tapWebStateElementWithID:@"buy"];
[self payWithCreditCardUsingCVC:@"123"];
FailureBlock failureBlock = ^(NSString* error) {
......@@ -498,7 +497,7 @@ using payments::JourneyLogger;
[self addCard1];
[self loadTestPage:"payment_request_contact_details_test.html"];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey tapWebStateElementWithID:@"buy"]);
[ChromeEarlGrey tapWebStateElementWithID:@"buy"];
[[EarlGrey
selectElementWithMatcher:chrome_test_util::ButtonWithAccessibilityLabelId(
IDS_CANCEL)] performAction:grey_tap()];
......@@ -579,7 +578,7 @@ using payments::JourneyLogger;
[self addCard1];
[self loadTestPage:"payment_request_free_shipping_test.html"];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey tapWebStateElementWithID:@"buy"]);
[ChromeEarlGrey tapWebStateElementWithID:@"buy"];
[self payWithCreditCardUsingCVC:@"123"];
FailureBlock failureBlock = ^(NSString* error) {
......@@ -655,7 +654,7 @@ using payments::JourneyLogger;
[self addCard1];
[self loadTestPage:"payment_request_free_shipping_test.html"];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey tapWebStateElementWithID:@"buy"]);
[ChromeEarlGrey tapWebStateElementWithID:@"buy"];
[[EarlGrey
selectElementWithMatcher:chrome_test_util::ButtonWithAccessibilityLabelId(
IDS_CANCEL)] performAction:grey_tap()];
......@@ -729,8 +728,7 @@ using payments::JourneyLogger;
chrome_test_util::HistogramTester histogramTester;
[self loadTestPage:"payment_request_can_make_payment_metrics_test.html"];
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey tapWebStateElementWithID:@"queryNoShow"]);
[ChromeEarlGrey tapWebStateElementWithID:@"queryNoShow"];
// Navigate away to abort the Payment Request and trigger the logs.
[self loadTestPage:"payment_request_email_test.html"];
......@@ -777,7 +775,7 @@ using payments::JourneyLogger;
[self addCard1];
[self loadTestPage:"payment_request_email_test.html"];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey tapWebStateElementWithID:@"buy"]);
[ChromeEarlGrey tapWebStateElementWithID:@"buy"];
// Navigate away to abort the Payment Request and trigger the logs.
[self loadTestPage:"payment_request_email_test.html"];
......@@ -829,7 +827,7 @@ using payments::JourneyLogger;
[self addProfiles]; // The user has no form of payment on file.
[self loadTestPage:"payment_request_email_test.html"];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey tapWebStateElementWithID:@"buy"]);
[ChromeEarlGrey tapWebStateElementWithID:@"buy"];
// Navigate away to abort the Payment Request and trigger the logs.
[self loadTestPage:"payment_request_email_test.html"];
......@@ -882,7 +880,7 @@ using payments::JourneyLogger;
[self addCard2]; // AMEX is not supported by the merchant.
[self loadTestPage:"payment_request_email_test.html"];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey tapWebStateElementWithID:@"buy"]);
[ChromeEarlGrey tapWebStateElementWithID:@"buy"];
// Navigate away to abort the Payment Request and trigger the logs.
[self loadTestPage:"payment_request_email_test.html"];
......
......@@ -8,7 +8,6 @@
#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/web/public/test/http_server/http_server.h"
#include "testing/gtest/include/gtest/gtest.h"
......@@ -37,8 +36,8 @@ const char kMultipleRequestsPage[] =
// Tests that the page can create multiple PaymentRequest objects.
- (void)testMultipleRequests {
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey
loadURL:web::test::HttpServer::MakeUrl(kMultipleRequestsPage)]);
[ChromeEarlGrey
loadURL:web::test::HttpServer::MakeUrl(kMultipleRequestsPage)];
const payments::PaymentRequestCache::PaymentRequestSet& payment_requests =
[self paymentRequestsForWebState:GetCurrentWebState()];
......
......@@ -101,10 +101,9 @@ id<GREYMatcher> PaymentMethodCellMatcher(
// Tests that no modifier should be applied if there is no selected instrument.
- (void)testNoModifierAppliedNoSelectedInstrument {
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kModifiersPage)]);
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kModifiersPage)];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey tapWebStateElementWithID:@"buy"]);
[ChromeEarlGrey tapWebStateElementWithID:@"buy"];
// Verify there's no line item.
[[EarlGrey selectElementWithMatcher:PriceCellMatcher(@"Total, USD $5.00", NO)]
......@@ -114,12 +113,11 @@ id<GREYMatcher> PaymentMethodCellMatcher(
// Tests that modifiers should be applied if there is a selected local credit
// card instrument and the modifiers are for basic-card.
- (void)testModifierAppliedSelectedLocalInstrumentWithoutTypeOrNetwork {
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kModifiersPage)]);
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kModifiersPage)];
[self addLocalCard];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey tapWebStateElementWithID:@"buy"]);
[ChromeEarlGrey tapWebStateElementWithID:@"buy"];
// Verify there's a selected payment method.
[[EarlGrey selectElementWithMatcher:PaymentMethodCellMatcher(_localCard)]
......@@ -143,12 +141,11 @@ id<GREYMatcher> PaymentMethodCellMatcher(
featureList.InitAndEnableFeature(
payments::features::kReturnGooglePayInBasicCard);
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kModifiersPage)]);
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kModifiersPage)];
[self addServerCardWithType:CREDIT];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey tapWebStateElementWithID:@"buy"]);
[ChromeEarlGrey tapWebStateElementWithID:@"buy"];
// Verify there's a selected payment method.
[[EarlGrey selectElementWithMatcher:PaymentMethodCellMatcher(_serverCard)]
......@@ -172,13 +169,11 @@ id<GREYMatcher> PaymentMethodCellMatcher(
featureList.InitAndEnableFeature(
payments::features::kReturnGooglePayInBasicCard);
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kModifiersPage)]);
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kModifiersPage)];
[self addServerCardWithType:CREDIT];
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey tapWebStateElementWithID:@"credit_supported_type"]);
[ChromeEarlGrey tapWebStateElementWithID:@"credit_supported_type"];
// Verify there's a selected payment method.
[[EarlGrey selectElementWithMatcher:PaymentMethodCellMatcher(_serverCard)]
......@@ -198,13 +193,11 @@ id<GREYMatcher> PaymentMethodCellMatcher(
// Tests that no modifier should be applied if there is a selected credit card
// instrument but the modifiers are for basic-card of mismatching type.
- (void)testNoModifierAppliedSelectedInstrumentWithMismatchingSupportedType {
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kModifiersPage)]);
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kModifiersPage)];
[self addServerCardWithType:CREDIT];
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey tapWebStateElementWithID:@"debit_supported_type"]);
[ChromeEarlGrey tapWebStateElementWithID:@"debit_supported_type"];
// Verify there's no line item.
[[EarlGrey selectElementWithMatcher:PriceCellMatcher(@"Total, USD $5.00", NO)]
......@@ -218,13 +211,11 @@ id<GREYMatcher> PaymentMethodCellMatcher(
featureList.InitAndEnableFeature(
payments::features::kReturnGooglePayInBasicCard);
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kModifiersPage)]);
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kModifiersPage)];
[self addServerCardWithType:CREDIT];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey
tapWebStateElementWithID:@"mastercard_any_supported_type"]);
[ChromeEarlGrey tapWebStateElementWithID:@"mastercard_any_supported_type"];
// Verify there's a selected payment method.
[[EarlGrey selectElementWithMatcher:PaymentMethodCellMatcher(_serverCard)]
......@@ -244,13 +235,11 @@ id<GREYMatcher> PaymentMethodCellMatcher(
// Tests that no modifier should be applied if there is a selected credit card
// instrument but the modifiers are for basic-card of mismatching network.
- (void)testNoModifierAppliedSelectedInstrumentWithMismatchingSupportedNetwork {
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kModifiersPage)]);
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kModifiersPage)];
[self addLocalCard];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey
tapWebStateElementWithID:@"mastercard_any_supported_type"]);
[ChromeEarlGrey tapWebStateElementWithID:@"mastercard_any_supported_type"];
// Verify there's a selected payment method.
[[EarlGrey selectElementWithMatcher:PaymentMethodCellMatcher(_localCard)]
......@@ -269,13 +258,11 @@ id<GREYMatcher> PaymentMethodCellMatcher(
featureList.InitAndEnableFeature(
payments::features::kReturnGooglePayInBasicCard);
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kModifiersPage)]);
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kModifiersPage)];
[self addServerCardWithType:CREDIT];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey
tapWebStateElementWithID:@"mastercard_supported_network"]);
[ChromeEarlGrey tapWebStateElementWithID:@"mastercard_supported_network"];
// Verify there's a selected payment method.
[[EarlGrey selectElementWithMatcher:PaymentMethodCellMatcher(_serverCard)]
......
......@@ -7,7 +7,6 @@
#include "base/ios/ios_util.h"
#import "ios/chrome/browser/ui/payments/payment_request_egtest_base.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey.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"
......@@ -42,10 +41,9 @@ const char kBobPayPage[] =
@"available.");
}
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kBobPayPage)]);
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kBobPayPage)];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey tapWebStateElementWithID:@"buy"]);
[ChromeEarlGrey tapWebStateElementWithID:@"buy"];
[self waitForWebViewContainingTexts:{"NotSupportedError",
"The payment method is not supported"}];
......@@ -54,11 +52,9 @@ const char kBobPayPage[] =
// Tests that the Promise returned by canMakePayment() gets resolved with false
// if the requested payment methods are payment apps that are not installed.
- (void)testCanMakePaymentPaymentAppNotInstalled {
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kBobPayPage)]);
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kBobPayPage)];
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey tapWebStateElementWithID:@"canMakePayment"]);
[ChromeEarlGrey tapWebStateElementWithID:@"canMakePayment"];
[self waitForWebViewContainingTexts:{"false"}];
}
......
......@@ -10,7 +10,6 @@
#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/web/public/test/http_server/http_server.h"
#import "ios/web/public/test/web_view_interaction_test_util.h"
#include "testing/gtest/include/gtest/gtest.h"
......@@ -43,10 +42,10 @@ const char kPaymentMethodIdentifierPage[] =
// One network is specified in 'basic-card' data, one in supportedMethods.
- (void)testBasicCardNetworksSpecified {
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey
loadURL:web::test::HttpServer::MakeUrl(kPaymentMethodIdentifierPage)]);
[ChromeEarlGrey
loadURL:web::test::HttpServer::MakeUrl(kPaymentMethodIdentifierPage)];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey tapWebStateElementWithID:@"buy"]);
[ChromeEarlGrey tapWebStateElementWithID:@"buy"];
const payments::PaymentRequestCache::PaymentRequestSet& requests =
[self paymentRequestsForWebState:GetCurrentWebState()];
......@@ -64,11 +63,10 @@ const char kPaymentMethodIdentifierPage[] =
// Only specifying 'basic-card' with no supportedNetworks means all networks are
// supported.
- (void)testBasicCardNoNetworksSpecified {
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey
loadURL:web::test::HttpServer::MakeUrl(kPaymentMethodIdentifierPage)]);
[ChromeEarlGrey
loadURL:web::test::HttpServer::MakeUrl(kPaymentMethodIdentifierPage)];
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey tapWebStateElementWithID:@"buyBasicCard"]);
[ChromeEarlGrey tapWebStateElementWithID:@"buyBasicCard"];
const payments::PaymentRequestCache::PaymentRequestSet& requests =
[self paymentRequestsForWebState:GetCurrentWebState()];
......@@ -91,8 +89,8 @@ const char kPaymentMethodIdentifierPage[] =
// Specifying 'basic-card' with some networks after having explicitely included
// the same networks does not yield duplicates and has the expected order.
- (void)testBasicCardNetworkThenBasicCardWithSameNetwork {
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey
loadURL:web::test::HttpServer::MakeUrl(kPaymentMethodIdentifierPage)]);
[ChromeEarlGrey
loadURL:web::test::HttpServer::MakeUrl(kPaymentMethodIdentifierPage)];
web::test::ExecuteJavaScript(
GetCurrentWebState(),
......@@ -123,8 +121,8 @@ const char kPaymentMethodIdentifierPage[] =
// A url-based payment method identifier is only supported if it has an https
// scheme.
- (void)testValidURLBasedPaymentMethodIdentifier {
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey
loadURL:web::test::HttpServer::MakeUrl(kPaymentMethodIdentifierPage)]);
[ChromeEarlGrey
loadURL:web::test::HttpServer::MakeUrl(kPaymentMethodIdentifierPage)];
web::test::ExecuteJavaScript(GetCurrentWebState(),
"buyHelper([{"
......@@ -146,8 +144,8 @@ const char kPaymentMethodIdentifierPage[] =
// An invalid URL-based payment method identifier results in a RangeError.
- (void)testURLBasedPaymentMethodIdentifierWithInvalidScheme {
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey
loadURL:web::test::HttpServer::MakeUrl(kPaymentMethodIdentifierPage)]);
[ChromeEarlGrey
loadURL:web::test::HttpServer::MakeUrl(kPaymentMethodIdentifierPage)];
web::test::ExecuteJavaScript(GetCurrentWebState(),
"buyHelper([{"
......@@ -168,8 +166,8 @@ const char kPaymentMethodIdentifierPage[] =
// An invalid standard payment method identifier results in a RangeError.
- (void)testStandardPaymentMethodIdentifierWithInvalidCharacters {
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey
loadURL:web::test::HttpServer::MakeUrl(kPaymentMethodIdentifierPage)]);
[ChromeEarlGrey
loadURL:web::test::HttpServer::MakeUrl(kPaymentMethodIdentifierPage)];
web::test::ExecuteJavaScript(
GetCurrentWebState(),
......
......@@ -67,10 +67,9 @@ const char kRequestEmailPage[] =
card.set_billing_address_id(billingAddress.guid());
CHROME_EG_ASSERT_NO_ERROR([self addCreditCard:card]);
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kNoShippingPage)]);
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kNoShippingPage)];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey tapWebStateElementWithID:@"buy"]);
[ChromeEarlGrey tapWebStateElementWithID:@"buy"];
// Tap the buy button.
[[EarlGrey selectElementWithMatcher:ButtonWithAccessibilityLabelId(
......@@ -135,10 +134,9 @@ const char kRequestEmailPage[] =
shippingAddress.set_use_count(2000);
CHROME_EG_ASSERT_NO_ERROR([self addAutofillProfile:shippingAddress]);
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey
loadURL:web::test::HttpServer::MakeUrl(kFreeShippingPage)]);
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kFreeShippingPage)];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey tapWebStateElementWithID:@"buy"]);
[ChromeEarlGrey tapWebStateElementWithID:@"buy"];
// Tap the buy button.
[[EarlGrey selectElementWithMatcher:ButtonWithAccessibilityLabelId(
......@@ -190,10 +188,9 @@ const char kRequestEmailPage[] =
card.set_billing_address_id(billingAddress.guid());
CHROME_EG_ASSERT_NO_ERROR([self addCreditCard:card]);
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey
loadURL:web::test::HttpServer::MakeUrl(kContactDetailsPage)]);
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kContactDetailsPage)];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey tapWebStateElementWithID:@"buy"]);
[ChromeEarlGrey tapWebStateElementWithID:@"buy"];
// Tap the buy button.
[[EarlGrey selectElementWithMatcher:ButtonWithAccessibilityLabelId(
......@@ -227,10 +224,9 @@ const char kRequestEmailPage[] =
card.set_billing_address_id(billingAddress.guid());
CHROME_EG_ASSERT_NO_ERROR([self addCreditCard:card]);
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey
loadURL:web::test::HttpServer::MakeUrl(kRequestEmailPage)]);
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kRequestEmailPage)];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey tapWebStateElementWithID:@"buy"]);
[ChromeEarlGrey tapWebStateElementWithID:@"buy"];
// Tap the buy button.
[[EarlGrey selectElementWithMatcher:ButtonWithAccessibilityLabelId(
......
......@@ -62,11 +62,9 @@ id<GREYMatcher> PriceCellMatcher(NSString* accessibilityLabel) {
// Tests when PaymentRequest.show() is called without a promise the payment
// sheet is displayed with the payment details.
- (void)testBuyWithNoPromise {
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey
loadURL:web::test::HttpServer::MakeUrl(kShowPromisePage)]);
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kShowPromisePage)];
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey tapWebStateElementWithID:@"buyWithNoPromise"]);
[ChromeEarlGrey tapWebStateElementWithID:@"buyWithNoPromise"];
// Confirm that the Payment Request UI is showing.
[[EarlGrey selectElementWithMatcher:chrome_test_util::PaymentRequestView()]
......@@ -87,8 +85,7 @@ id<GREYMatcher> PriceCellMatcher(NSString* accessibilityLabel) {
// the promise resolves, the payment sheet displays the payment details and the
// Buy button is enabled.
- (void)testBuyWithResolvingPromise {
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey
loadURL:web::test::HttpServer::MakeUrl(kShowPromisePage)]);
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kShowPromisePage)];
// Disable EarlGrey's synchronization. Needed likely due to
// MDCActivityIndicator being present on the payment request view.
......@@ -96,8 +93,7 @@ id<GREYMatcher> PriceCellMatcher(NSString* accessibilityLabel) {
setValue:@NO
forConfigKey:kGREYConfigKeySynchronizationEnabled];
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey tapWebStateElementWithID:@"buyWithResolvingPromise"]);
[ChromeEarlGrey tapWebStateElementWithID:@"buyWithResolvingPromise"];
// Wait until the payment request view shows.
ConditionBlock condition = ^{
......@@ -141,8 +137,7 @@ id<GREYMatcher> PriceCellMatcher(NSString* accessibilityLabel) {
// is initially displayed with a spinner and the Buy button is not enabled. Once
// the promise rejects, the payment is aborted.
- (void)testBuyWithRejectingPromise {
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey
loadURL:web::test::HttpServer::MakeUrl(kShowPromisePage)]);
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kShowPromisePage)];
// Disable EarlGrey's synchronization. Needed likely due to
// MDCActivityIndicator being present on the payment request view.
......@@ -150,8 +145,7 @@ id<GREYMatcher> PriceCellMatcher(NSString* accessibilityLabel) {
setValue:@NO
forConfigKey:kGREYConfigKeySynchronizationEnabled];
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey tapWebStateElementWithID:@"buyWithRejectingPromise"]);
[ChromeEarlGrey tapWebStateElementWithID:@"buyWithRejectingPromise"];
// Wait until the payment request view shows.
ConditionBlock condition = ^{
......
......@@ -67,7 +67,7 @@ const char kContactDetailsFreeShippingPage[] =
// Completes the Payment Request.
- (void)completePayment {
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey tapWebStateElementWithID:@"buy"]);
[ChromeEarlGrey tapWebStateElementWithID:@"buy"];
// Tap the buy button.
[[EarlGrey selectElementWithMatcher:ButtonWithAccessibilityLabelId(
......@@ -113,8 +113,7 @@ const char kContactDetailsFreeShippingPage[] =
EXPECT_EQ(1U, initialBilling->use_count());
EXPECT_EQ(kSomeDate, initialBilling->use_date());
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kNoShippingPage)]);
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kNoShippingPage)];
testClock.SetNow(kSomeLaterDate);
[self completePayment];
......@@ -152,8 +151,7 @@ const char kContactDetailsFreeShippingPage[] =
EXPECT_EQ(3U, initialShipping->use_count());
EXPECT_EQ(kSomeDate, initialShipping->use_date());
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey
loadURL:web::test::HttpServer::MakeUrl(kFreeShippingPage)]);
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kFreeShippingPage)];
testClock.SetNow(kSomeLaterDate);
[self completePayment];
......@@ -185,8 +183,7 @@ const char kContactDetailsFreeShippingPage[] =
EXPECT_EQ(3U, initialContact->use_count());
EXPECT_EQ(kSomeDate, initialContact->use_date());
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey
loadURL:web::test::HttpServer::MakeUrl(kRequestNamePage)]);
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kRequestNamePage)];
testClock.SetNow(kSomeLaterDate);
[self completePayment];
......@@ -218,8 +215,8 @@ const char kContactDetailsFreeShippingPage[] =
EXPECT_EQ(3U, initialAddress->use_count());
EXPECT_EQ(kSomeDate, initialAddress->use_date());
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey
loadURL:web::test::HttpServer::MakeUrl(kContactDetailsFreeShippingPage)]);
[ChromeEarlGrey
loadURL:web::test::HttpServer::MakeUrl(kContactDetailsFreeShippingPage)];
testClock.SetNow(kSomeLaterDate);
[self completePayment];
......
......@@ -29,7 +29,6 @@
#import "ios/chrome/test/app/chrome_test_util.h"
#import "ios/chrome/test/base/scoped_block_swizzler.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_test_case.h"
#import "ios/web/public/test/http_server/http_server.h"
......@@ -116,9 +115,8 @@ void ShowQRScanner() {
// Tap the omnibox to get the keyboard accessory view to show up.
[[EarlGrey selectElementWithMatcher:chrome_test_util::NewTabPageOmnibox()]
performAction:grey_tap()];
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey waitForSufficientlyVisibleElementWithMatcher:
chrome_test_util::Omnibox()]);
[ChromeEarlGrey
waitForSufficientlyVisibleElementWithMatcher:chrome_test_util::Omnibox()];
// Tap the QR Code scanner button in the keyboard accessory view.
id<GREYMatcher> matcher =
......@@ -777,8 +775,7 @@ void TapKeyboardReturnKeyInOmniboxWithText(std::string text) {
} else {
TapKeyboardReturnKeyInOmniboxWithText(result);
}
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey waitForWebStateContainingText:response]);
[ChromeEarlGrey waitForWebStateContainingText:response];
// Press the back button to get back to the NTP.
[[EarlGrey selectElementWithMatcher:chrome_test_util::BackButton()]
......
......@@ -32,7 +32,6 @@
#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_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/third_party/material_components_ios/src/components/Snackbar/src/MaterialSnackbar.h"
......@@ -434,8 +433,7 @@ void WaitForStaticHtmlViewNotContainingText(NSString* text) {
void AssertIsShowingDistillablePageNoNativeContent(
bool online,
const GURL& distillable_url) {
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey waitForWebStateContainingText:kContentToKeep]);
[ChromeEarlGrey waitForWebStateContainingText:kContentToKeep];
[[EarlGrey selectElementWithMatcher:chrome_test_util::OmniboxText(
distillable_url.GetContent())]
......@@ -443,15 +441,11 @@ void AssertIsShowingDistillablePageNoNativeContent(
// Test that the offline and online pages are properly displayed.
if (online) {
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey waitForWebStateContainingText:kContentToRemove]);
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey waitForWebStateContainingText:kContentToKeep]);
[ChromeEarlGrey waitForWebStateContainingText:kContentToRemove];
[ChromeEarlGrey waitForWebStateContainingText:kContentToKeep];
} else {
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey waitForWebStateNotContainingText:kContentToRemove]);
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey waitForWebStateContainingText:kContentToKeep]);
[ChromeEarlGrey waitForWebStateNotContainingText:kContentToRemove];
[ChromeEarlGrey waitForWebStateContainingText:kContentToKeep];
}
// Test the presence of the omnibox offline chip.
......@@ -489,12 +483,11 @@ void AssertIsShowingDistillablePageNativeContent(bool online,
// Test that the offline and online pages are properly displayed.
if (online) {
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey
waitForWebStateContainingText:base::SysNSStringToUTF8(contentToKeep)]);
[ChromeEarlGrey
waitForWebStateContainingText:base::SysNSStringToUTF8(contentToKeep)];
WaitForStaticHtmlViewNotContainingText(contentToKeep);
} else {
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey waitForWebStateNotContainingText:kContentToKeep]);
[ChromeEarlGrey waitForWebStateNotContainingText:kContentToKeep];
WaitForStaticHtmlViewContainingText(contentToKeep);
}
......@@ -572,13 +565,13 @@ void AssertIsShowingDistillablePage(bool online, const GURL& distillable_url) {
GURL nonDistillablePageURL(self.testServer->GetURL(kNonDistillableURL));
std::string pageTitle(kDistillableTitle);
// Open http://potato
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey loadURL:distillablePageURL]);
[ChromeEarlGrey loadURL:distillablePageURL];
AddCurrentPageToReadingList();
// Navigate to http://beans
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey loadURL:nonDistillablePageURL]);
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey waitForPageToFinishLoading]);
[ChromeEarlGrey loadURL:nonDistillablePageURL];
[ChromeEarlGrey waitForPageToFinishLoading];
// Verify that an entry with the correct title is present in the reading list.
OpenReadingList();
......@@ -616,14 +609,13 @@ void AssertIsShowingDistillablePage(bool online, const GURL& distillable_url) {
std::string pageTitle(kDistillableTitle);
GURL distillableURL = self.testServer->GetURL(kDistillableURL);
// Open http://potato
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey loadURL:distillableURL]);
[ChromeEarlGrey loadURL:distillableURL];
AddCurrentPageToReadingList();
// Navigate to http://beans
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey loadURL:self.testServer->GetURL(kNonDistillableURL)]);
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey waitForPageToFinishLoading]);
[ChromeEarlGrey loadURL:self.testServer->GetURL(kNonDistillableURL)];
[ChromeEarlGrey waitForPageToFinishLoading];
// Verify that an entry with the correct title is present in the reading list.
OpenReadingList();
......@@ -654,15 +646,14 @@ void AssertIsShowingDistillablePage(bool online, const GURL& distillable_url) {
std::string pageTitle(kDistillableTitle);
GURL distillableURL = self.testServer->GetURL(kDistillableURL);
// Open http://potato
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey loadURL:distillableURL]);
[ChromeEarlGrey loadURL:distillableURL];
AddCurrentPageToReadingList();
// Navigate to http://beans
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey loadURL:self.testServer->GetURL(kNonDistillableURL)]);
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey waitForPageToFinishLoading]);
[ChromeEarlGrey loadURL:self.testServer->GetURL(kNonDistillableURL)];
[ChromeEarlGrey waitForPageToFinishLoading];
// Verify that an entry with the correct title is present in the reading list.
OpenReadingList();
......@@ -684,8 +675,8 @@ void AssertIsShowingDistillablePage(bool online, const GURL& distillable_url) {
// TODO(crbug.com/954248) This DCHECK's (but works) with slimnav disabled.
if (base::FeatureList::IsEnabled(web::features::kSlimNavigationManager)) {
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey goBack]);
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey goForward]);
[ChromeEarlGrey goBack];
[ChromeEarlGrey goForward];
AssertIsShowingDistillablePage(false, distillableURL);
}
......@@ -709,14 +700,13 @@ void AssertIsShowingDistillablePage(bool online, const GURL& distillable_url) {
std::string pageTitle(kDistillableTitle);
GURL distillableURL = self.testServer->GetURL(kDistillableURL);
// Open http://potato
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey loadURL:distillableURL]);
[ChromeEarlGrey loadURL:distillableURL];
AddCurrentPageToReadingList();
// Navigate to http://beans
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey loadURL:self.testServer->GetURL(kNonDistillableURL)]);
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey waitForPageToFinishLoading]);
[ChromeEarlGrey loadURL:self.testServer->GetURL(kNonDistillableURL)];
[ChromeEarlGrey waitForPageToFinishLoading];
// Verify that an entry with the correct title is present in the reading
OpenReadingList();
......@@ -729,8 +719,8 @@ void AssertIsShowingDistillablePage(bool online, const GURL& distillable_url) {
AssertIsShowingDistillablePage(false, distillableURL);
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey goBack]);
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey goForward]);
[ChromeEarlGrey goBack];
[ChromeEarlGrey goForward];
AssertIsShowingDistillablePage(false, distillableURL);
// Reload should load online page.
......
......@@ -23,7 +23,6 @@
#import "ios/chrome/test/app/chrome_test_util.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h"
#import "ios/chrome/test/earl_grey/chrome_error_util.h"
#import "ios/chrome/test/earl_grey/chrome_matchers.h"
#import "ios/chrome/test/earl_grey/chrome_test_case.h"
#import "ios/public/provider/chrome/browser/signin/fake_chrome_identity_service.h"
......@@ -55,10 +54,10 @@ void OpenRecentTabsPanel() {
// At least one tab is needed to be able to open the recent tabs panel.
if ([ChromeEarlGrey isIncognitoMode]) {
if ([ChromeEarlGrey incognitoTabCount] == 0)
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey openNewIncognitoTab]);
[ChromeEarlGrey openNewIncognitoTab];
} else {
if ([ChromeEarlGrey mainTabCount] == 0)
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey openNewTab]);
[ChromeEarlGrey openNewTab];
}
[ChromeEarlGreyUI openToolsMenu];
......@@ -108,9 +107,8 @@ id<GREYMatcher> TitleOfTestPage() {
const GURL testPageURL = web::test::HttpServer::MakeUrl(kURLOfTestPage);
// Open the test page in a new tab.
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey loadURL:testPageURL]);
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey waitForWebStateContainingText:"hello"]);
[ChromeEarlGrey loadURL:testPageURL];
[ChromeEarlGrey waitForWebStateContainingText:"hello"];
// Open the Recent Tabs panel, check that the test page is not
// present.
......@@ -142,12 +140,11 @@ id<GREYMatcher> TitleOfTestPage() {
const GURL testPageURL = web::test::HttpServer::MakeUrl(kURLOfTestPage);
// Open the test page in a new tab.
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey loadURL:testPageURL]);
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey waitForWebStateContainingText:"hello"]);
[ChromeEarlGrey loadURL:testPageURL];
[ChromeEarlGrey waitForWebStateContainingText:"hello"];
// Open a new incognito tab, then close the non-OTR tab.
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey openNewIncognitoTab]);
[ChromeEarlGrey openNewIncognitoTab];
CloseAllNormalTabs();
// Open the Recent Tabs panel and check that the test page is present.
......@@ -161,7 +158,7 @@ id<GREYMatcher> TitleOfTestPage() {
@"Unexpected tabs in the main WebStateList");
[[EarlGrey selectElementWithMatcher:TitleOfTestPage()]
performAction:grey_tap()];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey waitForMainTabCount:1]);
[ChromeEarlGrey waitForMainTabCount:1];
GREYAssertTrue([ChromeEarlGrey incognitoTabCount] == 1,
@"Unexpected tab added to the incognito WebStateList");
}
......
......@@ -16,7 +16,6 @@
#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"
#include "ios/chrome/test/scoped_block_popups_pref.h"
......@@ -130,13 +129,13 @@ class ScopedBlockPopupsException {
ScopedBlockPopupsPref prefSetter(CONTENT_SETTING_ALLOW,
GetOriginalBrowserState());
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey loadURL:blockPopupsURL]);
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey waitForMainTabCount:1]);
[ChromeEarlGrey loadURL:blockPopupsURL];
[ChromeEarlGrey waitForMainTabCount:1];
// Request popup (execute script without using a user gesture) and make sure
// the popup opened in a new tab.
[ChromeEarlGrey executeJavaScript:kOpenPopupScript];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey waitForMainTabCount:2]);
[ChromeEarlGrey waitForMainTabCount:2];
// No infobar should be displayed.
[[EarlGrey selectElementWithMatcher:chrome_test_util::
......@@ -160,8 +159,8 @@ class ScopedBlockPopupsException {
ScopedBlockPopupsPref prefSetter(CONTENT_SETTING_BLOCK,
GetOriginalBrowserState());
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey loadURL:blockPopupsURL]);
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey waitForMainTabCount:1]);
[ChromeEarlGrey loadURL:blockPopupsURL];
[ChromeEarlGrey waitForMainTabCount:1];
// Request popup (execute script without using a user gesture), then make sure
// it was blocked and an infobar was displayed. The window.open() call is run
......@@ -180,7 +179,7 @@ class ScopedBlockPopupsException {
error:&error];
return error == nil;
}] waitWithTimeout:4.0];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey waitForMainTabCount:1]);
[ChromeEarlGrey waitForMainTabCount:1];
}
// Tests that the "exceptions" section on the settings page is hidden and
......
......@@ -31,7 +31,6 @@
#include "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_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/http_server/http_server.h"
......@@ -454,24 +453,18 @@ id<GREYMatcher> BandwidthSettingsButton() {
web::test::SetUpSimpleHttpServerWithSetCookies(response);
// Load |kUrl| and check that cookie is not set.
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kUrl)]);
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey waitForWebStateContainingText:kResponse]);
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kUrl)];
[ChromeEarlGrey waitForWebStateContainingText:kResponse];
NSDictionary* cookies = [ChromeEarlGrey cookies];
GREYAssertEqual(0U, cookies.count, @"No cookie should be found.");
// Visit |kUrlWithSetCookie| to set a cookie and then load |kUrl| to check it
// is still set.
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey
loadURL:web::test::HttpServer::MakeUrl(kUrlWithSetCookie)]);
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey waitForWebStateContainingText:kResponseWithSetCookie]);
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kUrl)]);
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey waitForWebStateContainingText:kResponse]);
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kUrlWithSetCookie)];
[ChromeEarlGrey waitForWebStateContainingText:kResponseWithSetCookie];
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kUrl)];
[ChromeEarlGrey waitForWebStateContainingText:kResponse];
cookies = [ChromeEarlGrey cookies];
GREYAssertEqualObjects(kCookieValue, cookies[kCookieName],
......@@ -489,10 +482,8 @@ id<GREYMatcher> BandwidthSettingsButton() {
[self clearCookiesAndSiteData];
// Reload and test that there are no cookies left.
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kUrl)]);
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey waitForWebStateContainingText:kResponse]);
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kUrl)];
[ChromeEarlGrey waitForWebStateContainingText:kResponse];
cookies = [ChromeEarlGrey cookies];
GREYAssertEqual(0U, cookies.count, @"No cookie should be found.");
......@@ -539,7 +530,7 @@ id<GREYMatcher> BandwidthSettingsButton() {
// Verifies that Settings opens when signed-out and in Incognito mode.
// This tests that crbug.com/607335 has not regressed.
- (void)testSettingsSignedOutIncognito {
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey openNewIncognitoTab]);
[ChromeEarlGrey openNewIncognitoTab];
[ChromeEarlGreyUI openSettingsMenu];
[[EarlGrey selectElementWithMatcher:SettingsCollectionView()]
assertWithMatcher:grey_notNil()];
......
......@@ -9,7 +9,6 @@
#import "ios/chrome/browser/ui/tab_grid/tab_grid_egtest_util.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h"
#import "ios/chrome/test/earl_grey/chrome_error_util.h"
#import "ios/chrome/test/earl_grey/chrome_matchers.h"
#import "ios/chrome/test/earl_grey/chrome_test_case.h"
#import "ios/web/public/test/http_server/http_server.h"
......@@ -143,17 +142,14 @@ char kResponse3[] = "Test Page 3 content";
}
- (void)loadTestURLs {
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey loadURL:_URL1]);
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey waitForWebStateContainingText:kResponse1]);
[ChromeEarlGrey loadURL:_URL1];
[ChromeEarlGrey waitForWebStateContainingText:kResponse1];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey loadURL:_URL2]);
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey waitForWebStateContainingText:kResponse2]);
[ChromeEarlGrey loadURL:_URL2];
[ChromeEarlGrey waitForWebStateContainingText:kResponse2];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey loadURL:_URL3]);
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey waitForWebStateContainingText:kResponse3]);
[ChromeEarlGrey loadURL:_URL3];
[ChromeEarlGrey waitForWebStateContainingText:kResponse3];
}
// Test that Clear Browsing Data can be successfully done from tab grid.
......
......@@ -17,7 +17,6 @@
#import "ios/chrome/test/app/chrome_test_util.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h"
#import "ios/chrome/test/earl_grey/chrome_error_util.h"
#import "ios/chrome/test/earl_grey/chrome_matchers.h"
#import "ios/chrome/test/earl_grey/chrome_test_case.h"
#include "net/test/embedded_test_server/http_request.h"
......@@ -194,16 +193,15 @@ std::unique_ptr<net::test_server::HttpResponse> HandleQueryTitle(
[self setUpTestServer];
// Load a test URL in the current tab.
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey loadURL:[self makeURLForTitle:tab1_title]]);
[ChromeEarlGrey loadURL:[self makeURLForTitle:tab1_title]];
// Enter and leave the switcher.
ShowTabSwitcher();
ShowTabViewController();
// Verify that the original tab is visible again.
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey
waitForWebStateContainingText:base::SysNSStringToUTF8(tab1_title)]);
[ChromeEarlGrey
waitForWebStateContainingText:base::SysNSStringToUTF8(tab1_title)];
}
// Tests exiting the switcher by tapping the new tab button or selecting new tab
......@@ -218,10 +216,9 @@ std::unique_ptr<net::test_server::HttpResponse> HandleQueryTitle(
[[EarlGrey selectElementWithMatcher:matcher] performAction:grey_tap()];
// Load a URL in this newly-created tab and verify that the tab is visible.
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey loadURL:[self makeURLForTitle:tab1_title]]);
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey
waitForWebStateContainingText:base::SysNSStringToUTF8(tab1_title)]);
[ChromeEarlGrey loadURL:[self makeURLForTitle:tab1_title]];
[ChromeEarlGrey
waitForWebStateContainingText:base::SysNSStringToUTF8(tab1_title)];
}
// Tests exiting the switcher by tapping the new incognito tab button or
......@@ -240,10 +237,9 @@ std::unique_ptr<net::test_server::HttpResponse> HandleQueryTitle(
[[EarlGrey selectElementWithMatcher:matcher] performAction:grey_tap()];
// Load a URL in this newly-created tab and verify that the tab is visible.
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey loadURL:[self makeURLForTitle:tab1_title]]);
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey
waitForWebStateContainingText:base::SysNSStringToUTF8(tab1_title)]);
[ChromeEarlGrey loadURL:[self makeURLForTitle:tab1_title]];
[ChromeEarlGrey
waitForWebStateContainingText:base::SysNSStringToUTF8(tab1_title)];
}
// Tests exiting the switcher by opening a new tab in the other tab model.
......@@ -260,10 +256,9 @@ std::unique_ptr<net::test_server::HttpResponse> HandleQueryTitle(
performAction:grey_tap()];
// Load a URL in this newly-created tab and verify that the tab is visible.
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey loadURL:[self makeURLForTitle:incognito_title]]);
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey
waitForWebStateContainingText:base::SysNSStringToUTF8(incognito_title)]);
[ChromeEarlGrey loadURL:[self makeURLForTitle:incognito_title]];
[ChromeEarlGrey
waitForWebStateContainingText:base::SysNSStringToUTF8(incognito_title)];
// Go from incognito mode to normal mode.
ShowTabSwitcher();
......@@ -273,10 +268,9 @@ std::unique_ptr<net::test_server::HttpResponse> HandleQueryTitle(
performAction:grey_tap()];
// Load a URL in this newly-created tab and verify that the tab is visible.
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey loadURL:[self makeURLForTitle:normal_title]]);
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey
waitForWebStateContainingText:base::SysNSStringToUTF8(normal_title)]);
[ChromeEarlGrey loadURL:[self makeURLForTitle:normal_title]];
[ChromeEarlGrey
waitForWebStateContainingText:base::SysNSStringToUTF8(normal_title)];
}
// Tests exiting the tab switcher by selecting a normal tab.
......@@ -287,24 +281,21 @@ std::unique_ptr<net::test_server::HttpResponse> HandleQueryTitle(
[self setUpTestServer];
// Create a few tabs and give them all unique titles.
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey loadURL:[self makeURLForTitle:tab1_title]]);
[ChromeEarlGrey loadURL:[self makeURLForTitle:tab1_title]];
[ChromeEarlGreyUI openNewTab];
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey loadURL:[self makeURLForTitle:tab2_title]]);
[ChromeEarlGrey loadURL:[self makeURLForTitle:tab2_title]];
[ChromeEarlGreyUI openNewTab];
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey loadURL:[self makeURLForTitle:tab3_title]]);
[ChromeEarlGrey loadURL:[self makeURLForTitle:tab3_title]];
ShowTabSwitcher();
SelectTab(tab1_title);
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey
waitForWebStateContainingText:base::SysNSStringToUTF8(tab1_title)]);
[ChromeEarlGrey
waitForWebStateContainingText:base::SysNSStringToUTF8(tab1_title)];
ShowTabSwitcher();
SelectTab(tab3_title);
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey
waitForWebStateContainingText:base::SysNSStringToUTF8(tab3_title)]);
[ChromeEarlGrey
waitForWebStateContainingText:base::SysNSStringToUTF8(tab3_title)];
}
// Tests exiting the tab switcher by selecting an incognito tab.
......@@ -316,25 +307,22 @@ std::unique_ptr<net::test_server::HttpResponse> HandleQueryTitle(
// Create a few tabs and give them all unique titles.
[ChromeEarlGreyUI openNewIncognitoTab];
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey loadURL:[self makeURLForTitle:tab1_title]]);
[ChromeEarlGrey loadURL:[self makeURLForTitle:tab1_title]];
[ChromeEarlGreyUI openNewIncognitoTab];
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey loadURL:[self makeURLForTitle:tab2_title]]);
[ChromeEarlGrey loadURL:[self makeURLForTitle:tab2_title]];
[ChromeEarlGreyUI openNewIncognitoTab];
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey loadURL:[self makeURLForTitle:tab3_title]]);
[ChromeEarlGrey loadURL:[self makeURLForTitle:tab3_title]];
[GetNormalTabModel() closeAllTabs];
ShowTabSwitcher();
SelectTab(tab1_title);
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey
waitForWebStateContainingText:base::SysNSStringToUTF8(tab1_title)]);
[ChromeEarlGrey
waitForWebStateContainingText:base::SysNSStringToUTF8(tab1_title)];
ShowTabSwitcher();
SelectTab(tab3_title);
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey
waitForWebStateContainingText:base::SysNSStringToUTF8(tab3_title)]);
[ChromeEarlGrey
waitForWebStateContainingText:base::SysNSStringToUTF8(tab3_title)];
}
// Tests exiting the tab switcher by selecting a tab in the other tab model.
......@@ -344,19 +332,17 @@ std::unique_ptr<net::test_server::HttpResponse> HandleQueryTitle(
[self setUpTestServer];
// Create a few tabs and give them all unique titles.
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey loadURL:[self makeURLForTitle:normal_title]]);
[ChromeEarlGrey loadURL:[self makeURLForTitle:normal_title]];
[ChromeEarlGreyUI openNewIncognitoTab];
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey loadURL:[self makeURLForTitle:incognito_title]]);
[ChromeEarlGrey loadURL:[self makeURLForTitle:incognito_title]];
ShowTabSwitcher();
// Switch to the normal panel and select the one tab that is there.
[[EarlGrey selectElementWithMatcher:TabGridOpenTabsPanelButton()]
performAction:grey_tap()];
SelectTab(normal_title);
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey
waitForWebStateContainingText:base::SysNSStringToUTF8(normal_title)]);
[ChromeEarlGrey
waitForWebStateContainingText:base::SysNSStringToUTF8(normal_title)];
ShowTabSwitcher();
// Switch to the incognito panel and select the one tab that is there.
......@@ -364,8 +350,8 @@ std::unique_ptr<net::test_server::HttpResponse> HandleQueryTitle(
performAction:grey_tap()];
SelectTab(incognito_title);
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey
waitForWebStateContainingText:base::SysNSStringToUTF8(incognito_title)]);
[ChromeEarlGrey
waitForWebStateContainingText:base::SysNSStringToUTF8(incognito_title)];
}
// Tests switching back and forth between the normal and incognito BVCs.
......@@ -390,32 +376,31 @@ std::unique_ptr<net::test_server::HttpResponse> HandleQueryTitle(
- (void)testRotationsWhileSwitcherIsNotActive {
NSString* tab_title = @"NormalTabLongerStringForRotationTest";
[self setUpTestServer];
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey loadURL:[self makeURLForTitle:tab_title]]);
[ChromeEarlGrey loadURL:[self makeURLForTitle:tab_title]];
// Show the tab switcher and return to the BVC, in portrait.
[EarlGrey rotateDeviceToOrientation:UIDeviceOrientationPortrait
errorOrNil:nil];
ShowTabSwitcher();
SelectTab(tab_title);
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey
waitForWebStateContainingText:base::SysNSStringToUTF8(tab_title)]);
[ChromeEarlGrey
waitForWebStateContainingText:base::SysNSStringToUTF8(tab_title)];
// Show the tab switcher and return to the BVC, in landscape.
[EarlGrey rotateDeviceToOrientation:UIDeviceOrientationLandscapeLeft
errorOrNil:nil];
ShowTabSwitcher();
SelectTab(tab_title);
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey
waitForWebStateContainingText:base::SysNSStringToUTF8(tab_title)]);
[ChromeEarlGrey
waitForWebStateContainingText:base::SysNSStringToUTF8(tab_title)];
// Show the tab switcher and return to the BVC, in portrait.
[EarlGrey rotateDeviceToOrientation:UIDeviceOrientationPortrait
errorOrNil:nil];
ShowTabSwitcher();
SelectTab(tab_title);
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey
waitForWebStateContainingText:base::SysNSStringToUTF8(tab_title)]);
[ChromeEarlGrey
waitForWebStateContainingText:base::SysNSStringToUTF8(tab_title)];
}
@end
......@@ -13,7 +13,6 @@
#import "ios/chrome/test/app/tab_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"
#include "ui/base/l10n/l10n_util.h"
......@@ -45,9 +44,9 @@ id<GREYMatcher> TabTitleMatcher(web::WebState* web_state) {
// case.
const int kNumberOfTabs = 3;
[ChromeEarlGreyUI openNewTab];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey loadURL:GURL("chrome://about")]);
[ChromeEarlGrey loadURL:GURL("chrome://about")];
[ChromeEarlGreyUI openNewTab];
CHROME_EG_ASSERT_NO_ERROR([ChromeEarlGrey loadURL:GURL("chrome://version")]);
[ChromeEarlGrey loadURL:GURL("chrome://version")];
// Note that the tab ordering wraps. E.g. if A, B, and C are open,
// and C is the current tab, the 'next' tab is 'A'.
......
......@@ -6,7 +6,6 @@
#import <XCTest/XCTest.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_test_case.h"
#include "url/gurl.h"
......@@ -22,10 +21,8 @@
// Verifies Internet connectivity by navigating to browsingtest.appspot.com.
- (void)testNetworkConnection {
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey loadURL:GURL("http://browsingtest.appspot.com")]);
CHROME_EG_ASSERT_NO_ERROR(
[ChromeEarlGrey waitForWebStateContainingText:"Window1"]);
[ChromeEarlGrey loadURL:GURL("http://browsingtest.appspot.com")];
[ChromeEarlGrey waitForWebStateContainingText:"Window1"];
}
@end
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