OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 <algorithm> | 5 #include <algorithm> |
6 #include <memory> | 6 #include <memory> |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 26 matching lines...) Expand all Loading... | |
37 | 37 |
38 BlobDataPtr blob_data = CreateBlobDataPtr(kDeadbeef); | 38 BlobDataPtr blob_data = CreateBlobDataPtr(kDeadbeef); |
39 cache_.Put(kFoo, blob_data); | 39 cache_.Put(kFoo, blob_data); |
40 | 40 |
41 EXPECT_TRUE(cache_.Contains(kFoo)); | 41 EXPECT_TRUE(cache_.Contains(kFoo)); |
42 EXPECT_FALSE(cache_.Contains(kBar)); | 42 EXPECT_FALSE(cache_.Contains(kBar)); |
43 | 43 |
44 BlobDataPtr out = cache_.Get(kFoo); | 44 BlobDataPtr out = cache_.Get(kFoo); |
45 | 45 |
46 EXPECT_EQ(blob_data, out); | 46 EXPECT_EQ(blob_data, out); |
47 | |
48 auto cache_state = cache_.GetCachedBlobIds(); | |
49 EXPECT_EQ(1u, cache_state.size()); | |
50 EXPECT_EQ(kFoo, cache_state[0]); | |
47 } | 51 } |
48 | 52 |
49 TEST_F(InMemoryBlobCacheTest, TestDuplicatePut) { | 53 TEST_F(InMemoryBlobCacheTest, TestDuplicatePut) { |
50 BlobDataPtr first = CreateBlobDataPtr(kDeadbeef); | 54 BlobDataPtr first = CreateBlobDataPtr(kDeadbeef); |
51 BlobDataPtr duplicate = CreateBlobDataPtr(kForbiddenCode); | 55 BlobDataPtr duplicate = CreateBlobDataPtr(kForbiddenCode); |
52 cache_.Put(kFoo, first); | 56 cache_.Put(kFoo, first); |
53 | 57 |
54 BlobDataPtr out1 = cache_.Get(kFoo); | 58 BlobDataPtr out1 = cache_.Get(kFoo); |
55 EXPECT_EQ(first, out1); | 59 EXPECT_EQ(first, out1); |
56 | 60 |
57 // The second put should be ignored and retrieving kFoo should still retrieve | 61 // The second put should be ignored and retrieving kFoo should still retrieve |
58 // the first item. | 62 // the first item. |
59 cache_.Put(kFoo, duplicate); | 63 cache_.Put(kFoo, duplicate); |
60 BlobDataPtr out2 = cache_.Get(kFoo); | 64 BlobDataPtr out2 = cache_.Get(kFoo); |
61 EXPECT_EQ(first, out2); | 65 EXPECT_EQ(first, out2); |
66 | |
67 auto cache_state = cache_.GetCachedBlobIds(); | |
68 EXPECT_EQ(1u, cache_state.size()); | |
nyquist
2016/07/15 22:13:46
Nit: It feels a little bit weird of having two tes
Kevin M
2016/07/18 16:58:16
Added multiple outputs to SimplePutContainsAndGetO
| |
69 EXPECT_EQ(kFoo, cache_state[0]); | |
62 } | 70 } |
63 | 71 |
64 } // namespace | 72 } // namespace |
65 } // namespace blimp | 73 } // namespace blimp |
OLD | NEW |