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/engine/renderer/blimp_engine_picture_cache.h" |
| 6 |
| 7 #include "blimp/test/support/compositor/picture_cache_test_support.h" |
| 8 #include "testing/gmock/include/gmock/gmock.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "third_party/skia/include/core/SkColor.h" |
| 11 #include "third_party/skia/include/core/SkPicture.h" |
| 12 #include "third_party/skia/include/core/SkRefCnt.h" |
| 13 |
| 14 namespace blimp { |
| 15 namespace engine { |
| 16 namespace { |
| 17 |
| 18 class BlimpEnginePictureCacheTest : public testing::Test { |
| 19 public: |
| 20 BlimpEnginePictureCacheTest() : cache_(nullptr) {} |
| 21 ~BlimpEnginePictureCacheTest() override = default; |
| 22 |
| 23 protected: |
| 24 BlimpEnginePictureCache cache_; |
| 25 |
| 26 private: |
| 27 DISALLOW_COPY_AND_ASSIGN(BlimpEnginePictureCacheTest); |
| 28 }; |
| 29 |
| 30 TEST_F(BlimpEnginePictureCacheTest, TwoCachedPicturesCanBeRetrieved) { |
| 31 EXPECT_TRUE(cache_.CalculateCacheUpdateAndFlush().empty()); |
| 32 |
| 33 sk_sp<const SkPicture> picture1 = CreateSkPicture(SK_ColorBLUE); |
| 34 cache_.MarkUsed(picture1.get()); |
| 35 sk_sp<const SkPicture> picture2 = CreateSkPicture(SK_ColorRED); |
| 36 cache_.MarkUsed(picture2.get()); |
| 37 |
| 38 std::vector<cc::PictureData> update = cache_.CalculateCacheUpdateAndFlush(); |
| 39 ASSERT_EQ(2U, update.size()); |
| 40 EXPECT_THAT(update, testing::UnorderedElementsAre(PictureMatches(picture1), |
| 41 PictureMatches(picture2))); |
| 42 |
| 43 EXPECT_TRUE(cache_.CalculateCacheUpdateAndFlush().empty()); |
| 44 } |
| 45 |
| 46 TEST_F(BlimpEnginePictureCacheTest, SamePictureOnlyReturnedOnce) { |
| 47 EXPECT_TRUE(cache_.CalculateCacheUpdateAndFlush().empty()); |
| 48 |
| 49 sk_sp<const SkPicture> picture = CreateSkPicture(SK_ColorBLUE); |
| 50 cache_.MarkUsed(picture.get()); |
| 51 cache_.MarkUsed(picture.get()); |
| 52 |
| 53 std::vector<cc::PictureData> update = cache_.CalculateCacheUpdateAndFlush(); |
| 54 ASSERT_EQ(1U, update.size()); |
| 55 EXPECT_THAT(update, testing::UnorderedElementsAre(PictureMatches(picture))); |
| 56 } |
| 57 |
| 58 } // namespace |
| 59 } // namespace engine |
| 60 } // namespace blimp |
OLD | NEW |