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

Side by Side Diff: cc/trees/threaded_channel_unittest.cc

Issue 1506023008: [NOT LANDED] Revert of cc: Split ThreadProxy into ProxyMain and ProxyImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
« no previous file with comments | « cc/trees/threaded_channel.cc ('k') | 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "cc/trees/threaded_channel.h" 5 #include "cc/trees/threaded_channel.h"
6 6
7 #include "cc/test/layer_tree_test.h" 7 #include "cc/test/layer_tree_test.h"
8 #include "cc/trees/single_thread_proxy.h" 8 #include "cc/trees/single_thread_proxy.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
11 namespace cc { 11 namespace cc {
12 12
13 // The ThreadedChannel tests are run only for threaded and direct mode. 13 // The ThreadedChannel tests are run only for threaded and direct mode.
14 class ThreadedChannelTest : public LayerTreeTest { 14 class ThreadedChannelTest : public LayerTreeTest {
15 protected: 15 protected:
16 ThreadedChannelTest() : calls_received_(0) {} 16 ThreadedChannelTest() : thread_proxy_(nullptr), calls_received_(0) {}
17 17
18 ~ThreadedChannelTest() override {} 18 ~ThreadedChannelTest() override {}
19 19
20 void BeginTest() override { 20 void BeginTest() override {
21 DCHECK(HasImplThread()); 21 DCHECK(HasImplThread());
22 thread_proxy_ = static_cast<ThreadProxy*>(proxy());
22 BeginChannelTest(); 23 BeginChannelTest();
23 }; 24 };
24 virtual void BeginChannelTest() {} 25 virtual void BeginChannelTest() {}
25 26
26 void PostOnImplThread() { 27 void PostOnImplThread() {
27 ImplThreadTaskRunner()->PostTask( 28 ImplThreadTaskRunner()->PostTask(
28 FROM_HERE, base::Bind(&ThreadedChannelTest::StartTestOnImplThread, 29 FROM_HERE, base::Bind(&ThreadedChannelTest::StartTestOnImplThread,
29 base::Unretained(this))); 30 base::Unretained(this)));
30 } 31 }
31 32
32 virtual void StartTestOnImplThread() { 33 virtual void StartTestOnImplThread() {
33 DCHECK(task_runner_provider()->IsImplThread()); 34 DCHECK(task_runner_provider()->IsImplThread());
34 } 35 }
35 36
36 void AfterTest() override {} 37 void AfterTest() override {}
37 38
39 // TODO(khushalsagar): Remove this once ProxyImpl is added to the
40 // LayerTreeTest.
41 ThreadProxy* thread_proxy_;
38 int calls_received_; 42 int calls_received_;
39 43
40 private: 44 private:
41 DISALLOW_COPY_AND_ASSIGN(ThreadedChannelTest); 45 DISALLOW_COPY_AND_ASSIGN(ThreadedChannelTest);
42 }; 46 };
43 47
44 class ThreadedChannelTestInitializationAndShutdown 48 class ThreadedChannelTestInitializationAndShutdown
45 : public ThreadedChannelTest { 49 : public ThreadedChannelTest {
50 void InitializeImplOnImpl() override { calls_received_++; }
51
46 void SetVisibleOnImpl(bool visible) override { calls_received_++; } 52 void SetVisibleOnImpl(bool visible) override { calls_received_++; }
47 53
48 void ReceivedRequestNewOutputSurface() override { calls_received_++; } 54 void ReceivedRequestNewOutputSurface() override { calls_received_++; }
49 55
50 void InitializeOutputSurfaceOnImpl(OutputSurface* output_surface) override { 56 void InitializeOutputSurfaceOnImpl(OutputSurface* output_surface) override {
51 calls_received_++; 57 calls_received_++;
52 } 58 }
53 59
54 void ReceivedSetRendererCapabilitiesMainCopy( 60 void ReceivedSetRendererCapabilitiesMainCopy(
55 const RendererCapabilities& capabilities) override { 61 const RendererCapabilities& capabilities) override {
56 calls_received_++; 62 calls_received_++;
57 } 63 }
58 64
59 void ReceivedDidInitializeOutputSurface( 65 void ReceivedDidInitializeOutputSurface(
60 bool success, 66 bool success,
61 const RendererCapabilities& capabilities) override { 67 const RendererCapabilities& capabilities) override {
62 calls_received_++; 68 calls_received_++;
63 EndTest(); 69 EndTest();
64 } 70 }
65 71
72 void WillCloseLayerTreeHostOnImpl() override { calls_received_++; }
66 void FinishGLOnImpl() override { calls_received_++; } 73 void FinishGLOnImpl() override { calls_received_++; }
67 74
68 void AfterTest() override { EXPECT_EQ(6, calls_received_); } 75 void AfterTest() override { EXPECT_EQ(8, calls_received_); }
69 }; 76 };
70 77
71 MULTI_THREAD_DIRECT_RENDERER_TEST_F( 78 MULTI_THREAD_DIRECT_RENDERER_TEST_F(
72 ThreadedChannelTestInitializationAndShutdown); 79 ThreadedChannelTestInitializationAndShutdown);
73 80
74 class ThreadedChannelTestThrottleFrameProduction : public ThreadedChannelTest { 81 class ThreadedChannelTestThrottleFrameProduction : public ThreadedChannelTest {
75 void BeginChannelTest() override { 82 void BeginChannelTest() override {
76 proxy()->SetThrottleFrameProduction(true); 83 proxy()->SetThrottleFrameProduction(true);
77 } 84 }
78 85
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 void AfterTest() override { EXPECT_EQ(1, calls_received_); } 239 void AfterTest() override { EXPECT_EQ(1, calls_received_); }
233 }; 240 };
234 241
235 MULTI_THREAD_DIRECT_RENDERER_TEST_F(ThreadedChannelTestBeginMainFrameAborted); 242 MULTI_THREAD_DIRECT_RENDERER_TEST_F(ThreadedChannelTestBeginMainFrameAborted);
236 243
237 class ThreadedChannelTestBeginMainFrameNotExpectedSoon 244 class ThreadedChannelTestBeginMainFrameNotExpectedSoon
238 : public ThreadedChannelTest { 245 : public ThreadedChannelTest {
239 void BeginChannelTest() override { PostOnImplThread(); } 246 void BeginChannelTest() override { PostOnImplThread(); }
240 247
241 void StartTestOnImplThread() override { 248 void StartTestOnImplThread() override {
242 GetProxyImplForTest()->SendBeginMainFrameNotExpectedSoon(); 249 thread_proxy_->SendBeginMainFrameNotExpectedSoon();
243 } 250 }
244 251
245 void ReceivedBeginMainFrameNotExpectedSoon() override { 252 void ReceivedBeginMainFrameNotExpectedSoon() override {
246 calls_received_++; 253 calls_received_++;
247 EndTest(); 254 EndTest();
248 } 255 }
249 256
250 void AfterTest() override { EXPECT_EQ(1, calls_received_); } 257 void AfterTest() override { EXPECT_EQ(1, calls_received_); }
251 }; 258 };
252 259
253 MULTI_THREAD_DIRECT_RENDERER_TEST_F( 260 MULTI_THREAD_DIRECT_RENDERER_TEST_F(
254 ThreadedChannelTestBeginMainFrameNotExpectedSoon); 261 ThreadedChannelTestBeginMainFrameNotExpectedSoon);
255 262
256 class ThreadedChannelTestSetAnimationEvents : public ThreadedChannelTest { 263 class ThreadedChannelTestSetAnimationEvents : public ThreadedChannelTest {
257 void BeginChannelTest() override { PostOnImplThread(); } 264 void BeginChannelTest() override { PostOnImplThread(); }
258 265
259 void StartTestOnImplThread() override { 266 void StartTestOnImplThread() override {
260 scoped_ptr<AnimationEventsVector> events( 267 scoped_ptr<AnimationEventsVector> events(
261 make_scoped_ptr(new AnimationEventsVector)); 268 make_scoped_ptr(new AnimationEventsVector));
262 GetProxyImplForTest()->PostAnimationEventsToMainThreadOnImplThread( 269 thread_proxy_->PostAnimationEventsToMainThreadOnImplThread(
263 std::move(events)); 270 std::move(events));
264 } 271 }
265 272
266 void ReceivedSetAnimationEvents() override { 273 void ReceivedSetAnimationEvents() override {
267 calls_received_++; 274 calls_received_++;
268 EndTest(); 275 EndTest();
269 } 276 }
270 277
271 void AfterTest() override { EXPECT_EQ(1, calls_received_); } 278 void AfterTest() override { EXPECT_EQ(1, calls_received_); }
272 }; 279 };
273 280
274 MULTI_THREAD_DIRECT_RENDERER_TEST_F(ThreadedChannelTestSetAnimationEvents); 281 MULTI_THREAD_DIRECT_RENDERER_TEST_F(ThreadedChannelTestSetAnimationEvents);
275 282
276 class ThreadedChannelTestLoseOutputSurface : public ThreadedChannelTest { 283 class ThreadedChannelTestLoseOutputSurface : public ThreadedChannelTest {
277 void BeginChannelTest() override { PostOnImplThread(); } 284 void BeginChannelTest() override { PostOnImplThread(); }
278 285
279 void StartTestOnImplThread() override { 286 void StartTestOnImplThread() override {
280 GetProxyImplForTest()->DidLoseOutputSurfaceOnImplThread(); 287 thread_proxy_->DidLoseOutputSurfaceOnImplThread();
281 } 288 }
282 289
283 void ReceivedDidLoseOutputSurface() override { 290 void ReceivedDidLoseOutputSurface() override {
284 calls_received_++; 291 calls_received_++;
285 EndTest(); 292 EndTest();
286 } 293 }
287 294
288 void AfterTest() override { EXPECT_EQ(1, calls_received_); } 295 void AfterTest() override { EXPECT_EQ(1, calls_received_); }
289 }; 296 };
290 297
291 MULTI_THREAD_DIRECT_RENDERER_TEST_F(ThreadedChannelTestLoseOutputSurface); 298 MULTI_THREAD_DIRECT_RENDERER_TEST_F(ThreadedChannelTestLoseOutputSurface);
292 299
293 class ThreadedChannelTestPageScaleAnimation : public ThreadedChannelTest { 300 class ThreadedChannelTestPageScaleAnimation : public ThreadedChannelTest {
294 void BeginChannelTest() override { PostOnImplThread(); } 301 void BeginChannelTest() override { PostOnImplThread(); }
295 302
296 void StartTestOnImplThread() override { 303 void StartTestOnImplThread() override {
297 GetProxyImplForTest()->DidCompletePageScaleAnimationOnImplThread(); 304 thread_proxy_->DidCompletePageScaleAnimationOnImplThread();
298 } 305 }
299 306
300 void ReceivedDidCompletePageScaleAnimation() override { 307 void ReceivedDidCompletePageScaleAnimation() override {
301 calls_received_++; 308 calls_received_++;
302 EndTest(); 309 EndTest();
303 } 310 }
304 311
305 void AfterTest() override { EXPECT_EQ(1, calls_received_); } 312 void AfterTest() override { EXPECT_EQ(1, calls_received_); }
306 }; 313 };
307 314
308 MULTI_THREAD_DIRECT_RENDERER_TEST_F(ThreadedChannelTestPageScaleAnimation); 315 MULTI_THREAD_DIRECT_RENDERER_TEST_F(ThreadedChannelTestPageScaleAnimation);
309 316
310 } // namespace cc 317 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/threaded_channel.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698