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/accelerators/accelerator_controller.h" | 5 #include "ash/accelerators/accelerator_controller.h" |
6 | 6 |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "ash/wm/window_state.h" | 8 #include "ash/wm/window_state.h" |
9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
10 #include "chrome/browser/ui/browser_window.h" | 10 #include "chrome/browser/ui/browser_window.h" |
(...skipping 20 matching lines...) Expand all Loading... | |
31 browser()->window()->Show(); | 31 browser()->window()->Show(); |
32 | 32 |
33 ui::Accelerator accelerator(ui::VKEY_OEM_PLUS, ui::EF_ALT_DOWN); | 33 ui::Accelerator accelerator(ui::VKEY_OEM_PLUS, ui::EF_ALT_DOWN); |
34 ash::AcceleratorController* accelerator_controller = | 34 ash::AcceleratorController* accelerator_controller = |
35 ash::Shell::GetInstance()->accelerator_controller(); | 35 ash::Shell::GetInstance()->accelerator_controller(); |
36 ASSERT_TRUE(accelerator_controller->IsRegistered(accelerator)); | 36 ASSERT_TRUE(accelerator_controller->IsRegistered(accelerator)); |
37 | 37 |
38 ash::wm::WindowState* window_state = ash::wm::GetActiveWindowState(); | 38 ash::wm::WindowState* window_state = ash::wm::GetActiveWindowState(); |
39 EXPECT_FALSE(window_state->IsMaximized()); | 39 EXPECT_FALSE(window_state->IsMaximized()); |
40 | 40 |
41 // Construct the key events from XEvents because RenderWidgetHostViewAura | |
42 // drops the ui::EF_IS_REPEAT flag otherwise. | |
oshima
2015/03/19 00:46:04
EventGenerator creates KeyEvent using native event
| |
43 ui::ScopedXI2Event xi2_down1; | |
44 xi2_down1.InitKeyEvent(ui::ET_KEY_PRESSED, | |
45 ui::VKEY_OEM_PLUS, | |
46 ui::EF_ALT_DOWN); | |
47 ui::KeyEvent down1(xi2_down1); | |
48 ui::test::EventGenerator generator(ash::Shell::GetPrimaryRootWindow()); | 41 ui::test::EventGenerator generator(ash::Shell::GetPrimaryRootWindow()); |
49 generator.Dispatch(&down1); | 42 generator.PressKey(ui::VKEY_OEM_PLUS, ui::EF_ALT_DOWN); |
50 EXPECT_TRUE(window_state->IsMaximized()); | 43 EXPECT_TRUE(window_state->IsMaximized()); |
51 | 44 |
52 ui::ScopedXI2Event xi2_down2; | 45 generator.PressKey(ui::VKEY_OEM_PLUS, ui::EF_ALT_DOWN); |
53 xi2_down2.InitKeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_OEM_PLUS, | |
54 ui::EF_ALT_DOWN); | |
55 ui::KeyEvent down2(xi2_down2); | |
56 generator.Dispatch(&down2); | |
57 | 46 |
58 ui::ScopedXI2Event xi2_up; | 47 generator.ReleaseKey(ui::VKEY_OEM_PLUS, ui::EF_ALT_DOWN); |
59 xi2_up.InitKeyEvent(ui::ET_KEY_RELEASED, ui::VKEY_OEM_PLUS, ui::EF_ALT_DOWN); | |
60 ui::KeyEvent up(xi2_up); | |
61 generator.Dispatch(&up); | |
62 EXPECT_TRUE(window_state->IsMaximized()); | 48 EXPECT_TRUE(window_state->IsMaximized()); |
63 } | 49 } |
64 #endif | 50 #endif |
OLD | NEW |