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 #include "chrome/browser/android/contextualsearch/contextual_search_delegate.h" | 5 #include "chrome/browser/android/contextualsearch/contextual_search_delegate.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "chrome/browser/android/contextualsearch/contextual_search_context.h" | 10 #include "chrome/browser/android/contextualsearch/contextual_search_context.h" |
11 #include "components/search_engines/template_url_service.h" | 11 #include "components/search_engines/template_url_service.h" |
12 #include "net/url_request/test_url_fetcher_factory.h" | 12 #include "net/url_request/test_url_fetcher_factory.h" |
13 #include "net/url_request/url_request_test_util.h" | 13 #include "net/url_request/url_request_test_util.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
15 | 15 |
16 namespace { | 16 namespace { |
17 | 17 |
18 const char kSomeSpecificBasePage[] = "http://some.specific.host.name.com"; | 18 const char kSomeSpecificBasePage[] = "http://some.specific.host.name.com"; |
19 | 19 |
20 } // namespace | 20 } // namespace |
21 | 21 |
22 class ContextualSearchDelegateTest : public testing::Test { | 22 class ContextualSearchDelegateTest : public testing::Test { |
23 public: | 23 public: |
24 ContextualSearchDelegateTest() {} | 24 ContextualSearchDelegateTest() {} |
25 ~ContextualSearchDelegateTest() override {} | 25 ~ContextualSearchDelegateTest() override {} |
26 | 26 |
27 protected: | 27 protected: |
28 void SetUp() override { | 28 void SetUp() override { |
29 request_context_ = new net::TestURLRequestContextGetter( | 29 request_context_ = |
30 io_message_loop_.message_loop_proxy()); | 30 new net::TestURLRequestContextGetter(io_message_loop_.task_runner()); |
31 template_url_service_.reset(CreateTemplateURLService()); | 31 template_url_service_.reset(CreateTemplateURLService()); |
32 delegate_.reset(new ContextualSearchDelegate( | 32 delegate_.reset(new ContextualSearchDelegate( |
33 request_context_.get(), template_url_service_.get(), | 33 request_context_.get(), template_url_service_.get(), |
34 base::Bind( | 34 base::Bind( |
35 &ContextualSearchDelegateTest::recordSearchTermResolutionResponse, | 35 &ContextualSearchDelegateTest::recordSearchTermResolutionResponse, |
36 base::Unretained(this)), | 36 base::Unretained(this)), |
37 base::Bind(&ContextualSearchDelegateTest::recordSurroundingText, | 37 base::Bind(&ContextualSearchDelegateTest::recordSurroundingText, |
38 base::Unretained(this)), | 38 base::Unretained(this)), |
39 base::Bind(&ContextualSearchDelegateTest::recordIcingSelectionAvailable, | 39 base::Bind(&ContextualSearchDelegateTest::recordIcingSelectionAvailable, |
40 base::Unretained(this)))); | 40 base::Unretained(this)))); |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 std::string alternate_term; | 318 std::string alternate_term; |
319 std::string prevent_preload; | 319 std::string prevent_preload; |
320 delegate_->DecodeSearchTermsFromJsonResponse(json_with_escape, &search_term, | 320 delegate_->DecodeSearchTermsFromJsonResponse(json_with_escape, &search_term, |
321 &display_text, &alternate_term, | 321 &display_text, &alternate_term, |
322 &prevent_preload); | 322 &prevent_preload); |
323 EXPECT_EQ("obama", search_term); | 323 EXPECT_EQ("obama", search_term); |
324 EXPECT_EQ("Barack Obama", display_text); | 324 EXPECT_EQ("Barack Obama", display_text); |
325 EXPECT_EQ("barack obama", alternate_term); | 325 EXPECT_EQ("barack obama", alternate_term); |
326 EXPECT_EQ("", prevent_preload); | 326 EXPECT_EQ("", prevent_preload); |
327 } | 327 } |
OLD | NEW |