Chromium Code Reviews| Index: blimp/client/feature/compositor/blimp_client_picture_cache_unittest.cc |
| diff --git a/blimp/client/feature/compositor/blimp_client_picture_cache_unittest.cc b/blimp/client/feature/compositor/blimp_client_picture_cache_unittest.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..25e061ab18e8e3faf3babdc5d05df7404c4bd19d |
| --- /dev/null |
| +++ b/blimp/client/feature/compositor/blimp_client_picture_cache_unittest.cc |
| @@ -0,0 +1,65 @@ |
| +// 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/client/feature/compositor/blimp_client_picture_cache.h" |
| + |
| +#include <stdint.h> |
| +#include <memory> |
| +#include <vector> |
| + |
| +#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 client { |
| + |
| +namespace { |
| + |
| +bool FakeImageDecoder(const void* input, size_t input_size, SkBitmap* bitmap) { |
| + return true; |
| +} |
| + |
| +class BlimpClientPictureCacheTest : public testing::Test { |
| + public: |
| + BlimpClientPictureCacheTest() : cache_(&FakeImageDecoder) {} |
| + |
| + protected: |
| + BlimpClientPictureCache cache_; |
|
Kevin M
2016/06/06 23:33:58
DISALLOW_COPY_AND_ASSIGN
nyquist
2016/06/10 22:02:24
Done.
|
| +}; |
| + |
| +TEST_F(BlimpClientPictureCacheTest, TwoSkPicturesInCache) { |
| + sk_sp<const SkPicture> picture1 = CreateSkPicture(SK_ColorBLUE); |
| + sk_sp<const SkPicture> picture2 = CreateSkPicture(SK_ColorRED); |
| + cc::PictureData picture1_data = CreatePictureData(picture1); |
| + cc::PictureData picture2_data = CreatePictureData(picture2); |
| + |
| + cc::PictureCacheUpdate cache_update; |
| + |
| + cache_update.push_back(picture1_data); |
| + cache_update.push_back(picture2_data); |
| + |
| + cache_.ApplyCacheUpdate(cache_update); |
| + |
| + cache_.MarkPictureForRegistration(picture1->uniqueID()); |
| + cache_.MarkPictureForRegistration(picture2->uniqueID()); |
| + |
| + sk_sp<const SkPicture> cached_picture1 = |
| + cache_.GetPicture(picture1->uniqueID()); |
| + EXPECT_NE(nullptr, cached_picture1); |
| + EXPECT_EQ(GetBlobId(picture1), GetBlobId(cached_picture1)); |
| + sk_sp<const SkPicture> cached_picture2 = |
| + cache_.GetPicture(picture2->uniqueID()); |
| + EXPECT_NE(nullptr, cached_picture2); |
| + EXPECT_EQ(GetBlobId(picture2), GetBlobId(cached_picture2)); |
| + |
| + cache_.Flush(); |
| +} |
| + |
| +} // namespace |
| + |
| +} // namespace client |
| +} // namespace blimp |