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

Side by Side Diff: chrome/test/base/ui_test_utils.cc

Issue 2835233002: Fix integration tests in src/chrome and src/extensions so that we can turn on IO thread checks wi... (Closed)
Patch Set: ready for review Created 3 years, 8 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 | « chrome/test/base/testing_profile.cc ('k') | chrome/test/base/web_ui_browser_test.cc » ('j') | 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 "chrome/test/base/ui_test_utils.h" 5 #include "chrome/test/base/ui_test_utils.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/bind_helpers.h" 12 #include "base/bind_helpers.h"
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "base/command_line.h" 14 #include "base/command_line.h"
15 #include "base/files/file_path.h" 15 #include "base/files/file_path.h"
16 #include "base/files/file_util.h" 16 #include "base/files/file_util.h"
17 #include "base/macros.h" 17 #include "base/macros.h"
18 #include "base/memory/ref_counted.h" 18 #include "base/memory/ref_counted.h"
19 #include "base/path_service.h" 19 #include "base/path_service.h"
20 #include "base/strings/utf_string_conversions.h" 20 #include "base/strings/utf_string_conversions.h"
21 #include "base/test/test_timeouts.h" 21 #include "base/test/test_timeouts.h"
22 #include "base/threading/thread_restrictions.h"
22 #include "base/time/time.h" 23 #include "base/time/time.h"
23 #include "build/build_config.h" 24 #include "build/build_config.h"
24 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 25 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
25 #include "chrome/browser/chrome_notification_types.h" 26 #include "chrome/browser/chrome_notification_types.h"
26 #include "chrome/browser/history/history_service_factory.h" 27 #include "chrome/browser/history/history_service_factory.h"
27 #include "chrome/browser/profiles/profile.h" 28 #include "chrome/browser/profiles/profile.h"
28 #include "chrome/browser/ui/browser.h" 29 #include "chrome/browser/ui/browser.h"
29 #include "chrome/browser/ui/browser_commands.h" 30 #include "chrome/browser/ui/browser_commands.h"
30 #include "chrome/browser/ui/browser_finder.h" 31 #include "chrome/browser/ui/browser_finder.h"
31 #include "chrome/browser/ui/browser_list.h" 32 #include "chrome/browser/ui/browser_list.h"
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 void NavigateToURLBlockUntilNavigationsComplete(Browser* browser, 275 void NavigateToURLBlockUntilNavigationsComplete(Browser* browser,
275 const GURL& url, 276 const GURL& url,
276 int number_of_navigations) { 277 int number_of_navigations) {
277 NavigateToURLWithDispositionBlockUntilNavigationsComplete( 278 NavigateToURLWithDispositionBlockUntilNavigationsComplete(
278 browser, url, number_of_navigations, WindowOpenDisposition::CURRENT_TAB, 279 browser, url, number_of_navigations, WindowOpenDisposition::CURRENT_TAB,
279 BROWSER_TEST_WAIT_FOR_NAVIGATION); 280 BROWSER_TEST_WAIT_FOR_NAVIGATION);
280 } 281 }
281 282
282 base::FilePath GetTestFilePath(const base::FilePath& dir, 283 base::FilePath GetTestFilePath(const base::FilePath& dir,
283 const base::FilePath& file) { 284 const base::FilePath& file) {
285 base::ThreadRestrictions::ScopedAllowIO allow_io;
284 base::FilePath path; 286 base::FilePath path;
285 PathService::Get(chrome::DIR_TEST_DATA, &path); 287 PathService::Get(chrome::DIR_TEST_DATA, &path);
286 return path.Append(dir).Append(file); 288 return path.Append(dir).Append(file);
287 } 289 }
288 290
289 GURL GetTestUrl(const base::FilePath& dir, const base::FilePath& file) { 291 GURL GetTestUrl(const base::FilePath& dir, const base::FilePath& file) {
290 return net::FilePathToFileURL(GetTestFilePath(dir, file)); 292 return net::FilePathToFileURL(GetTestFilePath(dir, file));
291 } 293 }
292 294
293 bool GetRelativeBuildDirectory(base::FilePath* build_dir) { 295 bool GetRelativeBuildDirectory(base::FilePath* build_dir) {
296 base::ThreadRestrictions::ScopedAllowIO allow_io;
294 // This function is used to find the build directory so TestServer can serve 297 // This function is used to find the build directory so TestServer can serve
295 // built files (nexes, etc). TestServer expects a path relative to the source 298 // built files (nexes, etc). TestServer expects a path relative to the source
296 // root. 299 // root.
297 base::FilePath exe_dir = 300 base::FilePath exe_dir =
298 base::CommandLine::ForCurrentProcess()->GetProgram().DirName(); 301 base::CommandLine::ForCurrentProcess()->GetProgram().DirName();
299 base::FilePath src_dir; 302 base::FilePath src_dir;
300 if (!PathService::Get(base::DIR_SOURCE_ROOT, &src_dir)) 303 if (!PathService::Get(base::DIR_SOURCE_ROOT, &src_dir))
301 return false; 304 return false;
302 305
303 // We must first generate absolute paths to SRC and EXE and from there 306 // We must first generate absolute paths to SRC and EXE and from there
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 FindInPageNotificationObserver observer(tab); 359 FindInPageNotificationObserver observer(tab);
357 observer.Wait(); 360 observer.Wait();
358 if (ordinal) 361 if (ordinal)
359 *ordinal = observer.active_match_ordinal(); 362 *ordinal = observer.active_match_ordinal();
360 if (selection_rect) 363 if (selection_rect)
361 *selection_rect = observer.selection_rect(); 364 *selection_rect = observer.selection_rect();
362 return observer.number_of_matches(); 365 return observer.number_of_matches();
363 } 366 }
364 367
365 void DownloadURL(Browser* browser, const GURL& download_url) { 368 void DownloadURL(Browser* browser, const GURL& download_url) {
369 base::ThreadRestrictions::ScopedAllowIO allow_io;
366 base::ScopedTempDir downloads_directory; 370 base::ScopedTempDir downloads_directory;
367 ASSERT_TRUE(downloads_directory.CreateUniqueTempDir()); 371 ASSERT_TRUE(downloads_directory.CreateUniqueTempDir());
368 browser->profile()->GetPrefs()->SetFilePath(prefs::kDownloadDefaultDirectory, 372 browser->profile()->GetPrefs()->SetFilePath(prefs::kDownloadDefaultDirectory,
369 downloads_directory.GetPath()); 373 downloads_directory.GetPath());
370 374
371 content::DownloadManager* download_manager = 375 content::DownloadManager* download_manager =
372 content::BrowserContext::GetDownloadManager(browser->profile()); 376 content::BrowserContext::GetDownloadManager(browser->profile());
373 std::unique_ptr<content::DownloadTestObserver> observer( 377 std::unique_ptr<content::DownloadTestObserver> observer(
374 new content::DownloadTestObserverTerminal( 378 new content::DownloadTestObserverTerminal(
375 download_manager, 1, 379 download_manager, 1,
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 if (browser != browser_) 596 if (browser != browser_)
593 return; 597 return;
594 598
595 observed_ = true; 599 observed_ = true;
596 BrowserList::RemoveObserver(this); 600 BrowserList::RemoveObserver(this);
597 if (message_loop_runner_.get() && message_loop_runner_->loop_running()) 601 if (message_loop_runner_.get() && message_loop_runner_->loop_running())
598 message_loop_runner_->Quit(); 602 message_loop_runner_->Quit();
599 } 603 }
600 604
601 } // namespace ui_test_utils 605 } // namespace ui_test_utils
OLDNEW
« no previous file with comments | « chrome/test/base/testing_profile.cc ('k') | chrome/test/base/web_ui_browser_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698