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

Unified Diff: chrome/browser/prefs/pref_service_unittest.cc

Issue 9251026: Reinitialize LocalState's CommandLinePrefStore after about_flags updates the command line. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 8 years, 11 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/prefs/pref_service_unittest.cc
===================================================================
--- chrome/browser/prefs/pref_service_unittest.cc (revision 118120)
+++ chrome/browser/prefs/pref_service_unittest.cc (working copy)
@@ -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.
@@ -8,6 +8,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/utf_string_conversions.h"
#include "base/values.h"
+#include "chrome/browser/about_flags.h"
#include "chrome/browser/policy/configuration_policy_pref_store.h"
#include "chrome/browser/policy/mock_configuration_policy_provider.h"
#include "chrome/browser/prefs/browser_prefs.h"
@@ -22,7 +23,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 +150,40 @@
EXPECT_EQ(kTestValue, actual_int_value);
}
+TEST(PrefServiceTest, UpdateCommandLinePrefStore) {
+ TestingPrefService prefs;
+ prefs.RegisterBooleanPref(prefs::kCloudPrintProxyEnabled, false);
+ const CommandLine::CharType* argv[] = { FILE_PATH_LITERAL("program") };
Nico 2012/01/19 00:39:18 I think the usual pattern is CommandLine command_
Lei Zhang 2012/01/19 01:10:29 Done.
+
+ // 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(arraysize(argv), argv);
+ cmd_line.AppendSwitch(switches::kEnableCloudPrintProxy);
+ prefs.RegisterListPref(prefs::kEnabledLabsExperiments);
+ about_flags::ConvertFlagsToSwitches(&prefs, &cmd_line);
+
Nico 2012/01/19 00:39:18 Do you want to check if ConvertFlagsToSwiches() ad
Lei Zhang 2012/01/19 01:10:29 Actually, i don't need about_flags in this test, s
+ // 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[];

Powered by Google App Engine
This is Rietveld 408576698