OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <cstring> | 5 #include <cstring> |
6 | 6 |
7 #include "base/i18n/char_iterator.h" | 7 #include "base/i18n/char_iterator.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chromeos/dbus/dbus_thread_manager.h" | 10 #include "chromeos/dbus/dbus_thread_manager.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 for (size_t i = 0; i < utf8_offset; ++i) | 28 for (size_t i = 0; i < utf8_offset; ++i) |
29 char_iterator.Advance(); | 29 char_iterator.Advance(); |
30 return char_iterator.array_pos(); | 30 return char_iterator.array_pos(); |
31 } | 31 } |
32 | 32 |
33 } // namespace | 33 } // namespace |
34 | 34 |
35 | 35 |
36 class TestableInputMethodIBus : public InputMethodIBus { | 36 class TestableInputMethodIBus : public InputMethodIBus { |
37 public: | 37 public: |
38 TestableInputMethodIBus(internal::InputMethodDelegate* delegate) | 38 explicit TestableInputMethodIBus(internal::InputMethodDelegate* delegate) |
39 : InputMethodIBus(delegate) { | 39 : InputMethodIBus(delegate) { |
40 } | 40 } |
41 | 41 |
42 // Change access rights. | 42 // Change access rights. |
43 using InputMethodIBus::ExtractCompositionText; | 43 using InputMethodIBus::ExtractCompositionText; |
44 }; | 44 }; |
45 | 45 |
46 class CreateInputContextSuccessHandler { | 46 class CreateInputContextSuccessHandler { |
47 public: | 47 public: |
48 CreateInputContextSuccessHandler(const dbus::ObjectPath& object_path) | 48 explicit CreateInputContextSuccessHandler(const dbus::ObjectPath& object_path) |
49 : object_path_(object_path) { | 49 : object_path_(object_path) { |
50 } | 50 } |
51 | 51 |
52 void Run(const std::string& client_name, | 52 void Run(const std::string& client_name, |
53 const chromeos::IBusClient::CreateInputContextCallback& callback, | 53 const chromeos::IBusClient::CreateInputContextCallback& callback, |
54 const chromeos::IBusClient::ErrorCallback& error_callback) { | 54 const chromeos::IBusClient::ErrorCallback& error_callback) { |
55 EXPECT_EQ("chrome", client_name); | 55 EXPECT_EQ("chrome", client_name); |
56 callback.Run(object_path_); | 56 callback.Run(object_path_); |
57 } | 57 } |
58 | 58 |
(...skipping 23 matching lines...) Expand all Loading... |
82 ~CreateInputContextDelayFailHandler() { | 82 ~CreateInputContextDelayFailHandler() { |
83 error_callback_.Run(); | 83 error_callback_.Run(); |
84 } | 84 } |
85 | 85 |
86 void Run(const std::string& client_name, | 86 void Run(const std::string& client_name, |
87 const chromeos::IBusClient::CreateInputContextCallback& callback, | 87 const chromeos::IBusClient::CreateInputContextCallback& callback, |
88 const chromeos::IBusClient::ErrorCallback& error_callback) { | 88 const chromeos::IBusClient::ErrorCallback& error_callback) { |
89 error_callback_ = error_callback; | 89 error_callback_ = error_callback; |
90 } | 90 } |
91 | 91 |
92 chromeos::IBusClient::ErrorCallback error_callback_; | 92 chromeos::IBusClient::ErrorCallback error_callback_; |
93 }; | 93 }; |
94 | 94 |
95 class InputMethodIBusTest : public internal::InputMethodDelegate, | 95 class InputMethodIBusTest : public internal::InputMethodDelegate, |
96 public testing::Test, | 96 public testing::Test, |
97 public TextInputClient { | 97 public TextInputClient { |
98 public: | 98 public: |
99 InputMethodIBusTest() { | 99 InputMethodIBusTest() { |
100 ResetFlags(); | 100 ResetFlags(); |
101 } | 101 } |
102 | 102 |
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
771 composition_text.underlines[0].start_offset); | 771 composition_text.underlines[0].start_offset); |
772 EXPECT_EQ(GetOffsetInUTF16(kSampleText, selection.end_index), | 772 EXPECT_EQ(GetOffsetInUTF16(kSampleText, selection.end_index), |
773 composition_text.underlines[0].end_offset); | 773 composition_text.underlines[0].end_offset); |
774 EXPECT_EQ(SK_ColorBLACK, composition_text.underlines[0].color); | 774 EXPECT_EQ(SK_ColorBLACK, composition_text.underlines[0].color); |
775 EXPECT_TRUE(composition_text.underlines[0].thick); | 775 EXPECT_TRUE(composition_text.underlines[0].thick); |
776 } | 776 } |
777 | 777 |
778 // TODO(nona): Write more tests, especially for key event functions. | 778 // TODO(nona): Write more tests, especially for key event functions. |
779 | 779 |
780 } // namespace ui | 780 } // namespace ui |
OLD | NEW |