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

Side by Side Diff: chrome/test/chromedriver/keycode_text_conversion_unittest.cc

Issue 2197113002: Force U.S. English keyboard layout for TextfieldTest.KeysWithModifiersTest (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix review issues Created 4 years, 3 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 <string> 5 #include <string>
6 6
7 #include "base/strings/string16.h" 7 #include "base/strings/string16.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 #include "chrome/test/chromedriver/chrome/ui_events.h" 10 #include "chrome/test/chromedriver/chrome/ui_events.h"
11 #include "chrome/test/chromedriver/keycode_text_conversion.h" 11 #include "chrome/test/chromedriver/keycode_text_conversion.h"
12 #include "chrome/test/chromedriver/test_util.h"
13 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
14 #include "ui/events/keycodes/keyboard_codes.h" 13 #include "ui/events/keycodes/keyboard_codes.h"
14 #include "ui/events/test/keyboard_layout.h"
15 15
16 namespace { 16 namespace {
17 17
18 void CheckCharToKeyCode16(base::char16 character, ui::KeyboardCode key_code, 18 void CheckCharToKeyCode16(base::char16 character, ui::KeyboardCode key_code,
19 int modifiers) { 19 int modifiers) {
20 ui::KeyboardCode actual_key_code = ui::VKEY_UNKNOWN; 20 ui::KeyboardCode actual_key_code = ui::VKEY_UNKNOWN;
21 int actual_modifiers = 0; 21 int actual_modifiers = 0;
22 std::string error_msg; 22 std::string error_msg;
23 EXPECT_TRUE(ConvertCharToKeyCode( 23 EXPECT_TRUE(ConvertCharToKeyCode(
24 character, &actual_key_code, &actual_modifiers, &error_msg)); 24 character, &actual_key_code, &actual_modifiers, &error_msg));
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 120
121 #if (defined(OS_LINUX) && !defined(OS_CHROMEOS)) || defined(OS_MACOSX) 121 #if (defined(OS_LINUX) && !defined(OS_CHROMEOS)) || defined(OS_MACOSX)
122 // Not implemented on Linux. 122 // Not implemented on Linux.
123 // Fails if German layout is not installed on Mac. 123 // Fails if German layout is not installed on Mac.
124 #define MAYBE_NonShiftModifiers DISABLED_NonShiftModifiers 124 #define MAYBE_NonShiftModifiers DISABLED_NonShiftModifiers
125 #else 125 #else
126 #define MAYBE_NonShiftModifiers NonShiftModifiers 126 #define MAYBE_NonShiftModifiers NonShiftModifiers
127 #endif 127 #endif
128 128
129 TEST(KeycodeTextConversionTest, MAYBE_NonShiftModifiers) { 129 TEST(KeycodeTextConversionTest, MAYBE_NonShiftModifiers) {
130 RestoreKeyboardLayoutOnDestruct restore; 130 ui::ScopedKeyboardLayout keyboard_layout(ui::KEYBOARD_LAYOUT_GERMAN);
131 #if defined(OS_WIN) 131 #if defined(OS_WIN)
132 ASSERT_TRUE(SwitchKeyboardLayout("00000407")); // german
133 int ctrl_and_alt = kControlKeyModifierMask | kAltKeyModifierMask; 132 int ctrl_and_alt = kControlKeyModifierMask | kAltKeyModifierMask;
134 CheckCharToKeyCode('@', ui::VKEY_Q, ctrl_and_alt); 133 CheckCharToKeyCode('@', ui::VKEY_Q, ctrl_and_alt);
135 EXPECT_EQ("@", ConvertKeyCodeToTextNoError(ui::VKEY_Q, ctrl_and_alt)); 134 EXPECT_EQ("@", ConvertKeyCodeToTextNoError(ui::VKEY_Q, ctrl_and_alt));
136 #elif defined(OS_MACOSX) 135 #elif defined(OS_MACOSX)
137 ASSERT_TRUE(SwitchKeyboardLayout("com.apple.keylayout.German"));
138 EXPECT_EQ("@", ConvertKeyCodeToTextNoError( 136 EXPECT_EQ("@", ConvertKeyCodeToTextNoError(
139 ui::VKEY_L, kAltKeyModifierMask)); 137 ui::VKEY_L, kAltKeyModifierMask));
140 #endif 138 #endif
141 } 139 }
142 140
143 #if (defined(OS_LINUX) && !defined(OS_CHROMEOS)) || defined(OS_MACOSX) 141 #if (defined(OS_LINUX) && !defined(OS_CHROMEOS)) || defined(OS_MACOSX)
144 // Not implemented on Linux. 142 // Not implemented on Linux.
145 // Fails if German layout is not installed on Mac. 143 // Fails if German layout is not installed on Mac.
146 #define MAYBE_NonEnglish DISABLED_NonEnglish 144 #define MAYBE_NonEnglish DISABLED_NonEnglish
147 #else 145 #else
148 #define MAYBE_NonEnglish NonEnglish 146 #define MAYBE_NonEnglish NonEnglish
149 #endif 147 #endif
150 148
151 TEST(KeycodeTextConversionTest, MAYBE_NonEnglish) { 149 TEST(KeycodeTextConversionTest, MAYBE_NonEnglish) {
152 RestoreKeyboardLayoutOnDestruct restore;
153 #if defined(OS_WIN) 150 #if defined(OS_WIN)
154 ASSERT_TRUE(SwitchKeyboardLayout("00000408")); // greek 151 {
155 CheckCharToKeyCode(';', ui::VKEY_Q, 0); 152 ui::ScopedKeyboardLayout greek_layout(ui::KEYBOARD_LAYOUT_GREEK);
156 EXPECT_EQ(";", ConvertKeyCodeToTextNoError(ui::VKEY_Q, 0)); 153 CheckCharToKeyCode(';', ui::VKEY_Q, 0);
157 // Regression test for chromedriver bug #405. 154 EXPECT_EQ(";", ConvertKeyCodeToTextNoError(ui::VKEY_Q, 0));
158 ASSERT_TRUE(SwitchKeyboardLayout("00000419")); // russian 155 }
159 CheckCharToKeyCode(L'\u0438', ui::VKEY_B, 0); 156 {
160 EXPECT_EQ(base::UTF16ToUTF8(L"\u0438"), 157 // Regression test for chromedriver bug #405.
161 ConvertKeyCodeToTextNoError(ui::VKEY_B, 0)); 158 ui::ScopedKeyboardLayout russian_layout(ui::KEYBOARD_LAYOUT_RUSSIAN);
159 CheckCharToKeyCode(L'\u0438', ui::VKEY_B, 0);
160 EXPECT_EQ(base::UTF16ToUTF8(L"\u0438"),
161 ConvertKeyCodeToTextNoError(ui::VKEY_B, 0));
162 }
Peter Kasting 2016/08/26 18:54:33 In principle, is there a reason why these tests wo
Tomasz Moniuszko 2016/08/31 15:29:42 I tested Greek and Russian keyboard layouts on Mac
Peter Kasting 2016/08/31 21:16:15 That sounds like those tests should be enabled on
chongz 2016/09/03 00:44:17 The following comments are not verified, please re
Tomasz Moniuszko 2016/09/07 11:19:01 I think this is the right answer. Windows system u
162 #elif defined(OS_MACOSX) 163 #elif defined(OS_MACOSX)
163 ASSERT_TRUE(SwitchKeyboardLayout("com.apple.keylayout.German")); 164 ui::ScopedKeyboardLayout german_layout(ui::KEYBOARD_LAYOUT_GERMAN);
164 CheckCharToKeyCode('z', ui::VKEY_Y, 0); 165 CheckCharToKeyCode('z', ui::VKEY_Y, 0);
165 EXPECT_EQ("z", ConvertKeyCodeToTextNoError(ui::VKEY_Y, 0)); 166 EXPECT_EQ("z", ConvertKeyCodeToTextNoError(ui::VKEY_Y, 0));
166 #endif 167 #endif
167 } 168 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698