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

Side by Side Diff: chrome/browser/extensions/extension_prefs_unittest.cc

Issue 8060017: Ensure that --disable-extensions disables extension prefs from being enacted (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ... Created 9 years, 2 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/auto_reset.h"
6 #include "base/command_line.h"
5 #include "base/message_loop.h" 7 #include "base/message_loop.h"
6 #include "base/path_service.h" 8 #include "base/path_service.h"
7 #include "base/scoped_temp_dir.h" 9 #include "base/scoped_temp_dir.h"
8 #include "base/stl_util.h" 10 #include "base/stl_util.h"
9 #include "base/string_number_conversions.h" 11 #include "base/string_number_conversions.h"
10 #include "base/stringprintf.h" 12 #include "base/stringprintf.h"
11 #include "chrome/browser/extensions/extension_prefs.h" 13 #include "chrome/browser/extensions/extension_prefs.h"
12 #include "chrome/browser/extensions/test_extension_prefs.h" 14 #include "chrome/browser/extensions/test_extension_prefs.h"
13 #include "chrome/browser/prefs/pref_change_registrar.h" 15 #include "chrome/browser/prefs/pref_change_registrar.h"
14 #include "chrome/browser/prefs/scoped_user_pref_update.h" 16 #include "chrome/browser/prefs/scoped_user_pref_update.h"
15 #include "chrome/common/chrome_paths.h" 17 #include "chrome/common/chrome_paths.h"
18 #include "chrome/common/chrome_switches.h"
16 #include "chrome/common/extensions/extension_constants.h" 19 #include "chrome/common/extensions/extension_constants.h"
17 #include "chrome/common/extensions/extension_permission_set.h" 20 #include "chrome/common/extensions/extension_permission_set.h"
18 #include "content/browser/browser_thread.h" 21 #include "content/browser/browser_thread.h"
19 #include "content/common/notification_details.h" 22 #include "content/common/notification_details.h"
20 #include "content/common/notification_observer_mock.h" 23 #include "content/common/notification_observer_mock.h"
21 #include "content/common/notification_source.h" 24 #include "content/common/notification_source.h"
22 #include "testing/gtest/include/gtest/gtest.h" 25 #include "testing/gtest/include/gtest/gtest.h"
23 26
24 using base::Time; 27 using base::Time;
25 using base::TimeDelta; 28 using base::TimeDelta;
(...skipping 1078 matching lines...) Expand 10 before | Expand all | Expand 10 after
1104 testing::Mock::VerifyAndClearExpectations(v1i); 1107 testing::Mock::VerifyAndClearExpectations(v1i);
1105 testing::Mock::VerifyAndClearExpectations(v2); 1108 testing::Mock::VerifyAndClearExpectations(v2);
1106 testing::Mock::VerifyAndClearExpectations(v2i); 1109 testing::Mock::VerifyAndClearExpectations(v2i);
1107 } 1110 }
1108 1111
1109 virtual void Verify() { 1112 virtual void Verify() {
1110 } 1113 }
1111 }; 1114 };
1112 TEST_F(ExtensionPrefsSetExtensionControlledPref, 1115 TEST_F(ExtensionPrefsSetExtensionControlledPref,
1113 ExtensionPrefsSetExtensionControlledPref) {} 1116 ExtensionPrefsSetExtensionControlledPref) {}
1117
1118 // Tests that the switches::kDisableExtensions command-line flag prevents
1119 // extension controlled preferences from being enacted.
1120 class ExtensionPrefsDisableExtensions
1121 : public ExtensionPrefsPreferencesBase {
1122 public:
1123 ExtensionPrefsDisableExtensions()
1124 : iteration_(0),
1125 cmd_auto_reset_(CommandLine::ForCurrentProcess(),
1126 *CommandLine::ForCurrentProcess()) {}
1127 virtual ~ExtensionPrefsDisableExtensions() {}
1128 virtual void Initialize() {
1129 InstallExtControlledPref(ext1_, kPref1, Value::CreateStringValue("val1"));
1130 // This becomes only active in the second verification phase.
1131 CommandLine::ForCurrentProcess()->AppendSwitch(
1132 switches::kDisableExtensions);
1133 }
1134 virtual void Verify() {
1135 std::string actual = prefs()->pref_service()->GetString(kPref1);
1136 if (iteration_ == 0) {
1137 EXPECT_EQ("val1", actual);
1138 ++iteration_;
1139 } else {
1140 EXPECT_EQ(kDefaultPref1, actual);
1141 }
1142 }
1143
1144 private:
1145 int iteration_;
1146 AutoReset<CommandLine> cmd_auto_reset_;
1147 };
1148 TEST_F(ExtensionPrefsDisableExtensions, ExtensionPrefsDisableExtensions) {}
OLDNEW
« chrome/browser/extensions/extension_prefs.cc ('K') | « chrome/browser/extensions/extension_prefs.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698