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

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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 TEST_F(DriSurfaceFactoryTest, SuccessfulWidgetRealization) { 90 TEST_F(DriSurfaceFactoryTest, SuccessfulWidgetRealization) {
91 EXPECT_EQ(ui::SurfaceFactoryOzone::INITIALIZED, 91 EXPECT_EQ(ui::SurfaceFactoryOzone::INITIALIZED,
92 factory_->InitializeHardware()); 92 factory_->InitializeHardware());
93 93
94 gfx::AcceleratedWidget w = factory_->GetAcceleratedWidget(); 94 gfx::AcceleratedWidget w = factory_->GetAcceleratedWidget();
95 EXPECT_EQ(ui::DriSurfaceFactory::kDefaultWidgetHandle, w); 95 EXPECT_EQ(ui::DriSurfaceFactory::kDefaultWidgetHandle, w);
96 96
97 EXPECT_TRUE(factory_->CreateCanvasForWidget(w)); 97 EXPECT_TRUE(factory_->CreateCanvasForWidget(w));
98 } 98 }
99 99
100 TEST_F(DriSurfaceFactoryTest, CheckNativeSurfaceContents) {
101 EXPECT_EQ(ui::SurfaceFactoryOzone::INITIALIZED,
102 factory_->InitializeHardware());
103
104 gfx::AcceleratedWidget w = factory_->GetAcceleratedWidget();
105 EXPECT_EQ(ui::DriSurfaceFactory::kDefaultWidgetHandle, w);
106
107 scoped_ptr<ui::SurfaceOzoneCanvas> surface =
108 factory_->CreateCanvasForWidget(w);
109
110 surface->ResizeCanvas(
111 gfx::Size(kDefaultMode.hdisplay, kDefaultMode.vdisplay));
112
113 SkPaint paint;
114 paint.setColor(SK_ColorWHITE);
115 SkRect rect = SkRect::MakeWH(kDefaultMode.hdisplay / 2,
116 kDefaultMode.vdisplay / 2);
117 surface->GetCanvas()->drawRect(rect, paint);
118 surface->PresentCanvas(
119 gfx::Rect(0, 0, kDefaultMode.hdisplay / 2, kDefaultMode.vdisplay / 2));
120
121 SkBitmap image;
122 // Buffers 0 and 1 are the cursor buffers, 2 is the modeset buffer, and
123 // 3 and 4 are the surface buffers.
124 // Buffer 4 is the backbuffer we just painted in, so we want to make sure its
125 // contents are correct.
126 image.setInfo(dri_->buffers()[4]->getCanvas()->imageInfo());
127 EXPECT_TRUE(dri_->buffers()[4]->getCanvas()->readPixels(&image, 0, 0));
128
129 EXPECT_EQ(kDefaultMode.hdisplay, image.width());
130 EXPECT_EQ(kDefaultMode.vdisplay, image.height());
131
132 // Make sure the updates are correctly propagated to the native surface.
133 for (int i = 0; i < image.height(); ++i) {
134 for (int j = 0; j < image.width(); ++j) {
135 if (j < kDefaultMode.hdisplay / 2 && i < kDefaultMode.vdisplay / 2)
136 EXPECT_EQ(SK_ColorWHITE, image.getColor(j, i));
137 else
138 EXPECT_EQ(SK_ColorBLACK, image.getColor(j, i));
139 }
140 }
141 }
142
143 TEST_F(DriSurfaceFactoryTest, SetCursorImage) { 100 TEST_F(DriSurfaceFactoryTest, SetCursorImage) {
144 EXPECT_EQ(ui::SurfaceFactoryOzone::INITIALIZED, 101 EXPECT_EQ(ui::SurfaceFactoryOzone::INITIALIZED,
145 factory_->InitializeHardware()); 102 factory_->InitializeHardware());
146 103
147 gfx::AcceleratedWidget w = factory_->GetAcceleratedWidget(); 104 gfx::AcceleratedWidget w = factory_->GetAcceleratedWidget();
148 EXPECT_EQ(ui::DriSurfaceFactory::kDefaultWidgetHandle, w); 105 EXPECT_EQ(ui::DriSurfaceFactory::kDefaultWidgetHandle, w);
149 106
150 scoped_ptr<ui::SurfaceOzoneCanvas> surf = factory_->CreateCanvasForWidget(w); 107 scoped_ptr<ui::SurfaceOzoneCanvas> surf = factory_->CreateCanvasForWidget(w);
151 EXPECT_TRUE(surf); 108 EXPECT_TRUE(surf);
152 109
(...skipping 14 matching lines...) Expand all
167 for (int i = 0; i < cursor.height(); ++i) { 124 for (int i = 0; i < cursor.height(); ++i) {
168 for (int j = 0; j < cursor.width(); ++j) { 125 for (int j = 0; j < cursor.width(); ++j) {
169 if (j < info.width() && i < info.height()) 126 if (j < info.width() && i < info.height())
170 EXPECT_EQ(SK_ColorWHITE, cursor.getColor(j, i)); 127 EXPECT_EQ(SK_ColorWHITE, cursor.getColor(j, i));
171 else 128 else
172 EXPECT_EQ(static_cast<SkColor>(SK_ColorTRANSPARENT), 129 EXPECT_EQ(static_cast<SkColor>(SK_ColorTRANSPARENT),
173 cursor.getColor(j, i)); 130 cursor.getColor(j, i));
174 } 131 }
175 } 132 }
176 } 133 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698