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

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: Address comments on 11361210 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"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "chromeos/dbus/ibus/ibus_object.h" 13 #include "chromeos/dbus/ibus/ibus_object.h"
14 #include "dbus/message.h" 14 #include "dbus/message.h"
15 #include "testing/gmock/include/gmock/gmock.h" 15 #include "testing/gmock/include/gmock/gmock.h"
16 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
17 17
18 namespace chromeos { 18 namespace chromeos {
19 // TODO(nona): Remove ibus namespace after complete libibus removal. 19 // TODO(nona): Remove ibus namespace after complete libibus removal.
20 namespace ibus { 20 namespace ibus {
21 21
22 TEST(IBusTextTest, WriteReadTest) { 22 TEST(IBusTextTest, WriteReadTest) {
23 const char kSampleText[] = "Sample Text"; 23 const char kSampleText[] = "Sample Text";
24 const char kAnnotation[] = "Annotation"; 24 const char kAnnotation[] = "Annotation";
25 const char kDescription[] = "Description"; 25 const char kDescriptionTitle[] = "Description Title";
26 const char kDescriptionBody[] = "Description Body";
26 const IBusText::UnderlineAttribute kSampleUnderlineAttribute1 = { 27 const IBusText::UnderlineAttribute kSampleUnderlineAttribute1 = {
27 IBusText::IBUS_TEXT_UNDERLINE_SINGLE, 10, 20}; 28 IBusText::IBUS_TEXT_UNDERLINE_SINGLE, 10, 20};
28 29
29 const IBusText::UnderlineAttribute kSampleUnderlineAttribute2 = { 30 const IBusText::UnderlineAttribute kSampleUnderlineAttribute2 = {
30 IBusText::IBUS_TEXT_UNDERLINE_DOUBLE, 11, 21}; 31 IBusText::IBUS_TEXT_UNDERLINE_DOUBLE, 11, 21};
31 32
32 const IBusText::UnderlineAttribute kSampleUnderlineAttribute3 = { 33 const IBusText::UnderlineAttribute kSampleUnderlineAttribute3 = {
33 IBusText::IBUS_TEXT_UNDERLINE_ERROR, 12, 22}; 34 IBusText::IBUS_TEXT_UNDERLINE_ERROR, 12, 22};
34 35
35 const IBusText::SelectionAttribute kSampleSelectionAttribute = {30, 40}; 36 const IBusText::SelectionAttribute kSampleSelectionAttribute = {30, 40};
36 37
37 // Make IBusText 38 // Make IBusText
38 IBusText text; 39 IBusText text;
39 text.set_text(kSampleText); 40 text.set_text(kSampleText);
40 text.set_annotation(kAnnotation); 41 text.set_annotation(kAnnotation);
41 text.set_description(kDescription); 42 text.set_description_title(kDescriptionTitle);
43 text.set_description_body(kDescriptionBody);
42 std::vector<IBusText::UnderlineAttribute>* underline_attributes = 44 std::vector<IBusText::UnderlineAttribute>* underline_attributes =
43 text.mutable_underline_attributes(); 45 text.mutable_underline_attributes();
44 underline_attributes->push_back(kSampleUnderlineAttribute1); 46 underline_attributes->push_back(kSampleUnderlineAttribute1);
45 underline_attributes->push_back(kSampleUnderlineAttribute2); 47 underline_attributes->push_back(kSampleUnderlineAttribute2);
46 underline_attributes->push_back(kSampleUnderlineAttribute3); 48 underline_attributes->push_back(kSampleUnderlineAttribute3);
47 std::vector<IBusText::SelectionAttribute>* selection_attributes = 49 std::vector<IBusText::SelectionAttribute>* selection_attributes =
48 text.mutable_selection_attributes(); 50 text.mutable_selection_attributes();
49 selection_attributes->push_back(kSampleSelectionAttribute); 51 selection_attributes->push_back(kSampleSelectionAttribute);
50 52
51 // Write to Response object. 53 // Write to Response object.
52 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); 54 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty());
53 dbus::MessageWriter writer(response.get()); 55 dbus::MessageWriter writer(response.get());
54 AppendIBusText(text, &writer); 56 AppendIBusText(text, &writer);
55 57
56 // Read from Response object. 58 // Read from Response object.
57 dbus::MessageReader reader(response.get()); 59 dbus::MessageReader reader(response.get());
58 IBusText expected_text; 60 IBusText expected_text;
59 ASSERT_TRUE(PopIBusText(&reader, &expected_text)); 61 ASSERT_TRUE(PopIBusText(&reader, &expected_text));
60 EXPECT_EQ(kSampleText, expected_text.text()); 62 EXPECT_EQ(kSampleText, expected_text.text());
61 EXPECT_EQ(kAnnotation, expected_text.annotation()); 63 EXPECT_EQ(kAnnotation, expected_text.annotation());
62 EXPECT_EQ(kDescription, expected_text.description()); 64 EXPECT_EQ(kDescriptionTitle, expected_text.description_title());
65 EXPECT_EQ(kDescriptionBody, expected_text.description_body());
63 EXPECT_EQ(3U, expected_text.underline_attributes().size()); 66 EXPECT_EQ(3U, expected_text.underline_attributes().size());
64 EXPECT_EQ(1U, expected_text.selection_attributes().size()); 67 EXPECT_EQ(1U, expected_text.selection_attributes().size());
65 } 68 }
66 69
67 TEST(IBusTextTest, StringAsIBusTextTest) { 70 TEST(IBusTextTest, StringAsIBusTextTest) {
68 const char kSampleText[] = "Sample Text"; 71 const char kSampleText[] = "Sample Text";
69 72
70 // Write to Response object. 73 // Write to Response object.
71 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); 74 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty());
72 dbus::MessageWriter writer(response.get()); 75 dbus::MessageWriter writer(response.get());
(...skipping 18 matching lines...) Expand all
91 94
92 // Read from Response object. 95 // Read from Response object.
93 dbus::MessageReader reader(response.get()); 96 dbus::MessageReader reader(response.get());
94 std::string result; 97 std::string result;
95 ASSERT_TRUE(PopStringFromIBusText(&reader, &result)); 98 ASSERT_TRUE(PopStringFromIBusText(&reader, &result));
96 EXPECT_EQ(kSampleText, result); 99 EXPECT_EQ(kSampleText, result);
97 } 100 }
98 101
99 } // namespace ibus 102 } // namespace ibus
100 } // namespace chromeos 103 } // 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