OLD | NEW |
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.h" | 5 #include "base/message_loop/message_loop.h" |
6 #include "base/run_loop.h" | 6 #include "base/run_loop.h" |
7 #include "base/single_thread_task_runner.h" | 7 #include "base/single_thread_task_runner.h" |
8 #include "cc/test/fake_output_surface_client.h" | 8 #include "cc/test/fake_output_surface_client.h" |
9 #include "cc/test/test_context_provider.h" | 9 #include "cc/test/test_context_provider.h" |
10 #include "cc/test/test_web_graphics_context_3d.h" | 10 #include "cc/test/test_web_graphics_context_3d.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 | 82 |
83 #if defined(OS_MACOSX) | 83 #if defined(OS_MACOSX) |
84 void OnSurfaceDisplayed() override {} | 84 void OnSurfaceDisplayed() override {} |
85 void OnSurfaceRecycled() override {} | 85 void OnSurfaceRecycled() override {} |
86 bool ShouldNotShowFramesAfterRecycle() const override { return false; } | 86 bool ShouldNotShowFramesAfterRecycle() const override { return false; } |
87 #endif | 87 #endif |
88 | 88 |
89 gfx::Size SurfaceSize() const override { return gfx::Size(256, 256); } | 89 gfx::Size SurfaceSize() const override { return gfx::Size(256, 256); } |
90 }; | 90 }; |
91 | 91 |
92 const gfx::Rect kSubRect(0, 0, 64, 64); | 92 const gfx::Rect kSubRect = gfx::Rect(0, 0, 64, 64); |
| 93 const SkIRect kSkSubRect = SkIRect::MakeXYWH(0, 0, 64, 64); |
93 | 94 |
94 } // namespace | 95 } // namespace |
95 | 96 |
96 class ReflectorImplTest : public testing::Test { | 97 class ReflectorImplTest : public testing::Test { |
97 public: | 98 public: |
98 void SetUp() override { | 99 void SetUp() override { |
99 bool enable_pixel_output = false; | 100 bool enable_pixel_output = false; |
100 ui::ContextFactory* context_factory = | 101 ui::ContextFactory* context_factory = |
101 ui::InitializeContextFactoryForTests(enable_pixel_output); | 102 ui::InitializeContextFactoryForTests(enable_pixel_output); |
102 ImageTransportFactory::InitializeForUnitTests( | 103 ImageTransportFactory::InitializeForUnitTests( |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 scoped_ptr<ReflectorImpl> reflector_; | 152 scoped_ptr<ReflectorImpl> reflector_; |
152 scoped_ptr<TestOutputSurface> output_surface_; | 153 scoped_ptr<TestOutputSurface> output_surface_; |
153 }; | 154 }; |
154 | 155 |
155 namespace { | 156 namespace { |
156 TEST_F(ReflectorImplTest, CheckNormalOutputSurface) { | 157 TEST_F(ReflectorImplTest, CheckNormalOutputSurface) { |
157 output_surface_->SetFlip(false); | 158 output_surface_->SetFlip(false); |
158 SetUpReflector(); | 159 SetUpReflector(); |
159 UpdateTexture(); | 160 UpdateTexture(); |
160 EXPECT_TRUE(mirroring_layer_->TextureFlipped()); | 161 EXPECT_TRUE(mirroring_layer_->TextureFlipped()); |
161 gfx::Rect expected_rect = | 162 EXPECT_EQ(SkRegion(SkIRect::MakeXYWH( |
162 kSubRect + gfx::Vector2d(0, output_surface_->SurfaceSize().height()) - | 163 0, output_surface_->SurfaceSize().height() - kSubRect.height(), |
163 gfx::Vector2d(0, kSubRect.height()); | 164 kSubRect.width(), kSubRect.height())), |
164 EXPECT_EQ(expected_rect, mirroring_layer_->damaged_region()); | 165 mirroring_layer_->damaged_region()); |
165 } | 166 } |
166 | 167 |
167 TEST_F(ReflectorImplTest, CheckInvertedOutputSurface) { | 168 TEST_F(ReflectorImplTest, CheckInvertedOutputSurface) { |
168 output_surface_->SetFlip(true); | 169 output_surface_->SetFlip(true); |
169 SetUpReflector(); | 170 SetUpReflector(); |
170 UpdateTexture(); | 171 UpdateTexture(); |
171 EXPECT_FALSE(mirroring_layer_->TextureFlipped()); | 172 EXPECT_FALSE(mirroring_layer_->TextureFlipped()); |
172 EXPECT_EQ(kSubRect, mirroring_layer_->damaged_region()); | 173 EXPECT_EQ(SkRegion(kSkSubRect), mirroring_layer_->damaged_region()); |
173 } | 174 } |
174 | 175 |
175 #if defined(USE_OZONE) | 176 #if defined(USE_OZONE) |
176 TEST_F(ReflectorImplTest, CheckOverlayNoReflector) { | 177 TEST_F(ReflectorImplTest, CheckOverlayNoReflector) { |
177 cc::OverlayCandidateList list; | 178 cc::OverlayCandidateList list; |
178 cc::OverlayCandidate plane_1, plane_2; | 179 cc::OverlayCandidate plane_1, plane_2; |
179 plane_1.plane_z_order = 0; | 180 plane_1.plane_z_order = 0; |
180 plane_2.plane_z_order = 1; | 181 plane_2.plane_z_order = 1; |
181 list.push_back(plane_1); | 182 list.push_back(plane_1); |
182 list.push_back(plane_2); | 183 list.push_back(plane_2); |
183 output_surface_->GetOverlayCandidateValidator()->CheckOverlaySupport(&list); | 184 output_surface_->GetOverlayCandidateValidator()->CheckOverlaySupport(&list); |
184 EXPECT_TRUE(list[0].overlay_handled); | 185 EXPECT_TRUE(list[0].overlay_handled); |
185 } | 186 } |
186 | 187 |
187 TEST_F(ReflectorImplTest, CheckOverlaySWMirroring) { | 188 TEST_F(ReflectorImplTest, CheckOverlaySWMirroring) { |
188 SetUpReflector(); | 189 SetUpReflector(); |
189 cc::OverlayCandidateList list; | 190 cc::OverlayCandidateList list; |
190 cc::OverlayCandidate plane_1, plane_2; | 191 cc::OverlayCandidate plane_1, plane_2; |
191 plane_1.plane_z_order = 0; | 192 plane_1.plane_z_order = 0; |
192 plane_2.plane_z_order = 1; | 193 plane_2.plane_z_order = 1; |
193 list.push_back(plane_1); | 194 list.push_back(plane_1); |
194 list.push_back(plane_2); | 195 list.push_back(plane_2); |
195 output_surface_->GetOverlayCandidateValidator()->CheckOverlaySupport(&list); | 196 output_surface_->GetOverlayCandidateValidator()->CheckOverlaySupport(&list); |
196 EXPECT_FALSE(list[0].overlay_handled); | 197 EXPECT_FALSE(list[0].overlay_handled); |
197 } | 198 } |
198 #endif // defined(USE_OZONE) | 199 #endif // defined(USE_OZONE) |
199 | 200 |
200 } // namespace | 201 } // namespace |
201 } // namespace content | 202 } // namespace content |
OLD | NEW |