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

Side by Side Diff: ash/system/overview/overview_button_tray_unittest.cc

Issue 2882073004: wm: Allow double tap on overview button to quick switch. (Closed)
Patch Set: Slight fix. Created 3 years, 7 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/system/overview/overview_button_tray.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 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"
31 #include "ui/events/gestures/gesture_types.h" 32 #include "ui/events/gestures/gesture_types.h"
32 #include "ui/views/controls/image_view.h" 33 #include "ui/views/controls/image_view.h"
33 34
34 namespace ash { 35 namespace ash {
35 36
36 namespace { 37 namespace {
37 38
38 const char kTrayOverview[] = "Tray_Overview"; 39 const char kTrayOverview[] = "Tray_Overview";
39 40
40 OverviewButtonTray* GetTray() { 41 OverviewButtonTray* GetTray() {
41 return StatusAreaWidgetTestHelper::GetStatusAreaWidget() 42 return StatusAreaWidgetTestHelper::GetStatusAreaWidget()
42 ->overview_button_tray(); 43 ->overview_button_tray();
43 } 44 }
44 45
45 OverviewButtonTray* GetSecondaryTray() { 46 OverviewButtonTray* GetSecondaryTray() {
46 return StatusAreaWidgetTestHelper::GetSecondaryStatusAreaWidget() 47 return StatusAreaWidgetTestHelper::GetSecondaryStatusAreaWidget()
47 ->overview_button_tray(); 48 ->overview_button_tray();
48 } 49 }
49 50
51 // Helper function to perform a double tap on the overview button tray. A double
52 // tap consists fot two tap gestures, one with tap count 1 and another with tap
53 // count 2.
54 void PerformDoubleTap() {
55 ui::GestureEvent first_tap(0, 0, 0, base::TimeTicks(),
56 ui::GestureEventDetails(ui::ET_GESTURE_TAP));
57 GetTray()->PerformAction(first_tap);
58
59 ui::GestureEventDetails second_tap_details(ui::ET_GESTURE_TAP);
60 second_tap_details.set_tap_count(2);
61 ui::GestureEvent second_tap(0, 0, 0, base::TimeTicks(), second_tap_details);
62 GetTray()->PerformAction(second_tap);
63 }
64
50 } // namespace 65 } // namespace
51 66
52 class OverviewButtonTrayTest : public test::AshTestBase { 67 class OverviewButtonTrayTest : public test::AshTestBase {
53 public: 68 public:
54 OverviewButtonTrayTest() {} 69 OverviewButtonTrayTest() {}
55 ~OverviewButtonTrayTest() override {} 70 ~OverviewButtonTrayTest() override {}
56 71
57 void SetUp() override; 72 void SetUp() override;
58 73
59 void NotifySessionStateChanged(); 74 void NotifySessionStateChanged();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 TEST_F(OverviewButtonTrayTest, PerformAction) { 116 TEST_F(OverviewButtonTrayTest, PerformAction) {
102 ASSERT_FALSE(Shell::Get()->window_selector_controller()->IsSelecting()); 117 ASSERT_FALSE(Shell::Get()->window_selector_controller()->IsSelecting());
103 118
104 // Overview Mode only works when there is a window 119 // Overview Mode only works when there is a window
105 std::unique_ptr<aura::Window> window( 120 std::unique_ptr<aura::Window> window(
106 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); 121 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20)));
107 ui::GestureEvent tap(0, 0, 0, base::TimeTicks(), 122 ui::GestureEvent tap(0, 0, 0, base::TimeTicks(),
108 ui::GestureEventDetails(ui::ET_GESTURE_TAP)); 123 ui::GestureEventDetails(ui::ET_GESTURE_TAP));
109 GetTray()->PerformAction(tap); 124 GetTray()->PerformAction(tap);
110 EXPECT_TRUE(Shell::Get()->window_selector_controller()->IsSelecting()); 125 EXPECT_TRUE(Shell::Get()->window_selector_controller()->IsSelecting());
126
127 // Verify tapping on the button again closes overview mode.
128 GetTray()->PerformAction(tap);
129 EXPECT_FALSE(Shell::Get()->window_selector_controller()->IsSelecting());
130 }
131
132 TEST_F(OverviewButtonTrayTest, PerformDoubleTapAction) {
133 ASSERT_FALSE(Shell::Get()->window_selector_controller()->IsSelecting());
134
135 // Add two windows and activate the second one to test quick switch.
136 std::unique_ptr<aura::Window> window1(
137 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20)));
138 std::unique_ptr<aura::Window> window2(
139 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20)));
140 wm::ActivateWindow(window2.get());
141 EXPECT_TRUE(wm::IsActiveWindow(window2.get()));
142
143 // Verify that after double tapping, we have switched to window 1.
144 PerformDoubleTap();
145 EXPECT_TRUE(wm::IsActiveWindow(window1.get()));
146 EXPECT_FALSE(Shell::Get()->window_selector_controller()->IsSelecting());
147
148 // Verify that if we double tap on the window selection page, we leave the
149 // window selection page, but window 1 remains the active window.
150 ui::GestureEvent tap(0, 0, 0, base::TimeTicks(),
151 ui::GestureEventDetails(ui::ET_GESTURE_TAP));
152 ASSERT_TRUE(wm::IsActiveWindow(window1.get()));
153 GetTray()->PerformAction(tap);
154 ASSERT_TRUE(Shell::Get()->window_selector_controller()->IsSelecting());
155 PerformDoubleTap();
156 EXPECT_TRUE(wm::IsActiveWindow(window1.get()));
157 EXPECT_FALSE(Shell::Get()->window_selector_controller()->IsSelecting());
111 } 158 }
112 159
113 // Tests that tapping on the control will record the user action Tray_Overview. 160 // Tests that tapping on the control will record the user action Tray_Overview.
114 TEST_F(OverviewButtonTrayTest, TrayOverviewUserAction) { 161 TEST_F(OverviewButtonTrayTest, TrayOverviewUserAction) {
115 // TODO: investigate failure in mash, http://crbug.com/698129. 162 // TODO: investigate failure in mash, http://crbug.com/698129.
116 if (Shell::GetAshConfig() == Config::MASH) 163 if (Shell::GetAshConfig() == Config::MASH)
117 return; 164 return;
118 165
119 ASSERT_FALSE(Shell::Get()->window_selector_controller()->IsSelecting()); 166 ASSERT_FALSE(Shell::Get()->window_selector_controller()->IsSelecting());
120 167
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 ASSERT_TRUE(ShellPort::Get()->IsSystemModalWindowOpen()); 302 ASSERT_TRUE(ShellPort::Get()->IsSystemModalWindowOpen());
256 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( 303 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
257 true); 304 true);
258 EXPECT_TRUE(GetTray()->visible()); 305 EXPECT_TRUE(GetTray()->visible());
259 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( 306 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
260 false); 307 false);
261 EXPECT_FALSE(GetTray()->visible()); 308 EXPECT_FALSE(GetTray()->visible());
262 } 309 }
263 310
264 } // namespace ash 311 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/overview/overview_button_tray.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698