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

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

Issue 14113053: chrome: Use base::MessageLoop. (Part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase again Created 7 years, 6 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.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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 base::FilePath(FILE_PATH_LITERAL("chrome/test/data"))), 113 base::FilePath(FILE_PATH_LITERAL("chrome/test/data"))),
114 callbacks_destroyed_(0), 114 callbacks_destroyed_(0),
115 add_provider_called_(0), 115 add_provider_called_(0),
116 waiting_for_download_(false) { 116 waiting_for_download_(false) {
117 } 117 }
118 118
119 void TemplateURLFetcherTest::DestroyedCallback( 119 void TemplateURLFetcherTest::DestroyedCallback(
120 TemplateURLFetcherTestCallbacks* callbacks) { 120 TemplateURLFetcherTestCallbacks* callbacks) {
121 callbacks_destroyed_++; 121 callbacks_destroyed_++;
122 if (waiting_for_download_) 122 if (waiting_for_download_)
123 MessageLoop::current()->Quit(); 123 base::MessageLoop::current()->Quit();
124 } 124 }
125 125
126 void TemplateURLFetcherTest::ConfirmAddSearchProvider( 126 void TemplateURLFetcherTest::ConfirmAddSearchProvider(
127 TemplateURL* template_url, 127 TemplateURL* template_url,
128 Profile* profile) { 128 Profile* profile) {
129 last_callback_template_url_.reset(template_url); 129 last_callback_template_url_.reset(template_url);
130 add_provider_called_++; 130 add_provider_called_++;
131 } 131 }
132 132
133 void TemplateURLFetcherTest::StartDownload( 133 void TemplateURLFetcherTest::StartDownload(
(...skipping 15 matching lines...) Expand all
149 GURL favicon_url; 149 GURL favicon_url;
150 TemplateURLFetcherFactory::GetForProfile( 150 TemplateURLFetcherFactory::GetForProfile(
151 test_util_.profile())->ScheduleDownload( 151 test_util_.profile())->ScheduleDownload(
152 keyword, osdd_url, favicon_url, NULL, 152 keyword, osdd_url, favicon_url, NULL,
153 new TemplateURLFetcherTestCallbacks(this), provider_type); 153 new TemplateURLFetcherTestCallbacks(this), provider_type);
154 } 154 }
155 155
156 void TemplateURLFetcherTest::WaitForDownloadToFinish() { 156 void TemplateURLFetcherTest::WaitForDownloadToFinish() {
157 ASSERT_FALSE(waiting_for_download_); 157 ASSERT_FALSE(waiting_for_download_);
158 waiting_for_download_ = true; 158 waiting_for_download_ = true;
159 MessageLoop::current()->Run(); 159 base::MessageLoop::current()->Run();
160 waiting_for_download_ = false; 160 waiting_for_download_ = false;
161 } 161 }
162 162
163 TEST_F(TemplateURLFetcherTest, BasicAutodetectedTest) { 163 TEST_F(TemplateURLFetcherTest, BasicAutodetectedTest) {
164 string16 keyword(ASCIIToUTF16("test")); 164 string16 keyword(ASCIIToUTF16("test"));
165 165
166 test_util_.ChangeModelToLoadState(); 166 test_util_.ChangeModelToLoadState();
167 ASSERT_FALSE(test_util_.model()->GetTemplateURLForKeyword(keyword)); 167 ASSERT_FALSE(test_util_.model()->GetTemplateURLForKeyword(keyword));
168 168
169 std::string osdd_file_name("simple_open_search.xml"); 169 std::string osdd_file_name("simple_open_search.xml");
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 StartDownload(keyword, osdd_file_name, 317 StartDownload(keyword, osdd_file_name,
318 TemplateURLFetcher::EXPLICIT_PROVIDER, true); 318 TemplateURLFetcher::EXPLICIT_PROVIDER, true);
319 ASSERT_EQ(0, add_provider_called_); 319 ASSERT_EQ(0, add_provider_called_);
320 ASSERT_EQ(1, callbacks_destroyed_); 320 ASSERT_EQ(1, callbacks_destroyed_);
321 321
322 WaitForDownloadToFinish(); 322 WaitForDownloadToFinish();
323 ASSERT_EQ(1, add_provider_called_); 323 ASSERT_EQ(1, add_provider_called_);
324 ASSERT_EQ(2, callbacks_destroyed_); 324 ASSERT_EQ(2, callbacks_destroyed_);
325 ASSERT_TRUE(last_callback_template_url_.get()); 325 ASSERT_TRUE(last_callback_template_url_.get());
326 } 326 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698