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

Side by Side Diff: chromeos/dbus/ibus/ibus_text_unittest.cc

Issue 11362111: Fix: infolist requries description title. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: reupload 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chromeos/dbus/ibus/ibus_text.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // TODO(nona): Add more tests. 4 // TODO(nona): Add more tests.
5 5
6 #include "chromeos/dbus/ibus/ibus_text.h" 6 #include "chromeos/dbus/ibus/ibus_text.h"
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 dbus::MessageReader reader(response.get()); 139 dbus::MessageReader reader(response.get());
140 PopIBusText(&reader, &ibus_text); 140 PopIBusText(&reader, &ibus_text);
141 141
142 // Check values. 142 // Check values.
143 EXPECT_EQ(kSampleText, ibus_text.text()); 143 EXPECT_EQ(kSampleText, ibus_text.text());
144 EXPECT_EQ(kSampleAnnotationText, ibus_text.annotation()); 144 EXPECT_EQ(kSampleAnnotationText, ibus_text.annotation());
145 } 145 }
146 146
147 TEST(IBusTextTest, ReadDescriptionFieldTest) { 147 TEST(IBusTextTest, ReadDescriptionFieldTest) {
148 const char kSampleText[] = "Sample Text"; 148 const char kSampleText[] = "Sample Text";
149 const char kSampleDescriptionText[] = "Sample Description"; 149 const char kSampleDescriptionTitleText[] = "Sample Description Title";
150 const char kSampleDescriptionBodyText[] = "Sample Description Body";
150 151
151 // Create IBusLookupTable. 152 // Create IBusLookupTable.
152 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); 153 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty());
153 dbus::MessageWriter writer(response.get()); 154 dbus::MessageWriter writer(response.get());
154 dbus::MessageWriter top_variant_writer(NULL); 155 dbus::MessageWriter top_variant_writer(NULL);
155 writer.OpenVariant("(sa{sv}sv)", &top_variant_writer); 156 writer.OpenVariant("(sa{sv}sv)", &top_variant_writer);
156 dbus::MessageWriter contents_writer(NULL); 157 dbus::MessageWriter contents_writer(NULL);
157 top_variant_writer.OpenStruct(&contents_writer); 158 top_variant_writer.OpenStruct(&contents_writer);
158 contents_writer.AppendString("IBusText"); 159 contents_writer.AppendString("IBusText");
159 160
160 // Write attachment field. 161 // Write attachment field.
satorux1 2012/11/08 08:39:30 Maybe // Write attachment fields. because we ha
Seigo Nonaka 2012/11/12 06:13:11 Sure will do. On 2012/11/08 08:39:30, satorux1 wro
161 dbus::MessageWriter attachment_array_writer(NULL); 162 dbus::MessageWriter attachment_array_writer(NULL);
162 contents_writer.OpenArray("{sv}", &attachment_array_writer); 163 contents_writer.OpenArray("{sv}", &attachment_array_writer);
163 dbus::MessageWriter entry_writer(NULL); 164
164 attachment_array_writer.OpenDictEntry(&entry_writer); 165 // Write description title field.
165 entry_writer.AppendString("description"); 166 dbus::MessageWriter title_entry_writer(NULL);
166 dbus::MessageWriter variant_writer(NULL); 167 attachment_array_writer.OpenDictEntry(&title_entry_writer);
167 entry_writer.OpenVariant("v", &variant_writer); 168 title_entry_writer.AppendString("description_title");
168 dbus::MessageWriter sub_variant_writer(NULL); 169 dbus::MessageWriter title_variant_writer(NULL);
169 variant_writer.OpenVariant("s", &sub_variant_writer); 170 title_entry_writer.OpenVariant("v", &title_variant_writer);
170 sub_variant_writer.AppendString(kSampleDescriptionText); 171 dbus::MessageWriter title_sub_variant_writer(NULL);
172 title_variant_writer.OpenVariant("s", &title_sub_variant_writer);
173 title_sub_variant_writer.AppendString(kSampleDescriptionTitleText);
174 title_variant_writer.CloseContainer(&title_sub_variant_writer);
175 title_entry_writer.CloseContainer(&title_variant_writer);
176 attachment_array_writer.CloseContainer(&title_entry_writer);
177
178 // Write description body field.
179 dbus::MessageWriter body_entry_writer(NULL);
180 attachment_array_writer.OpenDictEntry(&body_entry_writer);
181 body_entry_writer.AppendString("description_body");
182 dbus::MessageWriter body_variant_writer(NULL);
183 body_entry_writer.OpenVariant("v", &body_variant_writer);
184 dbus::MessageWriter body_sub_variant_writer(NULL);
185 body_variant_writer.OpenVariant("s", &body_sub_variant_writer);
186 body_sub_variant_writer.AppendString(kSampleDescriptionBodyText);
187 body_variant_writer.CloseContainer(&body_sub_variant_writer);
188 body_entry_writer.CloseContainer(&body_variant_writer);
189 attachment_array_writer.CloseContainer(&body_entry_writer);
satorux1 2012/11/08 08:39:30 Hmm, adding an attachment field seems to be a lot
Seigo Nonaka 2012/11/12 06:13:11 Sure, and I found that we need supporting writing
171 190
172 // Close attachment field container. 191 // Close attachment field container.
173 variant_writer.CloseContainer(&sub_variant_writer);
174 entry_writer.CloseContainer(&variant_writer);
175 attachment_array_writer.CloseContainer(&entry_writer);
176 contents_writer.CloseContainer(&attachment_array_writer); 192 contents_writer.CloseContainer(&attachment_array_writer);
177 193
178 // Write IBusText contents. 194 // Write IBusText contents.
179 contents_writer.AppendString(kSampleText); 195 contents_writer.AppendString(kSampleText);
180 IBusObjectWriter ibus_attr_list_writer("IBusAttrList", "av", 196 IBusObjectWriter ibus_attr_list_writer("IBusAttrList", "av",
181 &contents_writer); 197 &contents_writer);
182 dbus::MessageWriter attribute_array_writer(NULL); 198 dbus::MessageWriter attribute_array_writer(NULL);
183 ibus_attr_list_writer.OpenArray("v", &attribute_array_writer); 199 ibus_attr_list_writer.OpenArray("v", &attribute_array_writer);
184 ibus_attr_list_writer.CloseContainer(&attribute_array_writer); 200 ibus_attr_list_writer.CloseContainer(&attribute_array_writer);
185 ibus_attr_list_writer.CloseAll(); 201 ibus_attr_list_writer.CloseAll();
186 202
187 // Close all containers. 203 // Close all containers.
188 top_variant_writer.CloseContainer(&contents_writer); 204 top_variant_writer.CloseContainer(&contents_writer);
189 writer.CloseContainer(&top_variant_writer); 205 writer.CloseContainer(&top_variant_writer);
190 206
191 // Read IBusText. 207 // Read IBusText.
192 IBusText ibus_text; 208 IBusText ibus_text;
193 dbus::MessageReader reader(response.get()); 209 dbus::MessageReader reader(response.get());
194 PopIBusText(&reader, &ibus_text); 210 PopIBusText(&reader, &ibus_text);
195 211
196 // Check values. 212 // Check values.
197 EXPECT_EQ(kSampleText, ibus_text.text()); 213 EXPECT_EQ(kSampleText, ibus_text.text());
198 EXPECT_EQ(kSampleDescriptionText, ibus_text.description()); 214 EXPECT_EQ(kSampleDescriptionTitleText, ibus_text.description_title());
215 EXPECT_EQ(kSampleDescriptionBodyText, ibus_text.description_body());
199 } 216 }
200 217
201 } // namespace ibus 218 } // namespace ibus
202 } // namespace chromeos 219 } // namespace chromeos
OLDNEW
« 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