Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Side by Side Diff: blimp/client/feature/compositor/blimp_client_picture_cache_unittest.cc

Issue 1982893002: [blimp] Add SkPicture caching support. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix memory leak by adding virtual destructor Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 namespace {
20
21 bool FakeImageDecoder(const void* input, size_t input_size, SkBitmap* bitmap) {
Kevin M 2016/06/17 17:53:37 Turn this into a MOCK_METHOD of BlimpClientPicture
nyquist 2016/06/17 21:31:43 I could not find a good way of doing this. Mocking
22 return true;
23 }
24
25 class BlimpClientPictureCacheTest : public testing::Test {
26 public:
27 BlimpClientPictureCacheTest() : cache_(&FakeImageDecoder) {}
28
29 protected:
30 BlimpClientPictureCache cache_;
31
32 private:
33 DISALLOW_COPY_AND_ASSIGN(BlimpClientPictureCacheTest);
34 };
35
36 TEST_F(BlimpClientPictureCacheTest, TwoSkPicturesInCache) {
37 sk_sp<const SkPicture> picture1 = CreateSkPicture(SK_ColorBLUE);
38 sk_sp<const SkPicture> picture2 = CreateSkPicture(SK_ColorRED);
39 cc::PictureData picture1_data = CreatePictureData(picture1);
40 cc::PictureData picture2_data = CreatePictureData(picture2);
41
42 cc::PictureCacheUpdate cache_update;
43 cache_update.push_back(picture1_data);
44 cache_update.push_back(picture2_data);
45
46 cache_.ApplyCacheUpdate(cache_update);
47
48 cache_.MarkPictureForRegistration(picture1->uniqueID());
49 cache_.MarkPictureForRegistration(picture2->uniqueID());
50
51 sk_sp<const SkPicture> cached_picture1 =
52 cache_.GetPicture(picture1->uniqueID());
53 EXPECT_NE(nullptr, cached_picture1);
54 EXPECT_EQ(GetBlobId(picture1), GetBlobId(cached_picture1));
55 sk_sp<const SkPicture> cached_picture2 =
56 cache_.GetPicture(picture2->uniqueID());
57 EXPECT_NE(nullptr, cached_picture2);
58 EXPECT_EQ(GetBlobId(picture2), GetBlobId(cached_picture2));
59
60 cache_.Flush();
61 }
62
63 } // namespace
64 } // namespace client
65 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698