Commit 2c349508 authored by Ed Chin's avatar Ed Chin Committed by Commit Bot

Revert "[Payment Request] Adds tests for accessibility on main pages of Payment Request - Reland"

This reverts commit 535fbc0b.

Reason for revert: Failed tests on internal.bling.main bot. Configuration updates look like they are needed in this bot as well.

https://uberchromegw.corp.google.com/i/internal.bling.main/waterfall?builder=iphone10-simulator

Original change's description:
> [Payment Request] Adds tests for accessibility on main pages of Payment Request - Reland
> 
> Two build bot json files have been edited so that they run with the appropriate 
> command line flags. Given that these build bot changes are related to adding to this
> test this is all being packaged as one CL.
> 
> From original CL description:
> "The added HTML file and JS file have been downloaded from here:
> 
> https://rsolomakhin.github.io/pr/multi/
> 
> And thus do not need to be thoroughly reviewed. The only changes made to these
> files are as follows
> 1) In the html file an "id" attribute is added to the "buy" button, the 2016
> copyright is changed to 2017, and the stylesheet and favicon links are removed.
> 2) In the js file "requestPayerEmail," "requestPayerPhone," and "requestPayerName"
> is added to options on line 106, the JSLint directives are removed from the top of
> the file, and the long line on line 137 was changed into two lines."
> 
> TBR=@lpromero@google.com -- Reviewed already in last past. Only addition here is the
> build bot changes.
> 
> Change-Id: Ia20efa783eb763ae97f7e0df2f80e710823d7482
> Reviewed-on: https://chromium-review.googlesource.com/570879
> Commit-Queue: Randall Raymond <rayraymond@google.com>
> Reviewed-by: Eugene But <eugenebut@chromium.org>
> Reviewed-by: mahmadi <mahmadi@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#487162}

TBR=eugenebut@chromium.org,lpromero@chromium.org,michaeldo@chromium.org,rayraymond@google.com,mahmadi@chromium.org

