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

Side by Side Diff: content/public/test/browser_test_utils.cc

Issue 10873082: Converted policy.PolicyTest.ClearSiteDataOnExit pyauto test to a browser_test. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: . Created 8 years, 3 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
« no previous file with comments | « content/public/test/browser_test_utils.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "content/public/test/browser_test_utils.h" 5 #include "content/public/test/browser_test_utils.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/json/json_reader.h" 8 #include "base/json/json_reader.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/process_util.h" 10 #include "base/process_util.h"
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 } 159 }
160 160
161 void GetCookiesOnIOThread(const GURL& url, 161 void GetCookiesOnIOThread(const GURL& url,
162 net::URLRequestContextGetter* context_getter, 162 net::URLRequestContextGetter* context_getter,
163 base::WaitableEvent* event, 163 base::WaitableEvent* event,
164 std::string* cookies) { 164 std::string* cookies) {
165 net::CookieStore* cookie_store = 165 net::CookieStore* cookie_store =
166 context_getter->GetURLRequestContext()->cookie_store(); 166 context_getter->GetURLRequestContext()->cookie_store();
167 cookie_store->GetCookiesWithOptionsAsync( 167 cookie_store->GetCookiesWithOptionsAsync(
168 url, net::CookieOptions(), 168 url, net::CookieOptions(),
169 base::Bind(&GetCookiesCallback, 169 base::Bind(&GetCookiesCallback, cookies, event));
170 base::Unretained(cookies), base::Unretained(event))); 170 }
171
172 void SetCookieCallback(bool* result,
173 base::WaitableEvent* event,
174 bool success) {
175 *result = success;
176 event->Signal();
177 }
178
179 void SetCookieOnIOThread(const GURL& url,
180 const std::string& value,
181 net::URLRequestContextGetter* context_getter,
182 base::WaitableEvent* event,
183 bool* result) {
184 net::CookieStore* cookie_store =
185 context_getter->GetURLRequestContext()->cookie_store();
186 cookie_store->SetCookieWithOptionsAsync(
187 url, value, net::CookieOptions(),
188 base::Bind(&SetCookieCallback, result, event));
171 } 189 }
172 190
173 } // namespace 191 } // namespace
174 192
175 193
176 GURL GetFileUrlWithQuery(const FilePath& path, 194 GURL GetFileUrlWithQuery(const FilePath& path,
177 const std::string& query_string) { 195 const std::string& query_string) {
178 GURL url = net::FilePathToFileURL(path); 196 GURL url = net::FilePathToFileURL(path);
179 if (!query_string.empty()) { 197 if (!query_string.empty()) {
180 GURL::Replacements replacements; 198 GURL::Replacements replacements;
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 browser_context->GetRequestContext(); 330 browser_context->GetRequestContext();
313 331
314 BrowserThread::PostTask( 332 BrowserThread::PostTask(
315 BrowserThread::IO, FROM_HERE, 333 BrowserThread::IO, FROM_HERE,
316 base::Bind(&GetCookiesOnIOThread, url, 334 base::Bind(&GetCookiesOnIOThread, url,
317 make_scoped_refptr(context_getter), &event, &cookies)); 335 make_scoped_refptr(context_getter), &event, &cookies));
318 event.Wait(); 336 event.Wait();
319 return cookies; 337 return cookies;
320 } 338 }
321 339
340 bool SetCookie(BrowserContext* browser_context,
341 const GURL& url,
342 const std::string& value) {
343 bool result = false;
344 base::WaitableEvent event(true, false);
345 net::URLRequestContextGetter* context_getter =
346 browser_context->GetRequestContext();
347
348 BrowserThread::PostTask(
349 BrowserThread::IO, FROM_HERE,
350 base::Bind(&SetCookieOnIOThread, url, value,
351 make_scoped_refptr(context_getter), &event, &result));
352 event.Wait();
353 return result;
354 }
355
322 TitleWatcher::TitleWatcher(WebContents* web_contents, 356 TitleWatcher::TitleWatcher(WebContents* web_contents,
323 const string16& expected_title) 357 const string16& expected_title)
324 : web_contents_(web_contents), 358 : web_contents_(web_contents),
325 expected_title_observed_(false), 359 expected_title_observed_(false),
326 quit_loop_on_observation_(false) { 360 quit_loop_on_observation_(false) {
327 EXPECT_TRUE(web_contents != NULL); 361 EXPECT_TRUE(web_contents != NULL);
328 expected_titles_.push_back(expected_title); 362 expected_titles_.push_back(expected_title);
329 notification_registrar_.Add(this, 363 notification_registrar_.Add(this,
330 NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED, 364 NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED,
331 Source<WebContents>(web_contents)); 365 Source<WebContents>(web_contents));
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 base::LaunchProcess(*cmd_line.get(), options, NULL); 562 base::LaunchProcess(*cmd_line.get(), options, NULL);
529 563
530 #if defined(OS_POSIX) 564 #if defined(OS_POSIX)
531 // Just to make sure that the server process terminates certainly. 565 // Just to make sure that the server process terminates certainly.
532 if (process_group_id_ != base::kNullProcessHandle) 566 if (process_group_id_ != base::kNullProcessHandle)
533 base::KillProcessGroup(process_group_id_); 567 base::KillProcessGroup(process_group_id_);
534 #endif 568 #endif
535 } 569 }
536 570
537 } // namespace content 571 } // namespace content
OLDNEW
« no previous file with comments | « content/public/test/browser_test_utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698