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 <map> | 5 #include <map> |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/rand_util.h" | 8 #include "base/rand_util.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 2876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2887 | 2887 |
2888 class ViewLayerTest : public ViewsTestBase { | 2888 class ViewLayerTest : public ViewsTestBase { |
2889 public: | 2889 public: |
2890 ViewLayerTest() : widget_(NULL), old_use_acceleration_(false) {} | 2890 ViewLayerTest() : widget_(NULL), old_use_acceleration_(false) {} |
2891 | 2891 |
2892 virtual ~ViewLayerTest() { | 2892 virtual ~ViewLayerTest() { |
2893 } | 2893 } |
2894 | 2894 |
2895 // Returns the Layer used by the RootView. | 2895 // Returns the Layer used by the RootView. |
2896 ui::Layer* GetRootLayer() { | 2896 ui::Layer* GetRootLayer() { |
2897 ui::Layer* root_layer = NULL; | 2897 return widget()->GetLayer(); |
2898 widget()->CalculateOffsetToAncestorWithLayer(&root_layer); | |
2899 return root_layer; | |
2900 } | 2898 } |
2901 | 2899 |
2902 virtual void SetUp() OVERRIDE { | 2900 virtual void SetUp() OVERRIDE { |
2903 ViewTest::SetUp(); | 2901 ViewTest::SetUp(); |
2904 old_use_acceleration_ = View::get_use_acceleration_when_possible(); | 2902 old_use_acceleration_ = View::get_use_acceleration_when_possible(); |
2905 View::set_use_acceleration_when_possible(true); | 2903 View::set_use_acceleration_when_possible(true); |
2906 | 2904 |
2907 widget_ = new Widget; | 2905 widget_ = new Widget; |
2908 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP); | 2906 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP); |
2909 params.bounds = gfx::Rect(50, 50, 200, 200); | 2907 params.bounds = gfx::Rect(50, 50, 200, 200); |
(...skipping 12 matching lines...) Expand all Loading... |
2922 | 2920 |
2923 private: | 2921 private: |
2924 Widget* widget_; | 2922 Widget* widget_; |
2925 bool old_use_acceleration_; | 2923 bool old_use_acceleration_; |
2926 }; | 2924 }; |
2927 | 2925 |
2928 | 2926 |
2929 TEST_F(ViewLayerTest, LayerToggling) { | 2927 TEST_F(ViewLayerTest, LayerToggling) { |
2930 // Because we lazily create textures the calls to DrawTree are necessary to | 2928 // Because we lazily create textures the calls to DrawTree are necessary to |
2931 // ensure we trigger creation of textures. | 2929 // ensure we trigger creation of textures. |
2932 ui::Layer* root_layer = NULL; | 2930 ui::Layer* root_layer = widget()->GetLayer(); |
2933 widget()->CalculateOffsetToAncestorWithLayer(&root_layer); | |
2934 View* content_view = new View; | 2931 View* content_view = new View; |
2935 widget()->SetContentsView(content_view); | 2932 widget()->SetContentsView(content_view); |
2936 | 2933 |
2937 // Create v1, give it a bounds and verify everything is set up correctly. | 2934 // Create v1, give it a bounds and verify everything is set up correctly. |
2938 View* v1 = new View; | 2935 View* v1 = new View; |
2939 v1->SetPaintToLayer(true); | 2936 v1->SetPaintToLayer(true); |
2940 EXPECT_TRUE(v1->layer() != NULL); | 2937 EXPECT_TRUE(v1->layer() != NULL); |
2941 v1->SetBoundsRect(gfx::Rect(20, 30, 140, 150)); | 2938 v1->SetBoundsRect(gfx::Rect(20, 30, 140, 150)); |
2942 content_view->AddChildView(v1); | 2939 content_view->AddChildView(v1); |
2943 ASSERT_TRUE(v1->layer() != NULL); | 2940 ASSERT_TRUE(v1->layer() != NULL); |
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3376 // Set to non default value. | 3373 // Set to non default value. |
3377 v->layer()->set_scale_content(false); | 3374 v->layer()->set_scale_content(false); |
3378 scoped_ptr<ui::Layer> old_layer(v->RecreateLayer()); | 3375 scoped_ptr<ui::Layer> old_layer(v->RecreateLayer()); |
3379 ui::Layer* new_layer = v->layer(); | 3376 ui::Layer* new_layer = v->layer(); |
3380 EXPECT_FALSE(new_layer->scale_content()); | 3377 EXPECT_FALSE(new_layer->scale_content()); |
3381 } | 3378 } |
3382 | 3379 |
3383 #endif // USE_AURA | 3380 #endif // USE_AURA |
3384 | 3381 |
3385 } // namespace views | 3382 } // namespace views |
OLD | NEW |