| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ash/test/ash_test_base.h" | |
| 6 #include "ash/wm/image_grid.h" | |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 5 #include "testing/gtest/include/gtest/gtest.h" |
| 8 #include "third_party/skia/include/core/SkBitmap.h" | 6 #include "third_party/skia/include/core/SkBitmap.h" |
| 7 #include "ui/views/test/views_test_base.h" |
| 9 #include "ui/gfx/image/image.h" | 8 #include "ui/gfx/image/image.h" |
| 9 #include "ui/views/corewm/image_grid.h" |
| 10 | 10 |
| 11 using ash::internal::ImageGrid; | 11 namespace views { |
| 12 | 12 namespace corewm { |
| 13 namespace ash { | |
| 14 namespace test { | |
| 15 | 13 |
| 16 namespace { | 14 namespace { |
| 17 | 15 |
| 18 // Creates a gfx::Image with the requested dimensions. | 16 // Creates a gfx::Image with the requested dimensions. |
| 19 gfx::Image* CreateImage(const gfx::Size& size) { | 17 gfx::Image* CreateImage(const gfx::Size& size) { |
| 20 SkBitmap bitmap; | 18 SkBitmap bitmap; |
| 21 bitmap.setConfig(SkBitmap::kARGB_8888_Config, size.width(), size.height()); | 19 bitmap.setConfig(SkBitmap::kARGB_8888_Config, size.width(), size.height()); |
| 22 return new gfx::Image(bitmap); | 20 return new gfx::Image(bitmap); |
| 23 } | 21 } |
| 24 | 22 |
| 25 } // namespace | 23 } // namespace |
| 26 | 24 |
| 27 typedef ash::test::AshTestBase ImageGridTest; | 25 typedef ViewsTestBase ImageGridTest; |
| 28 | 26 |
| 29 // Test that an ImageGrid's layers are transformed correctly when SetSize() is | 27 // Test that an ImageGrid's layers are transformed correctly when SetSize() is |
| 30 // called. | 28 // called. |
| 31 TEST_F(ImageGridTest, Basic) { | 29 TEST_F(ImageGridTest, Basic) { |
| 32 // Size of the images around the grid's border. | 30 // Size of the images around the grid's border. |
| 33 const int kBorder = 2; | 31 const int kBorder = 2; |
| 34 | 32 |
| 35 scoped_ptr<gfx::Image> image_1x1(CreateImage(gfx::Size(1, 1))); | 33 scoped_ptr<gfx::Image> image_1x1(CreateImage(gfx::Size(1, 1))); |
| 36 scoped_ptr<gfx::Image> image_1xB(CreateImage(gfx::Size(1, kBorder))); | 34 scoped_ptr<gfx::Image> image_1xB(CreateImage(gfx::Size(1, kBorder))); |
| 37 scoped_ptr<gfx::Image> image_Bx1(CreateImage(gfx::Size(kBorder, 1))); | 35 scoped_ptr<gfx::Image> image_Bx1(CreateImage(gfx::Size(kBorder, 1))); |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 EXPECT_TRUE(grid.right_layer()->visible()); | 329 EXPECT_TRUE(grid.right_layer()->visible()); |
| 332 EXPECT_TRUE(grid.center_layer()->visible()); | 330 EXPECT_TRUE(grid.center_layer()->visible()); |
| 333 | 331 |
| 334 // We shouldn't be clipping the corner images anymore. | 332 // We shouldn't be clipping the corner images anymore. |
| 335 EXPECT_TRUE(test_api.top_left_clip_rect().IsEmpty()); | 333 EXPECT_TRUE(test_api.top_left_clip_rect().IsEmpty()); |
| 336 EXPECT_TRUE(test_api.top_right_clip_rect().IsEmpty()); | 334 EXPECT_TRUE(test_api.top_right_clip_rect().IsEmpty()); |
| 337 EXPECT_TRUE(test_api.bottom_left_clip_rect().IsEmpty()); | 335 EXPECT_TRUE(test_api.bottom_left_clip_rect().IsEmpty()); |
| 338 EXPECT_TRUE(test_api.bottom_right_clip_rect().IsEmpty()); | 336 EXPECT_TRUE(test_api.bottom_right_clip_rect().IsEmpty()); |
| 339 } | 337 } |
| 340 | 338 |
| 341 } // namespace test | 339 } // namespace corewm |
| 342 } // namespace ash | 340 } // namespace views |
| OLD | NEW |