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 // MediaFileSystemRegistry unit tests. | 5 // MediaFileSystemRegistry unit tests. |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 const std::string& fs_name); | 68 const std::string& fs_name); |
69 | 69 |
70 bool operator<(const FSInfo& other) const; | 70 bool operator<(const FSInfo& other) const; |
71 | 71 |
72 std::string device_id; | 72 std::string device_id; |
73 base::FilePath path; | 73 base::FilePath path; |
74 std::string fs_name; | 74 std::string fs_name; |
75 }; | 75 }; |
76 | 76 |
77 explicit TestMediaFileSystemContext(MediaFileSystemRegistry* registry); | 77 explicit TestMediaFileSystemContext(MediaFileSystemRegistry* registry); |
78 virtual ~TestMediaFileSystemContext() {} | 78 ~TestMediaFileSystemContext() override {} |
79 | 79 |
80 // MediaFileSystemContext implementation. | 80 // MediaFileSystemContext implementation. |
81 virtual bool RegisterFileSystem(const std::string& device_id, | 81 bool RegisterFileSystem(const std::string& device_id, |
82 const std::string& fs_name, | 82 const std::string& fs_name, |
83 const base::FilePath& path) override; | 83 const base::FilePath& path) override; |
84 | 84 |
85 virtual void RevokeFileSystem(const std::string& fs_name) override; | 85 void RevokeFileSystem(const std::string& fs_name) override; |
86 | 86 |
87 virtual base::FilePath GetRegisteredPath( | 87 base::FilePath GetRegisteredPath(const std::string& fs_name) const override; |
88 const std::string& fs_name) const override; | |
89 | 88 |
90 MediaFileSystemRegistry* registry() { return registry_; } | 89 MediaFileSystemRegistry* registry() { return registry_; } |
91 | 90 |
92 private: | 91 private: |
93 void AddFSEntry(const std::string& device_id, | 92 void AddFSEntry(const std::string& device_id, |
94 const base::FilePath& path, | 93 const base::FilePath& path, |
95 const std::string& fs_name); | 94 const std::string& fs_name); |
96 | 95 |
97 MediaFileSystemRegistry* registry_; | 96 MediaFileSystemRegistry* registry_; |
98 | 97 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 EXPECT_EQ(0UL, info.transient_device_id.size()); | 184 EXPECT_EQ(0UL, info.transient_device_id.size()); |
186 | 185 |
187 base::FilePath fsid_path = fs_context->GetRegisteredPath(info.fsid); | 186 base::FilePath fsid_path = fs_context->GetRegisteredPath(info.fsid); |
188 EXPECT_EQ(path, fsid_path); | 187 EXPECT_EQ(path, fsid_path); |
189 } | 188 } |
190 | 189 |
191 class MockProfileSharedRenderProcessHostFactory | 190 class MockProfileSharedRenderProcessHostFactory |
192 : public content::RenderProcessHostFactory { | 191 : public content::RenderProcessHostFactory { |
193 public: | 192 public: |
194 MockProfileSharedRenderProcessHostFactory() {} | 193 MockProfileSharedRenderProcessHostFactory() {} |
195 virtual ~MockProfileSharedRenderProcessHostFactory(); | 194 ~MockProfileSharedRenderProcessHostFactory() override; |
196 | 195 |
197 // RPH created with this factory are owned by it. If the RPH is destroyed | 196 // RPH created with this factory are owned by it. If the RPH is destroyed |
198 // for testing purposes, it must be removed from the factory first. | 197 // for testing purposes, it must be removed from the factory first. |
199 content::MockRenderProcessHost* ReleaseRPH( | 198 content::MockRenderProcessHost* ReleaseRPH( |
200 content::BrowserContext* browser_context); | 199 content::BrowserContext* browser_context); |
201 | 200 |
202 virtual content::RenderProcessHost* CreateRenderProcessHost( | 201 content::RenderProcessHost* CreateRenderProcessHost( |
203 content::BrowserContext* browser_context, | 202 content::BrowserContext* browser_context, |
204 content::SiteInstance* site_instance) const override; | 203 content::SiteInstance* site_instance) const override; |
205 | 204 |
206 private: | 205 private: |
207 typedef std::map<content::BrowserContext*, content::MockRenderProcessHost*> | 206 typedef std::map<content::BrowserContext*, content::MockRenderProcessHost*> |
208 ProfileRPHMap; | 207 ProfileRPHMap; |
209 mutable ProfileRPHMap rph_map_; | 208 mutable ProfileRPHMap rph_map_; |
210 | 209 |
211 DISALLOW_COPY_AND_ASSIGN(MockProfileSharedRenderProcessHostFactory); | 210 DISALLOW_COPY_AND_ASSIGN(MockProfileSharedRenderProcessHostFactory); |
212 }; | 211 }; |
(...skipping 858 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1071 fs_info.begin()->second.fsid).empty()); | 1070 fs_info.begin()->second.fsid).empty()); |
1072 | 1071 |
1073 // Revoke permission and ensure that the file system is revoked. | 1072 // Revoke permission and ensure that the file system is revoked. |
1074 SetGalleryPermission(profile_state, | 1073 SetGalleryPermission(profile_state, |
1075 profile_state->regular_permission_extension(), | 1074 profile_state->regular_permission_extension(), |
1076 device_id, | 1075 device_id, |
1077 false /*has access*/); | 1076 false /*has access*/); |
1078 EXPECT_TRUE(test_file_system_context()->GetRegisteredPath( | 1077 EXPECT_TRUE(test_file_system_context()->GetRegisteredPath( |
1079 fs_info.begin()->second.fsid).empty()); | 1078 fs_info.begin()->second.fsid).empty()); |
1080 } | 1079 } |
OLD | NEW |