Skip to content

Commit

Permalink
Replace ScopedAllowIO with ScopedAllowBlockingForTesting in tests.
Browse files Browse the repository at this point in the history
s/ThreadRestrictions::ScopedAllowIO allow_io;/
  ScopedAllowBlockingForTesting allow_blocking;/

in files that have the word "test" in their path.

ThreadRestrictions::ScopedAllowIO instances that are not named
|allow_io| are not changed by this CL. 

TBR=jam@chromium.org

Bug: 766678
Change-Id: Ie809d1b39d50c1669cd36399cdfe5657cf072c21
Reviewed-on: https://chromium-review.googlesource.com/718983
Reviewed-by: François Doray <fdoray@chromium.org>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Commit-Queue: François Doray <fdoray@chromium.org>
Cr-Commit-Position: refs/heads/master@{#509880}
  • Loading branch information
fdoray authored and Commit Bot committed Oct 18, 2017
1 parent 9167e1c commit e6fb2d0
Show file tree
Hide file tree
Showing 126 changed files with 300 additions and 301 deletions.
4 changes: 2 additions & 2 deletions apps/app_restore_service_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, FileAccessIsSavedToPrefs) {
extensions::NOTIFICATION_EXTENSION_HOST_DESTROYED,
content::NotificationService::AllSources());

base::ThreadRestrictions::ScopedAllowIO allow_io;
base::ScopedAllowBlockingForTesting allow_blocking;
base::ScopedTempDir temp_directory;
ASSERT_TRUE(temp_directory.CreateUniqueTempDir());
base::FilePath temp_file;
Expand Down Expand Up @@ -158,7 +158,7 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, MAYBE_FileAccessIsRestored) {
extensions::NOTIFICATION_EXTENSION_HOST_DESTROYED,
content::NotificationService::AllSources());

