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 | |
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_; | |
Kevin M
2016/06/06 23:33:58
DISALLOW_COPY_AND_ASSIGN
nyquist
2016/06/10 22:02:24
Done.
| |
32 }; | |
33 | |
34 TEST_F(BlimpClientPictureCacheTest, TwoSkPicturesInCache) { | |
35 sk_sp<const SkPicture> picture1 = CreateSkPicture(SK_ColorBLUE); | |
36 sk_sp<const SkPicture> picture2 = CreateSkPicture(SK_ColorRED); | |
37 cc::PictureData picture1_data = CreatePictureData(picture1); | |
38 cc::PictureData picture2_data = CreatePictureData(picture2); | |
39 | |
40 cc::PictureCacheUpdate cache_update; | |
41 | |
42 cache_update.push_back(picture1_data); | |
43 cache_update.push_back(picture2_data); | |
44 | |
45 cache_.ApplyCacheUpdate(cache_update); | |
46 | |
47 cache_.MarkPictureForRegistration(picture1->uniqueID()); | |
48 cache_.MarkPictureForRegistration(picture2->uniqueID()); | |
49 | |
50 sk_sp<const SkPicture> cached_picture1 = | |
51 cache_.GetPicture(picture1->uniqueID()); | |
52 EXPECT_NE(nullptr, cached_picture1); | |
53 EXPECT_EQ(GetBlobId(picture1), GetBlobId(cached_picture1)); | |
54 sk_sp<const SkPicture> cached_picture2 = | |
55 cache_.GetPicture(picture2->uniqueID()); | |
56 EXPECT_NE(nullptr, cached_picture2); | |
57 EXPECT_EQ(GetBlobId(picture2), GetBlobId(cached_picture2)); | |
58 | |
59 cache_.Flush(); | |
60 } | |
61 | |
62 } // namespace | |
63 | |
64 } // namespace client | |
65 } // namespace blimp | |
OLD | NEW |