Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(310)

Side by Side Diff: ui/gfx/compositor/layer_unittest.cc

Issue 10221028: Move DIP translation from ui/aura to ui/compositor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 359
360 class LayerWithDelegateTest : public testing::Test, public CompositorDelegate { 360 class LayerWithDelegateTest : public testing::Test, public CompositorDelegate {
361 public: 361 public:
362 LayerWithDelegateTest() : schedule_draw_invoked_(false) {} 362 LayerWithDelegateTest() : schedule_draw_invoked_(false) {}
363 virtual ~LayerWithDelegateTest() {} 363 virtual ~LayerWithDelegateTest() {}
364 364
365 // Overridden from testing::Test: 365 // Overridden from testing::Test:
366 virtual void SetUp() OVERRIDE { 366 virtual void SetUp() OVERRIDE {
367 ui::SetupTestCompositor(); 367 ui::SetupTestCompositor();
368 compositor_.reset(new Compositor( 368 compositor_.reset(new Compositor(
369 this, gfx::kNullAcceleratedWidget, gfx::Size(1000, 1000))); 369 this, gfx::kNullAcceleratedWidget));
370 compositor_->WidgetScaleOrSizeChanged(1.0f, gfx::Size(1000, 1000));
370 } 371 }
371 372
372 virtual void TearDown() OVERRIDE { 373 virtual void TearDown() OVERRIDE {
373 } 374 }
374 375
375 Compositor* compositor() { return compositor_.get(); } 376 Compositor* compositor() { return compositor_.get(); }
376 377
377 virtual Layer* CreateLayer(LayerType type) { 378 virtual Layer* CreateLayer(LayerType type) {
378 return new Layer(type); 379 return new Layer(type);
379 } 380 }
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
850 851
851 // Opacity changes should no longer alert the removed observer. 852 // Opacity changes should no longer alert the removed observer.
852 observer.Reset(); 853 observer.Reset();
853 l2->SetOpacity(0.5f); 854 l2->SetOpacity(0.5f);
854 RunPendingMessages(); 855 RunPendingMessages();
855 EXPECT_FALSE(observer.notified()); 856 EXPECT_FALSE(observer.notified());
856 } 857 }
857 858
858 // Checks that modifying the hierarchy correctly affects final composite. 859 // Checks that modifying the hierarchy correctly affects final composite.
859 TEST_F(LayerWithRealCompositorTest, MAYBE_ModifyHierarchy) { 860 TEST_F(LayerWithRealCompositorTest, MAYBE_ModifyHierarchy) {
860 GetCompositor()->WidgetSizeChanged(gfx::Size(50, 50)); 861 GetCompositor()->WidgetScaleOrSizeChanged(1.0f, gfx::Size(50, 50));
861 862
862 // l0 863 // l0
863 // +-l11 864 // +-l11
864 // | +-l21 865 // | +-l21
865 // +-l12 866 // +-l12
866 scoped_ptr<Layer> l0(CreateColorLayer(SK_ColorRED, 867 scoped_ptr<Layer> l0(CreateColorLayer(SK_ColorRED,
867 gfx::Rect(0, 0, 50, 50))); 868 gfx::Rect(0, 0, 50, 50)));
868 scoped_ptr<Layer> l11(CreateColorLayer(SK_ColorGREEN, 869 scoped_ptr<Layer> l11(CreateColorLayer(SK_ColorGREEN,
869 gfx::Rect(0, 0, 25, 25))); 870 gfx::Rect(0, 0, 25, 25)));
870 scoped_ptr<Layer> l21(CreateColorLayer(SK_ColorMAGENTA, 871 scoped_ptr<Layer> l21(CreateColorLayer(SK_ColorMAGENTA,
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
910 l0->StackAbove(l12.get(), l11.get()); 911 l0->StackAbove(l12.get(), l11.get());
911 DrawTree(l0.get()); 912 DrawTree(l0.get());
912 ASSERT_TRUE(ReadPixels(&bitmap)); 913 ASSERT_TRUE(ReadPixels(&bitmap));
913 ASSERT_FALSE(bitmap.empty()); 914 ASSERT_FALSE(bitmap.empty());
914 EXPECT_TRUE(IsSameAsPNGFile(bitmap, ref_img1)); 915 EXPECT_TRUE(IsSameAsPNGFile(bitmap, ref_img1));
915 } 916 }
916 917
917 // Opacity is rendered correctly. 918 // Opacity is rendered correctly.
918 // Checks that modifying the hierarchy correctly affects final composite. 919 // Checks that modifying the hierarchy correctly affects final composite.
919 TEST_F(LayerWithRealCompositorTest, MAYBE_Opacity) { 920 TEST_F(LayerWithRealCompositorTest, MAYBE_Opacity) {
920 GetCompositor()->WidgetSizeChanged(gfx::Size(50, 50)); 921 GetCompositor()->WidgetScaleOrSizeChanged(1.0f, gfx::Size(50, 50));
921 922
922 // l0 923 // l0
923 // +-l11 924 // +-l11
924 scoped_ptr<Layer> l0(CreateColorLayer(SK_ColorRED, 925 scoped_ptr<Layer> l0(CreateColorLayer(SK_ColorRED,
925 gfx::Rect(0, 0, 50, 50))); 926 gfx::Rect(0, 0, 50, 50)));
926 scoped_ptr<Layer> l11(CreateColorLayer(SK_ColorGREEN, 927 scoped_ptr<Layer> l11(CreateColorLayer(SK_ColorGREEN,
927 gfx::Rect(0, 0, 25, 25))); 928 gfx::Rect(0, 0, 25, 25)));
928 929
929 FilePath ref_img = test_data_directory().AppendASCII("Opacity.png"); 930 FilePath ref_img = test_data_directory().AppendASCII("Opacity.png");
930 931
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1015 EXPECT_TRUE(schedule_draw_invoked_); 1016 EXPECT_TRUE(schedule_draw_invoked_);
1016 // Because SchedulePaint() was invoked from OnPaintLayer() |child| should 1017 // Because SchedulePaint() was invoked from OnPaintLayer() |child| should
1017 // still need to be painted. 1018 // still need to be painted.
1018 DrawTree(root.get()); 1019 DrawTree(root.get());
1019 EXPECT_EQ(1, child_delegate.GetPaintCountAndClear()); 1020 EXPECT_EQ(1, child_delegate.GetPaintCountAndClear());
1020 EXPECT_TRUE(child_delegate.last_clip_rect().Contains( 1021 EXPECT_TRUE(child_delegate.last_clip_rect().Contains(
1021 gfx::Rect(10, 10, 30, 30))); 1022 gfx::Rect(10, 10, 30, 30)));
1022 } 1023 }
1023 1024
1024 } // namespace ui 1025 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698