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

Unified Diff: chrome/test/chromedriver/keycode_text_conversion_x.cc

Issue 2952383002: use ozone implementation for key code conversion when there is no X display (Closed)
Patch Set: Created 3 years, 6 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
« no previous file with comments | « chrome/test/chromedriver/keycode_text_conversion_ozone.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/chromedriver/keycode_text_conversion_x.cc
diff --git a/chrome/test/chromedriver/keycode_text_conversion_x.cc b/chrome/test/chromedriver/keycode_text_conversion_x.cc
index 58c632bcfaec97c9d5d4d17990636edf8ba1d63b..c0b2cf685f9ca303291182b5fca9db9e61434e8b 100644
--- a/chrome/test/chromedriver/keycode_text_conversion_x.cc
+++ b/chrome/test/chromedriver/keycode_text_conversion_x.cc
@@ -184,6 +184,11 @@ bool GetXModifierMask(Display* display, int modifier, int* x_modifier) {
bool ConvertKeyCodeToText(
ui::KeyboardCode key_code, int modifiers, std::string* text,
std::string* error_msg) {
+ XDisplay* display = gfx::GetXDisplay();
+ if (!display) {
+ return ConvertKeyCodeToTextOzone(key_code, modifiers, text, error_msg);
+ }
+
*error_msg = std::string();
int x_key_code = KeyboardCodeToXKeyCode(key_code);
if (x_key_code == -1) {
@@ -194,13 +199,6 @@ bool ConvertKeyCodeToText(
XEvent event;
memset(&event, 0, sizeof(XEvent));
XKeyEvent* key_event = &event.xkey;
- XDisplay* display = gfx::GetXDisplay();
- if (!display) {
- *error_msg =
- "an X display is required for keycode conversions, consider using Xvfb";
- *text = std::string();
- return false;
- }
key_event->display = display;
key_event->keycode = x_key_code;
if (modifiers & kShiftKeyModifierMask)
@@ -237,6 +235,12 @@ bool ConvertCharToKeyCode(
ui::KeyboardCode* key_code,
int* necessary_modifiers,
std::string* error_msg) {
+ XDisplay* display = gfx::GetXDisplay();
+ if (!display) {
+ return ConvertCharToKeyCodeOzone(key, key_code, necessary_modifiers,
+ error_msg);
+ }
+
std::string key_string(base::UTF16ToUTF8(base::string16(1, key)));
bool found = false;
ui::KeyboardCode test_code;
« no previous file with comments | « chrome/test/chromedriver/keycode_text_conversion_ozone.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698