OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <stddef.h> | 5 #include <stddef.h> |
6 #include <utility> | 6 #include <utility> |
7 | 7 |
8 #include "base/base64.h" | 8 #include "base/base64.h" |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 1298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1309 std::unique_ptr<base::DictionaryValue> params(new base::DictionaryValue()); | 1309 std::unique_ptr<base::DictionaryValue> params(new base::DictionaryValue()); |
1310 params->SetInteger("width", new_size.width()); | 1310 params->SetInteger("width", new_size.width()); |
1311 params->SetInteger("height", new_size.height()); | 1311 params->SetInteger("height", new_size.height()); |
1312 SendCommand("Emulation.setVisibleSize", std::move(params), true); | 1312 SendCommand("Emulation.setVisibleSize", std::move(params), true); |
1313 EXPECT_SIZE_EQ(new_size, (shell()->web_contents()) | 1313 EXPECT_SIZE_EQ(new_size, (shell()->web_contents()) |
1314 ->GetRenderWidgetHostView() | 1314 ->GetRenderWidgetHostView() |
1315 ->GetViewBounds() | 1315 ->GetViewBounds() |
1316 .size()); | 1316 .size()); |
1317 } | 1317 } |
1318 | 1318 |
1319 // TODO(701223): Enable this on android. | 1319 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, VirtualTimeTest) { |
1320 #if defined(OS_ANDROID) | |
1321 #define MAYBE_VirtualTimeTest DISABLED_VirtualTimeTest | |
1322 #else | |
1323 #define MAYBE_VirtualTimeTest VirtualTimeTest | |
1324 #endif | |
1325 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, MAYBE_VirtualTimeTest) { | |
1326 NavigateToURLBlockUntilNavigationsComplete(shell(), GURL("about:blank"), 1); | 1320 NavigateToURLBlockUntilNavigationsComplete(shell(), GURL("about:blank"), 1); |
1327 Attach(); | 1321 Attach(); |
1328 | 1322 |
1329 std::unique_ptr<base::DictionaryValue> params(new base::DictionaryValue()); | 1323 std::unique_ptr<base::DictionaryValue> params(new base::DictionaryValue()); |
1330 params->SetString("policy", "pause"); | 1324 params->SetString("policy", "pause"); |
1331 SendCommand("Emulation.setVirtualTimePolicy", std::move(params), true); | 1325 SendCommand("Emulation.setVirtualTimePolicy", std::move(params), true); |
1332 | 1326 |
| 1327 // TODO(scheduler-dev): Revisit timing when we have strict ordering |
| 1328 // guarantees. |
1333 params.reset(new base::DictionaryValue()); | 1329 params.reset(new base::DictionaryValue()); |
1334 params->SetString("expression", | 1330 params->SetString("expression", |
1335 "setTimeout(function(){console.log('before')}, 1000);" | 1331 "setTimeout(function(){console.log('before')}, 1000);" |
1336 "setTimeout(function(){console.log('after')}, 1001);"); | 1332 "setTimeout(function(){console.log('after')}, 1002);"); |
1337 SendCommand("Runtime.evaluate", std::move(params), true); | 1333 SendCommand("Runtime.evaluate", std::move(params), true); |
1338 | 1334 |
1339 // Let virtual time advance for one second. | 1335 // Let virtual time advance for one second. |
1340 params.reset(new base::DictionaryValue()); | 1336 params.reset(new base::DictionaryValue()); |
1341 params->SetString("policy", "advance"); | 1337 params->SetString("policy", "advance"); |
1342 params->SetInteger("budget", 1000); | 1338 params->SetInteger("budget", 1001); |
1343 SendCommand("Emulation.setVirtualTimePolicy", std::move(params), true); | 1339 SendCommand("Emulation.setVirtualTimePolicy", std::move(params), true); |
1344 | 1340 |
1345 WaitForNotification("Emulation.virtualTimeBudgetExpired"); | 1341 WaitForNotification("Emulation.virtualTimeBudgetExpired"); |
1346 | 1342 |
1347 params.reset(new base::DictionaryValue()); | 1343 params.reset(new base::DictionaryValue()); |
1348 params->SetString("expression", "console.log('done')"); | 1344 params->SetString("expression", "console.log('done')"); |
1349 SendCommand("Runtime.evaluate", std::move(params), true); | 1345 SendCommand("Runtime.evaluate", std::move(params), true); |
1350 | 1346 |
1351 // The second timer shold not fire. | 1347 // The second timer shold not fire. |
1352 EXPECT_THAT(console_messages_, ElementsAre("before", "done")); | 1348 EXPECT_THAT(console_messages_, ElementsAre("before", "done")); |
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1764 EXPECT_EQ("polyglottal", value); | 1760 EXPECT_EQ("polyglottal", value); |
1765 found++; | 1761 found++; |
1766 } else { | 1762 } else { |
1767 FAIL(); | 1763 FAIL(); |
1768 } | 1764 } |
1769 } | 1765 } |
1770 EXPECT_EQ(2u, found); | 1766 EXPECT_EQ(2u, found); |
1771 } | 1767 } |
1772 | 1768 |
1773 } // namespace content | 1769 } // namespace content |
OLD | NEW |