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 1088 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1099 for (int x = 0; is_all_red && x < 500; x++) | 1099 for (int x = 0; is_all_red && x < 500; x++) |
1100 for (int y = 0; is_all_red && y < 500; y++) | 1100 for (int y = 0; is_all_red && y < 500; y++) |
1101 is_all_red = is_all_red && (bitmap.getColor(x, y) == SK_ColorRED); | 1101 is_all_red = is_all_red && (bitmap.getColor(x, y) == SK_ColorRED); |
1102 | 1102 |
1103 EXPECT_TRUE(is_all_red); | 1103 EXPECT_TRUE(is_all_red); |
1104 } | 1104 } |
1105 | 1105 |
1106 // Checks the logic around Compositor::SetRootLayer and Layer::SetCompositor. | 1106 // Checks the logic around Compositor::SetRootLayer and Layer::SetCompositor. |
1107 TEST_F(LayerWithRealCompositorTest, MAYBE_SetRootLayer) { | 1107 TEST_F(LayerWithRealCompositorTest, MAYBE_SetRootLayer) { |
1108 Compositor* compositor = GetCompositor(); | 1108 Compositor* compositor = GetCompositor(); |
1109 Layer l1; | 1109 scoped_ptr<Layer> l1(CreateColorLayer(SK_ColorRED, |
1110 EXPECT_EQ(NULL, l1.GetCompositor()); | 1110 gfx::Rect(20, 20, 400, 400))); |
| 1111 scoped_ptr<Layer> l2(CreateColorLayer(SK_ColorBLUE, |
| 1112 gfx::Rect(10, 10, 350, 350))); |
1111 | 1113 |
1112 Layer l2; | 1114 EXPECT_EQ(NULL, l1->GetCompositor()); |
1113 EXPECT_EQ(NULL, l2.GetCompositor()); | 1115 EXPECT_EQ(NULL, l2->GetCompositor()); |
1114 | 1116 |
1115 compositor->SetRootLayer(&l1); | 1117 compositor->SetRootLayer(l1.get()); |
1116 EXPECT_EQ(compositor, l1.GetCompositor()); | 1118 EXPECT_EQ(compositor, l1->GetCompositor()); |
1117 | 1119 |
1118 l1.Add(&l2); | 1120 l1->Add(l2.get()); |
1119 EXPECT_EQ(compositor, l2.GetCompositor()); | 1121 EXPECT_EQ(compositor, l2->GetCompositor()); |
1120 | 1122 |
1121 l1.Remove(&l2); | 1123 l1->Remove(l2.get()); |
1122 EXPECT_EQ(NULL, l2.GetCompositor()); | 1124 EXPECT_EQ(NULL, l2->GetCompositor()); |
1123 | 1125 |
1124 l1.Add(&l2); | 1126 l1->Add(l2.get()); |
1125 EXPECT_EQ(compositor, l2.GetCompositor()); | 1127 EXPECT_EQ(compositor, l2->GetCompositor()); |
1126 | 1128 |
1127 compositor->SetRootLayer(NULL); | 1129 compositor->SetRootLayer(NULL); |
1128 EXPECT_EQ(NULL, l1.GetCompositor()); | 1130 EXPECT_EQ(NULL, l1->GetCompositor()); |
1129 EXPECT_EQ(NULL, l2.GetCompositor()); | 1131 EXPECT_EQ(NULL, l2->GetCompositor()); |
1130 } | 1132 } |
1131 | 1133 |
1132 // Checks that compositor observers are notified when: | 1134 // Checks that compositor observers are notified when: |
1133 // - DrawTree is called, | 1135 // - DrawTree is called, |
1134 // - After ScheduleDraw is called, or | 1136 // - After ScheduleDraw is called, or |
1135 // - Whenever SetBounds, SetOpacity or SetTransform are called. | 1137 // - Whenever SetBounds, SetOpacity or SetTransform are called. |
1136 // TODO(vollick): could be reorganized into compositor_unittest.cc | 1138 // TODO(vollick): could be reorganized into compositor_unittest.cc |
1137 TEST_F(LayerWithRealCompositorTest, MAYBE_CompositorObservers) { | 1139 TEST_F(LayerWithRealCompositorTest, MAYBE_CompositorObservers) { |
1138 scoped_ptr<Layer> l1(CreateColorLayer(SK_ColorRED, | 1140 scoped_ptr<Layer> l1(CreateColorLayer(SK_ColorRED, |
1139 gfx::Rect(20, 20, 400, 400))); | 1141 gfx::Rect(20, 20, 400, 400))); |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1275 l0->Add(l11.get()); | 1277 l0->Add(l11.get()); |
1276 DrawTree(l0.get()); | 1278 DrawTree(l0.get()); |
1277 SkBitmap bitmap; | 1279 SkBitmap bitmap; |
1278 ASSERT_TRUE(GetCompositor()->ReadPixels(&bitmap)); | 1280 ASSERT_TRUE(GetCompositor()->ReadPixels(&bitmap)); |
1279 ASSERT_FALSE(bitmap.empty()); | 1281 ASSERT_FALSE(bitmap.empty()); |
1280 // WritePNGFile(bitmap, ref_img); | 1282 // WritePNGFile(bitmap, ref_img); |
1281 EXPECT_TRUE(IsSameAsPNGFile(bitmap, ref_img)); | 1283 EXPECT_TRUE(IsSameAsPNGFile(bitmap, ref_img)); |
1282 } | 1284 } |
1283 | 1285 |
1284 } // namespace ui | 1286 } // namespace ui |
OLD | NEW |