Reinitialize LocalState's CommandLinePrefStore after about_flags updates the command line. Otherwise flags set in about:flags are ignored by the LocalState.
BUG=none
TEST=none
Review URL: https://chromiumcodereview.appspot.com/9251026
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@118926 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/prefs/pref_service_unittest.cc b/chrome/browser/prefs/pref_service_unittest.cc
index de2060d..3c04dd2 100644
--- a/chrome/browser/prefs/pref_service_unittest.cc
+++ b/chrome/browser/prefs/pref_service_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -22,7 +22,6 @@
#include "chrome/common/pref_names.h"
#include "chrome/test/base/chrome_render_view_host_test_harness.h"
#include "chrome/test/base/testing_pref_service.h"
-#include "chrome/test/base/testing_pref_service.h"
#include "chrome/test/base/testing_profile.h"
#include "content/browser/tab_contents/test_tab_contents.h"
#include "content/test/test_browser_thread.h"
@@ -150,6 +149,37 @@
EXPECT_EQ(kTestValue, actual_int_value);
}
+TEST(PrefServiceTest, UpdateCommandLinePrefStore) {
+ TestingPrefService prefs;
+ prefs.RegisterBooleanPref(prefs::kCloudPrintProxyEnabled, false);
+
+ // Check to make sure the value is as expected.
+ const PrefService::Preference* pref =
+ prefs.FindPreference(prefs::kCloudPrintProxyEnabled);
+ ASSERT_TRUE(pref);
+ const Value* value = pref->GetValue();
+ ASSERT_TRUE(value);
+ EXPECT_EQ(Value::TYPE_BOOLEAN, value->GetType());
+ bool actual_bool_value = true;
+ EXPECT_TRUE(value->GetAsBoolean(&actual_bool_value));
+ EXPECT_EQ(false, actual_bool_value);
+
+ // Change the command line.
+ CommandLine cmd_line(CommandLine::NO_PROGRAM);
+ cmd_line.AppendSwitch(switches::kEnableCloudPrintProxy);
+
+ // Call UpdateCommandLinePrefStore and check to see if the value has changed.
+ prefs.UpdateCommandLinePrefStore(&cmd_line);
+ pref = prefs.FindPreference(prefs::kCloudPrintProxyEnabled);
+ ASSERT_TRUE(pref);
+ value = pref->GetValue();
+ ASSERT_TRUE(value);
+ EXPECT_EQ(Value::TYPE_BOOLEAN, value->GetType());
+ actual_bool_value = false;
+ EXPECT_TRUE(value->GetAsBoolean(&actual_bool_value));
+ EXPECT_EQ(true, actual_bool_value);
+}
+
class PrefServiceSetValueTest : public testing::Test {
protected:
static const char kName[];