Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(30)

Unified Diff: services/ui/public/interfaces/ime/ime_struct_traits_unittest.cc

Issue 2539453002: IME for Mus: Add ui.mojom.CompositionText and its struct traits. (Closed)
Patch Set: Addressed feedback. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: services/ui/public/interfaces/ime/ime_struct_traits_unittest.cc
diff --git a/services/ui/public/interfaces/ime/ime_struct_traits_unittest.cc b/services/ui/public/interfaces/ime/ime_struct_traits_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..408ff8618eab1a8f65dd1da0289ec9a98215a5da
--- /dev/null
+++ b/services/ui/public/interfaces/ime/ime_struct_traits_unittest.cc
@@ -0,0 +1,58 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/message_loop/message_loop.h"
+#include "base/strings/utf_string_conversions.h"
+#include "mojo/public/cpp/bindings/binding_set.h"
+#include "services/ui/public/interfaces/ime/ime_struct_traits_test.mojom.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/base/ime/composition_text.h"
+#include "ui/base/ime/composition_underline.h"
+
+namespace ui {
+
+namespace {
+
+class IMEStructTraitsTest : public testing::Test,
+ public mojom::IMEStructTraitsTest {
+ public:
+ IMEStructTraitsTest() {}
+
+ protected:
+ mojom::IMEStructTraitsTestPtr GetTraitsTestProxy() {
+ return traits_test_bindings_.CreateInterfacePtrAndBind(this);
+ }
+
+ private:
+ // mojom::IMEStructTraitsTest:
+ void EchoCompositionText(
+ const CompositionText& in,
+ const EchoCompositionTextCallback& callback) override {
+ callback.Run(in);
+ }
+
+ base::MessageLoop loop_; // A MessageLoop is needed for Mojo IPC to work.
+ mojo::BindingSet<mojom::IMEStructTraitsTest> traits_test_bindings_;
+
+ DISALLOW_COPY_AND_ASSIGN(IMEStructTraitsTest);
+};
+
+} // namespace
+
+TEST_F(IMEStructTraitsTest, CompositionText) {
+ CompositionText input;
+ input.text = base::UTF8ToUTF16("abcdefghij");
+ input.underlines.push_back(CompositionUnderline(0, 2, SK_ColorGRAY, false));
+ input.underlines.push_back(
+ CompositionUnderline(3, 6, SK_ColorRED, true, SK_ColorGREEN));
+ input.selection = gfx::Range(1, 7);
+
+ mojom::IMEStructTraitsTestPtr proxy = GetTraitsTestProxy();
+ CompositionText output;
+ proxy->EchoCompositionText(input, &output);
+
+ EXPECT_EQ(input, output);
+}
+
+} // namespace ui
« no previous file with comments | « services/ui/public/interfaces/ime/ime_struct_traits_test.mojom ('k') | services/ui/public/interfaces/ime/typemaps.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698