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

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

Issue 2885313003: [scheduler] Fix --disable-background-timer-throttling flag. (Closed)
Patch Set: fix test crash 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
(Empty)
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
3 // found in LICENSE file.
4
5 #include "platform/scheduler/child/web_scheduler.h"
6 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h"
7 #include "platform/testing/UnitTestHelpers.h"
8 #include "public/platform/Platform.h"
9 #include "public/platform/WebThread.h"
10 #include "public/platform/scheduler/renderer/renderer_scheduler.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12 #include "web/tests/sim/SimRequest.h"
13 #include "web/tests/sim/SimTest.h"
14
15 using testing::ElementsAre;
16
17 namespace blink {
18
19 class DisableBackgroundThrottlingIsRespectedTest : public SimTest {
20 public:
21 void SetUp() override {
22 background_tab_timer_throttling_feature_ =
23 WTF::MakeUnique<ScopedBackgroundTabTimerThrottlingForTest>(false);
24 SimTest::SetUp();
25 }
26
27 void TearDown() { background_tab_timer_throttling_feature_.reset(); }
28
29 private:
30 typedef ScopedRuntimeEnabledFeatureForTest<
31 RuntimeEnabledFeatures::timerThrottlingForBackgroundTabsEnabled,
32 RuntimeEnabledFeatures::setTimerThrottlingForBackgroundTabsEnabled>
33 ScopedBackgroundTabTimerThrottlingForTest;
34
35 std::unique_ptr<ScopedBackgroundTabTimerThrottlingForTest>
36 background_tab_timer_throttling_feature_;
37 };
38
39 TEST_F(DisableBackgroundThrottlingIsRespectedTest,
40 DisableBackgroundThrottlingIsRespected) {
41 SimRequest main_resource("https://example.com/", "text/html");
42
43 LoadURL("https://example.com/");
44
45 main_resource.Complete(
46 "(<script>"
47 " function f(repetitions) {"
48 " if (repetitions == 0) return;"
49 " console.log('called f');"
50 " setTimeout(f, 10, repetitions - 1);"
51 " }"
52 " f(5);"
53 "</script>)");
54
55 Platform::Current()
56 ->CurrentThread()
57 ->Scheduler()
58 ->GetRendererSchedulerForTest()
59 ->OnRendererBackgrounded();
60
61 // Run delayed tasks for 1 second. All tasks should be completed
62 // with throttling disabled.
63 testing::RunDelayedTasks(1000);
64
65 EXPECT_THAT(ConsoleMessages(), ElementsAre("called f", "called f", "called f",
66 "called f", "called f"));
67 }
68
69 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/tests/scheduler/README.md ('k') | third_party/WebKit/Source/web/tests/sim/SimTest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698