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

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

Issue 23223003: Chromium Blob hacking (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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
« no previous file with comments | « webkit/browser/blob/blob_storage_controller.cc ('k') | webkit/browser/blob/blob_storage_host.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/files/file_path.h"
6 #include "base/memory/ref_counted.h"
7 #include "base/memory/scoped_ptr.h"
8 #include "base/time/time.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "webkit/browser/blob/blob_storage_controller.h"
11 #include "webkit/common/blob/blob_data.h"
12
13 namespace webkit_blob {
14
15 TEST(BlobStorageControllerTest, RegisterBlobUrl) {
16 // Setup a set of blob data for testing.
17 base::Time time1, time2;
18 base::Time::FromString("Tue, 15 Nov 1994, 12:45:26 GMT", &time1);
19 base::Time::FromString("Mon, 14 Nov 1994, 11:30:49 GMT", &time2);
20
21 scoped_refptr<BlobData> blob_data1(new BlobData());
22 blob_data1->AppendData("Data1");
23 blob_data1->AppendData("Data2");
24 blob_data1->AppendFile(base::FilePath(FILE_PATH_LITERAL("File1.txt")),
25 10, 1024, time1);
26
27 scoped_refptr<BlobData> blob_data2(new BlobData());
28 blob_data2->AppendData("Data3");
29 blob_data2->AppendBlob(GURL("blob://url_1"), 8, 100);
30 blob_data2->AppendFile(base::FilePath(FILE_PATH_LITERAL("File2.txt")),
31 0, 20, time2);
32
33 scoped_refptr<BlobData> canonicalized_blob_data2(new BlobData());
34 canonicalized_blob_data2->AppendData("Data3");
35 canonicalized_blob_data2->AppendData("a2___", 2);
36 canonicalized_blob_data2->AppendFile(
37 base::FilePath(FILE_PATH_LITERAL("File1.txt")),
38 10, 98, time1);
39 canonicalized_blob_data2->AppendFile(
40 base::FilePath(FILE_PATH_LITERAL("File2.txt")), 0, 20, time2);
41
42 BlobStorageController blob_storage_controller;
43
44 // Test registering a blob URL referring to the blob data containing only
45 // data and file.
46 GURL blob_url1("blob://url_1");
47 blob_storage_controller.AddFinishedBlob(blob_url1, blob_data1.get());
48
49 BlobData* blob_data_found =
50 blob_storage_controller.GetBlobDataFromUrl(blob_url1);
51 ASSERT_TRUE(blob_data_found != NULL);
52 EXPECT_TRUE(*blob_data_found == *blob_data1.get());
53
54 // Test registering a blob URL referring to the blob data containing data,
55 // file and blob.
56 GURL blob_url2("blob://url_2");
57 blob_storage_controller.AddFinishedBlob(blob_url2, blob_data2.get());
58
59 blob_data_found = blob_storage_controller.GetBlobDataFromUrl(blob_url2);
60 ASSERT_TRUE(blob_data_found != NULL);
61 EXPECT_TRUE(*blob_data_found == *canonicalized_blob_data2.get());
62
63 // Test registering a blob URL referring to existent blob URL.
64 GURL blob_url3("blob://url_3");
65 blob_storage_controller.CloneBlob(blob_url3, blob_url1);
66
67 blob_data_found = blob_storage_controller.GetBlobDataFromUrl(blob_url3);
68 ASSERT_TRUE(blob_data_found != NULL);
69 EXPECT_TRUE(*blob_data_found == *blob_data1.get());
70
71 // Test unregistering a blob URL.
72 blob_storage_controller.RemoveBlob(blob_url3);
73 blob_data_found = blob_storage_controller.GetBlobDataFromUrl(blob_url3);
74 EXPECT_TRUE(!blob_data_found);
75 }
76
77 } // namespace webkit_blob
OLDNEW
« no previous file with comments | « webkit/browser/blob/blob_storage_controller.cc ('k') | webkit/browser/blob/blob_storage_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698