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

Side by Side Diff: cc/surfaces/display_unittest.cc

Issue 1673783004: Hook up BeginFrameSource to SurfaceFactoryClient via SurfaceManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Register id namespace on Android Created 4 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 | « cc/surfaces/display.cc ('k') | cc/surfaces/surface.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 "cc/surfaces/display.h" 5 #include "cc/surfaces/display.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/test/null_task_runner.h" 9 #include "base/test/null_task_runner.h"
10 #include "cc/output/compositor_frame.h" 10 #include "cc/output/compositor_frame.h"
(...skipping 17 matching lines...) Expand all
28 28
29 namespace cc { 29 namespace cc {
30 namespace { 30 namespace {
31 31
32 class FakeSurfaceFactoryClient : public SurfaceFactoryClient { 32 class FakeSurfaceFactoryClient : public SurfaceFactoryClient {
33 public: 33 public:
34 FakeSurfaceFactoryClient() : begin_frame_source_(nullptr) {} 34 FakeSurfaceFactoryClient() : begin_frame_source_(nullptr) {}
35 35
36 void ReturnResources(const ReturnedResourceArray& resources) override {} 36 void ReturnResources(const ReturnedResourceArray& resources) override {}
37 37
38 void SetBeginFrameSource(SurfaceId surface_id, 38 void SetBeginFrameSource(BeginFrameSource* begin_frame_source) override {
39 BeginFrameSource* begin_frame_source) override {
40 begin_frame_source_ = begin_frame_source; 39 begin_frame_source_ = begin_frame_source;
41 } 40 }
42 41
43 BeginFrameSource* begin_frame_source() { return begin_frame_source_; } 42 BeginFrameSource* begin_frame_source() { return begin_frame_source_; }
44 43
45 private: 44 private:
46 BeginFrameSource* begin_frame_source_; 45 BeginFrameSource* begin_frame_source_;
47 }; 46 };
48 47
49 class TestSoftwareOutputDevice : public SoftwareOutputDevice { 48 class TestSoftwareOutputDevice : public SoftwareOutputDevice {
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 bool damaged; 146 bool damaged;
148 bool display_resized_; 147 bool display_resized_;
149 bool has_new_root_surface; 148 bool has_new_root_surface;
150 bool swapped; 149 bool swapped;
151 }; 150 };
152 151
153 void CopyCallback(bool* called, scoped_ptr<CopyOutputResult> result) { 152 void CopyCallback(bool* called, scoped_ptr<CopyOutputResult> result) {
154 *called = true; 153 *called = true;
155 } 154 }
156 155
157 // Verify Display responds to SurfaceAggregatorClient methods properly.
158 TEST_F(DisplayTest, DisplayAsSurfaceAggregatorClient) {
159 SetUpContext(nullptr);
160 TestDisplayClient client;
161 RendererSettings settings;
162 Display display(&client, &manager_, shared_bitmap_manager_.get(), nullptr,
163 settings);
164
165 TestDisplayScheduler scheduler(&display, &fake_begin_frame_source_,
166 task_runner_.get());
167 display.Initialize(std::move(output_surface_), &scheduler);
168
169 SurfaceId surface_id(6);
170 factory_.Create(surface_id);
171 Surface* surface = manager_.GetSurfaceForId(surface_id);
172
173 EXPECT_EQ(nullptr, surface_factory_client_.begin_frame_source());
174 display.AddSurface(surface);
175 EXPECT_NE(nullptr, surface_factory_client_.begin_frame_source());
176 display.RemoveSurface(surface);
177 EXPECT_EQ(nullptr, surface_factory_client_.begin_frame_source());
178 }
179
180 // Check that frame is damaged and swapped only under correct conditions. 156 // Check that frame is damaged and swapped only under correct conditions.
181 TEST_F(DisplayTest, DisplayDamaged) { 157 TEST_F(DisplayTest, DisplayDamaged) {
182 SetUpContext(nullptr); 158 SetUpContext(nullptr);
183 TestDisplayClient client; 159 TestDisplayClient client;
184 RendererSettings settings; 160 RendererSettings settings;
185 settings.partial_swap_enabled = true; 161 settings.partial_swap_enabled = true;
186 settings.finish_rendering_on_resize = true; 162 settings.finish_rendering_on_resize = true;
187 Display display(&client, &manager_, shared_bitmap_manager_.get(), nullptr, 163 Display display(&client, &manager_, shared_bitmap_manager_.get(), nullptr,
188 settings); 164 settings);
189 165
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 482
507 EXPECT_CALL(*context_ptr, shallowFinishCHROMIUM()); 483 EXPECT_CALL(*context_ptr, shallowFinishCHROMIUM());
508 display.Resize(gfx::Size(250, 250)); 484 display.Resize(gfx::Size(250, 250));
509 testing::Mock::VerifyAndClearExpectations(context_ptr); 485 testing::Mock::VerifyAndClearExpectations(context_ptr);
510 486
511 factory_.Destroy(surface_id); 487 factory_.Destroy(surface_id);
512 } 488 }
513 489
514 } // namespace 490 } // namespace
515 } // namespace cc 491 } // namespace cc
OLDNEW
« no previous file with comments | « cc/surfaces/display.cc ('k') | cc/surfaces/surface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698