OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ios/web/web_state/web_view_internal_creation_util.h" | 5 #import "ios/web/web_state/web_view_internal_creation_util.h" |
6 | 6 |
7 #import <CoreGraphics/CoreGraphics.h> | 7 #import <CoreGraphics/CoreGraphics.h> |
8 #import <WebKit/WebKit.h> | 8 #import <WebKit/WebKit.h> |
9 | 9 |
10 #include "base/mac/scoped_nsobject.h" | 10 #include "base/mac/scoped_nsobject.h" |
| 11 #include "base/memory/ptr_util.h" |
11 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
12 #include "ios/web/net/request_group_util.h" | 13 #include "ios/web/net/request_group_util.h" |
13 #include "ios/web/public/test/scoped_testing_web_client.h" | 14 #include "ios/web/public/test/scoped_testing_web_client.h" |
14 #include "ios/web/public/test/test_browser_state.h" | 15 #include "ios/web/public/test/test_browser_state.h" |
15 #import "ios/web/public/test/test_web_client.h" | 16 #import "ios/web/public/test/test_web_client.h" |
16 #include "ios/web/public/test/test_web_thread.h" | 17 #include "ios/web/public/test/test_web_thread.h" |
17 #import "ios/web/public/web_view_creation_util.h" | 18 #import "ios/web/public/web_view_creation_util.h" |
18 #import "ios/web/test/web_test.h" | 19 #import "ios/web/test/web_test.h" |
19 #import "ios/web/web_state/ui/wk_web_view_configuration_provider.h" | 20 #import "ios/web/web_state/ui/wk_web_view_configuration_provider.h" |
20 #include "testing/gmock/include/gmock/gmock.h" | 21 #include "testing/gmock/include/gmock/gmock.h" |
21 #include "testing/gtest_mac.h" | 22 #include "testing/gtest_mac.h" |
22 | 23 |
23 namespace web { | 24 namespace web { |
24 namespace { | 25 namespace { |
25 | 26 |
26 const CGRect kTestFrame = CGRectMake(5.0f, 10.0f, 15.0f, 20.0f); | 27 const CGRect kTestFrame = CGRectMake(5.0f, 10.0f, 15.0f, 20.0f); |
27 | 28 |
28 // A WebClient that stubs PreWebViewCreation/PostWebViewCreation calls for | 29 // A WebClient that stubs PreWebViewCreation/PostWebViewCreation calls for |
29 // testing purposes. | 30 // testing purposes. |
30 class CreationUtilsWebClient : public TestWebClient { | 31 class CreationUtilsWebClient : public TestWebClient { |
31 public: | 32 public: |
32 MOCK_CONST_METHOD0(PreWebViewCreation, void()); | 33 MOCK_CONST_METHOD0(PreWebViewCreation, void()); |
33 MOCK_CONST_METHOD1(PostWebViewCreation, void(UIWebView* web_view)); | 34 MOCK_CONST_METHOD1(PostWebViewCreation, void(UIWebView* web_view)); |
34 }; | 35 }; |
35 | 36 |
36 class WebViewCreationUtilsTest : public WebTest { | 37 class WebViewCreationUtilsTest : public WebTest { |
37 public: | 38 public: |
38 WebViewCreationUtilsTest() | 39 WebViewCreationUtilsTest() |
39 : web_client_(make_scoped_ptr(new CreationUtilsWebClient)) {} | 40 : web_client_(base::WrapUnique(new CreationUtilsWebClient)) {} |
40 | 41 |
41 protected: | 42 protected: |
42 CreationUtilsWebClient* creation_utils_web_client() { | 43 CreationUtilsWebClient* creation_utils_web_client() { |
43 return static_cast<CreationUtilsWebClient*>(web_client_.Get()); | 44 return static_cast<CreationUtilsWebClient*>(web_client_.Get()); |
44 } | 45 } |
45 void SetUp() override { | 46 void SetUp() override { |
46 WebTest::SetUp(); | 47 WebTest::SetUp(); |
47 logJavaScriptPref_ = | 48 logJavaScriptPref_ = |
48 [[NSUserDefaults standardUserDefaults] boolForKey:@"LogJavascript"]; | 49 [[NSUserDefaults standardUserDefaults] boolForKey:@"LogJavascript"]; |
49 } | 50 } |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 | 115 |
115 // Make sure that web views share the same non-nil process pool. Otherwise | 116 // Make sure that web views share the same non-nil process pool. Otherwise |
116 // cookie will not be immediately shared between different web views. | 117 // cookie will not be immediately shared between different web views. |
117 EXPECT_TRUE([[web_view configuration] processPool]); | 118 EXPECT_TRUE([[web_view configuration] processPool]); |
118 EXPECT_EQ([[web_view configuration] processPool], | 119 EXPECT_EQ([[web_view configuration] processPool], |
119 [[web_view2 configuration] processPool]); | 120 [[web_view2 configuration] processPool]); |
120 } | 121 } |
121 | 122 |
122 } // namespace | 123 } // namespace |
123 } // namespace web | 124 } // namespace web |
OLD | NEW |