Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(114)

Side by Side Diff: ui/aura_shell/modal_container_layout_manager_unittest.cc

Issue 8926004: Revert 114095 - Move the concept of Activation to the Shell. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
Property Changes:
Added: svn:mergeinfo
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/aura_shell/modal_container_layout_manager.h" 5 #include "ui/aura_shell/modal_container_layout_manager.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "ui/aura/root_window.h" 8 #include "ui/aura/root_window.h"
9 #include "ui/aura/test/event_generator.h" 9 #include "ui/aura/test/event_generator.h"
10 #include "ui/aura/window.h" 10 #include "ui/aura/window.h"
11 #include "ui/aura_shell/shell.h" 11 #include "ui/aura_shell/shell.h"
12 #include "ui/aura_shell/shell_window_ids.h" 12 #include "ui/aura_shell/shell_window_ids.h"
13 #include "ui/aura_shell/test/aura_shell_test_base.h" 13 #include "ui/aura_shell/test/aura_shell_test_base.h"
14 #include "ui/aura_shell/window_util.h"
15 #include "ui/views/widget/widget.h" 14 #include "ui/views/widget/widget.h"
16 #include "ui/views/widget/widget_delegate.h" 15 #include "ui/views/widget/widget_delegate.h"
17 16
18 namespace aura_shell { 17 namespace aura_shell {
19 namespace test { 18 namespace test {
20 19
21 namespace { 20 namespace {
22 21
23 aura::Window* GetModalContainer() { 22 aura::Window* GetModalContainer() {
24 return Shell::GetInstance()->GetContainer( 23 return Shell::GetInstance()->GetContainer(
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 } 74 }
76 75
77 private: 76 private:
78 bool destroyed_; 77 bool destroyed_;
79 78
80 DISALLOW_COPY_AND_ASSIGN(TransientWindowObserver); 79 DISALLOW_COPY_AND_ASSIGN(TransientWindowObserver);
81 }; 80 };
82 81
83 } // namespace 82 } // namespace
84 83
85 typedef AuraShellTestBase ModalContainerLayoutManagerTest; 84 typedef aura_shell::test::AuraShellTestBase ModalContainerLayoutManagerTest;
86 85
87 TEST_F(ModalContainerLayoutManagerTest, NonModalTransient) { 86 TEST_F(ModalContainerLayoutManagerTest, NonModalTransient) {
88 scoped_ptr<aura::Window> parent(TestWindow::OpenTestWindow(NULL, false)); 87 scoped_ptr<aura::Window> parent(TestWindow::OpenTestWindow(NULL, false));
89 aura::Window* transient = TestWindow::OpenTestWindow(parent.get(), false); 88 aura::Window* transient = TestWindow::OpenTestWindow(parent.get(), false);
90 TransientWindowObserver destruction_observer; 89 TransientWindowObserver destruction_observer;
91 transient->AddObserver(&destruction_observer); 90 transient->AddObserver(&destruction_observer);
92 91
93 EXPECT_EQ(parent.get(), transient->transient_parent()); 92 EXPECT_EQ(parent.get(), transient->transient_parent());
94 EXPECT_EQ(GetDefaultContainer(), transient->parent()); 93 EXPECT_EQ(GetDefaultContainer(), transient->parent());
95 94
96 // The transient should be destroyed with its parent. 95 // The transient should be destroyed with its parent.
97 parent.reset(); 96 parent.reset();
98 EXPECT_TRUE(destruction_observer.destroyed()); 97 EXPECT_TRUE(destruction_observer.destroyed());
99 } 98 }
100 99
101 TEST_F(ModalContainerLayoutManagerTest, ModalTransient) { 100 TEST_F(ModalContainerLayoutManagerTest, ModalTransient) {
102 scoped_ptr<aura::Window> parent(TestWindow::OpenTestWindow(NULL, false)); 101 scoped_ptr<aura::Window> parent(TestWindow::OpenTestWindow(NULL, false));
103 // parent should be active. 102 // parent should be active.
104 EXPECT_TRUE(IsActiveWindow(parent.get())); 103 EXPECT_EQ(parent.get(), aura::RootWindow::GetInstance()->active_window());
105 104
106 aura::Window* t1 = TestWindow::OpenTestWindow(parent.get(), true); 105 aura::Window* t1 = TestWindow::OpenTestWindow(parent.get(), true);
107 TransientWindowObserver do1; 106 TransientWindowObserver do1;
108 t1->AddObserver(&do1); 107 t1->AddObserver(&do1);
109 108
110 EXPECT_EQ(parent.get(), t1->transient_parent()); 109 EXPECT_EQ(parent.get(), t1->transient_parent());
111 EXPECT_EQ(GetModalContainer(), t1->parent()); 110 EXPECT_EQ(GetModalContainer(), t1->parent());
112 111
113 // t1 should now be active. 112 // t1 should now be active.
114 EXPECT_TRUE(IsActiveWindow(t1)); 113 EXPECT_EQ(t1, aura::RootWindow::GetInstance()->active_window());
115 114
116 // Attempting to click the parent should result in no activation change. 115 // Attempting to click the parent should result in no activation change.
117 aura::test::EventGenerator e1(parent.get()); 116 aura::test::EventGenerator e1(parent.get());
118 e1.ClickLeftButton(); 117 e1.ClickLeftButton();
119 EXPECT_TRUE(IsActiveWindow(t1)); 118 EXPECT_EQ(t1, aura::RootWindow::GetInstance()->active_window());
120 119
121 // Now open another modal transient parented to the original modal transient. 120 // Now open another modal transient parented to the original modal transient.
122 aura::Window* t2 = TestWindow::OpenTestWindow(t1, true); 121 aura::Window* t2 = TestWindow::OpenTestWindow(t1, true);
123 TransientWindowObserver do2; 122 TransientWindowObserver do2;
124 t2->AddObserver(&do2); 123 t2->AddObserver(&do2);
125 124
126 EXPECT_TRUE(IsActiveWindow(t2)); 125 EXPECT_EQ(t2, aura::RootWindow::GetInstance()->active_window());
127 126
128 EXPECT_EQ(t1, t2->transient_parent()); 127 EXPECT_EQ(t1, t2->transient_parent());
129 EXPECT_EQ(GetModalContainer(), t2->parent()); 128 EXPECT_EQ(GetModalContainer(), t2->parent());
130 129
131 // t2 should still be active, even after clicking on t1. 130 // t2 should still be active, even after clicking on t1.
132 aura::test::EventGenerator e2(t1); 131 aura::test::EventGenerator e2(t1);
133 e2.ClickLeftButton(); 132 e2.ClickLeftButton();
134 EXPECT_TRUE(IsActiveWindow(t2)); 133 EXPECT_EQ(t2, aura::RootWindow::GetInstance()->active_window());
135 134
136 // Both transients should be destroyed with parent. 135 // Both transients should be destroyed with parent.
137 parent.reset(); 136 parent.reset();
138 EXPECT_TRUE(do1.destroyed()); 137 EXPECT_TRUE(do1.destroyed());
139 EXPECT_TRUE(do2.destroyed()); 138 EXPECT_TRUE(do2.destroyed());
140 } 139 }
141 140
142 // Tests that we can activate an unrelated window after a modal window is closed 141 // Tests that we can activate an unrelated window after a modal window is closed
143 // for a window. 142 // for a window.
144 TEST_F(ModalContainerLayoutManagerTest, CanActivateAfterEndModalSession) { 143 TEST_F(ModalContainerLayoutManagerTest, CanActivateAfterEndModalSession) {
145 scoped_ptr<aura::Window> unrelated(TestWindow::OpenTestWindow(NULL, false)); 144 scoped_ptr<aura::Window> unrelated(TestWindow::OpenTestWindow(NULL, false));
146 unrelated->SetBounds(gfx::Rect(100, 100, 50, 50)); 145 unrelated->SetBounds(gfx::Rect(100, 100, 50, 50));
147 scoped_ptr<aura::Window> parent(TestWindow::OpenTestWindow(NULL, false)); 146 scoped_ptr<aura::Window> parent(TestWindow::OpenTestWindow(NULL, false));
148 // parent should be active. 147 // parent should be active.
149 EXPECT_TRUE(IsActiveWindow(parent.get())); 148 EXPECT_EQ(parent.get(), aura::RootWindow::GetInstance()->active_window());
150 149
151 scoped_ptr<aura::Window> transient( 150 scoped_ptr<aura::Window> transient(
152 TestWindow::OpenTestWindow(parent.get(), true)); 151 TestWindow::OpenTestWindow(parent.get(), true));
153 // t1 should now be active. 152 // t1 should now be active.
154 EXPECT_TRUE(IsActiveWindow(transient.get())); 153 EXPECT_EQ(transient.get(), aura::RootWindow::GetInstance()->active_window());
155 154
156 // Attempting to click the parent should result in no activation change. 155 // Attempting to click the parent should result in no activation change.
157 aura::test::EventGenerator e1(parent.get()); 156 aura::test::EventGenerator e1(parent.get());
158 e1.ClickLeftButton(); 157 e1.ClickLeftButton();
159 EXPECT_TRUE(IsActiveWindow(transient.get())); 158 EXPECT_EQ(transient.get(), aura::RootWindow::GetInstance()->active_window());
160 159
161 // Now close the transient. 160 // Now close the transient.
162 transient.reset(); 161 transient.reset();
163 162
164 // parent should now be active again. 163 // parent should now be active again.
165 EXPECT_TRUE(IsActiveWindow(parent.get())); 164 EXPECT_EQ(parent.get(), aura::RootWindow::GetInstance()->active_window());
166 165
167 // Attempting to click unrelated should activate it. 166 // Attempting to click unrelated should activate it.
168 aura::test::EventGenerator e2(unrelated.get()); 167 aura::test::EventGenerator e2(unrelated.get());
169 e2.ClickLeftButton(); 168 e2.ClickLeftButton();
170 EXPECT_TRUE(IsActiveWindow(unrelated.get())); 169 EXPECT_EQ(unrelated.get(), aura::RootWindow::GetInstance()->active_window());
171 } 170 }
172 171
173 } // namespace test 172 } // namespace test
174 } // namespace aura_shell 173 } // namespace aura_shell
OLDNEW
« no previous file with comments | « ui/aura_shell/modal_container_layout_manager.cc ('k') | ui/aura_shell/root_window_event_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698