OLD | NEW |
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 #include "base/file_path.h" | 5 #include "base/file_path.h" |
6 #include "base/memory/ref_counted.h" | 6 #include "base/memory/ref_counted.h" |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/time.h" | 8 #include "base/time.h" |
9 #include "net/base/upload_data.h" | 9 #include "net/base/upload_data.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
11 #include "webkit/blob/blob_data.h" | 11 #include "webkit/blob/blob_data.h" |
12 #include "webkit/blob/blob_storage_controller.h" | 12 #include "webkit/blob/blob_storage_controller.h" |
13 | 13 |
14 using net::UploadData; | 14 using net::UploadData; |
15 | 15 |
16 namespace webkit_blob { | 16 namespace webkit_blob { |
17 | 17 |
18 TEST(BlobStorageControllerTest, RegisterBlobUrl) { | 18 TEST(BlobStorageControllerTest, RegisterBlobUrl) { |
19 // Setup a set of blob data for testing. | 19 // Setup a set of blob data for testing. |
20 base::Time time1, time2; | 20 base::Time time1, time2; |
21 base::Time::FromString(L"Tue, 15 Nov 1994, 12:45:26 GMT", &time1); | 21 base::Time::FromString("Tue, 15 Nov 1994, 12:45:26 GMT", &time1); |
22 base::Time::FromString(L"Mon, 14 Nov 1994, 11:30:49 GMT", &time2); | 22 base::Time::FromString("Mon, 14 Nov 1994, 11:30:49 GMT", &time2); |
23 | 23 |
24 scoped_refptr<BlobData> blob_data1(new BlobData()); | 24 scoped_refptr<BlobData> blob_data1(new BlobData()); |
25 blob_data1->AppendData("Data1"); | 25 blob_data1->AppendData("Data1"); |
26 blob_data1->AppendData("Data2"); | 26 blob_data1->AppendData("Data2"); |
27 blob_data1->AppendFile(FilePath(FILE_PATH_LITERAL("File1.txt")), | 27 blob_data1->AppendFile(FilePath(FILE_PATH_LITERAL("File1.txt")), |
28 10, 1024, time1); | 28 10, 1024, time1); |
29 | 29 |
30 scoped_refptr<BlobData> blob_data2(new BlobData()); | 30 scoped_refptr<BlobData> blob_data2(new BlobData()); |
31 blob_data2->AppendData("Data3"); | 31 blob_data2->AppendData("Data3"); |
32 blob_data2->AppendBlob(GURL("blob://url_1"), 8, 100); | 32 blob_data2->AppendBlob(GURL("blob://url_1"), 8, 100); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 | 73 |
74 // Test unregistering a blob URL. | 74 // Test unregistering a blob URL. |
75 blob_storage_controller->UnregisterBlobUrl(blob_url3); | 75 blob_storage_controller->UnregisterBlobUrl(blob_url3); |
76 blob_data_found = blob_storage_controller->GetBlobDataFromUrl(blob_url3); | 76 blob_data_found = blob_storage_controller->GetBlobDataFromUrl(blob_url3); |
77 EXPECT_TRUE(!blob_data_found); | 77 EXPECT_TRUE(!blob_data_found); |
78 } | 78 } |
79 | 79 |
80 TEST(BlobStorageControllerTest, ResolveBlobReferencesInUploadData) { | 80 TEST(BlobStorageControllerTest, ResolveBlobReferencesInUploadData) { |
81 // Setup blob data for testing. | 81 // Setup blob data for testing. |
82 base::Time time1, time2; | 82 base::Time time1, time2; |
83 base::Time::FromString(L"Tue, 15 Nov 1994, 12:45:26 GMT", &time1); | 83 base::Time::FromString("Tue, 15 Nov 1994, 12:45:26 GMT", &time1); |
84 base::Time::FromString(L"Mon, 14 Nov 1994, 11:30:49 GMT", &time2); | 84 base::Time::FromString("Mon, 14 Nov 1994, 11:30:49 GMT", &time2); |
85 | 85 |
86 scoped_ptr<BlobStorageController> blob_storage_controller( | 86 scoped_ptr<BlobStorageController> blob_storage_controller( |
87 new BlobStorageController()); | 87 new BlobStorageController()); |
88 | 88 |
89 scoped_refptr<BlobData> blob_data(new BlobData()); | 89 scoped_refptr<BlobData> blob_data(new BlobData()); |
90 | 90 |
91 GURL blob_url0("blob://url_0"); | 91 GURL blob_url0("blob://url_0"); |
92 blob_storage_controller->RegisterBlobUrl(blob_url0, blob_data); | 92 blob_storage_controller->RegisterBlobUrl(blob_url0, blob_data); |
93 | 93 |
94 blob_data->AppendData("BlobData"); | 94 blob_data->AppendData("BlobData"); |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 EXPECT_TRUE(upload_data->elements()->at(1) == blob_element2); | 230 EXPECT_TRUE(upload_data->elements()->at(1) == blob_element2); |
231 EXPECT_TRUE(upload_data->elements()->at(2) == upload_element1); | 231 EXPECT_TRUE(upload_data->elements()->at(2) == upload_element1); |
232 EXPECT_TRUE(upload_data->elements()->at(3) == blob_element1); | 232 EXPECT_TRUE(upload_data->elements()->at(3) == blob_element1); |
233 EXPECT_TRUE(upload_data->elements()->at(4) == blob_element2); | 233 EXPECT_TRUE(upload_data->elements()->at(4) == blob_element2); |
234 EXPECT_TRUE(upload_data->elements()->at(5) == blob_element1); | 234 EXPECT_TRUE(upload_data->elements()->at(5) == blob_element1); |
235 EXPECT_TRUE(upload_data->elements()->at(6) == blob_element2); | 235 EXPECT_TRUE(upload_data->elements()->at(6) == blob_element2); |
236 EXPECT_TRUE(upload_data->elements()->at(7) == upload_element2); | 236 EXPECT_TRUE(upload_data->elements()->at(7) == upload_element2); |
237 } | 237 } |
238 | 238 |
239 } // namespace webkit_blob | 239 } // namespace webkit_blob |
OLD | NEW |