| 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 "base/stringprintf.h" |
| 13 #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" | 14 #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h" |
| 15 #include "ui/compositor/compositor_observer.h" | 15 #include "ui/compositor/compositor_observer.h" |
| 16 #include "ui/compositor/compositor_setup.h" | 16 #include "ui/compositor/compositor_setup.h" |
| 17 #include "ui/compositor/dip_util.h" | |
| 18 #include "ui/compositor/layer.h" | 17 #include "ui/compositor/layer.h" |
| 19 #include "ui/compositor/layer_animation_sequence.h" | 18 #include "ui/compositor/layer_animation_sequence.h" |
| 20 #include "ui/compositor/test/test_compositor_host.h" | 19 #include "ui/compositor/test/test_compositor_host.h" |
| 21 #include "ui/gfx/canvas.h" | 20 #include "ui/gfx/canvas.h" |
| 22 #include "ui/gfx/codec/png_codec.h" | 21 #include "ui/gfx/codec/png_codec.h" |
| 23 #include "ui/gfx/gfx_paths.h" | 22 #include "ui/gfx/gfx_paths.h" |
| 24 #include "ui/gfx/skia_util.h" | 23 #include "ui/gfx/skia_util.h" |
| 25 | 24 |
| 26 namespace ui { | 25 namespace ui { |
| 27 | 26 |
| (...skipping 1031 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1059 EXPECT_TRUE(schedule_draw_invoked_); | 1058 EXPECT_TRUE(schedule_draw_invoked_); |
| 1060 // Because SchedulePaint() was invoked from OnPaintLayer() |child| should | 1059 // Because SchedulePaint() was invoked from OnPaintLayer() |child| should |
| 1061 // still need to be painted. | 1060 // still need to be painted. |
| 1062 DrawTree(root.get()); | 1061 DrawTree(root.get()); |
| 1063 EXPECT_EQ(1, child_delegate.GetPaintCountAndClear()); | 1062 EXPECT_EQ(1, child_delegate.GetPaintCountAndClear()); |
| 1064 EXPECT_TRUE(child_delegate.last_clip_rect().Contains( | 1063 EXPECT_TRUE(child_delegate.last_clip_rect().Contains( |
| 1065 gfx::Rect(10, 10, 30, 30))); | 1064 gfx::Rect(10, 10, 30, 30))); |
| 1066 } | 1065 } |
| 1067 | 1066 |
| 1068 TEST_F(LayerWithRealCompositorTest, MAYBE_ScaleUpDown) { | 1067 TEST_F(LayerWithRealCompositorTest, MAYBE_ScaleUpDown) { |
| 1069 test::ScopedDIPEnablerForTest enable; | |
| 1070 | |
| 1071 scoped_ptr<Layer> root(CreateColorLayer(SK_ColorWHITE, | 1068 scoped_ptr<Layer> root(CreateColorLayer(SK_ColorWHITE, |
| 1072 gfx::Rect(10, 20, 200, 220))); | 1069 gfx::Rect(10, 20, 200, 220))); |
| 1073 TestLayerDelegate root_delegate; | 1070 TestLayerDelegate root_delegate; |
| 1074 root_delegate.AddColor(SK_ColorWHITE); | 1071 root_delegate.AddColor(SK_ColorWHITE); |
| 1075 root->set_delegate(&root_delegate); | 1072 root->set_delegate(&root_delegate); |
| 1076 | 1073 |
| 1077 scoped_ptr<Layer> l1(CreateColorLayer(SK_ColorWHITE, | 1074 scoped_ptr<Layer> l1(CreateColorLayer(SK_ColorWHITE, |
| 1078 gfx::Rect(10, 20, 140, 180))); | 1075 gfx::Rect(10, 20, 140, 180))); |
| 1079 TestLayerDelegate l1_delegate; | 1076 TestLayerDelegate l1_delegate; |
| 1080 l1_delegate.AddColor(SK_ColorWHITE); | 1077 l1_delegate.AddColor(SK_ColorWHITE); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1148 EXPECT_EQ(0.0f, root_delegate.device_scale_factor()); | 1145 EXPECT_EQ(0.0f, root_delegate.device_scale_factor()); |
| 1149 EXPECT_EQ(0.0f, l1_delegate.device_scale_factor()); | 1146 EXPECT_EQ(0.0f, l1_delegate.device_scale_factor()); |
| 1150 RunPendingMessages(); | 1147 RunPendingMessages(); |
| 1151 EXPECT_EQ("0x0", root_delegate.paint_size().ToString()); | 1148 EXPECT_EQ("0x0", root_delegate.paint_size().ToString()); |
| 1152 EXPECT_EQ("0.0 0.0", root_delegate.ToScaleString()); | 1149 EXPECT_EQ("0.0 0.0", root_delegate.ToScaleString()); |
| 1153 EXPECT_EQ("0x0", l1_delegate.paint_size().ToString()); | 1150 EXPECT_EQ("0x0", l1_delegate.paint_size().ToString()); |
| 1154 EXPECT_EQ("0.0 0.0", l1_delegate.ToScaleString()); | 1151 EXPECT_EQ("0.0 0.0", l1_delegate.ToScaleString()); |
| 1155 } | 1152 } |
| 1156 | 1153 |
| 1157 TEST_F(LayerWithRealCompositorTest, MAYBE_ScaleReparent) { | 1154 TEST_F(LayerWithRealCompositorTest, MAYBE_ScaleReparent) { |
| 1158 test::ScopedDIPEnablerForTest enable; | |
| 1159 scoped_ptr<Layer> root(CreateColorLayer(SK_ColorWHITE, | 1155 scoped_ptr<Layer> root(CreateColorLayer(SK_ColorWHITE, |
| 1160 gfx::Rect(10, 20, 200, 220))); | 1156 gfx::Rect(10, 20, 200, 220))); |
| 1161 scoped_ptr<Layer> l1(CreateColorLayer(SK_ColorWHITE, | 1157 scoped_ptr<Layer> l1(CreateColorLayer(SK_ColorWHITE, |
| 1162 gfx::Rect(10, 20, 140, 180))); | 1158 gfx::Rect(10, 20, 140, 180))); |
| 1163 TestLayerDelegate l1_delegate; | 1159 TestLayerDelegate l1_delegate; |
| 1164 l1_delegate.AddColor(SK_ColorWHITE); | 1160 l1_delegate.AddColor(SK_ColorWHITE); |
| 1165 l1->set_delegate(&l1_delegate); | 1161 l1->set_delegate(&l1_delegate); |
| 1166 | 1162 |
| 1167 GetCompositor()->SetScaleAndSize(1.0f, gfx::Size(500, 500)); | 1163 GetCompositor()->SetScaleAndSize(1.0f, gfx::Size(500, 500)); |
| 1168 GetCompositor()->SetRootLayer(root.get()); | 1164 GetCompositor()->SetRootLayer(root.get()); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1194 size_in_pixel = l1->web_layer().bounds(); | 1190 size_in_pixel = l1->web_layer().bounds(); |
| 1195 EXPECT_EQ("280x360", size_in_pixel.ToString()); | 1191 EXPECT_EQ("280x360", size_in_pixel.ToString()); |
| 1196 EXPECT_EQ(2.0f, l1_delegate.device_scale_factor()); | 1192 EXPECT_EQ(2.0f, l1_delegate.device_scale_factor()); |
| 1197 RunPendingMessages(); | 1193 RunPendingMessages(); |
| 1198 EXPECT_EQ("280x360", l1_delegate.paint_size().ToString()); | 1194 EXPECT_EQ("280x360", l1_delegate.paint_size().ToString()); |
| 1199 EXPECT_EQ("2.0 2.0", l1_delegate.ToScaleString()); | 1195 EXPECT_EQ("2.0 2.0", l1_delegate.ToScaleString()); |
| 1200 } | 1196 } |
| 1201 | 1197 |
| 1202 // Tests layer::set_scale_canvas(false). | 1198 // Tests layer::set_scale_canvas(false). |
| 1203 TEST_F(LayerWithRealCompositorTest, MAYBE_NoScaleCanvas) { | 1199 TEST_F(LayerWithRealCompositorTest, MAYBE_NoScaleCanvas) { |
| 1204 test::ScopedDIPEnablerForTest enable; | |
| 1205 scoped_ptr<Layer> root(CreateColorLayer(SK_ColorWHITE, | 1200 scoped_ptr<Layer> root(CreateColorLayer(SK_ColorWHITE, |
| 1206 gfx::Rect(10, 20, 200, 220))); | 1201 gfx::Rect(10, 20, 200, 220))); |
| 1207 scoped_ptr<Layer> l1(CreateColorLayer(SK_ColorWHITE, | 1202 scoped_ptr<Layer> l1(CreateColorLayer(SK_ColorWHITE, |
| 1208 gfx::Rect(10, 20, 140, 180))); | 1203 gfx::Rect(10, 20, 140, 180))); |
| 1209 l1->set_scale_canvas(false); | 1204 l1->set_scale_canvas(false); |
| 1210 root->Add(l1.get()); | 1205 root->Add(l1.get()); |
| 1211 TestLayerDelegate l1_delegate; | 1206 TestLayerDelegate l1_delegate; |
| 1212 l1_delegate.AddColor(SK_ColorWHITE); | 1207 l1_delegate.AddColor(SK_ColorWHITE); |
| 1213 l1->set_delegate(&l1_delegate); | 1208 l1->set_delegate(&l1_delegate); |
| 1214 | 1209 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1260 | 1255 |
| 1261 // Resize layer. | 1256 // Resize layer. |
| 1262 child->SetBounds(gfx::Rect(200, 200, 400, 400)); | 1257 child->SetBounds(gfx::Rect(200, 200, 400, 400)); |
| 1263 child->SetVisible(true); | 1258 child->SetVisible(true); |
| 1264 EXPECT_TRUE(schedule_draw_invoked_); | 1259 EXPECT_TRUE(schedule_draw_invoked_); |
| 1265 DrawTree(root.get()); | 1260 DrawTree(root.get()); |
| 1266 EXPECT_TRUE(delegate.painted()); | 1261 EXPECT_TRUE(delegate.painted()); |
| 1267 } | 1262 } |
| 1268 | 1263 |
| 1269 } // namespace ui | 1264 } // namespace ui |
| OLD | NEW |