OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
6 #include "base/message_loop/message_loop.h" | 6 #include "base/message_loop/message_loop.h" |
7 #include "cc/output/software_frame_data.h" | 7 #include "cc/output/software_frame_data.h" |
8 #include "content/browser/aura/software_output_device_ozone.h" | 8 #include "content/browser/aura/software_output_device_ozone.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 #include "third_party/skia/include/core/SkBitmapDevice.h" | 10 #include "third_party/skia/include/core/SkBitmapDevice.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/gfx/ozone/surface_factory_ozone.h" | 13 #include "ui/gfx/ozone/surface_factory_ozone.h" |
13 #include "ui/gfx/size.h" | 14 #include "ui/gfx/size.h" |
14 #include "ui/gfx/skia_util.h" | 15 #include "ui/gfx/skia_util.h" |
15 #include "ui/gl/gl_implementation.h" | 16 #include "ui/gl/gl_implementation.h" |
16 | 17 |
17 namespace { | 18 namespace { |
18 | 19 |
19 class MockSurfaceFactoryOzone : public gfx::SurfaceFactoryOzone { | 20 class MockSurfaceFactoryOzone : public gfx::SurfaceFactoryOzone { |
20 public: | 21 public: |
21 MockSurfaceFactoryOzone() {} | 22 MockSurfaceFactoryOzone() {} |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 | 77 |
77 SoftwareOutputDeviceOzoneTest::SoftwareOutputDeviceOzoneTest() { | 78 SoftwareOutputDeviceOzoneTest::SoftwareOutputDeviceOzoneTest() { |
78 CHECK(gfx::InitializeGLBindings(gfx::kGLImplementationOSMesaGL)); | 79 CHECK(gfx::InitializeGLBindings(gfx::kGLImplementationOSMesaGL)); |
79 message_loop_.reset(new base::MessageLoop(base::MessageLoop::TYPE_UI)); | 80 message_loop_.reset(new base::MessageLoop(base::MessageLoop::TYPE_UI)); |
80 } | 81 } |
81 | 82 |
82 SoftwareOutputDeviceOzoneTest::~SoftwareOutputDeviceOzoneTest() { | 83 SoftwareOutputDeviceOzoneTest::~SoftwareOutputDeviceOzoneTest() { |
83 } | 84 } |
84 | 85 |
85 void SoftwareOutputDeviceOzoneTest::SetUp() { | 86 void SoftwareOutputDeviceOzoneTest::SetUp() { |
86 ui::Compositor::InitializeContextFactoryForTests(false); | 87 ui::InitializeContextFactoryForTests(false); |
87 ui::Compositor::Initialize(); | 88 ui::Compositor::Initialize(); |
88 | 89 |
89 surface_factory_.reset(new MockSurfaceFactoryOzone()); | 90 surface_factory_.reset(new MockSurfaceFactoryOzone()); |
90 gfx::SurfaceFactoryOzone::SetInstance(surface_factory_.get()); | 91 gfx::SurfaceFactoryOzone::SetInstance(surface_factory_.get()); |
91 | 92 |
92 const gfx::Size size(500, 400); | 93 const gfx::Size size(500, 400); |
93 compositor_.reset(new ui::Compositor(gfx::SurfaceFactoryOzone::GetInstance() | 94 compositor_.reset(new ui::Compositor(gfx::SurfaceFactoryOzone::GetInstance() |
94 ->GetAcceleratedWidget())); | 95 ->GetAcceleratedWidget())); |
95 compositor_->SetScaleAndSize(1.0f, size); | 96 compositor_->SetScaleAndSize(1.0f, size); |
96 | 97 |
97 output_device_.reset(new content::SoftwareOutputDeviceOzone( | 98 output_device_.reset(new content::SoftwareOutputDeviceOzone( |
98 compositor_.get())); | 99 compositor_.get())); |
99 output_device_->Resize(size); | 100 output_device_->Resize(size); |
100 } | 101 } |
101 | 102 |
102 void SoftwareOutputDeviceOzoneTest::TearDown() { | 103 void SoftwareOutputDeviceOzoneTest::TearDown() { |
103 output_device_.reset(); | 104 output_device_.reset(); |
104 compositor_.reset(); | 105 compositor_.reset(); |
105 surface_factory_.reset(); | 106 surface_factory_.reset(); |
| 107 ui::TerminateContextFactoryForTests(); |
106 ui::Compositor::Terminate(); | 108 ui::Compositor::Terminate(); |
107 } | 109 } |
108 | 110 |
109 TEST_F(SoftwareOutputDeviceOzoneTest, CheckClipAfterBeginPaint) { | 111 TEST_F(SoftwareOutputDeviceOzoneTest, CheckClipAfterBeginPaint) { |
110 gfx::Rect damage(10, 10, 100, 100); | 112 gfx::Rect damage(10, 10, 100, 100); |
111 SkCanvas* canvas = output_device_->BeginPaint(damage); | 113 SkCanvas* canvas = output_device_->BeginPaint(damage); |
112 | 114 |
113 SkIRect sk_bounds; | 115 SkIRect sk_bounds; |
114 canvas->getClipDeviceBounds(&sk_bounds); | 116 canvas->getClipDeviceBounds(&sk_bounds); |
115 | 117 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 // painted. | 182 // painted. |
181 for (int i = 0; i < area.height(); ++i) { | 183 for (int i = 0; i < area.height(); ++i) { |
182 for (int j = 0; j < area.width(); ++j) { | 184 for (int j = 0; j < area.width(); ++j) { |
183 if (j < damage.width() && i < damage.height()) | 185 if (j < damage.width() && i < damage.height()) |
184 EXPECT_EQ(SK_ColorWHITE, bitmap.getColor(j, i)); | 186 EXPECT_EQ(SK_ColorWHITE, bitmap.getColor(j, i)); |
185 else | 187 else |
186 EXPECT_EQ(SK_ColorBLACK, bitmap.getColor(j, i)); | 188 EXPECT_EQ(SK_ColorBLACK, bitmap.getColor(j, i)); |
187 } | 189 } |
188 } | 190 } |
189 } | 191 } |
OLD | NEW |