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

Side by Side Diff: content/browser/fileapi/file_system_dir_url_request_job_unittest.cc

Issue 137923003: Change fileapi namespace to content for files that are moved under content/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: build fix Created 6 years, 11 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/browser/fileapi/file_system_dir_url_request_job.h" 5 #include "webkit/browser/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 13 matching lines...) Expand all
24 #include "net/url_request/url_request_context.h" 24 #include "net/url_request/url_request_context.h"
25 #include "net/url_request/url_request_test_util.h" 25 #include "net/url_request/url_request_test_util.h"
26 #include "testing/gtest/include/gtest/gtest.h" 26 #include "testing/gtest/include/gtest/gtest.h"
27 #include "third_party/icu/source/i18n/unicode/regex.h" 27 #include "third_party/icu/source/i18n/unicode/regex.h"
28 #include "webkit/browser/fileapi/file_system_context.h" 28 #include "webkit/browser/fileapi/file_system_context.h"
29 #include "webkit/browser/fileapi/file_system_file_util.h" 29 #include "webkit/browser/fileapi/file_system_file_util.h"
30 #include "webkit/browser/fileapi/file_system_operation_context.h" 30 #include "webkit/browser/fileapi/file_system_operation_context.h"
31 #include "webkit/browser/fileapi/file_system_url.h" 31 #include "webkit/browser/fileapi/file_system_url.h"
32 #include "webkit/browser/quota/mock_special_storage_policy.h" 32 #include "webkit/browser/quota/mock_special_storage_policy.h"
33 33
34 namespace fileapi { 34 using fileapi::FileSystemContext;
35 using fileapi::FileSystemOperationContext;
36 using fileapi::FileSystemURL;
37
38 namespace content {
35 namespace { 39 namespace {
36 40
37 // We always use the TEMPORARY FileSystem in this test. 41 // We always use the TEMPORARY FileSystem in this test.
38 static const char kFileSystemURLPrefix[] = 42 static const char kFileSystemURLPrefix[] =
39 "filesystem:http://remote/temporary/"; 43 "filesystem:http://remote/temporary/";
40 44
41 } // namespace 45 } // namespace
42 46
43 class FileSystemDirURLRequestJobTest : public testing::Test { 47 class FileSystemDirURLRequestJobTest : public testing::Test {
44 protected: 48 protected:
45 FileSystemDirURLRequestJobTest() 49 FileSystemDirURLRequestJobTest()
46 : weak_factory_(this) { 50 : weak_factory_(this) {
47 } 51 }
48 52
49 virtual void SetUp() OVERRIDE { 53 virtual void SetUp() OVERRIDE {
50 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 54 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
51 55
52 special_storage_policy_ = new quota::MockSpecialStoragePolicy; 56 special_storage_policy_ = new quota::MockSpecialStoragePolicy;
53 file_system_context_ = CreateFileSystemContextForTesting( 57 file_system_context_ = CreateFileSystemContextForTesting(
54 NULL, temp_dir_.path()); 58 NULL, temp_dir_.path());
55 59
56 file_system_context_->OpenFileSystem( 60 file_system_context_->OpenFileSystem(
57 GURL("http://remote/"), kFileSystemTypeTemporary, 61 GURL("http://remote/"), fileapi::kFileSystemTypeTemporary,
58 OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT, 62 fileapi::OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT,
59 base::Bind(&FileSystemDirURLRequestJobTest::OnOpenFileSystem, 63 base::Bind(&FileSystemDirURLRequestJobTest::OnOpenFileSystem,
60 weak_factory_.GetWeakPtr())); 64 weak_factory_.GetWeakPtr()));
61 base::RunLoop().RunUntilIdle(); 65 base::RunLoop().RunUntilIdle();
62 66
63 net::URLRequest::Deprecated::RegisterProtocolFactory( 67 net::URLRequest::Deprecated::RegisterProtocolFactory(
64 "filesystem", &FileSystemDirURLRequestJobFactory); 68 "filesystem", &FileSystemDirURLRequestJobFactory);
65 } 69 }
66 70
67 virtual void TearDown() OVERRIDE { 71 virtual void TearDown() OVERRIDE {
68 // NOTE: order matters, request must die before delegate 72 // NOTE: order matters, request must die before delegate
69 request_.reset(NULL); 73 request_.reset(NULL);
70 delegate_.reset(NULL); 74 delegate_.reset(NULL);
71 75
72 net::URLRequest::Deprecated::RegisterProtocolFactory("filesystem", NULL); 76 net::URLRequest::Deprecated::RegisterProtocolFactory("filesystem", NULL);
73 ClearUnusedJob(); 77 ClearUnusedJob();
74 } 78 }
75 79
76 void OnOpenFileSystem(const GURL& root_url, 80 void OnOpenFileSystem(const GURL& root_url,
77 const std::string& name, 81 const std::string& name,
78 base::PlatformFileError result) { 82 base::PlatformFileError result) {
79 ASSERT_EQ(base::PLATFORM_FILE_OK, result); 83 ASSERT_EQ(base::PLATFORM_FILE_OK, result);
80 } 84 }
81 85
82 void TestRequestHelper(const GURL& url, bool run_to_completion, 86 void TestRequestHelper(const GURL& url, bool run_to_completion,
83 FileSystemContext* file_system_context) { 87 FileSystemContext* file_system_context) {
84 delegate_.reset(new net::TestDelegate()); 88 delegate_.reset(new net::TestDelegate());
85 delegate_->set_quit_on_redirect(true); 89 delegate_->set_quit_on_redirect(true);
86 request_ = empty_context_.CreateRequest( 90 request_ = empty_context_.CreateRequest(
87 url, net::DEFAULT_PRIORITY, delegate_.get()); 91 url, net::DEFAULT_PRIORITY, delegate_.get());
88 job_ = new FileSystemDirURLRequestJob( 92 job_ = new fileapi::FileSystemDirURLRequestJob(
89 request_.get(), NULL, file_system_context); 93 request_.get(), NULL, file_system_context);
90 94
91 request_->Start(); 95 request_->Start();
92 ASSERT_TRUE(request_->is_pending()); // verify that we're starting async 96 ASSERT_TRUE(request_->is_pending()); // verify that we're starting async
93 if (run_to_completion) 97 if (run_to_completion)
94 base::MessageLoop::current()->Run(); 98 base::MessageLoop::current()->Run();
95 } 99 }
96 100
97 void TestRequest(const GURL& url) { 101 void TestRequest(const GURL& url) {
98 TestRequestHelper(url, true, file_system_context_.get()); 102 TestRequestHelper(url, true, file_system_context_.get());
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 return temp; 203 return temp;
200 } 204 }
201 205
202 static void ClearUnusedJob() { 206 static void ClearUnusedJob() {
203 if (job_) { 207 if (job_) {
204 scoped_refptr<net::URLRequestJob> deleter = job_; 208 scoped_refptr<net::URLRequestJob> deleter = job_;
205 job_ = NULL; 209 job_ = NULL;
206 } 210 }
207 } 211 }
208 212
209 FileSystemFileUtil* file_util() { 213 fileapi::FileSystemFileUtil* file_util() {
210 return file_system_context_->sandbox_delegate()->sync_file_util(); 214 return file_system_context_->sandbox_delegate()->sync_file_util();
211 } 215 }
212 216
213 // Put the message loop at the top, so that it's the last thing deleted. 217 // Put the message loop at the top, so that it's the last thing deleted.
214 // Delete all MessageLoopProxy objects before the MessageLoop, to help prevent 218 // Delete all MessageLoopProxy objects before the MessageLoop, to help prevent
215 // leaks caused by tasks posted during shutdown. 219 // leaks caused by tasks posted during shutdown.
216 base::MessageLoopForIO message_loop_; 220 base::MessageLoopForIO message_loop_;
217 221
218 base::ScopedTempDir temp_dir_; 222 base::ScopedTempDir temp_dir_;
219 net::URLRequestContext empty_context_; 223 net::URLRequestContext empty_context_;
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 EXPECT_FALSE(!!std::getline(in, line)); 315 EXPECT_FALSE(!!std::getline(in, line));
312 316
313 TestRequestWithContext(CreateFileSystemURL("foo"), 317 TestRequestWithContext(CreateFileSystemURL("foo"),
314 file_system_context.get()); 318 file_system_context.get());
315 ASSERT_FALSE(request_->is_pending()); 319 ASSERT_FALSE(request_->is_pending());
316 ASSERT_FALSE(request_->status().is_success()); 320 ASSERT_FALSE(request_->status().is_success());
317 EXPECT_EQ(net::ERR_FILE_NOT_FOUND, request_->status().error()); 321 EXPECT_EQ(net::ERR_FILE_NOT_FOUND, request_->status().error());
318 } 322 }
319 323
320 } // namespace (anonymous) 324 } // namespace (anonymous)
321 } // namespace fileapi 325 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698