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_; | |
|
Kevin M
2016/06/11 00:29:33
DISALLOW_COPY_AND_ASSIGN
nyquist
2016/06/14 01:37:57
Done.
| |
| 24 }; | |
| 25 | |
| 26 MATCHER_P(PictureMatches, picture, "") { | |
| 27 return SamePicture(picture, arg); | |
| 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_.MarkPictureForRegistration(picture1.get()); | |
| 35 sk_sp<const SkPicture> picture2 = CreateSkPicture(SK_ColorRED); | |
| 36 cache_.MarkPictureForRegistration(picture2.get()); | |
| 37 | |
| 38 cc::PictureCacheUpdate 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_.MarkPictureForRegistration(picture.get()); | |
| 51 cache_.MarkPictureForRegistration(picture.get()); | |
| 52 | |
| 53 cc::PictureCacheUpdate 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 |