Change-Id: Ib69b8365f7e45f8f7df9113fa2980052bf0cc361
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/574675Reviewed-by: default avatarEd Chin <edchin@chromium.org>
Commit-Queue: Ed Chin <edchin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#487232}
parent 3e964c0d
...@@ -47,9 +47,6 @@ ...@@ -47,9 +47,6 @@
}, },
{ {
"app": "ios_chrome_ui_egtests", "app": "ios_chrome_ui_egtests",
"test args": [
"--enable-features=WebPayments"
],
"device type": "iPhone 6s", "device type": "iPhone 6s",
"os": "10.0", "os": "10.0",
"xcode version": "8.0", "xcode version": "8.0",
...@@ -109,9 +106,6 @@ ...@@ -109,9 +106,6 @@
}, },
{ {
"app": "ios_chrome_ui_egtests", "app": "ios_chrome_ui_egtests",
"test args": [
"--enable-features=WebPayments"
],
"device type": "iPad Air 2", "device type": "iPad Air 2",
"os": "10.0", "os": "10.0",
"xcode version": "8.0", "xcode version": "8.0",
......
...@@ -47,9 +47,6 @@ ...@@ -47,9 +47,6 @@
}, },
{ {
"app": "ios_chrome_ui_egtests", "app": "ios_chrome_ui_egtests",
"test args": [
"--enable-features=WebPayments"
],
"device type": "iPhone 6s", "device type": "iPhone 6s",
"os": "10.0", "os": "10.0",
"xcode version": "8.0", "xcode version": "8.0",
...@@ -109,9 +106,6 @@ ...@@ -109,9 +106,6 @@
}, },
{ {
"app": "ios_chrome_ui_egtests", "app": "ios_chrome_ui_egtests",
"test args": [
"--enable-features=WebPayments"
],
"device type": "iPad Air 2", "device type": "iPad Air 2",
"os": "10.0", "os": "10.0",
"xcode version": "8.0", "xcode version": "8.0",
......
...@@ -214,34 +214,3 @@ source_set("unit_tests") { ...@@ -214,34 +214,3 @@ source_set("unit_tests") {
"//ui/base", "//ui/base",
] ]
} }
source_set("eg_tests") {
configs += [ "//build/config/compiler:enable_arc" ]
testonly = true
sources = [
"payments_accessibility_egtest.mm",
]
deps = [
":payments_ui",
"//base",
"//components/autofill/core/browser",
"//components/autofill/core/browser:test_support",
"//components/payments/core",
"//components/strings",
"//ios/chrome/app:app_internal",
"//ios/chrome/browser/autofill",
"//ios/chrome/browser/payments",
"//ios/chrome/browser/ui/payments/cells",
"//ios/chrome/browser/ui/tools_menu",
"//ios/chrome/test/app:test_support",
"//ios/chrome/test/earl_grey:test_support",
"//ios/testing/earl_grey:earl_grey_support",
"//ios/third_party/material_components_ios",
"//ios/web/public/test/http_server",
]
libs = [
"UIKit.framework",
"XCTest.framework",
]
}
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import <XCTest/XCTest.h>
#include "base/strings/sys_string_conversions.h"
#include "components/autofill/core/browser/autofill_profile.h"
#include "components/autofill/core/browser/autofill_test_utils.h"
#include "components/autofill/core/browser/personal_data_manager.h"
#include "components/strings/grit/components_strings.h"
#include "ios/chrome/browser/autofill/personal_data_manager_factory.h"
#include "ios/chrome/browser/payments/payment_request_util.h"
#import "ios/chrome/browser/ui/payments/cells/payments_text_item.h"
#import "ios/chrome/browser/ui/payments/cells/price_item.h"
#import "ios/chrome/browser/ui/payments/payment_request_view_controller.h"
#import "ios/chrome/test/app/chrome_test_util.h"
#import "ios/chrome/test/app/web_view_interaction_test_util.h"
#import "ios/chrome/test/earl_grey/accessibility_util.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey.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"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
namespace {
using chrome_test_util::ButtonWithAccessibilityLabel;
using chrome_test_util::ButtonWithAccessibilityLabelId;
using payment_request_util::GetAddressNotificationLabelFromAutofillProfile;
using payment_request_util::GetEmailLabelFromAutofillProfile;
using payment_request_util::GetNameLabelFromAutofillProfile;
using payment_request_util::GetPhoneNumberLabelFromAutofillProfile;
using payment_request_util::GetShippingAddressLabelFromAutofillProfile;
// Displacement for scroll action.
const CGFloat kScrollDisplacement = 100.0;
// URL of the Payment Request test page.
const char kPaymentRequestDemoPage[] =
"http://ios/testing/data/http_server_files/payment_request.html";
// Finds the shipping address cell on the Payment Summary page.
id<GREYMatcher> ShippingAddressCellMatcher(autofill::AutofillProfile* profile) {
NSString* email_label = nil;
NSString* notification_label = nil;
return chrome_test_util::ButtonWithAccessibilityLabel([NSString
stringWithFormat:@"%@, %@, %@, %@, %@",
GetNameLabelFromAutofillProfile(*profile),
GetShippingAddressLabelFromAutofillProfile(*profile),
GetPhoneNumberLabelFromAutofillProfile(*profile),
email_label, notification_label]);
}
// Finds the payment method cell on the Payment Summary page.
id<GREYMatcher> PaymentMethodCellMatcher(autofill::CreditCard* credit_card) {
NSString* billing_address_label = nil;
NSString* notification_label = nil;
return chrome_test_util::ButtonWithAccessibilityLabel([NSString
stringWithFormat:@"%@, %@, %@, %@",
base::SysUTF16ToNSString(
credit_card->NetworkAndLastFourDigits()),
base::SysUTF16ToNSString(credit_card->GetRawInfo(
autofill::CREDIT_CARD_NAME_FULL)),
billing_address_label, notification_label]);
}
// Finds the order summary cell on the Payment Summary page.
id<GREYMatcher> PriceCellMatcher(NSString* main_label, NSString* price_label) {
NSString* notification_label = nil;
return chrome_test_util::ButtonWithAccessibilityLabel(
[NSString stringWithFormat:@"%@, %@, %@", main_label, notification_label,
price_label]);
}
// Finds the shipping option cell on the Payment Summary page.
id<GREYMatcher> ShippingOptionCellMatcher(NSString* main_label,
NSString* detail_label) {
return chrome_test_util::ButtonWithAccessibilityLabel(
[NSString stringWithFormat:@"%@, %@", main_label, detail_label]);
}
// Finds the contact info cell on the Payment Summary page.
id<GREYMatcher> ContactInfoCellMatcher(autofill::AutofillProfile* profile) {
NSString* address_label = nil;
NSString* notification_label = nil;
return chrome_test_util::ButtonWithAccessibilityLabel([NSString
stringWithFormat:@"%@, %@, %@, %@, %@",
GetNameLabelFromAutofillProfile(*profile), address_label,
GetPhoneNumberLabelFromAutofillProfile(*profile),
GetEmailLabelFromAutofillProfile(*profile),
notification_label]);
}
} // namespace
// Various tests for Payment Request.
@interface PaymentRequestTestCase : ChromeTestCase
@end
@implementation PaymentRequestTestCase {
autofill::AutofillProfile _profile;
autofill::CreditCard _creditCard1;
autofill::CreditCard _creditCard2;
GURL _testURL;
}
#pragma mark - XCTest.
// Set up called once before each test.
- (void)setUp {
[super setUp];
autofill::PersonalDataManager* personalDataManager =
autofill::PersonalDataManagerFactory::GetForBrowserState(
chrome_test_util::GetOriginalBrowserState());
_profile = autofill::test::GetFullProfile();
_creditCard1 = autofill::test::GetCreditCard();
_creditCard2 = autofill::test::GetCreditCard2();
personalDataManager->AddProfile(_profile);
_creditCard1.set_billing_address_id(_profile.guid());
personalDataManager->AddCreditCard(_creditCard1);
personalDataManager->AddCreditCard(_creditCard2);
_testURL = web::test::HttpServer::MakeUrl(kPaymentRequestDemoPage);
}
#pragma mark - Tests.
// Tests accessibility on the Payment Request summary page.
- (void)testAccessibilityOnPaymentRequestSummaryPage {
[ChromeEarlGrey loadURL:_testURL];
// Tap the buy button.
chrome_test_util::TapWebViewElementWithId("buy");
chrome_test_util::VerifyAccessibilityForCurrentScreen();
}
// Tests accessibility on the Payment Request order summary page.
- (void)testAccessibilityOnPaymentRequestOrderSummaryPage {
[ChromeEarlGrey loadURL:_testURL];
// Tap the buy button.
chrome_test_util::TapWebViewElementWithId("buy");
[[EarlGrey
selectElementWithMatcher:PriceCellMatcher(@"Donation", @"USD $55.00")]
performAction:grey_tap()];
chrome_test_util::VerifyAccessibilityForCurrentScreen();
}
// Tests accessibility on the Payment Request delivery address page.
- (void)testAccessibilityOnPaymentRequestDeliveryAddressPage {
[ChromeEarlGrey loadURL:_testURL];
// Tap the buy button.
chrome_test_util::TapWebViewElementWithId("buy");
[[EarlGrey selectElementWithMatcher:ShippingAddressCellMatcher(&_profile)]
performAction:grey_tap()];
chrome_test_util::VerifyAccessibilityForCurrentScreen();
}
// Tests accessibility on the Payment Request delivery method page.
- (void)testAccessibilityOnPaymentRequestDeliveryMethodPage {
[ChromeEarlGrey loadURL:_testURL];
// Tap the buy button.
chrome_test_util::TapWebViewElementWithId("buy");
[[EarlGrey selectElementWithMatcher:ShippingOptionCellMatcher(
@"Standard shipping", @"$0.00")]
performAction:grey_tap()];
chrome_test_util::VerifyAccessibilityForCurrentScreen();
}
// Tests accessibility on the Payment Request payment method page.
- (void)testAccessibilityOnPaymentRequestPaymentMethodPage {
[ChromeEarlGrey loadURL:_testURL];
// Tap the buy button.
chrome_test_util::TapWebViewElementWithId("buy");
[[[EarlGrey selectElementWithMatcher:PaymentMethodCellMatcher(&_creditCard1)]
usingSearchAction:grey_scrollInDirection(kGREYDirectionDown,
kScrollDisplacement)
onElementWithMatcher:grey_accessibilityID(
kPaymentRequestCollectionViewID)]
performAction:grey_tap()];
chrome_test_util::VerifyAccessibilityForCurrentScreen();
}
// Tests accessibility on the Payment Request contact info page.
- (void)testAccessibilityOnPaymentRequestContactInfoPage {
[ChromeEarlGrey loadURL:_testURL];
// Tap the buy button.
chrome_test_util::TapWebViewElementWithId("buy");
[[[EarlGrey selectElementWithMatcher:ContactInfoCellMatcher(&_profile)]
usingSearchAction:grey_scrollInDirection(kGREYDirectionDown,
kScrollDisplacement)
onElementWithMatcher:grey_accessibilityID(
kPaymentRequestCollectionViewID)]
performAction:grey_tap()];
chrome_test_util::VerifyAccessibilityForCurrentScreen();
}
@end
...@@ -60,7 +60,6 @@ chrome_ios_eg_test("ios_chrome_ui_egtests") { ...@@ -60,7 +60,6 @@ chrome_ios_eg_test("ios_chrome_ui_egtests") {
"//ios/chrome/browser/ui/infobars:eg_tests", "//ios/chrome/browser/ui/infobars:eg_tests",
"//ios/chrome/browser/ui/ntp:eg_tests", "//ios/chrome/browser/ui/ntp:eg_tests",
"//ios/chrome/browser/ui/ntp/recent_tabs:eg_tests", "//ios/chrome/browser/ui/ntp/recent_tabs:eg_tests",
"//ios/chrome/browser/ui/payments:eg_tests",
"//ios/chrome/browser/ui/print:eg_tests", "//ios/chrome/browser/ui/print:eg_tests",
"//ios/chrome/browser/ui/qr_scanner:eg_tests", "//ios/chrome/browser/ui/qr_scanner:eg_tests",
"//ios/chrome/browser/ui/sad_tab:eg_tests", "//ios/chrome/browser/ui/sad_tab:eg_tests",
......
...@@ -79,8 +79,6 @@ bundle_data("http_server_bundle_data") { ...@@ -79,8 +79,6 @@ bundle_data("http_server_bundle_data") {
"data/http_server_files/history_go.js", "data/http_server_files/history_go.js",
"data/http_server_files/memory_usage.html", "data/http_server_files/memory_usage.html",
"data/http_server_files/multi_field_form.html", "data/http_server_files/multi_field_form.html",
"data/http_server_files/payment_request.html",
"data/http_server_files/payment_request.js",
"data/http_server_files/pony.html", "data/http_server_files/pony.html",
"data/http_server_files/redirect_refresh.html", "data/http_server_files/redirect_refresh.html",
"data/http_server_files/single_page_wide.pdf", "data/http_server_files/single_page_wide.pdf",
......
<!doctype html>
<!-- Copyright 2017 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. -->
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>US-only delivery with e-mail address</title>
</head>
<body>
<div id="contents">
<h1>Worldwide multi-option shipping</h1>
<p>This merchant provides multiple shipping options worldwide, independent of the shipping address. No payment will be processed.</p>
<p>Price: USD <strong>$55.00</strong></p>
<p><button id="buy" onclick="onBuyClicked()">Buy</button></p>
</div>
<pre id="msg"></pre>
<script src="payment_request.js"></script>
</body>
</html>
\ No newline at end of file
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/**
* Updates the price based on the selected shipping option.
* @param {object} details - The current details to update.
* @param {string} shippingOption - The shipping option selected by user.
* @return {object} The updated details.
*/
function updateDetails(details, shippingOption) {
var selectedShippingOption;
var otherShippingOption;
if (shippingOption === 'standard') {
selectedShippingOption = details.shippingOptions[0];
otherShippingOption = details.shippingOptions[1];
details.total.amount.value = '55.00';
} else {
selectedShippingOption = details.shippingOptions[1];
otherShippingOption = details.shippingOptions[0];
details.total.amount.value = '67.00';
}
if (details.displayItems.length === 2) {
details.displayItems.splice(1, 0, selectedShippingOption);
} else {
details.displayItems.splice(1, 1, selectedShippingOption);
}
selectedShippingOption.selected = true;
otherShippingOption.selected = false;
return details;
}
/**
* Launches payment request that provides multiple shipping options worldwide,
* regardless of the shipping address.
*/
function onBuyClicked() { // eslint-disable-line no-unused-vars
var supportedInstruments = [{
supportedMethods: ['https://android.com/pay'],
data: {
merchantName: 'Rouslan Solomakhin',
merchantId: '00184145120947117657',
allowedCardNetworks: ['AMEX', 'MASTERCARD', 'VISA', 'DISCOVER'],
paymentMethodTokenizationParameters: {
tokenizationType: 'GATEWAY_TOKEN',
parameters: {
'gateway': 'stripe',
'stripe:publishableKey': 'pk_live_lNk21zqKM2BENZENh3rzCUgo',
'stripe:version': '2016-07-06'
}
}
}
},
{
supportedMethods: ['basic-card']
}
];
var details = {
total: {
label: 'Donation',
amount: {
currency: 'USD',
value: '55.00'
}
},
displayItems: [{
label: 'Original donation amount',
amount: {
currency: 'USD',
value: '65.00'
}
},
{
label: 'Friends and family discount',
amount: {
currency: 'USD',
value: '-10.00'
}
}
],
shippingOptions: [{
id: 'standard',
label: 'Standard shipping',
amount: {
currency: 'USD',
value: '0.00'
},
selected: true
},
{
id: 'express',
label: 'Express shipping',
amount: {
currency: 'USD',
value: '12.00'
}
}
]
};
var options = {
requestShipping: true,
requestPayerName: true,
requestPayerPhone: true,
requestPayerEmail: true
};
if (!window.PaymentRequest) {
error('PaymentRequest API is not supported.');
return;
}
try {
var request = new PaymentRequest(supportedInstruments, details, options);
request.addEventListener('shippingaddresschange', function(e) {
e.updateWith(new Promise(function(resolve) {
window.setTimeout(function() {
// No changes in price based on shipping address change.
resolve(details);
}, 2000);
}));
});
request.addEventListener('shippingoptionchange', function(e) {
e.updateWith(new Promise(function(resolve) {
resolve(updateDetails(details, request.shippingOption));
}));
});
request.show()
.then(function(instrumentResponse) {
window.setTimeout(function() {
instrumentResponse.complete('success')
.then(function() {
done('This is a demo website. No payment will be processed.',
instrumentResponse);
})
.catch(function(err) {
error(err);
});
}, 2000);
})
.catch(function(err) {
error(err);
});
} catch (e) {
error('Developer mistake: \'' + e.message + '\'');
}
}
\ No newline at end of file
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