Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(313)

Side by Side Diff: chrome/browser/search_engines/template_url_fetcher_unittest.cc

Issue 17127002: Correctly integrate StoragePartition into TestingProfile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix InstantNTP test. Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "base/file_util.h" 5 #include "base/file_util.h"
6 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/search_engines/template_url.h" 10 #include "chrome/browser/search_engines/template_url.h"
11 #include "chrome/browser/search_engines/template_url_fetcher.h" 11 #include "chrome/browser/search_engines/template_url_fetcher.h"
12 #include "chrome/browser/search_engines/template_url_fetcher_callbacks.h" 12 #include "chrome/browser/search_engines/template_url_fetcher_callbacks.h"
13 #include "chrome/browser/search_engines/template_url_fetcher_factory.h" 13 #include "chrome/browser/search_engines/template_url_fetcher_factory.h"
14 #include "chrome/browser/search_engines/template_url_service.h" 14 #include "chrome/browser/search_engines/template_url_service.h"
15 #include "chrome/browser/search_engines/template_url_service_test_util.h" 15 #include "chrome/browser/search_engines/template_url_service_test_util.h"
16 #include "chrome/common/chrome_paths.h" 16 #include "chrome/common/chrome_paths.h"
17 #include "chrome/test/base/testing_profile.h" 17 #include "chrome/test/base/testing_profile.h"
18 #include "content/public/browser/browser_thread.h"
18 #include "net/test/embedded_test_server/embedded_test_server.h" 19 #include "net/test/embedded_test_server/embedded_test_server.h"
19 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
20 #include "url/gurl.h" 21 #include "url/gurl.h"
21 22
22 class TemplateURLFetcherTest; 23 class TemplateURLFetcherTest;
23 24
24 // Handles callbacks from TemplateURLFetcher. 25 // Handles callbacks from TemplateURLFetcher.
25 class TemplateURLFetcherTestCallbacks : public TemplateURLFetcherCallbacks { 26 class TemplateURLFetcherTestCallbacks : public TemplateURLFetcherCallbacks {
26 public: 27 public:
27 explicit TemplateURLFetcherTestCallbacks(TemplateURLFetcherTest* test) 28 explicit TemplateURLFetcherTestCallbacks(TemplateURLFetcherTest* test)
(...skipping 11 matching lines...) Expand all
39 DISALLOW_COPY_AND_ASSIGN(TemplateURLFetcherTestCallbacks); 40 DISALLOW_COPY_AND_ASSIGN(TemplateURLFetcherTestCallbacks);
40 }; 41 };
41 42
42 // Basic set-up for TemplateURLFetcher tests. 43 // Basic set-up for TemplateURLFetcher tests.
43 class TemplateURLFetcherTest : public testing::Test { 44 class TemplateURLFetcherTest : public testing::Test {
44 public: 45 public:
45 TemplateURLFetcherTest(); 46 TemplateURLFetcherTest();
46 47
47 virtual void SetUp() OVERRIDE { 48 virtual void SetUp() OVERRIDE {
48 test_util_.SetUp(); 49 test_util_.SetUp();
49 test_util_.StartIOThread();
50 TestingProfile* profile = test_util_.profile(); 50 TestingProfile* profile = test_util_.profile();
51 ASSERT_TRUE(profile); 51 ASSERT_TRUE(profile);
52 ASSERT_TRUE(TemplateURLFetcherFactory::GetForProfile(profile)); 52 ASSERT_TRUE(TemplateURLFetcherFactory::GetForProfile(profile));
53 53
54 profile->CreateRequestContext();
55 ASSERT_TRUE(profile->GetRequestContext()); 54 ASSERT_TRUE(profile->GetRequestContext());
56 ASSERT_TRUE(test_server_.InitializeAndWaitUntilReady()); 55 ASSERT_TRUE(test_server_.InitializeAndWaitUntilReady());
57 } 56 }
58 57
59 virtual void TearDown() OVERRIDE { 58 virtual void TearDown() OVERRIDE {
60 ASSERT_TRUE(test_server_.ShutdownAndWaitUntilComplete()); 59 ASSERT_TRUE(test_server_.ShutdownAndWaitUntilComplete());
61 test_util_.TearDown(); 60 test_util_.TearDown();
62 } 61 }
63 62
64 // Called by ~TemplateURLFetcherTestCallbacks. 63 // Called by ~TemplateURLFetcherTestCallbacks.
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 StartDownload(keyword, osdd_file_name, 321 StartDownload(keyword, osdd_file_name,
323 TemplateURLFetcher::EXPLICIT_PROVIDER, true); 322 TemplateURLFetcher::EXPLICIT_PROVIDER, true);
324 ASSERT_EQ(0, add_provider_called_); 323 ASSERT_EQ(0, add_provider_called_);
325 ASSERT_EQ(1, callbacks_destroyed_); 324 ASSERT_EQ(1, callbacks_destroyed_);
326 325
327 WaitForDownloadToFinish(); 326 WaitForDownloadToFinish();
328 ASSERT_EQ(1, add_provider_called_); 327 ASSERT_EQ(1, add_provider_called_);
329 ASSERT_EQ(2, callbacks_destroyed_); 328 ASSERT_EQ(2, callbacks_destroyed_);
330 ASSERT_TRUE(last_callback_template_url_.get()); 329 ASSERT_TRUE(last_callback_template_url_.get());
331 } 330 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698