base::ThreadRestrictions::ScopedAllowIO allow_io;
base::ScopedAllowBlockingForTesting allow_blocking;
base::ScopedTempDir temp_directory;
ASSERT_TRUE(temp_directory.CreateUniqueTempDir());
base::FilePath temp_file;
Expand Down
2 changes: 1 addition & 1 deletion base/test/multiprocess_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ bool TerminateMultiProcessTestChild(const Process& process,
#endif // !defined(OS_ANDROID)

CommandLine GetMultiProcessTestChildBaseCommandLine() {
base::ThreadRestrictions::ScopedAllowIO allow_io;
base::ScopedAllowBlockingForTesting allow_blocking;
CommandLine cmd_line = *CommandLine::ForCurrentProcess();
cmd_line.SetProgram(MakeAbsoluteFilePath(cmd_line.GetProgram()));
return cmd_line;
Expand Down
8 changes: 4 additions & 4 deletions chrome/browser/app_controller_mac_browsertest.mm
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ void CreateAndWaitForSystemProfile() {
base::scoped_nsobject<AppController> ac([[AppController alloc] init]);

// Lock the active profile.
base::ThreadRestrictions::ScopedAllowIO allow_io;
base::ScopedAllowBlockingForTesting allow_blocking;
Profile* profile = [ac lastProfile];
ProfileAttributesEntry* entry;
ASSERT_TRUE(g_browser_process->profile_manager()->
Expand Down Expand Up @@ -297,7 +297,7 @@ void CreateAndWaitForSystemProfile() {

base::scoped_nsobject<AppController> ac([[AppController alloc] init]);

base::ThreadRestrictions::ScopedAllowIO allow_io;
base::ScopedAllowBlockingForTesting allow_blocking;
Profile* profile = [ac lastProfile];
EXPECT_EQ(ProfileManager::GetGuestProfilePath(), profile->GetPath());
EXPECT_TRUE(profile->IsGuestSession());
Expand Down Expand Up @@ -332,7 +332,7 @@ void CreateAndWaitForSystemProfile() {
// Prohibiting guest mode forces the user manager flow for About Chrome.
local_state->SetBoolean(prefs::kBrowserGuestModeEnabled, false);

base::ThreadRestrictions::ScopedAllowIO allow_io;
base::ScopedAllowBlockingForTesting allow_blocking;
Profile* guest_profile = [ac lastProfile];
EXPECT_EQ(ProfileManager::GetGuestProfilePath(), guest_profile->GetPath());
EXPECT_TRUE(guest_profile->IsGuestSession());
Expand Down Expand Up @@ -545,7 +545,7 @@ void SetUpCommandLine(base::CommandLine* command_line) override {
BookmarkModelFactory::GetForBrowserContext(profile1));

// Create profile 2.
base::ThreadRestrictions::ScopedAllowIO allow_io;
base::ScopedAllowBlockingForTesting allow_blocking;
base::FilePath path2 = profile_manager->GenerateNextProfileDirectoryPath();
Profile* profile2 =
Profile::CreateProfile(path2, NULL, Profile::CREATE_MODE_SYNCHRONOUS);
Expand Down
6 changes: 3 additions & 3 deletions chrome/browser/apps/app_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ IN_PROC_BROWSER_TEST_F(PlatformAppWithFileBrowserTest,
// a handler accepts "".
IN_PROC_BROWSER_TEST_F(PlatformAppWithFileBrowserTest,
LaunchWithFileEmptyExtension) {
base::ThreadRestrictions::ScopedAllowIO allow_io;
base::ScopedAllowBlockingForTesting allow_blocking;
base::ScopedTempDir temp_dir;
ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
base::FilePath test_file;
Expand All @@ -618,7 +618,7 @@ IN_PROC_BROWSER_TEST_F(PlatformAppWithFileBrowserTest,
// a handler accepts *.
IN_PROC_BROWSER_TEST_F(PlatformAppWithFileBrowserTest,
LaunchWithFileEmptyExtensionAcceptAny) {
base::ThreadRestrictions::ScopedAllowIO allow_io;
base::ScopedAllowBlockingForTesting allow_blocking;
base::ScopedTempDir temp_dir;
ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
base::FilePath test_file;
Expand Down Expand Up @@ -727,7 +727,7 @@ IN_PROC_BROWSER_TEST_F(PlatformAppWithFileBrowserTest, GetDisplayPath) {
// Tests that the file is created if the file does not exist and the app has the
// fileSystem.write permission.
IN_PROC_BROWSER_TEST_F(PlatformAppWithFileBrowserTest, LaunchNewFile) {
base::ThreadRestrictions::ScopedAllowIO allow_io;
base::ScopedAllowBlockingForTesting allow_blocking;
base::ScopedTempDir temp_dir;
ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
ASSERT_TRUE(RunPlatformAppTestWithFile(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void Send(const T& message) {
user_data_dir.Append(app_mode::kAppShimSocketSymlinkName);

base::FilePath socket_path;
base::ThreadRestrictions::ScopedAllowIO allow_io;
base::ScopedAllowBlockingForTesting allow_blocking;
CHECK(base::ReadSymbolicLink(symlink_path, &socket_path));
app_mode::VerifySocketPermissions(socket_path);

Expand All @@ -84,7 +84,7 @@ void Send(const T& message) {
}

TestShimClient::~TestShimClient() {
base::ThreadRestrictions::ScopedAllowIO allow_io;
base::ScopedAllowBlockingForTesting allow_blocking;
io_thread_.Stop();
}

Expand Down Expand Up @@ -286,7 +286,7 @@ void OnShimSetHidden(apps::AppShimHandler::Host* host, bool hidden) override {
directory_in_tmp_ = test_api.directory_in_tmp();

// Check that socket files have been created.
base::ThreadRestrictions::ScopedAllowIO allow_io;
base::ScopedAllowBlockingForTesting allow_blocking;
EXPECT_TRUE(base::PathExists(directory_in_tmp_));
EXPECT_TRUE(base::PathExists(symlink_path_));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ bool HasAppShimHost(Profile* profile, const std::string& app_id) {
// (always) in tests. If it wasn't the case, the following test would fail
// (but flakily since the creation happens on the FILE thread).
shim_path_ = GetAppShimPath(profile(), app);
base::ThreadRestrictions::ScopedAllowIO allow_io;
base::ScopedAllowBlockingForTesting allow_blocking;
EXPECT_FALSE(base::PathExists(shim_path_));

// To create a shim in a test, instead call UpdateAllShortcuts, which has been
Expand Down
8 changes: 4 additions & 4 deletions chrome/browser/apps/guest_view/web_view_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2596,7 +2596,7 @@ IN_PROC_BROWSER_TEST_P(WebViewTest, DownloadPermission) {
"web_view/download");
ASSERT_TRUE(guest_web_contents);

base::ThreadRestrictions::ScopedAllowIO allow_io;
base::ScopedAllowBlockingForTesting allow_blocking;
base::ScopedTempDir temporary_download_dir;
ASSERT_TRUE(temporary_download_dir.CreateUniqueTempDir());
DownloadPrefs::FromBrowserContext(guest_web_contents->GetBrowserContext())
Expand Down Expand Up @@ -2754,7 +2754,7 @@ IN_PROC_BROWSER_TEST_P(WebViewTest, DownloadCookieIsolation) {
content::WebContents* web_contents = GetFirstAppWindowWebContents();
ASSERT_TRUE(web_contents);

base::ThreadRestrictions::ScopedAllowIO allow_io;
base::ScopedAllowBlockingForTesting allow_blocking;
base::ScopedTempDir temporary_download_dir;
ASSERT_TRUE(temporary_download_dir.CreateUniqueTempDir());
DownloadPrefs::FromBrowserContext(web_contents->GetBrowserContext())
Expand Down Expand Up @@ -2840,7 +2840,7 @@ IN_PROC_BROWSER_TEST_P(WebViewTest, PRE_DownloadCookieIsolation_CrossSession) {
content::WebContents* web_contents = GetFirstAppWindowWebContents();
ASSERT_TRUE(web_contents);

base::ThreadRestrictions::ScopedAllowIO allow_io;
base::ScopedAllowBlockingForTesting allow_blocking;
base::ScopedTempDir temporary_download_dir;
ASSERT_TRUE(temporary_download_dir.CreateUniqueTempDir());
DownloadPrefs::FromBrowserContext(web_contents->GetBrowserContext())
Expand Down Expand Up @@ -2899,7 +2899,7 @@ IN_PROC_BROWSER_TEST_P(WebViewTest, DownloadCookieIsolation_CrossSession) {
DownloadHistoryWaiter history_waiter(browser_context);
history_waiter.WaitForHistoryLoad();

base::ThreadRestrictions::ScopedAllowIO allow_io;
base::ScopedAllowBlockingForTesting allow_blocking;
base::ScopedTempDir temporary_download_dir;
ASSERT_TRUE(temporary_download_dir.Set(
DownloadPrefs::FromBrowserContext(browser_context)->DownloadPath()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ constexpr base::FilePath::CharType kTestFileExtension[] = FILE_PATH_LITERAL(
class BrowsingDataLocalStorageHelperTest : public InProcessBrowserTest {
protected:
void CreateLocalStorageFilesForTest() {
base::ThreadRestrictions::ScopedAllowIO allow_io;
base::ScopedAllowBlockingForTesting allow_blocking;
// Note: This helper depends on details of how the dom_storage library
// stores data in the host file system.
base::FilePath storage_path = GetLocalStoragePathForTestingProfile();
Expand Down Expand Up @@ -131,7 +131,7 @@ IN_PROC_BROWSER_TEST_F(BrowsingDataLocalStorageHelperTest, DeleteSingleFile) {
content::RunAllTasksUntilIdle();

// Ensure the file has been deleted.
base::ThreadRestrictions::ScopedAllowIO allow_io;
base::ScopedAllowBlockingForTesting allow_blocking;
base::FileEnumerator file_enumerator(
GetLocalStoragePathForTestingProfile(),
false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class BrowsingDataRemoverBrowserTest : public InProcessBrowserTest {
}

void DownloadAnItem() {
base::ThreadRestrictions::ScopedAllowIO allow_io;
base::ScopedAllowBlockingForTesting allow_blocking;
base::ScopedTempDir downloads_directory;
ASSERT_TRUE(downloads_directory.CreateUniqueTempDir());
browser()->profile()->GetPrefs()->SetFilePath(
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/chrome_service_worker_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class ChromeServiceWorkerTest : public InProcessBrowserTest {

void WriteFile(const base::FilePath::StringType& filename,
base::StringPiece contents) {
base::ThreadRestrictions::ScopedAllowIO allow_io;
base::ScopedAllowBlockingForTesting allow_blocking;
EXPECT_EQ(base::checked_cast<int>(contents.size()),
base::WriteFile(service_worker_dir_.GetPath().Append(filename),
contents.data(), contents.size()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ IN_PROC_BROWSER_TEST_F(CustomizationLocaleTest, CheckAvailableLocales) {
waiter.Wait();
{
std::string resolved_locale;
base::ThreadRestrictions::ScopedAllowIO allow_io;
base::ScopedAllowBlockingForTesting allow_blocking;
l10n_util::CheckAndResolveLocale(languages_available[i],
&resolved_locale);
EXPECT_EQ(GetExpectedLanguage(languages_available[i]), resolved_locale)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ class MultiProfileFileManagerBrowserTest : public FileManagerBrowserTestBase {

// Adds a new user for testing to the current session.
void AddUser(const TestAccountInfo& info, bool log_in) {
base::ThreadRestrictions::ScopedAllowIO allow_io;
base::ScopedAllowBlockingForTesting allow_blocking;
const AccountId account_id(AccountId::FromUserEmail(info.email));
if (log_in) {
session_manager::SessionManager::Get()->CreateSession(account_id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ void FileManagerBrowserTestBase::RunTestMessageLoop() {
void FileManagerBrowserTestBase::OnMessage(const std::string& name,
const base::DictionaryValue& value,
std::string* output) {
base::ThreadRestrictions::ScopedAllowIO allow_io;
base::ScopedAllowBlockingForTesting allow_blocking;
if (name == "getTestName") {
// Pass the test case name.
*output = GetTestCaseNameParam();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class WallpaperManagerBrowserTest : public InProcessBrowserTest {
const char* sub_dir,
const wallpaper::WallpaperFilesId& wallpaper_files_id,
const std::string& id) {
base::ThreadRestrictions::ScopedAllowIO allow_io;
base::ScopedAllowBlockingForTesting allow_blocking;
base::FilePath wallpaper_path =
WallpaperManager::Get()->GetCustomWallpaperPath(sub_dir,
wallpaper_files_id, id);
Expand All @@ -141,7 +141,7 @@ class WallpaperManagerBrowserTest : public InProcessBrowserTest {

// Logs in |account_id|.
void LogIn(const AccountId& account_id, const std::string& user_id_hash) {
base::ThreadRestrictions::ScopedAllowIO allow_io;
base::ScopedAllowBlockingForTesting allow_blocking;
SessionManager::Get()->CreateSession(account_id, user_id_hash);
SessionManager::Get()->SessionStarted();
// Flush to ensure the created session and ACTIVE state reaches ash.
Expand Down Expand Up @@ -181,7 +181,7 @@ class WallpaperManagerBrowserTest : public InProcessBrowserTest {
// Only needs to be called (once) by tests that want to test loading of
// default wallpapers.
void CreateCmdlineWallpapers() {
base::ThreadRestrictions::ScopedAllowIO allow_io;
base::ScopedAllowBlockingForTesting allow_blocking;
wallpaper_dir_.reset(new base::ScopedTempDir);
ASSERT_TRUE(wallpaper_dir_->CreateUniqueTempDir());
wallpaper_manager_test_utils::CreateCmdlineWallpapers(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ bool WriteJPEGFile(const base::FilePath& path,
int width,
int height,
SkColor color) {
base::ThreadRestrictions::ScopedAllowIO allow_io;
base::ScopedAllowBlockingForTesting allow_blocking;
std::vector<unsigned char> output;
if (!CreateJPEGImage(width, height, color, &output))
return false;
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/devtools/devtools_sanity_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ class DevToolsExtensionTest : public DevToolsSanityTest,
const Extension* GetExtensionByPath(
const extensions::ExtensionSet& extensions,
const base::FilePath& path) {
base::ThreadRestrictions::ScopedAllowIO allow_io;
base::ScopedAllowBlockingForTesting allow_blocking;
base::FilePath extension_path = base::MakeAbsoluteFilePath(path);
EXPECT_TRUE(!extension_path.empty());
for (const scoped_refptr<const Extension>& extension : extensions) {
Expand Down
6 changes: 3 additions & 3 deletions chrome/browser/downgrade/user_data_downgrade_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -116,22 +116,22 @@ class UserDataDowngradeBrowserNoMSITest
// Verify the user data directory has been renamed and created again after
// downgrade.
IN_PROC_BROWSER_TEST_F(UserDataDowngradeBrowserCopyAndCleanTest, Test) {
base::ThreadRestrictions::ScopedAllowIO allow_io;
base::ScopedAllowBlockingForTesting allow_blocking;
base::TaskScheduler::GetInstance()->FlushForTesting();
EXPECT_EQ(chrome::kChromeVersion, GetLastVersion(user_data_dir_).GetString());
ASSERT_FALSE(base::PathExists(other_file_));
}

// Verify the user data directory will not be reset without downgrade.
IN_PROC_BROWSER_TEST_F(UserDataDowngradeBrowserNoResetTest, Test) {
base::ThreadRestrictions::ScopedAllowIO allow_io;
base::ScopedAllowBlockingForTesting allow_blocking;
EXPECT_EQ(chrome::kChromeVersion, GetLastVersion(user_data_dir_).GetString());
ASSERT_TRUE(base::PathExists(other_file_));
}

// Verify the "Last Version" file won't be created for non-msi install.
IN_PROC_BROWSER_TEST_F(UserDataDowngradeBrowserNoMSITest, Test) {
base::ThreadRestrictions::ScopedAllowIO allow_io;
base::ScopedAllowBlockingForTesting allow_blocking;
ASSERT_FALSE(base::PathExists(last_version_file_path_));
ASSERT_TRUE(base::PathExists(other_file_));
}
Expand Down
Loading

0 comments on commit e6fb2d0

Please sign in to comment.