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 "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" |
11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
| 12 #include "base/stringprintf.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h" |
13 #include "ui/compositor/compositor_observer.h" | 15 #include "ui/compositor/compositor_observer.h" |
| 16 #include "ui/compositor/compositor_setup.h" |
| 17 #include "ui/compositor/dip_util.h" |
14 #include "ui/compositor/layer.h" | 18 #include "ui/compositor/layer.h" |
15 #include "ui/compositor/layer_animation_sequence.h" | 19 #include "ui/compositor/layer_animation_sequence.h" |
16 #include "ui/compositor/test/test_compositor_host.h" | 20 #include "ui/compositor/test/test_compositor_host.h" |
17 #include "ui/gfx/canvas.h" | 21 #include "ui/gfx/canvas.h" |
18 #include "ui/gfx/codec/png_codec.h" | 22 #include "ui/gfx/codec/png_codec.h" |
19 #include "ui/gfx/gfx_paths.h" | 23 #include "ui/gfx/gfx_paths.h" |
20 #include "ui/gfx/skia_util.h" | 24 #include "ui/gfx/skia_util.h" |
21 | 25 |
22 #include "ui/compositor/compositor_setup.h" | |
23 | |
24 namespace ui { | 26 namespace ui { |
25 | 27 |
26 namespace { | 28 namespace { |
27 | 29 |
28 // Encodes a bitmap into a PNG and write to disk. Returns true on success. The | 30 // Encodes a bitmap into a PNG and write to disk. Returns true on success. The |
29 // parent directory does not have to exist. | 31 // parent directory does not have to exist. |
30 bool WritePNGFile(const SkBitmap& bitmap, const FilePath& file_path) { | 32 bool WritePNGFile(const SkBitmap& bitmap, const FilePath& file_path) { |
31 std::vector<unsigned char> png_data; | 33 std::vector<unsigned char> png_data; |
32 if (gfx::PNGCodec::EncodeBGRASkBitmap(bitmap, true, &png_data) && | 34 if (gfx::PNGCodec::EncodeBGRASkBitmap(bitmap, true, &png_data) && |
33 file_util::CreateDirectory(file_path.DirName())) { | 35 file_util::CreateDirectory(file_path.DirName())) { |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 explicit TestLayerDelegate() : color_index_(0) {} | 215 explicit TestLayerDelegate() : color_index_(0) {} |
214 virtual ~TestLayerDelegate() {} | 216 virtual ~TestLayerDelegate() {} |
215 | 217 |
216 void AddColor(SkColor color) { | 218 void AddColor(SkColor color) { |
217 colors_.push_back(color); | 219 colors_.push_back(color); |
218 } | 220 } |
219 | 221 |
220 const gfx::Size& paint_size() const { return paint_size_; } | 222 const gfx::Size& paint_size() const { return paint_size_; } |
221 int color_index() const { return color_index_; } | 223 int color_index() const { return color_index_; } |
222 | 224 |
| 225 std::string ToScaleString() const { |
| 226 return StringPrintf("%.1f %.1f", scale_x_, scale_y_); |
| 227 } |
| 228 |
223 // Overridden from LayerDelegate: | 229 // Overridden from LayerDelegate: |
224 virtual void OnPaintLayer(gfx::Canvas* canvas) OVERRIDE { | 230 virtual void OnPaintLayer(gfx::Canvas* canvas) OVERRIDE { |
225 SkBitmap contents = canvas->ExtractBitmap(); | 231 SkBitmap contents = canvas->ExtractBitmap(); |
226 paint_size_ = gfx::Size(contents.width(), contents.height()); | 232 paint_size_ = gfx::Size(contents.width(), contents.height()); |
227 canvas->FillRect(gfx::Rect(paint_size_), colors_[color_index_]); | 233 canvas->FillRect(gfx::Rect(paint_size_), colors_[color_index_]); |
228 color_index_ = (color_index_ + 1) % static_cast<int>(colors_.size()); | 234 color_index_ = (color_index_ + 1) % static_cast<int>(colors_.size()); |
| 235 const SkMatrix& matrix = canvas->sk_canvas()->getTotalMatrix(); |
| 236 scale_x_ = matrix.getScaleX(); |
| 237 scale_y_ = matrix.getScaleY(); |
229 } | 238 } |
230 | 239 |
231 private: | 240 private: |
232 std::vector<SkColor> colors_; | 241 std::vector<SkColor> colors_; |
233 int color_index_; | 242 int color_index_; |
234 gfx::Size paint_size_; | 243 gfx::Size paint_size_; |
| 244 float scale_x_; |
| 245 float scale_y_; |
235 | 246 |
236 DISALLOW_COPY_AND_ASSIGN(TestLayerDelegate); | 247 DISALLOW_COPY_AND_ASSIGN(TestLayerDelegate); |
237 }; | 248 }; |
238 | 249 |
239 // LayerDelegate that verifies that a layer was asked to update its canvas. | 250 // LayerDelegate that verifies that a layer was asked to update its canvas. |
240 class DrawTreeLayerDelegate : public LayerDelegate { | 251 class DrawTreeLayerDelegate : public LayerDelegate { |
241 public: | 252 public: |
242 DrawTreeLayerDelegate() : painted_(false) {} | 253 DrawTreeLayerDelegate() : painted_(false) {} |
243 virtual ~DrawTreeLayerDelegate() {} | 254 virtual ~DrawTreeLayerDelegate() {} |
244 | 255 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 #define MAYBE_Delegate DISABLED_Delegate | 319 #define MAYBE_Delegate DISABLED_Delegate |
309 #define MAYBE_Draw DISABLED_Draw | 320 #define MAYBE_Draw DISABLED_Draw |
310 #define MAYBE_DrawTree DISABLED_DrawTree | 321 #define MAYBE_DrawTree DISABLED_DrawTree |
311 #define MAYBE_Hierarchy DISABLED_Hierarchy | 322 #define MAYBE_Hierarchy DISABLED_Hierarchy |
312 #define MAYBE_HierarchyNoTexture DISABLED_HierarchyNoTexture | 323 #define MAYBE_HierarchyNoTexture DISABLED_HierarchyNoTexture |
313 #define MAYBE_DrawPixels DISABLED_DrawPixels | 324 #define MAYBE_DrawPixels DISABLED_DrawPixels |
314 #define MAYBE_SetRootLayer DISABLED_SetRootLayer | 325 #define MAYBE_SetRootLayer DISABLED_SetRootLayer |
315 #define MAYBE_CompositorObservers DISABLED_CompositorObservers | 326 #define MAYBE_CompositorObservers DISABLED_CompositorObservers |
316 #define MAYBE_ModifyHierarchy DISABLED_ModifyHierarchy | 327 #define MAYBE_ModifyHierarchy DISABLED_ModifyHierarchy |
317 #define MAYBE_Opacity DISABLED_Opacity | 328 #define MAYBE_Opacity DISABLED_Opacity |
| 329 #define MAYBE_ScaleUpDown DISABLED_ScaleUpDown |
| 330 #define MAYBE_ScaleReparent DISABLED_ScaleReparent |
| 331 #define MAYBE_NoScaleCanvas DISABLED_NoScaleCanvas |
318 #else | 332 #else |
319 #define MAYBE_Delegate DISABLED_Delegate | 333 #define MAYBE_Delegate DISABLED_Delegate |
320 #define MAYBE_Draw Draw | 334 #define MAYBE_Draw Draw |
321 #define MAYBE_DrawTree DISABLED_DrawTree | 335 #define MAYBE_DrawTree DISABLED_DrawTree |
322 #define MAYBE_Hierarchy Hierarchy | 336 #define MAYBE_Hierarchy Hierarchy |
323 #define MAYBE_HierarchyNoTexture DISABLED_HierarchyNoTexture | 337 #define MAYBE_HierarchyNoTexture DISABLED_HierarchyNoTexture |
324 #define MAYBE_DrawPixels DrawPixels | 338 #define MAYBE_DrawPixels DrawPixels |
325 #define MAYBE_SetRootLayer SetRootLayer | 339 #define MAYBE_SetRootLayer SetRootLayer |
326 #define MAYBE_CompositorObservers DISABLED_CompositorObservers | 340 #define MAYBE_CompositorObservers DISABLED_CompositorObservers |
327 #define MAYBE_ModifyHierarchy ModifyHierarchy | 341 #define MAYBE_ModifyHierarchy ModifyHierarchy |
328 #define MAYBE_Opacity Opacity | 342 #define MAYBE_Opacity Opacity |
| 343 #define MAYBE_ScaleUpDown ScaleUpDown |
| 344 #define MAYBE_ScaleReparent ScaleReparent |
| 345 #define MAYBE_NoScaleCanvas NoScaleCanvas |
329 #endif | 346 #endif |
330 | 347 |
331 TEST_F(LayerWithRealCompositorTest, MAYBE_Draw) { | 348 TEST_F(LayerWithRealCompositorTest, MAYBE_Draw) { |
332 scoped_ptr<Layer> layer(CreateColorLayer(SK_ColorRED, | 349 scoped_ptr<Layer> layer(CreateColorLayer(SK_ColorRED, |
333 gfx::Rect(20, 20, 50, 50))); | 350 gfx::Rect(20, 20, 50, 50))); |
334 DrawTree(layer.get()); | 351 DrawTree(layer.get()); |
335 } | 352 } |
336 | 353 |
337 // Create this hierarchy: | 354 // Create this hierarchy: |
338 // L1 - red | 355 // L1 - red |
(...skipping 20 matching lines...) Expand all Loading... |
359 | 376 |
360 class LayerWithDelegateTest : public testing::Test, public CompositorDelegate { | 377 class LayerWithDelegateTest : public testing::Test, public CompositorDelegate { |
361 public: | 378 public: |
362 LayerWithDelegateTest() : schedule_draw_invoked_(false) {} | 379 LayerWithDelegateTest() : schedule_draw_invoked_(false) {} |
363 virtual ~LayerWithDelegateTest() {} | 380 virtual ~LayerWithDelegateTest() {} |
364 | 381 |
365 // Overridden from testing::Test: | 382 // Overridden from testing::Test: |
366 virtual void SetUp() OVERRIDE { | 383 virtual void SetUp() OVERRIDE { |
367 ui::SetupTestCompositor(); | 384 ui::SetupTestCompositor(); |
368 compositor_.reset(new Compositor( | 385 compositor_.reset(new Compositor( |
369 this, gfx::kNullAcceleratedWidget, gfx::Size(1000, 1000))); | 386 this, gfx::kNullAcceleratedWidget)); |
| 387 compositor_->SetScaleAndSize(1.0f, gfx::Size(1000, 1000)); |
370 } | 388 } |
371 | 389 |
372 virtual void TearDown() OVERRIDE { | 390 virtual void TearDown() OVERRIDE { |
373 } | 391 } |
374 | 392 |
375 Compositor* compositor() { return compositor_.get(); } | 393 Compositor* compositor() { return compositor_.get(); } |
376 | 394 |
377 virtual Layer* CreateLayer(LayerType type) { | 395 virtual Layer* CreateLayer(LayerType type) { |
378 return new Layer(type); | 396 return new Layer(type); |
379 } | 397 } |
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
850 | 868 |
851 // Opacity changes should no longer alert the removed observer. | 869 // Opacity changes should no longer alert the removed observer. |
852 observer.Reset(); | 870 observer.Reset(); |
853 l2->SetOpacity(0.5f); | 871 l2->SetOpacity(0.5f); |
854 RunPendingMessages(); | 872 RunPendingMessages(); |
855 EXPECT_FALSE(observer.notified()); | 873 EXPECT_FALSE(observer.notified()); |
856 } | 874 } |
857 | 875 |
858 // Checks that modifying the hierarchy correctly affects final composite. | 876 // Checks that modifying the hierarchy correctly affects final composite. |
859 TEST_F(LayerWithRealCompositorTest, MAYBE_ModifyHierarchy) { | 877 TEST_F(LayerWithRealCompositorTest, MAYBE_ModifyHierarchy) { |
860 GetCompositor()->WidgetSizeChanged(gfx::Size(50, 50)); | 878 GetCompositor()->SetScaleAndSize(1.0f, gfx::Size(50, 50)); |
861 | 879 |
862 // l0 | 880 // l0 |
863 // +-l11 | 881 // +-l11 |
864 // | +-l21 | 882 // | +-l21 |
865 // +-l12 | 883 // +-l12 |
866 scoped_ptr<Layer> l0(CreateColorLayer(SK_ColorRED, | 884 scoped_ptr<Layer> l0(CreateColorLayer(SK_ColorRED, |
867 gfx::Rect(0, 0, 50, 50))); | 885 gfx::Rect(0, 0, 50, 50))); |
868 scoped_ptr<Layer> l11(CreateColorLayer(SK_ColorGREEN, | 886 scoped_ptr<Layer> l11(CreateColorLayer(SK_ColorGREEN, |
869 gfx::Rect(0, 0, 25, 25))); | 887 gfx::Rect(0, 0, 25, 25))); |
870 scoped_ptr<Layer> l21(CreateColorLayer(SK_ColorMAGENTA, | 888 scoped_ptr<Layer> l21(CreateColorLayer(SK_ColorMAGENTA, |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
910 l0->StackAbove(l12.get(), l11.get()); | 928 l0->StackAbove(l12.get(), l11.get()); |
911 DrawTree(l0.get()); | 929 DrawTree(l0.get()); |
912 ASSERT_TRUE(ReadPixels(&bitmap)); | 930 ASSERT_TRUE(ReadPixels(&bitmap)); |
913 ASSERT_FALSE(bitmap.empty()); | 931 ASSERT_FALSE(bitmap.empty()); |
914 EXPECT_TRUE(IsSameAsPNGFile(bitmap, ref_img1)); | 932 EXPECT_TRUE(IsSameAsPNGFile(bitmap, ref_img1)); |
915 } | 933 } |
916 | 934 |
917 // Opacity is rendered correctly. | 935 // Opacity is rendered correctly. |
918 // Checks that modifying the hierarchy correctly affects final composite. | 936 // Checks that modifying the hierarchy correctly affects final composite. |
919 TEST_F(LayerWithRealCompositorTest, MAYBE_Opacity) { | 937 TEST_F(LayerWithRealCompositorTest, MAYBE_Opacity) { |
920 GetCompositor()->WidgetSizeChanged(gfx::Size(50, 50)); | 938 GetCompositor()->SetScaleAndSize(1.0f, gfx::Size(50, 50)); |
921 | 939 |
922 // l0 | 940 // l0 |
923 // +-l11 | 941 // +-l11 |
924 scoped_ptr<Layer> l0(CreateColorLayer(SK_ColorRED, | 942 scoped_ptr<Layer> l0(CreateColorLayer(SK_ColorRED, |
925 gfx::Rect(0, 0, 50, 50))); | 943 gfx::Rect(0, 0, 50, 50))); |
926 scoped_ptr<Layer> l11(CreateColorLayer(SK_ColorGREEN, | 944 scoped_ptr<Layer> l11(CreateColorLayer(SK_ColorGREEN, |
927 gfx::Rect(0, 0, 25, 25))); | 945 gfx::Rect(0, 0, 25, 25))); |
928 | 946 |
929 FilePath ref_img = test_data_directory().AppendASCII("Opacity.png"); | 947 FilePath ref_img = test_data_directory().AppendASCII("Opacity.png"); |
930 | 948 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1014 // ScheduleDraw() should have been invoked. | 1032 // ScheduleDraw() should have been invoked. |
1015 EXPECT_TRUE(schedule_draw_invoked_); | 1033 EXPECT_TRUE(schedule_draw_invoked_); |
1016 // Because SchedulePaint() was invoked from OnPaintLayer() |child| should | 1034 // Because SchedulePaint() was invoked from OnPaintLayer() |child| should |
1017 // still need to be painted. | 1035 // still need to be painted. |
1018 DrawTree(root.get()); | 1036 DrawTree(root.get()); |
1019 EXPECT_EQ(1, child_delegate.GetPaintCountAndClear()); | 1037 EXPECT_EQ(1, child_delegate.GetPaintCountAndClear()); |
1020 EXPECT_TRUE(child_delegate.last_clip_rect().Contains( | 1038 EXPECT_TRUE(child_delegate.last_clip_rect().Contains( |
1021 gfx::Rect(10, 10, 30, 30))); | 1039 gfx::Rect(10, 10, 30, 30))); |
1022 } | 1040 } |
1023 | 1041 |
| 1042 TEST_F(LayerWithRealCompositorTest, MAYBE_ScaleUpDown) { |
| 1043 test::ScopedDIPEnablerForTest enable; |
| 1044 |
| 1045 scoped_ptr<Layer> root(CreateColorLayer(SK_ColorWHITE, |
| 1046 gfx::Rect(10, 20, 200, 220))); |
| 1047 TestLayerDelegate root_delegate; |
| 1048 root_delegate.AddColor(SK_ColorWHITE); |
| 1049 root->set_delegate(&root_delegate); |
| 1050 |
| 1051 scoped_ptr<Layer> l1(CreateColorLayer(SK_ColorWHITE, |
| 1052 gfx::Rect(10, 20, 140, 180))); |
| 1053 TestLayerDelegate l1_delegate; |
| 1054 l1_delegate.AddColor(SK_ColorWHITE); |
| 1055 l1->set_delegate(&l1_delegate); |
| 1056 |
| 1057 GetCompositor()->SetScaleAndSize(1.0f, gfx::Size(500, 500)); |
| 1058 GetCompositor()->SetRootLayer(root.get()); |
| 1059 root->Add(l1.get()); |
| 1060 RunPendingMessages(); |
| 1061 |
| 1062 EXPECT_EQ("10,20 200x220", root->bounds().ToString()); |
| 1063 EXPECT_EQ("10,20 140x180", l1->bounds().ToString()); |
| 1064 gfx::Size size_in_pixel = root->web_layer().bounds(); |
| 1065 EXPECT_EQ("200x220", size_in_pixel.ToString()); |
| 1066 size_in_pixel = l1->web_layer().bounds(); |
| 1067 EXPECT_EQ("140x180", size_in_pixel.ToString()); |
| 1068 |
| 1069 SchedulePaintForLayer(root.get()); |
| 1070 SchedulePaintForLayer(l1.get()); |
| 1071 RunPendingMessages(); |
| 1072 |
| 1073 EXPECT_EQ("200x220", root_delegate.paint_size().ToString()); |
| 1074 EXPECT_EQ("140x180", l1_delegate.paint_size().ToString()); |
| 1075 |
| 1076 // Scale up to 2.0. Changing scale doesn't change the bounds in DIP. |
| 1077 GetCompositor()->SetScaleAndSize(2.0f, gfx::Size(500, 500)); |
| 1078 EXPECT_EQ("10,20 200x220", root->bounds().ToString()); |
| 1079 EXPECT_EQ("10,20 140x180", l1->bounds().ToString()); |
| 1080 // Pixel size must have been scaled up. |
| 1081 size_in_pixel = root->web_layer().bounds(); |
| 1082 EXPECT_EQ("400x440", size_in_pixel.ToString()); |
| 1083 size_in_pixel = l1->web_layer().bounds(); |
| 1084 EXPECT_EQ("280x360", size_in_pixel.ToString()); |
| 1085 |
| 1086 // Canvas size must have been scaled down up. |
| 1087 SchedulePaintForLayer(root.get()); |
| 1088 SchedulePaintForLayer(l1.get()); |
| 1089 RunPendingMessages(); |
| 1090 EXPECT_EQ("400x440", root_delegate.paint_size().ToString()); |
| 1091 EXPECT_EQ("2.0 2.0", root_delegate.ToScaleString()); |
| 1092 EXPECT_EQ("280x360", l1_delegate.paint_size().ToString()); |
| 1093 EXPECT_EQ("2.0 2.0", l1_delegate.ToScaleString()); |
| 1094 |
| 1095 // Scale down back to 1.0f. |
| 1096 GetCompositor()->SetScaleAndSize(1.0f, gfx::Size(500, 500)); |
| 1097 EXPECT_EQ("10,20 200x220", root->bounds().ToString()); |
| 1098 EXPECT_EQ("10,20 140x180", l1->bounds().ToString()); |
| 1099 // Pixel size must have been scaled down. |
| 1100 size_in_pixel = root->web_layer().bounds(); |
| 1101 EXPECT_EQ("200x220", size_in_pixel.ToString()); |
| 1102 size_in_pixel = l1->web_layer().bounds(); |
| 1103 EXPECT_EQ("140x180", size_in_pixel.ToString()); |
| 1104 |
| 1105 // Canvas size must have been scaled down too. |
| 1106 SchedulePaintForLayer(root.get()); |
| 1107 SchedulePaintForLayer(l1.get()); |
| 1108 RunPendingMessages(); |
| 1109 EXPECT_EQ("200x220", root_delegate.paint_size().ToString()); |
| 1110 EXPECT_EQ("1.0 1.0", root_delegate.ToScaleString()); |
| 1111 EXPECT_EQ("140x180", l1_delegate.paint_size().ToString()); |
| 1112 EXPECT_EQ("1.0 1.0", l1_delegate.ToScaleString()); |
| 1113 } |
| 1114 |
| 1115 TEST_F(LayerWithRealCompositorTest, MAYBE_ScaleReparent) { |
| 1116 test::ScopedDIPEnablerForTest enable; |
| 1117 scoped_ptr<Layer> root(CreateColorLayer(SK_ColorWHITE, |
| 1118 gfx::Rect(10, 20, 200, 220))); |
| 1119 scoped_ptr<Layer> l1(CreateColorLayer(SK_ColorWHITE, |
| 1120 gfx::Rect(10, 20, 140, 180))); |
| 1121 TestLayerDelegate l1_delegate; |
| 1122 l1_delegate.AddColor(SK_ColorWHITE); |
| 1123 l1->set_delegate(&l1_delegate); |
| 1124 |
| 1125 GetCompositor()->SetScaleAndSize(1.0f, gfx::Size(500, 500)); |
| 1126 GetCompositor()->SetRootLayer(root.get()); |
| 1127 RunPendingMessages(); |
| 1128 |
| 1129 root->Add(l1.get()); |
| 1130 EXPECT_EQ("10,20 140x180", l1->bounds().ToString()); |
| 1131 gfx::Size size_in_pixel = l1->web_layer().bounds(); |
| 1132 EXPECT_EQ("140x180", size_in_pixel.ToString()); |
| 1133 |
| 1134 SchedulePaintForLayer(l1.get()); |
| 1135 RunPendingMessages(); |
| 1136 EXPECT_EQ("140x180", l1_delegate.paint_size().ToString()); |
| 1137 EXPECT_EQ("1.0 1.0", l1_delegate.ToScaleString()); |
| 1138 |
| 1139 // Remove l1 from root and change the scale. |
| 1140 root->Remove(l1.get()); |
| 1141 EXPECT_EQ(NULL, l1->parent()); |
| 1142 EXPECT_EQ(NULL, l1->GetCompositor()); |
| 1143 GetCompositor()->SetScaleAndSize(2.0f, gfx::Size(500, 500)); |
| 1144 // Sanity check on root and l1. |
| 1145 EXPECT_EQ("10,20 200x220", root->bounds().ToString()); |
| 1146 size_in_pixel = l1->web_layer().bounds(); |
| 1147 EXPECT_EQ("140x180", size_in_pixel.ToString()); |
| 1148 |
| 1149 |
| 1150 root->Add(l1.get()); |
| 1151 EXPECT_EQ("10,20 140x180", l1->bounds().ToString()); |
| 1152 size_in_pixel = l1->web_layer().bounds(); |
| 1153 EXPECT_EQ("280x360", size_in_pixel.ToString()); |
| 1154 SchedulePaintForLayer(l1.get()); |
| 1155 RunPendingMessages(); |
| 1156 EXPECT_EQ("280x360", l1_delegate.paint_size().ToString()); |
| 1157 EXPECT_EQ("2.0 2.0", l1_delegate.ToScaleString()); |
| 1158 } |
| 1159 |
| 1160 // Tests layer::set_scale_canvas(false). |
| 1161 TEST_F(LayerWithRealCompositorTest, MAYBE_NoScaleCanvas) { |
| 1162 test::ScopedDIPEnablerForTest enable; |
| 1163 scoped_ptr<Layer> root(CreateColorLayer(SK_ColorWHITE, |
| 1164 gfx::Rect(10, 20, 200, 220))); |
| 1165 scoped_ptr<Layer> l1(CreateColorLayer(SK_ColorWHITE, |
| 1166 gfx::Rect(10, 20, 140, 180))); |
| 1167 l1->set_scale_canvas(false); |
| 1168 root->Add(l1.get()); |
| 1169 TestLayerDelegate l1_delegate; |
| 1170 l1_delegate.AddColor(SK_ColorWHITE); |
| 1171 l1->set_delegate(&l1_delegate); |
| 1172 |
| 1173 GetCompositor()->SetScaleAndSize(2.0f, gfx::Size(500, 500)); |
| 1174 GetCompositor()->SetRootLayer(root.get()); |
| 1175 |
| 1176 SchedulePaintForLayer(l1.get()); |
| 1177 RunPendingMessages(); |
| 1178 EXPECT_EQ("280x360", l1_delegate.paint_size().ToString()); |
| 1179 EXPECT_EQ("1.0 1.0", l1_delegate.ToScaleString()); |
| 1180 } |
| 1181 |
1024 } // namespace ui | 1182 } // namespace ui |
OLD | NEW |