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

Unified Diff: chrome/browser/profiles/profile_browsertest.cc

Issue 378863003: Revert of Fix Windows logoff race. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/lifetime/application_lifetime.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/profiles/profile_browsertest.cc
diff --git a/chrome/browser/profiles/profile_browsertest.cc b/chrome/browser/profiles/profile_browsertest.cc
index 53abe2584a6a30c22350770514273d51eba6ea01..0cc502f4ea4b0aa0a8587afc44ff0970963d1ab5 100644
--- a/chrome/browser/profiles/profile_browsertest.cc
+++ b/chrome/browser/profiles/profile_browsertest.cc
@@ -7,17 +7,12 @@
#include "base/command_line.h"
#include "base/file_util.h"
#include "base/files/scoped_temp_dir.h"
-#include "base/json/json_reader.h"
#include "base/prefs/pref_service.h"
-#include "base/sequenced_task_runner.h"
#include "base/synchronization/waitable_event.h"
-#include "base/values.h"
#include "base/version.h"
-#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/profiles/chrome_version_service.h"
#include "chrome/browser/profiles/profile_impl.h"
-#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/profiles/startup_task_runner_service.h"
#include "chrome/browser/profiles/startup_task_runner_service_factory.h"
#include "chrome/common/chrome_constants.h"
@@ -47,6 +42,20 @@
ASSERT_TRUE(base::WriteFile(pref_path, data.c_str(), data.size()));
}
+scoped_ptr<Profile> CreateProfile(
+ const base::FilePath& path,
+ Profile::Delegate* delegate,
+ Profile::CreateMode create_mode) {
+ scoped_ptr<Profile> profile(Profile::CreateProfile(
+ path, delegate, create_mode));
+ EXPECT_TRUE(profile.get());
+ // This is necessary to avoid a memleak from BookmarkModel::Load.
+ // Unfortunately, this also results in warnings during debug runs.
+ StartupTaskRunnerServiceFactory::GetForProfile(profile.get())->
+ StartDeferredTaskRunners();
+ return profile.Pass();
+}
+
void CheckChromeVersion(Profile *profile, bool is_new) {
std::string created_by_version;
if (is_new) {
@@ -66,38 +75,6 @@
base::WaitableEvent* unblock) {
is_blocked->Signal();
unblock->Wait();
-}
-
-void FlushTaskRunner(base::SequencedTaskRunner* runner) {
- ASSERT_TRUE(runner);
- base::WaitableEvent unblock(false, false);
-
- runner->PostTask(FROM_HERE,
- base::Bind(&base::WaitableEvent::Signal, base::Unretained(&unblock)));
-
- unblock.Wait();
-}
-
-std::string GetExitTypePreferenceFromDisk(Profile* profile) {
- base::FilePath prefs_path =
- profile->GetPath().Append(chrome::kPreferencesFilename);
- std::string prefs;
- if (!base::ReadFileToString(prefs_path, &prefs))
- return std::string();
-
- scoped_ptr<base::Value> value(base::JSONReader::Read(prefs));
- if (!value)
- return std::string();
-
- base::DictionaryValue* dict = NULL;
- if (!value->GetAsDictionary(&dict) || !dict)
- return std::string();
-
- std::string exit_type;
- if (!dict->GetString("profile.exit_type", &exit_type))
- return std::string();
-
- return exit_type;
}
void SpinThreads() {
@@ -120,32 +97,14 @@
chromeos::switches::kIgnoreUserProfileMappingForTests);
#endif
}
-
- scoped_ptr<Profile> CreateProfile(
- const base::FilePath& path,
- Profile::Delegate* delegate,
- Profile::CreateMode create_mode) {
- scoped_ptr<Profile> profile(Profile::CreateProfile(
- path, delegate, create_mode));
- EXPECT_TRUE(profile.get());
-
- // Store the Profile's IO task runner so we can wind it down.
- profile_io_task_runner_ = profile->GetIOTaskRunner();
-
- return profile.Pass();
- }
-
- void FlushIoTaskRunnerAndSpinThreads() {
- FlushTaskRunner(profile_io_task_runner_);
- SpinThreads();
- }
-
- scoped_refptr<base::SequencedTaskRunner> profile_io_task_runner_;
};
// Test OnProfileCreate is called with is_new_profile set to true when
// creating a new profile synchronously.
-IN_PROC_BROWSER_TEST_F(ProfileBrowserTest, CreateNewProfileSynchronous) {
+//
+// Flaky (sometimes timeout): http://crbug.com/141141
+IN_PROC_BROWSER_TEST_F(ProfileBrowserTest,
+ DISABLED_CreateNewProfileSynchronous) {
base::ScopedTempDir temp_dir;
ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
@@ -158,12 +117,14 @@
CheckChromeVersion(profile.get(), true);
}
- FlushIoTaskRunnerAndSpinThreads();
+ SpinThreads();
}
// Test OnProfileCreate is called with is_new_profile set to false when
// creating a profile synchronously with an existing prefs file.
-IN_PROC_BROWSER_TEST_F(ProfileBrowserTest, CreateOldProfileSynchronous) {
+// Flaky: http://crbug.com/141517
+IN_PROC_BROWSER_TEST_F(ProfileBrowserTest,
+ DISABLED_CreateOldProfileSynchronous) {
base::ScopedTempDir temp_dir;
ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
CreatePrefsFileInDirectory(temp_dir.path());
@@ -177,12 +138,14 @@
CheckChromeVersion(profile.get(), false);
}
- FlushIoTaskRunnerAndSpinThreads();
+ SpinThreads();
}
// Test OnProfileCreate is called with is_new_profile set to true when
// creating a new profile asynchronously.
-IN_PROC_BROWSER_TEST_F(ProfileBrowserTest, CreateNewProfileAsynchronous) {
+// This test is flaky on Linux, Win and Mac. See crbug.com/142787
+IN_PROC_BROWSER_TEST_F(ProfileBrowserTest,
+ DISABLED_CreateNewProfileAsynchronous) {
base::ScopedTempDir temp_dir;
ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
@@ -202,12 +165,14 @@
CheckChromeVersion(profile.get(), true);
}
- FlushIoTaskRunnerAndSpinThreads();
+ SpinThreads();
}
// Test OnProfileCreate is called with is_new_profile set to false when
// creating a profile asynchronously with an existing prefs file.
-IN_PROC_BROWSER_TEST_F(ProfileBrowserTest, CreateOldProfileAsynchronous) {
+// Flaky: http://crbug.com/141517
+IN_PROC_BROWSER_TEST_F(ProfileBrowserTest,
+ DISABLED_CreateOldProfileAsynchronous) {
base::ScopedTempDir temp_dir;
ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
CreatePrefsFileInDirectory(temp_dir.path());
@@ -228,11 +193,12 @@
CheckChromeVersion(profile.get(), false);
}
- FlushIoTaskRunnerAndSpinThreads();
+ SpinThreads();
}
// Test that a README file is created for profiles that didn't have it.
-IN_PROC_BROWSER_TEST_F(ProfileBrowserTest, ProfileReadmeCreated) {
+// Flaky: http://crbug.com/140882
+IN_PROC_BROWSER_TEST_F(ProfileBrowserTest, DISABLED_ProfileReadmeCreated) {
base::ScopedTempDir temp_dir;
ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
@@ -261,7 +227,7 @@
temp_dir.path().Append(chrome::kReadmeFilename)));
}
- FlushIoTaskRunnerAndSpinThreads();
+ SpinThreads();
}
// Test that Profile can be deleted before README file is created.
@@ -296,11 +262,17 @@
// task for README creation).
unblock->Signal();
- FlushIoTaskRunnerAndSpinThreads();
+ SpinThreads();
}
// Test that repeated setting of exit type is handled correctly.
-IN_PROC_BROWSER_TEST_F(ProfileBrowserTest, ExitType) {
+#if defined(OS_WIN)
+// Flaky on Windows: http://crbug.com/163713
+#define MAYBE_ExitType DISABLED_ExitType
+#else
+#define MAYBE_ExitType ExitType
+#endif
+IN_PROC_BROWSER_TEST_F(ProfileBrowserTest, MAYBE_ExitType) {
base::ScopedTempDir temp_dir;
ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
@@ -330,38 +302,5 @@
EXPECT_EQ(crash_value, final_value);
}
- FlushIoTaskRunnerAndSpinThreads();
-}
-
-IN_PROC_BROWSER_TEST_F(ProfileBrowserTest,
- WritesProfilesSynchronouslyOnEndSession) {
- base::ScopedTempDir temp_dir;
- ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
-
- ProfileManager* profile_manager = g_browser_process->profile_manager();
- ASSERT_TRUE(profile_manager);
- std::vector<Profile*> loaded_profiles = profile_manager->GetLoadedProfiles();
-
- ASSERT_NE(loaded_profiles.size(), 0UL);
- for (size_t i = 0; i < loaded_profiles.size(); ++i) {
- Profile* profile = loaded_profiles[i];
-
- // Flush the profile data to disk for all loaded profiles.
- profile->SetExitType(Profile::EXIT_CRASHED);
- FlushTaskRunner(profile->GetIOTaskRunner());
-
- // Make sure that the prefs file was written with the expected key/value.
- ASSERT_EQ(GetExitTypePreferenceFromDisk(profile), "Crashed");
- }
-
- // This must not return until the profile data has been written to disk.
- // If this test flakes, then logoff on Windows has broken again.
- g_browser_process->EndSession();
-
- // Verify that the setting was indeed written.
- for (size_t i = 0; i < loaded_profiles.size(); ++i) {
- Profile* profile = loaded_profiles[i];
- // Make sure that the prefs file was written with the expected key/value.
- ASSERT_EQ(GetExitTypePreferenceFromDisk(profile), "SessionEnded");
- }
-}
+ SpinThreads();
+}
« no previous file with comments | « chrome/browser/lifetime/application_lifetime.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698