Chromium Code Reviews| Index: ios/web/web_state/js/crw_js_window_id_manager_unittest.mm |
| diff --git a/ios/web/web_state/js/crw_js_window_id_manager_unittest.mm b/ios/web/web_state/js/crw_js_window_id_manager_unittest.mm |
| index a6655fbb46a62a85c7008fae7baaba05380a7d3f..11ef90fd019967db0a89f3b69ae27ad5959f041e 100644 |
| --- a/ios/web/web_state/js/crw_js_window_id_manager_unittest.mm |
| +++ b/ios/web/web_state/js/crw_js_window_id_manager_unittest.mm |
| @@ -6,18 +6,25 @@ |
| #import <WebKit/WebKit.h> |
| +#include "ios/web/public/test/fakes/test_browser_state.h" |
| #import "ios/web/public/test/js_test_util.h" |
| #import "ios/web/web_state/js/page_script_util.h" |
| #import "testing/gtest_mac.h" |
| +#import "testing/platform_test.h" |
| namespace web { |
|
Eugene But (OOO till 7-30)
2017/03/16 16:12:40
nit: Please add comment: "Test fixture for testing
Hiroshi Ichikawa
2017/03/17 06:09:24
Done.
|
| +class JSWindowIDManagerTest : public PlatformTest { |
| + protected: |
| + TestBrowserState browser_state_; |
| +}; |
| + |
| // Tests that window ID injection by a second manager results in a different |
| // window ID. |
| -TEST(JSWindowIDManagerTest, WindowIDDifferentManager) { |
| +TEST_F(JSWindowIDManagerTest, WindowIDDifferentManager) { |
| // Inject the first manager. |
| WKWebView* web_view = [[[WKWebView alloc] init] autorelease]; |
| - ExecuteJavaScript(web_view, GetEarlyPageScript()); |
| + ExecuteJavaScript(web_view, GetEarlyPageScript(&browser_state_)); |
| CRWJSWindowIDManager* manager = |
| [[[CRWJSWindowIDManager alloc] initWithWebView:web_view] autorelease]; |
| @@ -27,7 +34,7 @@ TEST(JSWindowIDManagerTest, WindowIDDifferentManager) { |
| // Inject the second manager. |
| WKWebView* web_view2 = [[[WKWebView alloc] init] autorelease]; |
| - ExecuteJavaScript(web_view2, GetEarlyPageScript()); |
| + ExecuteJavaScript(web_view2, GetEarlyPageScript(&browser_state_)); |
| CRWJSWindowIDManager* manager2 = |
| [[[CRWJSWindowIDManager alloc] initWithWebView:web_view2] autorelease]; |
| @@ -40,9 +47,9 @@ TEST(JSWindowIDManagerTest, WindowIDDifferentManager) { |
| } |
| // Tests that injecting multiple times creates a new window ID. |
| -TEST(JSWindowIDManagerTest, MultipleInjections) { |
| +TEST_F(JSWindowIDManagerTest, MultipleInjections) { |
| WKWebView* web_view = [[[WKWebView alloc] init] autorelease]; |
| - ExecuteJavaScript(web_view, GetEarlyPageScript()); |
| + ExecuteJavaScript(web_view, GetEarlyPageScript(&browser_state_)); |
| // First injection. |
| CRWJSWindowIDManager* manager = |
| @@ -61,7 +68,7 @@ TEST(JSWindowIDManagerTest, MultipleInjections) { |
| } |
| // Tests that injection will retry if |window.__gCrWeb| is not present. |
| -TEST(JSWindowIDManagerTest, InjectionRetry) { |
| +TEST_F(JSWindowIDManagerTest, InjectionRetry) { |
| WKWebView* web_view = [[[WKWebView alloc] init] autorelease]; |
| CRWJSWindowIDManager* manager = |
| @@ -71,7 +78,7 @@ TEST(JSWindowIDManagerTest, InjectionRetry) { |
| EXPECT_FALSE(ExecuteJavaScript(web_view, @"window.__gCrWeb")); |
| // Now inject window.__gCrWeb and check if window ID injection retried. |
| - ExecuteJavaScript(web_view, GetEarlyPageScript()); |
| + ExecuteJavaScript(web_view, GetEarlyPageScript(&browser_state_)); |
| EXPECT_NSEQ([manager windowID], |
| ExecuteJavaScript(web_view, @"window.__gCrWeb.windowId")); |
| } |