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

Unified Diff: cc/output/managed_memory_policy_unittest.cc

Issue 1490513005: Add support for ManagedMemoryPolicy (de)serialization (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@renderer-settings
Patch Set: Add missing return-statements for conversions Created 5 years 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: cc/output/managed_memory_policy_unittest.cc
diff --git a/cc/output/managed_memory_policy_unittest.cc b/cc/output/managed_memory_policy_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..3ba75461aba1f0a8b7f435a4ee7cc5c29108c02c
--- /dev/null
+++ b/cc/output/managed_memory_policy_unittest.cc
@@ -0,0 +1,41 @@
+// Copyright 2015 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 "cc/output/managed_memory_policy.h"
+
+#include "cc/proto/managed_memory_policy.pb.h"
+#include "cc/proto/memory_allocation.pb.h"
+#include "gpu/command_buffer/common/gpu_memory_allocation.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace cc {
+namespace {
+
+void VerifySerializeAndDeserialize(
+ size_t bytes_limit_when_visible,
+ gpu::MemoryAllocation::PriorityCutoff priority_cutoff_when_visible,
+ size_t num_resources_limit) {
+ ManagedMemoryPolicy policy1(bytes_limit_when_visible,
+ gpu::MemoryAllocation::CUTOFF_ALLOW_REQUIRED_ONLY,
+ num_resources_limit);
+ proto::ManagedMemoryPolicy proto;
+ policy1.ToProtobuf(&proto);
+ ManagedMemoryPolicy policy2(1);
+ policy2.FromProtobuf(proto);
+ EXPECT_EQ(policy1, policy2);
+}
+
+TEST(ManagedMemoryPolicyTest, SerializeDeserialize) {
+ VerifySerializeAndDeserialize(
+ 42, gpu::MemoryAllocation::CUTOFF_ALLOW_REQUIRED_ONLY, 24);
+ VerifySerializeAndDeserialize(0, gpu::MemoryAllocation::CUTOFF_ALLOW_NOTHING,
+ 1);
+ VerifySerializeAndDeserialize(
+ 1, gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE, 0);
+ VerifySerializeAndDeserialize(
+ 1024, gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING, 4096);
+}
+
+} // namespace
+} // namespace cc

Powered by Google App Engine
This is Rietveld 408576698