OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 // TODO(nona): Add more tests. | |
5 | |
6 #include "chromeos/ime/ibus_text.h" | |
7 | |
8 #include <string> | |
9 | |
10 #include "base/compiler_specific.h" | |
11 #include "base/logging.h" | |
12 #include "base/memory/scoped_ptr.h" | |
13 #include "testing/gmock/include/gmock/gmock.h" | |
Seigo Nonaka
2013/11/13 14:09:52
Seems no longer using gmock.
Hiro Komatsu
2013/11/14 02:55:01
Done.
| |
14 #include "testing/gtest/include/gtest/gtest.h" | |
15 | |
16 namespace chromeos { | |
17 | |
18 TEST(IBusTextTest, WriteReadTest) { | |
Seigo Nonaka
2013/11/13 14:09:52
This is not your fault but seems "CopyTest" is app
Hiro Komatsu
2013/11/14 02:55:01
Done.
| |
19 const char kSampleText[] = "Sample Text"; | |
20 const char kAnnotation[] = "Annotation"; | |
21 const char kDescriptionTitle[] = "Description Title"; | |
22 const char kDescriptionBody[] = "Description Body"; | |
23 const IBusText::UnderlineAttribute kSampleUnderlineAttribute1 = { | |
24 IBusText::IBUS_TEXT_UNDERLINE_SINGLE, 10, 20}; | |
25 | |
26 const IBusText::UnderlineAttribute kSampleUnderlineAttribute2 = { | |
27 IBusText::IBUS_TEXT_UNDERLINE_DOUBLE, 11, 21}; | |
28 | |
29 const IBusText::UnderlineAttribute kSampleUnderlineAttribute3 = { | |
30 IBusText::IBUS_TEXT_UNDERLINE_ERROR, 12, 22}; | |
31 | |
32 const IBusText::SelectionAttribute kSampleSelectionAttribute = {30, 40}; | |
33 | |
34 // Make IBusText | |
35 IBusText text; | |
36 text.set_text(kSampleText); | |
37 text.set_annotation(kAnnotation); | |
38 text.set_description_title(kDescriptionTitle); | |
39 text.set_description_body(kDescriptionBody); | |
40 std::vector<IBusText::UnderlineAttribute>* underline_attributes = | |
41 text.mutable_underline_attributes(); | |
42 underline_attributes->push_back(kSampleUnderlineAttribute1); | |
43 underline_attributes->push_back(kSampleUnderlineAttribute2); | |
44 underline_attributes->push_back(kSampleUnderlineAttribute3); | |
45 std::vector<IBusText::SelectionAttribute>* selection_attributes = | |
46 text.mutable_selection_attributes(); | |
47 selection_attributes->push_back(kSampleSelectionAttribute); | |
48 | |
49 IBusText text2; | |
50 text2.CopyFrom(text); | |
51 | |
52 EXPECT_EQ(text.text(), text2.text()); | |
53 EXPECT_EQ(text.annotation(), text2.annotation()); | |
54 EXPECT_EQ(text.description_title(), text2.description_title()); | |
55 EXPECT_EQ(text.description_body(), text2.description_body()); | |
56 | |
57 EXPECT_EQ(text.underline_attributes().size(), | |
58 text2.underline_attributes().size()); | |
59 for (size_t i = 0; i < text.underline_attributes().size(); ++i) { | |
60 EXPECT_EQ(text.underline_attributes()[i].type, | |
61 text2.underline_attributes()[i].type); | |
62 EXPECT_EQ(text.underline_attributes()[i].start_index, | |
63 text2.underline_attributes()[i].start_index); | |
64 EXPECT_EQ(text.underline_attributes()[i].end_index, | |
65 text2.underline_attributes()[i].end_index); | |
66 } | |
67 | |
68 EXPECT_EQ(text.selection_attributes().size(), | |
69 text2.selection_attributes().size()); | |
70 for (size_t i = 0; i < text.selection_attributes().size(); ++i) { | |
71 EXPECT_EQ(text.selection_attributes()[i].start_index, | |
72 text2.selection_attributes()[i].start_index); | |
73 EXPECT_EQ(text.selection_attributes()[i].end_index, | |
74 text2.selection_attributes()[i].end_index); | |
75 } | |
76 } | |
77 | |
78 } // namespace chromeos | |
OLD | NEW |