summaryrefslogtreecommitdiffstats
path: root/ui/aura
diff options
context:
space:
mode:
authoryusukes@chromium.org <yusukes@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-05 04:09:23 +0000
committeryusukes@chromium.org <yusukes@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-05 04:09:23 +0000
commit273bf9e24c8268d80d89b35b3f8de678be5723e6 (patch)
tree68b95599229c80f980a7702706c07231b73bb0b6 /ui/aura
parent6ff45e6c846d665cb8b5dfcdebbef55a91e9cd6e (diff)
downloadchromium_src-273bf9e24c8268d80d89b35b3f8de678be5723e6.zip
chromium_src-273bf9e24c8268d80d89b35b3f8de678be5723e6.tar.gz
chromium_src-273bf9e24c8268d80d89b35b3f8de678be5723e6.tar.bz2
Do not use ui::GetCharacterFromXEvent when Control is pressed.
The function does not take into account the modifier. BUG=107837 TEST=see the bug Review URL: http://codereview.chromium.org/8968011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@116451 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/aura')
-rw-r--r--ui/aura/event.cc6
-rw-r--r--ui/aura/event_unittest.cc37
2 files changed, 40 insertions, 3 deletions
diff --git a/ui/aura/event.cc b/ui/aura/event.cc
index bdd4764..18687d1 100644
--- a/ui/aura/event.cc
+++ b/ui/aura/event.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -229,7 +229,9 @@ uint16 KeyEvent::GetCharacter() const {
DCHECK(native_event()->type == KeyPress ||
native_event()->type == KeyRelease);
- uint16 ch = ui::GetCharacterFromXEvent(native_event());
+ uint16 ch = 0;
+ if (!IsControlDown())
+ ch = ui::GetCharacterFromXEvent(native_event());
return ch ? ch : ui::GetCharacterFromKeyCode(key_code_, flags());
#else
NOTIMPLEMENTED();
diff --git a/ui/aura/event_unittest.cc b/ui/aura/event_unittest.cc
index f1e65a1..1e05df6 100644
--- a/ui/aura/event_unittest.cc
+++ b/ui/aura/event_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -31,6 +31,41 @@ TEST(EventTest, NativeEvent) {
native_event.get());
KeyEvent keyev(native_event.get(), false);
EXPECT_TRUE(keyev.HasNativeEvent());
+}
+
+TEST(EventTest, GetCharacter) {
+ // Check if Control+Enter returns 10.
+ KeyEvent keyev1(ui::ET_KEY_PRESSED,
+ ui::VKEY_RETURN,
+ ui::EF_CONTROL_DOWN);
+ EXPECT_EQ(10, keyev1.GetCharacter());
+ EXPECT_EQ(13, keyev1.GetUnmodifiedCharacter());
+ // Check if Enter returns 13.
+ KeyEvent keyev2(ui::ET_KEY_PRESSED,
+ ui::VKEY_RETURN,
+ 0);
+ EXPECT_EQ(13, keyev2.GetCharacter());
+ EXPECT_EQ(13, keyev2.GetUnmodifiedCharacter());
+
+#if defined(USE_X11)
+ // For X11, test the functions with native_event() as well. crbug.com/107837
+ scoped_ptr<XEvent> native_event(new XEvent);
+
+ ui::InitXKeyEventForTesting(ui::ET_KEY_PRESSED,
+ ui::VKEY_RETURN,
+ ui::EF_CONTROL_DOWN,
+ native_event.get());
+ KeyEvent keyev3(native_event.get(), false);
+ EXPECT_EQ(10, keyev3.GetCharacter());
+ EXPECT_EQ(13, keyev3.GetUnmodifiedCharacter());
+
+ ui::InitXKeyEventForTesting(ui::ET_KEY_PRESSED,
+ ui::VKEY_RETURN,
+ 0,
+ native_event.get());
+ KeyEvent keyev4(native_event.get(), false);
+ EXPECT_EQ(13, keyev4.GetCharacter());
+ EXPECT_EQ(13, keyev4.GetUnmodifiedCharacter());
#endif
}