| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "blimp/client/feature/compositor/blimp_client_picture_cache.h" | |
| 6 | |
| 7 #include <stdint.h> | |
| 8 #include <memory> | |
| 9 #include <vector> | |
| 10 | |
| 11 #include "blimp/test/support/compositor/picture_cache_test_support.h" | |
| 12 #include "testing/gtest/include/gtest/gtest.h" | |
| 13 #include "third_party/skia/include/core/SkColor.h" | |
| 14 #include "third_party/skia/include/core/SkPicture.h" | |
| 15 #include "third_party/skia/include/core/SkRefCnt.h" | |
| 16 | |
| 17 namespace blimp { | |
| 18 namespace client { | |
| 19 namespace { | |
| 20 | |
| 21 bool FakeImageDecoder(const void* input, size_t input_size, SkBitmap* bitmap) { | |
| 22 return true; | |
| 23 } | |
| 24 | |
| 25 class BlimpClientPictureCacheTest : public testing::Test { | |
| 26 public: | |
| 27 BlimpClientPictureCacheTest() : cache_(&FakeImageDecoder) {} | |
| 28 ~BlimpClientPictureCacheTest() override = default; | |
| 29 | |
| 30 protected: | |
| 31 BlimpClientPictureCache cache_; | |
| 32 | |
| 33 private: | |
| 34 DISALLOW_COPY_AND_ASSIGN(BlimpClientPictureCacheTest); | |
| 35 }; | |
| 36 | |
| 37 TEST_F(BlimpClientPictureCacheTest, TwoSkPicturesInCache) { | |
| 38 sk_sp<const SkPicture> picture1 = CreateSkPicture(SK_ColorBLUE); | |
| 39 sk_sp<const SkPicture> picture2 = CreateSkPicture(SK_ColorRED); | |
| 40 cc::PictureData picture1_data = CreatePictureData(picture1); | |
| 41 cc::PictureData picture2_data = CreatePictureData(picture2); | |
| 42 | |
| 43 std::vector<cc::PictureData> cache_update; | |
| 44 cache_update.push_back(picture1_data); | |
| 45 cache_update.push_back(picture2_data); | |
| 46 | |
| 47 cache_.ApplyCacheUpdate(cache_update); | |
| 48 | |
| 49 cache_.MarkUsed(picture1->uniqueID()); | |
| 50 cache_.MarkUsed(picture2->uniqueID()); | |
| 51 | |
| 52 sk_sp<const SkPicture> cached_picture1 = | |
| 53 cache_.GetPicture(picture1->uniqueID()); | |
| 54 EXPECT_NE(nullptr, cached_picture1); | |
| 55 EXPECT_EQ(GetBlobId(picture1), GetBlobId(cached_picture1)); | |
| 56 sk_sp<const SkPicture> cached_picture2 = | |
| 57 cache_.GetPicture(picture2->uniqueID()); | |
| 58 EXPECT_NE(nullptr, cached_picture2); | |
| 59 EXPECT_EQ(GetBlobId(picture2), GetBlobId(cached_picture2)); | |
| 60 | |
| 61 cache_.Flush(); | |
| 62 } | |
| 63 | |
| 64 } // namespace | |
| 65 } // namespace client | |
| 66 } // namespace blimp | |
| OLD | NEW |