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

Unified Diff: chromeos/dbus/ibus/ibus_text_unittest.cc

Issue 11363033: Extends IBusText to handle mozc's extended field. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 8 years, 1 month 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
« no previous file with comments | « chromeos/dbus/ibus/ibus_text.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/dbus/ibus/ibus_text_unittest.cc
diff --git a/chromeos/dbus/ibus/ibus_text_unittest.cc b/chromeos/dbus/ibus/ibus_text_unittest.cc
index 744eb78d075d83ad66bb1fda443a8f86401c1b68..b3df566b4fa49311fd1140360cd95861effd396b 100644
--- a/chromeos/dbus/ibus/ibus_text_unittest.cc
+++ b/chromeos/dbus/ibus/ibus_text_unittest.cc
@@ -90,5 +90,113 @@ TEST(IBusTextTest, PopStringFromIBusTextTest) {
EXPECT_EQ(kSampleText, result);
}
+TEST(IBusTextTest, ReadAnnotationFieldTest) {
+ const char kSampleText[] = "Sample Text";
+ const char kSampleAnnotationText[] = "Sample Annotation";
+
+ // Create IBusLookupTable.
+ scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty());
+ dbus::MessageWriter writer(response.get());
+ dbus::MessageWriter top_variant_writer(NULL);
+ writer.OpenVariant("(sa{sv}sv)", &top_variant_writer);
+ dbus::MessageWriter contents_writer(NULL);
+ top_variant_writer.OpenStruct(&contents_writer);
+ contents_writer.AppendString("IBusText");
+
+ // Write attachment field.
+ dbus::MessageWriter attachment_array_writer(NULL);
+ contents_writer.OpenArray("{sv}", &attachment_array_writer);
+ dbus::MessageWriter entry_writer(NULL);
+ attachment_array_writer.OpenDictEntry(&entry_writer);
+ entry_writer.AppendString("annotation");
+ dbus::MessageWriter variant_writer(NULL);
+ entry_writer.OpenVariant("v", &variant_writer);
+ dbus::MessageWriter sub_variant_writer(NULL);
+ variant_writer.OpenVariant("s", &sub_variant_writer);
+ sub_variant_writer.AppendString(kSampleAnnotationText);
+
+ // Close attachment field container.
+ variant_writer.CloseContainer(&sub_variant_writer);
+ entry_writer.CloseContainer(&variant_writer);
+ attachment_array_writer.CloseContainer(&entry_writer);
+ contents_writer.CloseContainer(&attachment_array_writer);
+
+ // Write IBusText contents.
+ contents_writer.AppendString(kSampleText);
+ IBusObjectWriter ibus_attr_list_writer("IBusAttrList", "av",
+ &contents_writer);
+ dbus::MessageWriter attribute_array_writer(NULL);
+ ibus_attr_list_writer.OpenArray("v", &attribute_array_writer);
+ ibus_attr_list_writer.CloseContainer(&attribute_array_writer);
+ ibus_attr_list_writer.CloseAll();
+
+ // Close all containers.
+ top_variant_writer.CloseContainer(&contents_writer);
+ writer.CloseContainer(&top_variant_writer);
+
+ // Read IBusText.
+ IBusText ibus_text;
+ dbus::MessageReader reader(response.get());
+ PopIBusText(&reader, &ibus_text);
+
+ // Check values.
+ EXPECT_EQ(kSampleText, ibus_text.text());
+ EXPECT_EQ(kSampleAnnotationText, ibus_text.annotation());
+}
+
+TEST(IBusTextTest, ReadDescriptionFieldTest) {
+ const char kSampleText[] = "Sample Text";
+ const char kSampleDescriptionText[] = "Sample Description";
+
+ // Create IBusLookupTable.
+ scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty());
+ dbus::MessageWriter writer(response.get());
+ dbus::MessageWriter top_variant_writer(NULL);
+ writer.OpenVariant("(sa{sv}sv)", &top_variant_writer);
+ dbus::MessageWriter contents_writer(NULL);
+ top_variant_writer.OpenStruct(&contents_writer);
+ contents_writer.AppendString("IBusText");
+
+ // Write attachment field.
+ dbus::MessageWriter attachment_array_writer(NULL);
+ contents_writer.OpenArray("{sv}", &attachment_array_writer);
+ dbus::MessageWriter entry_writer(NULL);
+ attachment_array_writer.OpenDictEntry(&entry_writer);
+ entry_writer.AppendString("description");
+ dbus::MessageWriter variant_writer(NULL);
+ entry_writer.OpenVariant("v", &variant_writer);
+ dbus::MessageWriter sub_variant_writer(NULL);
+ variant_writer.OpenVariant("s", &sub_variant_writer);
+ sub_variant_writer.AppendString(kSampleDescriptionText);
+
+ // Close attachment field container.
+ variant_writer.CloseContainer(&sub_variant_writer);
+ entry_writer.CloseContainer(&variant_writer);
+ attachment_array_writer.CloseContainer(&entry_writer);
+ contents_writer.CloseContainer(&attachment_array_writer);
+
+ // Write IBusText contents.
+ contents_writer.AppendString(kSampleText);
+ IBusObjectWriter ibus_attr_list_writer("IBusAttrList", "av",
+ &contents_writer);
+ dbus::MessageWriter attribute_array_writer(NULL);
+ ibus_attr_list_writer.OpenArray("v", &attribute_array_writer);
+ ibus_attr_list_writer.CloseContainer(&attribute_array_writer);
+ ibus_attr_list_writer.CloseAll();
+
+ // Close all containers.
+ top_variant_writer.CloseContainer(&contents_writer);
+ writer.CloseContainer(&top_variant_writer);
+
+ // Read IBusText.
+ IBusText ibus_text;
+ dbus::MessageReader reader(response.get());
+ PopIBusText(&reader, &ibus_text);
+
+ // Check values.
+ EXPECT_EQ(kSampleText, ibus_text.text());
+ EXPECT_EQ(kSampleDescriptionText, ibus_text.description());
+}
+
} // namespace ibus
} // namespace chromeos
« no previous file with comments | « chromeos/dbus/ibus/ibus_text.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698