Chromium Code Reviews| Index: services/prediction/prediction_apptests.cc |
| diff --git a/services/prediction/prediction_apptests.cc b/services/prediction/prediction_apptests.cc |
| index effaebbe15cc854f35601325f102b13f007e813a..dde303f73249e8ec0d93c534420a75137f98342c 100644 |
| --- a/services/prediction/prediction_apptests.cc |
| +++ b/services/prediction/prediction_apptests.cc |
| @@ -30,21 +30,13 @@ class PredictionApptest : public mojo::test::ApplicationTestBase { |
| &prediction_); |
| } |
| - void SetSettingsClient(bool correction, |
| - bool offensive, |
| - bool space_aware_gesture) { |
| - SettingsPtr settings = Settings::New(); |
| - settings->correction_enabled = correction; |
| - settings->block_potentially_offensive = offensive; |
| - settings->space_aware_gesture_enabled = space_aware_gesture; |
| - prediction_->SetSettings(settings.Pass()); |
| - } |
| - |
| std::vector<std::string> GetPredictionListClient( |
| - const mojo::Array<mojo::String>& prev_words, |
| + mojo::Array<mojo::String>& prev_words, |
| + mojo::Array<bool>& beginning_of_sentence, |
| const mojo::String& cur_word) { |
| PredictionInfoPtr prediction_info = PredictionInfo::New(); |
| - prediction_info->previous_words = prev_words.Clone().Pass(); |
| + prediction_info->previous_words = prev_words.Pass(); |
| + prediction_info->are_beginning_of_sentence = beginning_of_sentence.Pass(); |
| prediction_info->current_word = cur_word; |
| std::vector<std::string> prediction_list; |
| @@ -61,12 +53,75 @@ class PredictionApptest : public mojo::test::ApplicationTestBase { |
| DISALLOW_COPY_AND_ASSIGN(PredictionApptest); |
| }; |
| -TEST_F(PredictionApptest, PredictCat) { |
| - SetSettingsClient(true, true, true); |
| - mojo::Array<mojo::String> prev_words; |
| - prev_words.push_back("dog"); |
| - std::string prediction_cat = GetPredictionListClient(prev_words, "d")[0]; |
| - EXPECT_EQ(prediction_cat, "cat"); |
| +TEST_F(PredictionApptest, CurrentSpellcheck) { |
| + mojo::Array<mojo::String> prev_words = mojo::Array<mojo::String>::New(0); |
| + mojo::Array<bool> beginning_of_sentence = mojo::Array<bool>::New(0); |
| + std::string prediction = |
| + GetPredictionListClient(prev_words, beginning_of_sentence, "tgis")[0]; |
| + EXPECT_EQ(prediction, "this"); |
| + |
| + mojo::Array<mojo::String> prev_words1 = mojo::Array<mojo::String>::New(0); |
| + mojo::Array<bool> beginning_of_sentence1 = mojo::Array<bool>::New(0); |
| + std::string prediction1 = |
| + GetPredictionListClient(prev_words1, beginning_of_sentence1, "aplle")[0]; |
| + EXPECT_EQ(prediction1, "Apple"); |
| +} |
| + |
| +TEST_F(PredictionApptest, CurrentSuggest) { |
| + mojo::Array<mojo::String> prev_words = mojo::Array<mojo::String>::New(0); |
| + mojo::Array<bool> beginning_of_sentence = mojo::Array<bool>::New(0); |
| + std::string prediction = |
| + GetPredictionListClient(prev_words, beginning_of_sentence, "peac")[0]; |
| + EXPECT_EQ(prediction, "peace"); |
| + |
| + mojo::Array<mojo::String> prev_words1 = mojo::Array<mojo::String>::New(0); |
| + mojo::Array<bool> beginning_of_sentence1 = mojo::Array<bool>::New(0); |
| + std::string prediction1 = |
| + GetPredictionListClient(prev_words1, beginning_of_sentence1, "fil")[0]; |
| + EXPECT_EQ(prediction1, "film"); |
| + |
| + mojo::Array<mojo::String> prev_words2 = mojo::Array<mojo::String>::New(0); |
| + mojo::Array<bool> beginning_of_sentence2 = mojo::Array<bool>::New(0); |
| + std::string prediction2 = |
| + GetPredictionListClient(prev_words2, beginning_of_sentence2, "entert")[0]; |
| + EXPECT_EQ(prediction2, "entertainment"); |
| +} |
| + |
| +TEST_F(PredictionApptest, CurrentSuggestCont) { |
| + mojo::Array<mojo::String> prev_words = mojo::Array<mojo::String>::New(0); |
| + mojo::Array<bool> beginning_of_sentence = mojo::Array<bool>::New(0); |
| + std::string prediction = |
| + GetPredictionListClient(prev_words, beginning_of_sentence, "a")[0]; |
| + EXPECT_EQ(prediction, "and"); |
| + |
| + mojo::Array<mojo::String> prev_words1 = mojo::Array<mojo::String>::New(0); |
| + mojo::Array<bool> beginning_of_sentence1 = mojo::Array<bool>::New(0); |
| + std::string prediction1 = |
| + GetPredictionListClient(prev_words1, beginning_of_sentence1, "ab")[0]; |
| + EXPECT_EQ(prediction1, "an"); |
| +} |
| + |
| +TEST_F(PredictionApptest, CurrentSuggestUp) { |
| + mojo::Array<mojo::String> prev_words = mojo::Array<mojo::String>::New(0); |
| + mojo::Array<bool> beginning_of_sentence = mojo::Array<bool>::New(0); |
| + std::string prediction = |
| + GetPredictionListClient(prev_words, beginning_of_sentence, "Beau")[0]; |
| + EXPECT_EQ(prediction, "Beautiful"); |
| + |
| + mojo::Array<mojo::String> prev_words1 = mojo::Array<mojo::String>::New(0); |
| + mojo::Array<bool> beginning_of_sentence1 = mojo::Array<bool>::New(0); |
| + std::string prediction1 = |
| + GetPredictionListClient(prev_words1, beginning_of_sentence1, "THis")[0]; |
| + EXPECT_EQ(prediction1, "This"); |
| +} |
| + |
| +TEST_F(PredictionApptest, CurrentNoSuggest) { |
| + mojo::Array<mojo::String> prev_words = mojo::Array<mojo::String>::New(0); |
| + mojo::Array<bool> beginning_of_sentence = mojo::Array<bool>::New(0); |
| + std::string prediction = GetPredictionListClient( |
| + prev_words, beginning_of_sentence, |
| + "hjlahflgfagfdafaffgruhgadfhjklghadflkghjalkdfjkldfhrshrtshtsrhkra")[0]; |
| + EXPECT_EQ(prediction, "hula JFK"); |
|
APW
2015/07/23 20:11:28
Please add a test where the previous word is This
riajiang
2015/07/31 02:13:04
Added. Suggestions are empty tho since there's no
|
| } |
| } // namespace prediction |