| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ui/views/view.h" | 5 #include "ui/views/view.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "ui/aura/window.h" | 9 #include "ui/aura/window.h" |
| 10 #include "ui/compositor/layer.h" | 10 #include "ui/compositor/layer.h" |
| 11 #include "ui/compositor/layer_tree_owner.h" | 11 #include "ui/compositor/layer_tree_owner.h" |
| 12 #include "ui/compositor/layer_type.h" |
| 12 #include "ui/compositor/test/test_layers.h" | 13 #include "ui/compositor/test/test_layers.h" |
| 13 #include "ui/gfx/geometry/rect.h" | 14 #include "ui/gfx/geometry/rect.h" |
| 14 #include "ui/views/test/views_test_base.h" | 15 #include "ui/views/test/views_test_base.h" |
| 15 #include "ui/views/view_constants_aura.h" | 16 #include "ui/views/view_constants_aura.h" |
| 16 #include "ui/views/widget/widget.h" | 17 #include "ui/views/widget/widget.h" |
| 17 #include "ui/wm/core/window_util.h" | 18 #include "ui/wm/core/window_util.h" |
| 18 | 19 |
| 19 namespace views { | 20 namespace views { |
| 20 | 21 |
| 21 namespace { | 22 namespace { |
| 22 | 23 |
| 23 // Creates a widget of TYPE_CONTROL. | 24 // Creates a widget of TYPE_CONTROL. |
| 24 // The caller takes ownership of the returned widget. | 25 // The caller takes ownership of the returned widget. |
| 25 Widget* CreateControlWidget(aura::Window* parent, const gfx::Rect& bounds) { | 26 Widget* CreateControlWidget(aura::Window* parent, const gfx::Rect& bounds) { |
| 26 Widget::InitParams params(Widget::InitParams::TYPE_CONTROL); | 27 Widget::InitParams params(Widget::InitParams::TYPE_CONTROL); |
| 27 params.parent = parent; | 28 params.parent = parent; |
| 28 params.bounds = bounds; | 29 params.bounds = bounds; |
| 29 Widget* widget = new Widget(); | 30 Widget* widget = new Widget(); |
| 30 widget->Init(params); | 31 widget->Init(params); |
| 31 return widget; | 32 return widget; |
| 32 } | 33 } |
| 33 | 34 |
| 34 // Returns a view with a layer with the passed in |bounds| and |layer_name|. | 35 // Returns a view with a layer with the passed in |bounds| and |layer_name|. |
| 35 // The caller takes ownership of the returned view. | 36 // The caller takes ownership of the returned view. |
| 36 View* CreateViewWithLayer(const gfx::Rect& bounds, const char* layer_name) { | 37 View* CreateViewWithLayer(const gfx::Rect& bounds, const char* layer_name) { |
| 37 View* view = new View(); | 38 View* view = new View(); |
| 38 view->SetBoundsRect(bounds); | 39 view->SetBoundsRect(bounds); |
| 39 view->SetPaintToLayer(true); | 40 view->SetPaintToLayer(ui::LAYER_TEXTURED); |
| 40 view->layer()->set_name(layer_name); | 41 view->layer()->set_name(layer_name); |
| 41 return view; | 42 return view; |
| 42 } | 43 } |
| 43 | 44 |
| 44 } // namespace | 45 } // namespace |
| 45 | 46 |
| 46 typedef ViewsTestBase ViewAuraTest; | 47 typedef ViewsTestBase ViewAuraTest; |
| 47 | 48 |
| 48 // Test that wm::RecreateLayers() recreates the layers for all child windows and | 49 // Test that wm::RecreateLayers() recreates the layers for all child windows and |
| 49 // all child views and that the z-order of the recreated layers matches that of | 50 // all child views and that the z-order of the recreated layers matches that of |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 std::vector<ui::Layer*> new_w1_root_sublayers = w1->GetRootLayers(); | 179 std::vector<ui::Layer*> new_w1_root_sublayers = w1->GetRootLayers(); |
| 179 ASSERT_EQ(3u, new_w1_root_sublayers.size()); | 180 ASSERT_EQ(3u, new_w1_root_sublayers.size()); |
| 180 EXPECT_EQ(v1_new_layer, new_w1_root_sublayers[0]); | 181 EXPECT_EQ(v1_new_layer, new_w1_root_sublayers[0]); |
| 181 EXPECT_EQ(v4_new_layer, new_w1_root_sublayers[1]); | 182 EXPECT_EQ(v4_new_layer, new_w1_root_sublayers[1]); |
| 182 EXPECT_EQ(v7_new_layer, new_w1_root_sublayers[2]); | 183 EXPECT_EQ(v7_new_layer, new_w1_root_sublayers[2]); |
| 183 } | 184 } |
| 184 w1->CloseNow(); | 185 w1->CloseNow(); |
| 185 } | 186 } |
| 186 | 187 |
| 187 } // namespace views | 188 } // namespace views |
| OLD | NEW |