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

Side by Side Diff: third_party/WebKit/Source/web/tests/VirtualTimeTest.cpp

Issue 2239293003: Disable VirtualTimeTest* on Andorid (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 } 49 }
50 50
51 // Some task queues may have repeating v8 tasks that run forever so we impos e a hard time limit. 51 // Some task queues may have repeating v8 tasks that run forever so we impos e a hard time limit.
52 void runTasksForPeriod(double delayMs) 52 void runTasksForPeriod(double delayMs)
53 { 53 {
54 Platform::current()->currentThread()->getWebTaskRunner()->postDelayedTas k(BLINK_FROM_HERE, WTF::bind(&quitRunLoop), delayMs); 54 Platform::current()->currentThread()->getWebTaskRunner()->postDelayedTas k(BLINK_FROM_HERE, WTF::bind(&quitRunLoop), delayMs);
55 testing::enterRunLoop(); 55 testing::enterRunLoop();
56 } 56 }
57 } 57 }
58 58
59 TEST_F(VirtualTimeTest, DOMTimersFireInExpectedOrder) 59 // http://crbug.com/633321
60 #if OS(ANDROID)
61 #define MAYBE_DOMTimersFireInExpectedOrder DISABLED_DOMTimersFireInExpectedOrder
62 #else
63 #define MAYBE_DOMTimersFireInExpectedOrder DOMTimersFireInExpectedOrder
64 #endif
65 TEST_F(VirtualTimeTest, MAYBE_DOMTimersFireInExpectedOrder)
60 { 66 {
61 webView().scheduler()->enableVirtualTime(); 67 webView().scheduler()->enableVirtualTime();
62 68
63 ExecuteJavaScript( 69 ExecuteJavaScript(
64 "var run_order = [];" 70 "var run_order = [];"
65 "function timerFn(delay, value) {" 71 "function timerFn(delay, value) {"
66 " setTimeout(function() { run_order.push(value); }, delay);" 72 " setTimeout(function() { run_order.push(value); }, delay);"
67 "};" 73 "};"
68 "var one_hour = 60 * 60 * 1000;" 74 "var one_hour = 60 * 60 * 1000;"
69 "timerFn(one_hour * 100, 'a');" 75 "timerFn(one_hour * 100, 'a');"
70 "timerFn(one_hour * 10, 'b');" 76 "timerFn(one_hour * 10, 'b');"
71 "timerFn(one_hour, 'c');"); 77 "timerFn(one_hour, 'c');");
72 78
73 // Normally the JS runs pretty much instantly but the timer callbacks will 79 // Normally the JS runs pretty much instantly but the timer callbacks will
74 // take 100h to fire, but thanks to timer fast forwarding we can make them 80 // take 100h to fire, but thanks to timer fast forwarding we can make them
75 // fire immediatly. 81 // fire immediatly.
76 82
77 testing::runPendingTasks(); 83 testing::runPendingTasks();
78 EXPECT_EQ("c, b, a", ExecuteJavaScript("run_order.join(', ')")); 84 EXPECT_EQ("c, b, a", ExecuteJavaScript("run_order.join(', ')"));
79 } 85 }
80 86
81 TEST_F(VirtualTimeTest, SetInterval) 87 // http://crbug.com/633321
88 #if OS(ANDROID)
89 #define MAYBE_SetInterval DISABLED_SetInterval
90 #else
91 #define MAYBE_SetInterval SetInterval
92 #endif
93 TEST_F(VirtualTimeTest, MAYBE_SetInterval)
82 { 94 {
83 webView().scheduler()->enableVirtualTime(); 95 webView().scheduler()->enableVirtualTime();
84 96
85 ExecuteJavaScript( 97 ExecuteJavaScript(
86 "var run_order = [];" 98 "var run_order = [];"
87 "var count = 10;" 99 "var count = 10;"
88 "var interval_handle = setInterval(function() {" 100 "var interval_handle = setInterval(function() {"
89 " if (--window.count == 0) {" 101 " if (--window.count == 0) {"
90 " clearInterval(interval_handle);" 102 " clearInterval(interval_handle);"
91 " }" 103 " }"
92 " run_order.push(count);" 104 " run_order.push(count);"
93 "}, 1000);" 105 "}, 1000);"
94 "setTimeout(function() { run_order.push('timer'); }, 1500);"); 106 "setTimeout(function() { run_order.push('timer'); }, 1500);");
95 107
96 runTasksForPeriod(12000); 108 runTasksForPeriod(12000);
97 109
98 EXPECT_EQ("9, timer, 8, 7, 6, 5, 4, 3, 2, 1, 0", ExecuteJavaScript("run_orde r.join(', ')")); 110 EXPECT_EQ("9, timer, 8, 7, 6, 5, 4, 3, 2, 1, 0", ExecuteJavaScript("run_orde r.join(', ')"));
99 } 111 }
100 112
101 TEST_F(VirtualTimeTest, AllowVirtualTimeToAdvance) 113 // http://crbug.com/633321
114 #if OS(ANDROID)
115 #define MAYBE_AllowVirtualTimeToAdvance DISABLED_AllowVirtualTimeToAdvance
116 #else
117 #define MAYBE_AllowVirtualTimeToAdvance AllowVirtualTimeToAdvance
118 #endif
119 TEST_F(VirtualTimeTest, MAYBE_AllowVirtualTimeToAdvance)
102 { 120 {
103 webView().scheduler()->enableVirtualTime(); 121 webView().scheduler()->enableVirtualTime();
104 webView().scheduler()->setVirtualTimePolicy(WebViewScheduler::VirtualTimePol icy::PAUSE); 122 webView().scheduler()->setVirtualTimePolicy(WebViewScheduler::VirtualTimePol icy::PAUSE);
105 123
106 ExecuteJavaScript( 124 ExecuteJavaScript(
107 "var run_order = [];" 125 "var run_order = [];"
108 "timerFn = function(delay, value) {" 126 "timerFn = function(delay, value) {"
109 " setTimeout(function() { run_order.push(value); }, delay);" 127 " setTimeout(function() { run_order.push(value); }, delay);"
110 "};" 128 "};"
111 "timerFn(100, 'a');" 129 "timerFn(100, 'a');"
112 "timerFn(10, 'b');" 130 "timerFn(10, 'b');"
113 "timerFn(1, 'c');"); 131 "timerFn(1, 'c');");
114 132
115 testing::runPendingTasks(); 133 testing::runPendingTasks();
116 EXPECT_EQ("", ExecuteJavaScript("run_order.join(', ')")); 134 EXPECT_EQ("", ExecuteJavaScript("run_order.join(', ')"));
117 135
118 webView().scheduler()->setVirtualTimePolicy(WebViewScheduler::VirtualTimePol icy::ADVANCE); 136 webView().scheduler()->setVirtualTimePolicy(WebViewScheduler::VirtualTimePol icy::ADVANCE);
119 runTasksForPeriod(1000); 137 runTasksForPeriod(1000);
120 138
121 EXPECT_EQ("c, b, a", ExecuteJavaScript("run_order.join(', ')")); 139 EXPECT_EQ("c, b, a", ExecuteJavaScript("run_order.join(', ')"));
122 } 140 }
123 141
124 TEST_F(VirtualTimeTest, VirtualTimeNotAllowedToAdvanceWhileResourcesLoading) 142 // http://crbug.com/633321
143 #if OS(ANDROID)
144 #define MAYBE_VirtualTimeNotAllowedToAdvanceWhileResourcesLoading DISABLED_Virtu alTimeNotAllowedToAdvanceWhileResourcesLoading
145 #else
146 #define MAYBE_VirtualTimeNotAllowedToAdvanceWhileResourcesLoading VirtualTimeNot AllowedToAdvanceWhileResourcesLoading
147 #endif
148 TEST_F(VirtualTimeTest, MAYBE_VirtualTimeNotAllowedToAdvanceWhileResourcesLoadin g)
125 { 149 {
126 webView().scheduler()->enableVirtualTime(); 150 webView().scheduler()->enableVirtualTime();
127 webView().scheduler()->setVirtualTimePolicy(WebViewScheduler::VirtualTimePol icy::DETERMINISTIC_LOADING); 151 webView().scheduler()->setVirtualTimePolicy(WebViewScheduler::VirtualTimePol icy::DETERMINISTIC_LOADING);
128 152
129 // To ensure determinism virtual time is not allowed to advance until we hav e seen at least one load. 153 // To ensure determinism virtual time is not allowed to advance until we hav e seen at least one load.
130 EXPECT_FALSE(webView().scheduler()->virtualTimeAllowedToAdvance()); 154 EXPECT_FALSE(webView().scheduler()->virtualTimeAllowedToAdvance());
131 155
132 SimRequest mainResource("https://example.com/test.html", "text/html"); 156 SimRequest mainResource("https://example.com/test.html", "text/html");
133 SimRequest cssResource("https://example.com/test.css", "text/css"); 157 SimRequest cssResource("https://example.com/test.css", "text/css");
134 158
(...skipping 19 matching lines...) Expand all
154 // Still Loading, virtual time should not advance. 178 // Still Loading, virtual time should not advance.
155 mainResource.write("<body>"); 179 mainResource.write("<body>");
156 EXPECT_FALSE(webView().scheduler()->virtualTimeAllowedToAdvance()); 180 EXPECT_FALSE(webView().scheduler()->virtualTimeAllowedToAdvance());
157 181
158 // Finished loading, virtual time should be able to advance. 182 // Finished loading, virtual time should be able to advance.
159 mainResource.finish(); 183 mainResource.finish();
160 EXPECT_TRUE(webView().scheduler()->virtualTimeAllowedToAdvance()); 184 EXPECT_TRUE(webView().scheduler()->virtualTimeAllowedToAdvance());
161 } 185 }
162 186
163 } // namespace blink 187 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698