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

Side by Side Diff: blimp/engine/renderer/blimp_engine_picture_cache_unittest.cc

Issue 1982893002: [blimp] Add SkPicture caching support. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments from kmarshall 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/engine/renderer/blimp_engine_picture_cache.h"
6
7 #include "blimp/test/support/compositor/picture_cache_test_support.h"
8 #include "testing/gmock/include/gmock/gmock.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "third_party/skia/include/core/SkColor.h"
11 #include "third_party/skia/include/core/SkPicture.h"
12 #include "third_party/skia/include/core/SkRefCnt.h"
13
14 namespace blimp {
15 namespace engine {
16 namespace {
17
18 class BlimpEnginePictureCacheTest : public testing::Test {
19 public:
20 BlimpEnginePictureCacheTest() : cache_(nullptr) {}
21
22 protected:
23 BlimpEnginePictureCache cache_;
24
25 private:
26 DISALLOW_COPY_AND_ASSIGN(BlimpEnginePictureCacheTest);
27 };
28
29 TEST_F(BlimpEnginePictureCacheTest, TwoCachedPicturesCanBeRetrieved) {
30 EXPECT_TRUE(cache_.CalculateCacheUpdateAndFlush().empty());
31
32 sk_sp<const SkPicture> picture1 = CreateSkPicture(SK_ColorBLUE);
33 cache_.MarkPictureForRegistration(picture1.get());
34 sk_sp<const SkPicture> picture2 = CreateSkPicture(SK_ColorRED);
35 cache_.MarkPictureForRegistration(picture2.get());
36
37 cc::PictureCacheUpdate update = cache_.CalculateCacheUpdateAndFlush();
38 ASSERT_EQ(2U, update.size());
39 EXPECT_THAT(update, testing::UnorderedElementsAre(PictureMatches(picture1),
40 PictureMatches(picture2)));
41
42 EXPECT_TRUE(cache_.CalculateCacheUpdateAndFlush().empty());
43 }
44
45 TEST_F(BlimpEnginePictureCacheTest, SamePictureOnlyReturnedOnce) {
46 EXPECT_TRUE(cache_.CalculateCacheUpdateAndFlush().empty());
47
48 sk_sp<const SkPicture> picture = CreateSkPicture(SK_ColorBLUE);
49 cache_.MarkPictureForRegistration(picture.get());
50 cache_.MarkPictureForRegistration(picture.get());
51
52 cc::PictureCacheUpdate update = cache_.CalculateCacheUpdateAndFlush();
53 ASSERT_EQ(1U, update.size());
54 EXPECT_THAT(update, testing::UnorderedElementsAre(PictureMatches(picture)));
55 }
56
57 } // namespace
58 } // namespace engine
59 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698