| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "extension_prefs_unittest.h" | 5 #include "extension_prefs_unittest.h" |
| 6 | 6 |
| 7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
| 8 #include "base/scoped_temp_dir.h" | 8 #include "base/scoped_temp_dir.h" |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
| 11 #include "base/stringprintf.h" | 11 #include "base/stringprintf.h" |
| 12 #include "base/values.h" | 12 #include "base/values.h" |
| 13 #include "chrome/browser/extensions/extension_prefs.h" | 13 #include "chrome/browser/extensions/extension_prefs.h" |
| 14 #include "chrome/browser/extensions/extension_pref_value_map.h" | 14 #include "chrome/browser/extensions/extension_pref_value_map.h" |
| 15 #include "chrome/browser/prefs/pref_change_registrar.h" | 15 #include "chrome/browser/prefs/pref_change_registrar.h" |
| 16 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 16 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
| 17 #include "chrome/common/chrome_paths.h" | 17 #include "chrome/common/chrome_paths.h" |
| 18 #include "chrome/common/extensions/extension_manifest_constants.h" | 18 #include "chrome/common/extensions/extension_manifest_constants.h" |
| 19 #include "chrome/common/extensions/extension_permission_set.h" | 19 #include "chrome/common/extensions/extension_permission_set.h" |
| 20 #include "chrome/common/string_ordinal.h" | 20 #include "chrome/common/string_ordinal.h" |
| 21 #include "content/public/browser/notification_details.h" | 21 #include "content/public/browser/notification_details.h" |
| 22 #include "content/public/browser/notification_source.h" | 22 #include "content/public/browser/notification_source.h" |
| 23 #include "content/test/notification_observer_mock.h" | 23 #include "content/public/test/mock_notification_observer.h" |
| 24 | 24 |
| 25 using base::Time; | 25 using base::Time; |
| 26 using base::TimeDelta; | 26 using base::TimeDelta; |
| 27 using content::BrowserThread; | 27 using content::BrowserThread; |
| 28 using extensions::Extension; | 28 using extensions::Extension; |
| 29 using extensions::ExtensionList; | 29 using extensions::ExtensionList; |
| 30 | 30 |
| 31 namespace { | 31 namespace { |
| 32 | 32 |
| 33 const char kPref1[] = "path1.subpath"; | 33 const char kPref1[] = "path1.subpath"; |
| (...skipping 926 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 960 TEST_F(ExtensionPrefsUninstallExtension, | 960 TEST_F(ExtensionPrefsUninstallExtension, |
| 961 ExtensionPrefsUninstallExtension) {} | 961 ExtensionPrefsUninstallExtension) {} |
| 962 | 962 |
| 963 // Tests triggering of notifications to registered observers. | 963 // Tests triggering of notifications to registered observers. |
| 964 class ExtensionPrefsNotifyWhenNeeded : public ExtensionPrefsPrepopulatedTest { | 964 class ExtensionPrefsNotifyWhenNeeded : public ExtensionPrefsPrepopulatedTest { |
| 965 virtual void Initialize() { | 965 virtual void Initialize() { |
| 966 using testing::_; | 966 using testing::_; |
| 967 using testing::Mock; | 967 using testing::Mock; |
| 968 using testing::StrEq; | 968 using testing::StrEq; |
| 969 | 969 |
| 970 content::NotificationObserverMock observer; | 970 content::MockNotificationObserver observer; |
| 971 PrefChangeRegistrar registrar; | 971 PrefChangeRegistrar registrar; |
| 972 registrar.Init(prefs()->pref_service()); | 972 registrar.Init(prefs()->pref_service()); |
| 973 registrar.Add(kPref1, &observer); | 973 registrar.Add(kPref1, &observer); |
| 974 | 974 |
| 975 content::NotificationObserverMock incognito_observer; | 975 content::MockNotificationObserver incognito_observer; |
| 976 scoped_ptr<PrefService> incog_prefs(prefs_.CreateIncognitoPrefService()); | 976 scoped_ptr<PrefService> incog_prefs(prefs_.CreateIncognitoPrefService()); |
| 977 PrefChangeRegistrar incognito_registrar; | 977 PrefChangeRegistrar incognito_registrar; |
| 978 incognito_registrar.Init(incog_prefs.get()); | 978 incognito_registrar.Init(incog_prefs.get()); |
| 979 incognito_registrar.Add(kPref1, &incognito_observer); | 979 incognito_registrar.Add(kPref1, &incognito_observer); |
| 980 | 980 |
| 981 // Write value and check notification. | 981 // Write value and check notification. |
| 982 EXPECT_CALL(observer, Observe(_, _, _)); | 982 EXPECT_CALL(observer, Observe(_, _, _)); |
| 983 EXPECT_CALL(incognito_observer, Observe(_, _, _)); | 983 EXPECT_CALL(incognito_observer, Observe(_, _, _)); |
| 984 InstallExtControlledPref(ext1_, kPref1, | 984 InstallExtControlledPref(ext1_, kPref1, |
| 985 Value::CreateStringValue("https://www.chromium.org")); | 985 Value::CreateStringValue("https://www.chromium.org")); |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1198 string16 error16; | 1198 string16 error16; |
| 1199 EXPECT_TRUE(prefs()->UserMayLoad(extension_.get(), &error16)); | 1199 EXPECT_TRUE(prefs()->UserMayLoad(extension_.get(), &error16)); |
| 1200 EXPECT_EQ(string16(), error16); | 1200 EXPECT_EQ(string16(), error16); |
| 1201 EXPECT_TRUE(prefs()->UserMayModifySettings(extension_.get(), &error16)); | 1201 EXPECT_TRUE(prefs()->UserMayModifySettings(extension_.get(), &error16)); |
| 1202 EXPECT_EQ(string16(), error16); | 1202 EXPECT_EQ(string16(), error16); |
| 1203 EXPECT_FALSE(prefs()->MustRemainEnabled(extension_.get(), &error16)); | 1203 EXPECT_FALSE(prefs()->MustRemainEnabled(extension_.get(), &error16)); |
| 1204 EXPECT_EQ(string16(), error16); | 1204 EXPECT_EQ(string16(), error16); |
| 1205 } | 1205 } |
| 1206 }; | 1206 }; |
| 1207 TEST_F(ExtensionPrefsNotRequiredExtension, NotRequiredExtension) {} | 1207 TEST_F(ExtensionPrefsNotRequiredExtension, NotRequiredExtension) {} |
| OLD | NEW |