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

Side by Side Diff: athena/wm/window_manager_unittest.cc

Issue 546123002: Ensure that an activity is activated when overview mode is exited (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "athena/wm/public/window_manager.h" 5 #include "athena/wm/public/window_manager.h"
6 6
7 #include "athena/screen/public/screen_manager.h" 7 #include "athena/screen/public/screen_manager.h"
8 #include "athena/test/athena_test_base.h" 8 #include "athena/test/athena_test_base.h"
9 #include "athena/wm/public/window_list_provider.h" 9 #include "athena/wm/public/window_list_provider.h"
10 #include "athena/wm/split_view_controller.h" 10 #include "athena/wm/split_view_controller.h"
11 #include "athena/wm/test/window_manager_impl_test_api.h" 11 #include "athena/wm/test/window_manager_impl_test_api.h"
12 #include "athena/wm/window_manager_impl.h" 12 #include "athena/wm/window_manager_impl.h"
13 #include "ui/aura/client/window_tree_client.h" 13 #include "ui/aura/client/window_tree_client.h"
14 #include "ui/aura/test/test_window_delegate.h" 14 #include "ui/aura/test/test_window_delegate.h"
15 #include "ui/aura/window.h" 15 #include "ui/aura/window.h"
16 #include "ui/base/hit_test.h" 16 #include "ui/base/hit_test.h"
17 #include "ui/events/test/event_generator.h" 17 #include "ui/events/test/event_generator.h"
18 #include "ui/gfx/display.h" 18 #include "ui/gfx/display.h"
19 #include "ui/gfx/screen.h" 19 #include "ui/gfx/screen.h"
20 #include "ui/wm/core/window_util.h" 20 #include "ui/wm/core/window_util.h"
21 21
22 namespace {
23
24 scoped_ptr<aura::Window> CreateWindow(aura::WindowDelegate* delegate) {
25 scoped_ptr<aura::Window> window(new aura::Window(delegate));
26 window->SetType(ui::wm::WINDOW_TYPE_NORMAL);
27 window->Init(aura::WINDOW_LAYER_SOLID_COLOR);
28 window->Show();
29 return window.Pass();
30 }
31
32 } // namespace
33
34 namespace athena { 22 namespace athena {
35 23
36 typedef test::AthenaTestBase WindowManagerTest; 24 class WindowManagerTest : public test::AthenaTestBase {
25 public:
26 WindowManagerTest() {}
27 virtual ~WindowManagerTest() {}
28
29 scoped_ptr<aura::Window> CreateWindow(aura::WindowDelegate* delegate) {
30 scoped_ptr<aura::Window> window(CreateTestWindow(delegate, gfx::Rect()));
31 window->Show();
32 return window.Pass();
33 }
34
35 private:
36 DISALLOW_COPY_AND_ASSIGN(WindowManagerTest);
37 };
37 38
38 TEST_F(WindowManagerTest, OverviewModeBasics) { 39 TEST_F(WindowManagerTest, OverviewModeBasics) {
39 aura::test::TestWindowDelegate delegate; 40 aura::test::TestWindowDelegate delegate;
40 scoped_ptr<aura::Window> first(CreateWindow(&delegate)); 41 scoped_ptr<aura::Window> first(CreateWindow(&delegate));
41 scoped_ptr<aura::Window> second(CreateWindow(&delegate)); 42 scoped_ptr<aura::Window> second(CreateWindow(&delegate));
42 43
43 test::WindowManagerImplTestApi wm_api; 44 test::WindowManagerImplTestApi wm_api;
44 aura::client::ParentWindowWithContext(
45 first.get(), ScreenManager::Get()->GetContext(), gfx::Rect());
46 aura::client::ParentWindowWithContext(
47 second.get(), ScreenManager::Get()->GetContext(), gfx::Rect());
48 wm::ActivateWindow(second.get()); 45 wm::ActivateWindow(second.get());
49 46
50 ASSERT_FALSE(WindowManager::GetInstance()->IsOverviewModeActive()); 47 ASSERT_FALSE(WindowManager::GetInstance()->IsOverviewModeActive());
51 EXPECT_EQ(first->bounds().ToString(), second->bounds().ToString()); 48 EXPECT_EQ(first->bounds().ToString(), second->bounds().ToString());
52 EXPECT_EQ(gfx::Screen::GetNativeScreen() 49 EXPECT_EQ(gfx::Screen::GetNativeScreen()
53 ->GetPrimaryDisplay() 50 ->GetPrimaryDisplay()
54 .work_area() 51 .work_area()
55 .size() 52 .size()
56 .ToString(), 53 .ToString(),
57 first->bounds().size().ToString()); 54 first->bounds().size().ToString());
(...skipping 17 matching lines...) Expand all
75 WindowManager::GetInstance()->ToggleOverview(); 72 WindowManager::GetInstance()->ToggleOverview();
76 ASSERT_FALSE(WindowManager::GetInstance()->IsOverviewModeActive()); 73 ASSERT_FALSE(WindowManager::GetInstance()->IsOverviewModeActive());
77 EXPECT_FALSE(first->IsVisible()); 74 EXPECT_FALSE(first->IsVisible());
78 EXPECT_TRUE(second->IsVisible()); 75 EXPECT_TRUE(second->IsVisible());
79 } 76 }
80 77
81 TEST_F(WindowManagerTest, OverviewToSplitViewMode) { 78 TEST_F(WindowManagerTest, OverviewToSplitViewMode) {
82 test::WindowManagerImplTestApi wm_api; 79 test::WindowManagerImplTestApi wm_api;
83 80
84 aura::test::TestWindowDelegate delegate; 81 aura::test::TestWindowDelegate delegate;
85 scoped_ptr<aura::Window> w1(CreateTestWindow(&delegate, gfx::Rect())); 82 scoped_ptr<aura::Window> w1(CreateWindow(&delegate));
86 scoped_ptr<aura::Window> w2(CreateTestWindow(&delegate, gfx::Rect())); 83 scoped_ptr<aura::Window> w2(CreateWindow(&delegate));
87 scoped_ptr<aura::Window> w3(CreateTestWindow(&delegate, gfx::Rect())); 84 scoped_ptr<aura::Window> w3(CreateWindow(&delegate));
88 wm::ActivateWindow(w3.get()); 85 wm::ActivateWindow(w3.get());
89 86
90 WindowManager::GetInstance()->ToggleOverview(); 87 WindowManager::GetInstance()->ToggleOverview();
91 EXPECT_TRUE(w1->IsVisible()); 88 EXPECT_TRUE(w1->IsVisible());
92 EXPECT_TRUE(w2->IsVisible()); 89 EXPECT_TRUE(w2->IsVisible());
93 EXPECT_TRUE(w3->IsVisible()); 90 EXPECT_TRUE(w3->IsVisible());
94 91
95 // Go into split-view mode. 92 // Go into split-view mode.
96 WindowOverviewModeDelegate* overview_delegate = wm_api.wm(); 93 WindowOverviewModeDelegate* overview_delegate = wm_api.wm();
97 overview_delegate->OnSplitViewMode(NULL, w2.get()); 94 overview_delegate->OnSelectSplitViewWindow(w3.get(), NULL, w3.get());
98 EXPECT_TRUE(w3->IsVisible()); 95 EXPECT_TRUE(w3->IsVisible());
99 EXPECT_TRUE(w2->IsVisible()); 96 EXPECT_TRUE(w2->IsVisible());
100 EXPECT_FALSE(w1->IsVisible()); 97 EXPECT_FALSE(w1->IsVisible());
101 } 98 }
102 99
100 TEST_F(WindowManagerTest, NewWindowFromOverview) {
101 aura::test::TestWindowDelegate delegate;
102 scoped_ptr<aura::Window> w1(CreateWindow(&delegate));
103 scoped_ptr<aura::Window> w2(CreateWindow(&delegate));
104
105 WindowManager::GetInstance()->ToggleOverview();
106 EXPECT_TRUE(w1->IsVisible());
107 EXPECT_TRUE(w2->IsVisible());
108
109 // Test that opening a new window exits overview mode. The new window could
110 // have been opened by JavaScript or by the home card.
111 scoped_ptr<aura::Window> w3(CreateWindow(&delegate));
112
113 ASSERT_FALSE(WindowManager::GetInstance()->IsOverviewModeActive());
114 EXPECT_TRUE(w3->IsVisible());
115 EXPECT_TRUE(wm::IsActiveWindow(w3.get()));
116 EXPECT_FALSE(w1->IsVisible());
117 EXPECT_FALSE(w2->IsVisible());
118 }
119
103 TEST_F(WindowManagerTest, BezelGestureToSplitViewMode) { 120 TEST_F(WindowManagerTest, BezelGestureToSplitViewMode) {
104 aura::test::TestWindowDelegate delegate; 121 aura::test::TestWindowDelegate delegate;
105 scoped_ptr<aura::Window> first(CreateWindow(&delegate)); 122 scoped_ptr<aura::Window> first(CreateWindow(&delegate));
106 scoped_ptr<aura::Window> second(CreateWindow(&delegate)); 123 scoped_ptr<aura::Window> second(CreateWindow(&delegate));
107 scoped_ptr<aura::Window> third(CreateWindow(&delegate)); 124 scoped_ptr<aura::Window> third(CreateWindow(&delegate));
108 125
109 test::WindowManagerImplTestApi wm_api; 126 test::WindowManagerImplTestApi wm_api;
110 aura::client::ParentWindowWithContext(
111 first.get(), ScreenManager::Get()->GetContext(), gfx::Rect());
112 aura::client::ParentWindowWithContext(
113 second.get(), ScreenManager::Get()->GetContext(), gfx::Rect());
114 aura::client::ParentWindowWithContext(
115 third.get(), ScreenManager::Get()->GetContext(), gfx::Rect());
116 127
117 // Test that going into split-view mode with two-finger gesture selects the 128 // Test that going into split-view mode with two-finger gesture selects the
118 // correct windows on left and right splits. 129 // correct windows on left and right splits.
119 ui::test::EventGenerator generator(root_window()); 130 ui::test::EventGenerator generator(root_window());
120 const gfx::Point start_points[2] = { 131 const gfx::Point start_points[2] = {
121 gfx::Point(2, 10), gfx::Point(4, 20), 132 gfx::Point(2, 10), gfx::Point(4, 20),
122 }; 133 };
123 const int kEventTimeSepration = 16; 134 const int kEventTimeSepration = 16;
124 int x_middle = root_window()->bounds().width() / 2; 135 int x_middle = root_window()->bounds().width() / 2;
125 generator.GestureMultiFingerScroll( 136 generator.GestureMultiFingerScroll(
126 2, start_points, kEventTimeSepration, 1, x_middle, 0); 137 2, start_points, kEventTimeSepration, 1, x_middle, 0);
127 ASSERT_TRUE(wm_api.GetSplitViewController()->IsSplitViewModeActive()); 138 ASSERT_TRUE(wm_api.GetSplitViewController()->IsSplitViewModeActive());
128 EXPECT_EQ(second.get(), wm_api.GetSplitViewController()->left_window()); 139 EXPECT_EQ(second.get(), wm_api.GetSplitViewController()->left_window());
129 EXPECT_EQ(third.get(), wm_api.GetSplitViewController()->right_window()); 140 EXPECT_EQ(third.get(), wm_api.GetSplitViewController()->right_window());
130 EXPECT_EQ(second->bounds().size().ToString(), 141 EXPECT_EQ(second->bounds().size().ToString(),
131 third->bounds().size().ToString()); 142 third->bounds().size().ToString());
132 } 143 }
133 144
134 TEST_F(WindowManagerTest, BezelGestureToSwitchBetweenWindows) { 145 TEST_F(WindowManagerTest, BezelGestureToSwitchBetweenWindows) {
135 aura::test::TestWindowDelegate delegate; 146 aura::test::TestWindowDelegate delegate;
136 scoped_ptr<aura::Window> first(CreateWindow(&delegate)); 147 scoped_ptr<aura::Window> first(CreateWindow(&delegate));
137 scoped_ptr<aura::Window> second(CreateWindow(&delegate)); 148 scoped_ptr<aura::Window> second(CreateWindow(&delegate));
138 scoped_ptr<aura::Window> third(CreateWindow(&delegate)); 149 scoped_ptr<aura::Window> third(CreateWindow(&delegate));
139 first->Hide(); 150 first->Hide();
140 second->Hide(); 151 second->Hide();
141 152
142 test::WindowManagerImplTestApi wm_api; 153 test::WindowManagerImplTestApi wm_api;
143 aura::client::ParentWindowWithContext(
144 first.get(), ScreenManager::Get()->GetContext(), gfx::Rect());
145 aura::client::ParentWindowWithContext(
146 second.get(), ScreenManager::Get()->GetContext(), gfx::Rect());
147 aura::client::ParentWindowWithContext(
148 third.get(), ScreenManager::Get()->GetContext(), gfx::Rect());
149 154
150 EXPECT_EQ(third.get(), 155 EXPECT_EQ(third.get(),
151 wm_api.GetWindowListProvider()->GetWindowList().back()); 156 wm_api.GetWindowListProvider()->GetWindowList().back());
152 157
153 // Do a two-finger swipe from the left bezel. 158 // Do a two-finger swipe from the left bezel.
154 ui::test::EventGenerator generator(root_window()); 159 ui::test::EventGenerator generator(root_window());
155 const gfx::Point left_bezel_points[2] = { 160 const gfx::Point left_bezel_points[2] = {
156 gfx::Point(2, 10), gfx::Point(4, 20), 161 gfx::Point(2, 10), gfx::Point(4, 20),
157 }; 162 };
158 const int kEventTimeSepration = 16; 163 const int kEventTimeSepration = 16;
159 int width = root_window()->bounds().width(); 164 int width = root_window()->bounds().width();
160 generator.GestureMultiFingerScroll( 165 generator.GestureMultiFingerScroll(
161 2, left_bezel_points, kEventTimeSepration, 1, width, 0); 166 2, left_bezel_points, kEventTimeSepration, 1, width, 0);
162 EXPECT_TRUE(wm::IsActiveWindow(second.get())); 167 EXPECT_TRUE(wm::IsActiveWindow(second.get()));
163 EXPECT_EQ(second.get(), 168 EXPECT_EQ(second.get(),
164 wm_api.GetWindowListProvider()->GetWindowList().back()); 169 wm_api.GetWindowListProvider()->GetWindowList().back());
165 } 170 }
166 171
167 TEST_F(WindowManagerTest, TitleDragSwitchBetweenWindows) { 172 TEST_F(WindowManagerTest, TitleDragSwitchBetweenWindows) {
168 aura::test::TestWindowDelegate delegate; 173 aura::test::TestWindowDelegate delegate;
169 delegate.set_window_component(HTCAPTION); 174 delegate.set_window_component(HTCAPTION);
170 scoped_ptr<aura::Window> first(CreateWindow(&delegate)); 175 scoped_ptr<aura::Window> first(CreateWindow(&delegate));
171 scoped_ptr<aura::Window> second(CreateWindow(&delegate)); 176 scoped_ptr<aura::Window> second(CreateWindow(&delegate));
172 scoped_ptr<aura::Window> third(CreateWindow(&delegate)); 177 scoped_ptr<aura::Window> third(CreateWindow(&delegate));
173 178
174 test::WindowManagerImplTestApi wm_api; 179 test::WindowManagerImplTestApi wm_api;
175 aura::client::ParentWindowWithContext(
176 first.get(), ScreenManager::Get()->GetContext(), gfx::Rect());
177 aura::client::ParentWindowWithContext(
178 second.get(), ScreenManager::Get()->GetContext(), gfx::Rect());
179 aura::client::ParentWindowWithContext(
180 third.get(), ScreenManager::Get()->GetContext(), gfx::Rect());
181 180
182 EXPECT_EQ(third.get(), 181 EXPECT_EQ(third.get(),
183 wm_api.GetWindowListProvider()->GetWindowList().back()); 182 wm_api.GetWindowListProvider()->GetWindowList().back());
184 183
185 // Do a title-swipe from the top to switch to the previous window. 184 // Do a title-swipe from the top to switch to the previous window.
186 ui::test::EventGenerator generator(root_window()); 185 ui::test::EventGenerator generator(root_window());
187 generator.GestureScrollSequence(gfx::Point(20, 10), 186 generator.GestureScrollSequence(gfx::Point(20, 10),
188 gfx::Point(20, 400), 187 gfx::Point(20, 400),
189 base::TimeDelta::FromMilliseconds(20), 188 base::TimeDelta::FromMilliseconds(20),
190 5); 189 5);
(...skipping 28 matching lines...) Expand all
219 218
220 TEST_F(WindowManagerTest, TitleDragSwitchBetweenWindowsInSplitViewMode) { 219 TEST_F(WindowManagerTest, TitleDragSwitchBetweenWindowsInSplitViewMode) {
221 aura::test::TestWindowDelegate delegate; 220 aura::test::TestWindowDelegate delegate;
222 delegate.set_window_component(HTCAPTION); 221 delegate.set_window_component(HTCAPTION);
223 scoped_ptr<aura::Window> first(CreateWindow(&delegate)); 222 scoped_ptr<aura::Window> first(CreateWindow(&delegate));
224 scoped_ptr<aura::Window> second(CreateWindow(&delegate)); 223 scoped_ptr<aura::Window> second(CreateWindow(&delegate));
225 scoped_ptr<aura::Window> third(CreateWindow(&delegate)); 224 scoped_ptr<aura::Window> third(CreateWindow(&delegate));
226 scoped_ptr<aura::Window> fourth(CreateWindow(&delegate)); 225 scoped_ptr<aura::Window> fourth(CreateWindow(&delegate));
227 226
228 test::WindowManagerImplTestApi wm_api; 227 test::WindowManagerImplTestApi wm_api;
229 aura::client::ParentWindowWithContext(
230 first.get(), ScreenManager::Get()->GetContext(), gfx::Rect());
231 aura::client::ParentWindowWithContext(
232 second.get(), ScreenManager::Get()->GetContext(), gfx::Rect());
233 aura::client::ParentWindowWithContext(
234 third.get(), ScreenManager::Get()->GetContext(), gfx::Rect());
235 aura::client::ParentWindowWithContext(
236 fourth.get(), ScreenManager::Get()->GetContext(), gfx::Rect());
237 228
238 // Test that going into split-view mode with two-finger gesture selects the 229 // Test that going into split-view mode with two-finger gesture selects the
239 // correct windows on left and right splits. 230 // correct windows on left and right splits.
240 ui::test::EventGenerator generator(root_window()); 231 ui::test::EventGenerator generator(root_window());
241 const gfx::Point start_points[2] = { 232 const gfx::Point start_points[2] = {
242 gfx::Point(2, 10), gfx::Point(4, 20), 233 gfx::Point(2, 10), gfx::Point(4, 20),
243 }; 234 };
244 const int kEventTimeSepration = 16; 235 const int kEventTimeSepration = 16;
245 int x_middle = root_window()->bounds().width() / 2; 236 int x_middle = root_window()->bounds().width() / 2;
246 generator.GestureMultiFingerScroll( 237 generator.GestureMultiFingerScroll(
(...skipping 26 matching lines...) Expand all
273 ASSERT_EQ(4u, windows.size()); 264 ASSERT_EQ(4u, windows.size());
274 EXPECT_EQ(second.get(), windows[3]); 265 EXPECT_EQ(second.get(), windows[3]);
275 EXPECT_EQ(third.get(), windows[2]); 266 EXPECT_EQ(third.get(), windows[2]);
276 } 267 }
277 268
278 TEST_F(WindowManagerTest, NewWindowBounds) { 269 TEST_F(WindowManagerTest, NewWindowBounds) {
279 aura::test::TestWindowDelegate delegate; 270 aura::test::TestWindowDelegate delegate;
280 scoped_ptr<aura::Window> first(CreateWindow(&delegate)); 271 scoped_ptr<aura::Window> first(CreateWindow(&delegate));
281 272
282 test::WindowManagerImplTestApi wm_api; 273 test::WindowManagerImplTestApi wm_api;
283 aura::client::ParentWindowWithContext(
284 first.get(), ScreenManager::Get()->GetContext(), gfx::Rect());
285 // The window should have the same size as the container. 274 // The window should have the same size as the container.
286 const gfx::Size work_area = 275 const gfx::Size work_area =
287 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().work_area().size(); 276 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().work_area().size();
288 EXPECT_EQ(work_area.ToString(), 277 EXPECT_EQ(work_area.ToString(),
289 first->bounds().size().ToString()); 278 first->bounds().size().ToString());
290 EXPECT_TRUE(first->bounds().origin().IsOrigin()); 279 EXPECT_TRUE(first->bounds().origin().IsOrigin());
291 280
292 // A second window should have the same bounds as the first one. 281 // A second window should have the same bounds as the first one.
293 scoped_ptr<aura::Window> second(CreateWindow(&delegate)); 282 scoped_ptr<aura::Window> second(CreateWindow(&delegate));
294 aura::client::ParentWindowWithContext(
295 second.get(), ScreenManager::Get()->GetContext(), gfx::Rect());
296 EXPECT_EQ(first->bounds().ToString(), second->bounds().ToString()); 283 EXPECT_EQ(first->bounds().ToString(), second->bounds().ToString());
297 284
298 // Get into split view. 285 // Get into split view.
299 wm_api.GetSplitViewController()->ActivateSplitMode(NULL, NULL); 286 wm_api.GetSplitViewController()->ActivateSplitMode(NULL, NULL);
300 const gfx::Rect left_bounds = 287 const gfx::Rect left_bounds =
301 wm_api.GetSplitViewController()->left_window()->bounds(); 288 wm_api.GetSplitViewController()->left_window()->bounds();
302 EXPECT_NE(work_area.ToString(), 289 EXPECT_NE(work_area.ToString(),
303 left_bounds.size().ToString()); 290 left_bounds.size().ToString());
304 291
305 // A new window should replace the left window when in split view. 292 // A new window should replace the left window when in split view.
306 scoped_ptr<aura::Window> third(CreateWindow(&delegate)); 293 scoped_ptr<aura::Window> third(CreateWindow(&delegate));
307 aura::client::ParentWindowWithContext(
308 third.get(), ScreenManager::Get()->GetContext(), gfx::Rect());
309 EXPECT_EQ(wm_api.GetSplitViewController()->left_window(), third.get()); 294 EXPECT_EQ(wm_api.GetSplitViewController()->left_window(), third.get());
310 EXPECT_EQ(left_bounds.ToString(), third->bounds().ToString()); 295 EXPECT_EQ(left_bounds.ToString(), third->bounds().ToString());
311 } 296 }
312 297
313 TEST_F(WindowManagerTest, SplitModeActivationByShortcut) { 298 TEST_F(WindowManagerTest, SplitModeActivationByShortcut) {
314 test::WindowManagerImplTestApi wm_api; 299 test::WindowManagerImplTestApi wm_api;
315 300
316 aura::test::TestWindowDelegate delegate; 301 aura::test::TestWindowDelegate delegate;
317 scoped_ptr<aura::Window> w1(CreateTestWindow(&delegate, gfx::Rect())); 302 scoped_ptr<aura::Window> w1(CreateTestWindow(&delegate, gfx::Rect()));
318 w1->Show(); 303 w1->Show();
319 304
320 ui::test::EventGenerator generator(root_window()); 305 ui::test::EventGenerator generator(root_window());
321 306
322 // Splitview mode needs at least two windows. 307 // Splitview mode needs at least two windows.
323 generator.PressKey(ui::VKEY_F6, ui::EF_CONTROL_DOWN); 308 generator.PressKey(ui::VKEY_F6, ui::EF_CONTROL_DOWN);
324 generator.ReleaseKey(ui::VKEY_F6, ui::EF_CONTROL_DOWN); 309 generator.ReleaseKey(ui::VKEY_F6, ui::EF_CONTROL_DOWN);
325 EXPECT_FALSE(wm_api.GetSplitViewController()->IsSplitViewModeActive()); 310 EXPECT_FALSE(wm_api.GetSplitViewController()->IsSplitViewModeActive());
326 311
327 scoped_ptr<aura::Window> w2(CreateTestWindow(&delegate, gfx::Rect())); 312 scoped_ptr<aura::Window> w2(CreateWindow(&delegate));
328 w2->Show(); 313 w2->Show();
329 314
330 generator.PressKey(ui::VKEY_F6, ui::EF_CONTROL_DOWN); 315 generator.PressKey(ui::VKEY_F6, ui::EF_CONTROL_DOWN);
331 generator.ReleaseKey(ui::VKEY_F6, ui::EF_CONTROL_DOWN); 316 generator.ReleaseKey(ui::VKEY_F6, ui::EF_CONTROL_DOWN);
332 EXPECT_TRUE(wm_api.GetSplitViewController()->IsSplitViewModeActive()); 317 EXPECT_TRUE(wm_api.GetSplitViewController()->IsSplitViewModeActive());
333 int width = 318 int width =
334 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().work_area().width(); 319 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().work_area().width();
335 320
336 EXPECT_EQ(width / 2, w1->bounds().width()); 321 EXPECT_EQ(width / 2, w1->bounds().width());
337 EXPECT_EQ(width / 2, w2->bounds().width()); 322 EXPECT_EQ(width / 2, w2->bounds().width());
338 323
339 // Toggle back to normal mode. 324 // Toggle back to normal mode.
340 generator.PressKey(ui::VKEY_F6, ui::EF_CONTROL_DOWN); 325 generator.PressKey(ui::VKEY_F6, ui::EF_CONTROL_DOWN);
341 generator.ReleaseKey(ui::VKEY_F6, ui::EF_CONTROL_DOWN); 326 generator.ReleaseKey(ui::VKEY_F6, ui::EF_CONTROL_DOWN);
342 EXPECT_FALSE(wm_api.GetSplitViewController()->IsSplitViewModeActive()); 327 EXPECT_FALSE(wm_api.GetSplitViewController()->IsSplitViewModeActive());
343 328
344 EXPECT_EQ(width, w1->bounds().width()); 329 EXPECT_EQ(width, w1->bounds().width());
345 EXPECT_EQ(width, w2->bounds().width()); 330 EXPECT_EQ(width, w2->bounds().width());
346 } 331 }
347 332
348 TEST_F(WindowManagerTest, OverviewModeFromSplitMode) { 333 TEST_F(WindowManagerTest, OverviewModeFromSplitMode) {
349 test::WindowManagerImplTestApi wm_api; 334 test::WindowManagerImplTestApi wm_api;
350 335
351 aura::test::TestWindowDelegate delegate; 336 aura::test::TestWindowDelegate delegate;
352 scoped_ptr<aura::Window> w1(CreateTestWindow(&delegate, gfx::Rect())); 337 scoped_ptr<aura::Window> w1(CreateWindow(&delegate));
353 scoped_ptr<aura::Window> w2(CreateTestWindow(&delegate, gfx::Rect())); 338 scoped_ptr<aura::Window> w2(CreateWindow(&delegate));
354 scoped_ptr<aura::Window> w3(CreateTestWindow(&delegate, gfx::Rect())); 339 scoped_ptr<aura::Window> w3(CreateWindow(&delegate));
355 340
356 // Get into split-view mode, and then turn on overview mode. 341 // Get into split-view mode, and then turn on overview mode.
357 wm_api.GetSplitViewController()->ActivateSplitMode(NULL, NULL); 342 wm_api.GetSplitViewController()->ActivateSplitMode(NULL, NULL);
358 WindowManager::GetInstance()->ToggleOverview(); 343 WindowManager::GetInstance()->ToggleOverview();
359 EXPECT_TRUE(wm_api.GetSplitViewController()->IsSplitViewModeActive()); 344 EXPECT_TRUE(wm_api.GetSplitViewController()->IsSplitViewModeActive());
360 EXPECT_EQ(w3.get(), wm_api.GetSplitViewController()->left_window()); 345 EXPECT_EQ(w3.get(), wm_api.GetSplitViewController()->left_window());
361 EXPECT_EQ(w2.get(), wm_api.GetSplitViewController()->right_window()); 346 EXPECT_EQ(w2.get(), wm_api.GetSplitViewController()->right_window());
362 347
363 WindowOverviewModeDelegate* overview_delegate = wm_api.wm(); 348 WindowOverviewModeDelegate* overview_delegate = wm_api.wm();
364 overview_delegate->OnSelectWindow(w1.get()); 349 overview_delegate->OnSelectWindow(w1.get());
365 EXPECT_FALSE(wm_api.GetSplitViewController()->IsSplitViewModeActive()); 350 EXPECT_FALSE(wm_api.GetSplitViewController()->IsSplitViewModeActive());
366 EXPECT_TRUE(w1->IsVisible()); 351 EXPECT_TRUE(w1->IsVisible());
367 // Make sure the windows that were in split-view mode are hidden. 352 // Make sure the windows that were in split-view mode are hidden.
368 EXPECT_FALSE(w2->IsVisible()); 353 EXPECT_FALSE(w2->IsVisible());
369 EXPECT_FALSE(w3->IsVisible()); 354 EXPECT_FALSE(w3->IsVisible());
370 } 355 }
371 356
372 } // namespace athena 357 } // namespace athena
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698