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/files/file_path.h" | 5 #include "base/files/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 "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 #include "webkit/browser/blob/blob_storage_controller.h" | 10 #include "webkit/browser/blob/blob_storage_controller.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 base::FilePath(FILE_PATH_LITERAL("File1.txt")), | 37 base::FilePath(FILE_PATH_LITERAL("File1.txt")), |
38 10, 98, time1); | 38 10, 98, time1); |
39 canonicalized_blob_data2->AppendFile( | 39 canonicalized_blob_data2->AppendFile( |
40 base::FilePath(FILE_PATH_LITERAL("File2.txt")), 0, 20, time2); | 40 base::FilePath(FILE_PATH_LITERAL("File2.txt")), 0, 20, time2); |
41 | 41 |
42 BlobStorageController blob_storage_controller; | 42 BlobStorageController blob_storage_controller; |
43 | 43 |
44 // Test registering a blob URL referring to the blob data containing only | 44 // Test registering a blob URL referring to the blob data containing only |
45 // data and file. | 45 // data and file. |
46 GURL blob_url1("blob://url_1"); | 46 GURL blob_url1("blob://url_1"); |
47 blob_storage_controller.AddFinishedBlob(blob_url1, blob_data1); | 47 blob_storage_controller.AddFinishedBlob(blob_url1, blob_data1.get()); |
48 | 48 |
49 BlobData* blob_data_found = | 49 BlobData* blob_data_found = |
50 blob_storage_controller.GetBlobDataFromUrl(blob_url1); | 50 blob_storage_controller.GetBlobDataFromUrl(blob_url1); |
51 ASSERT_TRUE(blob_data_found != NULL); | 51 ASSERT_TRUE(blob_data_found != NULL); |
52 EXPECT_TRUE(*blob_data_found == *blob_data1); | 52 EXPECT_TRUE(*blob_data_found == *blob_data1.get()); |
53 | 53 |
54 // Test registering a blob URL referring to the blob data containing data, | 54 // Test registering a blob URL referring to the blob data containing data, |
55 // file and blob. | 55 // file and blob. |
56 GURL blob_url2("blob://url_2"); | 56 GURL blob_url2("blob://url_2"); |
57 blob_storage_controller.AddFinishedBlob(blob_url2, blob_data2); | 57 blob_storage_controller.AddFinishedBlob(blob_url2, blob_data2.get()); |
58 | 58 |
59 blob_data_found = blob_storage_controller.GetBlobDataFromUrl(blob_url2); | 59 blob_data_found = blob_storage_controller.GetBlobDataFromUrl(blob_url2); |
60 ASSERT_TRUE(blob_data_found != NULL); | 60 ASSERT_TRUE(blob_data_found != NULL); |
61 EXPECT_TRUE(*blob_data_found == *canonicalized_blob_data2); | 61 EXPECT_TRUE(*blob_data_found == *canonicalized_blob_data2.get()); |
62 | 62 |
63 // Test registering a blob URL referring to existent blob URL. | 63 // Test registering a blob URL referring to existent blob URL. |
64 GURL blob_url3("blob://url_3"); | 64 GURL blob_url3("blob://url_3"); |
65 blob_storage_controller.CloneBlob(blob_url3, blob_url1); | 65 blob_storage_controller.CloneBlob(blob_url3, blob_url1); |
66 | 66 |
67 blob_data_found = blob_storage_controller.GetBlobDataFromUrl(blob_url3); | 67 blob_data_found = blob_storage_controller.GetBlobDataFromUrl(blob_url3); |
68 ASSERT_TRUE(blob_data_found != NULL); | 68 ASSERT_TRUE(blob_data_found != NULL); |
69 EXPECT_TRUE(*blob_data_found == *blob_data1); | 69 EXPECT_TRUE(*blob_data_found == *blob_data1.get()); |
70 | 70 |
71 // Test unregistering a blob URL. | 71 // Test unregistering a blob URL. |
72 blob_storage_controller.RemoveBlob(blob_url3); | 72 blob_storage_controller.RemoveBlob(blob_url3); |
73 blob_data_found = blob_storage_controller.GetBlobDataFromUrl(blob_url3); | 73 blob_data_found = blob_storage_controller.GetBlobDataFromUrl(blob_url3); |
74 EXPECT_TRUE(!blob_data_found); | 74 EXPECT_TRUE(!blob_data_found); |
75 } | 75 } |
76 | 76 |
77 } // namespace webkit_blob | 77 } // namespace webkit_blob |
OLD | NEW |