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

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

Issue 7633016: Test cleanup: Using MockSpecialStoragePolicy instead of local subclasses of SpecialStoragePolicy. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Keeping up to date with trunk. Created 9 years, 4 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // NOTE: These tests are run as part of "unit_tests" (in chrome/test/unit) 5 // NOTE: These tests are run as part of "unit_tests" (in chrome/test/unit)
6 // rather than as part of test_shell_tests because they rely on being able 6 // rather than as part of test_shell_tests because they rely on being able
7 // to instantiate a MessageLoop of type TYPE_IO. test_shell_tests uses 7 // to instantiate a MessageLoop of type TYPE_IO. test_shell_tests uses
8 // TYPE_UI, which URLRequest doesn't allow. 8 // TYPE_UI, which URLRequest doesn't allow.
9 // 9 //
10 10
(...skipping 15 matching lines...) Expand all
26 #include "net/http/http_request_headers.h" 26 #include "net/http/http_request_headers.h"
27 #include "net/url_request/url_request.h" 27 #include "net/url_request/url_request.h"
28 #include "net/url_request/url_request_test_util.h" 28 #include "net/url_request/url_request_test_util.h"
29 #include "testing/gtest/include/gtest/gtest.h" 29 #include "testing/gtest/include/gtest/gtest.h"
30 #include "unicode/regex.h" 30 #include "unicode/regex.h"
31 #include "webkit/fileapi/file_system_context.h" 31 #include "webkit/fileapi/file_system_context.h"
32 #include "webkit/fileapi/file_system_file_util.h" 32 #include "webkit/fileapi/file_system_file_util.h"
33 #include "webkit/fileapi/file_system_operation_context.h" 33 #include "webkit/fileapi/file_system_operation_context.h"
34 #include "webkit/fileapi/file_system_path_manager.h" 34 #include "webkit/fileapi/file_system_path_manager.h"
35 #include "webkit/fileapi/sandbox_mount_point_provider.h" 35 #include "webkit/fileapi/sandbox_mount_point_provider.h"
36 #include "webkit/quota/mock_special_storage_policy.h"
36 37
37 namespace fileapi { 38 namespace fileapi {
38 namespace { 39 namespace {
39 40
40 // We always use the TEMPORARY FileSystem in this test. 41 // We always use the TEMPORARY FileSystem in this test.
41 static const char kFileSystemURLPrefix[] = 42 static const char kFileSystemURLPrefix[] =
42 "filesystem:http://remote/temporary/"; 43 "filesystem:http://remote/temporary/";
43 44
44 class TestSpecialStoragePolicy : public quota::SpecialStoragePolicy {
45 public:
46 virtual bool IsStorageProtected(const GURL& origin) {
47 return false;
48 }
49
50 virtual bool IsStorageUnlimited(const GURL& origin) {
51 return true;
52 }
53
54 virtual bool IsFileHandler(const std::string& extension_id) {
55 return true;
56 }
57 };
58
59 } // namespace 45 } // namespace
60 46
61 class FileSystemDirURLRequestJobTest : public testing::Test { 47 class FileSystemDirURLRequestJobTest : public testing::Test {
62 protected: 48 protected:
63 FileSystemDirURLRequestJobTest() 49 FileSystemDirURLRequestJobTest()
64 : message_loop_(MessageLoop::TYPE_IO), // simulate an IO thread 50 : message_loop_(MessageLoop::TYPE_IO), // simulate an IO thread
65 ALLOW_THIS_IN_INITIALIZER_LIST(callback_factory_(this)) { 51 ALLOW_THIS_IN_INITIALIZER_LIST(callback_factory_(this)) {
66 } 52 }
67 53
68 virtual void SetUp() { 54 virtual void SetUp() {
69 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 55 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
70 56
71 file_thread_proxy_ = base::MessageLoopProxy::current(); 57 file_thread_proxy_ = base::MessageLoopProxy::current();
72 58
73 special_storage_policy_ = new TestSpecialStoragePolicy(); 59 special_storage_policy_ = new quota::MockSpecialStoragePolicy;
74 file_system_context_ = 60 file_system_context_ =
75 new FileSystemContext( 61 new FileSystemContext(
76 base::MessageLoopProxy::current(), 62 base::MessageLoopProxy::current(),
77 base::MessageLoopProxy::current(), 63 base::MessageLoopProxy::current(),
78 special_storage_policy_, NULL, 64 special_storage_policy_, NULL,
79 FilePath(), false /* is_incognito */, 65 FilePath(), false /* is_incognito */,
80 false, true, 66 false, true,
81 new FileSystemPathManager( 67 new FileSystemPathManager(
82 file_thread_proxy_, temp_dir_.path(), 68 file_thread_proxy_, temp_dir_.path(),
83 NULL, false, false)); 69 NULL, false, false));
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 // Put the message loop at the top, so that it's the last thing deleted. 209 // Put the message loop at the top, so that it's the last thing deleted.
224 MessageLoop message_loop_; 210 MessageLoop message_loop_;
225 // Delete all MessageLoopProxy objects before the MessageLoop, to help prevent 211 // Delete all MessageLoopProxy objects before the MessageLoop, to help prevent
226 // leaks caused by tasks posted during shutdown. 212 // leaks caused by tasks posted during shutdown.
227 scoped_refptr<base::MessageLoopProxy> file_thread_proxy_; 213 scoped_refptr<base::MessageLoopProxy> file_thread_proxy_;
228 214
229 ScopedTempDir temp_dir_; 215 ScopedTempDir temp_dir_;
230 FilePath root_path_; 216 FilePath root_path_;
231 scoped_ptr<net::URLRequest> request_; 217 scoped_ptr<net::URLRequest> request_;
232 scoped_ptr<TestDelegate> delegate_; 218 scoped_ptr<TestDelegate> delegate_;
233 scoped_refptr<TestSpecialStoragePolicy> special_storage_policy_; 219 scoped_refptr<quota::MockSpecialStoragePolicy> special_storage_policy_;
234 scoped_refptr<FileSystemContext> file_system_context_; 220 scoped_refptr<FileSystemContext> file_system_context_;
235 base::ScopedCallbackFactory<FileSystemDirURLRequestJobTest> callback_factory_; 221 base::ScopedCallbackFactory<FileSystemDirURLRequestJobTest> callback_factory_;
236 222
237 static net::URLRequestJob* job_; 223 static net::URLRequestJob* job_;
238 }; 224 };
239 225
240 // static 226 // static
241 net::URLRequestJob* FileSystemDirURLRequestJobTest::job_ = NULL; 227 net::URLRequestJob* FileSystemDirURLRequestJobTest::job_ = NULL;
242 228
243 namespace { 229 namespace {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 MessageLoop::current()->PostTask(FROM_HERE, new QuitNowTask); 296 MessageLoop::current()->PostTask(FROM_HERE, new QuitNowTask);
311 MessageLoop::current()->Run(); 297 MessageLoop::current()->Run();
312 298
313 request_.reset(); 299 request_.reset();
314 MessageLoop::current()->RunAllPending(); 300 MessageLoop::current()->RunAllPending();
315 // If we get here, success! we didn't crash! 301 // If we get here, success! we didn't crash!
316 } 302 }
317 303
318 } // namespace (anonymous) 304 } // namespace (anonymous)
319 } // namespace fileapi 305 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/fileapi/file_system_context_unittest.cc ('k') | webkit/fileapi/file_system_path_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698