Chromium Code Reviews| Index: chrome/browser/chromeos/input_method/candidate_window_view_unittest.cc |
| diff --git a/chrome/browser/chromeos/input_method/candidate_window_view_unittest.cc b/chrome/browser/chromeos/input_method/candidate_window_view_unittest.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..baf35b3460277324d014403789ae34400cda5bef |
| --- /dev/null |
| +++ b/chrome/browser/chromeos/input_method/candidate_window_view_unittest.cc |
| @@ -0,0 +1,120 @@ |
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/chromeos/input_method/candidate_window_view.h" |
| + |
| +#include "testing/gtest/include/gtest/gtest.h" |
| + |
| +namespace chromeos { |
| +namespace input_method { |
| + |
| +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.
|
| + const char* kSampleCandidate1 = "Sample Candidate 1"; |
| + const char* kSampleCandidate2 = "Sample Candidate 2"; |
| + const char* kSampleCandidate3 = "Sample Candidate 3"; |
| + |
| + const char* kSampleAnnotation1 = "Sample Annotation 1"; |
| + const char* kSampleAnnotation2 = "Sample Annotation 2"; |
| + const char* kSampleAnnotation3 = "Sample Annotation 3"; |
| + |
| + const char* kSampleLabel1 = "Sample Label 1"; |
| + const char* kSampleLabel2 = "Sample Label 2"; |
| + const char* kSampleLabel3 = "Sample Label 3"; |
| + |
| + InputMethodLookupTable old_table; |
| + InputMethodLookupTable new_table; |
| + |
| + old_table.visible = true; |
| + old_table.cursor_absolute_index = 0; |
| + old_table.page_size = 1; |
| + old_table.candidates.clear(); |
| + old_table.orientation = InputMethodLookupTable::kVertical; |
| + old_table.labels.clear(); |
| + old_table.annotations.clear(); |
| + |
| + new_table = old_table; |
| + |
| + EXPECT_FALSE(CandidateWindowView::ShouldUpdateCandidateViews(old_table, |
| + new_table)); |
| + |
| + new_table.visible = false; |
| + // Visibility would be ignored. |
| + EXPECT_FALSE(CandidateWindowView::ShouldUpdateCandidateViews(old_table, |
| + new_table)); |
| + new_table = old_table; |
| + new_table.candidates.push_back(kSampleCandidate1); |
| + old_table.candidates.push_back(kSampleCandidate1); |
| + EXPECT_FALSE(CandidateWindowView::ShouldUpdateCandidateViews(old_table, |
| + new_table)); |
| + new_table.labels.push_back(kSampleLabel1); |
| + old_table.labels.push_back(kSampleLabel1); |
| + EXPECT_FALSE(CandidateWindowView::ShouldUpdateCandidateViews(old_table, |
| + new_table)); |
| + new_table.annotations.push_back(kSampleAnnotation1); |
| + old_table.annotations.push_back(kSampleAnnotation1); |
| + EXPECT_FALSE(CandidateWindowView::ShouldUpdateCandidateViews(old_table, |
| + new_table)); |
| + |
| + new_table.cursor_absolute_index = 1; |
| + EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table, |
| + new_table)); |
| + new_table = old_table; |
| + |
| + new_table.page_size = 2; |
| + EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table, |
| + new_table)); |
| + new_table = old_table; |
| + |
| + new_table.orientation = InputMethodLookupTable::kHorizontal; |
| + EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table, |
| + new_table)); |
| + |
| + new_table = old_table; |
| + new_table.candidates.push_back(kSampleCandidate2); |
| + EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table, |
| + new_table)); |
| + old_table.candidates.push_back(kSampleCandidate3); |
| + EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table, |
| + new_table)); |
| + new_table.candidates.clear(); |
| + EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table, |
| + new_table)); |
| + new_table.candidates.push_back(kSampleCandidate2); |
| + old_table.candidates.clear(); |
| + EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table, |
| + new_table)); |
| + |
| + new_table = old_table; |
| + new_table.labels.push_back(kSampleLabel2); |
| + EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table, |
| + new_table)); |
| + old_table.labels.push_back(kSampleLabel3); |
| + EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table, |
| + new_table)); |
| + new_table.labels.clear(); |
| + EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table, |
| + new_table)); |
| + new_table.labels.push_back(kSampleLabel2); |
| + old_table.labels.clear(); |
| + EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table, |
| + new_table)); |
| + |
| + new_table = old_table; |
| + new_table.annotations.push_back(kSampleAnnotation2); |
| + EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table, |
| + new_table)); |
| + old_table.annotations.push_back(kSampleAnnotation3); |
| + EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table, |
| + new_table)); |
| + new_table.annotations.clear(); |
| + EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table, |
| + new_table)); |
| + new_table.annotations.push_back(kSampleAnnotation2); |
| + old_table.annotations.clear(); |
| + EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table, |
| + new_table)); |
| +} |
| + |
| +} // namespace input_method |
| +} // namespace chromeos |