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 "webkit/fileapi/sandbox_mount_point_provider.h" | 5 #include "webkit/fileapi/sandbox_mount_point_provider.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
51 protected: | 51 protected: |
52 void CreateOriginTypeDirectory(const GURL& origin, | 52 void CreateOriginTypeDirectory(const GURL& origin, |
53 fileapi::FileSystemType type) { | 53 fileapi::FileSystemType type) { |
54 base::FilePath target = sandbox_provider_-> | 54 base::FilePath target = sandbox_provider_-> |
55 GetBaseDirectoryForOriginAndType(origin, type, true); | 55 GetBaseDirectoryForOriginAndType(origin, type, true); |
56 ASSERT_TRUE(!target.empty()); | 56 ASSERT_TRUE(!target.empty()); |
57 ASSERT_TRUE(file_util::DirectoryExists(target)); | 57 ASSERT_TRUE(file_util::DirectoryExists(target)); |
58 } | 58 } |
59 | 59 |
60 base::ScopedTempDir data_dir_; | 60 base::ScopedTempDir data_dir_; |
61 MessageLoop message_loop_; | 61 base::MessageLoop message_loop_; |
62 scoped_ptr<SandboxMountPointProvider> sandbox_provider_; | 62 scoped_ptr<SandboxMountPointProvider> sandbox_provider_; |
63 }; | 63 }; |
64 | 64 |
65 TEST_F(SandboxMountPointProviderOriginEnumeratorTest, Empty) { | 65 TEST_F(SandboxMountPointProviderOriginEnumeratorTest, Empty) { |
66 scoped_ptr<SandboxMountPointProvider::OriginEnumerator> enumerator( | 66 scoped_ptr<SandboxMountPointProvider::OriginEnumerator> enumerator( |
67 CreateEnumerator()); | 67 CreateEnumerator()); |
68 ASSERT_TRUE(enumerator->Next().is_empty()); | 68 ASSERT_TRUE(enumerator->Next().is_empty()); |
69 } | 69 } |
70 | 70 |
71 TEST_F(SandboxMountPointProviderOriginEnumeratorTest, EnumerateOrigins) { | 71 TEST_F(SandboxMountPointProviderOriginEnumeratorTest, EnumerateOrigins) { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
110 ASSERT_TRUE(persistent_set.find(current) != persistent_set.end()); | 110 ASSERT_TRUE(persistent_set.find(current) != persistent_set.end()); |
111 ++persistent_actual_size; | 111 ++persistent_actual_size; |
112 } | 112 } |
113 } | 113 } |
114 | 114 |
115 EXPECT_EQ(temporary_size, temporary_actual_size); | 115 EXPECT_EQ(temporary_size, temporary_actual_size); |
116 EXPECT_EQ(persistent_size, persistent_actual_size); | 116 EXPECT_EQ(persistent_size, persistent_actual_size); |
117 } | 117 } |
118 | 118 |
119 TEST(SandboxMountPointProviderTest, AccessPermissions) { | 119 TEST(SandboxMountPointProviderTest, AccessPermissions) { |
120 MessageLoop message_loop_; | 120 base::MessageLoop message_loop_; |
121 SandboxMountPointProvider provider( | 121 SandboxMountPointProvider provider(NULL, |
brettw
2013/05/06 17:43:33
You didn't need to change this statement at all, I
xhwang
2013/05/07 00:11:07
Done.
| |
122 NULL, base::MessageLoopProxy::current(), base::FilePath(), | 122 base::MessageLoopProxy::current(), |
123 CreateAllowFileAccessOptions(), NULL); | 123 base::FilePath(), |
124 CreateAllowFileAccessOptions(), | |
125 NULL); | |
124 | 126 |
125 // Any access should be allowed in sandbox directory. | 127 // Any access should be allowed in sandbox directory. |
126 EXPECT_EQ(FILE_PERMISSION_ALWAYS_ALLOW, | 128 EXPECT_EQ(FILE_PERMISSION_ALWAYS_ALLOW, |
127 provider.GetPermissionPolicy(CreateFileSystemURL("foo"), | 129 provider.GetPermissionPolicy(CreateFileSystemURL("foo"), |
128 kReadFilePermissions)); | 130 kReadFilePermissions)); |
129 EXPECT_EQ(FILE_PERMISSION_ALWAYS_ALLOW, | 131 EXPECT_EQ(FILE_PERMISSION_ALWAYS_ALLOW, |
130 provider.GetPermissionPolicy(CreateFileSystemURL("foo"), | 132 provider.GetPermissionPolicy(CreateFileSystemURL("foo"), |
131 kWriteFilePermissions)); | 133 kWriteFilePermissions)); |
132 EXPECT_EQ(FILE_PERMISSION_ALWAYS_ALLOW, | 134 EXPECT_EQ(FILE_PERMISSION_ALWAYS_ALLOW, |
133 provider.GetPermissionPolicy(CreateFileSystemURL("foo"), | 135 provider.GetPermissionPolicy(CreateFileSystemURL("foo"), |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
193 provider.GetPermissionPolicy(CreateFileSystemURL(".b"), | 195 provider.GetPermissionPolicy(CreateFileSystemURL(".b"), |
194 kCreateFilePermissions)); | 196 kCreateFilePermissions)); |
195 | 197 |
196 // A path that looks like a drive letter. | 198 // A path that looks like a drive letter. |
197 EXPECT_EQ(FILE_PERMISSION_ALWAYS_ALLOW, | 199 EXPECT_EQ(FILE_PERMISSION_ALWAYS_ALLOW, |
198 provider.GetPermissionPolicy(CreateFileSystemURL("c:"), | 200 provider.GetPermissionPolicy(CreateFileSystemURL("c:"), |
199 kCreateFilePermissions)); | 201 kCreateFilePermissions)); |
200 } | 202 } |
201 | 203 |
202 } // namespace fileapi | 204 } // namespace fileapi |
OLD | NEW |