| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <memory> | 5 #include <memory> |
| 6 | 6 |
| 7 #include "ui/aura/test/aura_test_base.h" | 7 #include "ui/aura/test/aura_test_base.h" |
| 8 #include "ui/aura/test/test_windows.h" | 8 #include "ui/aura/test/test_windows.h" |
| 9 #include "ui/aura/window.h" | 9 #include "ui/aura/window.h" |
| 10 #include "ui/aura/window_event_dispatcher.h" | 10 #include "ui/aura/window_event_dispatcher.h" |
| 11 #include "ui/compositor/layer.h" | 11 #include "ui/compositor/layer.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/views/view.h" | 14 #include "ui/views/view.h" |
| 14 #include "ui/views/view_constants_aura.h" | 15 #include "ui/views/view_constants_aura.h" |
| 15 #include "ui/views/widget/widget.h" | 16 #include "ui/views/widget/widget.h" |
| 16 | 17 |
| 17 namespace views { | 18 namespace views { |
| 18 namespace { | 19 namespace { |
| 19 | 20 |
| 20 // Creates a control widget with the passed in parameters. | 21 // Creates a control widget with the passed in parameters. |
| 21 // The caller takes ownership of the returned widget. | 22 // The caller takes ownership of the returned widget. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 parent->Show(); | 60 parent->Show(); |
| 60 aura::Window* parent_window = parent->GetNativeWindow(); | 61 aura::Window* parent_window = parent->GetNativeWindow(); |
| 61 | 62 |
| 62 View* contents_view = new View(); | 63 View* contents_view = new View(); |
| 63 parent->SetContentsView(contents_view); | 64 parent->SetContentsView(contents_view); |
| 64 | 65 |
| 65 // 1) Test that layers for views and layers for windows associated to a host | 66 // 1) Test that layers for views and layers for windows associated to a host |
| 66 // view are stacked below the layers for any windows not associated to a host | 67 // view are stacked below the layers for any windows not associated to a host |
| 67 // view. | 68 // view. |
| 68 View* v = new View(); | 69 View* v = new View(); |
| 69 v->SetPaintToLayer(true); | 70 v->SetPaintToLayer(ui::LAYER_TEXTURED); |
| 70 v->layer()->set_name("v"); | 71 v->layer()->set_name("v"); |
| 71 contents_view->AddChildView(v); | 72 contents_view->AddChildView(v); |
| 72 | 73 |
| 73 std::unique_ptr<Widget> w1( | 74 std::unique_ptr<Widget> w1( |
| 74 CreateControlWidget(parent_window, gfx::Rect(0, 1, 100, 101))); | 75 CreateControlWidget(parent_window, gfx::Rect(0, 1, 100, 101))); |
| 75 SetWindowAndLayerName(w1->GetNativeView(), "w1"); | 76 SetWindowAndLayerName(w1->GetNativeView(), "w1"); |
| 76 w1->Show(); | 77 w1->Show(); |
| 77 std::unique_ptr<Widget> w2( | 78 std::unique_ptr<Widget> w2( |
| 78 CreateControlWidget(parent_window, gfx::Rect(0, 2, 100, 102))); | 79 CreateControlWidget(parent_window, gfx::Rect(0, 2, 100, 102))); |
| 79 SetWindowAndLayerName(w2->GetNativeView(), "w2"); | 80 SetWindowAndLayerName(w2->GetNativeView(), "w2"); |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 // +-- v1 | 209 // +-- v1 |
| 209 // +-- v11* | 210 // +-- v11* |
| 210 // +-- v12 (attached window) | 211 // +-- v12 (attached window) |
| 211 // +-- v13* | 212 // +-- v13* |
| 212 // +--v2* | 213 // +--v2* |
| 213 | 214 |
| 214 View* v1 = new View(); | 215 View* v1 = new View(); |
| 215 contents_view->AddChildView(v1); | 216 contents_view->AddChildView(v1); |
| 216 | 217 |
| 217 View* v11 = new View(); | 218 View* v11 = new View(); |
| 218 v11->SetPaintToLayer(true); | 219 v11->SetPaintToLayer(ui::LAYER_TEXTURED); |
| 219 v11->layer()->set_name("v11"); | 220 v11->layer()->set_name("v11"); |
| 220 v1->AddChildView(v11); | 221 v1->AddChildView(v11); |
| 221 | 222 |
| 222 std::unique_ptr<Widget> w( | 223 std::unique_ptr<Widget> w( |
| 223 CreateControlWidget(parent_window, gfx::Rect(0, 1, 100, 101))); | 224 CreateControlWidget(parent_window, gfx::Rect(0, 1, 100, 101))); |
| 224 SetWindowAndLayerName(w->GetNativeView(), "w"); | 225 SetWindowAndLayerName(w->GetNativeView(), "w"); |
| 225 w->Show(); | 226 w->Show(); |
| 226 | 227 |
| 227 View* v12 = new View(); | 228 View* v12 = new View(); |
| 228 v1->AddChildView(v12); | 229 v1->AddChildView(v12); |
| 229 w->GetNativeView()->SetProperty(kHostViewKey, v12); | 230 w->GetNativeView()->SetProperty(kHostViewKey, v12); |
| 230 | 231 |
| 231 View* v13 = new View(); | 232 View* v13 = new View(); |
| 232 v13->SetPaintToLayer(true); | 233 v13->SetPaintToLayer(ui::LAYER_TEXTURED); |
| 233 v13->layer()->set_name("v13"); | 234 v13->layer()->set_name("v13"); |
| 234 v1->AddChildView(v13); | 235 v1->AddChildView(v13); |
| 235 | 236 |
| 236 View* v2 = new View(); | 237 View* v2 = new View(); |
| 237 v2->SetPaintToLayer(true); | 238 v2->SetPaintToLayer(ui::LAYER_TEXTURED); |
| 238 v2->layer()->set_name("v2"); | 239 v2->layer()->set_name("v2"); |
| 239 contents_view->AddChildView(v2); | 240 contents_view->AddChildView(v2); |
| 240 | 241 |
| 241 // Test intial state. | 242 // Test intial state. |
| 242 EXPECT_EQ("w", ChildWindowNamesAsString(*parent_window)); | 243 EXPECT_EQ("w", ChildWindowNamesAsString(*parent_window)); |
| 243 EXPECT_EQ("v11 w v13 v2", | 244 EXPECT_EQ("v11 w v13 v2", |
| 244 ui::test::ChildLayerNamesAsString(*parent_window->layer())); | 245 ui::test::ChildLayerNamesAsString(*parent_window->layer())); |
| 245 | 246 |
| 246 // |w|'s layer should be stacked above |v1|'s layer. | 247 // |w|'s layer should be stacked above |v1|'s layer. |
| 247 v1->SetPaintToLayer(true); | 248 v1->SetPaintToLayer(ui::LAYER_TEXTURED); |
| 248 v1->layer()->set_name("v1"); | 249 v1->layer()->set_name("v1"); |
| 249 EXPECT_EQ("w", ChildWindowNamesAsString(*parent_window)); | 250 EXPECT_EQ("w", ChildWindowNamesAsString(*parent_window)); |
| 250 EXPECT_EQ("v1 w v2", | 251 EXPECT_EQ("v1 w v2", |
| 251 ui::test::ChildLayerNamesAsString(*parent_window->layer())); | 252 ui::test::ChildLayerNamesAsString(*parent_window->layer())); |
| 252 | 253 |
| 253 // Test moving the host view from one view with a layer to another. | 254 // Test moving the host view from one view with a layer to another. |
| 254 v2->AddChildView(v12); | 255 v2->AddChildView(v12); |
| 255 EXPECT_EQ("w", ChildWindowNamesAsString(*parent_window)); | 256 EXPECT_EQ("w", ChildWindowNamesAsString(*parent_window)); |
| 256 EXPECT_EQ("v1 v2 w", | 257 EXPECT_EQ("v1 v2 w", |
| 257 ui::test::ChildLayerNamesAsString(*parent_window->layer())); | 258 ui::test::ChildLayerNamesAsString(*parent_window->layer())); |
| 258 | 259 |
| 259 // Work around for bug in NativeWidgetAura. | 260 // Work around for bug in NativeWidgetAura. |
| 260 // TODO: fix bug and remove this. | 261 // TODO: fix bug and remove this. |
| 261 parent->Close(); | 262 parent->Close(); |
| 262 } | 263 } |
| 263 | 264 |
| 264 } // namespace | 265 } // namespace |
| 265 } // namespace views | 266 } // namespace views |
| OLD | NEW |