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

Side by Side Diff: ash/wm/overview/window_selector_unittest.cc

Issue 1059903002: Allow Alt-Tab to move the focus to docked windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <algorithm> 5 #include <algorithm>
6 #include <vector> 6 #include <vector>
7 7
8 #include "ash/accessibility_delegate.h" 8 #include "ash/accessibility_delegate.h"
9 #include "ash/drag_drop/drag_drop_controller.h" 9 #include "ash/drag_drop/drag_drop_controller.h"
10 #include "ash/root_window_controller.h" 10 #include "ash/root_window_controller.h"
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 } 279 }
280 280
281 // Tests entering overview mode with two windows and selecting one by clicking. 281 // Tests entering overview mode with two windows and selecting one by clicking.
282 TEST_F(WindowSelectorTest, Basic) { 282 TEST_F(WindowSelectorTest, Basic) {
283 gfx::Rect bounds(0, 0, 400, 400); 283 gfx::Rect bounds(0, 0, 400, 400);
284 aura::Window* root_window = Shell::GetPrimaryRootWindow(); 284 aura::Window* root_window = Shell::GetPrimaryRootWindow();
285 scoped_ptr<aura::Window> window1(CreateWindow(bounds)); 285 scoped_ptr<aura::Window> window1(CreateWindow(bounds));
286 scoped_ptr<aura::Window> window2(CreateWindow(bounds)); 286 scoped_ptr<aura::Window> window2(CreateWindow(bounds));
287 scoped_ptr<aura::Window> panel1(CreatePanelWindow(bounds)); 287 scoped_ptr<aura::Window> panel1(CreatePanelWindow(bounds));
288 scoped_ptr<aura::Window> panel2(CreatePanelWindow(bounds)); 288 scoped_ptr<aura::Window> panel2(CreatePanelWindow(bounds));
289
289 EXPECT_TRUE(WindowsOverlapping(window1.get(), window2.get())); 290 EXPECT_TRUE(WindowsOverlapping(window1.get(), window2.get()));
290 EXPECT_TRUE(WindowsOverlapping(panel1.get(), panel2.get())); 291 EXPECT_TRUE(WindowsOverlapping(panel1.get(), panel2.get()));
291 wm::ActivateWindow(window2.get()); 292 wm::ActivateWindow(window2.get());
292 EXPECT_FALSE(wm::IsActiveWindow(window1.get())); 293 EXPECT_FALSE(wm::IsActiveWindow(window1.get()));
293 EXPECT_TRUE(wm::IsActiveWindow(window2.get())); 294 EXPECT_TRUE(wm::IsActiveWindow(window2.get()));
294 EXPECT_EQ(window2.get(), GetFocusedWindow()); 295 EXPECT_EQ(window2.get(), GetFocusedWindow());
295 // Hide the cursor before entering overview to test that it will be shown. 296 // Hide the cursor before entering overview to test that it will be shown.
296 aura::client::GetCursorClient(root_window)->HideCursor(); 297 aura::client::GetCursorClient(root_window)->HideCursor();
297 298
298 // In overview mode the windows should no longer overlap and the text filter 299 // In overview mode the windows should no longer overlap and the text filter
299 // widget should be focused. 300 // widget should be focused.
300 ToggleOverview(); 301 ToggleOverview();
301 EXPECT_EQ(text_filter_widget()->GetNativeWindow(), GetFocusedWindow()); 302 EXPECT_EQ(text_filter_widget()->GetNativeWindow(), GetFocusedWindow());
302 EXPECT_FALSE(WindowsOverlapping(window1.get(), window2.get())); 303 EXPECT_FALSE(WindowsOverlapping(window1.get(), window2.get()));
303 EXPECT_FALSE(WindowsOverlapping(window1.get(), panel1.get())); 304 EXPECT_FALSE(WindowsOverlapping(window1.get(), panel1.get()));
304 EXPECT_FALSE(WindowsOverlapping(panel1.get(), panel2.get())); 305 EXPECT_FALSE(WindowsOverlapping(panel1.get(), panel2.get()));
305 306
306 // Clicking window 1 should activate it. 307 // Clicking window 1 should activate it.
307 ClickWindow(window1.get()); 308 ClickWindow(window1.get());
308 EXPECT_TRUE(wm::IsActiveWindow(window1.get())); 309 EXPECT_TRUE(wm::IsActiveWindow(window1.get()));
309 EXPECT_FALSE(wm::IsActiveWindow(window2.get())); 310 EXPECT_FALSE(wm::IsActiveWindow(window2.get()));
310 EXPECT_EQ(window1.get(), GetFocusedWindow()); 311 EXPECT_EQ(window1.get(), GetFocusedWindow());
311 312
312 // Cursor should have been unlocked. 313 // Cursor should have been unlocked.
313 EXPECT_FALSE(aura::client::GetCursorClient(root_window)->IsCursorLocked()); 314 EXPECT_FALSE(aura::client::GetCursorClient(root_window)->IsCursorLocked());
314 } 315 }
315 316
317 // Tests entering overview mode with docked windows
318 TEST_F(WindowSelectorTest, BasicWithDocked) {
319 // aura::Window* root_window = Shell::GetPrimaryRootWindow();
320 gfx::Rect bounds(300, 0, 200, 200);
321 scoped_ptr<aura::Window> window1(CreateWindow(bounds));
322 scoped_ptr<aura::Window> window2(CreateWindow(bounds));
323 scoped_ptr<aura::Window> docked1(CreateWindow(bounds));
324 scoped_ptr<aura::Window> docked2(CreateWindow(bounds));
325
326 wm::WMEvent dock_event(wm::WM_EVENT_DOCK);
327 wm::GetWindowState(docked1.get())->OnWMEvent(&dock_event);
328
329 wm::WindowState* docked_state2 = wm::GetWindowState(docked2.get());
330 docked_state2->OnWMEvent(&dock_event);
331 wm::WMEvent minimize_event(wm::WM_EVENT_MINIMIZE);
332 docked_state2->OnWMEvent(&minimize_event);
333
334 EXPECT_TRUE(WindowsOverlapping(window1.get(), window2.get()));
335 gfx::Rect docked_bounds = docked1->GetBoundsInScreen();
336
337 EXPECT_NE(bounds.ToString(), docked_bounds.ToString());
338 EXPECT_FALSE(WindowsOverlapping(window1.get(), docked1.get()));
339 EXPECT_FALSE(WindowsOverlapping(window1.get(), docked2.get()));
340 EXPECT_FALSE(docked2->IsVisible());
341
342 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED,
343 wm::GetWindowState(docked1.get())->GetStateType());
344 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED_MINIMIZED,
345 wm::GetWindowState(docked2.get())->GetStateType());
346
347 ToggleOverview();
348
349 EXPECT_FALSE(WindowsOverlapping(window1.get(), window2.get()));
350 // Docked windows stays the same.
351 EXPECT_EQ(docked_bounds.ToString(), docked1->GetBoundsInScreen().ToString());
352 EXPECT_FALSE(docked2->IsVisible());
353
354 // Docked window can still be activated, which will exit the overview mode.
355 ClickWindow(docked1.get());
356 EXPECT_TRUE(wm::IsActiveWindow(docked1.get()));
357 EXPECT_FALSE(
358 ash::Shell::GetInstance()->window_selector_controller()->IsSelecting());
359 }
360
316 // Tests selecting a window by tapping on it. 361 // Tests selecting a window by tapping on it.
317 TEST_F(WindowSelectorTest, BasicGesture) { 362 TEST_F(WindowSelectorTest, BasicGesture) {
318 gfx::Rect bounds(0, 0, 400, 400); 363 gfx::Rect bounds(0, 0, 400, 400);
319 scoped_ptr<aura::Window> window1(CreateWindow(bounds)); 364 scoped_ptr<aura::Window> window1(CreateWindow(bounds));
320 scoped_ptr<aura::Window> window2(CreateWindow(bounds)); 365 scoped_ptr<aura::Window> window2(CreateWindow(bounds));
321 wm::ActivateWindow(window1.get()); 366 wm::ActivateWindow(window1.get());
322 EXPECT_EQ(window1.get(), GetFocusedWindow()); 367 EXPECT_EQ(window1.get(), GetFocusedWindow());
323 ToggleOverview(); 368 ToggleOverview();
324 EXPECT_EQ(text_filter_widget()->GetNativeWindow(), GetFocusedWindow()); 369 EXPECT_EQ(text_filter_widget()->GetNativeWindow(), GetFocusedWindow());
325 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), 370 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
(...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after
1236 // Switch to overview mode. 1281 // Switch to overview mode.
1237 ToggleOverview(); 1282 ToggleOverview();
1238 ASSERT_TRUE(IsSelecting()); 1283 ASSERT_TRUE(IsSelecting());
1239 1284
1240 // Tap should now exit overview mode. 1285 // Tap should now exit overview mode.
1241 generator.GestureTapAt(point_in_background_page); 1286 generator.GestureTapAt(point_in_background_page);
1242 EXPECT_FALSE(IsSelecting()); 1287 EXPECT_FALSE(IsSelecting());
1243 } 1288 }
1244 1289
1245 } // namespace ash 1290 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698