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

Side by Side Diff: chrome/browser/chromeos/input_method/candidate_window_view_unittest.cc

Issue 8573035: Implement unittest for CandidateWindowView. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Fixed type and write some comments. Created 9 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 | « chrome/browser/chromeos/input_method/candidate_window_view.h ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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) {
13 // This test verifies the process of judging update lookup-table or not.
14 // This judgement is handled by ShouldUpdateCandidateViews, which returns true
15 // if update is necessary and vice versa.
16 const char* kSampleCandidate1 = "Sample Candidate 1";
17 const char* kSampleCandidate2 = "Sample Candidate 2";
18 const char* kSampleCandidate3 = "Sample Candidate 3";
19
20 const char* kSampleAnnotation1 = "Sample Annotation 1";
21 const char* kSampleAnnotation2 = "Sample Annotation 2";
22 const char* kSampleAnnotation3 = "Sample Annotation 3";
23
24 const char* kSampleLabel1 = "Sample Label 1";
25 const char* kSampleLabel2 = "Sample Label 2";
26 const char* kSampleLabel3 = "Sample Label 3";
27
28 InputMethodLookupTable old_table;
29 InputMethodLookupTable new_table;
30
31 old_table.visible = true;
32 old_table.cursor_absolute_index = 0;
33 old_table.page_size = 1;
34 old_table.candidates.clear();
35 old_table.orientation = InputMethodLookupTable::kVertical;
36 old_table.labels.clear();
37 old_table.annotations.clear();
38
39 new_table = old_table;
40
41 EXPECT_FALSE(CandidateWindowView::ShouldUpdateCandidateViews(old_table,
42 new_table));
43
44 new_table.visible = false;
45 // Visibility would be ignored.
46 EXPECT_FALSE(CandidateWindowView::ShouldUpdateCandidateViews(old_table,
47 new_table));
48 new_table = old_table;
49 new_table.candidates.push_back(kSampleCandidate1);
50 old_table.candidates.push_back(kSampleCandidate1);
51 EXPECT_FALSE(CandidateWindowView::ShouldUpdateCandidateViews(old_table,
52 new_table));
53 new_table.labels.push_back(kSampleLabel1);
54 old_table.labels.push_back(kSampleLabel1);
55 EXPECT_FALSE(CandidateWindowView::ShouldUpdateCandidateViews(old_table,
56 new_table));
57 new_table.annotations.push_back(kSampleAnnotation1);
58 old_table.annotations.push_back(kSampleAnnotation1);
59 EXPECT_FALSE(CandidateWindowView::ShouldUpdateCandidateViews(old_table,
60 new_table));
61
62 new_table.cursor_absolute_index = 1;
63 EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table,
64 new_table));
65 new_table = old_table;
66
67 new_table.page_size = 2;
68 EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table,
69 new_table));
70 new_table = old_table;
71
72 new_table.orientation = InputMethodLookupTable::kHorizontal;
73 EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table,
74 new_table));
75
76 new_table = old_table;
77 new_table.candidates.push_back(kSampleCandidate2);
78 EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table,
79 new_table));
80 old_table.candidates.push_back(kSampleCandidate3);
81 EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table,
82 new_table));
83 new_table.candidates.clear();
84 EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table,
85 new_table));
86 new_table.candidates.push_back(kSampleCandidate2);
87 old_table.candidates.clear();
88 EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table,
89 new_table));
90
91 new_table = old_table;
92 new_table.labels.push_back(kSampleLabel2);
93 EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table,
94 new_table));
95 old_table.labels.push_back(kSampleLabel3);
96 EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table,
97 new_table));
98 new_table.labels.clear();
99 EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table,
100 new_table));
101 new_table.labels.push_back(kSampleLabel2);
102 old_table.labels.clear();
103 EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table,
104 new_table));
105
106 new_table = old_table;
107 new_table.annotations.push_back(kSampleAnnotation2);
108 EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table,
109 new_table));
110 old_table.annotations.push_back(kSampleAnnotation3);
111 EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table,
112 new_table));
113 new_table.annotations.clear();
114 EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table,
115 new_table));
116 new_table.annotations.push_back(kSampleAnnotation2);
117 old_table.annotations.clear();
118 EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table,
119 new_table));
120 }
121
122 } // namespace input_method
123 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/input_method/candidate_window_view.h ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698