Chromium Code Reviews| 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 | |
| 22 protected: | |
| 23 BlimpEnginePictureCache cache_; | |
| 24 | |
| 25 private: | |
| 26 DISALLOW_COPY_AND_ASSIGN(BlimpEnginePictureCacheTest); | |
| 27 }; | |
| 28 | |
| 29 MATCHER_P(PictureMatches, picture, "") { | |
| 30 return SamePicture(picture, arg); | |
| 31 } | |
| 32 | |
| 33 TEST_F(BlimpEnginePictureCacheTest, TwoCachedPicturesCanBeRetrieved) { | |
| 34 EXPECT_TRUE(cache_.CalculateCacheUpdateAndFlush().empty()); | |
| 35 | |
| 36 sk_sp<const SkPicture> picture1 = CreateSkPicture(SK_ColorBLUE); | |
| 37 cache_.MarkPictureForRegistration(picture1.get()); | |
| 38 sk_sp<const SkPicture> picture2 = CreateSkPicture(SK_ColorRED); | |
| 39 cache_.MarkPictureForRegistration(picture2.get()); | |
| 40 | |
| 41 cc::PictureCacheUpdate update = cache_.CalculateCacheUpdateAndFlush(); | |
| 42 ASSERT_EQ(2U, update.size()); | |
| 43 EXPECT_THAT(update, testing::UnorderedElementsAre(PictureMatches(picture1), | |
|
vmpstr
2016/06/16 22:09:59
O_O TIL
nyquist
2016/06/24 11:11:14
:-)
| |
| 44 PictureMatches(picture2))); | |
| 45 | |
| 46 EXPECT_TRUE(cache_.CalculateCacheUpdateAndFlush().empty()); | |
| 47 } | |
| 48 | |
| 49 TEST_F(BlimpEnginePictureCacheTest, SamePictureOnlyReturnedOnce) { | |
| 50 EXPECT_TRUE(cache_.CalculateCacheUpdateAndFlush().empty()); | |
| 51 | |
| 52 sk_sp<const SkPicture> picture = CreateSkPicture(SK_ColorBLUE); | |
| 53 cache_.MarkPictureForRegistration(picture.get()); | |
| 54 cache_.MarkPictureForRegistration(picture.get()); | |
| 55 | |
| 56 cc::PictureCacheUpdate update = cache_.CalculateCacheUpdateAndFlush(); | |
| 57 ASSERT_EQ(1U, update.size()); | |
| 58 EXPECT_THAT(update, testing::UnorderedElementsAre(PictureMatches(picture))); | |
| 59 } | |
| 60 | |
| 61 } // namespace | |
| 62 } // namespace engine | |
| 63 } // namespace blimp | |
| OLD | NEW |