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

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

Issue 2970833002: Be explicit about namespace testing to not mix it with blink::testing (Closed)
Patch Set: Created 3 years, 5 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 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 "core/dom/ScriptedIdleTaskController.h" 5 #include "core/dom/ScriptedIdleTaskController.h"
6 6
7 #include "core/dom/IdleRequestCallback.h" 7 #include "core/dom/IdleRequestCallback.h"
8 #include "core/dom/IdleRequestOptions.h" 8 #include "core/dom/IdleRequestOptions.h"
9 #include "core/testing/NullExecutionContext.h" 9 #include "core/testing/NullExecutionContext.h"
10 #include "platform/testing/TestingPlatformSupport.h" 10 #include "platform/testing/TestingPlatformSupport.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 DISALLOW_COPY_AND_ASSIGN(MockPlatform); 88 DISALLOW_COPY_AND_ASSIGN(MockPlatform);
89 }; 89 };
90 90
91 class MockIdleRequestCallback : public IdleRequestCallback { 91 class MockIdleRequestCallback : public IdleRequestCallback {
92 public: 92 public:
93 MOCK_METHOD1(handleEvent, void(IdleDeadline*)); 93 MOCK_METHOD1(handleEvent, void(IdleDeadline*));
94 }; 94 };
95 95
96 } // namespace 96 } // namespace
97 97
98 class ScriptedIdleTaskControllerTest : public testing::Test { 98 class ScriptedIdleTaskControllerTest : public ::testing::Test {
99 public: 99 public:
100 void SetUp() override { execution_context_ = new NullExecutionContext(); } 100 void SetUp() override { execution_context_ = new NullExecutionContext(); }
101 101
102 protected: 102 protected:
103 Persistent<ExecutionContext> execution_context_; 103 Persistent<ExecutionContext> execution_context_;
104 }; 104 };
105 105
106 TEST_F(ScriptedIdleTaskControllerTest, RunCallback) { 106 TEST_F(ScriptedIdleTaskControllerTest, RunCallback) {
107 ScopedTestingPlatformSupport<MockPlatform, bool> platform(false); 107 ScopedTestingPlatformSupport<MockPlatform, bool> platform(false);
108 NullExecutionContext execution_context; 108 NullExecutionContext execution_context;
109 ScriptedIdleTaskController* controller = 109 ScriptedIdleTaskController* controller =
110 ScriptedIdleTaskController::Create(execution_context_); 110 ScriptedIdleTaskController::Create(execution_context_);
111 111
112 Persistent<MockIdleRequestCallback> callback(new MockIdleRequestCallback()); 112 Persistent<MockIdleRequestCallback> callback(new MockIdleRequestCallback());
113 IdleRequestOptions options; 113 IdleRequestOptions options;
114 EXPECT_FALSE(platform->HasIdleTask()); 114 EXPECT_FALSE(platform->HasIdleTask());
115 int id = controller->RegisterCallback(callback, options); 115 int id = controller->RegisterCallback(callback, options);
116 EXPECT_TRUE(platform->HasIdleTask()); 116 EXPECT_TRUE(platform->HasIdleTask());
117 EXPECT_NE(0, id); 117 EXPECT_NE(0, id);
118 118
119 EXPECT_CALL(*callback, handleEvent(testing::_)); 119 EXPECT_CALL(*callback, handleEvent(testing::_));
120 platform->RunIdleTask(); 120 platform->RunIdleTask();
121 testing::Mock::VerifyAndClearExpectations(callback); 121 ::testing::Mock::VerifyAndClearExpectations(callback);
122 EXPECT_FALSE(platform->HasIdleTask()); 122 EXPECT_FALSE(platform->HasIdleTask());
123 } 123 }
124 124
125 TEST_F(ScriptedIdleTaskControllerTest, DontRunCallbackWhenAskedToYield) { 125 TEST_F(ScriptedIdleTaskControllerTest, DontRunCallbackWhenAskedToYield) {
126 ScopedTestingPlatformSupport<MockPlatform, bool> platform(true); 126 ScopedTestingPlatformSupport<MockPlatform, bool> platform(true);
127 NullExecutionContext execution_context; 127 NullExecutionContext execution_context;
128 ScriptedIdleTaskController* controller = 128 ScriptedIdleTaskController* controller =
129 ScriptedIdleTaskController::Create(execution_context_); 129 ScriptedIdleTaskController::Create(execution_context_);
130 130
131 Persistent<MockIdleRequestCallback> callback(new MockIdleRequestCallback()); 131 Persistent<MockIdleRequestCallback> callback(new MockIdleRequestCallback());
132 IdleRequestOptions options; 132 IdleRequestOptions options;
133 int id = controller->RegisterCallback(callback, options); 133 int id = controller->RegisterCallback(callback, options);
134 EXPECT_NE(0, id); 134 EXPECT_NE(0, id);
135 135
136 EXPECT_CALL(*callback, handleEvent(testing::_)).Times(0); 136 EXPECT_CALL(*callback, handleEvent(testing::_)).Times(0);
137 platform->RunIdleTask(); 137 platform->RunIdleTask();
138 testing::Mock::VerifyAndClearExpectations(callback); 138 ::testing::Mock::VerifyAndClearExpectations(callback);
139 139
140 // The idle task should have been reposted. 140 // The idle task should have been reposted.
141 EXPECT_TRUE(platform->HasIdleTask()); 141 EXPECT_TRUE(platform->HasIdleTask());
142 } 142 }
143 143
144 } // namespace blink 144 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/ScriptRunnerTest.cpp ('k') | third_party/WebKit/Source/core/dom/StaticRangeTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698