OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "chrome/browser/ui/app_list/search/people/people_provider.h" | 5 #include "chrome/browser/ui/app_list/search/people/people_provider.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 |
| 9 #include <memory> |
8 #include <string> | 10 #include <string> |
9 #include <utility> | 11 #include <utility> |
10 | 12 |
11 #include "base/bind.h" | 13 #include "base/bind.h" |
12 #include "base/command_line.h" | 14 #include "base/command_line.h" |
13 #include "base/macros.h" | 15 #include "base/macros.h" |
14 #include "base/memory/scoped_ptr.h" | |
15 #include "base/run_loop.h" | 16 #include "base/run_loop.h" |
16 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
17 #include "chrome/browser/profiles/profile_manager.h" | 18 #include "chrome/browser/profiles/profile_manager.h" |
18 #include "chrome/browser/ui/app_list/test/test_app_list_controller_delegate.h" | 19 #include "chrome/browser/ui/app_list/test/test_app_list_controller_delegate.h" |
19 #include "chrome/common/chrome_switches.h" | 20 #include "chrome/common/chrome_switches.h" |
20 #include "chrome/test/base/in_process_browser_test.h" | 21 #include "chrome/test/base/in_process_browser_test.h" |
21 #include "content/public/browser/browser_thread.h" | 22 #include "content/public/browser/browser_thread.h" |
22 #include "net/test/embedded_test_server/embedded_test_server.h" | 23 #include "net/test/embedded_test_server/embedded_test_server.h" |
23 #include "net/test/embedded_test_server/http_request.h" | 24 #include "net/test/embedded_test_server/http_request.h" |
24 #include "net/test/embedded_test_server/http_response.h" | 25 #include "net/test/embedded_test_server/http_response.h" |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 if (!results.empty()) | 213 if (!results.empty()) |
213 results += ','; | 214 results += ','; |
214 results += base::UTF16ToUTF8((*it)->title()); | 215 results += base::UTF16ToUTF8((*it)->title()); |
215 } | 216 } |
216 return results; | 217 return results; |
217 } | 218 } |
218 | 219 |
219 PeopleProvider* people_provider() { return people_provider_.get(); } | 220 PeopleProvider* people_provider() { return people_provider_.get(); } |
220 | 221 |
221 private: | 222 private: |
222 scoped_ptr<HttpResponse> HandleRequest(const HttpRequest& request) { | 223 std::unique_ptr<HttpResponse> HandleRequest(const HttpRequest& request) { |
223 scoped_ptr<BasicHttpResponse> response(new BasicHttpResponse); | 224 std::unique_ptr<BasicHttpResponse> response(new BasicHttpResponse); |
224 response->set_code(net::HTTP_OK); | 225 response->set_code(net::HTTP_OK); |
225 response->set_content(mock_server_response_); | 226 response->set_content(mock_server_response_); |
226 | 227 |
227 return std::move(response); | 228 return std::move(response); |
228 } | 229 } |
229 | 230 |
230 void OnSearchResultsFetched() { | 231 void OnSearchResultsFetched() { |
231 if (run_loop_) | 232 if (run_loop_) |
232 run_loop_->Quit(); | 233 run_loop_->Quit(); |
233 } | 234 } |
234 | 235 |
235 scoped_ptr<base::RunLoop> run_loop_; | 236 std::unique_ptr<base::RunLoop> run_loop_; |
236 | 237 |
237 std::string mock_server_response_; | 238 std::string mock_server_response_; |
238 | 239 |
239 scoped_ptr<PeopleProvider> people_provider_; | 240 std::unique_ptr<PeopleProvider> people_provider_; |
240 ::test::TestAppListControllerDelegate test_controller_; | 241 ::test::TestAppListControllerDelegate test_controller_; |
241 | 242 |
242 DISALLOW_COPY_AND_ASSIGN(PeopleProviderTest); | 243 DISALLOW_COPY_AND_ASSIGN(PeopleProviderTest); |
243 }; | 244 }; |
244 | 245 |
245 IN_PROC_BROWSER_TEST_F(PeopleProviderTest, Basic) { | 246 IN_PROC_BROWSER_TEST_F(PeopleProviderTest, Basic) { |
246 struct { | 247 struct { |
247 const char* query; | 248 const char* query; |
248 const char* mock_server_response; | 249 const char* mock_server_response; |
249 const char* expected_results_content; | 250 const char* expected_results_content; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 } | 283 } |
283 | 284 |
284 IN_PROC_BROWSER_TEST_F(PeopleProviderTest, NoSearchForShortQueries) { | 285 IN_PROC_BROWSER_TEST_F(PeopleProviderTest, NoSearchForShortQueries) { |
285 EXPECT_EQ("", RunQuery("f", kOneResult)); | 286 EXPECT_EQ("", RunQuery("f", kOneResult)); |
286 EXPECT_EQ("", RunQuery("fi", kOneResult)); | 287 EXPECT_EQ("", RunQuery("fi", kOneResult)); |
287 EXPECT_EQ("first person", RunQuery("fir", kOneResult)); | 288 EXPECT_EQ("first person", RunQuery("fir", kOneResult)); |
288 } | 289 } |
289 | 290 |
290 } // namespace test | 291 } // namespace test |
291 } // namespace app_list | 292 } // namespace app_list |
OLD | NEW |