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

Unified Diff: chrome/browser/chromeos/input_method/candidate_window_view_unittest.cc

Issue 8505051: Support mozc suggest window on ChromeOS. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Apply latest mozc repository. 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 side-by-side diff with in-line comments
Download patch
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
index f3e62f92b724adb6908de8176886888a35fd3224..613294e69949261935b38696d2bbe41f8c3b959d 100644
--- a/chrome/browser/chromeos/input_method/candidate_window_view_unittest.cc
+++ b/chrome/browser/chromeos/input_method/candidate_window_view_unittest.cc
@@ -4,11 +4,61 @@
#include "chrome/browser/chromeos/input_method/candidate_window_view.h"
+#include <string>
Yusuke Sato 2011/11/30 13:38:20 nit: space between line 7&8
Seigo Nonaka 2011/12/01 07:10:01 Done.
#include "testing/gtest/include/gtest/gtest.h"
namespace chromeos {
namespace input_method {
+namespace {
+void ClearInputMethodLookupTable(InputMethodLookupTable* table) {
+ table->visible = false;
+ table->cursor_absolute_index = 0;
+ table->page_size = 10;
+ table->candidates.clear();
+ table->orientation = InputMethodLookupTable::kVertical;
+ table->labels.clear();
+ table->annotations.clear();
+ table->mozc_candidates.Clear();
+}
+
+void InitializeMozcCandidates(InputMethodLookupTable* table) {
+ table->mozc_candidates.Clear();
+ table->mozc_candidates.set_position(0);
+ table->mozc_candidates.set_size(0);
+}
+
+void SetCaretRectIntoMozcCandidates(
+ InputMethodLookupTable* table,
+ mozc::commands::Candidates::CandidateWindowLocation location,
+ int x,
+ int y,
+ int width,
+ int height) {
+ table->mozc_candidates.set_window_location(location);
+ mozc::commands::Rectangle *rect =
+ table->mozc_candidates.mutable_composition_rectangle();
+ rect->set_x(x);
+ rect->set_y(y);
+ rect->set_width(width);
+ rect->set_height(height);
+}
+
+void AppendCandidateIntoMozcCandidates(InputMethodLookupTable* table,
+ std::string value) {
+ mozc::commands::Candidates::Candidate *candidate =
+ table->mozc_candidates.add_candidate();
+
+ int current_entry_count = table->mozc_candidates.candidate_size();
+ candidate->set_index(current_entry_count);
+ candidate->set_value(value);
+ candidate->set_id(current_entry_count);
+ candidate->set_information_id(current_entry_count);
+
+
+}
+} // namespace
+
TEST(CandidateWindowViewTest, ShouldUpdateCandidateViewsTest) {
// This test verifies the process of judging update lookup-table or not.
// This judgement is handled by ShouldUpdateCandidateViews, which returns true
@@ -28,6 +78,9 @@ TEST(CandidateWindowViewTest, ShouldUpdateCandidateViewsTest) {
InputMethodLookupTable old_table;
InputMethodLookupTable new_table;
+ ClearInputMethodLookupTable(&old_table);
+ ClearInputMethodLookupTable(&new_table);
+
old_table.visible = true;
old_table.cursor_absolute_index = 0;
old_table.page_size = 1;
@@ -119,5 +172,160 @@ TEST(CandidateWindowViewTest, ShouldUpdateCandidateViewsTest) {
new_table));
}
+TEST(CandidateWindowViewTest, MozcSuggestWindowShouldUpdateTest) {
+ // This test verifies the process of judging update lookup-table or not with
Yusuke Sato 2011/11/30 13:38:20 I couldn't parse this sentence..
Seigo Nonaka 2011/12/01 07:10:01 Done.
+ // mozc candidates.
+ const char* kSampleCandidate1 = "Sample Candidate 1";
+ const char* kSampleCandidate2 = "Sample Candidate 2";
+
+ const int kCaretPositionX1 = 10;
+ const int kCaretPositionY1 = 20;
+ const int kCaretPositionWidth1 = 30;
+ const int kCaretPositionHeight1 = 40;
+
+ const int kCaretPositionX2 = 15;
+ const int kCaretPositionY2 = 25;
+ const int kCaretPositionWidth2 = 35;
+ const int kCaretPositionHeight2 = 45;
+
+ InputMethodLookupTable old_table;
+ InputMethodLookupTable new_table;
+
+ // State chagne from non-Mozc candidate to Mozc candidate.
Yusuke Sato 2011/11/30 13:38:20 be consistent: Mozc or mozc. You're using the lat
Seigo Nonaka 2011/12/01 07:10:01 Done.
+ ClearInputMethodLookupTable(&old_table);
+ ClearInputMethodLookupTable(&new_table);
+
+ old_table.candidates.push_back(kSampleCandidate1);
+ InitializeMozcCandidates(&new_table);
+ AppendCandidateIntoMozcCandidates(&new_table, kSampleCandidate1);
+ SetCaretRectIntoMozcCandidates(&new_table,
+ mozc::commands::Candidates::CARET,
+ kCaretPositionX1,
+ kCaretPositionY1,
+ kCaretPositionWidth1,
+ kCaretPositionHeight1);
+
+ EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table,
+ new_table));
+
+ // State change from Mozc candidate to non-Mozc candidate
+ ClearInputMethodLookupTable(&old_table);
+ ClearInputMethodLookupTable(&new_table);
+
+ InitializeMozcCandidates(&old_table);
+ AppendCandidateIntoMozcCandidates(&old_table, kSampleCandidate1);
+ SetCaretRectIntoMozcCandidates(&old_table,
+ mozc::commands::Candidates::CARET,
+ kCaretPositionX1,
+ kCaretPositionY1,
+ kCaretPositionWidth1,
+ kCaretPositionHeight1);
+
+ new_table.candidates.push_back(kSampleCandidate1);
+
+ EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table,
+ new_table));
+
+ // State change from Mozc candidate to Mozc candidate
+
+ // No change
+ ClearInputMethodLookupTable(&old_table);
+ ClearInputMethodLookupTable(&new_table);
+
+ InitializeMozcCandidates(&old_table);
+ AppendCandidateIntoMozcCandidates(&old_table, kSampleCandidate1);
+ SetCaretRectIntoMozcCandidates(&old_table,
+ mozc::commands::Candidates::CARET,
+ kCaretPositionX1,
+ kCaretPositionY1,
+ kCaretPositionWidth1,
+ kCaretPositionHeight1);
+
+ InitializeMozcCandidates(&new_table);
+ AppendCandidateIntoMozcCandidates(&new_table, kSampleCandidate1);
+ SetCaretRectIntoMozcCandidates(&new_table,
+ mozc::commands::Candidates::CARET,
+ kCaretPositionX1,
+ kCaretPositionY1,
+ kCaretPositionWidth1,
+ kCaretPositionHeight1);
+
+ EXPECT_FALSE(CandidateWindowView::ShouldUpdateCandidateViews(old_table,
+ new_table));
+ // Position change only
+ ClearInputMethodLookupTable(&old_table);
+ ClearInputMethodLookupTable(&new_table);
+
+ InitializeMozcCandidates(&old_table);
+ AppendCandidateIntoMozcCandidates(&old_table, kSampleCandidate1);
+ SetCaretRectIntoMozcCandidates(&old_table,
+ mozc::commands::Candidates::CARET,
+ kCaretPositionX1,
+ kCaretPositionY1,
+ kCaretPositionWidth1,
+ kCaretPositionHeight1);
+
+ InitializeMozcCandidates(&new_table);
+ AppendCandidateIntoMozcCandidates(&new_table, kSampleCandidate1);
+ SetCaretRectIntoMozcCandidates(&new_table,
+ mozc::commands::Candidates::CARET,
+ kCaretPositionX2,
+ kCaretPositionY2,
+ kCaretPositionWidth2,
+ kCaretPositionHeight2);
+
+ EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table,
+ new_table));
+ // Candidate contents only
+ ClearInputMethodLookupTable(&old_table);
+ ClearInputMethodLookupTable(&new_table);
+
+ InitializeMozcCandidates(&old_table);
+ AppendCandidateIntoMozcCandidates(&old_table, kSampleCandidate1);
+ SetCaretRectIntoMozcCandidates(&old_table,
+ mozc::commands::Candidates::CARET,
+ kCaretPositionX1,
+ kCaretPositionY1,
+ kCaretPositionWidth1,
+ kCaretPositionHeight1);
+
+ InitializeMozcCandidates(&new_table);
+ AppendCandidateIntoMozcCandidates(&new_table, kSampleCandidate2);
+ SetCaretRectIntoMozcCandidates(&new_table,
+ mozc::commands::Candidates::CARET,
+ kCaretPositionX1,
+ kCaretPositionY1,
+ kCaretPositionWidth1,
+ kCaretPositionHeight1);
+
+ EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table,
+ new_table));
+
+ // Both candidate and position
+ ClearInputMethodLookupTable(&old_table);
+ ClearInputMethodLookupTable(&new_table);
+
+ InitializeMozcCandidates(&old_table);
+ AppendCandidateIntoMozcCandidates(&old_table, kSampleCandidate1);
+ SetCaretRectIntoMozcCandidates(&old_table,
+ mozc::commands::Candidates::CARET,
+ kCaretPositionX1,
+ kCaretPositionY1,
+ kCaretPositionWidth1,
+ kCaretPositionHeight1);
+
+ InitializeMozcCandidates(&new_table);
+ AppendCandidateIntoMozcCandidates(&new_table, kSampleCandidate2);
+ SetCaretRectIntoMozcCandidates(&new_table,
+ mozc::commands::Candidates::CARET,
+ kCaretPositionX2,
+ kCaretPositionY2,
+ kCaretPositionWidth2,
+ kCaretPositionHeight2);
+
+ EXPECT_TRUE(CandidateWindowView::ShouldUpdateCandidateViews(old_table,
+ new_table));
+}
+
} // namespace input_method
} // namespace chromeos

Powered by Google App Engine
This is Rietveld 408576698