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

Side by Side Diff: content/browser/blob_storage/blob_storage_registry_unittest.cc

Issue 2774413002: Move some blob tests next to the files they cover. (Closed)
Patch Set: Created 3 years, 9 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
OLDNEW
(Empty)
1 // Copyright 2015 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 "storage/browser/blob/blob_storage_registry.h"
6
7 #include "base/callback.h"
8 #include "storage/browser/blob/blob_entry.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "url/gurl.h"
11
12 namespace storage {
13 namespace {
14
15 TEST(BlobStorageRegistry, UUIDRegistration) {
16 const std::string kBlob1 = "Blob1";
17 const std::string kType = "type1";
18 const std::string kDisposition = "disp1";
19 BlobStorageRegistry registry;
20
21 EXPECT_FALSE(registry.DeleteEntry(kBlob1));
22 EXPECT_EQ(0u, registry.blob_count());
23
24 BlobEntry* entry = registry.CreateEntry(kBlob1, kType, kDisposition);
25 ASSERT_NE(nullptr, entry);
26 EXPECT_EQ(BlobStatus::PENDING_QUOTA, entry->status());
27 EXPECT_EQ(kType, entry->content_type());
28 EXPECT_EQ(kDisposition, entry->content_disposition());
29 EXPECT_EQ(0u, entry->refcount());
30
31 EXPECT_EQ(entry, registry.GetEntry(kBlob1));
32 EXPECT_TRUE(registry.DeleteEntry(kBlob1));
33 entry = registry.CreateEntry(kBlob1, kType, kDisposition);
34
35 EXPECT_EQ(1u, registry.blob_count());
36 }
37
38 TEST(BlobStorageRegistry, URLRegistration) {
39 const std::string kBlob = "Blob1";
40 const std::string kType = "type1";
41 const std::string kDisposition = "disp1";
42 const std::string kBlob2 = "Blob2";
43 const GURL kURL = GURL("blob://Blob1");
44 const GURL kURL2 = GURL("blob://Blob2");
45 BlobStorageRegistry registry;
46
47 EXPECT_FALSE(registry.IsURLMapped(kURL));
48 EXPECT_EQ(nullptr, registry.GetEntryFromURL(kURL, nullptr));
49 EXPECT_FALSE(registry.DeleteURLMapping(kURL, nullptr));
50 EXPECT_FALSE(registry.CreateUrlMapping(kURL, kBlob));
51 EXPECT_EQ(0u, registry.url_count());
52 BlobEntry* entry = registry.CreateEntry(kBlob, kType, kDisposition);
53
54 EXPECT_FALSE(registry.IsURLMapped(kURL));
55 EXPECT_TRUE(registry.CreateUrlMapping(kURL, kBlob));
56 EXPECT_FALSE(registry.CreateUrlMapping(kURL, kBlob2));
57
58 EXPECT_TRUE(registry.IsURLMapped(kURL));
59 EXPECT_EQ(entry, registry.GetEntryFromURL(kURL, nullptr));
60 std::string uuid;
61 EXPECT_EQ(entry, registry.GetEntryFromURL(kURL, &uuid));
62 EXPECT_EQ(kBlob, uuid);
63 EXPECT_EQ(1u, registry.url_count());
64
65 registry.CreateEntry(kBlob2, kType, kDisposition);
66 EXPECT_TRUE(registry.CreateUrlMapping(kURL2, kBlob2));
67 EXPECT_EQ(2u, registry.url_count());
68 EXPECT_TRUE(registry.DeleteURLMapping(kURL2, &uuid));
69 EXPECT_EQ(kBlob2, uuid);
70 EXPECT_FALSE(registry.IsURLMapped(kURL2));
71
72 // Both urls point to the same blob.
73 EXPECT_TRUE(registry.CreateUrlMapping(kURL2, kBlob));
74 std::string uuid2;
75 EXPECT_EQ(registry.GetEntryFromURL(kURL, &uuid),
76 registry.GetEntryFromURL(kURL2, &uuid2));
77 EXPECT_EQ(uuid, uuid2);
78 }
79
80 } // namespace
81 } // namespace storage
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698