OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/compiler_specific.h" | 6 #include "base/compiler_specific.h" |
7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 989 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1000 l1->SetBounds(gfx::Rect(5, 5, 100, 100)); | 1000 l1->SetBounds(gfx::Rect(5, 5, 100, 100)); |
1001 | 1001 |
1002 // The CompositorDelegate (us) should have been told to draw for a resize. | 1002 // The CompositorDelegate (us) should have been told to draw for a resize. |
1003 EXPECT_TRUE(schedule_draw_invoked_); | 1003 EXPECT_TRUE(schedule_draw_invoked_); |
1004 } | 1004 } |
1005 | 1005 |
1006 // Checks that pixels are actually drawn to the screen with a read back. | 1006 // Checks that pixels are actually drawn to the screen with a read back. |
1007 TEST_F(LayerWithRealCompositorTest, MAYBE_DrawPixels) { | 1007 TEST_F(LayerWithRealCompositorTest, MAYBE_DrawPixels) { |
1008 scoped_ptr<Layer> layer(CreateColorLayer(SK_ColorRED, | 1008 scoped_ptr<Layer> layer(CreateColorLayer(SK_ColorRED, |
1009 gfx::Rect(0, 0, 500, 500))); | 1009 gfx::Rect(0, 0, 500, 500))); |
| 1010 scoped_ptr<Layer> layer2(CreateColorLayer(SK_ColorBLUE, |
| 1011 gfx::Rect(0, 0, 500, 10))); |
| 1012 |
| 1013 layer->Add(layer2.get()); |
| 1014 |
1010 DrawTree(layer.get()); | 1015 DrawTree(layer.get()); |
1011 | 1016 |
1012 SkBitmap bitmap; | 1017 SkBitmap bitmap; |
1013 ASSERT_TRUE(GetCompositor()->ReadPixels(&bitmap)); | 1018 gfx::Size size = GetCompositor()->size(); |
| 1019 ASSERT_TRUE(GetCompositor()->ReadPixels(&bitmap, |
| 1020 gfx::Rect(0, 10, |
| 1021 size.width(), size.height() - 10))); |
1014 ASSERT_FALSE(bitmap.empty()); | 1022 ASSERT_FALSE(bitmap.empty()); |
1015 | 1023 |
1016 SkAutoLockPixels lock(bitmap); | 1024 SkAutoLockPixels lock(bitmap); |
1017 bool is_all_red = true; | 1025 bool is_all_red = true; |
1018 for (int x = 0; is_all_red && x < 500; x++) | 1026 for (int x = 0; is_all_red && x < 500; x++) |
1019 for (int y = 0; is_all_red && y < 500; y++) | 1027 for (int y = 0; is_all_red && y < 490; y++) |
1020 is_all_red = is_all_red && (bitmap.getColor(x, y) == SK_ColorRED); | 1028 is_all_red = is_all_red && (bitmap.getColor(x, y) == SK_ColorRED); |
1021 | 1029 |
1022 EXPECT_TRUE(is_all_red); | 1030 EXPECT_TRUE(is_all_red); |
1023 } | 1031 } |
1024 | 1032 |
1025 // Checks the logic around Compositor::SetRootLayer and Layer::SetCompositor. | 1033 // Checks the logic around Compositor::SetRootLayer and Layer::SetCompositor. |
1026 TEST_F(LayerWithRealCompositorTest, MAYBE_SetRootLayer) { | 1034 TEST_F(LayerWithRealCompositorTest, MAYBE_SetRootLayer) { |
1027 Compositor* compositor = GetCompositor(); | 1035 Compositor* compositor = GetCompositor(); |
1028 Layer l1; | 1036 Layer l1; |
1029 EXPECT_EQ(NULL, l1.GetCompositor()); | 1037 EXPECT_EQ(NULL, l1.GetCompositor()); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1111 GetCompositor()->RemoveObserver(&observer); | 1119 GetCompositor()->RemoveObserver(&observer); |
1112 | 1120 |
1113 // Opacity changes should no longer alert the removed observer. | 1121 // Opacity changes should no longer alert the removed observer. |
1114 observer.Reset(); | 1122 observer.Reset(); |
1115 l2->SetOpacity(0.5f); | 1123 l2->SetOpacity(0.5f); |
1116 RunPendingMessages(); | 1124 RunPendingMessages(); |
1117 EXPECT_FALSE(observer.notified()); | 1125 EXPECT_FALSE(observer.notified()); |
1118 } | 1126 } |
1119 | 1127 |
1120 } // namespace ui | 1128 } // namespace ui |
OLD | NEW |