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

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: Created 6 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 side-by-side diff with in-line comments
Download patch
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 4145281969e4e5b210094f6375d5ccd3ab162902..c31ce71fc3c6c54b39ac75e9571425c9ac4448bc 100644
--- a/ash/wm/maximize_mode/maximize_mode_controller_unittest.cc
+++ b/ash/wm/maximize_mode/maximize_mode_controller_unittest.cc
@@ -18,6 +18,7 @@
#include "ash/wm/maximize_mode/maximize_mode_event_blocker.h"
#include "ui/aura/test/event_generator.h"
#include "ui/events/event_handler.h"
+#include "ui/events/test/events_test_utils_x11.h"
#include "ui/gfx/vector3d_f.h"
#include "ui/message_center/message_center.h"
@@ -416,7 +417,6 @@ TEST_F(MaximizeModeControllerTest, Screenshot) {
EXPECT_EQ(1, delegate->handle_take_screenshot_count());
event_generator.ReleaseKey(ui::VKEY_VOLUME_DOWN, 0);
}
-#endif // OS_CHROMEOS
// Tests that maximize mode does not block Volume Up & Down events.
jonross 2014/05/23 18:48:49 Update description to clarify that this differenti
bruthig 2014/05/23 19:50:07 Done.
TEST_F(MaximizeModeControllerTest, AllowsVolumeControl) {
@@ -433,18 +433,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 // OS_CHROMEOS
jonross 2014/05/23 18:48:49 I see this is being brought into chrome os. Is the
bruthig 2014/05/23 19:50:07 This is a chrome os specific test.
jonross 2014/05/26 13:55:41 Sounds good.
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') | chrome/browser/chromeos/events/event_rewriter.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698