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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 quota_manager_ = new quota::MockQuotaManager( | 66 quota_manager_ = new quota::MockQuotaManager( |
67 false /* is_incognito */, dir_.path(), | 67 false /* is_incognito */, dir_.path(), |
68 base::MessageLoopProxy::current(), | 68 base::MessageLoopProxy::current(), |
69 base::MessageLoopProxy::current(), | 69 base::MessageLoopProxy::current(), |
70 NULL /* special storage policy */); | 70 NULL /* special storage policy */); |
71 virtual_path_ = base::FilePath(FILE_PATH_LITERAL("temporary file")); | 71 virtual_path_ = base::FilePath(FILE_PATH_LITERAL("temporary file")); |
72 | 72 |
73 file_system_context_ = CreateFileSystemContextForTesting( | 73 file_system_context_ = CreateFileSystemContextForTesting( |
74 quota_manager_->proxy(), dir_.path()); | 74 quota_manager_->proxy(), dir_.path()); |
75 url_request_context_.reset( | 75 url_request_context_.reset( |
76 new MockBlobURLRequestContext(file_system_context_)); | 76 new MockBlobURLRequestContext(file_system_context_.get())); |
77 | 77 |
78 NewOperation()->CreateFile( | 78 NewOperation()->CreateFile( |
79 URLForPath(virtual_path_), true /* exclusive */, | 79 URLForPath(virtual_path_), true /* exclusive */, |
80 base::Bind(&AssertStatusEq, base::PLATFORM_FILE_OK)); | 80 base::Bind(&AssertStatusEq, base::PLATFORM_FILE_OK)); |
81 } | 81 } |
82 | 82 |
83 virtual void TearDown() { | 83 virtual void TearDown() { |
84 quota_manager_ = NULL; | 84 quota_manager_ = NULL; |
85 file_system_context_ = NULL; | 85 file_system_context_ = NULL; |
86 base::MessageLoop::current()->RunUntilIdle(); | 86 base::MessageLoop::current()->RunUntilIdle(); |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 EXPECT_EQ(base::PLATFORM_FILE_OK, status()); | 187 EXPECT_EQ(base::PLATFORM_FILE_OK, status()); |
188 EXPECT_TRUE(complete()); | 188 EXPECT_TRUE(complete()); |
189 | 189 |
190 EXPECT_EQ(1, change_observer()->get_and_reset_modify_file_count()); | 190 EXPECT_EQ(1, change_observer()->get_and_reset_modify_file_count()); |
191 } | 191 } |
192 | 192 |
193 TEST_F(LocalFileSystemOperationWriteTest, TestWriteZero) { | 193 TEST_F(LocalFileSystemOperationWriteTest, TestWriteZero) { |
194 GURL blob_url("blob:zero"); | 194 GURL blob_url("blob:zero"); |
195 scoped_refptr<webkit_blob::BlobData> blob_data(new webkit_blob::BlobData()); | 195 scoped_refptr<webkit_blob::BlobData> blob_data(new webkit_blob::BlobData()); |
196 | 196 |
197 url_request_context().blob_storage_controller()->AddFinishedBlob( | 197 url_request_context().blob_storage_controller() |
198 blob_url, blob_data); | 198 ->AddFinishedBlob(blob_url, blob_data.get()); |
199 | 199 |
200 NewOperation()->Write( | 200 NewOperation()->Write( |
201 &url_request_context(), URLForPath(virtual_path_), | 201 &url_request_context(), URLForPath(virtual_path_), |
202 blob_url, 0, RecordWriteCallback()); | 202 blob_url, 0, RecordWriteCallback()); |
203 base::MessageLoop::current()->Run(); | 203 base::MessageLoop::current()->Run(); |
204 | 204 |
205 url_request_context().blob_storage_controller()->RemoveBlob(blob_url); | 205 url_request_context().blob_storage_controller()->RemoveBlob(blob_url); |
206 | 206 |
207 EXPECT_EQ(0, bytes_written()); | 207 EXPECT_EQ(0, bytes_written()); |
208 EXPECT_EQ(base::PLATFORM_FILE_OK, status()); | 208 EXPECT_EQ(base::PLATFORM_FILE_OK, status()); |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 EXPECT_EQ(base::PLATFORM_FILE_ERROR_ABORT, status()); | 331 EXPECT_EQ(base::PLATFORM_FILE_ERROR_ABORT, status()); |
332 EXPECT_EQ(base::PLATFORM_FILE_OK, cancel_status()); | 332 EXPECT_EQ(base::PLATFORM_FILE_OK, cancel_status()); |
333 EXPECT_TRUE(complete()); | 333 EXPECT_TRUE(complete()); |
334 | 334 |
335 EXPECT_EQ(0, change_observer()->get_and_reset_modify_file_count()); | 335 EXPECT_EQ(0, change_observer()->get_and_reset_modify_file_count()); |
336 } | 336 } |
337 | 337 |
338 // TODO(ericu,dmikurube,kinuko): Add more tests for cancel cases. | 338 // TODO(ericu,dmikurube,kinuko): Add more tests for cancel cases. |
339 | 339 |
340 } // namespace fileapi | 340 } // namespace fileapi |
OLD | NEW |