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

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
« no previous file with comments | « ash/wm/overview/window_selector_controller.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 ToggleOverview(); 748 ToggleOverview();
704 } 749 }
705 EXPECT_NE(initial_bounds, ToEnclosingRect( 750 EXPECT_NE(initial_bounds, ToEnclosingRect(
706 GetTransformedTargetBounds(window.get()))); 751 GetTransformedTargetBounds(window.get())));
707 ToggleOverview(); 752 ToggleOverview();
708 EXPECT_FALSE(IsSelecting()); 753 EXPECT_FALSE(IsSelecting());
709 EXPECT_EQ(initial_bounds, ToEnclosingRect( 754 EXPECT_EQ(initial_bounds, ToEnclosingRect(
710 GetTransformedTargetBounds(window.get()))); 755 GetTransformedTargetBounds(window.get())));
711 } 756 }
712 757
713 // Tests that non-activatable windows are hidden when entering overview mode.
714 TEST_F(WindowSelectorTest, NonActivatableWindowsHidden) {
715 gfx::Rect bounds(0, 0, 400, 400);
716 scoped_ptr<aura::Window> window1(CreateWindow(bounds));
717 scoped_ptr<aura::Window> window2(CreateWindow(bounds));
718 scoped_ptr<aura::Window> non_activatable_window(
719 CreateNonActivatableWindow(Shell::GetPrimaryRootWindow()->bounds()));
720 EXPECT_TRUE(non_activatable_window->IsVisible());
721 ToggleOverview();
722 EXPECT_FALSE(non_activatable_window->IsVisible());
723 ToggleOverview();
724 EXPECT_TRUE(non_activatable_window->IsVisible());
725
726 // Test that a window behind the fullscreen non-activatable window can be
727 // clicked.
728 non_activatable_window->parent()->StackChildAtTop(
729 non_activatable_window.get());
730 ToggleOverview();
731 ClickWindow(window1.get());
732 EXPECT_FALSE(IsSelecting());
733 EXPECT_TRUE(wm::IsActiveWindow(window1.get()));
734 }
735
736 // Tests that windows with modal child windows are transformed with the modal 758 // Tests that windows with modal child windows are transformed with the modal
737 // child even though not activatable themselves. 759 // child even though not activatable themselves.
738 TEST_F(WindowSelectorTest, ModalChild) { 760 TEST_F(WindowSelectorTest, ModalChild) {
739 gfx::Rect bounds(0, 0, 400, 400); 761 gfx::Rect bounds(0, 0, 400, 400);
740 scoped_ptr<aura::Window> window1(CreateWindow(bounds)); 762 scoped_ptr<aura::Window> window1(CreateWindow(bounds));
741 scoped_ptr<aura::Window> child1(CreateWindow(bounds)); 763 scoped_ptr<aura::Window> child1(CreateWindow(bounds));
742 child1->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_WINDOW); 764 child1->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_WINDOW);
743 ::wm::AddTransientChild(window1.get(), child1.get()); 765 ::wm::AddTransientChild(window1.get(), child1.get());
744 EXPECT_EQ(window1->parent(), child1->parent()); 766 EXPECT_EQ(window1->parent(), child1->parent());
745 ToggleOverview(); 767 ToggleOverview();
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
1236 // Switch to overview mode. 1258 // Switch to overview mode.
1237 ToggleOverview(); 1259 ToggleOverview();
1238 ASSERT_TRUE(IsSelecting()); 1260 ASSERT_TRUE(IsSelecting());
1239 1261
1240 // Tap should now exit overview mode. 1262 // Tap should now exit overview mode.
1241 generator.GestureTapAt(point_in_background_page); 1263 generator.GestureTapAt(point_in_background_page);
1242 EXPECT_FALSE(IsSelecting()); 1264 EXPECT_FALSE(IsSelecting());
1243 } 1265 }
1244 1266
1245 } // namespace ash 1267 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/overview/window_selector_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698