Blake O'Hare | 5501e5a | 2017-10-05 06:43:25 | [diff] [blame] | 1 | // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
Shu Chen | 3c379ddb | 2018-08-17 01:51:59 | [diff] [blame] | 5 | #ifndef CHROME_BROWSER_UI_ASH_TEST_IME_CONTROLLER_H_ |
| 6 | #define CHROME_BROWSER_UI_ASH_TEST_IME_CONTROLLER_H_ |
Blake O'Hare | 5501e5a | 2017-10-05 06:43:25 | [diff] [blame] | 7 | |
| 8 | #include <memory> |
| 9 | #include <string> |
| 10 | #include <utility> |
Lei Zhang | d89b6cc9 | 2021-06-29 02:07:30 | [diff] [blame] | 11 | #include <vector> |
Blake O'Hare | 5501e5a | 2017-10-05 06:43:25 | [diff] [blame] | 12 | |
Darren Shen | 7b13278 | 2019-12-10 04:36:06 | [diff] [blame] | 13 | #include "ash/public/cpp/ime_controller.h" |
| 14 | #include "ash/public/cpp/ime_info.h" |
Blake O'Hare | 5501e5a | 2017-10-05 06:43:25 | [diff] [blame] | 15 | |
Darren Shen | 7b13278 | 2019-12-10 04:36:06 | [diff] [blame] | 16 | // Class that resets the ImeController instance to nullptr and then restores it |
| 17 | // when it is destroyed. |
| 18 | class ImeControllerResetterForTest { |
| 19 | public: |
| 20 | ImeControllerResetterForTest(); |
| 21 | ~ImeControllerResetterForTest(); |
| 22 | |
| 23 | private: |
| 24 | ash::ImeController* const instance_; |
| 25 | }; |
| 26 | |
| 27 | class TestImeController : private ImeControllerResetterForTest, |
| 28 | public ash::ImeController { |
Blake O'Hare | 5501e5a | 2017-10-05 06:43:25 | [diff] [blame] | 29 | public: |
| 30 | TestImeController(); |
| 31 | ~TestImeController() override; |
| 32 | |
Darren Shen | 7b13278 | 2019-12-10 04:36:06 | [diff] [blame] | 33 | // ash::ImeController: |
| 34 | void SetClient(ash::ImeControllerClient* client) override; |
Blake O'Hare | 5501e5a | 2017-10-05 06:43:25 | [diff] [blame] | 35 | void RefreshIme(const std::string& current_ime_id, |
Darren Shen | 7b13278 | 2019-12-10 04:36:06 | [diff] [blame] | 36 | std::vector<ash::ImeInfo> available_imes, |
| 37 | std::vector<ash::ImeMenuItem> menu_items) override; |
Blake O'Hare | 5501e5a | 2017-10-05 06:43:25 | [diff] [blame] | 38 | void SetImesManagedByPolicy(bool managed) override; |
| 39 | void ShowImeMenuOnShelf(bool show) override; |
Darren Shen | 9f63661 | 2018-03-08 00:02:39 | [diff] [blame] | 40 | void UpdateCapsLockState(bool enabled) override; |
Darren Shen | 29b26a4 | 2018-03-18 22:36:12 | [diff] [blame] | 41 | void OnKeyboardLayoutNameChanged(const std::string& layout_name) override; |
Blake O'Hare | 5501e5a | 2017-10-05 06:43:25 | [diff] [blame] | 42 | void SetExtraInputOptionsEnabledState(bool is_extra_input_options_enabled, |
| 43 | bool is_emoji_enabled, |
| 44 | bool is_handwriting_enabled, |
| 45 | bool is_voice_enabled) override; |
Shu Chen | 3cb6c3f | 2018-08-15 04:18:47 | [diff] [blame] | 46 | void ShowModeIndicator(const gfx::Rect& anchor_bounds, |
Jan Wilken Dörrie | 3f97e29 | 2021-03-11 18:07:14 | [diff] [blame] | 47 | const std::u16string& text) override; |
Blake O'Hare | 5501e5a | 2017-10-05 06:43:25 | [diff] [blame] | 48 | |
| 49 | // The most recent values received via mojo. |
| 50 | std::string current_ime_id_; |
Darren Shen | 7b13278 | 2019-12-10 04:36:06 | [diff] [blame] | 51 | std::vector<ash::ImeInfo> available_imes_; |
| 52 | std::vector<ash::ImeMenuItem> menu_items_; |
Blake O'Hare | 5501e5a | 2017-10-05 06:43:25 | [diff] [blame] | 53 | bool managed_by_policy_ = false; |
| 54 | bool show_ime_menu_on_shelf_ = false; |
Shu Chen | 3cb6c3f | 2018-08-15 04:18:47 | [diff] [blame] | 55 | bool show_mode_indicator_ = false; |
Blake O'Hare | 5501e5a | 2017-10-05 06:43:25 | [diff] [blame] | 56 | bool is_caps_lock_enabled_ = false; |
Darren Shen | 29b26a4 | 2018-03-18 22:36:12 | [diff] [blame] | 57 | std::string keyboard_layout_name_; |
Blake O'Hare | 5501e5a | 2017-10-05 06:43:25 | [diff] [blame] | 58 | bool is_extra_input_options_enabled_ = false; |
| 59 | bool is_emoji_enabled_ = false; |
| 60 | bool is_handwriting_enabled_ = false; |
| 61 | bool is_voice_enabled_ = false; |
| 62 | |
| 63 | private: |
Blake O'Hare | 5501e5a | 2017-10-05 06:43:25 | [diff] [blame] | 64 | DISALLOW_COPY_AND_ASSIGN(TestImeController); |
| 65 | }; |
| 66 | |
Shu Chen | 3c379ddb | 2018-08-17 01:51:59 | [diff] [blame] | 67 | #endif // CHROME_BROWSER_UI_ASH_TEST_IME_CONTROLLER_H_ |