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 // MediaGalleriesPreferences unit tests. | 5 // MediaGalleriesPreferences unit tests. |
6 | 6 |
7 #include "chrome/browser/media_galleries/media_galleries_preferences.h" | 7 #include "chrome/browser/media_galleries/media_galleries_preferences.h" |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 : pref_(pref), | 56 : pref_(pref), |
57 notifications_(0) {} | 57 notifications_(0) {} |
58 virtual ~MockGalleryChangeObserver() {} | 58 virtual ~MockGalleryChangeObserver() {} |
59 | 59 |
60 int notifications() const { return notifications_;} | 60 int notifications() const { return notifications_;} |
61 | 61 |
62 private: | 62 private: |
63 // MediaGalleriesPreferences::GalleryChangeObserver implementation. | 63 // MediaGalleriesPreferences::GalleryChangeObserver implementation. |
64 virtual void OnPermissionAdded(MediaGalleriesPreferences* pref, | 64 virtual void OnPermissionAdded(MediaGalleriesPreferences* pref, |
65 const std::string& extension_id, | 65 const std::string& extension_id, |
66 MediaGalleryPrefId pref_id) OVERRIDE { | 66 MediaGalleryPrefId pref_id) override { |
67 EXPECT_EQ(pref_, pref); | 67 EXPECT_EQ(pref_, pref); |
68 ++notifications_; | 68 ++notifications_; |
69 } | 69 } |
70 | 70 |
71 virtual void OnPermissionRemoved(MediaGalleriesPreferences* pref, | 71 virtual void OnPermissionRemoved(MediaGalleriesPreferences* pref, |
72 const std::string& extension_id, | 72 const std::string& extension_id, |
73 MediaGalleryPrefId pref_id) OVERRIDE { | 73 MediaGalleryPrefId pref_id) override { |
74 EXPECT_EQ(pref_, pref); | 74 EXPECT_EQ(pref_, pref); |
75 ++notifications_; | 75 ++notifications_; |
76 } | 76 } |
77 | 77 |
78 virtual void OnGalleryAdded(MediaGalleriesPreferences* pref, | 78 virtual void OnGalleryAdded(MediaGalleriesPreferences* pref, |
79 MediaGalleryPrefId pref_id) OVERRIDE { | 79 MediaGalleryPrefId pref_id) override { |
80 EXPECT_EQ(pref_, pref); | 80 EXPECT_EQ(pref_, pref); |
81 ++notifications_; | 81 ++notifications_; |
82 } | 82 } |
83 | 83 |
84 virtual void OnGalleryRemoved(MediaGalleriesPreferences* pref, | 84 virtual void OnGalleryRemoved(MediaGalleriesPreferences* pref, |
85 MediaGalleryPrefId pref_id) OVERRIDE { | 85 MediaGalleryPrefId pref_id) override { |
86 EXPECT_EQ(pref_, pref); | 86 EXPECT_EQ(pref_, pref); |
87 ++notifications_; | 87 ++notifications_; |
88 } | 88 } |
89 | 89 |
90 virtual void OnGalleryInfoUpdated(MediaGalleriesPreferences* pref, | 90 virtual void OnGalleryInfoUpdated(MediaGalleriesPreferences* pref, |
91 MediaGalleryPrefId pref_id) OVERRIDE { | 91 MediaGalleryPrefId pref_id) override { |
92 EXPECT_EQ(pref_, pref); | 92 EXPECT_EQ(pref_, pref); |
93 ++notifications_; | 93 ++notifications_; |
94 } | 94 } |
95 | 95 |
96 MediaGalleriesPreferences* pref_; | 96 MediaGalleriesPreferences* pref_; |
97 int notifications_; | 97 int notifications_; |
98 | 98 |
99 DISALLOW_COPY_AND_ASSIGN(MockGalleryChangeObserver); | 99 DISALLOW_COPY_AND_ASSIGN(MockGalleryChangeObserver); |
100 }; | 100 }; |
101 | 101 |
102 } // namespace | 102 } // namespace |
103 | 103 |
104 class MediaGalleriesPreferencesTest : public testing::Test { | 104 class MediaGalleriesPreferencesTest : public testing::Test { |
105 public: | 105 public: |
106 typedef std::map<std::string /*device id*/, MediaGalleryPrefIdSet> | 106 typedef std::map<std::string /*device id*/, MediaGalleryPrefIdSet> |
107 DeviceIdPrefIdsMap; | 107 DeviceIdPrefIdsMap; |
108 | 108 |
109 MediaGalleriesPreferencesTest() | 109 MediaGalleriesPreferencesTest() |
110 : profile_(new TestingProfile()), | 110 : profile_(new TestingProfile()), |
111 default_galleries_count_(0) { | 111 default_galleries_count_(0) { |
112 } | 112 } |
113 | 113 |
114 virtual ~MediaGalleriesPreferencesTest() { | 114 virtual ~MediaGalleriesPreferencesTest() { |
115 } | 115 } |
116 | 116 |
117 virtual void SetUp() OVERRIDE { | 117 virtual void SetUp() override { |
118 ASSERT_TRUE(TestStorageMonitor::CreateAndInstall()); | 118 ASSERT_TRUE(TestStorageMonitor::CreateAndInstall()); |
119 | 119 |
120 extensions::TestExtensionSystem* extension_system( | 120 extensions::TestExtensionSystem* extension_system( |
121 static_cast<extensions::TestExtensionSystem*>( | 121 static_cast<extensions::TestExtensionSystem*>( |
122 extensions::ExtensionSystem::Get(profile_.get()))); | 122 extensions::ExtensionSystem::Get(profile_.get()))); |
123 extension_system->CreateExtensionService( | 123 extension_system->CreateExtensionService( |
124 CommandLine::ForCurrentProcess(), base::FilePath(), false); | 124 CommandLine::ForCurrentProcess(), base::FilePath(), false); |
125 | 125 |
126 ReinitPrefsAndExpectations(); | 126 ReinitPrefsAndExpectations(); |
127 | 127 |
(...skipping 13 matching lines...) Expand all Loading... |
141 extensions::MediaGalleriesPermission::kReadPermission); | 141 extensions::MediaGalleriesPermission::kReadPermission); |
142 | 142 |
143 all_permission_extension = | 143 all_permission_extension = |
144 AddMediaGalleriesApp("all", all_permissions, profile_.get()); | 144 AddMediaGalleriesApp("all", all_permissions, profile_.get()); |
145 regular_permission_extension = | 145 regular_permission_extension = |
146 AddMediaGalleriesApp("regular", read_permissions, profile_.get()); | 146 AddMediaGalleriesApp("regular", read_permissions, profile_.get()); |
147 no_permissions_extension = | 147 no_permissions_extension = |
148 AddMediaGalleriesApp("no", read_permissions, profile_.get()); | 148 AddMediaGalleriesApp("no", read_permissions, profile_.get()); |
149 } | 149 } |
150 | 150 |
151 virtual void TearDown() OVERRIDE { | 151 virtual void TearDown() override { |
152 Verify(); | 152 Verify(); |
153 TestStorageMonitor::Destroy(); | 153 TestStorageMonitor::Destroy(); |
154 } | 154 } |
155 | 155 |
156 void ChangeMediaPathOverrides() { | 156 void ChangeMediaPathOverrides() { |
157 mock_gallery_locations_.ChangeMediaPathOverrides(); | 157 mock_gallery_locations_.ChangeMediaPathOverrides(); |
158 } | 158 } |
159 | 159 |
160 void ReinitPrefsAndExpectations() { | 160 void ReinitPrefsAndExpectations() { |
161 gallery_prefs_.reset(new MediaGalleriesPreferences(profile_.get())); | 161 gallery_prefs_.reset(new MediaGalleriesPreferences(profile_.get())); |
(...skipping 1364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1526 MediaGalleryPrefInfo::DefaultGalleryType::kNotDefault) { | 1526 MediaGalleryPrefInfo::DefaultGalleryType::kNotDefault) { |
1527 found_user_added = true; | 1527 found_user_added = true; |
1528 } | 1528 } |
1529 } | 1529 } |
1530 | 1530 |
1531 EXPECT_TRUE(found_music); | 1531 EXPECT_TRUE(found_music); |
1532 EXPECT_TRUE(found_pictures); | 1532 EXPECT_TRUE(found_pictures); |
1533 EXPECT_TRUE(found_videos); | 1533 EXPECT_TRUE(found_videos); |
1534 EXPECT_TRUE(found_user_added); | 1534 EXPECT_TRUE(found_user_added); |
1535 } | 1535 } |
OLD | NEW |