Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(612)

Side by Side Diff: content/browser/devtools/protocol/devtools_protocol_browsertest.cc

Issue 2841463003: scheduler: Make virtual time expiration deterministic (Closed)
Patch Set: Review comments Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1346 matching lines...) Expand 10 before | Expand all | Expand 10 after
1357 } 1357 }
1358 1358
1359 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, VirtualTimeTest) { 1359 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, VirtualTimeTest) {
1360 NavigateToURLBlockUntilNavigationsComplete(shell(), GURL("about:blank"), 1); 1360 NavigateToURLBlockUntilNavigationsComplete(shell(), GURL("about:blank"), 1);
1361 Attach(); 1361 Attach();
1362 1362
1363 std::unique_ptr<base::DictionaryValue> params(new base::DictionaryValue()); 1363 std::unique_ptr<base::DictionaryValue> params(new base::DictionaryValue());
1364 params->SetString("policy", "pause"); 1364 params->SetString("policy", "pause");
1365 SendCommand("Emulation.setVirtualTimePolicy", std::move(params), true); 1365 SendCommand("Emulation.setVirtualTimePolicy", std::move(params), true);
1366 1366
1367 // TODO(scheduler-dev): Revisit timing when we have strict ordering
1368 // guarantees.
1369 params.reset(new base::DictionaryValue()); 1367 params.reset(new base::DictionaryValue());
1370 params->SetString("expression", 1368 params->SetString("expression",
1371 "setTimeout(function(){console.log('before')}, 1000);" 1369 "setTimeout(function(){console.log('before')}, 999);"
1370 "setTimeout(function(){console.log('at')}, 1000);"
1372 "setTimeout(function(){console.log('after')}, 1002);"); 1371 "setTimeout(function(){console.log('after')}, 1002);");
1373 SendCommand("Runtime.evaluate", std::move(params), true); 1372 SendCommand("Runtime.evaluate", std::move(params), true);
1374 1373
1375 // Let virtual time advance for one second. 1374 // Let virtual time advance for one second.
1376 params.reset(new base::DictionaryValue()); 1375 params.reset(new base::DictionaryValue());
1377 params->SetString("policy", "advance"); 1376 params->SetString("policy", "advance");
1378 params->SetInteger("budget", 1001); 1377 params->SetInteger("budget", 1000);
1379 SendCommand("Emulation.setVirtualTimePolicy", std::move(params), true); 1378 SendCommand("Emulation.setVirtualTimePolicy", std::move(params), true);
1380 1379
1381 WaitForNotification("Emulation.virtualTimeBudgetExpired"); 1380 WaitForNotification("Emulation.virtualTimeBudgetExpired");
1382 1381
1383 params.reset(new base::DictionaryValue()); 1382 params.reset(new base::DictionaryValue());
1384 params->SetString("expression", "console.log('done')"); 1383 params->SetString("expression", "console.log('done')");
1385 SendCommand("Runtime.evaluate", std::move(params), true); 1384 SendCommand("Runtime.evaluate", std::move(params), true);
1386 1385
1387 // The second timer shold not fire. 1386 // The second timer shold not fire.
1388 EXPECT_THAT(console_messages_, ElementsAre("before", "done")); 1387 EXPECT_THAT(console_messages_, ElementsAre("before", "done"));
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
1800 EXPECT_EQ("polyglottal", value); 1799 EXPECT_EQ("polyglottal", value);
1801 found++; 1800 found++;
1802 } else { 1801 } else {
1803 FAIL(); 1802 FAIL();
1804 } 1803 }
1805 } 1804 }
1806 EXPECT_EQ(2u, found); 1805 EXPECT_EQ(2u, found);
1807 } 1806 }
1808 1807
1809 } // namespace content 1808 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698