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/client/feature/compositor/blimp_client_picture_cache.h" | |
| 6 | |
| 7 #include <stdint.h> | |
| 8 #include <memory> | |
| 9 #include <vector> | |
| 10 | |
| 11 #include "blimp/test/support/compositor/picture_cache_test_support.h" | |
| 12 #include "testing/gtest/include/gtest/gtest.h" | |
| 13 #include "third_party/skia/include/core/SkColor.h" | |
| 14 #include "third_party/skia/include/core/SkPicture.h" | |
| 15 #include "third_party/skia/include/core/SkRefCnt.h" | |
| 16 | |
| 17 namespace blimp { | |
| 18 namespace client { | |
| 19 | |
|
Kevin M
2016/06/11 00:29:32
remove newline here
nyquist
2016/06/14 01:37:57
Done.
| |
| 20 namespace { | |
| 21 | |
| 22 bool FakeImageDecoder(const void* input, size_t input_size, SkBitmap* bitmap) { | |
| 23 return true; | |
| 24 } | |
| 25 | |
| 26 class BlimpClientPictureCacheTest : public testing::Test { | |
| 27 public: | |
| 28 BlimpClientPictureCacheTest() : cache_(&FakeImageDecoder) {} | |
| 29 | |
| 30 protected: | |
| 31 BlimpClientPictureCache cache_; | |
| 32 | |
| 33 private: | |
| 34 DISALLOW_COPY_AND_ASSIGN(BlimpClientPictureCacheTest); | |
| 35 }; | |
| 36 | |
| 37 TEST_F(BlimpClientPictureCacheTest, TwoSkPicturesInCache) { | |
| 38 sk_sp<const SkPicture> picture1 = CreateSkPicture(SK_ColorBLUE); | |
| 39 sk_sp<const SkPicture> picture2 = CreateSkPicture(SK_ColorRED); | |
| 40 cc::PictureData picture1_data = CreatePictureData(picture1); | |
| 41 cc::PictureData picture2_data = CreatePictureData(picture2); | |
| 42 | |
| 43 cc::PictureCacheUpdate cache_update; | |
| 44 | |
|
Kevin M
2016/06/11 00:29:32
remove newline
nyquist
2016/06/14 01:37:57
Done.
| |
| 45 cache_update.push_back(picture1_data); | |
| 46 cache_update.push_back(picture2_data); | |
| 47 | |
| 48 cache_.ApplyCacheUpdate(cache_update); | |
| 49 | |
| 50 cache_.MarkPictureForRegistration(picture1->uniqueID()); | |
| 51 cache_.MarkPictureForRegistration(picture2->uniqueID()); | |
| 52 | |
| 53 sk_sp<const SkPicture> cached_picture1 = | |
| 54 cache_.GetPicture(picture1->uniqueID()); | |
| 55 EXPECT_NE(nullptr, cached_picture1); | |
| 56 EXPECT_EQ(GetBlobId(picture1), GetBlobId(cached_picture1)); | |
| 57 sk_sp<const SkPicture> cached_picture2 = | |
| 58 cache_.GetPicture(picture2->uniqueID()); | |
| 59 EXPECT_NE(nullptr, cached_picture2); | |
| 60 EXPECT_EQ(GetBlobId(picture2), GetBlobId(cached_picture2)); | |
| 61 | |
| 62 cache_.Flush(); | |
| 63 } | |
| 64 | |
| 65 } // namespace | |
| 66 | |
|
Kevin M
2016/06/11 00:29:32
remove newline
nyquist
2016/06/14 01:37:57
Done.
| |
| 67 } // namespace client | |
| 68 } // namespace blimp | |
| OLD | NEW |