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