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

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

Issue 2752303002: views/mus: Install a mus-friend ContextFactory for tests. (Closed)
Patch Set: . Created 3 years, 9 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 | « ui/compositor/BUILD.gn ('k') | ui/compositor/test/fake_context_factory.h » ('j') | 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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/threading/thread_task_runner_handle.h" 9 #include "base/threading/thread_task_runner_handle.h"
10 #include "cc/output/begin_frame_args.h" 10 #include "cc/output/begin_frame_args.h"
11 #include "cc/surfaces/local_surface_id_allocator.h" 11 #include "cc/surfaces/local_surface_id_allocator.h"
12 #include "cc/surfaces/surface_factory.h" 12 #include "cc/surfaces/surface_factory.h"
13 #include "cc/surfaces/surface_factory_client.h" 13 #include "cc/surfaces/surface_factory_client.h"
14 #include "cc/surfaces/surface_manager.h" 14 #include "cc/surfaces/surface_manager.h"
15 #include "cc/test/begin_frame_args_test.h" 15 #include "cc/test/begin_frame_args_test.h"
16 #include "testing/gmock/include/gmock/gmock.h" 16 #include "testing/gmock/include/gmock/gmock.h"
17 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
18 #include "ui/compositor/compositor.h" 18 #include "ui/compositor/compositor.h"
19 #include "ui/compositor/layer.h" 19 #include "ui/compositor/layer.h"
20 #include "ui/compositor/test/context_factories_for_test.h" 20 #include "ui/compositor/test/context_factories_for_test.h"
21 #include "ui/compositor/test/draw_waiter_for_test.h" 21 #include "ui/compositor/test/draw_waiter_for_test.h"
22 22
23 using testing::Mock; 23 using testing::Mock;
24 using testing::_; 24 using testing::_;
25 25
26 namespace ui { 26 namespace ui {
27 namespace { 27 namespace {
28 28
29 class FakeCompositorFrameSink : public cc::SurfaceFactoryClient {
30 public:
31 FakeCompositorFrameSink(const cc::FrameSinkId& frame_sink_id,
32 cc::SurfaceManager* manager)
33 : frame_sink_id_(frame_sink_id),
34 manager_(manager),
35 source_(nullptr),
36 factory_(frame_sink_id, manager, this) {
37 manager_->RegisterFrameSinkId(frame_sink_id_);
38 manager_->RegisterSurfaceFactoryClient(frame_sink_id_, this);
39 }
40
41 ~FakeCompositorFrameSink() override {
42 manager_->UnregisterSurfaceFactoryClient(frame_sink_id_);
43 manager_->InvalidateFrameSinkId(frame_sink_id_);
44 }
45
46 void ReturnResources(const cc::ReturnedResourceArray& resources) override {}
47 void SetBeginFrameSource(cc::BeginFrameSource* begin_frame_source) override {
48 DCHECK(!source_ || !begin_frame_source);
49 source_ = begin_frame_source;
50 };
51
52 private:
53 const cc::FrameSinkId frame_sink_id_;
54 cc::SurfaceManager* const manager_;
55 cc::BeginFrameSource* source_;
56 cc::SurfaceFactory factory_;
57 };
58
59 ACTION_P2(RemoveObserver, compositor, observer) {
60 compositor->RemoveBeginFrameObserver(observer);
61 }
62
63 // Test fixture for tests that require a ui::Compositor with a real task 29 // Test fixture for tests that require a ui::Compositor with a real task
64 // runner. 30 // runner.
65 class CompositorTest : public testing::Test { 31 class CompositorTest : public testing::Test {
66 public: 32 public:
67 CompositorTest() {} 33 CompositorTest() {}
68 ~CompositorTest() override {} 34 ~CompositorTest() override {}
69 35
70 void SetUp() override { 36 void SetUp() override {
71 task_runner_ = base::ThreadTaskRunnerHandle::Get(); 37 task_runner_ = base::ThreadTaskRunnerHandle::Get();
72 38
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 EXPECT_EQ(gfx::kNullAcceleratedWidget, 119 EXPECT_EQ(gfx::kNullAcceleratedWidget,
154 compositor()->ReleaseAcceleratedWidget()); 120 compositor()->ReleaseAcceleratedWidget());
155 compositor()->SetAcceleratedWidget(gfx::kNullAcceleratedWidget); 121 compositor()->SetAcceleratedWidget(gfx::kNullAcceleratedWidget);
156 compositor()->SetVisible(true); 122 compositor()->SetVisible(true);
157 compositor()->ScheduleDraw(); 123 compositor()->ScheduleDraw();
158 DrawWaiterForTest::WaitForCompositingEnded(compositor()); 124 DrawWaiterForTest::WaitForCompositingEnded(compositor());
159 compositor()->SetRootLayer(nullptr); 125 compositor()->SetRootLayer(nullptr);
160 } 126 }
161 127
162 } // namespace ui 128 } // namespace ui
OLDNEW
« no previous file with comments | « ui/compositor/BUILD.gn ('k') | ui/compositor/test/fake_context_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698