OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2011 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 | |
5 #include "chrome/browser/chromeos/input_method/candidate_window_view.h" | |
6 | |
7 #include "testing/gtest/include/gtest/gtest.h" | |
8 | |
9 namespace chromeos { | |
10 namespace input_method { | |
11 | |
12 TEST(CandidateWindowViewTest, ShouldUpdateCandidateViewsTest) { | |
Yusuke Sato
2011/11/17 06:07:39
Please add 3-4 lines of test description.
Seigo Nonaka
2011/11/17 07:52:50
Done.
| |
13 const char* kSampleCandidate1 = "Sample Candidate 1"; | |
14 const char* kSampleCandidate2 = "Sample Candidate 2"; | |
15 const char* kSampleCandidate3 = "Sample Candidate 3"; | |
16 | |
17 const char* kSampleAnnotation1 = "Sample Annotation 1"; | |
18 const char* kSampleAnnotation2 = "Sample Annotation 2"; | |
19 const char* kSampleAnnotation3 = "Sample Annotation 3"; | |
20 | |
21 const char* kSampleLabel1 = "Sample Label 1"; | |
22 const char* kSampleLabel2 = "Sample Label 2"; | |
23 const char* kSampleLabel3 = "Sample Label 3"; | |
24 | |
25 InputMethodLookupTable old_table; | |
26 InputMethodLookupTable new_table; | |
27 | |
28 old_table.visible = true; | |
29 old_table.cursor_absolute_index = 0; | |
30 old_table.page_size = 1; | |
31 old_table.candidates.clear(); | |
32 old_table.orientation = InputMethodLookupTable::kVertical; | |
33 old_table.labels.clear(); | |
34 old_table.annotations.clear(); | |
35 | |
36 new_table = old_table; | |
37 | |
38 EXPECT_FALSE(CandidateWindowView::ShouldUpdateCandidateViews(old_table, | |
39 new_table)); | |
40 | |
41 new_table.visible = false; | |
42 // Visibility would be ignored. | |
43 EXPECT_FALSE(CandidateWindowView::ShouldUpdateCandidateViews(old_table, | |
44 new_table)); | |
45 new_table = old_table; | |
46 new_table.candidates.push_back(kSampleCandidate1); | |
47 old_table.candidates.push_back(kSampleCandidate1); | |
48 EXPECT_FALSE(CandidateWindowView::ShouldUpdateCandidateViews(old_table, | |
49 new_table)); | |
50 new_table.labels.push_back(kSampleLabel1); | |
51 old_table.labels.push_back(kSampleLabel1); | |
52 EXPECT_FALSE(CandidateWindowView::ShouldUpdateCandidateViews(old_table, | |
53 new_table)); | |
54 new_table.annotations.push_back(kSampleAnnotation1); | |
55 old_table.annotations.push_back(kSampleAnnotation1); | |
56 EXPECT_FALSE(CandidateWindowView::ShouldUpdateCandidateViews(old_table, | |
57 new_table)); | |
58 | |
59 new_table.cursor_absolute_index = 1; | |
60 EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table, | |
61 new_table)); | |
62 new_table = old_table; | |
63 | |
64 new_table.page_size = 2; | |
65 EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table, | |
66 new_table)); | |
67 new_table = old_table; | |
68 | |
69 new_table.orientation = InputMethodLookupTable::kHorizontal; | |
70 EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table, | |
71 new_table)); | |
72 | |
73 new_table = old_table; | |
74 new_table.candidates.push_back(kSampleCandidate2); | |
75 EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table, | |
76 new_table)); | |
77 old_table.candidates.push_back(kSampleCandidate3); | |
78 EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table, | |
79 new_table)); | |
80 new_table.candidates.clear(); | |
81 EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table, | |
82 new_table)); | |
83 new_table.candidates.push_back(kSampleCandidate2); | |
84 old_table.candidates.clear(); | |
85 EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table, | |
86 new_table)); | |
87 | |
88 new_table = old_table; | |
89 new_table.labels.push_back(kSampleLabel2); | |
90 EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table, | |
91 new_table)); | |
92 old_table.labels.push_back(kSampleLabel3); | |
93 EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table, | |
94 new_table)); | |
95 new_table.labels.clear(); | |
96 EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table, | |
97 new_table)); | |
98 new_table.labels.push_back(kSampleLabel2); | |
99 old_table.labels.clear(); | |
100 EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table, | |
101 new_table)); | |
102 | |
103 new_table = old_table; | |
104 new_table.annotations.push_back(kSampleAnnotation2); | |
105 EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table, | |
106 new_table)); | |
107 old_table.annotations.push_back(kSampleAnnotation3); | |
108 EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table, | |
109 new_table)); | |
110 new_table.annotations.clear(); | |
111 EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table, | |
112 new_table)); | |
113 new_table.annotations.push_back(kSampleAnnotation2); | |
114 old_table.annotations.clear(); | |
115 EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table, | |
116 new_table)); | |
117 } | |
118 | |
119 } // namespace input_method | |
120 } // namespace chromeos | |
OLD | NEW |