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

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

Issue 113403006: Update some uses of char16 to use the base:: namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 12 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 | Annotate | Revision Log
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 "chrome/test/chromedriver/chrome/ui_events.h" 9 #include "chrome/test/chromedriver/chrome/ui_events.h"
10 #include "chrome/test/chromedriver/keycode_text_conversion.h" 10 #include "chrome/test/chromedriver/keycode_text_conversion.h"
11 #include "chrome/test/chromedriver/test_util.h" 11 #include "chrome/test/chromedriver/test_util.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 #include "ui/events/keycodes/keyboard_codes.h" 13 #include "ui/events/keycodes/keyboard_codes.h"
14 14
15 namespace { 15 namespace {
16 16
17 void CheckCharToKeyCode16(char16 character, ui::KeyboardCode key_code, 17 void CheckCharToKeyCode16(base::char16 character, ui::KeyboardCode key_code,
18 int modifiers) { 18 int modifiers) {
19 ui::KeyboardCode actual_key_code = ui::VKEY_UNKNOWN; 19 ui::KeyboardCode actual_key_code = ui::VKEY_UNKNOWN;
20 int actual_modifiers = 0; 20 int actual_modifiers = 0;
21 std::string error_msg; 21 std::string error_msg;
22 EXPECT_TRUE(ConvertCharToKeyCode( 22 EXPECT_TRUE(ConvertCharToKeyCode(
23 character, &actual_key_code, &actual_modifiers, &error_msg)); 23 character, &actual_key_code, &actual_modifiers, &error_msg));
24 EXPECT_EQ(key_code, actual_key_code) << "Char: " << character; 24 EXPECT_EQ(key_code, actual_key_code) << "Char: " << character;
25 EXPECT_EQ(modifiers, actual_modifiers) << "Char: " << character; 25 EXPECT_EQ(modifiers, actual_modifiers) << "Char: " << character;
26 } 26 }
27 27
28 void CheckCharToKeyCode(char character, ui::KeyboardCode key_code, 28 void CheckCharToKeyCode(char character, ui::KeyboardCode key_code,
29 int modifiers) { 29 int modifiers) {
30 CheckCharToKeyCode16(base::UTF8ToUTF16(std::string(1, character))[0], 30 CheckCharToKeyCode16(base::UTF8ToUTF16(std::string(1, character))[0],
31 key_code, modifiers); 31 key_code, modifiers);
32 } 32 }
33 33
34 #if defined(OS_WIN) 34 #if defined(OS_WIN)
35 void CheckCharToKeyCode(wchar_t character, ui::KeyboardCode key_code, 35 void CheckCharToKeyCode(wchar_t character, ui::KeyboardCode key_code,
36 int modifiers) { 36 int modifiers) {
37 CheckCharToKeyCode16(base::WideToUTF16(std::wstring(1, character))[0], 37 CheckCharToKeyCode16(base::WideToUTF16(std::wstring(1, character))[0],
38 key_code, modifiers); 38 key_code, modifiers);
39 } 39 }
40 #endif 40 #endif
41 41
42 void CheckCantConvertChar(wchar_t character) { 42 void CheckCantConvertChar(wchar_t character) {
43 std::wstring character_string; 43 std::wstring character_string;
44 character_string.push_back(character); 44 character_string.push_back(character);
45 char16 character_utf16 = base::WideToUTF16(character_string)[0]; 45 base::char16 character_utf16 = base::WideToUTF16(character_string)[0];
46 ui::KeyboardCode actual_key_code = ui::VKEY_UNKNOWN; 46 ui::KeyboardCode actual_key_code = ui::VKEY_UNKNOWN;
47 int actual_modifiers = 0; 47 int actual_modifiers = 0;
48 std::string error_msg; 48 std::string error_msg;
49 EXPECT_FALSE(ConvertCharToKeyCode( 49 EXPECT_FALSE(ConvertCharToKeyCode(
50 character_utf16, &actual_key_code, &actual_modifiers, &error_msg)); 50 character_utf16, &actual_key_code, &actual_modifiers, &error_msg));
51 } 51 }
52 52
53 std::string ConvertKeyCodeToTextNoError(ui::KeyboardCode key_code, 53 std::string ConvertKeyCodeToTextNoError(ui::KeyboardCode key_code,
54 int modifiers) { 54 int modifiers) {
55 std::string error_msg; 55 std::string error_msg;
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 ASSERT_TRUE(SwitchKeyboardLayout("00000419")); // russian 157 ASSERT_TRUE(SwitchKeyboardLayout("00000419")); // russian
158 CheckCharToKeyCode(L'\u0438', ui::VKEY_B, 0); 158 CheckCharToKeyCode(L'\u0438', ui::VKEY_B, 0);
159 EXPECT_EQ(base::UTF16ToUTF8(L"\u0438"), 159 EXPECT_EQ(base::UTF16ToUTF8(L"\u0438"),
160 ConvertKeyCodeToTextNoError(ui::VKEY_B, 0)); 160 ConvertKeyCodeToTextNoError(ui::VKEY_B, 0));
161 #elif defined(OS_MACOSX) 161 #elif defined(OS_MACOSX)
162 ASSERT_TRUE(SwitchKeyboardLayout("com.apple.keylayout.German")); 162 ASSERT_TRUE(SwitchKeyboardLayout("com.apple.keylayout.German"));
163 CheckCharToKeyCode('z', ui::VKEY_Y, 0); 163 CheckCharToKeyCode('z', ui::VKEY_Y, 0);
164 EXPECT_EQ("z", ConvertKeyCodeToTextNoError(ui::VKEY_Y, 0)); 164 EXPECT_EQ("z", ConvertKeyCodeToTextNoError(ui::VKEY_Y, 0));
165 #endif 165 #endif
166 } 166 }
OLDNEW
« no previous file with comments | « chrome/test/chromedriver/keycode_text_conversion_mac.mm ('k') | chrome/test/chromedriver/keycode_text_conversion_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698