OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 class TemplateURLFetcherTest : public testing::Test { | 26 class TemplateURLFetcherTest : public testing::Test { |
27 public: | 27 public: |
28 TemplateURLFetcherTest(); | 28 TemplateURLFetcherTest(); |
29 | 29 |
30 void SetUp() override { | 30 void SetUp() override { |
31 TestingProfile* profile = test_util_.profile(); | 31 TestingProfile* profile = test_util_.profile(); |
32 ASSERT_TRUE(profile->GetRequestContext()); | 32 ASSERT_TRUE(profile->GetRequestContext()); |
33 template_url_fetcher_.reset(new TemplateURLFetcher( | 33 template_url_fetcher_.reset(new TemplateURLFetcher( |
34 test_util_.model(), profile->GetRequestContext())); | 34 test_util_.model(), profile->GetRequestContext())); |
35 | 35 |
36 ASSERT_TRUE(test_server_.InitializeAndWaitUntilReady()); | 36 ASSERT_TRUE(test_server_.Start()); |
37 } | 37 } |
38 | 38 |
39 void TearDown() override { | 39 void TearDown() override { |
40 ASSERT_TRUE(test_server_.ShutdownAndWaitUntilComplete()); | 40 ASSERT_TRUE(test_server_.ShutdownAndWaitUntilComplete()); |
41 } | 41 } |
42 | 42 |
43 // Called when the callback is destroyed. | 43 // Called when the callback is destroyed. |
44 void DestroyedCallback(); | 44 void DestroyedCallback(); |
45 | 45 |
46 // TemplateURLFetcherCallbacks implementation. (Although not derived from | 46 // TemplateURLFetcherCallbacks implementation. (Although not derived from |
(...skipping 18 matching lines...) Expand all Loading... |
65 const TemplateURL* last_callback_template_url() const { | 65 const TemplateURL* last_callback_template_url() const { |
66 return last_callback_template_url_.get(); | 66 return last_callback_template_url_.get(); |
67 } | 67 } |
68 int callbacks_destroyed() const { return callbacks_destroyed_; } | 68 int callbacks_destroyed() const { return callbacks_destroyed_; } |
69 int add_provider_called() const { return add_provider_called_; } | 69 int add_provider_called() const { return add_provider_called_; } |
70 | 70 |
71 private: | 71 private: |
72 content::TestBrowserThreadBundle thread_bundle_; // To set up BrowserThreads. | 72 content::TestBrowserThreadBundle thread_bundle_; // To set up BrowserThreads. |
73 TemplateURLServiceTestUtil test_util_; | 73 TemplateURLServiceTestUtil test_util_; |
74 scoped_ptr<TemplateURLFetcher> template_url_fetcher_; | 74 scoped_ptr<TemplateURLFetcher> template_url_fetcher_; |
75 net::test_server::EmbeddedTestServer test_server_; | 75 net::EmbeddedTestServer test_server_; |
76 | 76 |
77 // The last TemplateURL to come from a callback. | 77 // The last TemplateURL to come from a callback. |
78 scoped_ptr<TemplateURL> last_callback_template_url_; | 78 scoped_ptr<TemplateURL> last_callback_template_url_; |
79 | 79 |
80 // How many TemplateURLFetcherTestCallbacks have been destructed. | 80 // How many TemplateURLFetcherTestCallbacks have been destructed. |
81 int callbacks_destroyed_; | 81 int callbacks_destroyed_; |
82 | 82 |
83 // How many times ConfirmAddSearchProvider has been called. | 83 // How many times ConfirmAddSearchProvider has been called. |
84 int add_provider_called_; | 84 int add_provider_called_; |
85 | 85 |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 | 335 |
336 std::string osdd_file_name("unicode_open_search.xml"); | 336 std::string osdd_file_name("unicode_open_search.xml"); |
337 StartDownload(keyword, osdd_file_name, | 337 StartDownload(keyword, osdd_file_name, |
338 TemplateURLFetcher::AUTODETECTED_PROVIDER, true); | 338 TemplateURLFetcher::AUTODETECTED_PROVIDER, true); |
339 WaitForDownloadToFinish(); | 339 WaitForDownloadToFinish(); |
340 const TemplateURL* t_url = | 340 const TemplateURL* t_url = |
341 test_util()->model()->GetTemplateURLForKeyword(keyword); | 341 test_util()->model()->GetTemplateURLForKeyword(keyword); |
342 EXPECT_EQ(base::UTF8ToUTF16("\xd1\x82\xd0\xb5\xd1\x81\xd1\x82"), | 342 EXPECT_EQ(base::UTF8ToUTF16("\xd1\x82\xd0\xb5\xd1\x81\xd1\x82"), |
343 t_url->short_name()); | 343 t_url->short_name()); |
344 } | 344 } |
OLD | NEW |