| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2016 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 |
| 5 #include "base/message_loop/message_loop.h" |
| 6 #include "base/strings/utf_string_conversions.h" |
| 7 #include "mojo/public/cpp/bindings/binding_set.h" |
| 8 #include "services/ui/public/interfaces/ime/ime_struct_traits_test.mojom.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "ui/base/ime/composition_text.h" |
| 11 #include "ui/base/ime/composition_underline.h" |
| 12 |
| 13 namespace ui { |
| 14 |
| 15 namespace { |
| 16 |
| 17 class IMEStructTraitsTest : public testing::Test, |
| 18 public mojom::IMEStructTraitsTest { |
| 19 public: |
| 20 IMEStructTraitsTest() {} |
| 21 |
| 22 protected: |
| 23 mojom::IMEStructTraitsTestPtr GetTraitsTestProxy() { |
| 24 return traits_test_bindings_.CreateInterfacePtrAndBind(this); |
| 25 } |
| 26 |
| 27 private: |
| 28 // mojom::IMEStructTraitsTest: |
| 29 void EchoCompositionText( |
| 30 const CompositionText& in, |
| 31 const EchoCompositionTextCallback& callback) override { |
| 32 callback.Run(in); |
| 33 } |
| 34 |
| 35 base::MessageLoop loop_; // A MessageLoop is needed for Mojo IPC to work. |
| 36 mojo::BindingSet<mojom::IMEStructTraitsTest> traits_test_bindings_; |
| 37 |
| 38 DISALLOW_COPY_AND_ASSIGN(IMEStructTraitsTest); |
| 39 }; |
| 40 |
| 41 } // namespace |
| 42 |
| 43 TEST_F(IMEStructTraitsTest, CompositionText) { |
| 44 CompositionText input; |
| 45 input.text = base::UTF8ToUTF16("abcdefghij"); |
| 46 input.underlines.push_back(CompositionUnderline(0, 2, SK_ColorGRAY, false)); |
| 47 input.underlines.push_back( |
| 48 CompositionUnderline(3, 6, SK_ColorRED, true, SK_ColorGREEN)); |
| 49 input.selection = gfx::Range(1, 7); |
| 50 |
| 51 mojom::IMEStructTraitsTestPtr proxy = GetTraitsTestProxy(); |
| 52 CompositionText output; |
| 53 proxy->EchoCompositionText(input, &output); |
| 54 |
| 55 EXPECT_EQ(input, output); |
| 56 } |
| 57 |
| 58 } // namespace ui |
| OLD | NEW |