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

Side by Side Diff: ui/compositor/compositor_unittest.cc

Issue 1063823007: Stop Using MessageLoopProxy in Test Since It's Deprecated (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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
« no previous file with comments | « no previous file | 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 2015 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 "base/message_loop/message_loop_proxy.h"
6 #include "base/run_loop.h" 5 #include "base/run_loop.h"
6 #include "base/thread_task_runner_handle.h"
7 #include "cc/output/begin_frame_args.h" 7 #include "cc/output/begin_frame_args.h"
8 #include "cc/test/begin_frame_args_test.h" 8 #include "cc/test/begin_frame_args_test.h"
9 #include "testing/gmock/include/gmock/gmock.h" 9 #include "testing/gmock/include/gmock/gmock.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 #include "ui/compositor/compositor.h" 11 #include "ui/compositor/compositor.h"
12 #include "ui/compositor/test/context_factories_for_test.h" 12 #include "ui/compositor/test/context_factories_for_test.h"
13 13
14 using testing::Mock; 14 using testing::Mock;
15 using testing::_; 15 using testing::_;
16 16
17 namespace ui { 17 namespace ui {
18 namespace { 18 namespace {
19 19
20 class MockCompositorBeginFrameObserver : public CompositorBeginFrameObserver { 20 class MockCompositorBeginFrameObserver : public CompositorBeginFrameObserver {
21 public: 21 public:
22 MOCK_METHOD1(OnSendBeginFrame, void(const cc::BeginFrameArgs&)); 22 MOCK_METHOD1(OnSendBeginFrame, void(const cc::BeginFrameArgs&));
23 }; 23 };
24 24
25 // Test fixture for tests that require a ui::Compositor with a real task 25 // Test fixture for tests that require a ui::Compositor with a real task
26 // runner. 26 // runner.
27 class CompositorTest : public testing::Test { 27 class CompositorTest : public testing::Test {
28 public: 28 public:
29 CompositorTest() {} 29 CompositorTest() {}
30 ~CompositorTest() override {} 30 ~CompositorTest() override {}
31 31
32 void SetUp() override { 32 void SetUp() override {
33 task_runner_ = base::MessageLoopProxy::current(); 33 task_runner_ = base::ThreadTaskRunnerHandle::Get();
danakj 2015/04/22 19:34:04 This might DCHECK if you didn't make a MessageLoop
34 34
35 ui::ContextFactory* context_factory = 35 ui::ContextFactory* context_factory =
36 ui::InitializeContextFactoryForTests(false); 36 ui::InitializeContextFactoryForTests(false);
37 37
38 compositor_.reset(new ui::Compositor(gfx::kNullAcceleratedWidget, 38 compositor_.reset(new ui::Compositor(gfx::kNullAcceleratedWidget,
39 context_factory, task_runner_)); 39 context_factory, task_runner_));
40 } 40 }
41 void TearDown() override { 41 void TearDown() override {
42 compositor_.reset(); 42 compositor_.reset();
43 ui::TerminateContextFactoryForTests(); 43 ui::TerminateContextFactoryForTests();
44 } 44 }
45 45
46 protected: 46 protected:
47 base::MessageLoopProxy* task_runner() { return task_runner_.get(); } 47 base::SingleThreadTaskRunner* task_runner() { return task_runner_.get(); }
48 ui::Compositor* compositor() { return compositor_.get(); } 48 ui::Compositor* compositor() { return compositor_.get(); }
49 49
50 private: 50 private:
51 scoped_refptr<base::MessageLoopProxy> task_runner_; 51 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
52 scoped_ptr<ui::Compositor> compositor_; 52 scoped_ptr<ui::Compositor> compositor_;
53 53
54 DISALLOW_COPY_AND_ASSIGN(CompositorTest); 54 DISALLOW_COPY_AND_ASSIGN(CompositorTest);
55 }; 55 };
56 56
57 } // namespace 57 } // namespace
58 58
59 TEST_F(CompositorTest, LocksTimeOut) { 59 TEST_F(CompositorTest, LocksTimeOut) {
60 scoped_refptr<ui::CompositorLock> lock; 60 scoped_refptr<ui::CompositorLock> lock;
61 { 61 {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 EXPECT_CALL(test_observer2, OnSendBeginFrame(_)).Times(0); 119 EXPECT_CALL(test_observer2, OnSendBeginFrame(_)).Times(0);
120 compositor()->RemoveBeginFrameObserver(&test_observer); 120 compositor()->RemoveBeginFrameObserver(&test_observer);
121 compositor()->RemoveBeginFrameObserver(&test_observer2); 121 compositor()->RemoveBeginFrameObserver(&test_observer2);
122 compositor()->AddBeginFrameObserver(&test_observer2); 122 compositor()->AddBeginFrameObserver(&test_observer2);
123 Mock::VerifyAndClearExpectations(&test_observer2); 123 Mock::VerifyAndClearExpectations(&test_observer2);
124 124
125 compositor()->RemoveBeginFrameObserver(&test_observer2); 125 compositor()->RemoveBeginFrameObserver(&test_observer2);
126 } 126 }
127 127
128 } // namespace ui 128 } // namespace ui
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698