| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/compiler_specific.h" | 6 #include "base/compiler_specific.h" |
| 7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
| 8 #include "chrome/browser/chromeos/keyboard_driven_event_rewriter.h" | 8 #include "chrome/browser/chromeos/keyboard_driven_event_rewriter.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "ui/events/event.h" | 10 #include "ui/events/event.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 std::string GetRewrittenEventAsString(ui::KeyboardCode ui_keycode, | 35 std::string GetRewrittenEventAsString(ui::KeyboardCode ui_keycode, |
| 36 int ui_flags, | 36 int ui_flags, |
| 37 ui::EventType ui_type, | 37 ui::EventType ui_type, |
| 38 KeyCode x_keycode, | 38 KeyCode x_keycode, |
| 39 unsigned int x_state) { | 39 unsigned int x_state) { |
| 40 ui::ScopedXI2Event xev; | 40 ui::ScopedXI2Event xev; |
| 41 xev.InitKeyEvent(ui_type, ui_keycode, ui_flags); | 41 xev.InitKeyEvent(ui_type, ui_keycode, ui_flags); |
| 42 XEvent* xevent = xev; | 42 XEvent* xevent = xev; |
| 43 xevent->xkey.keycode = x_keycode; | 43 xevent->xkey.keycode = x_keycode; |
| 44 xevent->xkey.state = x_state; | 44 xevent->xkey.state = x_state; |
| 45 bool changed = rewriter_.RewriteForTesting(xevent); |
| 45 ui::KeyEvent keyevent(xev, false /* is_char */); | 46 ui::KeyEvent keyevent(xev, false /* is_char */); |
| 46 bool changed = rewriter_.RewriteForTesting(&keyevent); | |
| 47 return base::StringPrintf("ui_flags=%d x_state=%u changed=%d", | 47 return base::StringPrintf("ui_flags=%d x_state=%u changed=%d", |
| 48 keyevent.flags(), | 48 keyevent.flags(), |
| 49 xevent->xkey.state, | 49 xevent->xkey.state, |
| 50 changed); | 50 changed); |
| 51 } | 51 } |
| 52 | 52 |
| 53 std::string GetExpectedResultAsString(int ui_flags, | 53 std::string GetExpectedResultAsString(int ui_flags, |
| 54 unsigned int x_state, | 54 unsigned int x_state, |
| 55 bool changed) { | 55 bool changed) { |
| 56 return base::StringPrintf( | 56 return base::StringPrintf( |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 GetRewrittenEventAsString(kTests[i].ui_keycode, | 150 GetRewrittenEventAsString(kTests[i].ui_keycode, |
| 151 kTests[i].ui_flags, | 151 kTests[i].ui_flags, |
| 152 ui::ET_KEY_PRESSED, | 152 ui::ET_KEY_PRESSED, |
| 153 kTests[i].x_keycode, | 153 kTests[i].x_keycode, |
| 154 kTests[i].x_state)) | 154 kTests[i].x_state)) |
| 155 << "Test case " << i; | 155 << "Test case " << i; |
| 156 } | 156 } |
| 157 } | 157 } |
| 158 | 158 |
| 159 } // namespace chromeos | 159 } // namespace chromeos |
| OLD | NEW |