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

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

Issue 304633005: ozone: Add ozone_unittests target (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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"
11 #include "third_party/skia/include/core/SkColor.h" 11 #include "third_party/skia/include/core/SkColor.h"
12 #include "third_party/skia/include/core/SkImageInfo.h"
12 #include "ui/gfx/ozone/surface_factory_ozone.h" 13 #include "ui/gfx/ozone/surface_factory_ozone.h"
13 #include "ui/gfx/ozone/surface_ozone_canvas.h" 14 #include "ui/gfx/ozone/surface_ozone_canvas.h"
14 #include "ui/ozone/platform/dri/dri_buffer.h" 15 #include "ui/ozone/platform/dri/dri_buffer.h"
15 #include "ui/ozone/platform/dri/dri_surface.h" 16 #include "ui/ozone/platform/dri/dri_surface.h"
16 #include "ui/ozone/platform/dri/dri_surface_factory.h" 17 #include "ui/ozone/platform/dri/dri_surface_factory.h"
17 #include "ui/ozone/platform/dri/hardware_display_controller.h" 18 #include "ui/ozone/platform/dri/hardware_display_controller.h"
18 #include "ui/ozone/platform/dri/screen_manager.h" 19 #include "ui/ozone/platform/dri/screen_manager.h"
19 #include "ui/ozone/platform/dri/test/mock_dri_surface.h" 20 #include "ui/ozone/platform/dri/test/mock_dri_surface.h"
20 #include "ui/ozone/platform/dri/test/mock_dri_wrapper.h" 21 #include "ui/ozone/platform/dri/test/mock_dri_wrapper.h"
21 #include "ui/ozone/platform/dri/test/mock_surface_generator.h" 22 #include "ui/ozone/platform/dri/test/mock_surface_generator.h"
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 factory_->InitializeHardware()); 165 factory_->InitializeHardware());
165 166
166 gfx::AcceleratedWidget w = factory_->GetAcceleratedWidget(); 167 gfx::AcceleratedWidget w = factory_->GetAcceleratedWidget();
167 EXPECT_EQ(ui::DriSurfaceFactory::kDefaultWidgetHandle, w); 168 EXPECT_EQ(ui::DriSurfaceFactory::kDefaultWidgetHandle, w);
168 169
169 scoped_ptr<gfx::SurfaceOzoneCanvas> surf = factory_->CreateCanvasForWidget(w); 170 scoped_ptr<gfx::SurfaceOzoneCanvas> surf = factory_->CreateCanvasForWidget(w);
170 EXPECT_TRUE(surf); 171 EXPECT_TRUE(surf);
171 172
172 SkBitmap image; 173 SkBitmap image;
173 SkImageInfo info = SkImageInfo::Make( 174 SkImageInfo info = SkImageInfo::Make(
174 6, 4, kPMColor_SkColorType, kPremul_SkAlphaType); 175 6, 4, kN32_SkColorType, kPremul_SkAlphaType);
175 image.allocPixels(info); 176 image.allocPixels(info);
176 image.eraseColor(SK_ColorWHITE); 177 image.eraseColor(SK_ColorWHITE);
177 178
178 factory_->SetHardwareCursor(w, image, gfx::Point(4, 2)); 179 factory_->SetHardwareCursor(w, image, gfx::Point(4, 2));
179 const std::vector<ui::MockDriSurface*>& surfaces = factory_->get_surfaces(); 180 const std::vector<ui::MockDriSurface*>& surfaces = factory_->get_surfaces();
180 181
181 // The first surface is the cursor surface since it is allocated early in the 182 // The first surface is the cursor surface since it is allocated early in the
182 // initialization process. 183 // initialization process.
183 const std::vector<ui::DriBuffer*>& bitmaps = surfaces[0]->bitmaps(); 184 const std::vector<ui::DriBuffer*>& bitmaps = surfaces[0]->bitmaps();
184 185
185 // The surface should have been initialized to a double-buffered surface. 186 // The surface should have been initialized to a double-buffered surface.
186 EXPECT_EQ(2u, bitmaps.size()); 187 EXPECT_EQ(2u, bitmaps.size());
187 188
188 SkBitmap cursor; 189 SkBitmap cursor;
189 bitmaps[1]->canvas()->readPixels(&cursor, 0, 0); 190 bitmaps[1]->canvas()->readPixels(&cursor, 0, 0);
190 191
191 // Check that the frontbuffer is displaying the right image as set above. 192 // Check that the frontbuffer is displaying the right image as set above.
192 for (int i = 0; i < cursor.height(); ++i) { 193 for (int i = 0; i < cursor.height(); ++i) {
193 for (int j = 0; j < cursor.width(); ++j) { 194 for (int j = 0; j < cursor.width(); ++j) {
194 if (j < info.width() && i < info.height()) 195 if (j < info.width() && i < info.height())
195 EXPECT_EQ(SK_ColorWHITE, cursor.getColor(j, i)); 196 EXPECT_EQ(SK_ColorWHITE, cursor.getColor(j, i));
196 else 197 else
197 EXPECT_EQ(static_cast<SkColor>(SK_ColorTRANSPARENT), 198 EXPECT_EQ(static_cast<SkColor>(SK_ColorTRANSPARENT),
198 cursor.getColor(j, i)); 199 cursor.getColor(j, i));
199 } 200 }
200 } 201 }
201 } 202 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698