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

Side by Side Diff: webkit/blob/blob_storage_controller_unittest.cc

Issue 4192012: Convert implicit scoped_refptr constructor calls to explicit ones, part 1 (Closed) Base URL: http://git.chromium.org/git/chromium.git
Patch Set: fix presubmit Created 10 years, 1 month 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
« no previous file with comments | « webkit/blob/blob_storage_controller.cc ('k') | webkit/blob/blob_url_request_job_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/time.h" 6 #include "base/time.h"
7 #include "base/ref_counted.h" 7 #include "base/ref_counted.h"
8 #include "base/scoped_ptr.h" 8 #include "base/scoped_ptr.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(L"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(L"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);
33 blob_data2->AppendFile(FilePath(FILE_PATH_LITERAL("File2.txt")), 33 blob_data2->AppendFile(FilePath(FILE_PATH_LITERAL("File2.txt")),
34 0, 20, time2); 34 0, 20, time2);
35 35
36 scoped_refptr<BlobData> canonicalized_blob_data2 = new BlobData(); 36 scoped_refptr<BlobData> canonicalized_blob_data2(new BlobData());
37 canonicalized_blob_data2->AppendData("Data3"); 37 canonicalized_blob_data2->AppendData("Data3");
38 canonicalized_blob_data2->AppendData("Data2", 3, 2); 38 canonicalized_blob_data2->AppendData("Data2", 3, 2);
39 canonicalized_blob_data2->AppendFile(FilePath(FILE_PATH_LITERAL("File1.txt")), 39 canonicalized_blob_data2->AppendFile(FilePath(FILE_PATH_LITERAL("File1.txt")),
40 10, 98, time1); 40 10, 98, time1);
41 canonicalized_blob_data2->AppendFile(FilePath(FILE_PATH_LITERAL("File2.txt")), 41 canonicalized_blob_data2->AppendFile(FilePath(FILE_PATH_LITERAL("File2.txt")),
42 0, 20, time2); 42 0, 20, time2);
43 43
44 scoped_ptr<BlobStorageController> blob_storage_controller( 44 scoped_ptr<BlobStorageController> blob_storage_controller(
45 new BlobStorageController()); 45 new BlobStorageController());
46 46
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(L"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(L"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");
95 blob_data->AppendFile( 95 blob_data->AppendFile(
96 FilePath(FILE_PATH_LITERAL("BlobFile.txt")), 0, 20, time1); 96 FilePath(FILE_PATH_LITERAL("BlobFile.txt")), 0, 20, time1);
97 97
98 GURL blob_url1("blob://url_1"); 98 GURL blob_url1("blob://url_1");
99 blob_storage_controller->RegisterBlobUrl(blob_url1, blob_data); 99 blob_storage_controller->RegisterBlobUrl(blob_url1, blob_data);
(...skipping 15 matching lines...) Expand all
115 blob_data->items().at(1).offset(), 115 blob_data->items().at(1).offset(),
116 blob_data->items().at(1).length(), 116 blob_data->items().at(1).length(),
117 blob_data->items().at(1).expected_modification_time()); 117 blob_data->items().at(1).expected_modification_time());
118 118
119 UploadData::Element upload_element1, upload_element2; 119 UploadData::Element upload_element1, upload_element2;
120 upload_element1.SetToBytes("Hello", 5); 120 upload_element1.SetToBytes("Hello", 5);
121 upload_element2.SetToFilePathRange( 121 upload_element2.SetToFilePathRange(
122 FilePath(FILE_PATH_LITERAL("foo1.txt")), 0, 20, time2); 122 FilePath(FILE_PATH_LITERAL("foo1.txt")), 0, 20, time2);
123 123
124 // Test no blob reference. 124 // Test no blob reference.
125 scoped_refptr<UploadData> upload_data = new UploadData(); 125 scoped_refptr<UploadData> upload_data(new UploadData());
126 upload_data->AppendBytes( 126 upload_data->AppendBytes(
127 &upload_element1.bytes().at(0), 127 &upload_element1.bytes().at(0),
128 upload_element1.bytes().size()); 128 upload_element1.bytes().size());
129 upload_data->AppendFileRange( 129 upload_data->AppendFileRange(
130 upload_element2.file_path(), 130 upload_element2.file_path(),
131 upload_element2.file_range_offset(), 131 upload_element2.file_range_offset(),
132 upload_element2.file_range_length(), 132 upload_element2.file_range_length(),
133 upload_element2.expected_file_modification_time()); 133 upload_element2.expected_file_modification_time());
134 134
135 blob_storage_controller->ResolveBlobReferencesInUploadData(upload_data.get()); 135 blob_storage_controller->ResolveBlobReferencesInUploadData(upload_data.get());
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW
« no previous file with comments | « webkit/blob/blob_storage_controller.cc ('k') | webkit/blob/blob_url_request_job_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698