| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import <Foundation/Foundation.h> | 5 #import <Foundation/Foundation.h> |
| 6 | 6 |
| 7 #import "ios/chrome/browser/itunes_links/itunes_links_observer.h" | 7 #import "ios/chrome/browser/itunes_links/itunes_links_observer.h" |
| 8 | 8 |
| 9 #import "ios/chrome/browser/storekit_launcher.h" | 9 #import "ios/chrome/browser/store_kit/store_kit_tab_helper.h" |
| 10 #import "ios/web/public/test/fakes/test_web_state.h" | 10 #import "ios/web/public/test/fakes/test_web_state.h" |
| 11 #include "testing/gtest_mac.h" | 11 #include "testing/gtest_mac.h" |
| 12 #include "testing/platform_test.h" | 12 #include "testing/platform_test.h" |
| 13 #import "third_party/ocmock/OCMock/OCMock.h" | 13 #import "third_party/ocmock/OCMock/OCMock.h" |
| 14 #import "third_party/ocmock/gtest_support.h" | 14 #import "third_party/ocmock/gtest_support.h" |
| 15 #include "url/gurl.h" | 15 #include "url/gurl.h" |
| 16 | 16 |
| 17 #if !defined(__has_feature) || !__has_feature(objc_arc) | 17 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 18 #error "This file requires ARC support." | 18 #error "This file requires ARC support." |
| 19 #endif | 19 #endif |
| 20 | 20 |
| 21 namespace { | 21 namespace { |
| 22 | 22 |
| 23 class ITunesLinksObserverTest : public PlatformTest { | 23 class ITunesLinksObserverTest : public PlatformTest { |
| 24 protected: | 24 protected: |
| 25 void SetUp() override { | 25 void SetUp() override { |
| 26 StoreKitTabHelper::CreateForWebState(&web_state_); |
| 26 mocked_store_kit_launcher_ = | 27 mocked_store_kit_launcher_ = |
| 27 [OCMockObject mockForProtocol:@protocol(StoreKitLauncher)]; | 28 [OCMockObject mockForProtocol:@protocol(StoreKitLauncher)]; |
| 28 link_observer_ = [[ITunesLinksObserver alloc] initWithWebState:&web_state_]; | 29 link_observer_ = [[ITunesLinksObserver alloc] initWithWebState:&web_state_]; |
| 29 [link_observer_ setStoreKitLauncher:mocked_store_kit_launcher_]; | 30 [link_observer_ setStoreKitLauncher:mocked_store_kit_launcher_]; |
| 30 } | 31 } |
| 31 void VerifyOpeningOfAppStore(NSString* expected_product_id, | 32 void VerifyOpeningOfAppStore(NSString* expected_product_id, |
| 32 std::string const& url_string) { | 33 std::string const& url_string) { |
| 33 if (expected_product_id) | 34 if (expected_product_id) |
| 34 [[mocked_store_kit_launcher_ expect] openAppStore:expected_product_id]; | 35 [[mocked_store_kit_launcher_ expect] openAppStore:expected_product_id]; |
| 35 web_state_.SetCurrentURL(GURL(url_string)); | 36 web_state_.SetCurrentURL(GURL(url_string)); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 VerifyOpeningOfAppStore(@"123", "http://itunes.apple.com/bar/id123"); | 72 VerifyOpeningOfAppStore(@"123", "http://itunes.apple.com/bar/id123"); |
| 72 VerifyOpeningOfAppStore(@"123", "http://itunes.apple.com/bar/id123?qux"); | 73 VerifyOpeningOfAppStore(@"123", "http://itunes.apple.com/bar/id123?qux"); |
| 73 VerifyOpeningOfAppStore(@"123", "http://itunes.apple.com/bar/id123?qux&baz"); | 74 VerifyOpeningOfAppStore(@"123", "http://itunes.apple.com/bar/id123?qux&baz"); |
| 74 VerifyOpeningOfAppStore(@"123", | 75 VerifyOpeningOfAppStore(@"123", |
| 75 "http://itunes.apple.com/bar/id123?qux&baz#foo"); | 76 "http://itunes.apple.com/bar/id123?qux&baz#foo"); |
| 76 VerifyOpeningOfAppStore(@"123", | 77 VerifyOpeningOfAppStore(@"123", |
| 77 "http://foo.itunes.apple.com/bar/id123?qux&baz#foo"); | 78 "http://foo.itunes.apple.com/bar/id123?qux&baz#foo"); |
| 78 } | 79 } |
| 79 | 80 |
| 80 } // namespace | 81 } // namespace |
| OLD | NEW |