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

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

Issue 8221027: Make views::Label and views::Link auto-color themselves to be readable over their background colo... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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.h" 7 #include "base/message_loop.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/search_engines/template_url.h" 10 #include "chrome/browser/search_engines/template_url.h"
(...skipping 11 matching lines...) Expand all
22 22
23 // Handles callbacks from TemplateURLFetcher. 23 // Handles callbacks from TemplateURLFetcher.
24 class TemplateURLFetcherTestCallbacks : public TemplateURLFetcherCallbacks { 24 class TemplateURLFetcherTestCallbacks : public TemplateURLFetcherCallbacks {
25 public: 25 public:
26 explicit TemplateURLFetcherTestCallbacks(TemplateURLFetcherTest* test) 26 explicit TemplateURLFetcherTestCallbacks(TemplateURLFetcherTest* test)
27 : test_(test) { 27 : test_(test) {
28 } 28 }
29 virtual ~TemplateURLFetcherTestCallbacks(); 29 virtual ~TemplateURLFetcherTestCallbacks();
30 30
31 // TemplateURLFetcherCallbacks implementation. 31 // TemplateURLFetcherCallbacks implementation.
32 virtual void ConfirmSetDefaultSearchProvider( 32 virtual void ConfirmSetDefaultSearchProvider(TemplateURL* template_url,
33 TemplateURL* template_url, 33 Profile* profile) OVERRIDE;
34 TemplateURLService* template_url_service); 34 virtual void ConfirmAddSearchProvider(TemplateURL* template_url,
35 virtual void ConfirmAddSearchProvider( 35 Profile* profile) OVERRIDE;
36 TemplateURL* template_url,
37 Profile* profile);
38 36
39 private: 37 private:
40 TemplateURLFetcherTest* test_; 38 TemplateURLFetcherTest* test_;
41 39
42 DISALLOW_COPY_AND_ASSIGN(TemplateURLFetcherTestCallbacks); 40 DISALLOW_COPY_AND_ASSIGN(TemplateURLFetcherTestCallbacks);
43 }; 41 };
44 42
45 // Basic set-up for TemplateURLFetcher tests. 43 // Basic set-up for TemplateURLFetcher tests.
46 class TemplateURLFetcherTest : public testing::Test { 44 class TemplateURLFetcherTest : public testing::Test {
47 public: 45 public:
48 TemplateURLFetcherTest(); 46 TemplateURLFetcherTest();
49 47
50 virtual void SetUp() { 48 virtual void SetUp() OVERRIDE {
51 test_util_.SetUp(); 49 test_util_.SetUp();
52 test_util_.StartIOThread(); 50 test_util_.StartIOThread();
53 ASSERT_TRUE(test_util_.profile()); 51 ASSERT_TRUE(test_util_.profile());
54 test_util_.profile()->CreateTemplateURLFetcher(); 52 test_util_.profile()->CreateTemplateURLFetcher();
55 ASSERT_TRUE(test_util_.profile()->GetTemplateURLFetcher()); 53 ASSERT_TRUE(test_util_.profile()->GetTemplateURLFetcher());
56 54
57 test_util_.profile()->CreateRequestContext(); 55 test_util_.profile()->CreateRequestContext();
58 ASSERT_TRUE(test_util_.profile()->GetRequestContext()); 56 ASSERT_TRUE(test_util_.profile()->GetRequestContext());
59 ASSERT_TRUE(test_server_.Start()); 57 ASSERT_TRUE(test_server_.Start());
60 } 58 }
61 59
62 virtual void TearDown() { 60 virtual void TearDown() OVERRIDE {
63 test_util_.TearDown(); 61 test_util_.TearDown();
64 } 62 }
65 63
66 // Called by ~TemplateURLFetcherTestCallbacks. 64 // Called by ~TemplateURLFetcherTestCallbacks.
67 void DestroyedCallback(TemplateURLFetcherTestCallbacks* callbacks); 65 void DestroyedCallback(TemplateURLFetcherTestCallbacks* callbacks);
68 66
69 // TemplateURLFetcherCallbacks implementation. (Although not derived from 67 // TemplateURLFetcherCallbacks implementation. (Although not derived from
70 // this class, these methods handle those calls for the test.) 68 // this class, these methods handle those calls for the test.)
71 virtual void ConfirmSetDefaultSearchProvider( 69 void ConfirmSetDefaultSearchProvider(TemplateURL* template_url,
72 TemplateURL* template_url, 70 Profile* profile);
73 TemplateURLService* template_url_service); 71 void ConfirmAddSearchProvider(TemplateURL* template_url, Profile* profile);
74 virtual void ConfirmAddSearchProvider(
75 TemplateURL* template_url,
76 Profile* profile);
77 72
78 protected: 73 protected:
79 // Schedules the download of the url. 74 // Schedules the download of the url.
80 void StartDownload(const string16& keyword, 75 void StartDownload(const string16& keyword,
81 const std::string& osdd_file_name, 76 const std::string& osdd_file_name,
82 TemplateURLFetcher::ProviderType provider_type, 77 TemplateURLFetcher::ProviderType provider_type,
83 bool check_that_file_exists); 78 bool check_that_file_exists);
84 79
85 // Waits for any downloads to finish. 80 // Waits for any downloads to finish.
86 void WaitForDownloadToFinish(); 81 void WaitForDownloadToFinish();
(...skipping 20 matching lines...) Expand all
107 private: 102 private:
108 DISALLOW_COPY_AND_ASSIGN(TemplateURLFetcherTest); 103 DISALLOW_COPY_AND_ASSIGN(TemplateURLFetcherTest);
109 }; 104 };
110 105
111 TemplateURLFetcherTestCallbacks::~TemplateURLFetcherTestCallbacks() { 106 TemplateURLFetcherTestCallbacks::~TemplateURLFetcherTestCallbacks() {
112 test_->DestroyedCallback(this); 107 test_->DestroyedCallback(this);
113 } 108 }
114 109
115 void TemplateURLFetcherTestCallbacks::ConfirmSetDefaultSearchProvider( 110 void TemplateURLFetcherTestCallbacks::ConfirmSetDefaultSearchProvider(
116 TemplateURL* template_url, 111 TemplateURL* template_url,
117 TemplateURLService* template_url_service) { 112 Profile* profile) {
118 test_->ConfirmSetDefaultSearchProvider(template_url, template_url_service); 113 test_->ConfirmSetDefaultSearchProvider(template_url, profile);
119 } 114 }
120 115
121 void TemplateURLFetcherTestCallbacks::ConfirmAddSearchProvider( 116 void TemplateURLFetcherTestCallbacks::ConfirmAddSearchProvider(
122 TemplateURL* template_url, 117 TemplateURL* template_url,
123 Profile* profile) { 118 Profile* profile) {
124 test_->ConfirmAddSearchProvider(template_url, profile); 119 test_->ConfirmAddSearchProvider(template_url, profile);
125 } 120 }
126 121
127 TemplateURLFetcherTest::TemplateURLFetcherTest() 122 TemplateURLFetcherTest::TemplateURLFetcherTest()
128 : test_server_(net::TestServer::TYPE_HTTP, 123 : test_server_(net::TestServer::TYPE_HTTP,
129 FilePath(FILE_PATH_LITERAL("chrome/test/data"))), 124 FilePath(FILE_PATH_LITERAL("chrome/test/data"))),
130 callbacks_destroyed_(0), 125 callbacks_destroyed_(0),
131 set_default_called_(0), 126 set_default_called_(0),
132 add_provider_called_(0), 127 add_provider_called_(0),
133 waiting_for_download_(false) { 128 waiting_for_download_(false) {
134 } 129 }
135 130
136 void TemplateURLFetcherTest::DestroyedCallback( 131 void TemplateURLFetcherTest::DestroyedCallback(
137 TemplateURLFetcherTestCallbacks* callbacks) { 132 TemplateURLFetcherTestCallbacks* callbacks) {
138 callbacks_destroyed_++; 133 callbacks_destroyed_++;
139 if (waiting_for_download_) 134 if (waiting_for_download_)
140 MessageLoop::current()->Quit(); 135 MessageLoop::current()->Quit();
141 } 136 }
142 137
143 void TemplateURLFetcherTest::ConfirmSetDefaultSearchProvider( 138 void TemplateURLFetcherTest::ConfirmSetDefaultSearchProvider(
144 TemplateURL* template_url, 139 TemplateURL* template_url,
145 TemplateURLService* template_url_service) { 140 Profile* profile) {
146 last_callback_template_url_.reset(template_url); 141 last_callback_template_url_.reset(template_url);
147 set_default_called_++; 142 set_default_called_++;
148 } 143 }
149 144
150 void TemplateURLFetcherTest::ConfirmAddSearchProvider( 145 void TemplateURLFetcherTest::ConfirmAddSearchProvider(
151 TemplateURL* template_url, 146 TemplateURL* template_url,
152 Profile* profile) { 147 Profile* profile) {
153 last_callback_template_url_.reset(template_url); 148 last_callback_template_url_.reset(template_url);
154 add_provider_called_++; 149 add_provider_called_++;
155 } 150 }
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 ASSERT_EQ(0, add_provider_called_); 376 ASSERT_EQ(0, add_provider_called_);
382 ASSERT_EQ(2, callbacks_destroyed_); 377 ASSERT_EQ(2, callbacks_destroyed_);
383 378
384 WaitForDownloadToFinish(); 379 WaitForDownloadToFinish();
385 ASSERT_EQ(1, set_default_called_); 380 ASSERT_EQ(1, set_default_called_);
386 ASSERT_EQ(0, add_provider_called_); 381 ASSERT_EQ(0, add_provider_called_);
387 ASSERT_EQ(3, callbacks_destroyed_); 382 ASSERT_EQ(3, callbacks_destroyed_);
388 ASSERT_TRUE(last_callback_template_url_.get()); 383 ASSERT_TRUE(last_callback_template_url_.get());
389 ASSERT_NE(keyword, last_callback_template_url_->keyword()); 384 ASSERT_NE(keyword, last_callback_template_url_->keyword());
390 } 385 }
OLDNEW
« no previous file with comments | « chrome/browser/search_engines/template_url_fetcher_callbacks.h ('k') | chrome/browser/ui/browser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698