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 "base/run_loop.h" | 6 #include "base/run_loop.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/media_galleries/media_galleries_preferences.h" | 9 #include "chrome/browser/media_galleries/media_galleries_preferences.h" |
10 #include "chrome/browser/media_galleries/media_galleries_test_util.h" | 10 #include "chrome/browser/media_galleries/media_galleries_test_util.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 class MediaGalleriesPermissionsTest : public extensions::ExtensionPrefsTest { | 33 class MediaGalleriesPermissionsTest : public extensions::ExtensionPrefsTest { |
34 protected: | 34 protected: |
35 MediaGalleriesPermissionsTest() | 35 MediaGalleriesPermissionsTest() |
36 : file_thread_(content::BrowserThread::FILE) { | 36 : file_thread_(content::BrowserThread::FILE) { |
37 } | 37 } |
38 virtual ~MediaGalleriesPermissionsTest() {} | 38 virtual ~MediaGalleriesPermissionsTest() {} |
39 | 39 |
40 // This is the same implementation as ExtensionPrefsTest::TearDown(), except | 40 // This is the same implementation as ExtensionPrefsTest::TearDown(), except |
41 // for also resetting the ExtensionPrefs used by |gallery_prefs_| after | 41 // for also resetting the ExtensionPrefs used by |gallery_prefs_| after |
42 // TestExtensionPrefs reconstructs them. | 42 // TestExtensionPrefs reconstructs them. |
43 virtual void TearDown() OVERRIDE { | 43 virtual void TearDown() override { |
44 Verify(); | 44 Verify(); |
45 | 45 |
46 // Reset ExtensionPrefs, and re-verify. | 46 // Reset ExtensionPrefs, and re-verify. |
47 prefs_.ResetPrefRegistry(); | 47 prefs_.ResetPrefRegistry(); |
48 RegisterPreferences(prefs_.pref_registry().get()); | 48 RegisterPreferences(prefs_.pref_registry().get()); |
49 prefs_.RecreateExtensionPrefs(); | 49 prefs_.RecreateExtensionPrefs(); |
50 gallery_prefs_->SetExtensionPrefsForTesting(prefs()); | 50 gallery_prefs_->SetExtensionPrefsForTesting(prefs()); |
51 Verify(); | 51 Verify(); |
52 prefs_.pref_service()->CommitPendingWrite(); | 52 prefs_.pref_service()->CommitPendingWrite(); |
53 message_loop_.RunUntilIdle(); | 53 message_loop_.RunUntilIdle(); |
54 | 54 |
55 storage_monitor::TestStorageMonitor::Destroy(); | 55 storage_monitor::TestStorageMonitor::Destroy(); |
56 | 56 |
57 testing::Test::TearDown(); | 57 testing::Test::TearDown(); |
58 } | 58 } |
59 | 59 |
60 virtual void Initialize() OVERRIDE { | 60 virtual void Initialize() override { |
61 file_thread_.Start(); | 61 file_thread_.Start(); |
62 | 62 |
63 ASSERT_TRUE(storage_monitor::TestStorageMonitor::CreateAndInstall()); | 63 ASSERT_TRUE(storage_monitor::TestStorageMonitor::CreateAndInstall()); |
64 profile_.reset(new TestingProfile); | 64 profile_.reset(new TestingProfile); |
65 gallery_prefs_.reset(new MediaGalleriesPreferences(profile_.get())); | 65 gallery_prefs_.reset(new MediaGalleriesPreferences(profile_.get())); |
66 base::RunLoop loop; | 66 base::RunLoop loop; |
67 gallery_prefs_->EnsureInitialized(loop.QuitClosure()); | 67 gallery_prefs_->EnsureInitialized(loop.QuitClosure()); |
68 loop.Run(); | 68 loop.Run(); |
69 | 69 |
70 gallery_prefs_->SetExtensionPrefsForTesting(prefs()); | 70 gallery_prefs_->SetExtensionPrefsForTesting(prefs()); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 gallery_prefs_->RemoveGalleryPermissionsFromPrefs(3); | 103 gallery_prefs_->RemoveGalleryPermissionsFromPrefs(3); |
104 extension2_expectation_.erase(extension2_expectation_.begin() + 1); | 104 extension2_expectation_.erase(extension2_expectation_.begin() + 1); |
105 extension3_expectation_.erase(extension3_expectation_.begin()); | 105 extension3_expectation_.erase(extension3_expectation_.begin()); |
106 Verify(); | 106 Verify(); |
107 | 107 |
108 gallery_prefs_->UnsetGalleryPermissionInPrefs(extension1_id_, 1); | 108 gallery_prefs_->UnsetGalleryPermissionInPrefs(extension1_id_, 1); |
109 extension1_expectation_.erase(extension1_expectation_.begin()); | 109 extension1_expectation_.erase(extension1_expectation_.begin()); |
110 Verify(); | 110 Verify(); |
111 } | 111 } |
112 | 112 |
113 virtual void Verify() OVERRIDE { | 113 virtual void Verify() override { |
114 struct TestData { | 114 struct TestData { |
115 std::string* id; | 115 std::string* id; |
116 std::vector<MediaGalleryPermission>* expectation; | 116 std::vector<MediaGalleryPermission>* expectation; |
117 }; | 117 }; |
118 | 118 |
119 const TestData test_data[] = {{&extension1_id_, &extension1_expectation_}, | 119 const TestData test_data[] = {{&extension1_id_, &extension1_expectation_}, |
120 {&extension2_id_, &extension2_expectation_}, | 120 {&extension2_id_, &extension2_expectation_}, |
121 {&extension3_id_, &extension3_expectation_}, | 121 {&extension3_id_, &extension3_expectation_}, |
122 {&extension4_id_, &extension4_expectation_}}; | 122 {&extension4_id_, &extension4_expectation_}}; |
123 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_data); i++) { | 123 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_data); i++) { |
(...skipping 24 matching lines...) Expand all Loading... |
148 | 148 |
149 // Needed for |gallery_prefs_| to initialize correctly. | 149 // Needed for |gallery_prefs_| to initialize correctly. |
150 EnsureMediaDirectoriesExists ensure_media_directories_exists_; | 150 EnsureMediaDirectoriesExists ensure_media_directories_exists_; |
151 content::TestBrowserThread file_thread_; | 151 content::TestBrowserThread file_thread_; |
152 | 152 |
153 scoped_ptr<TestingProfile> profile_; | 153 scoped_ptr<TestingProfile> profile_; |
154 scoped_ptr<MediaGalleriesPreferences> gallery_prefs_; | 154 scoped_ptr<MediaGalleriesPreferences> gallery_prefs_; |
155 }; | 155 }; |
156 | 156 |
157 TEST_F(MediaGalleriesPermissionsTest, MediaGalleries) {} | 157 TEST_F(MediaGalleriesPermissionsTest, MediaGalleries) {} |
OLD | NEW |