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

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

Issue 9911029: Refactored the CloudPolicyProvider so that it becomes initialized once and stays initialized. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Using mock caches in the unittest Created 8 years, 9 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
Index: chrome/browser/profiles/profile_browsertest.cc
diff --git a/chrome/browser/profiles/profile_browsertest.cc b/chrome/browser/profiles/profile_browsertest.cc
index eb5cf21b880e9ef435a027456fa5ad4cbda78777..9d39ec1791582dbb4cbbb32260475dd9f012cb12 100644
--- a/chrome/browser/profiles/profile_browsertest.cc
+++ b/chrome/browser/profiles/profile_browsertest.cc
@@ -8,6 +8,8 @@
#include "base/platform_file.h"
#include "base/scoped_temp_dir.h"
#include "base/version.h"
+#include "chrome/browser/browser_process.h"
+#include "chrome/browser/policy/browser_policy_connector.h"
#include "chrome/browser/profiles/chrome_version_service.h"
#include "chrome/browser/profiles/profile_impl.h"
#include "chrome/common/chrome_constants.h"
@@ -50,6 +52,21 @@ void CheckChromeVersion(Profile *profile, bool is_new) {
EXPECT_EQ(created_by_version, pref_version);
}
+// Helper function that makes sure all the PrefStores for the profile's
+// PrefService are initialized.
+void InitializeAllPrefStores() {
+#if defined(OS_CHROMEOS)
+ // On enterprise Chrome OS devices, the policy PrefStore only becomes ready
+ // after refreshing the user policy, so that the Profile PrefService sees the
+ // right managed values. On non-enterprise devices this behavior is disabled
+ // after a sign-in; signal that here too, for the test.
+ policy::BrowserPolicyConnector* connector =
+ g_browser_process->browser_policy_connector();
+ if (connector)
+ connector->InitializeUserPolicy("", false);
+#endif
+}
+
} // namespace
typedef InProcessBrowserTest ProfileBrowserTest;
@@ -98,6 +115,8 @@ IN_PROC_BROWSER_TEST_F(ProfileBrowserTest, CreateNewProfileAsynchronous) {
temp_dir.path(), &delegate, Profile::CREATE_MODE_ASYNCHRONOUS));
ASSERT_TRUE(profile.get());
+ InitializeAllPrefStores();
+
// Wait for the profile to be created.
ui_test_utils::WindowedNotificationObserver observer(
chrome::NOTIFICATION_PROFILE_CREATED,
@@ -119,6 +138,8 @@ IN_PROC_BROWSER_TEST_F(ProfileBrowserTest, CreateOldProfileAsynchronous) {
temp_dir.path(), &delegate, Profile::CREATE_MODE_ASYNCHRONOUS));
ASSERT_TRUE(profile.get());
+ InitializeAllPrefStores();
+
// Wait for the profile to be created.
ui_test_utils::WindowedNotificationObserver observer(
chrome::NOTIFICATION_PROFILE_CREATED,
@@ -142,6 +163,8 @@ IN_PROC_BROWSER_TEST_F(ProfileBrowserTest, ProfileReadmeCreated) {
temp_dir.path(), &delegate, Profile::CREATE_MODE_ASYNCHRONOUS));
ASSERT_TRUE(profile.get());
+ InitializeAllPrefStores();
+
// Wait for the profile to be created.
ui_test_utils::WindowedNotificationObserver observer(
chrome::NOTIFICATION_PROFILE_CREATED,

Powered by Google App Engine
This is Rietveld 408576698