| 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" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "blimp/common/blob_cache/blob_cache.h" | 12 #include "blimp/common/blob_cache/blob_cache.h" |
| 13 #include "blimp/common/blob_cache/in_memory_blob_cache.h" | 13 #include "blimp/common/blob_cache/in_memory_blob_cache.h" |
| 14 #include "blimp/common/blob_cache/test_util.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 15 | 16 |
| 16 namespace blimp { | 17 namespace blimp { |
| 17 namespace { | 18 namespace { |
| 18 | 19 |
| 19 const char kFoo[] = "foo"; | 20 const char kFoo[] = "foo"; |
| 20 const char kBar[] = "bar"; | 21 const char kBar[] = "bar"; |
| 21 const char kDeadbeef[] = "\xde\xad\xbe\xef"; | 22 const char kDeadbeef[] = "\xde\xad\xbe\xef"; |
| 22 const char kForbiddenCode[] = "\x4b\x1d\xc0\xd3"; | 23 const char kForbiddenCode[] = "\x4b\x1d\xc0\xd3"; |
| 23 | 24 |
| 24 BlobDataPtr CreateBlobDataPtr(const std::string& data) { | |
| 25 return new BlobData(data); | |
| 26 } | |
| 27 | |
| 28 class InMemoryBlobCacheTest : public testing::Test { | 25 class InMemoryBlobCacheTest : public testing::Test { |
| 29 public: | 26 public: |
| 30 InMemoryBlobCacheTest() {} | 27 InMemoryBlobCacheTest() {} |
| 31 ~InMemoryBlobCacheTest() override {} | 28 ~InMemoryBlobCacheTest() override {} |
| 32 | 29 |
| 33 protected: | 30 protected: |
| 34 InMemoryBlobCache cache_; | 31 InMemoryBlobCache cache_; |
| 35 }; | 32 }; |
| 36 | 33 |
| 37 TEST_F(InMemoryBlobCacheTest, SimplePutContainsAndGetOperations) { | 34 TEST_F(InMemoryBlobCacheTest, SimplePutContainsAndGetOperations) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 59 | 56 |
| 60 // The second put should be ignored and retrieving kFoo should still retrieve | 57 // The second put should be ignored and retrieving kFoo should still retrieve |
| 61 // the first item. | 58 // the first item. |
| 62 cache_.Put(kFoo, duplicate); | 59 cache_.Put(kFoo, duplicate); |
| 63 BlobDataPtr out2 = cache_.Get(kFoo); | 60 BlobDataPtr out2 = cache_.Get(kFoo); |
| 64 EXPECT_EQ(first, out2); | 61 EXPECT_EQ(first, out2); |
| 65 } | 62 } |
| 66 | 63 |
| 67 } // namespace | 64 } // namespace |
| 68 } // namespace blimp | 65 } // namespace blimp |
| OLD | NEW |