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