OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "platform/testing/UnitTestHelpers.h" | 5 #include "platform/testing/UnitTestHelpers.h" |
6 #include "public/platform/Platform.h" | 6 #include "public/platform/Platform.h" |
7 #include "public/platform/WebViewScheduler.h" | 7 #include "public/platform/WebViewScheduler.h" |
8 #include "public/web/WebLocalFrame.h" | 8 #include "public/web/WebLocalFrame.h" |
9 #include "public/web/WebScriptExecutionCallback.h" | 9 #include "public/web/WebScriptExecutionCallback.h" |
10 #include "public/web/WebScriptSource.h" | 10 #include "public/web/WebScriptSource.h" |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 | 102 |
103 webView().scheduler()->setVirtualTimePolicy(WebViewScheduler::VirtualTimePol
icy::ADVANCE); | 103 webView().scheduler()->setVirtualTimePolicy(WebViewScheduler::VirtualTimePol
icy::ADVANCE); |
104 testing::runPendingTasks(); | 104 testing::runPendingTasks(); |
105 | 105 |
106 EXPECT_EQ("c, b, a", ExecuteJavaScript("run_order.join(', ')")); | 106 EXPECT_EQ("c, b, a", ExecuteJavaScript("run_order.join(', ')")); |
107 } | 107 } |
108 | 108 |
109 TEST_F(VirtualTimeTest, VirtualTimeNotAllowedToAdvanceWhileResourcesLoading) | 109 TEST_F(VirtualTimeTest, VirtualTimeNotAllowedToAdvanceWhileResourcesLoading) |
110 { | 110 { |
111 webView().scheduler()->enableVirtualTime(); | 111 webView().scheduler()->enableVirtualTime(); |
112 webView().scheduler()->setVirtualTimePolicy(WebViewScheduler::VirtualTimePol
icy::PAUSE_IF_NETWORK_FETCHES_PENDING); | 112 webView().scheduler()->setVirtualTimePolicy(WebViewScheduler::VirtualTimePol
icy::DETERMINISTIC_LOADING); |
113 | 113 |
114 EXPECT_TRUE(webView().scheduler()->virtualTimeAllowedToAdvance()); | 114 EXPECT_TRUE(webView().scheduler()->virtualTimeAllowedToAdvance()); |
115 | 115 |
116 SimRequest mainResource("https://example.com/test.html", "text/html"); | 116 SimRequest mainResource("https://example.com/test.html", "text/html"); |
117 SimRequest cssResource("https://example.com/test.css", "text/css"); | 117 SimRequest cssResource("https://example.com/test.css", "text/css"); |
118 | 118 |
119 // Not loading, virtual time should be able to advance. | 119 // Not loading, virtual time should be able to advance. |
120 EXPECT_TRUE(webView().scheduler()->virtualTimeAllowedToAdvance()); | 120 EXPECT_TRUE(webView().scheduler()->virtualTimeAllowedToAdvance()); |
121 | 121 |
122 // Loading, virtual time should not advance. | 122 // Loading, virtual time should not advance. |
(...skipping 18 matching lines...) Expand all Loading... |
141 // Still Loading, virtual time should not advance. | 141 // Still Loading, virtual time should not advance. |
142 mainResource.write("<body>"); | 142 mainResource.write("<body>"); |
143 EXPECT_FALSE(webView().scheduler()->virtualTimeAllowedToAdvance()); | 143 EXPECT_FALSE(webView().scheduler()->virtualTimeAllowedToAdvance()); |
144 | 144 |
145 // Finished loading, virtual time should be able to advance. | 145 // Finished loading, virtual time should be able to advance. |
146 mainResource.finish(); | 146 mainResource.finish(); |
147 EXPECT_TRUE(webView().scheduler()->virtualTimeAllowedToAdvance()); | 147 EXPECT_TRUE(webView().scheduler()->virtualTimeAllowedToAdvance()); |
148 } | 148 } |
149 | 149 |
150 } // namespace blink | 150 } // namespace blink |
OLD | NEW |