summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authorzelidrag@chromium.org <zelidrag@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-05 23:10:56 +0000
committerzelidrag@chromium.org <zelidrag@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-05 23:10:56 +0000
commit3fe224d430d863880df0050faaa037b0eb00d3c0 (patch)
treea9dd40208b9f6f4ac8c43b220c75cf55c43d51b2 /ash
parentfc5e9293477d6defb2a9bbef78f6303ad0211202 (diff)
downloadchromium_src-3fe224d430d863880df0050faaa037b0eb00d3c0.zip
chromium_src-3fe224d430d863880df0050faaa037b0eb00d3c0.tar.gz
chromium_src-3fe224d430d863880df0050faaa037b0eb00d3c0.tar.bz2
Removed requirement for ash::Window::transient_parent() presence for system modal dialogs.
BUG=130420 TEST=SystemModalContainerLayoutManagerTest.ModalTransientAndNonTransient Review URL: https://chromiumcodereview.appspot.com/10514012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@140647 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r--ash/wm/stacking_controller.cc3
-rw-r--r--ash/wm/system_modal_container_layout_manager_unittest.cc43
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 \