| 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" | 
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 133   void RunPendingMessages() { | 133   void RunPendingMessages() { | 
| 134     MessageLoopForUI::current()->RunUntilIdle(); | 134     MessageLoopForUI::current()->RunUntilIdle(); | 
| 135   } | 135   } | 
| 136 | 136 | 
| 137   // Invalidates the entire contents of the layer. | 137   // Invalidates the entire contents of the layer. | 
| 138   void SchedulePaintForLayer(Layer* layer) { | 138   void SchedulePaintForLayer(Layer* layer) { | 
| 139     layer->SchedulePaint( | 139     layer->SchedulePaint( | 
| 140         gfx::Rect(0, 0, layer->bounds().width(), layer->bounds().height())); | 140         gfx::Rect(0, 0, layer->bounds().width(), layer->bounds().height())); | 
| 141   } | 141   } | 
| 142 | 142 | 
| 143   const FilePath& test_data_directory() const { return test_data_directory_; } | 143   const base::FilePath& test_data_directory() const { | 
|  | 144     return test_data_directory_; | 
|  | 145   } | 
| 144 | 146 | 
| 145  private: | 147  private: | 
| 146   scoped_ptr<TestCompositorHost> window_; | 148   scoped_ptr<TestCompositorHost> window_; | 
| 147 | 149 | 
| 148   // The root directory for test files. | 150   // The root directory for test files. | 
| 149   FilePath test_data_directory_; | 151   base::FilePath test_data_directory_; | 
| 150 | 152 | 
| 151   DISALLOW_COPY_AND_ASSIGN(LayerWithRealCompositorTest); | 153   DISALLOW_COPY_AND_ASSIGN(LayerWithRealCompositorTest); | 
| 152 }; | 154 }; | 
| 153 | 155 | 
| 154 // LayerDelegate that paints colors to the layer. | 156 // LayerDelegate that paints colors to the layer. | 
| 155 class TestLayerDelegate : public LayerDelegate { | 157 class TestLayerDelegate : public LayerDelegate { | 
| 156  public: | 158  public: | 
| 157   explicit TestLayerDelegate() { reset(); } | 159   explicit TestLayerDelegate() { reset(); } | 
| 158   virtual ~TestLayerDelegate() {} | 160   virtual ~TestLayerDelegate() {} | 
| 159 | 161 | 
| (...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 885   //  +-l12 | 887   //  +-l12 | 
| 886   scoped_ptr<Layer> l0(CreateColorLayer(SK_ColorRED, | 888   scoped_ptr<Layer> l0(CreateColorLayer(SK_ColorRED, | 
| 887                                         gfx::Rect(0, 0, 50, 50))); | 889                                         gfx::Rect(0, 0, 50, 50))); | 
| 888   scoped_ptr<Layer> l11(CreateColorLayer(SK_ColorGREEN, | 890   scoped_ptr<Layer> l11(CreateColorLayer(SK_ColorGREEN, | 
| 889                                          gfx::Rect(0, 0, 25, 25))); | 891                                          gfx::Rect(0, 0, 25, 25))); | 
| 890   scoped_ptr<Layer> l21(CreateColorLayer(SK_ColorMAGENTA, | 892   scoped_ptr<Layer> l21(CreateColorLayer(SK_ColorMAGENTA, | 
| 891                                          gfx::Rect(0, 0, 15, 15))); | 893                                          gfx::Rect(0, 0, 15, 15))); | 
| 892   scoped_ptr<Layer> l12(CreateColorLayer(SK_ColorBLUE, | 894   scoped_ptr<Layer> l12(CreateColorLayer(SK_ColorBLUE, | 
| 893                                          gfx::Rect(10, 10, 25, 25))); | 895                                          gfx::Rect(10, 10, 25, 25))); | 
| 894 | 896 | 
| 895   FilePath ref_img1 = test_data_directory().AppendASCII("ModifyHierarchy1.png"); | 897   base::FilePath ref_img1 = | 
| 896   FilePath ref_img2 = test_data_directory().AppendASCII("ModifyHierarchy2.png"); | 898       test_data_directory().AppendASCII("ModifyHierarchy1.png"); | 
|  | 899   base::FilePath ref_img2 = | 
|  | 900       test_data_directory().AppendASCII("ModifyHierarchy2.png"); | 
| 897   SkBitmap bitmap; | 901   SkBitmap bitmap; | 
| 898 | 902 | 
| 899   l0->Add(l11.get()); | 903   l0->Add(l11.get()); | 
| 900   l11->Add(l21.get()); | 904   l11->Add(l21.get()); | 
| 901   l0->Add(l12.get()); | 905   l0->Add(l12.get()); | 
| 902   DrawTree(l0.get()); | 906   DrawTree(l0.get()); | 
| 903   ASSERT_TRUE(ReadPixels(&bitmap)); | 907   ASSERT_TRUE(ReadPixels(&bitmap)); | 
| 904   ASSERT_FALSE(bitmap.empty()); | 908   ASSERT_FALSE(bitmap.empty()); | 
| 905   // WritePNGFile(bitmap, ref_img1); | 909   // WritePNGFile(bitmap, ref_img1); | 
| 906   EXPECT_TRUE(IsSameAsPNGFile(bitmap, ref_img1)); | 910   EXPECT_TRUE(IsSameAsPNGFile(bitmap, ref_img1)); | 
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 939 TEST_F(LayerWithRealCompositorTest, MAYBE_Opacity) { | 943 TEST_F(LayerWithRealCompositorTest, MAYBE_Opacity) { | 
| 940   GetCompositor()->SetScaleAndSize(1.0f, gfx::Size(50, 50)); | 944   GetCompositor()->SetScaleAndSize(1.0f, gfx::Size(50, 50)); | 
| 941 | 945 | 
| 942   // l0 | 946   // l0 | 
| 943   //  +-l11 | 947   //  +-l11 | 
| 944   scoped_ptr<Layer> l0(CreateColorLayer(SK_ColorRED, | 948   scoped_ptr<Layer> l0(CreateColorLayer(SK_ColorRED, | 
| 945                                         gfx::Rect(0, 0, 50, 50))); | 949                                         gfx::Rect(0, 0, 50, 50))); | 
| 946   scoped_ptr<Layer> l11(CreateColorLayer(SK_ColorGREEN, | 950   scoped_ptr<Layer> l11(CreateColorLayer(SK_ColorGREEN, | 
| 947                                          gfx::Rect(0, 0, 25, 25))); | 951                                          gfx::Rect(0, 0, 25, 25))); | 
| 948 | 952 | 
| 949   FilePath ref_img = test_data_directory().AppendASCII("Opacity.png"); | 953   base::FilePath ref_img = test_data_directory().AppendASCII("Opacity.png"); | 
| 950 | 954 | 
| 951   l11->SetOpacity(0.75); | 955   l11->SetOpacity(0.75); | 
| 952   l0->Add(l11.get()); | 956   l0->Add(l11.get()); | 
| 953   DrawTree(l0.get()); | 957   DrawTree(l0.get()); | 
| 954   SkBitmap bitmap; | 958   SkBitmap bitmap; | 
| 955   ASSERT_TRUE(ReadPixels(&bitmap)); | 959   ASSERT_TRUE(ReadPixels(&bitmap)); | 
| 956   ASSERT_FALSE(bitmap.empty()); | 960   ASSERT_FALSE(bitmap.empty()); | 
| 957   // WritePNGFile(bitmap, ref_img); | 961   // WritePNGFile(bitmap, ref_img); | 
| 958   EXPECT_TRUE(IsSameAsPNGFile(bitmap, ref_img)); | 962   EXPECT_TRUE(IsSameAsPNGFile(bitmap, ref_img)); | 
| 959 } | 963 } | 
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1239 | 1243 | 
| 1240   // Resize layer. | 1244   // Resize layer. | 
| 1241   child->SetBounds(gfx::Rect(200, 200, 400, 400)); | 1245   child->SetBounds(gfx::Rect(200, 200, 400, 400)); | 
| 1242   child->SetVisible(true); | 1246   child->SetVisible(true); | 
| 1243   EXPECT_TRUE(schedule_draw_invoked_); | 1247   EXPECT_TRUE(schedule_draw_invoked_); | 
| 1244   DrawTree(root.get()); | 1248   DrawTree(root.get()); | 
| 1245   EXPECT_TRUE(delegate.painted()); | 1249   EXPECT_TRUE(delegate.painted()); | 
| 1246 } | 1250 } | 
| 1247 | 1251 | 
| 1248 }  // namespace ui | 1252 }  // namespace ui | 
| OLD | NEW | 
|---|