OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/bind.h" | 6 #include "base/bind.h" |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/memory/shared_memory.h" | 8 #include "base/memory/shared_memory.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 2191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2202 TEST_F(RenderViewImplTest, ScreenMetricsEmulation) { | 2202 TEST_F(RenderViewImplTest, ScreenMetricsEmulation) { |
2203 LoadHTML("<body style='min-height:1000px;'></body>"); | 2203 LoadHTML("<body style='min-height:1000px;'></body>"); |
2204 | 2204 |
2205 blink::WebDeviceEmulationParams params; | 2205 blink::WebDeviceEmulationParams params; |
2206 base::string16 get_width = base::ASCIIToUTF16("Number(window.innerWidth)"); | 2206 base::string16 get_width = base::ASCIIToUTF16("Number(window.innerWidth)"); |
2207 base::string16 get_height = base::ASCIIToUTF16("Number(window.innerHeight)"); | 2207 base::string16 get_height = base::ASCIIToUTF16("Number(window.innerHeight)"); |
2208 int width, height; | 2208 int width, height; |
2209 | 2209 |
2210 params.viewSize.width = 327; | 2210 params.viewSize.width = 327; |
2211 params.viewSize.height = 415; | 2211 params.viewSize.height = 415; |
2212 view()->EnableScreenMetricsEmulation(params); | 2212 view()->OnEnableDeviceEmulation(params); |
2213 EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(get_width, &width)); | 2213 EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(get_width, &width)); |
2214 EXPECT_EQ(params.viewSize.width, width); | 2214 EXPECT_EQ(params.viewSize.width, width); |
2215 EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(get_height, &height)); | 2215 EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(get_height, &height)); |
2216 EXPECT_EQ(params.viewSize.height, height); | 2216 EXPECT_EQ(params.viewSize.height, height); |
2217 | 2217 |
2218 params.viewSize.width = 1005; | 2218 params.viewSize.width = 1005; |
2219 params.viewSize.height = 1102; | 2219 params.viewSize.height = 1102; |
2220 view()->EnableScreenMetricsEmulation(params); | 2220 view()->OnEnableDeviceEmulation(params); |
2221 EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(get_width, &width)); | 2221 EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(get_width, &width)); |
2222 EXPECT_EQ(params.viewSize.width, width); | 2222 EXPECT_EQ(params.viewSize.width, width); |
2223 EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(get_height, &height)); | 2223 EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(get_height, &height)); |
2224 EXPECT_EQ(params.viewSize.height, height); | 2224 EXPECT_EQ(params.viewSize.height, height); |
2225 | 2225 |
2226 view()->DisableScreenMetricsEmulation(); | 2226 view()->OnDisableDeviceEmulation(); |
2227 | 2227 |
2228 view()->EnableScreenMetricsEmulation(params); | 2228 view()->OnEnableDeviceEmulation(params); |
2229 // Don't disable here to test that emulation is being shutdown properly. | 2229 // Don't disable here to test that emulation is being shutdown properly. |
2230 } | 2230 } |
2231 | 2231 |
2232 // Sanity checks for the Navigation Timing API |navigationStart| override. We | 2232 // Sanity checks for the Navigation Timing API |navigationStart| override. We |
2233 // are asserting only most basic constraints, as TimeTicks (passed as the | 2233 // are asserting only most basic constraints, as TimeTicks (passed as the |
2234 // override) are not comparable with the wall time (returned by the Blink API). | 2234 // override) are not comparable with the wall time (returned by the Blink API). |
2235 TEST_F(RenderViewImplTest, NavigationStartOverride) { | 2235 TEST_F(RenderViewImplTest, NavigationStartOverride) { |
2236 // Verify that a navigation that claims to have started at the earliest | 2236 // Verify that a navigation that claims to have started at the earliest |
2237 // possible TimeTicks is indeed reported as one that started before | 2237 // possible TimeTicks is indeed reported as one that started before |
2238 // OnNavigate() is called. | 2238 // OnNavigate() is called. |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2309 frame()->OnNavigate(CommonNavigationParams(), StartNavigationParams(), | 2309 frame()->OnNavigate(CommonNavigationParams(), StartNavigationParams(), |
2310 CommitNavigationParams(), history_params); | 2310 CommitNavigationParams(), history_params); |
2311 | 2311 |
2312 // The history list in RenderView should have been updated. | 2312 // The history list in RenderView should have been updated. |
2313 EXPECT_EQ(1, view()->historyBackListCount()); | 2313 EXPECT_EQ(1, view()->historyBackListCount()); |
2314 EXPECT_EQ(2, view()->historyBackListCount() + | 2314 EXPECT_EQ(2, view()->historyBackListCount() + |
2315 view()->historyForwardListCount() + 1); | 2315 view()->historyForwardListCount() + 1); |
2316 } | 2316 } |
2317 | 2317 |
2318 } // namespace content | 2318 } // namespace content |
OLD | NEW |