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

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: git merge origin/master 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/gtest/include/gtest/gtest.h"
9 #include "third_party/skia/include/core/SkColor.h"
10 #include "third_party/skia/include/core/SkPicture.h"
11 #include "third_party/skia/include/core/SkRefCnt.h"
12
13 namespace blimp {
14 namespace engine {
15
Kevin M 2016/06/06 23:33:59 remove newline on 15, add one after 16
nyquist 2016/06/10 22:02:24 Done.
16 namespace {
17 class BlimpEnginePictureCacheTest : public testing::Test {
18 public:
19 BlimpEnginePictureCacheTest() : cache_(nullptr) {}
20
21 protected:
22 BlimpEnginePictureCache cache_;
23 };
24
25 TEST_F(BlimpEnginePictureCacheTest, TwoCachedPicturesCanBeRetrieved) {
26 EXPECT_EQ(0U, cache_.CalculateCacheUpdateAndFlush().size());
27
28 sk_sp<const SkPicture> picture1 = CreateSkPicture(SK_ColorBLUE);
29 cache_.MarkPictureForRegistration(picture1.get());
30 sk_sp<const SkPicture> picture2 = CreateSkPicture(SK_ColorRED);
31 cache_.MarkPictureForRegistration(picture2.get());
32
33 cc::PictureCacheUpdate update = cache_.CalculateCacheUpdateAndFlush();
34 ASSERT_EQ(2U, update.size());
35 cc::PictureData picture_data_a = update.at(0);
36 cc::PictureData picture_data_b = update.at(1);
37
38 // Order is unknown, but pictures should be the same.
Kevin M 2016/06/06 23:33:59 UnorderedElementsAre FTW! Just make a MATCHER_P fo
nyquist 2016/06/10 22:02:24 Wow.
39 EXPECT_TRUE((SamePicture(picture1, picture_data_a) &&
40 SamePicture(picture2, picture_data_b)) ||
41 (SamePicture(picture2, picture_data_a) &&
42 SamePicture(picture1, picture_data_b)));
43
44 EXPECT_EQ(0U, cache_.CalculateCacheUpdateAndFlush().size());
45 }
46
47 TEST_F(BlimpEnginePictureCacheTest, SamePictureOnlyReturnedOnce) {
48 EXPECT_EQ(0U, cache_.CalculateCacheUpdateAndFlush().size());
49
50 sk_sp<const SkPicture> picture = CreateSkPicture(SK_ColorBLUE);
51 cache_.MarkPictureForRegistration(picture.get());
52 cache_.MarkPictureForRegistration(picture.get());
53
54 cc::PictureCacheUpdate update = cache_.CalculateCacheUpdateAndFlush();
55 ASSERT_EQ(1U, update.size());
56 cc::PictureData picture_data = update.at(0);
57 EXPECT_TRUE(SamePicture(picture, picture_data));
58 }
59
60 } // namespace
61
Kevin M 2016/06/06 23:33:59 remove newline
nyquist 2016/06/10 22:02:24 Done.
62 } // namespace engine
63 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698