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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: blimp/engine/renderer/blimp_engine_picture_cache_unittest.cc
diff --git a/blimp/engine/renderer/blimp_engine_picture_cache_unittest.cc b/blimp/engine/renderer/blimp_engine_picture_cache_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..e3ee48b4fcb30e804d0919aebdabec885912b26d
--- /dev/null
+++ b/blimp/engine/renderer/blimp_engine_picture_cache_unittest.cc
@@ -0,0 +1,63 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "blimp/engine/renderer/blimp_engine_picture_cache.h"
+
+#include "blimp/test/support/compositor/picture_cache_test_support.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "third_party/skia/include/core/SkColor.h"
+#include "third_party/skia/include/core/SkPicture.h"
+#include "third_party/skia/include/core/SkRefCnt.h"
+
+namespace blimp {
+namespace engine {
+
Kevin M 2016/06/06 23:33:59 remove newline on 15, add one after 16
nyquist 2016/06/10 22:02:24 Done.
+namespace {
+class BlimpEnginePictureCacheTest : public testing::Test {
+ public:
+ BlimpEnginePictureCacheTest() : cache_(nullptr) {}
+
+ protected:
+ BlimpEnginePictureCache cache_;
+};
+
+TEST_F(BlimpEnginePictureCacheTest, TwoCachedPicturesCanBeRetrieved) {
+ EXPECT_EQ(0U, cache_.CalculateCacheUpdateAndFlush().size());
+
+ sk_sp<const SkPicture> picture1 = CreateSkPicture(SK_ColorBLUE);
+ cache_.MarkPictureForRegistration(picture1.get());
+ sk_sp<const SkPicture> picture2 = CreateSkPicture(SK_ColorRED);
+ cache_.MarkPictureForRegistration(picture2.get());
+
+ cc::PictureCacheUpdate update = cache_.CalculateCacheUpdateAndFlush();
+ ASSERT_EQ(2U, update.size());
+ cc::PictureData picture_data_a = update.at(0);
+ cc::PictureData picture_data_b = update.at(1);
+
+ // 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.
+ EXPECT_TRUE((SamePicture(picture1, picture_data_a) &&
+ SamePicture(picture2, picture_data_b)) ||
+ (SamePicture(picture2, picture_data_a) &&
+ SamePicture(picture1, picture_data_b)));
+
+ EXPECT_EQ(0U, cache_.CalculateCacheUpdateAndFlush().size());
+}
+
+TEST_F(BlimpEnginePictureCacheTest, SamePictureOnlyReturnedOnce) {
+ EXPECT_EQ(0U, cache_.CalculateCacheUpdateAndFlush().size());
+
+ sk_sp<const SkPicture> picture = CreateSkPicture(SK_ColorBLUE);
+ cache_.MarkPictureForRegistration(picture.get());
+ cache_.MarkPictureForRegistration(picture.get());
+
+ cc::PictureCacheUpdate update = cache_.CalculateCacheUpdateAndFlush();
+ ASSERT_EQ(1U, update.size());
+ cc::PictureData picture_data = update.at(0);
+ EXPECT_TRUE(SamePicture(picture, picture_data));
+}
+
+} // namespace
+
Kevin M 2016/06/06 23:33:59 remove newline
nyquist 2016/06/10 22:02:24 Done.
+} // namespace engine
+} // namespace blimp

Powered by Google App Engine
This is Rietveld 408576698