OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #include <stdint.h> | 5 #include <stdint.h> |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/debug/leak_annotations.h" | 8 #include "base/debug/leak_annotations.h" |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 #include "content/common/frame_messages.h" | 10 #include "content/common/frame_messages.h" |
11 #include "content/common/view_messages.h" | 11 #include "content/common/view_messages.h" |
12 #include "content/public/renderer/document_state.h" | 12 #include "content/public/renderer/document_state.h" |
13 #include "content/public/test/frame_load_waiter.h" | 13 #include "content/public/test/frame_load_waiter.h" |
14 #include "content/public/test/render_view_test.h" | 14 #include "content/public/test/render_view_test.h" |
15 #include "content/public/test/test_utils.h" | 15 #include "content/public/test/test_utils.h" |
16 #include "content/renderer/navigation_state_impl.h" | 16 #include "content/renderer/navigation_state_impl.h" |
17 #include "content/renderer/render_frame_impl.h" | 17 #include "content/renderer/render_frame_impl.h" |
18 #include "content/renderer/render_view_impl.h" | 18 #include "content/renderer/render_view_impl.h" |
19 #include "content/test/fake_compositor_dependencies.h" | 19 #include "content/test/fake_compositor_dependencies.h" |
20 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
21 #include "third_party/WebKit/public/platform/WebEffectiveConnectionType.h" | 21 #include "third_party/WebKit/public/platform/WebEffectiveConnectionType.h" |
22 #include "third_party/WebKit/public/platform/WebURLRequest.h" | 22 #include "third_party/WebKit/public/platform/WebURLRequest.h" |
23 #include "third_party/WebKit/public/web/WebFrameOwnerProperties.h" | 23 #include "third_party/WebKit/public/web/WebFrameOwnerProperties.h" |
24 #include "third_party/WebKit/public/web/WebHistoryItem.h" | 24 #include "third_party/WebKit/public/web/WebHistoryItem.h" |
25 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 25 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
| 26 #include "third_party/WebKit/public/web/WebView.h" |
26 | 27 |
27 namespace { | 28 namespace { |
28 const int32_t kSubframeRouteId = 20; | 29 const int32_t kSubframeRouteId = 20; |
29 const int32_t kSubframeWidgetRouteId = 21; | 30 const int32_t kSubframeWidgetRouteId = 21; |
30 const int32_t kFrameProxyRouteId = 22; | 31 const int32_t kFrameProxyRouteId = 22; |
31 } // namespace | 32 } // namespace |
32 | 33 |
33 namespace content { | 34 namespace content { |
34 | 35 |
35 // RenderFrameImplTest creates a RenderFrameImpl that is a child of the | 36 // RenderFrameImplTest creates a RenderFrameImpl that is a child of the |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 GetMainRenderFrame()->GetWebFrame(), item, blink::WebStandardCommit); | 286 GetMainRenderFrame()->GetWebFrame(), item, blink::WebStandardCommit); |
286 EXPECT_EQ(blink::WebEffectiveConnectionType::TypeUnknown, | 287 EXPECT_EQ(blink::WebEffectiveConnectionType::TypeUnknown, |
287 GetMainRenderFrame()->getEffectiveConnectionType()); | 288 GetMainRenderFrame()->getEffectiveConnectionType()); |
288 | 289 |
289 // The subframe would be deleted here after a cross-document navigation. | 290 // The subframe would be deleted here after a cross-document navigation. |
290 // It happens to be left around in this test because this does not simulate | 291 // It happens to be left around in this test because this does not simulate |
291 // the frame detach. | 292 // the frame detach. |
292 } | 293 } |
293 } | 294 } |
294 | 295 |
| 296 TEST_F(RenderFrameImplTest, ZoomLimit) { |
| 297 const double kMinZoomLevel = ZoomFactorToZoomLevel(kMinimumZoomFactor); |
| 298 const double kMaxZoomLevel = ZoomFactorToZoomLevel(kMaximumZoomFactor); |
| 299 |
| 300 // Verifies navigation to a URL with preset zoom level indeed sets the level. |
| 301 // Regression test for http://crbug.com/139559, where the level was not |
| 302 // properly set when it is out of the default zoom limits of WebView. |
| 303 CommonNavigationParams common_params; |
| 304 common_params.url = GURL("data:text/html,min_zoomlimit_test"); |
| 305 GetMainRenderFrame()->OnGotZoomLevel(common_params.url, kMinZoomLevel); |
| 306 GetMainRenderFrame()->OnNavigate(common_params, StartNavigationParams(), |
| 307 RequestNavigationParams()); |
| 308 ProcessPendingMessages(); |
| 309 EXPECT_DOUBLE_EQ(kMinZoomLevel, view_->GetWebView()->zoomLevel()); |
| 310 |
| 311 // It should work even when the zoom limit is temporarily changed in the page. |
| 312 view_->GetWebView()->zoomLimitsChanged(ZoomFactorToZoomLevel(1.0), |
| 313 ZoomFactorToZoomLevel(1.0)); |
| 314 common_params.url = GURL("data:text/html,max_zoomlimit_test"); |
| 315 GetMainRenderFrame()->OnGotZoomLevel(common_params.url, kMaxZoomLevel); |
| 316 GetMainRenderFrame()->OnNavigate(common_params, StartNavigationParams(), |
| 317 RequestNavigationParams()); |
| 318 ProcessPendingMessages(); |
| 319 EXPECT_DOUBLE_EQ(kMaxZoomLevel, view_->GetWebView()->zoomLevel()); |
| 320 } |
| 321 |
295 } // namespace | 322 } // namespace |
OLD | NEW |