diff options
Diffstat (limited to 'ash')
-rw-r--r-- | ash/wm/stacking_controller.cc | 3 | ||||
-rw-r--r-- | ash/wm/system_modal_container_layout_manager_unittest.cc | 43 |
2 files changed, 42 insertions, 4 deletions
diff --git a/ash/wm/stacking_controller.cc b/ash/wm/stacking_controller.cc index 867342c..42aedf6 100644 --- a/ash/wm/stacking_controller.cc +++ b/ash/wm/stacking_controller.cc @@ -27,8 +27,7 @@ aura::Window* GetContainerForWindow(aura::Window* window) { } bool IsSystemModal(aura::Window* window) { - return window->transient_parent() && - window->GetProperty(aura::client::kModalKey) == ui::MODAL_TYPE_SYSTEM; + return window->GetProperty(aura::client::kModalKey) == ui::MODAL_TYPE_SYSTEM; } bool IsWindowModal(aura::Window* window) { diff --git a/ash/wm/system_modal_container_layout_manager_unittest.cc b/ash/wm/system_modal_container_layout_manager_unittest.cc index 6e5ac4a..616cd1c 100644 --- a/ash/wm/system_modal_container_layout_manager_unittest.cc +++ b/ash/wm/system_modal_container_layout_manager_unittest.cc @@ -40,7 +40,6 @@ class TestWindow : public views::WidgetDelegateView { virtual ~TestWindow() {} static aura::Window* OpenTestWindow(aura::Window* parent, bool modal) { - DCHECK(!modal || (modal && parent)); views::Widget* widget = views::Widget::CreateWindowWithParent(new TestWindow(modal), parent); widget->Show(); @@ -132,8 +131,8 @@ TEST_F(SystemModalContainerLayoutManagerTest, ModalTransient) { scoped_ptr<aura::Window> parent(TestWindow::OpenTestWindow(NULL, false)); // parent should be active. EXPECT_TRUE(wm::IsActiveWindow(parent.get())); - aura::Window* t1 = TestWindow::OpenTestWindow(parent.get(), true); + TransientWindowObserver do1; t1->AddObserver(&do1); @@ -169,6 +168,46 @@ TEST_F(SystemModalContainerLayoutManagerTest, ModalTransient) { EXPECT_TRUE(do2.destroyed()); } +TEST_F(SystemModalContainerLayoutManagerTest, ModalNonTransient) { + scoped_ptr<aura::Window> t1(TestWindow::OpenTestWindow(NULL, true)); + // parent should be active. + EXPECT_TRUE(wm::IsActiveWindow(t1.get())); + TransientWindowObserver do1; + t1->AddObserver(&do1); + + EXPECT_EQ(NULL, t1->transient_parent()); + EXPECT_EQ(GetModalContainer(), t1->parent()); + + // t1 should now be active. + EXPECT_TRUE(wm::IsActiveWindow(t1.get())); + + // Attempting to click the parent should result in no activation change. + aura::test::EventGenerator e1(Shell::GetPrimaryRootWindow(), + Shell::GetPrimaryRootWindow()); + e1.ClickLeftButton(); + EXPECT_TRUE(wm::IsActiveWindow(t1.get())); + + // Now open another modal transient parented to the original modal transient. + aura::Window* t2 = TestWindow::OpenTestWindow(t1.get(), true); + TransientWindowObserver do2; + t2->AddObserver(&do2); + + EXPECT_TRUE(wm::IsActiveWindow(t2)); + + EXPECT_EQ(t1, t2->transient_parent()); + EXPECT_EQ(GetModalContainer(), t2->parent()); + + // t2 should still be active, even after clicking on t1. + aura::test::EventGenerator e2(Shell::GetPrimaryRootWindow(), t1.get()); + e2.ClickLeftButton(); + EXPECT_TRUE(wm::IsActiveWindow(t2)); + + // Both transients should be destroyed with parent. + t1.reset(); + EXPECT_TRUE(do1.destroyed()); + EXPECT_TRUE(do2.destroyed()); +} + // Fails on Mac only. Needs to be implemented. http://crbug.com/111279. #if defined(OS_MACOSX) #define MAYBE_CanActivateAfterEndModalSession \ |