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

Unified Diff: chrome/test/webdriver/keycode_text_conversion_mac.mm

Issue 23526047: Delete old chromedriver code, and remove mongoose webserver. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/test/webdriver/keycode_text_conversion_mac.mm
diff --git a/chrome/test/webdriver/keycode_text_conversion_mac.mm b/chrome/test/webdriver/keycode_text_conversion_mac.mm
deleted file mode 100644
index aa2e424824f5f6f91fc170ec7e930ba033b5348f..0000000000000000000000000000000000000000
--- a/chrome/test/webdriver/keycode_text_conversion_mac.mm
+++ /dev/null
@@ -1,102 +0,0 @@
-// Copyright (c) 2011 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.
-
-#include "chrome/test/webdriver/keycode_text_conversion.h"
-
-#import <Carbon/Carbon.h>
-
-#include <cctype>
-
-#include "base/mac/scoped_cftyperef.h"
-#include "base/strings/utf_string_conversions.h"
-#include "chrome/common/automation_constants.h"
-#include "ui/base/keycodes/keyboard_code_conversion_mac.h"
-
-namespace webdriver {
-
-std::string ConvertKeyCodeToText(ui::KeyboardCode key_code, int modifiers) {
- int mac_key_code = 0;
- {
- unichar character, unmodified_character;
- mac_key_code = ui::MacKeyCodeForWindowsKeyCode(
- key_code,
- 0,
- &character,
- &unmodified_character);
- }
- if (mac_key_code < 0)
- return "";
-
- int mac_modifiers = 0;
- if (modifiers & automation::kShiftKeyMask)
- mac_modifiers |= shiftKey;
- if (modifiers & automation::kControlKeyMask)
- mac_modifiers |= controlKey;
- if (modifiers & automation::kAltKeyMask)
- mac_modifiers |= optionKey;
- if (modifiers & automation::kMetaKeyMask)
- mac_modifiers |= cmdKey;
- // Convert EventRecord modifiers to format UCKeyTranslate accepts. See docs
- // on UCKeyTranslate for more info.
- UInt32 modifier_key_state = (mac_modifiers >> 8) & 0xFF;
-
- base::ScopedCFTypeRef<TISInputSourceRef> input_source_copy(
- TISCopyCurrentKeyboardLayoutInputSource());
- CFDataRef layout_data = static_cast<CFDataRef>(TISGetInputSourceProperty(
- input_source_copy, kTISPropertyUnicodeKeyLayoutData));
-
- UInt32 dead_key_state = 0;
- UniCharCount char_count = 0;
- UniChar character = 0;
- OSStatus status = UCKeyTranslate(
- reinterpret_cast<const UCKeyboardLayout*>(CFDataGetBytePtr(layout_data)),
- static_cast<UInt16>(mac_key_code),
- kUCKeyActionDown,
- modifier_key_state,
- LMGetKbdLast(),
- kUCKeyTranslateNoDeadKeysBit,
- &dead_key_state,
- 1,
- &char_count,
- &character);
- if (status == noErr && char_count == 1 && !std::iscntrl(character)) {
- string16 text;
- text.push_back(character);
- return UTF16ToUTF8(text);
- } else {
- return "";
- }
-}
-
-bool ConvertCharToKeyCode(
- char16 key, ui::KeyboardCode* key_code, int *necessary_modifiers) {
- string16 key_string;
- key_string.push_back(key);
- std::string key_string_utf8 = UTF16ToUTF8(key_string);
- bool found_code = false;
- // There doesn't seem to be a way to get a mac key code for a given unicode
- // character. So here we check every key code to see if it produces the
- // right character. We could cache the results and regenerate everytime the
- // language changes, but this brute force technique has negligble performance
- // effects (on my laptop it is a submillisecond difference).
- for (int i = 0; i < 256; ++i) {
- ui::KeyboardCode code = static_cast<ui::KeyboardCode>(i);
- // Skip the numpad keys.
- if (code >= ui::VKEY_NUMPAD0 && code <= ui::VKEY_DIVIDE)
- continue;
- found_code = key_string_utf8 == ConvertKeyCodeToText(code, 0);
- if (!found_code && key_string_utf8 == ConvertKeyCodeToText(
- code, automation::kShiftKeyMask)) {
- *necessary_modifiers = automation::kShiftKeyMask;
- found_code = true;
- }
- if (found_code) {
- *key_code = code;
- break;
- }
- }
- return found_code;
-}
-
-} // namespace webdriver
« no previous file with comments | « chrome/test/webdriver/keycode_text_conversion_gtk.cc ('k') | chrome/test/webdriver/keycode_text_conversion_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698