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" |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 CreateWKWebView(CGRectZero, GetBrowserState())); | 175 CreateWKWebView(CGRectZero, GetBrowserState())); |
176 EXPECT_EQ(2U, GetActiveWKWebViewsCount()); | 176 EXPECT_EQ(2U, GetActiveWKWebViewsCount()); |
177 web_view2.reset(); | 177 web_view2.reset(); |
178 EXPECT_EQ(1U, GetActiveWKWebViewsCount()); | 178 EXPECT_EQ(1U, GetActiveWKWebViewsCount()); |
179 web_view1.reset(); | 179 web_view1.reset(); |
180 EXPECT_EQ(0U, GetActiveWKWebViewsCount()); | 180 EXPECT_EQ(0U, GetActiveWKWebViewsCount()); |
181 } | 181 } |
182 | 182 |
183 #endif // defined(NDEBUG) | 183 #endif // defined(NDEBUG) |
184 | 184 |
185 // Tests web::CreateStaticFileWebView that it correctly returns a | |
186 // CRWStaticFileWebView with the correct frame, user agent, and calls | |
187 // WebClient::PreWebViewCreation/WebClient::PostWebViewCreation methods. | |
188 TEST_F(WebViewCreationUtilsTest, TestNewStaticFileWebViewTrue) { | |
189 UIWebView* captured_web_view = nil; | |
190 ExpectWebClientCalls(&captured_web_view); | |
191 | |
192 base::scoped_nsobject<UIWebView> web_view( | |
193 CreateStaticFileWebView(kTestFrame, GetBrowserState())); | |
194 ASSERT_TRUE([web_view isMemberOfClass:[CRWStaticFileWebView class]]); | |
195 EXPECT_TRUE(CGRectEqualToRect(kTestFrame, [web_view frame])); | |
196 EXPECT_NSEQ(web_view, captured_web_view); | |
197 | |
198 NSString* user_agent = GetWebViewUserAgent(web_view); | |
199 EXPECT_TRUE([CRWStaticFileWebView isStaticFileUserAgent:user_agent]); | |
200 } | |
201 | |
202 // Tests web::CreateSimpleWebViewController returns a CRWSimpleWebViewController | 185 // Tests web::CreateSimpleWebViewController returns a CRWSimpleWebViewController |
203 // instance with a web view. | 186 // instance with a web view. |
204 TEST_F(WebViewCreationUtilsTest, CreateSimpleWebViewController) { | 187 TEST_F(WebViewCreationUtilsTest, CreateSimpleWebViewController) { |
205 base::scoped_nsprotocol<id<CRWSimpleWebViewController>> | 188 base::scoped_nsprotocol<id<CRWSimpleWebViewController>> |
206 simpleWebViewController( | 189 simpleWebViewController( |
207 CreateSimpleWebViewController(CGRectZero, nullptr, UI_WEB_VIEW_TYPE)); | 190 CreateSimpleWebViewController(CGRectZero, GetBrowserState())); |
208 EXPECT_TRUE([simpleWebViewController view]); | 191 EXPECT_TRUE([simpleWebViewController view]); |
209 } | 192 } |
210 | 193 |
211 } // namespace | 194 } // namespace |
212 } // namespace web | 195 } // namespace web |
OLD | NEW |