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

Unified 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: 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 side-by-side diff with in-line comments
Download patch
Index: blimp/client/feature/compositor/blimp_client_picture_cache_unittest.cc
diff --git a/blimp/client/feature/compositor/blimp_client_picture_cache_unittest.cc b/blimp/client/feature/compositor/blimp_client_picture_cache_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..fbcce9b3e135c290af5ff006fd52fbe2d8ceb838
--- /dev/null
+++ b/blimp/client/feature/compositor/blimp_client_picture_cache_unittest.cc
@@ -0,0 +1,68 @@
+// 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/client/feature/compositor/blimp_client_picture_cache.h"
+
+#include <stdint.h>
+#include <memory>
+#include <vector>
+
+#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 client {
+
Kevin M 2016/06/11 00:29:32 remove newline here
nyquist 2016/06/14 01:37:57 Done.
+namespace {
+
+bool FakeImageDecoder(const void* input, size_t input_size, SkBitmap* bitmap) {
+ return true;
+}
+
+class BlimpClientPictureCacheTest : public testing::Test {
+ public:
+ BlimpClientPictureCacheTest() : cache_(&FakeImageDecoder) {}
+
+ protected:
+ BlimpClientPictureCache cache_;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(BlimpClientPictureCacheTest);
+};
+
+TEST_F(BlimpClientPictureCacheTest, TwoSkPicturesInCache) {
+ sk_sp<const SkPicture> picture1 = CreateSkPicture(SK_ColorBLUE);
+ sk_sp<const SkPicture> picture2 = CreateSkPicture(SK_ColorRED);
+ cc::PictureData picture1_data = CreatePictureData(picture1);
+ cc::PictureData picture2_data = CreatePictureData(picture2);
+
+ cc::PictureCacheUpdate cache_update;
+
Kevin M 2016/06/11 00:29:32 remove newline
nyquist 2016/06/14 01:37:57 Done.
+ cache_update.push_back(picture1_data);
+ cache_update.push_back(picture2_data);
+
+ cache_.ApplyCacheUpdate(cache_update);
+
+ cache_.MarkPictureForRegistration(picture1->uniqueID());
+ cache_.MarkPictureForRegistration(picture2->uniqueID());
+
+ sk_sp<const SkPicture> cached_picture1 =
+ cache_.GetPicture(picture1->uniqueID());
+ EXPECT_NE(nullptr, cached_picture1);
+ EXPECT_EQ(GetBlobId(picture1), GetBlobId(cached_picture1));
+ sk_sp<const SkPicture> cached_picture2 =
+ cache_.GetPicture(picture2->uniqueID());
+ EXPECT_NE(nullptr, cached_picture2);
+ EXPECT_EQ(GetBlobId(picture2), GetBlobId(cached_picture2));
+
+ cache_.Flush();
+}
+
+} // namespace
+
Kevin M 2016/06/11 00:29:32 remove newline
nyquist 2016/06/14 01:37:57 Done.
+} // namespace client
+} // namespace blimp

Powered by Google App Engine
This is Rietveld 408576698