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

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

Issue 2131603004: [ash-md] Makes Ctrl+W accelerator close a selected window in overview mode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: [ash-md] Makes Ctrl+W accelerator close a selected window in overview mode (UMA) Created 4 years, 5 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/metrics/user_metrics_recorder.cc ('k') | tools/metrics/actions/actions.xml » ('j') | 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/aura/wm_window_aura.h" 8 #include "ash/aura/wm_window_aura.h"
9 #include "ash/common/accessibility_delegate.h" 9 #include "ash/common/accessibility_delegate.h"
10 #include "ash/common/accessibility_types.h" 10 #include "ash/common/accessibility_types.h"
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 ui::test::EventGenerator event_generator(window->GetRootWindow(), window); 224 ui::test::EventGenerator event_generator(window->GetRootWindow(), window);
225 event_generator.ClickLeftButton(); 225 event_generator.ClickLeftButton();
226 } 226 }
227 227
228 void SendKey(ui::KeyboardCode key) { 228 void SendKey(ui::KeyboardCode key) {
229 ui::test::EventGenerator event_generator(Shell::GetPrimaryRootWindow()); 229 ui::test::EventGenerator event_generator(Shell::GetPrimaryRootWindow());
230 event_generator.PressKey(key, 0); 230 event_generator.PressKey(key, 0);
231 event_generator.ReleaseKey(key, 0); 231 event_generator.ReleaseKey(key, 0);
232 } 232 }
233 233
234 void SendCtrlKey(ui::KeyboardCode key) {
235 ui::test::EventGenerator event_generator(Shell::GetPrimaryRootWindow());
236 event_generator.PressKey(ui::VKEY_CONTROL, ui::EF_CONTROL_DOWN);
237 event_generator.PressKey(key, ui::EF_CONTROL_DOWN);
238 event_generator.ReleaseKey(key, ui::EF_CONTROL_DOWN);
239 event_generator.ReleaseKey(ui::VKEY_CONTROL, ui::EF_NONE);
240 }
241
234 bool IsSelecting() { return window_selector_controller()->IsSelecting(); } 242 bool IsSelecting() { return window_selector_controller()->IsSelecting(); }
235 243
236 aura::Window* GetFocusedWindow() { 244 aura::Window* GetFocusedWindow() {
237 return aura::client::GetFocusClient(Shell::GetPrimaryRootWindow()) 245 return aura::client::GetFocusClient(Shell::GetPrimaryRootWindow())
238 ->GetFocusedWindow(); 246 ->GetFocusedWindow();
239 } 247 }
240 248
241 const std::vector<WindowSelectorItem*>& GetWindowItemsForRoot(int index) { 249 const std::vector<WindowSelectorItem*>& GetWindowItemsForRoot(int index) {
242 return window_selector()->grid_list_[index]->window_list_.get(); 250 return window_selector()->grid_list_[index]->window_list_.get();
243 } 251 }
(...skipping 1123 matching lines...) Expand 10 before | Expand all | Expand 10 after
1367 EXPECT_EQ(GetSelectedWindow(), 1375 EXPECT_EQ(GetSelectedWindow(),
1368 WmWindowAura::GetAuraWindow(overview_windows[0]->GetWindow())); 1376 WmWindowAura::GetAuraWindow(overview_windows[0]->GetWindow()));
1369 SendKey(ui::VKEY_TAB); 1377 SendKey(ui::VKEY_TAB);
1370 EXPECT_EQ(GetSelectedWindow(), 1378 EXPECT_EQ(GetSelectedWindow(),
1371 WmWindowAura::GetAuraWindow(overview_windows[1]->GetWindow())); 1379 WmWindowAura::GetAuraWindow(overview_windows[1]->GetWindow()));
1372 SendKey(ui::VKEY_TAB); 1380 SendKey(ui::VKEY_TAB);
1373 EXPECT_EQ(GetSelectedWindow(), 1381 EXPECT_EQ(GetSelectedWindow(),
1374 WmWindowAura::GetAuraWindow(overview_windows[0]->GetWindow())); 1382 WmWindowAura::GetAuraWindow(overview_windows[0]->GetWindow()));
1375 } 1383 }
1376 1384
1385 // Tests that pressing Ctrl+W while a window is selected in overview closes it.
1386 TEST_P(WindowSelectorTest, CloseWindowWithKey) {
1387 gfx::Rect bounds(0, 0, 100, 100);
1388 std::unique_ptr<aura::Window> window2(CreateWindow(bounds));
1389 std::unique_ptr<views::Widget> widget =
1390 CreateWindowWidget(gfx::Rect(0, 0, 400, 400));
1391 aura::Window* window1 = widget->GetNativeWindow();
1392 ToggleOverview();
1393
1394 SendKey(ui::VKEY_RIGHT);
1395 EXPECT_EQ(window1, GetSelectedWindow());
1396 SendCtrlKey(ui::VKEY_W);
1397 EXPECT_TRUE(widget->IsClosed());
1398 }
1399
1377 // Tests traversing some windows in overview mode with the arrow keys in every 1400 // Tests traversing some windows in overview mode with the arrow keys in every
1378 // possible direction. 1401 // possible direction.
1379 TEST_P(WindowSelectorTest, BasicArrowKeyNavigation) { 1402 TEST_P(WindowSelectorTest, BasicArrowKeyNavigation) {
1380 if (!SupportsHostWindowResize()) 1403 if (!SupportsHostWindowResize())
1381 return; 1404 return;
1382 const size_t test_windows = 9; 1405 const size_t test_windows = 9;
1383 UpdateDisplay("800x600"); 1406 UpdateDisplay("800x600");
1384 ScopedVector<aura::Window> windows; 1407 ScopedVector<aura::Window> windows;
1385 for (size_t i = test_windows; i > 0; i--) 1408 for (size_t i = test_windows; i > 0; i--)
1386 windows.push_back(CreateWindowWithId(gfx::Rect(0, 0, 100, 100), i)); 1409 windows.push_back(CreateWindowWithId(gfx::Rect(0, 0, 100, 100), i));
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
1822 bounds.y()); 1845 bounds.y());
1823 EXPECT_LE(transformed_rect.bottom(), bounds.bottom()); 1846 EXPECT_LE(transformed_rect.bottom(), bounds.bottom());
1824 EXPECT_NEAR(transformed_rect.x() - bounds.x(), 1847 EXPECT_NEAR(transformed_rect.x() - bounds.x(),
1825 bounds.right() - transformed_rect.right(), 1); 1848 bounds.right() - transformed_rect.right(), 1);
1826 EXPECT_NEAR( 1849 EXPECT_NEAR(
1827 transformed_rect.y() + (int)(scale * inset) - header_height - bounds.y(), 1850 transformed_rect.y() + (int)(scale * inset) - header_height - bounds.y(),
1828 bounds.bottom() - transformed_rect.bottom(), 1); 1851 bounds.bottom() - transformed_rect.bottom(), 1);
1829 } 1852 }
1830 1853
1831 } // namespace ash 1854 } // namespace ash
OLDNEW
« no previous file with comments | « ash/metrics/user_metrics_recorder.cc ('k') | tools/metrics/actions/actions.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698