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

Side by Side Diff: third_party/WebKit/Source/core/dom/MainThreadTaskRunnerTest.cpp

Issue 2527143002: Suspend frame schedulers on a page suspension (Closed)
Patch Set: mod a comment Created 4 years 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 /* 1 /*
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved.
3 * Copyright (C) 2013 Google Inc. All Rights Reserved. 3 * Copyright (C) 2013 Google Inc. All Rights Reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 bool isMarked = false; 48 bool isMarked = false;
49 49
50 runner->postTask( 50 runner->postTask(
51 BLINK_FROM_HERE, 51 BLINK_FROM_HERE,
52 createSameThreadTask(&markBoolean, WTF::unretained(&isMarked))); 52 createSameThreadTask(&markBoolean, WTF::unretained(&isMarked)));
53 EXPECT_FALSE(isMarked); 53 EXPECT_FALSE(isMarked);
54 blink::testing::runPendingTasks(); 54 blink::testing::runPendingTasks();
55 EXPECT_TRUE(isMarked); 55 EXPECT_TRUE(isMarked);
56 } 56 }
57 57
58 TEST(MainThreadTaskRunnerTest, SuspendTask) {
59 NullExecutionContext* context = new NullExecutionContext();
60 std::unique_ptr<MainThreadTaskRunner> runner =
61 MainThreadTaskRunner::create(context);
62 bool isMarked = false;
63
64 context->setTasksNeedSuspension(true);
65 runner->postTask(
66 BLINK_FROM_HERE,
67 createSameThreadTask(&markBoolean, WTF::unretained(&isMarked)));
68 runner->suspend();
69 blink::testing::runPendingTasks();
70 EXPECT_FALSE(isMarked);
71
72 context->setTasksNeedSuspension(false);
73 runner->resume();
74 blink::testing::runPendingTasks();
75 EXPECT_TRUE(isMarked);
76 }
77
78 TEST(MainThreadTaskRunnerTest, RemoveRunner) { 58 TEST(MainThreadTaskRunnerTest, RemoveRunner) {
79 NullExecutionContext* context = new NullExecutionContext(); 59 NullExecutionContext* context = new NullExecutionContext();
80 std::unique_ptr<MainThreadTaskRunner> runner = 60 std::unique_ptr<MainThreadTaskRunner> runner =
81 MainThreadTaskRunner::create(context); 61 MainThreadTaskRunner::create(context);
82 bool isMarked = false; 62 bool isMarked = false;
83 63
84 context->setTasksNeedSuspension(true); 64 context->setTasksNeedSuspension(true);
85 runner->postTask( 65 runner->postTask(
86 BLINK_FROM_HERE, 66 BLINK_FROM_HERE,
87 createSameThreadTask(&markBoolean, WTF::unretained(&isMarked))); 67 createSameThreadTask(&markBoolean, WTF::unretained(&isMarked)));
88 runner = nullptr; 68 runner = nullptr;
89 blink::testing::runPendingTasks(); 69 blink::testing::runPendingTasks();
90 EXPECT_FALSE(isMarked); 70 EXPECT_FALSE(isMarked);
91 } 71 }
92 72
93 } // namespace blink 73 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/MainThreadTaskRunner.cpp ('k') | third_party/WebKit/Source/core/page/Page.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698