| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "ui/base/ime/input_method_auralinux.h" | 5 #include "ui/base/ime/input_method_auralinux.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 expected_actions_.clear(); | 50 expected_actions_.clear(); |
| 51 } | 51 } |
| 52 | 52 |
| 53 private: | 53 private: |
| 54 std::vector<base::string16> recorded_actions_; | 54 std::vector<base::string16> recorded_actions_; |
| 55 std::vector<base::string16> expected_actions_; | 55 std::vector<base::string16> expected_actions_; |
| 56 }; | 56 }; |
| 57 | 57 |
| 58 class LinuxInputMethodContextForTesting : public LinuxInputMethodContext { | 58 class LinuxInputMethodContextForTesting : public LinuxInputMethodContext { |
| 59 public: | 59 public: |
| 60 LinuxInputMethodContextForTesting(LinuxInputMethodContextDelegate* delegate, | 60 explicit LinuxInputMethodContextForTesting( |
| 61 bool is_simple) | 61 LinuxInputMethodContextDelegate* delegate) |
| 62 : delegate_(delegate), | 62 : delegate_(delegate), |
| 63 is_simple_(is_simple), | |
| 64 is_sync_mode_(false), | 63 is_sync_mode_(false), |
| 65 eat_key_(false), | 64 eat_key_(false), |
| 66 focused_(false) {} | 65 focused_(false) {} |
| 67 | 66 |
| 68 void SetSyncMode(bool is_sync_mode) { is_sync_mode_ = is_sync_mode; } | 67 void SetSyncMode(bool is_sync_mode) { is_sync_mode_ = is_sync_mode; } |
| 69 void SetEatKey(bool eat_key) { eat_key_ = eat_key; } | 68 void SetEatKey(bool eat_key) { eat_key_ = eat_key; } |
| 70 | 69 |
| 71 void AddCommitAction(const std::string& text) { | 70 void AddCommitAction(const std::string& text) { |
| 72 actions_.push_back(base::ASCIIToUTF16("C:" + text)); | 71 actions_.push_back(base::ASCIIToUTF16("C:" + text)); |
| 73 } | 72 } |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 | 121 |
| 123 void Blur() override { focused_ = false; } | 122 void Blur() override { focused_ = false; } |
| 124 | 123 |
| 125 void SetCursorLocation(const gfx::Rect& rect) override { | 124 void SetCursorLocation(const gfx::Rect& rect) override { |
| 126 cursor_position_ = rect; | 125 cursor_position_ = rect; |
| 127 } | 126 } |
| 128 | 127 |
| 129 private: | 128 private: |
| 130 LinuxInputMethodContextDelegate* delegate_; | 129 LinuxInputMethodContextDelegate* delegate_; |
| 131 std::vector<base::string16> actions_; | 130 std::vector<base::string16> actions_; |
| 132 bool is_simple_; | |
| 133 bool is_sync_mode_; | 131 bool is_sync_mode_; |
| 134 bool eat_key_; | 132 bool eat_key_; |
| 135 bool focused_; | 133 bool focused_; |
| 136 gfx::Rect cursor_position_; | 134 gfx::Rect cursor_position_; |
| 137 | 135 |
| 138 DISALLOW_COPY_AND_ASSIGN(LinuxInputMethodContextForTesting); | 136 DISALLOW_COPY_AND_ASSIGN(LinuxInputMethodContextForTesting); |
| 139 }; | 137 }; |
| 140 | 138 |
| 141 class LinuxInputMethodContextFactoryForTesting | 139 class LinuxInputMethodContextFactoryForTesting |
| 142 : public LinuxInputMethodContextFactory { | 140 : public LinuxInputMethodContextFactory { |
| 143 public: | 141 public: |
| 144 LinuxInputMethodContextFactoryForTesting(){}; | 142 LinuxInputMethodContextFactoryForTesting(){}; |
| 145 | 143 |
| 146 std::unique_ptr<LinuxInputMethodContext> CreateInputMethodContext( | 144 std::unique_ptr<LinuxInputMethodContext> CreateInputMethodContext( |
| 147 LinuxInputMethodContextDelegate* delegate, | 145 LinuxInputMethodContextDelegate* delegate, |
| 148 bool is_simple) const override { | 146 bool is_simple) const override { |
| 149 return std::unique_ptr<ui::LinuxInputMethodContext>( | 147 return std::unique_ptr<ui::LinuxInputMethodContext>( |
| 150 new LinuxInputMethodContextForTesting(delegate, is_simple)); | 148 new LinuxInputMethodContextForTesting(delegate)); |
| 151 }; | 149 }; |
| 152 | 150 |
| 153 private: | 151 private: |
| 154 DISALLOW_COPY_AND_ASSIGN(LinuxInputMethodContextFactoryForTesting); | 152 DISALLOW_COPY_AND_ASSIGN(LinuxInputMethodContextFactoryForTesting); |
| 155 }; | 153 }; |
| 156 | 154 |
| 157 class InputMethodDelegateForTesting : public internal::InputMethodDelegate { | 155 class InputMethodDelegateForTesting : public internal::InputMethodDelegate { |
| 158 public: | 156 public: |
| 159 InputMethodDelegateForTesting(){}; | 157 InputMethodDelegateForTesting(){}; |
| 160 ~InputMethodDelegateForTesting() override{}; | 158 ~InputMethodDelegateForTesting() override{}; |
| (...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 757 input_method_auralinux_->DispatchKeyEvent(&key); | 755 input_method_auralinux_->DispatchKeyEvent(&key); |
| 758 | 756 |
| 759 test_result_->ExpectAction("textinput:c"); | 757 test_result_->ExpectAction("textinput:c"); |
| 760 test_result_->ExpectAction("keydown:65"); | 758 test_result_->ExpectAction("keydown:65"); |
| 761 test_result_->ExpectAction("keypress:65"); | 759 test_result_->ExpectAction("keypress:65"); |
| 762 test_result_->Verify(); | 760 test_result_->Verify(); |
| 763 } | 761 } |
| 764 | 762 |
| 765 } // namespace | 763 } // namespace |
| 766 } // namespace ui | 764 } // namespace ui |
| OLD | NEW |