| Index: blimp/engine/renderer/blimp_engine_picture_cache_unittest.cc
|
| diff --git a/blimp/engine/renderer/blimp_engine_picture_cache_unittest.cc b/blimp/engine/renderer/blimp_engine_picture_cache_unittest.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..e3ee48b4fcb30e804d0919aebdabec885912b26d
|
| --- /dev/null
|
| +++ b/blimp/engine/renderer/blimp_engine_picture_cache_unittest.cc
|
| @@ -0,0 +1,63 @@
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "blimp/engine/renderer/blimp_engine_picture_cache.h"
|
| +
|
| +#include "blimp/test/support/compositor/picture_cache_test_support.h"
|
| +#include "testing/gtest/include/gtest/gtest.h"
|
| +#include "third_party/skia/include/core/SkColor.h"
|
| +#include "third_party/skia/include/core/SkPicture.h"
|
| +#include "third_party/skia/include/core/SkRefCnt.h"
|
| +
|
| +namespace blimp {
|
| +namespace engine {
|
| +
|
| +namespace {
|
| +class BlimpEnginePictureCacheTest : public testing::Test {
|
| + public:
|
| + BlimpEnginePictureCacheTest() : cache_(nullptr) {}
|
| +
|
| + protected:
|
| + BlimpEnginePictureCache cache_;
|
| +};
|
| +
|
| +TEST_F(BlimpEnginePictureCacheTest, TwoCachedPicturesCanBeRetrieved) {
|
| + EXPECT_EQ(0U, cache_.CalculateCacheUpdateAndFlush().size());
|
| +
|
| + sk_sp<const SkPicture> picture1 = CreateSkPicture(SK_ColorBLUE);
|
| + cache_.MarkPictureForRegistration(picture1.get());
|
| + sk_sp<const SkPicture> picture2 = CreateSkPicture(SK_ColorRED);
|
| + cache_.MarkPictureForRegistration(picture2.get());
|
| +
|
| + cc::PictureCacheUpdate update = cache_.CalculateCacheUpdateAndFlush();
|
| + ASSERT_EQ(2U, update.size());
|
| + cc::PictureData picture_data_a = update.at(0);
|
| + cc::PictureData picture_data_b = update.at(1);
|
| +
|
| + // Order is unknown, but pictures should be the same.
|
| + EXPECT_TRUE((SamePicture(picture1, picture_data_a) &&
|
| + SamePicture(picture2, picture_data_b)) ||
|
| + (SamePicture(picture2, picture_data_a) &&
|
| + SamePicture(picture1, picture_data_b)));
|
| +
|
| + EXPECT_EQ(0U, cache_.CalculateCacheUpdateAndFlush().size());
|
| +}
|
| +
|
| +TEST_F(BlimpEnginePictureCacheTest, SamePictureOnlyReturnedOnce) {
|
| + EXPECT_EQ(0U, cache_.CalculateCacheUpdateAndFlush().size());
|
| +
|
| + sk_sp<const SkPicture> picture = CreateSkPicture(SK_ColorBLUE);
|
| + cache_.MarkPictureForRegistration(picture.get());
|
| + cache_.MarkPictureForRegistration(picture.get());
|
| +
|
| + cc::PictureCacheUpdate update = cache_.CalculateCacheUpdateAndFlush();
|
| + ASSERT_EQ(1U, update.size());
|
| + cc::PictureData picture_data = update.at(0);
|
| + EXPECT_TRUE(SamePicture(picture, picture_data));
|
| +}
|
| +
|
| +} // namespace
|
| +
|
| +} // namespace engine
|
| +} // namespace blimp
|
|
|