| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
| 6 #include "chrome/browser/extensions/extension_prefs.h" | 6 #include "chrome/browser/extensions/extension_prefs.h" |
| 7 #include "chrome/browser/extensions/extension_prefs_unittest.h" | 7 #include "chrome/browser/extensions/extension_prefs_unittest.h" |
| 8 #include "chrome/browser/extensions/extension_service.h" | 8 #include "chrome/browser/extensions/extension_service.h" |
| 9 #include "chrome/browser/extensions/extension_system.h" | 9 #include "chrome/browser/extensions/extension_system.h" |
| 10 #include "chrome/browser/media_galleries/media_galleries_preferences.h" | 10 #include "chrome/browser/media_galleries/media_galleries_preferences.h" |
| 11 #include "chrome/browser/storage_monitor/test_storage_monitor.h" | 11 #include "chrome/browser/storage_monitor/test_storage_monitor.h" |
| 12 #include "chrome/test/base/testing_profile.h" | 12 #include "chrome/test/base/testing_profile.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 | 14 |
| 15 namespace chrome { | |
| 16 | |
| 17 namespace { | 15 namespace { |
| 18 | 16 |
| 19 void AddGalleryPermission(MediaGalleryPrefId gallery, | 17 void AddGalleryPermission(MediaGalleryPrefId gallery, |
| 20 bool has_access, | 18 bool has_access, |
| 21 std::vector<MediaGalleryPermission>* vector) { | 19 std::vector<MediaGalleryPermission>* vector) { |
| 22 MediaGalleryPermission permission; | 20 MediaGalleryPermission permission; |
| 23 permission.pref_id = gallery; | 21 permission.pref_id = gallery; |
| 24 permission.has_permission = has_access; | 22 permission.has_permission = has_access; |
| 25 vector->push_back(permission); | 23 vector->push_back(permission); |
| 26 } | 24 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 41 | 39 |
| 42 // Reset ExtensionPrefs, and re-verify. | 40 // Reset ExtensionPrefs, and re-verify. |
| 43 prefs_.ResetPrefRegistry(); | 41 prefs_.ResetPrefRegistry(); |
| 44 RegisterPreferences(prefs_.pref_registry().get()); | 42 RegisterPreferences(prefs_.pref_registry().get()); |
| 45 prefs_.RecreateExtensionPrefs(); | 43 prefs_.RecreateExtensionPrefs(); |
| 46 gallery_prefs_->SetExtensionPrefsForTesting(prefs()); | 44 gallery_prefs_->SetExtensionPrefsForTesting(prefs()); |
| 47 Verify(); | 45 Verify(); |
| 48 prefs_.pref_service()->CommitPendingWrite(); | 46 prefs_.pref_service()->CommitPendingWrite(); |
| 49 message_loop_.RunUntilIdle(); | 47 message_loop_.RunUntilIdle(); |
| 50 | 48 |
| 51 test::TestStorageMonitor::RemoveSingleton(); | 49 TestStorageMonitor::RemoveSingleton(); |
| 52 | 50 |
| 53 testing::Test::TearDown(); | 51 testing::Test::TearDown(); |
| 54 } | 52 } |
| 55 | 53 |
| 56 virtual void Initialize() OVERRIDE { | 54 virtual void Initialize() OVERRIDE { |
| 57 ASSERT_TRUE(test::TestStorageMonitor::CreateAndInstall()); | 55 ASSERT_TRUE(TestStorageMonitor::CreateAndInstall()); |
| 58 profile_.reset(new TestingProfile); | 56 profile_.reset(new TestingProfile); |
| 59 gallery_prefs_.reset(new MediaGalleriesPreferences(profile_.get())); | 57 gallery_prefs_.reset(new MediaGalleriesPreferences(profile_.get())); |
| 60 gallery_prefs_->SetExtensionPrefsForTesting(prefs()); | 58 gallery_prefs_->SetExtensionPrefsForTesting(prefs()); |
| 61 | 59 |
| 62 extension1_id_ = prefs_.AddExtensionAndReturnId("test1"); | 60 extension1_id_ = prefs_.AddExtensionAndReturnId("test1"); |
| 63 extension2_id_ = prefs_.AddExtensionAndReturnId("test2"); | 61 extension2_id_ = prefs_.AddExtensionAndReturnId("test2"); |
| 64 extension3_id_ = prefs_.AddExtensionAndReturnId("test3"); | 62 extension3_id_ = prefs_.AddExtensionAndReturnId("test3"); |
| 65 // Id4 isn't used to ensure that an empty permission list is ok. | 63 // Id4 isn't used to ensure that an empty permission list is ok. |
| 66 extension4_id_ = prefs_.AddExtensionAndReturnId("test4"); | 64 extension4_id_ = prefs_.AddExtensionAndReturnId("test4"); |
| 67 Verify(); | 65 Verify(); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 std::string extension4_id_; | 130 std::string extension4_id_; |
| 133 | 131 |
| 134 std::vector<MediaGalleryPermission> extension1_expectation_; | 132 std::vector<MediaGalleryPermission> extension1_expectation_; |
| 135 std::vector<MediaGalleryPermission> extension2_expectation_; | 133 std::vector<MediaGalleryPermission> extension2_expectation_; |
| 136 std::vector<MediaGalleryPermission> extension3_expectation_; | 134 std::vector<MediaGalleryPermission> extension3_expectation_; |
| 137 std::vector<MediaGalleryPermission> extension4_expectation_; | 135 std::vector<MediaGalleryPermission> extension4_expectation_; |
| 138 | 136 |
| 139 scoped_ptr<TestingProfile> profile_; | 137 scoped_ptr<TestingProfile> profile_; |
| 140 scoped_ptr<MediaGalleriesPreferences> gallery_prefs_; | 138 scoped_ptr<MediaGalleriesPreferences> gallery_prefs_; |
| 141 }; | 139 }; |
| 140 |
| 142 TEST_F(MediaGalleriesPermissionsTest, MediaGalleries) {} | 141 TEST_F(MediaGalleriesPermissionsTest, MediaGalleries) {} |
| 143 | |
| 144 } // namespace chrome | |
| OLD | NEW |