Index: ui/ozone/platform/dri/dri_surface_factory_unittest.cc |
diff --git a/ui/ozone/platform/dri/dri_surface_factory_unittest.cc b/ui/ozone/platform/dri/dri_surface_factory_unittest.cc |
index 13d81cbc84ef221a26d7d5d1bc8762db7ce20dba..e5bf3c0ddc661df8e6744ec53f805dc3ccbd3d55 100644 |
--- a/ui/ozone/platform/dri/dri_surface_factory_unittest.cc |
+++ b/ui/ozone/platform/dri/dri_surface_factory_unittest.cc |
@@ -15,7 +15,6 @@ |
#include "ui/ozone/platform/dri/dri_surface_factory.h" |
#include "ui/ozone/platform/dri/hardware_display_controller.h" |
#include "ui/ozone/platform/dri/screen_manager.h" |
-#include "ui/ozone/platform/dri/test/mock_dri_surface.h" |
#include "ui/ozone/platform/dri/test/mock_dri_wrapper.h" |
#include "ui/ozone/platform/dri/test/mock_surface_generator.h" |
#include "ui/ozone/public/surface_factory_ozone.h" |
@@ -26,33 +25,6 @@ namespace { |
const drmModeModeInfo kDefaultMode = |
{0, 6, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, {'\0'}}; |
-// SSFO would normally allocate DRM resources. We can't rely on having a DRM |
-// backend to allocate and display our buffers. Thus, we replace these |
-// resources with stubs. For DRM calls, we simply use stubs that do nothing and |
-// for buffers we use the default SkBitmap allocator. |
-class MockDriSurfaceFactory : public ui::DriSurfaceFactory { |
- public: |
- MockDriSurfaceFactory(ui::DriWrapper* dri, ui::ScreenManager* screen_manager) |
- : DriSurfaceFactory(dri, screen_manager), dri_(dri) {} |
- virtual ~MockDriSurfaceFactory() {}; |
- |
- const std::vector<ui::MockDriSurface*>& get_surfaces() const { |
- return surfaces_; |
- } |
- |
- private: |
- virtual ui::DriSurface* CreateSurface(const gfx::Size& size) OVERRIDE { |
- ui::MockDriSurface* surface = new ui::MockDriSurface(dri_, size); |
- surfaces_.push_back(surface); |
- return surface; |
- } |
- |
- ui::DriWrapper* dri_; |
- std::vector<ui::MockDriSurface*> surfaces_; // Not owned. |
- |
- DISALLOW_COPY_AND_ASSIGN(MockDriSurfaceFactory); |
-}; |
- |
class MockScreenManager : public ui::ScreenManager { |
public: |
MockScreenManager(ui::DriWrapper* dri, |
@@ -69,7 +41,6 @@ class MockScreenManager : public ui::ScreenManager { |
private: |
ui::DriWrapper* dri_; // Not owned. |
- std::vector<ui::MockDriSurface*> surfaces_; // Not owned. |
DISALLOW_COPY_AND_ASSIGN(MockScreenManager); |
}; |
@@ -87,7 +58,7 @@ class DriSurfaceFactoryTest : public testing::Test { |
scoped_ptr<ui::MockDriWrapper> dri_; |
scoped_ptr<ui::MockSurfaceGenerator> surface_generator_; |
scoped_ptr<MockScreenManager> screen_manager_; |
- scoped_ptr<MockDriSurfaceFactory> factory_; |
+ scoped_ptr<ui::DriSurfaceFactory> factory_; |
private: |
DISALLOW_COPY_AND_ASSIGN(DriSurfaceFactoryTest); |
@@ -99,7 +70,7 @@ void DriSurfaceFactoryTest::SetUp() { |
surface_generator_.reset(new ui::MockSurfaceGenerator(dri_.get())); |
screen_manager_.reset(new MockScreenManager(dri_.get(), |
surface_generator_.get())); |
- factory_.reset(new MockDriSurfaceFactory(dri_.get(), screen_manager_.get())); |
+ factory_.reset(new ui::DriSurfaceFactory(dri_.get(), screen_manager_.get())); |
} |
void DriSurfaceFactoryTest::TearDown() { |
@@ -139,15 +110,24 @@ TEST_F(DriSurfaceFactoryTest, CheckNativeSurfaceContents) { |
surface->ResizeCanvas( |
gfx::Size(kDefaultMode.hdisplay, kDefaultMode.vdisplay)); |
- surface->GetCanvas()->drawColor(SK_ColorWHITE); |
+ |
+ SkPaint paint; |
+ paint.setColor(SK_ColorWHITE); |
+ SkRect rect = SkRect::MakeWH(kDefaultMode.hdisplay / 2, |
+ kDefaultMode.vdisplay / 2); |
+ surface->GetCanvas()->drawRect(rect, paint); |
surface->PresentCanvas( |
gfx::Rect(0, 0, kDefaultMode.hdisplay / 2, kDefaultMode.vdisplay / 2)); |
- const std::vector<ui::DriBuffer*>& bitmaps = |
- surface_generator_->surfaces()[0]->bitmaps(); |
- |
SkBitmap image; |
- bitmaps[1]->canvas()->readPixels(&image, 0, 0); |
+ // Buffers 0 and 1 are the cursor buffers and 2 and 3 are the surface buffers. |
+ // Buffer 3 is the backbuffer we just painted in, so we want to make sure its |
+ // contents are correct. |
+ image.setInfo(dri_->buffers()[3]->getCanvas()->imageInfo()); |
+ EXPECT_TRUE(dri_->buffers()[3]->getCanvas()->readPixels(&image, 0, 0)); |
+ |
+ EXPECT_EQ(kDefaultMode.hdisplay, image.width()); |
+ EXPECT_EQ(kDefaultMode.vdisplay, image.height()); |
// Make sure the updates are correctly propagated to the native surface. |
for (int i = 0; i < image.height(); ++i) { |
@@ -177,17 +157,11 @@ TEST_F(DriSurfaceFactoryTest, SetCursorImage) { |
image.eraseColor(SK_ColorWHITE); |
factory_->SetHardwareCursor(w, image, gfx::Point(4, 2)); |
- const std::vector<ui::MockDriSurface*>& surfaces = factory_->get_surfaces(); |
- |
- // The first surface is the cursor surface since it is allocated early in the |
- // initialization process. |
- const std::vector<ui::DriBuffer*>& bitmaps = surfaces[0]->bitmaps(); |
- |
- // The surface should have been initialized to a double-buffered surface. |
- EXPECT_EQ(2u, bitmaps.size()); |
SkBitmap cursor; |
- bitmaps[1]->canvas()->readPixels(&cursor, 0, 0); |
+ // Buffers 0 and 1 are the cursor buffers. |
+ cursor.setInfo(dri_->buffers()[1]->getCanvas()->imageInfo()); |
+ EXPECT_TRUE(dri_->buffers()[1]->getCanvas()->readPixels(&cursor, 0, 0)); |
// Check that the frontbuffer is displaying the right image as set above. |
for (int i = 0; i < cursor.height(); ++i) { |