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

Unified Diff: ash/wm/maximize_mode/maximize_mode_controller_unittest.cc

Issue 286103004: Blocked volume up/down events that originated from remapped function keys. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge of 'master' branch Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ash/wm/maximize_mode/maximize_mode_event_blocker.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/wm/maximize_mode/maximize_mode_controller_unittest.cc
diff --git a/ash/wm/maximize_mode/maximize_mode_controller_unittest.cc b/ash/wm/maximize_mode/maximize_mode_controller_unittest.cc
index e9d925d729a7d322a761b1709079e1d4b82c07ef..b3724c88652a76cb4dff2285ca6ea8c7c8117a9b 100644
--- a/ash/wm/maximize_mode/maximize_mode_controller_unittest.cc
+++ b/ash/wm/maximize_mode/maximize_mode_controller_unittest.cc
@@ -21,6 +21,10 @@
#include "ui/gfx/vector3d_f.h"
#include "ui/message_center/message_center.h"
+#if defined(USE_X11)
+#include "ui/events/test/events_test_utils_x11.h"
+#endif
+
namespace ash {
namespace {
@@ -418,7 +422,9 @@ TEST_F(MaximizeModeControllerTest, Screenshot) {
}
#endif // OS_CHROMEOS
-// Tests that maximize mode does not block Volume Up & Down events.
+#if defined(USE_X11)
+// Tests that maximize mode allows volume up/down events originating
+// from dedicated buttons versus remapped keyboard buttons.
TEST_F(MaximizeModeControllerTest, AllowsVolumeControl) {
aura::Window* root = Shell::GetPrimaryRootWindow();
aura::test::EventGenerator event_generator(root, root);
@@ -433,18 +439,39 @@ TEST_F(MaximizeModeControllerTest, AllowsVolumeControl) {
gfx::Vector3dF(-1.0f, 0.0f, 0.0f));
ASSERT_TRUE(IsMaximizeModeStarted());
+ ui::ScopedXI2Event xevent;
+
+ // Verify F9 button event is blocked
+ ASSERT_EQ(0, volume_delegate->handle_volume_down_count());
+ xevent.InitKeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_VOLUME_DOWN, ui::EF_NONE);
+ ui::KeyEvent press_f9(xevent, false /* is_char */);
+ press_f9.set_flags(ui::EF_FUNCTION_KEY);
+ event_generator.Dispatch(&press_f9);
+ EXPECT_EQ(0, volume_delegate->handle_volume_down_count());
+
+ // Verify F10 button event is blocked
+ ASSERT_EQ(0, volume_delegate->handle_volume_up_count());
+ xevent.InitKeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_VOLUME_UP, ui::EF_NONE);
+ ui::KeyEvent press_f10(xevent, false /* is_char */);
+ press_f10.set_flags(ui::EF_FUNCTION_KEY);
+ event_generator.Dispatch(&press_f10);
+ EXPECT_EQ(0, volume_delegate->handle_volume_up_count());
+
// Verify volume down button event is not blocked
ASSERT_EQ(0, volume_delegate->handle_volume_down_count());
- event_generator.PressKey(ui::VKEY_VOLUME_DOWN, 0);
- event_generator.ReleaseKey(ui::VKEY_VOLUME_DOWN, 0);
+ xevent.InitKeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_VOLUME_DOWN, ui::EF_NONE);
+ ui::KeyEvent press_vol_down(xevent, false /* is_char */);
+ event_generator.Dispatch(&press_vol_down);
EXPECT_EQ(1, volume_delegate->handle_volume_down_count());
// Verify volume up event is not blocked
ASSERT_EQ(0, volume_delegate->handle_volume_up_count());
- event_generator.PressKey(ui::VKEY_VOLUME_UP, 0);
- event_generator.ReleaseKey(ui::VKEY_VOLUME_UP, 0);
+ xevent.InitKeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_VOLUME_UP, ui::EF_NONE);
+ ui::KeyEvent press_vol_up(xevent, false /* is_char */);
+ event_generator.Dispatch(&press_vol_up);
EXPECT_EQ(1, volume_delegate->handle_volume_up_count());
}
+#endif // defined(USE_X11)
TEST_F(MaximizeModeControllerTest, LaptopTest) {
// Feeds in sample accelerometer data and verifies that there are no
« no previous file with comments | « no previous file | ash/wm/maximize_mode/maximize_mode_event_blocker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698