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

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

Issue 2896603002: [scheduler] Move task alignment into WakeUpBudgetPool. (Closed)
Patch Set: no iostream Created 3 years, 7 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code if governed by a BSD-style license that can be 2 // Use of this source code if governed by a BSD-style license that can be
3 // found in LICENSE file. 3 // found in LICENSE file.
4 4
5 #include "platform/scheduler/child/web_scheduler.h" 5 #include "platform/scheduler/child/web_scheduler.h"
6 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" 6 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h"
7 #include "platform/testing/UnitTestHelpers.h" 7 #include "platform/testing/UnitTestHelpers.h"
8 #include "public/platform/Platform.h" 8 #include "public/platform/Platform.h"
9 #include "public/platform/WebThread.h" 9 #include "public/platform/WebThread.h"
10 #include "public/platform/scheduler/renderer/renderer_scheduler.h" 10 #include "public/platform/scheduler/renderer/renderer_scheduler.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 ->OnRendererBackgrounded(); 59 ->OnRendererBackgrounded();
60 60
61 // Run delayed tasks for 1 second. All tasks should be completed 61 // Run delayed tasks for 1 second. All tasks should be completed
62 // with throttling disabled. 62 // with throttling disabled.
63 testing::RunDelayedTasks(1000); 63 testing::RunDelayedTasks(1000);
64 64
65 EXPECT_THAT(ConsoleMessages(), ElementsAre("called f", "called f", "called f", 65 EXPECT_THAT(ConsoleMessages(), ElementsAre("called f", "called f", "called f",
66 "called f", "called f")); 66 "called f", "called f"));
67 } 67 }
68 68
69 class BackgroundRendererThrottlingTest : public SimTest {};
70
71 TEST_F(BackgroundRendererThrottlingTest, BackgroundRenderersAreThrottled) {
72 SimRequest main_resource("https://example.com/", "text/html");
73
74 LoadURL("https://example.com/");
75
76 main_resource.Complete(
77 "(<script>"
78 " function f(repetitions) {"
79 " if (repetitions == 0) return;"
80 " console.log('called f');"
81 " setTimeout(f, 10, repetitions - 1);"
82 " }"
83 " setTimeout(f, 10, 3);"
84 "</script>)");
85
86 Platform::Current()
87 ->CurrentThread()
88 ->Scheduler()
89 ->GetRendererSchedulerForTest()
90 ->OnRendererBackgrounded();
91
92 // Make sure that we run a task once a second.
93 for (int i = 0; i < 3; ++i) {
94 testing::RunDelayedTasks(1000);
95 EXPECT_THAT(ConsoleMessages(), ElementsAre("called f"));
96 ConsoleMessages().clear();
97 }
98 }
99
69 } // namespace blink 100 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698