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

Side by Side Diff: chrome/test/webdriver/keycode_text_conversion_gtk.cc

Issue 13145003: Rewrite std::string("") to std::string(), Linux edition. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ugh Created 7 years, 8 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/test/webdriver/keycode_text_conversion.h" 5 #include "chrome/test/webdriver/keycode_text_conversion.h"
6 6
7 #include <gdk/gdk.h> 7 #include <gdk/gdk.h>
8 8
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
11 #include "chrome/common/automation_constants.h" 11 #include "chrome/common/automation_constants.h"
12 #include "ui/base/keycodes/keyboard_code_conversion_gtk.h" 12 #include "ui/base/keycodes/keyboard_code_conversion_gtk.h"
13 13
14 namespace webdriver { 14 namespace webdriver {
15 15
16 std::string ConvertKeyCodeToText(ui::KeyboardCode key_code, int modifiers) { 16 std::string ConvertKeyCodeToText(ui::KeyboardCode key_code, int modifiers) {
17 // |gdk_keyval_to_upper| does not convert some keys like '1' to '!', so 17 // |gdk_keyval_to_upper| does not convert some keys like '1' to '!', so
18 // provide |ui::GdkKeyCodeForWindowsKeyCode| with our shift state as well, 18 // provide |ui::GdkKeyCodeForWindowsKeyCode| with our shift state as well,
19 // which will do basic conversions like it for us. 19 // which will do basic conversions like it for us.
20 guint gdk_key_code = ui::GdkKeyCodeForWindowsKeyCode( 20 guint gdk_key_code = ui::GdkKeyCodeForWindowsKeyCode(
21 key_code, modifiers & automation::kShiftKeyMask); 21 key_code, modifiers & automation::kShiftKeyMask);
22 if (modifiers & automation::kShiftKeyMask) 22 if (modifiers & automation::kShiftKeyMask)
23 gdk_key_code = gdk_keyval_to_upper(gdk_key_code); 23 gdk_key_code = gdk_keyval_to_upper(gdk_key_code);
24 guint32 unicode_char = gdk_keyval_to_unicode(gdk_key_code); 24 guint32 unicode_char = gdk_keyval_to_unicode(gdk_key_code);
25 if (!unicode_char) 25 if (!unicode_char)
26 return ""; 26 return std::string();
27 gchar buffer[6]; 27 gchar buffer[6];
28 gint length = g_unichar_to_utf8(unicode_char, buffer); 28 gint length = g_unichar_to_utf8(unicode_char, buffer);
29 return std::string(buffer, length); 29 return std::string(buffer, length);
30 } 30 }
31 31
32 // Converts a character to the key code and modifier set that would 32 // Converts a character to the key code and modifier set that would
33 // produce the character using the given keyboard layout. 33 // produce the character using the given keyboard layout.
34 bool ConvertCharToKeyCode( 34 bool ConvertCharToKeyCode(
35 char16 key, ui::KeyboardCode* key_code, int *necessary_modifiers) { 35 char16 key, ui::KeyboardCode* key_code, int *necessary_modifiers) {
36 guint gdk_key_code = gdk_unicode_to_keyval(key); 36 guint gdk_key_code = gdk_unicode_to_keyval(key);
(...skipping 20 matching lines...) Expand all
57 57
58 if (is_special_symbol || key_utf32 != g_unichar_tolower(key_utf32)) 58 if (is_special_symbol || key_utf32 != g_unichar_tolower(key_utf32))
59 *necessary_modifiers = automation::kShiftKeyMask; 59 *necessary_modifiers = automation::kShiftKeyMask;
60 ui::KeyboardCode code = ui::WindowsKeyCodeForGdkKeyCode(gdk_key_code); 60 ui::KeyboardCode code = ui::WindowsKeyCodeForGdkKeyCode(gdk_key_code);
61 if (code != ui::VKEY_UNKNOWN) 61 if (code != ui::VKEY_UNKNOWN)
62 *key_code = code; 62 *key_code = code;
63 return code != ui::VKEY_UNKNOWN; 63 return code != ui::VKEY_UNKNOWN;
64 } 64 }
65 65
66 } // namespace webdriver 66 } // namespace webdriver
OLDNEW
« no previous file with comments | « chrome/test/webdriver/frame_path.cc ('k') | chrome/test/webdriver/webdriver_dispatch_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698