OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "testing/gtest/include/gtest/gtest.h" | 6 #include "testing/gtest/include/gtest/gtest.h" |
7 #include "third_party/skia/include/core/SkCanvas.h" | 7 #include "third_party/skia/include/core/SkCanvas.h" |
8 #include "third_party/skia/include/core/SkColor.h" | 8 #include "third_party/skia/include/core/SkColor.h" |
9 #include "third_party/skia/include/core/SkDevice.h" | 9 #include "third_party/skia/include/core/SkDevice.h" |
10 #include "ui/ozone/platform/dri/crtc_controller.h" | 10 #include "ui/ozone/platform/dri/crtc_controller.h" |
11 #include "ui/ozone/platform/dri/dri_buffer.h" | 11 #include "ui/ozone/platform/dri/dri_buffer.h" |
12 #include "ui/ozone/platform/dri/dri_surface.h" | 12 #include "ui/ozone/platform/dri/dri_surface.h" |
13 #include "ui/ozone/platform/dri/dri_window_delegate.h" | 13 #include "ui/ozone/platform/dri/dri_window_delegate.h" |
14 #include "ui/ozone/platform/dri/hardware_display_controller.h" | 14 #include "ui/ozone/platform/dri/hardware_display_controller.h" |
15 #include "ui/ozone/platform/dri/test/mock_dri_wrapper.h" | 15 #include "ui/ozone/platform/dri/test/mock_drm_device.h" |
16 | 16 |
17 namespace { | 17 namespace { |
18 | 18 |
19 // Create a basic mode for a 6x4 screen. | 19 // Create a basic mode for a 6x4 screen. |
20 const drmModeModeInfo kDefaultMode = | 20 const drmModeModeInfo kDefaultMode = |
21 {0, 6, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, {'\0'}}; | 21 {0, 6, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, {'\0'}}; |
22 | 22 |
23 const uint32_t kDefaultCrtc = 1; | 23 const uint32_t kDefaultCrtc = 1; |
24 const uint32_t kDefaultConnector = 2; | 24 const uint32_t kDefaultConnector = 2; |
25 const size_t kPlanesPerCrtc = 1; | 25 const size_t kPlanesPerCrtc = 1; |
26 | 26 |
27 class MockDriWindowDelegate : public ui::DriWindowDelegate { | 27 class MockDriWindowDelegate : public ui::DriWindowDelegate { |
28 public: | 28 public: |
29 MockDriWindowDelegate(ui::DriWrapper* drm) { | 29 MockDriWindowDelegate(ui::DrmDevice* drm) { |
30 controller_.reset(new ui::HardwareDisplayController(make_scoped_ptr( | 30 controller_.reset(new ui::HardwareDisplayController(make_scoped_ptr( |
31 new ui::CrtcController(drm, kDefaultCrtc, kDefaultConnector)))); | 31 new ui::CrtcController(drm, kDefaultCrtc, kDefaultConnector)))); |
32 scoped_refptr<ui::DriBuffer> buffer(new ui::DriBuffer(drm)); | 32 scoped_refptr<ui::DriBuffer> buffer(new ui::DriBuffer(drm)); |
33 SkImageInfo info = SkImageInfo::MakeN32Premul(kDefaultMode.hdisplay, | 33 SkImageInfo info = SkImageInfo::MakeN32Premul(kDefaultMode.hdisplay, |
34 kDefaultMode.vdisplay); | 34 kDefaultMode.vdisplay); |
35 EXPECT_TRUE(buffer->Initialize(info, true)); | 35 EXPECT_TRUE(buffer->Initialize(info, true)); |
36 EXPECT_TRUE(controller_->Modeset(ui::OverlayPlane(buffer), kDefaultMode)); | 36 EXPECT_TRUE(controller_->Modeset(ui::OverlayPlane(buffer), kDefaultMode)); |
37 } | 37 } |
38 ~MockDriWindowDelegate() override {} | 38 ~MockDriWindowDelegate() override {} |
39 | 39 |
(...skipping 22 matching lines...) Expand all Loading... |
62 | 62 |
63 class DriSurfaceTest : public testing::Test { | 63 class DriSurfaceTest : public testing::Test { |
64 public: | 64 public: |
65 DriSurfaceTest() {} | 65 DriSurfaceTest() {} |
66 | 66 |
67 void SetUp() override; | 67 void SetUp() override; |
68 void TearDown() override; | 68 void TearDown() override; |
69 | 69 |
70 protected: | 70 protected: |
71 scoped_ptr<base::MessageLoop> message_loop_; | 71 scoped_ptr<base::MessageLoop> message_loop_; |
72 scoped_refptr<ui::MockDriWrapper> drm_; | 72 scoped_refptr<ui::MockDrmDevice> drm_; |
73 scoped_ptr<MockDriWindowDelegate> window_delegate_; | 73 scoped_ptr<MockDriWindowDelegate> window_delegate_; |
74 scoped_ptr<ui::DriSurface> surface_; | 74 scoped_ptr<ui::DriSurface> surface_; |
75 | 75 |
76 private: | 76 private: |
77 DISALLOW_COPY_AND_ASSIGN(DriSurfaceTest); | 77 DISALLOW_COPY_AND_ASSIGN(DriSurfaceTest); |
78 }; | 78 }; |
79 | 79 |
80 void DriSurfaceTest::SetUp() { | 80 void DriSurfaceTest::SetUp() { |
81 message_loop_.reset(new base::MessageLoopForUI); | 81 message_loop_.reset(new base::MessageLoopForUI); |
82 std::vector<uint32_t> crtcs; | 82 std::vector<uint32_t> crtcs; |
83 crtcs.push_back(kDefaultCrtc); | 83 crtcs.push_back(kDefaultCrtc); |
84 drm_ = new ui::MockDriWrapper(true, crtcs, kPlanesPerCrtc); | 84 drm_ = new ui::MockDrmDevice(true, crtcs, kPlanesPerCrtc); |
85 window_delegate_.reset(new MockDriWindowDelegate(drm_.get())); | 85 window_delegate_.reset(new MockDriWindowDelegate(drm_.get())); |
86 surface_.reset(new ui::DriSurface(window_delegate_.get())); | 86 surface_.reset(new ui::DriSurface(window_delegate_.get())); |
87 surface_->ResizeCanvas(gfx::Size(kDefaultMode.hdisplay, | 87 surface_->ResizeCanvas(gfx::Size(kDefaultMode.hdisplay, |
88 kDefaultMode.vdisplay)); | 88 kDefaultMode.vdisplay)); |
89 } | 89 } |
90 | 90 |
91 void DriSurfaceTest::TearDown() { | 91 void DriSurfaceTest::TearDown() { |
92 surface_.reset(); | 92 surface_.reset(); |
93 window_delegate_.reset(); | 93 window_delegate_.reset(); |
94 drm_ = nullptr; | 94 drm_ = nullptr; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 // Make sure the updates are correctly propagated to the native surface. | 126 // Make sure the updates are correctly propagated to the native surface. |
127 for (int i = 0; i < image.height(); ++i) { | 127 for (int i = 0; i < image.height(); ++i) { |
128 for (int j = 0; j < image.width(); ++j) { | 128 for (int j = 0; j < image.width(); ++j) { |
129 if (j < kDefaultMode.hdisplay / 2 && i < kDefaultMode.vdisplay / 2) | 129 if (j < kDefaultMode.hdisplay / 2 && i < kDefaultMode.vdisplay / 2) |
130 EXPECT_EQ(SK_ColorWHITE, image.getColor(j, i)); | 130 EXPECT_EQ(SK_ColorWHITE, image.getColor(j, i)); |
131 else | 131 else |
132 EXPECT_EQ(SK_ColorBLACK, image.getColor(j, i)); | 132 EXPECT_EQ(SK_ColorBLACK, image.getColor(j, i)); |
133 } | 133 } |
134 } | 134 } |
135 } | 135 } |
OLD | NEW |