Commit 2971910b authored by Eugene But's avatar Eugene But Committed by Commit Bot

Made pass_kit_egtest.mm EG2 compatible.

Replaced code which waits for PassKit UI presentation for EG2. EG1 still
relies on checking for presented UIViewController, while EG2 can use
XCUITest API to test that "Toy Town Membership" element (pkpass title)
is displayed.

Bug: 987646
Change-Id: I7295aa58538100957eb438ea5d5972ec9628a5c9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1727732
Commit-Queue: Eugene But <eugenebut@chromium.org>
Reviewed-by: default avatarStepan Khapugin <stkhapugin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#682778}
parent 106bb72f
...@@ -19,8 +19,6 @@ source_set("download") { ...@@ -19,8 +19,6 @@ source_set("download") {
"download_manager_tab_helper_delegate.h", "download_manager_tab_helper_delegate.h",
"google_drive_app_util.h", "google_drive_app_util.h",
"google_drive_app_util.mm", "google_drive_app_util.mm",
"pass_kit_mime_type.cc",
"pass_kit_mime_type.h",
"pass_kit_tab_helper.h", "pass_kit_tab_helper.h",
"pass_kit_tab_helper.mm", "pass_kit_tab_helper.mm",
"pass_kit_tab_helper_delegate.h", "pass_kit_tab_helper_delegate.h",
...@@ -28,6 +26,10 @@ source_set("download") { ...@@ -28,6 +26,10 @@ source_set("download") {
"usdz_mime_type.h", "usdz_mime_type.h",
] ]
public_deps = [
":pass_kit_mime_type",
]
deps = [ deps = [
":features", ":features",
"//base", "//base",
...@@ -62,6 +64,19 @@ source_set("features") { ...@@ -62,6 +64,19 @@ source_set("features") {
configs += [ "//build/config/compiler:enable_arc" ] configs += [ "//build/config/compiler:enable_arc" ]
} }
source_set("pass_kit_mime_type") {
sources = [
"pass_kit_mime_type.cc",
"pass_kit_mime_type.h",
]
deps = [
"//base",
]
configs += [ "//build/config/compiler:enable_arc" ]
}
source_set("unit_tests") { source_set("unit_tests") {
configs += [ "//build/config/compiler:enable_arc" ] configs += [ "//build/config/compiler:enable_arc" ]
testonly = true testonly = true
......
...@@ -104,6 +104,7 @@ source_set("unit_tests") { ...@@ -104,6 +104,7 @@ source_set("unit_tests") {
} }
source_set("eg_tests") { source_set("eg_tests") {
defines = [ "CHROME_EARL_GREY_1" ]
configs += [ "//build/config/compiler:enable_arc" ] configs += [ "//build/config/compiler:enable_arc" ]
testonly = true testonly = true
sources = [ sources = [
...@@ -128,6 +129,7 @@ source_set("eg_tests") { ...@@ -128,6 +129,7 @@ source_set("eg_tests") {
"//ios/chrome/test/app:test_support", "//ios/chrome/test/app:test_support",
"//ios/chrome/test/earl_grey:test_support", "//ios/chrome/test/earl_grey:test_support",
"//ios/testing:embedded_test_server_support", "//ios/testing:embedded_test_server_support",
"//ios/testing/earl_grey:earl_grey_support",
"//ios/third_party/earl_grey:earl_grey+link", "//ios/third_party/earl_grey:earl_grey+link",
"//ios/web:earl_grey_test_support", "//ios/web:earl_grey_test_support",
"//ios/web/public", "//ios/web/public",
...@@ -145,10 +147,17 @@ source_set("eg2_tests") { ...@@ -145,10 +147,17 @@ source_set("eg2_tests") {
] ]
testonly = true testonly = true
sources = [] sources = [
"pass_kit_egtest.mm",
]
deps = [ deps = [
"//ios/chrome/app/strings:ios_strings_grit",
"//ios/chrome/browser/download:pass_kit_mime_type",
"//ios/chrome/browser/download:test_support",
"//ios/chrome/test/earl_grey:eg_test_support+eg2", "//ios/chrome/test/earl_grey:eg_test_support+eg2",
"//ios/testing/earl_grey:eg_test_support+eg2",
"//ios/third_party/earl_grey2:test_lib",
"//ios/web/public/test:element_selector", "//ios/web/public/test:element_selector",
"//net:test_support", "//net:test_support",
"//ui/base", "//ui/base",
......
...@@ -2,33 +2,36 @@ ...@@ -2,33 +2,36 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#import <EarlGrey/EarlGrey.h>
#import <PassKit/PassKit.h> #import <PassKit/PassKit.h>
#include <memory> #include <memory>
#include "base/bind.h" #include "base/bind.h"
#import "base/test/ios/wait_util.h" #import "base/test/ios/wait_util.h"
#import "ios/chrome/app/main_controller.h"
#include "ios/chrome/browser/download/download_test_util.h" #include "ios/chrome/browser/download/download_test_util.h"
#include "ios/chrome/browser/download/pass_kit_mime_type.h" #include "ios/chrome/browser/download/pass_kit_mime_type.h"
#import "ios/chrome/browser/ui/browser_view/browser_view_controller.h"
#include "ios/chrome/browser/ui/util/ui_util.h"
#include "ios/chrome/grit/ios_strings.h" #include "ios/chrome/grit/ios_strings.h"
#import "ios/chrome/test/app/chrome_test_util.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey.h" #import "ios/chrome/test/earl_grey/chrome_earl_grey.h"
#import "ios/chrome/test/earl_grey/chrome_test_case.h" #import "ios/chrome/test/earl_grey/chrome_test_case.h"
#import "ios/testing/earl_grey/earl_grey_test.h"
#include "net/test/embedded_test_server/http_request.h" #include "net/test/embedded_test_server/http_request.h"
#include "net/test/embedded_test_server/http_response.h" #include "net/test/embedded_test_server/http_response.h"
#include "ui/base/l10n/l10n_util_mac.h" #include "ui/base/l10n/l10n_util_mac.h"
#if defined(CHROME_EARL_GREY_1)
// EG1 test relies on view controller presentation as the signal that PassKit
// Dialog is shown.
#import "ios/chrome/app/main_controller.h" // nogncheck
#import "ios/chrome/browser/ui/browser_view/browser_view_controller.h" // nogncheck
#import "ios/chrome/test/app/chrome_test_util.h" // nogncheck
#endif
#if !defined(__has_feature) || !__has_feature(objc_arc) #if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support." #error "This file requires ARC support."
#endif #endif
using base::test::ios::WaitUntilConditionOrTimeout; using base::test::ios::WaitUntilConditionOrTimeout;
using base::test::ios::kWaitForDownloadTimeout; using base::test::ios::kWaitForDownloadTimeout;
using chrome_test_util::GetMainController;
namespace { namespace {
...@@ -104,10 +107,12 @@ std::unique_ptr<net::test_server::HttpResponse> GetResponse( ...@@ -104,10 +107,12 @@ std::unique_ptr<net::test_server::HttpResponse> GetResponse(
[ChromeEarlGrey tapWebStateElementWithID:@"good"]; [ChromeEarlGrey tapWebStateElementWithID:@"good"];
// PKAddPassesViewController UI is rendered out of host process so EarlGrey // PKAddPassesViewController UI is rendered out of host process so EarlGrey
// matcher can not find PassKit Dialog UI. Instead this test relies on view // matcher can not find PassKit Dialog UI.
// controller presentation as the signal that PassKit Dialog is shown. #if defined(CHROME_EARL_GREY_1)
// EG1 test relies on view controller presentation as the signal that PassKit
// Dialog is shown.
id<BrowserInterface> interface = id<BrowserInterface> interface =
GetMainController().interfaceProvider.mainInterface; chrome_test_util::GetMainController().interfaceProvider.mainInterface;
UIViewController* viewController = interface.viewController; UIViewController* viewController = interface.viewController;
bool dialogShown = WaitUntilConditionOrTimeout(kWaitForDownloadTimeout, ^{ bool dialogShown = WaitUntilConditionOrTimeout(kWaitForDownloadTimeout, ^{
UIViewController* presentedController = UIViewController* presentedController =
...@@ -115,6 +120,16 @@ std::unique_ptr<net::test_server::HttpResponse> GetResponse( ...@@ -115,6 +120,16 @@ std::unique_ptr<net::test_server::HttpResponse> GetResponse(
return [presentedController class] == [PKAddPassesViewController class]; return [presentedController class] == [PKAddPassesViewController class];
}); });
GREYAssert(dialogShown, @"PassKit dialog was not shown"); GREYAssert(dialogShown, @"PassKit dialog was not shown");
#elif defined(CHROME_EARL_GREY_2)
// EG2 test can use XCUIApplication API to check for PassKit dialog UI
// presentation.
XCUIApplication* app = [[XCUIApplication alloc] init];
XCUIElement* title = app.otherElements[@"Toy Town Membership"];
GREYAssert([title waitForExistenceWithTimeout:kWaitForDownloadTimeout],
@"PassKit dialog UI was not presented");
#else
#error Must define either CHROME_EARL_GREY_1 or CHROME_EARL_GREY_2.
#endif
} }
@end @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