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

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

Issue 7397008: Deprecate RegisterProtocolFactory/(Un)RegisterInterceptor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix indent. Created 9 years, 5 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 68
69 virtual bool IsStorageUnlimited(const GURL& origin) { 69 virtual bool IsStorageUnlimited(const GURL& origin) {
70 return true; 70 return true;
71 } 71 }
72 72
73 virtual bool IsFileHandler(const std::string& extension_id) { 73 virtual bool IsFileHandler(const std::string& extension_id) {
74 return true; 74 return true;
75 } 75 }
76 }; 76 };
77 77
78 } // namespace
79
78 class FileSystemURLRequestJobTest : public testing::Test { 80 class FileSystemURLRequestJobTest : public testing::Test {
79 protected: 81 protected:
80 FileSystemURLRequestJobTest() 82 FileSystemURLRequestJobTest()
81 : message_loop_(MessageLoop::TYPE_IO), // simulate an IO thread 83 : message_loop_(MessageLoop::TYPE_IO), // simulate an IO thread
82 ALLOW_THIS_IN_INITIALIZER_LIST(callback_factory_(this)) { 84 ALLOW_THIS_IN_INITIALIZER_LIST(callback_factory_(this)) {
83 } 85 }
84 86
85 virtual void SetUp() { 87 virtual void SetUp() {
86 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 88 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
87 89
(...skipping 10 matching lines...) Expand all
98 new FileSystemPathManager( 100 new FileSystemPathManager(
99 base::MessageLoopProxy::CreateForCurrentThread(), 101 base::MessageLoopProxy::CreateForCurrentThread(),
100 temp_dir_.path(), NULL, false, false)); 102 temp_dir_.path(), NULL, false, false));
101 103
102 file_system_context_->path_manager()->ValidateFileSystemRootAndGetURL( 104 file_system_context_->path_manager()->ValidateFileSystemRootAndGetURL(
103 GURL("http://remote/"), kFileSystemTypeTemporary, true, // create 105 GURL("http://remote/"), kFileSystemTypeTemporary, true, // create
104 callback_factory_.NewCallback( 106 callback_factory_.NewCallback(
105 &FileSystemURLRequestJobTest::OnGetRootPath)); 107 &FileSystemURLRequestJobTest::OnGetRootPath));
106 MessageLoop::current()->RunAllPending(); 108 MessageLoop::current()->RunAllPending();
107 109
108 net::URLRequest::RegisterProtocolFactory("filesystem", 110 net::URLRequest::Deprecated::RegisterProtocolFactory(
109 &FileSystemURLRequestJobFactory); 111 "filesystem", &FileSystemURLRequestJobFactory);
110 } 112 }
111 113
112 virtual void TearDown() { 114 virtual void TearDown() {
113 net::URLRequest::RegisterProtocolFactory("filesystem", NULL); 115 net::URLRequest::Deprecated::RegisterProtocolFactory("filesystem", NULL);
114 } 116 }
115 117
116 void OnGetRootPath(bool success, const FilePath& root_path, 118 void OnGetRootPath(bool success, const FilePath& root_path,
117 const std::string& name) { 119 const std::string& name) {
118 ASSERT_TRUE(success); 120 ASSERT_TRUE(success);
119 origin_root_path_ = root_path; 121 origin_root_path_ = root_path;
120 } 122 }
121 123
122 void TestRequestHelper(const GURL& url, 124 void TestRequestHelper(const GURL& url,
123 const net::HttpRequestHeaders* headers, 125 const net::HttpRequestHeaders* headers,
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 // NOTE: order matters, request must die before delegate 223 // NOTE: order matters, request must die before delegate
222 scoped_ptr<TestDelegate> delegate_; 224 scoped_ptr<TestDelegate> delegate_;
223 scoped_ptr<net::URLRequest> request_; 225 scoped_ptr<net::URLRequest> request_;
224 226
225 static net::URLRequestJob* job_; 227 static net::URLRequestJob* job_;
226 }; 228 };
227 229
228 // static 230 // static
229 net::URLRequestJob* FileSystemURLRequestJobTest::job_ = NULL; 231 net::URLRequestJob* FileSystemURLRequestJobTest::job_ = NULL;
230 232
233 namespace {
234
231 TEST_F(FileSystemURLRequestJobTest, FileTest) { 235 TEST_F(FileSystemURLRequestJobTest, FileTest) {
232 WriteFile("file1.dat", kTestFileData, arraysize(kTestFileData) - 1); 236 WriteFile("file1.dat", kTestFileData, arraysize(kTestFileData) - 1);
233 TestRequest(CreateFileSystemURL("file1.dat")); 237 TestRequest(CreateFileSystemURL("file1.dat"));
234 238
235 ASSERT_FALSE(request_->is_pending()); 239 ASSERT_FALSE(request_->is_pending());
236 EXPECT_EQ(1, delegate_->response_started_count()); 240 EXPECT_EQ(1, delegate_->response_started_count());
237 EXPECT_FALSE(delegate_->received_data_before_response()); 241 EXPECT_FALSE(delegate_->received_data_before_response());
238 EXPECT_EQ(kTestFileData, delegate_->data_received()); 242 EXPECT_EQ(kTestFileData, delegate_->data_received());
239 EXPECT_EQ(200, request_->GetResponseCode()); 243 EXPECT_EQ(200, request_->GetResponseCode());
240 std::string cache_control; 244 std::string cache_control;
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 383
380 TestRequest(CreateFileSystemURL(kFilename)); 384 TestRequest(CreateFileSystemURL(kFilename));
381 385
382 std::string mime_type_from_job; 386 std::string mime_type_from_job;
383 request_->GetMimeType(&mime_type_from_job); 387 request_->GetMimeType(&mime_type_from_job);
384 EXPECT_EQ(mime_type_direct, mime_type_from_job); 388 EXPECT_EQ(mime_type_direct, mime_type_from_job);
385 } 389 }
386 390
387 } // namespace (anonymous) 391 } // namespace (anonymous)
388 } // namespace fileapi 392 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/fileapi/file_system_operation_write_unittest.cc ('k') | webkit/fileapi/file_writer_delegate_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698