Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(176)

Side by Side Diff: webkit/fileapi/file_system_dir_url_request_job_unittest.cc

Issue 14096022: Make MountPointProvider pluggable from outside webkit/fileapi (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/file_system_dir_url_request_job.h" 5 #include "webkit/fileapi/file_system_dir_url_request_job.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/files/scoped_temp_dir.h" 10 #include "base/files/scoped_temp_dir.h"
(...skipping 12 matching lines...) Expand all
23 #include "testing/gtest/include/gtest/gtest.h" 23 #include "testing/gtest/include/gtest/gtest.h"
24 #include "third_party/icu/public/i18n/unicode/regex.h" 24 #include "third_party/icu/public/i18n/unicode/regex.h"
25 #include "webkit/fileapi/external_mount_points.h" 25 #include "webkit/fileapi/external_mount_points.h"
26 #include "webkit/fileapi/file_system_context.h" 26 #include "webkit/fileapi/file_system_context.h"
27 #include "webkit/fileapi/file_system_file_util.h" 27 #include "webkit/fileapi/file_system_file_util.h"
28 #include "webkit/fileapi/file_system_operation_context.h" 28 #include "webkit/fileapi/file_system_operation_context.h"
29 #include "webkit/fileapi/file_system_task_runners.h" 29 #include "webkit/fileapi/file_system_task_runners.h"
30 #include "webkit/fileapi/file_system_url.h" 30 #include "webkit/fileapi/file_system_url.h"
31 #include "webkit/fileapi/mock_file_system_options.h" 31 #include "webkit/fileapi/mock_file_system_options.h"
32 #include "webkit/fileapi/sandbox_mount_point_provider.h" 32 #include "webkit/fileapi/sandbox_mount_point_provider.h"
33 #include "webkit/quota/mock_special_storage_policy.h"
34 33
35 namespace fileapi { 34 namespace fileapi {
36 namespace { 35 namespace {
37 36
38 // We always use the TEMPORARY FileSystem in this test. 37 // We always use the TEMPORARY FileSystem in this test.
39 static const char kFileSystemURLPrefix[] = 38 static const char kFileSystemURLPrefix[] =
40 "filesystem:http://remote/temporary/"; 39 "filesystem:http://remote/temporary/";
41 40
42 } // namespace 41 } // namespace
43 42
44 class FileSystemDirURLRequestJobTest : public testing::Test { 43 class FileSystemDirURLRequestJobTest : public testing::Test {
45 protected: 44 protected:
46 FileSystemDirURLRequestJobTest() 45 FileSystemDirURLRequestJobTest()
47 : message_loop_(MessageLoop::TYPE_IO), // simulate an IO thread 46 : message_loop_(MessageLoop::TYPE_IO), // simulate an IO thread
48 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { 47 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {
49 } 48 }
50 49
51 virtual void SetUp() OVERRIDE { 50 virtual void SetUp() OVERRIDE {
52 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 51 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
53 52
54 special_storage_policy_ = new quota::MockSpecialStoragePolicy;
55 file_system_context_ = 53 file_system_context_ =
56 new FileSystemContext( 54 new FileSystemContext(
57 FileSystemTaskRunners::CreateMockTaskRunners(), 55 FileSystemTaskRunners::CreateMockTaskRunners(),
58 ExternalMountPoints::CreateRefCounted().get(), 56 NULL,
59 special_storage_policy_, NULL, 57 ScopedVector<FileSystemMountPointProvider>(),
58 std::vector<MountPoints*>(),
60 temp_dir_.path(), 59 temp_dir_.path(),
61 CreateAllowFileAccessOptions()); 60 CreateAllowFileAccessOptions());
62 61
63 file_system_context_->sandbox_provider()->ValidateFileSystemRoot( 62 file_system_context_->sandbox_provider()->ValidateFileSystemRoot(
64 GURL("http://remote/"), kFileSystemTypeTemporary, true, // create 63 GURL("http://remote/"), kFileSystemTypeTemporary, true, // create
65 base::Bind(&FileSystemDirURLRequestJobTest::OnValidateFileSystem, 64 base::Bind(&FileSystemDirURLRequestJobTest::OnValidateFileSystem,
66 weak_factory_.GetWeakPtr())); 65 weak_factory_.GetWeakPtr()));
67 MessageLoop::current()->RunUntilIdle(); 66 MessageLoop::current()->RunUntilIdle();
68 67
69 net::URLRequest::Deprecated::RegisterProtocolFactory( 68 net::URLRequest::Deprecated::RegisterProtocolFactory(
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 209
211 // Put the message loop at the top, so that it's the last thing deleted. 210 // Put the message loop at the top, so that it's the last thing deleted.
212 // Delete all MessageLoopProxy objects before the MessageLoop, to help prevent 211 // Delete all MessageLoopProxy objects before the MessageLoop, to help prevent
213 // leaks caused by tasks posted during shutdown. 212 // leaks caused by tasks posted during shutdown.
214 MessageLoop message_loop_; 213 MessageLoop message_loop_;
215 214
216 base::ScopedTempDir temp_dir_; 215 base::ScopedTempDir temp_dir_;
217 net::URLRequestContext empty_context_; 216 net::URLRequestContext empty_context_;
218 scoped_ptr<net::TestDelegate> delegate_; 217 scoped_ptr<net::TestDelegate> delegate_;
219 scoped_ptr<net::URLRequest> request_; 218 scoped_ptr<net::URLRequest> request_;
220 scoped_refptr<quota::MockSpecialStoragePolicy> special_storage_policy_;
221 scoped_refptr<FileSystemContext> file_system_context_; 219 scoped_refptr<FileSystemContext> file_system_context_;
222 base::WeakPtrFactory<FileSystemDirURLRequestJobTest> weak_factory_; 220 base::WeakPtrFactory<FileSystemDirURLRequestJobTest> weak_factory_;
223 221
224 static net::URLRequestJob* job_; 222 static net::URLRequestJob* job_;
225 }; 223 };
226 224
227 // static 225 // static
228 net::URLRequestJob* FileSystemDirURLRequestJobTest::job_ = NULL; 226 net::URLRequestJob* FileSystemDirURLRequestJobTest::job_ = NULL;
229 227
230 namespace { 228 namespace {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 CreateDirectory("foo"); 285 CreateDirectory("foo");
288 TestRequestNoRun(CreateFileSystemURL("foo/")); 286 TestRequestNoRun(CreateFileSystemURL("foo/"));
289 // Run StartAsync() and only StartAsync(). 287 // Run StartAsync() and only StartAsync().
290 MessageLoop::current()->DeleteSoon(FROM_HERE, request_.release()); 288 MessageLoop::current()->DeleteSoon(FROM_HERE, request_.release());
291 MessageLoop::current()->RunUntilIdle(); 289 MessageLoop::current()->RunUntilIdle();
292 // If we get here, success! we didn't crash! 290 // If we get here, success! we didn't crash!
293 } 291 }
294 292
295 } // namespace (anonymous) 293 } // namespace (anonymous)
296 } // namespace fileapi 294 } // namespace fileapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698