Commit af629fda authored by Eugene But's avatar Eugene But Committed by Commit Bot

[New PassKit] Gracefully handle pkpass download on iPad.

On iPad PKAddPassesViewController alloc/init returns nil. This CL fixes
a crash, which caused by presenting nil view controller.

The functional behavior remains the same as for old pass kit
implementaiton (the error is silentry ignored). This issues is tracked
in a separate bug (crbug.com/794301).

Bug: 787943
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: Id3826fa13d5c327795d411b3ec7b9c5d343031c1
Reviewed-on: https://chromium-review.googlesource.com/823239Reviewed-by: default avatarGregory Chatzinoff <gchatz@chromium.org>
Commit-Queue: Eugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#523804}
parent 45dcf931
......@@ -71,6 +71,10 @@
// Presents PKAddPassesViewController.
- (void)presentAddPassUI {
if (![PKAddPassesViewController canAddPasses]) {
[self stop];
return;
}
_viewController = [[PKAddPassesViewController alloc] initWithPass:self.pass];
_viewController.delegate = self;
[self.baseViewController presentViewController:_viewController
......
......@@ -27,6 +27,7 @@
#endif
using testing::WaitUntilConditionOrTimeout;
using testing::kWaitForUIElementTimeout;
// Test fixture for PassKitCoordinator class.
class PassKitCoordinatorTest : public PlatformTest {
......@@ -57,11 +58,6 @@ class PassKitCoordinatorTest : public PlatformTest {
// Tests that PassKitCoordinator presents PKAddPassesViewController for the
// valid PKPass object.
TEST_F(PassKitCoordinatorTest, ValidPassKitObject) {
if (IsIPadIdiom()) {
// Wallet app is not supported on iPads.
return;
}
std::string data = testing::GetTestPass();
NSData* nsdata = [NSData dataWithBytes:data.c_str() length:data.size()];
PKPass* pass = [[PKPass alloc] initWithData:nsdata error:nil];
......@@ -72,16 +68,21 @@ TEST_F(PassKitCoordinatorTest, ValidPassKitObject) {
presentDialogForPass:pass
webState:web_state_.get()];
EXPECT_TRUE(WaitUntilConditionOrTimeout(testing::kWaitForUIElementTimeout, ^{
if (IsIPadIdiom()) {
// Wallet app is not supported on iPads.
} else {
EXPECT_TRUE(WaitUntilConditionOrTimeout(kWaitForUIElementTimeout, ^{
return [base_view_controller_.presentedViewController class] ==
[PKAddPassesViewController class];
}));
[coordinator_ stop];
EXPECT_TRUE(WaitUntilConditionOrTimeout(testing::kWaitForUIElementTimeout, ^{
EXPECT_TRUE(WaitUntilConditionOrTimeout(kWaitForUIElementTimeout, ^{
return base_view_controller_.presentedViewController == nil;
}));
}
EXPECT_FALSE(coordinator_.webState);
EXPECT_FALSE(coordinator_.pass);
}
......
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