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

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

Issue 550043002: Keep the split view activities topmost in z-order in Athena (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> CreateAndActivateWindow(
30 aura::WindowDelegate* delegate) {
31 scoped_ptr<aura::Window> window(CreateTestWindow(delegate, gfx::Rect()));
32 window->Show();
33 wm::ActivateWindow(window.get());
34 return window.Pass();
35 }
36
37 private:
38 DISALLOW_COPY_AND_ASSIGN(WindowManagerTest);
39 };
37 40
38 TEST_F(WindowManagerTest, Empty) { 41 TEST_F(WindowManagerTest, Empty) {
39 } 42 }
40 43
41 TEST_F(WindowManagerTest, OverviewModeBasics) { 44 TEST_F(WindowManagerTest, OverviewModeBasics) {
42 aura::test::TestWindowDelegate delegate; 45 aura::test::TestWindowDelegate delegate;
43 scoped_ptr<aura::Window> first(CreateWindow(&delegate)); 46 scoped_ptr<aura::Window> first(CreateAndActivateWindow(&delegate));
44 scoped_ptr<aura::Window> second(CreateWindow(&delegate)); 47 scoped_ptr<aura::Window> second(CreateAndActivateWindow(&delegate));
45 48
46 test::WindowManagerImplTestApi wm_api; 49 test::WindowManagerImplTestApi wm_api;
47 aura::client::ParentWindowWithContext(
48 first.get(), ScreenManager::Get()->GetContext(), gfx::Rect());
49 aura::client::ParentWindowWithContext(
50 second.get(), ScreenManager::Get()->GetContext(), gfx::Rect());
51 wm::ActivateWindow(second.get());
52 50
53 ASSERT_FALSE(WindowManager::GetInstance()->IsOverviewModeActive()); 51 ASSERT_FALSE(WindowManager::GetInstance()->IsOverviewModeActive());
54 EXPECT_EQ(first->bounds().ToString(), second->bounds().ToString()); 52 EXPECT_EQ(first->bounds().ToString(), second->bounds().ToString());
55 EXPECT_EQ(gfx::Screen::GetNativeScreen() 53 EXPECT_EQ(gfx::Screen::GetNativeScreen()
56 ->GetPrimaryDisplay() 54 ->GetPrimaryDisplay()
57 .work_area() 55 .work_area()
58 .size() 56 .size()
59 .ToString(), 57 .ToString(),
60 first->bounds().size().ToString()); 58 first->bounds().size().ToString());
61 EXPECT_FALSE(WindowManager::GetInstance()->IsOverviewModeActive()); 59 EXPECT_FALSE(WindowManager::GetInstance()->IsOverviewModeActive());
(...skipping 16 matching lines...) Expand all
78 WindowManager::GetInstance()->ToggleOverview(); 76 WindowManager::GetInstance()->ToggleOverview();
79 ASSERT_FALSE(WindowManager::GetInstance()->IsOverviewModeActive()); 77 ASSERT_FALSE(WindowManager::GetInstance()->IsOverviewModeActive());
80 EXPECT_FALSE(first->IsVisible()); 78 EXPECT_FALSE(first->IsVisible());
81 EXPECT_TRUE(second->IsVisible()); 79 EXPECT_TRUE(second->IsVisible());
82 } 80 }
83 81
84 TEST_F(WindowManagerTest, OverviewToSplitViewMode) { 82 TEST_F(WindowManagerTest, OverviewToSplitViewMode) {
85 test::WindowManagerImplTestApi wm_api; 83 test::WindowManagerImplTestApi wm_api;
86 84
87 aura::test::TestWindowDelegate delegate; 85 aura::test::TestWindowDelegate delegate;
88 scoped_ptr<aura::Window> w1(CreateTestWindow(&delegate, gfx::Rect())); 86 scoped_ptr<aura::Window> w1(CreateAndActivateWindow(&delegate));
89 scoped_ptr<aura::Window> w2(CreateTestWindow(&delegate, gfx::Rect())); 87 scoped_ptr<aura::Window> w2(CreateAndActivateWindow(&delegate));
90 scoped_ptr<aura::Window> w3(CreateTestWindow(&delegate, gfx::Rect())); 88 scoped_ptr<aura::Window> w3(CreateAndActivateWindow(&delegate));
91 wm::ActivateWindow(w3.get());
92 89
93 WindowManager::GetInstance()->ToggleOverview(); 90 WindowManager::GetInstance()->ToggleOverview();
94 EXPECT_TRUE(w1->IsVisible()); 91 EXPECT_TRUE(w1->IsVisible());
95 EXPECT_TRUE(w2->IsVisible()); 92 EXPECT_TRUE(w2->IsVisible());
96 EXPECT_TRUE(w3->IsVisible()); 93 EXPECT_TRUE(w3->IsVisible());
97 94
98 // Go into split-view mode. 95 // Go into split-view mode.
99 WindowOverviewModeDelegate* overview_delegate = wm_api.wm(); 96 WindowOverviewModeDelegate* overview_delegate = wm_api.wm();
100 overview_delegate->OnSplitViewMode(NULL, w2.get()); 97 overview_delegate->OnSplitViewMode(w3.get(), NULL);
101 EXPECT_TRUE(w3->IsVisible()); 98 EXPECT_TRUE(w3->IsVisible());
102 EXPECT_TRUE(w2->IsVisible()); 99 EXPECT_TRUE(w2->IsVisible());
103 EXPECT_FALSE(w1->IsVisible()); 100 EXPECT_FALSE(w1->IsVisible());
104 } 101 }
105 102
106 TEST_F(WindowManagerTest, BezelGestureToSplitViewMode) { 103 TEST_F(WindowManagerTest, BezelGestureToSplitViewMode) {
107 aura::test::TestWindowDelegate delegate; 104 aura::test::TestWindowDelegate delegate;
108 scoped_ptr<aura::Window> first(CreateWindow(&delegate)); 105 scoped_ptr<aura::Window> first(CreateAndActivateWindow(&delegate));
109 scoped_ptr<aura::Window> second(CreateWindow(&delegate)); 106 scoped_ptr<aura::Window> second(CreateAndActivateWindow(&delegate));
110 scoped_ptr<aura::Window> third(CreateWindow(&delegate)); 107 scoped_ptr<aura::Window> third(CreateAndActivateWindow(&delegate));
111 108
112 test::WindowManagerImplTestApi wm_api; 109 test::WindowManagerImplTestApi wm_api;
113 aura::client::ParentWindowWithContext(
114 first.get(), ScreenManager::Get()->GetContext(), gfx::Rect());
115 aura::client::ParentWindowWithContext(
116 second.get(), ScreenManager::Get()->GetContext(), gfx::Rect());
117 aura::client::ParentWindowWithContext(
118 third.get(), ScreenManager::Get()->GetContext(), gfx::Rect());
119 110
120 // Test that going into split-view mode with two-finger gesture selects the 111 // Test that going into split-view mode with two-finger gesture selects the
121 // correct windows on left and right splits. 112 // correct windows on left and right splits.
122 ui::test::EventGenerator generator(root_window()); 113 ui::test::EventGenerator generator(root_window());
123 const gfx::Point start_points[2] = { 114 const gfx::Point start_points[2] = {
124 gfx::Point(2, 10), gfx::Point(4, 20), 115 gfx::Point(2, 10), gfx::Point(4, 20),
125 }; 116 };
126 const int kEventTimeSepration = 16; 117 const int kEventTimeSepration = 16;
127 int x_middle = root_window()->bounds().width() / 2; 118 int x_middle = root_window()->bounds().width() / 2;
128 generator.GestureMultiFingerScroll( 119 generator.GestureMultiFingerScroll(
129 2, start_points, kEventTimeSepration, 1, x_middle, 0); 120 2, start_points, kEventTimeSepration, 1, x_middle, 0);
130 ASSERT_TRUE(wm_api.GetSplitViewController()->IsSplitViewModeActive()); 121 ASSERT_TRUE(wm_api.GetSplitViewController()->IsSplitViewModeActive());
131 EXPECT_EQ(second.get(), wm_api.GetSplitViewController()->left_window()); 122 EXPECT_EQ(second.get(), wm_api.GetSplitViewController()->left_window());
132 EXPECT_EQ(third.get(), wm_api.GetSplitViewController()->right_window()); 123 EXPECT_EQ(third.get(), wm_api.GetSplitViewController()->right_window());
133 EXPECT_EQ(second->bounds().size().ToString(), 124 EXPECT_EQ(second->bounds().size().ToString(),
134 third->bounds().size().ToString()); 125 third->bounds().size().ToString());
135 } 126 }
136 127
137 TEST_F(WindowManagerTest, BezelGestureToSwitchBetweenWindows) { 128 TEST_F(WindowManagerTest, BezelGestureToSwitchBetweenWindows) {
138 aura::test::TestWindowDelegate delegate; 129 aura::test::TestWindowDelegate delegate;
139 scoped_ptr<aura::Window> first(CreateWindow(&delegate)); 130 scoped_ptr<aura::Window> first(CreateAndActivateWindow(&delegate));
140 scoped_ptr<aura::Window> second(CreateWindow(&delegate)); 131 scoped_ptr<aura::Window> second(CreateAndActivateWindow(&delegate));
141 scoped_ptr<aura::Window> third(CreateWindow(&delegate)); 132 scoped_ptr<aura::Window> third(CreateAndActivateWindow(&delegate));
142 first->Hide(); 133 first->Hide();
143 second->Hide(); 134 second->Hide();
144 135
145 test::WindowManagerImplTestApi wm_api; 136 test::WindowManagerImplTestApi wm_api;
146 aura::client::ParentWindowWithContext(
147 first.get(), ScreenManager::Get()->GetContext(), gfx::Rect());
148 aura::client::ParentWindowWithContext(
149 second.get(), ScreenManager::Get()->GetContext(), gfx::Rect());
150 aura::client::ParentWindowWithContext(
151 third.get(), ScreenManager::Get()->GetContext(), gfx::Rect());
152
153 EXPECT_EQ(third.get(), 137 EXPECT_EQ(third.get(),
154 wm_api.GetWindowListProvider()->GetWindowList().back()); 138 wm_api.GetWindowListProvider()->GetWindowList().back());
155 139
156 // Do a two-finger swipe from the left bezel. 140 // Do a two-finger swipe from the left bezel.
157 ui::test::EventGenerator generator(root_window()); 141 ui::test::EventGenerator generator(root_window());
158 const gfx::Point left_bezel_points[2] = { 142 const gfx::Point left_bezel_points[2] = {
159 gfx::Point(2, 10), gfx::Point(4, 20), 143 gfx::Point(2, 10), gfx::Point(4, 20),
160 }; 144 };
161 const int kEventTimeSepration = 16; 145 const int kEventTimeSepration = 16;
162 int width = root_window()->bounds().width(); 146 int width = root_window()->bounds().width();
163 generator.GestureMultiFingerScroll( 147 generator.GestureMultiFingerScroll(
164 2, left_bezel_points, kEventTimeSepration, 1, width, 0); 148 2, left_bezel_points, kEventTimeSepration, 1, width, 0);
165 EXPECT_TRUE(wm::IsActiveWindow(second.get())); 149 EXPECT_TRUE(wm::IsActiveWindow(second.get()));
166 EXPECT_EQ(second.get(), 150 EXPECT_EQ(second.get(),
167 wm_api.GetWindowListProvider()->GetWindowList().back()); 151 wm_api.GetWindowListProvider()->GetWindowList().back());
168 EXPECT_FALSE(first->IsVisible()); 152 EXPECT_FALSE(first->IsVisible());
169 EXPECT_TRUE(second->IsVisible()); 153 EXPECT_TRUE(second->IsVisible());
170 EXPECT_FALSE(third->IsVisible()); 154 EXPECT_FALSE(third->IsVisible());
171 } 155 }
172 156
173 TEST_F(WindowManagerTest, TitleDragSwitchBetweenWindows) { 157 TEST_F(WindowManagerTest, TitleDragSwitchBetweenWindows) {
174 aura::test::TestWindowDelegate delegate; 158 aura::test::TestWindowDelegate delegate;
175 delegate.set_window_component(HTCAPTION); 159 delegate.set_window_component(HTCAPTION);
176 scoped_ptr<aura::Window> first(CreateWindow(&delegate)); 160 scoped_ptr<aura::Window> first(CreateAndActivateWindow(&delegate));
177 scoped_ptr<aura::Window> second(CreateWindow(&delegate)); 161 scoped_ptr<aura::Window> second(CreateAndActivateWindow(&delegate));
178 scoped_ptr<aura::Window> third(CreateWindow(&delegate)); 162 scoped_ptr<aura::Window> third(CreateAndActivateWindow(&delegate));
179 163
180 test::WindowManagerImplTestApi wm_api; 164 test::WindowManagerImplTestApi wm_api;
181 aura::client::ParentWindowWithContext(
182 first.get(), ScreenManager::Get()->GetContext(), gfx::Rect());
183 aura::client::ParentWindowWithContext(
184 second.get(), ScreenManager::Get()->GetContext(), gfx::Rect());
185 aura::client::ParentWindowWithContext(
186 third.get(), ScreenManager::Get()->GetContext(), gfx::Rect());
187
188 EXPECT_EQ(third.get(), 165 EXPECT_EQ(third.get(),
189 wm_api.GetWindowListProvider()->GetWindowList().back()); 166 wm_api.GetWindowListProvider()->GetWindowList().back());
190 167
191 // Do a title-swipe from the top to switch to the previous window. 168 // Do a title-swipe from the top to switch to the previous window.
192 ui::test::EventGenerator generator(root_window()); 169 ui::test::EventGenerator generator(root_window());
193 generator.GestureScrollSequence(gfx::Point(20, 10), 170 generator.GestureScrollSequence(gfx::Point(20, 10),
194 gfx::Point(20, 400), 171 gfx::Point(20, 400),
195 base::TimeDelta::FromMilliseconds(20), 172 base::TimeDelta::FromMilliseconds(20),
196 5); 173 5);
197 EXPECT_TRUE(wm::IsActiveWindow(second.get())); 174 EXPECT_TRUE(wm::IsActiveWindow(second.get()));
(...skipping 21 matching lines...) Expand all
219 EXPECT_TRUE(wm::IsActiveWindow(third.get())); 196 EXPECT_TRUE(wm::IsActiveWindow(third.get()));
220 EXPECT_EQ(third.get(), 197 EXPECT_EQ(third.get(),
221 wm_api.GetWindowListProvider()->GetWindowList().back()); 198 wm_api.GetWindowListProvider()->GetWindowList().back());
222 EXPECT_FALSE(second->IsVisible()); 199 EXPECT_FALSE(second->IsVisible());
223 EXPECT_TRUE(third->IsVisible()); 200 EXPECT_TRUE(third->IsVisible());
224 } 201 }
225 202
226 TEST_F(WindowManagerTest, TitleDragSwitchBetweenWindowsInSplitViewMode) { 203 TEST_F(WindowManagerTest, TitleDragSwitchBetweenWindowsInSplitViewMode) {
227 aura::test::TestWindowDelegate delegate; 204 aura::test::TestWindowDelegate delegate;
228 delegate.set_window_component(HTCAPTION); 205 delegate.set_window_component(HTCAPTION);
229 scoped_ptr<aura::Window> first(CreateWindow(&delegate)); 206 scoped_ptr<aura::Window> first(CreateAndActivateWindow(&delegate));
230 scoped_ptr<aura::Window> second(CreateWindow(&delegate)); 207 scoped_ptr<aura::Window> second(CreateAndActivateWindow(&delegate));
231 scoped_ptr<aura::Window> third(CreateWindow(&delegate)); 208 scoped_ptr<aura::Window> third(CreateAndActivateWindow(&delegate));
232 scoped_ptr<aura::Window> fourth(CreateWindow(&delegate)); 209 scoped_ptr<aura::Window> fourth(CreateAndActivateWindow(&delegate));
233 210
234 test::WindowManagerImplTestApi wm_api; 211 test::WindowManagerImplTestApi wm_api;
235 aura::client::ParentWindowWithContext(
236 first.get(), ScreenManager::Get()->GetContext(), gfx::Rect());
237 aura::client::ParentWindowWithContext(
238 second.get(), ScreenManager::Get()->GetContext(), gfx::Rect());
239 aura::client::ParentWindowWithContext(
240 third.get(), ScreenManager::Get()->GetContext(), gfx::Rect());
241 aura::client::ParentWindowWithContext(
242 fourth.get(), ScreenManager::Get()->GetContext(), gfx::Rect());
243 212
244 // Test that going into split-view mode with two-finger gesture selects the 213 // Test that going into split-view mode with two-finger gesture selects the
245 // correct windows on left and right splits. 214 // correct windows on left and right splits.
246 ui::test::EventGenerator generator(root_window()); 215 ui::test::EventGenerator generator(root_window());
247 const gfx::Point start_points[2] = { 216 const gfx::Point start_points[2] = {
248 gfx::Point(2, 10), gfx::Point(4, 20), 217 gfx::Point(2, 10), gfx::Point(4, 20),
249 }; 218 };
250 const int kEventTimeSepration = 16; 219 const int kEventTimeSepration = 16;
251 int x_middle = root_window()->bounds().width() / 2; 220 int x_middle = root_window()->bounds().width() / 2;
252 generator.GestureMultiFingerScroll( 221 generator.GestureMultiFingerScroll(
253 2, start_points, kEventTimeSepration, 1, x_middle, 0); 222 2, start_points, kEventTimeSepration, 1, x_middle, 0);
254 ASSERT_TRUE(wm_api.GetSplitViewController()->IsSplitViewModeActive()); 223 ASSERT_TRUE(wm_api.GetSplitViewController()->IsSplitViewModeActive());
255 EXPECT_EQ(third.get(), wm_api.GetSplitViewController()->left_window()); 224 EXPECT_EQ(third.get(), wm_api.GetSplitViewController()->left_window());
256 EXPECT_EQ(fourth.get(), wm_api.GetSplitViewController()->right_window()); 225 EXPECT_EQ(fourth.get(), wm_api.GetSplitViewController()->right_window());
257 226
258 // Swipe the title of the left window. It should switch to |second|. 227 // Swipe the title of the left window. It should switch to |second|.
259 generator.GestureScrollSequence(gfx::Point(20, 10), 228 generator.GestureScrollSequence(gfx::Point(20, 10),
260 gfx::Point(20, 400), 229 gfx::Point(20, 400),
261 base::TimeDelta::FromMilliseconds(20), 230 base::TimeDelta::FromMilliseconds(20),
262 5); 231 5);
263 EXPECT_EQ(second.get(), wm_api.GetSplitViewController()->left_window()); 232 EXPECT_EQ(second.get(), wm_api.GetSplitViewController()->left_window());
264 EXPECT_EQ(fourth.get(), wm_api.GetSplitViewController()->right_window()); 233 EXPECT_EQ(fourth.get(), wm_api.GetSplitViewController()->right_window());
234 EXPECT_TRUE(wm::IsActiveWindow(second.get()));
265 aura::Window::Windows windows = 235 aura::Window::Windows windows =
266 wm_api.GetWindowListProvider()->GetWindowList(); 236 wm_api.GetWindowListProvider()->GetWindowList();
267 ASSERT_EQ(4u, windows.size()); 237 ASSERT_EQ(4u, windows.size());
268 EXPECT_EQ(second.get(), windows[3]); 238 EXPECT_EQ(second.get(), windows[3]);
269 EXPECT_EQ(third.get(), windows[2]); 239 EXPECT_EQ(fourth.get(), windows[2]);
270 EXPECT_EQ(fourth.get(), windows[1]); 240 EXPECT_EQ(third.get(), windows[1]);
271 241
272 // Swipe the title of the right window now. It should switch to |third|. 242 // Swipe the title of the right window now. It should switch to |third|.
273 generator.GestureScrollSequence(gfx::Point(x_middle + 20, 10), 243 generator.GestureScrollSequence(gfx::Point(x_middle + 20, 10),
274 gfx::Point(x_middle + 20, 400), 244 gfx::Point(x_middle + 20, 400),
275 base::TimeDelta::FromMilliseconds(20), 245 base::TimeDelta::FromMilliseconds(20),
276 5); 246 5);
277 EXPECT_EQ(second.get(), wm_api.GetSplitViewController()->left_window()); 247 EXPECT_EQ(second.get(), wm_api.GetSplitViewController()->left_window());
278 EXPECT_EQ(third.get(), wm_api.GetSplitViewController()->right_window()); 248 EXPECT_EQ(third.get(), wm_api.GetSplitViewController()->right_window());
249 EXPECT_TRUE(wm::IsActiveWindow(third.get()));
250 windows = wm_api.GetWindowListProvider()->GetWindowList();
251 ASSERT_EQ(4u, windows.size());
252 EXPECT_EQ(third.get(), windows[3]);
253 EXPECT_EQ(second.get(), windows[2]);
254 EXPECT_EQ(fourth.get(), windows[1]);
279 } 255 }
280 256
281 TEST_F(WindowManagerTest, NewWindowBounds) { 257 TEST_F(WindowManagerTest, NewWindowBounds) {
282 aura::test::TestWindowDelegate delegate; 258 aura::test::TestWindowDelegate delegate;
283 scoped_ptr<aura::Window> first(CreateWindow(&delegate)); 259 scoped_ptr<aura::Window> first(CreateAndActivateWindow(&delegate));
284 260
285 test::WindowManagerImplTestApi wm_api; 261 test::WindowManagerImplTestApi wm_api;
286 aura::client::ParentWindowWithContext( 262
287 first.get(), ScreenManager::Get()->GetContext(), gfx::Rect());
288 // The window should have the same size as the container. 263 // The window should have the same size as the container.
289 const gfx::Size work_area = 264 const gfx::Size work_area =
290 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().work_area().size(); 265 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().work_area().size();
291 EXPECT_EQ(work_area.ToString(), 266 EXPECT_EQ(work_area.ToString(),
292 first->bounds().size().ToString()); 267 first->bounds().size().ToString());
293 EXPECT_TRUE(first->bounds().origin().IsOrigin()); 268 EXPECT_TRUE(first->bounds().origin().IsOrigin());
294 269
295 // A second window should have the same bounds as the first one. 270 // A second window should have the same bounds as the first one.
296 scoped_ptr<aura::Window> second(CreateWindow(&delegate)); 271 scoped_ptr<aura::Window> second(CreateAndActivateWindow(&delegate));
297 aura::client::ParentWindowWithContext(
298 second.get(), ScreenManager::Get()->GetContext(), gfx::Rect());
299 EXPECT_EQ(first->bounds().ToString(), second->bounds().ToString()); 272 EXPECT_EQ(first->bounds().ToString(), second->bounds().ToString());
300 273
301 // Get into split view. 274 // Get into split view.
302 wm_api.GetSplitViewController()->ActivateSplitMode(NULL, NULL); 275 wm_api.GetSplitViewController()->ActivateSplitMode(NULL, second.get());
303 const gfx::Rect left_bounds = 276 const gfx::Rect left_bounds =
304 wm_api.GetSplitViewController()->left_window()->bounds(); 277 wm_api.GetSplitViewController()->left_window()->bounds();
305 EXPECT_NE(work_area.ToString(), 278 EXPECT_NE(work_area.ToString(),
306 left_bounds.size().ToString()); 279 left_bounds.size().ToString());
307 280
308 // A new window should replace the left window when in split view. 281 // A new window should replace the left window when in split view.
309 scoped_ptr<aura::Window> third(CreateWindow(&delegate)); 282 scoped_ptr<aura::Window> third(CreateAndActivateWindow(&delegate));
310 aura::client::ParentWindowWithContext(
311 third.get(), ScreenManager::Get()->GetContext(), gfx::Rect());
312 EXPECT_EQ(wm_api.GetSplitViewController()->left_window(), third.get()); 283 EXPECT_EQ(wm_api.GetSplitViewController()->left_window(), third.get());
313 EXPECT_EQ(left_bounds.ToString(), third->bounds().ToString()); 284 EXPECT_EQ(left_bounds.ToString(), third->bounds().ToString());
314 } 285 }
315 286
316 TEST_F(WindowManagerTest, SplitModeActivationByShortcut) { 287 TEST_F(WindowManagerTest, SplitModeActivationByShortcut) {
317 test::WindowManagerImplTestApi wm_api; 288 test::WindowManagerImplTestApi wm_api;
318 289
319 aura::test::TestWindowDelegate delegate; 290 aura::test::TestWindowDelegate delegate;
320 scoped_ptr<aura::Window> w1(CreateTestWindow(&delegate, gfx::Rect())); 291 scoped_ptr<aura::Window> w1(CreateAndActivateWindow(&delegate));
321 w1->Show();
322
323 ui::test::EventGenerator generator(root_window());
324 292
325 // Splitview mode needs at least two windows. 293 // Splitview mode needs at least two windows.
326 generator.PressKey(ui::VKEY_F6, ui::EF_CONTROL_DOWN); 294 wm_api.wm()->ToggleSplitView();
327 generator.ReleaseKey(ui::VKEY_F6, ui::EF_CONTROL_DOWN);
328 EXPECT_FALSE(wm_api.GetSplitViewController()->IsSplitViewModeActive()); 295 EXPECT_FALSE(wm_api.GetSplitViewController()->IsSplitViewModeActive());
329 296
330 scoped_ptr<aura::Window> w2(CreateTestWindow(&delegate, gfx::Rect())); 297 scoped_ptr<aura::Window> w2(CreateAndActivateWindow(&delegate));
331 w2->Show();
332 298
333 generator.PressKey(ui::VKEY_F6, ui::EF_CONTROL_DOWN); 299 wm_api.wm()->ToggleSplitView();
pkotwicz 2014/09/08 02:27:46 In order for accelerators to work when an activity
334 generator.ReleaseKey(ui::VKEY_F6, ui::EF_CONTROL_DOWN);
335 EXPECT_TRUE(wm_api.GetSplitViewController()->IsSplitViewModeActive()); 300 EXPECT_TRUE(wm_api.GetSplitViewController()->IsSplitViewModeActive());
336 int width = 301 int width =
337 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().work_area().width(); 302 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().work_area().width();
338 303
339 EXPECT_EQ(width / 2, w1->bounds().width()); 304 EXPECT_EQ(width / 2, w1->bounds().width());
340 EXPECT_EQ(width / 2, w2->bounds().width()); 305 EXPECT_EQ(width / 2, w2->bounds().width());
341 306
342 // Toggle back to normal mode. 307 // Toggle back to normal mode.
343 generator.PressKey(ui::VKEY_F6, ui::EF_CONTROL_DOWN); 308 wm_api.wm()->ToggleSplitView();
344 generator.ReleaseKey(ui::VKEY_F6, ui::EF_CONTROL_DOWN);
345 EXPECT_FALSE(wm_api.GetSplitViewController()->IsSplitViewModeActive()); 309 EXPECT_FALSE(wm_api.GetSplitViewController()->IsSplitViewModeActive());
346 310
347 EXPECT_EQ(width, w1->bounds().width()); 311 EXPECT_EQ(width, w1->bounds().width());
348 EXPECT_EQ(width, w2->bounds().width()); 312 EXPECT_EQ(width, w2->bounds().width());
349 } 313 }
350 314
351 TEST_F(WindowManagerTest, OverviewModeFromSplitMode) { 315 TEST_F(WindowManagerTest, OverviewModeFromSplitMode) {
352 test::WindowManagerImplTestApi wm_api; 316 test::WindowManagerImplTestApi wm_api;
353 317
354 aura::test::TestWindowDelegate delegate; 318 aura::test::TestWindowDelegate delegate;
355 scoped_ptr<aura::Window> w1(CreateTestWindow(&delegate, gfx::Rect())); 319 scoped_ptr<aura::Window> w1(CreateAndActivateWindow(&delegate));
356 scoped_ptr<aura::Window> w2(CreateTestWindow(&delegate, gfx::Rect())); 320 scoped_ptr<aura::Window> w2(CreateAndActivateWindow(&delegate));
357 scoped_ptr<aura::Window> w3(CreateTestWindow(&delegate, gfx::Rect())); 321 scoped_ptr<aura::Window> w3(CreateAndActivateWindow(&delegate));
358 322
359 // Get into split-view mode, and then turn on overview mode. 323 // Get into split-view mode, and then turn on overview mode.
360 wm_api.GetSplitViewController()->ActivateSplitMode(NULL, NULL); 324 wm_api.GetSplitViewController()->ActivateSplitMode(w3.get(), NULL);
361 WindowManager::GetInstance()->ToggleOverview(); 325 WindowManager::GetInstance()->ToggleOverview();
362 EXPECT_TRUE(wm_api.GetSplitViewController()->IsSplitViewModeActive()); 326 EXPECT_TRUE(wm_api.GetSplitViewController()->IsSplitViewModeActive());
363 EXPECT_EQ(w3.get(), wm_api.GetSplitViewController()->left_window()); 327 EXPECT_EQ(w3.get(), wm_api.GetSplitViewController()->left_window());
364 EXPECT_EQ(w2.get(), wm_api.GetSplitViewController()->right_window()); 328 EXPECT_EQ(w2.get(), wm_api.GetSplitViewController()->right_window());
365 329
366 WindowOverviewModeDelegate* overview_delegate = wm_api.wm(); 330 WindowOverviewModeDelegate* overview_delegate = wm_api.wm();
367 overview_delegate->OnSelectWindow(w1.get()); 331 overview_delegate->OnSelectWindow(w1.get());
368 EXPECT_FALSE(wm_api.GetSplitViewController()->IsSplitViewModeActive()); 332 EXPECT_FALSE(wm_api.GetSplitViewController()->IsSplitViewModeActive());
369 EXPECT_TRUE(w1->IsVisible()); 333 EXPECT_TRUE(w1->IsVisible());
370 // Make sure the windows that were in split-view mode are hidden. 334 // Make sure the windows that were in split-view mode are hidden.
371 EXPECT_FALSE(w2->IsVisible()); 335 EXPECT_FALSE(w2->IsVisible());
372 EXPECT_FALSE(w3->IsVisible()); 336 EXPECT_FALSE(w3->IsVisible());
373 } 337 }
374 338
375 } // namespace athena 339 } // namespace athena
OLDNEW
« athena/wm/window_manager_impl.cc ('K') | « athena/wm/window_manager_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698