OLD | NEW |
---|---|
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 "ash/system/overview/overview_button_tray.h" | 5 #include "ash/system/overview/overview_button_tray.h" |
6 | 6 |
7 #include "ash/login_status.h" | 7 #include "ash/login_status.h" |
8 #include "ash/public/cpp/config.h" | 8 #include "ash/public/cpp/config.h" |
9 #include "ash/public/cpp/shelf_types.h" | 9 #include "ash/public/cpp/shelf_types.h" |
10 #include "ash/root_window_controller.h" | 10 #include "ash/root_window_controller.h" |
11 #include "ash/rotator/screen_rotation_animator.h" | 11 #include "ash/rotator/screen_rotation_animator.h" |
12 #include "ash/session/session_controller.h" | 12 #include "ash/session/session_controller.h" |
13 #include "ash/shell.h" | 13 #include "ash/shell.h" |
14 #include "ash/shell_port.h" | 14 #include "ash/shell_port.h" |
15 #include "ash/system/status_area_widget.h" | 15 #include "ash/system/status_area_widget.h" |
16 #include "ash/test/ash_test_base.h" | 16 #include "ash/test/ash_test_base.h" |
17 #include "ash/test/ash_test_helper.h" | 17 #include "ash/test/ash_test_helper.h" |
18 #include "ash/test/status_area_widget_test_helper.h" | 18 #include "ash/test/status_area_widget_test_helper.h" |
19 #include "ash/wm/maximize_mode/maximize_mode_controller.h" | 19 #include "ash/wm/maximize_mode/maximize_mode_controller.h" |
20 #include "ash/wm/overview/window_selector_controller.h" | 20 #include "ash/wm/overview/window_selector_controller.h" |
21 #include "ash/wm/window_util.h" | |
21 #include "base/command_line.h" | 22 #include "base/command_line.h" |
22 #include "base/test/user_action_tester.h" | 23 #include "base/test/user_action_tester.h" |
23 #include "base/time/time.h" | 24 #include "base/time/time.h" |
24 #include "ui/aura/client/aura_constants.h" | 25 #include "ui/aura/client/aura_constants.h" |
25 #include "ui/aura/window.h" | 26 #include "ui/aura/window.h" |
26 #include "ui/compositor/scoped_animation_duration_scale_mode.h" | 27 #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
27 #include "ui/display/display_switches.h" | 28 #include "ui/display/display_switches.h" |
28 #include "ui/display/manager/display_manager.h" | 29 #include "ui/display/manager/display_manager.h" |
29 #include "ui/events/event.h" | 30 #include "ui/events/event.h" |
30 #include "ui/events/event_constants.h" | 31 #include "ui/events/event_constants.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
101 TEST_F(OverviewButtonTrayTest, PerformAction) { | 102 TEST_F(OverviewButtonTrayTest, PerformAction) { |
102 ASSERT_FALSE(Shell::Get()->window_selector_controller()->IsSelecting()); | 103 ASSERT_FALSE(Shell::Get()->window_selector_controller()->IsSelecting()); |
103 | 104 |
104 // Overview Mode only works when there is a window | 105 // Overview Mode only works when there is a window |
105 std::unique_ptr<aura::Window> window( | 106 std::unique_ptr<aura::Window> window( |
106 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); | 107 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); |
107 ui::GestureEvent tap(0, 0, 0, base::TimeTicks(), | 108 ui::GestureEvent tap(0, 0, 0, base::TimeTicks(), |
108 ui::GestureEventDetails(ui::ET_GESTURE_TAP)); | 109 ui::GestureEventDetails(ui::ET_GESTURE_TAP)); |
109 GetTray()->PerformAction(tap); | 110 GetTray()->PerformAction(tap); |
110 EXPECT_TRUE(Shell::Get()->window_selector_controller()->IsSelecting()); | 111 EXPECT_TRUE(Shell::Get()->window_selector_controller()->IsSelecting()); |
112 | |
113 // Verify tapping on the button again closes overview mode. | |
114 GetTray()->PerformAction(tap); | |
115 EXPECT_FALSE(Shell::Get()->window_selector_controller()->IsSelecting()); | |
116 } | |
117 | |
118 TEST_F(OverviewButtonTrayTest, PerformDoubleTapAction) { | |
119 ASSERT_FALSE(Shell::Get()->window_selector_controller()->IsSelecting()); | |
120 | |
121 // Verify that when we only have one active window, a double tap will act as a | |
122 // two single taps and open then close overview mode. | |
sadrul
2017/05/18 13:41:38
I don't think this case is actually tested. Can yo
sammiequon
2017/05/18 16:19:06
Done.
| |
123 std::unique_ptr<aura::Window> window1( | |
124 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); | |
125 wm::ActivateWindow(window1.get()); | |
James Cook
2017/05/18 15:10:54
Do you have to activate this one?
sammiequon
2017/05/18 16:19:06
Nope. Removed.
| |
126 | |
127 // Add a secondary active window to test quick switch. | |
128 std::unique_ptr<aura::Window> window2( | |
129 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); | |
130 wm::ActivateWindow(window2.get()); | |
131 EXPECT_TRUE(wm::IsActiveWindow(window2.get())); | |
132 | |
133 // Verify that after double tapping, we have switched to window 1. | |
134 ui::GestureEventDetails double_tap_details(ui::ET_GESTURE_TAP); | |
135 double_tap_details.set_tap_count(2); | |
136 ui::GestureEvent double_tap(0, 0, 0, base::TimeTicks(), double_tap_details); | |
137 GetTray()->PerformAction(double_tap); | |
138 EXPECT_TRUE(wm::IsActiveWindow(window1.get())); | |
139 EXPECT_FALSE(Shell::Get()->window_selector_controller()->IsSelecting()); | |
140 | |
141 // Verify that if we double tap on the window selection page, nothing happens | |
142 // and both windows are not the active window. | |
143 ui::GestureEvent tap(0, 0, 0, base::TimeTicks(), | |
144 ui::GestureEventDetails(ui::ET_GESTURE_TAP)); | |
145 GetTray()->PerformAction(tap); | |
146 ASSERT_TRUE(Shell::Get()->window_selector_controller()->IsSelecting()); | |
147 GetTray()->PerformAction(double_tap); | |
148 EXPECT_FALSE(wm::IsActiveWindow(window1.get())); | |
149 EXPECT_FALSE(wm::IsActiveWindow(window2.get())); | |
150 EXPECT_TRUE(Shell::Get()->window_selector_controller()->IsSelecting()); | |
James Cook
2017/05/18 15:10:54
Nice test - easy to read. I like the style of bloc
sammiequon
2017/05/18 16:19:06
Thanks :-).
| |
111 } | 151 } |
112 | 152 |
113 // Tests that tapping on the control will record the user action Tray_Overview. | 153 // Tests that tapping on the control will record the user action Tray_Overview. |
114 TEST_F(OverviewButtonTrayTest, TrayOverviewUserAction) { | 154 TEST_F(OverviewButtonTrayTest, TrayOverviewUserAction) { |
115 // TODO: investigate failure in mash, http://crbug.com/698129. | 155 // TODO: investigate failure in mash, http://crbug.com/698129. |
116 if (Shell::GetAshConfig() == Config::MASH) | 156 if (Shell::GetAshConfig() == Config::MASH) |
117 return; | 157 return; |
118 | 158 |
119 ASSERT_FALSE(Shell::Get()->window_selector_controller()->IsSelecting()); | 159 ASSERT_FALSE(Shell::Get()->window_selector_controller()->IsSelecting()); |
120 | 160 |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
255 ASSERT_TRUE(ShellPort::Get()->IsSystemModalWindowOpen()); | 295 ASSERT_TRUE(ShellPort::Get()->IsSystemModalWindowOpen()); |
256 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( | 296 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( |
257 true); | 297 true); |
258 EXPECT_TRUE(GetTray()->visible()); | 298 EXPECT_TRUE(GetTray()->visible()); |
259 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( | 299 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( |
260 false); | 300 false); |
261 EXPECT_FALSE(GetTray()->visible()); | 301 EXPECT_FALSE(GetTray()->visible()); |
262 } | 302 } |
263 | 303 |
264 } // namespace ash | 304 } // namespace ash |
OLD | NEW |