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

Side by Side Diff: ui/ozone/platform/dri/dri_surface_factory_unittest.cc

Issue 403043004: [Ozone-DRI] Remove unneeded wrappers (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 5 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 | Annotate | Revision Log
OLDNEW
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 <vector> 5 #include <vector>
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "third_party/skia/include/core/SkCanvas.h" 10 #include "third_party/skia/include/core/SkCanvas.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 TEST_F(DriSurfaceFactoryTest, SuccessfulWidgetRealization) { 91 TEST_F(DriSurfaceFactoryTest, SuccessfulWidgetRealization) {
92 EXPECT_EQ(ui::SurfaceFactoryOzone::INITIALIZED, 92 EXPECT_EQ(ui::SurfaceFactoryOzone::INITIALIZED,
93 factory_->InitializeHardware()); 93 factory_->InitializeHardware());
94 94
95 gfx::AcceleratedWidget w = factory_->GetAcceleratedWidget(); 95 gfx::AcceleratedWidget w = factory_->GetAcceleratedWidget();
96 EXPECT_EQ(ui::DriSurfaceFactory::kDefaultWidgetHandle, w); 96 EXPECT_EQ(ui::DriSurfaceFactory::kDefaultWidgetHandle, w);
97 97
98 EXPECT_TRUE(factory_->CreateCanvasForWidget(w)); 98 EXPECT_TRUE(factory_->CreateCanvasForWidget(w));
99 } 99 }
100 100
101 TEST_F(DriSurfaceFactoryTest, CheckNativeSurfaceContents) {
102 EXPECT_EQ(ui::SurfaceFactoryOzone::INITIALIZED,
103 factory_->InitializeHardware());
104
105 gfx::AcceleratedWidget w = factory_->GetAcceleratedWidget();
106 EXPECT_EQ(ui::DriSurfaceFactory::kDefaultWidgetHandle, w);
107
108 scoped_ptr<ui::SurfaceOzoneCanvas> surface =
109 factory_->CreateCanvasForWidget(w);
110
111 surface->ResizeCanvas(
112 gfx::Size(kDefaultMode.hdisplay, kDefaultMode.vdisplay));
113
114 SkPaint paint;
115 paint.setColor(SK_ColorWHITE);
116 SkRect rect = SkRect::MakeWH(kDefaultMode.hdisplay / 2,
117 kDefaultMode.vdisplay / 2);
118 surface->GetCanvas()->drawRect(rect, paint);
119 surface->PresentCanvas(
120 gfx::Rect(0, 0, kDefaultMode.hdisplay / 2, kDefaultMode.vdisplay / 2));
121
122 SkBitmap image;
123 // Buffers 0 and 1 are the cursor buffers, 2 is the modeset buffer, and
124 // 3 and 4 are the surface buffers.
125 // Buffer 4 is the backbuffer we just painted in, so we want to make sure its
126 // contents are correct.
127 image.setInfo(dri_->buffers()[4]->getCanvas()->imageInfo());
128 EXPECT_TRUE(dri_->buffers()[4]->getCanvas()->readPixels(&image, 0, 0));
129
130 EXPECT_EQ(kDefaultMode.hdisplay, image.width());
131 EXPECT_EQ(kDefaultMode.vdisplay, image.height());
132
133 // Make sure the updates are correctly propagated to the native surface.
134 for (int i = 0; i < image.height(); ++i) {
135 for (int j = 0; j < image.width(); ++j) {
136 if (j < kDefaultMode.hdisplay / 2 && i < kDefaultMode.vdisplay / 2)
137 EXPECT_EQ(SK_ColorWHITE, image.getColor(j, i));
138 else
139 EXPECT_EQ(SK_ColorBLACK, image.getColor(j, i));
140 }
141 }
142 }
143
144 TEST_F(DriSurfaceFactoryTest, SetCursorImage) { 101 TEST_F(DriSurfaceFactoryTest, SetCursorImage) {
145 EXPECT_EQ(ui::SurfaceFactoryOzone::INITIALIZED, 102 EXPECT_EQ(ui::SurfaceFactoryOzone::INITIALIZED,
146 factory_->InitializeHardware()); 103 factory_->InitializeHardware());
147 104
148 gfx::AcceleratedWidget w = factory_->GetAcceleratedWidget(); 105 gfx::AcceleratedWidget w = factory_->GetAcceleratedWidget();
149 EXPECT_EQ(ui::DriSurfaceFactory::kDefaultWidgetHandle, w); 106 EXPECT_EQ(ui::DriSurfaceFactory::kDefaultWidgetHandle, w);
150 107
151 scoped_ptr<ui::SurfaceOzoneCanvas> surf = factory_->CreateCanvasForWidget(w); 108 scoped_ptr<ui::SurfaceOzoneCanvas> surf = factory_->CreateCanvasForWidget(w);
152 EXPECT_TRUE(surf); 109 EXPECT_TRUE(surf);
153 110
(...skipping 14 matching lines...) Expand all
168 for (int i = 0; i < cursor.height(); ++i) { 125 for (int i = 0; i < cursor.height(); ++i) {
169 for (int j = 0; j < cursor.width(); ++j) { 126 for (int j = 0; j < cursor.width(); ++j) {
170 if (j < info.width() && i < info.height()) 127 if (j < info.width() && i < info.height())
171 EXPECT_EQ(SK_ColorWHITE, cursor.getColor(j, i)); 128 EXPECT_EQ(SK_ColorWHITE, cursor.getColor(j, i));
172 else 129 else
173 EXPECT_EQ(static_cast<SkColor>(SK_ColorTRANSPARENT), 130 EXPECT_EQ(static_cast<SkColor>(SK_ColorTRANSPARENT),
174 cursor.getColor(j, i)); 131 cursor.getColor(j, i));
175 } 132 }
176 } 133 }
177 } 134 }
OLDNEW
« no previous file with comments | « ui/ozone/platform/dri/dri_surface_factory.cc ('k') | ui/ozone/platform/dri/dri_surface_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698