| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
| 12 #include "chrome/browser/chromeos/events/keyboard_driven_event_rewriter.h" | 12 #include "chrome/browser/chromeos/events/keyboard_driven_event_rewriter.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 #include "ui/events/event.h" | 14 #include "ui/events/event.h" |
| 15 | 15 |
| 16 namespace chromeos { | 16 namespace chromeos { |
| 17 | 17 |
| 18 class KeyboardDrivenEventRewriterTest : public testing::Test { | 18 class KeyboardDrivenEventRewriterTest : public testing::Test { |
| 19 public: | 19 public: |
| 20 KeyboardDrivenEventRewriterTest() {} | 20 KeyboardDrivenEventRewriterTest() {} |
| 21 | 21 |
| 22 ~KeyboardDrivenEventRewriterTest() override {} | 22 ~KeyboardDrivenEventRewriterTest() override {} |
| 23 | 23 |
| 24 protected: | 24 protected: |
| 25 std::string GetRewrittenEventAsString(ui::KeyboardCode ui_keycode, | 25 std::string GetRewrittenEventAsString(ui::KeyboardCode ui_keycode, |
| 26 int ui_flags, | 26 int ui_flags, |
| 27 ui::EventType ui_type) { | 27 ui::EventType ui_type) { |
| 28 ui::KeyEvent keyevent(ui_type, ui_keycode, ui_flags); | 28 ui::KeyEvent keyevent(ui_type, ui_keycode, ui_flags); |
| 29 scoped_ptr<ui::Event> rewritten_event; | 29 std::unique_ptr<ui::Event> rewritten_event; |
| 30 ui::EventRewriteStatus status = | 30 ui::EventRewriteStatus status = |
| 31 rewriter_.RewriteForTesting(keyevent, &rewritten_event); | 31 rewriter_.RewriteForTesting(keyevent, &rewritten_event); |
| 32 return base::StringPrintf( | 32 return base::StringPrintf( |
| 33 "ui_flags=%d status=%d", | 33 "ui_flags=%d status=%d", |
| 34 rewritten_event ? rewritten_event->flags() : keyevent.flags(), | 34 rewritten_event ? rewritten_event->flags() : keyevent.flags(), |
| 35 status); | 35 status); |
| 36 } | 36 } |
| 37 | 37 |
| 38 std::string GetExpectedResultAsString(int ui_flags, | 38 std::string GetExpectedResultAsString(int ui_flags, |
| 39 ui::EventRewriteStatus status) { | 39 ui::EventRewriteStatus status) { |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 EXPECT_EQ(GetExpectedResultAsString(ui::EF_NONE, | 108 EXPECT_EQ(GetExpectedResultAsString(ui::EF_NONE, |
| 109 ui::EVENT_REWRITE_REWRITTEN), | 109 ui::EVENT_REWRITE_REWRITTEN), |
| 110 GetRewrittenEventAsString(kTests[i].ui_keycode, | 110 GetRewrittenEventAsString(kTests[i].ui_keycode, |
| 111 kTests[i].ui_flags, | 111 kTests[i].ui_flags, |
| 112 ui::ET_KEY_PRESSED)) | 112 ui::ET_KEY_PRESSED)) |
| 113 << "Test case " << i; | 113 << "Test case " << i; |
| 114 } | 114 } |
| 115 } | 115 } |
| 116 | 116 |
| 117 } // namespace chromeos | 117 } // namespace chromeos |
| OLD | NEW |