OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // To test, run "out/Debug//mojo_shell mojo:prediction_apptests" | 5 // To test, run "out/Debug//mojo_shell mojo:prediction_apptests" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "mojo/public/cpp/application/application_impl.h" | 9 #include "mojo/public/cpp/application/application_impl.h" |
10 #include "mojo/public/cpp/application/application_test_base.h" | 10 #include "mojo/public/cpp/application/application_test_base.h" |
11 #include "mojo/services/prediction/interfaces/prediction.mojom.h" | 11 #include "mojo/services/prediction/interfaces/prediction.mojom.h" |
12 | 12 |
13 namespace prediction { | 13 namespace prediction { |
14 | 14 |
15 void GetPredictionListAndEnd(std::vector<std::string>* output_list, | 15 void GetPredictionListAndEnd(std::vector<std::string>* output_list, |
16 const mojo::Array<mojo::String>& input_list) { | 16 const mojo::Array<mojo::String>& input_list) { |
17 *output_list = input_list.To<std::vector<std::string>>(); | 17 *output_list = input_list.To<std::vector<std::string>>(); |
18 base::MessageLoop::current()->Quit(); | 18 base::MessageLoop::current()->Quit(); |
19 } | 19 } |
20 | 20 |
21 class PredictionApptest : public mojo::test::ApplicationTestBase { | 21 class PredictionApptest : public mojo::test::ApplicationTestBase { |
22 public: | 22 public: |
23 PredictionApptest() : ApplicationTestBase() {} | 23 PredictionApptest() : ApplicationTestBase() {} |
24 | 24 |
25 ~PredictionApptest() override {} | 25 ~PredictionApptest() override {} |
26 | 26 |
27 void SetUp() override { | 27 void SetUp() override { |
28 mojo::test::ApplicationTestBase::SetUp(); | 28 mojo::test::ApplicationTestBase::SetUp(); |
29 application_impl()->ConnectToService("mojo:prediction_service", | 29 application_impl()->ConnectToServiceDeprecated("mojo:prediction_service", |
30 &prediction_); | 30 &prediction_); |
31 } | 31 } |
32 | 32 |
33 std::vector<std::string> GetPredictionListClient( | 33 std::vector<std::string> GetPredictionListClient( |
34 mojo::Array<PrevWordInfoPtr>& prev_words, | 34 mojo::Array<PrevWordInfoPtr>& prev_words, |
35 const mojo::String& cur_word) { | 35 const mojo::String& cur_word) { |
36 PredictionInfoPtr prediction_info = PredictionInfo::New(); | 36 PredictionInfoPtr prediction_info = PredictionInfo::New(); |
37 prediction_info->previous_words = prev_words.Pass(); | 37 prediction_info->previous_words = prev_words.Pass(); |
38 prediction_info->current_word = cur_word; | 38 prediction_info->current_word = cur_word; |
39 | 39 |
40 std::vector<std::string> prediction_list; | 40 std::vector<std::string> prediction_list; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 PrevWordInfoPtr prev_word = PrevWordInfo::New(); | 117 PrevWordInfoPtr prev_word = PrevWordInfo::New(); |
118 prev_word->word = "This"; | 118 prev_word->word = "This"; |
119 prev_word->is_beginning_of_sentence = true; | 119 prev_word->is_beginning_of_sentence = true; |
120 mojo::Array<PrevWordInfoPtr> prev_words = | 120 mojo::Array<PrevWordInfoPtr> prev_words = |
121 mojo::Array<PrevWordInfoPtr>::New(0); | 121 mojo::Array<PrevWordInfoPtr>::New(0); |
122 prev_words.push_back(prev_word.Pass()); | 122 prev_words.push_back(prev_word.Pass()); |
123 EXPECT_EQ((int)GetPredictionListClient(prev_words, "").size(), 0); | 123 EXPECT_EQ((int)GetPredictionListClient(prev_words, "").size(), 0); |
124 } | 124 } |
125 | 125 |
126 } // namespace prediction | 126 } // namespace prediction |
OLD | NEW |