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

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

Issue 94013004: Add base:: to string16s in chrome/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: try again Created 7 years 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 "chrome/test/chromedriver/key_converter.h" 5 #include "chrome/test/chromedriver/key_converter.h"
6 6
7 #include "base/format_macros.h" 7 #include "base/format_macros.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/test/chromedriver/chrome/status.h" 10 #include "chrome/test/chromedriver/chrome/status.h"
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 } 132 }
133 133
134 // Gets the key code associated with |key_utf16|, if it is a special shorthand 134 // Gets the key code associated with |key_utf16|, if it is a special shorthand
135 // key. Shorthand keys are common text equivalents for keys, such as the newline 135 // key. Shorthand keys are common text equivalents for keys, such as the newline
136 // character, which is shorthand for the return key. Returns whether |key| is 136 // character, which is shorthand for the return key. Returns whether |key| is
137 // a shorthand key. If true, |key_code| will be set and |client_should_skip| 137 // a shorthand key. If true, |key_code| will be set and |client_should_skip|
138 // will be set to whether the key should be skipped. 138 // will be set to whether the key should be skipped.
139 bool KeyCodeFromShorthandKey(char16 key_utf16, 139 bool KeyCodeFromShorthandKey(char16 key_utf16,
140 ui::KeyboardCode* key_code, 140 ui::KeyboardCode* key_code,
141 bool* client_should_skip) { 141 bool* client_should_skip) {
142 string16 key_str_utf16; 142 base::string16 key_str_utf16;
143 key_str_utf16.push_back(key_utf16); 143 key_str_utf16.push_back(key_utf16);
144 std::string key_str_utf8 = UTF16ToUTF8(key_str_utf16); 144 std::string key_str_utf8 = UTF16ToUTF8(key_str_utf16);
145 if (key_str_utf8.length() != 1) 145 if (key_str_utf8.length() != 1)
146 return false; 146 return false;
147 bool should_skip = false; 147 bool should_skip = false;
148 char key = key_str_utf8[0]; 148 char key = key_str_utf8[0];
149 if (key == '\n') { 149 if (key == '\n') {
150 *key_code = ui::VKEY_RETURN; 150 *key_code = ui::VKEY_RETURN;
151 } else if (key == '\t') { 151 } else if (key == '\t') {
152 *key_code = ui::VKEY_TAB; 152 *key_code = ui::VKEY_TAB;
(...skipping 26 matching lines...) Expand all
179 KeyEvent CreateCharEvent(const std::string& unmodified_text, 179 KeyEvent CreateCharEvent(const std::string& unmodified_text,
180 const std::string& modified_text, 180 const std::string& modified_text,
181 int modifiers) { 181 int modifiers) {
182 return KeyEvent(kCharEventType, 182 return KeyEvent(kCharEventType,
183 modifiers, 183 modifiers,
184 modified_text, 184 modified_text,
185 unmodified_text, 185 unmodified_text,
186 ui::VKEY_UNKNOWN); 186 ui::VKEY_UNKNOWN);
187 } 187 }
188 188
189 Status ConvertKeysToKeyEvents(const string16& client_keys, 189 Status ConvertKeysToKeyEvents(const base::string16& client_keys,
190 bool release_modifiers, 190 bool release_modifiers,
191 int* modifiers, 191 int* modifiers,
192 std::list<KeyEvent>* client_key_events) { 192 std::list<KeyEvent>* client_key_events) {
193 std::list<KeyEvent> key_events; 193 std::list<KeyEvent> key_events;
194 194
195 string16 keys = client_keys; 195 base::string16 keys = client_keys;
196 // Add an implicit NULL character to the end of the input to depress all 196 // Add an implicit NULL character to the end of the input to depress all
197 // modifiers. 197 // modifiers.
198 if (release_modifiers) 198 if (release_modifiers)
199 keys.push_back(kWebDriverNullKey); 199 keys.push_back(kWebDriverNullKey);
200 200
201 int sticky_modifiers = *modifiers; 201 int sticky_modifiers = *modifiers;
202 for (size_t i = 0; i < keys.size(); ++i) { 202 for (size_t i = 0; i < keys.size(); ++i) {
203 char16 key = keys[i]; 203 char16 key = keys[i];
204 204
205 if (key == kWebDriverNullKey) { 205 if (key == kWebDriverNullKey) {
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 if (necessary_modifiers[i]) { 331 if (necessary_modifiers[i]) {
332 key_events.push_back( 332 key_events.push_back(
333 CreateKeyUpEvent(kModifiers[i].key_code, sticky_modifiers)); 333 CreateKeyUpEvent(kModifiers[i].key_code, sticky_modifiers));
334 } 334 }
335 } 335 }
336 } 336 }
337 client_key_events->swap(key_events); 337 client_key_events->swap(key_events);
338 *modifiers = sticky_modifiers; 338 *modifiers = sticky_modifiers;
339 return Status(kOk); 339 return Status(kOk);
340 } 340 }
OLDNEW
« no previous file with comments | « chrome/test/chromedriver/key_converter.h ('k') | chrome/test/chromedriver/key_converter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698