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

Unified Diff: cc/trees/layer_tree_host_impl_unittest.cc

Issue 165773004: CC: Add test for implicit limit overflow. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@CC_fix_mem_overflow
Patch Set: Created 6 years, 10 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
« no previous file with comments | « cc/trees/layer_tree_host_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/trees/layer_tree_host_impl_unittest.cc
diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc
index 22174b4aff7beb19cca12041c12a74897e332b65..5f45115f186bfca8df31ae02898470f73494daa3 100644
--- a/cc/trees/layer_tree_host_impl_unittest.cc
+++ b/cc/trees/layer_tree_host_impl_unittest.cc
@@ -5848,5 +5848,30 @@ TEST_F(LayerTreeHostImplWithTopControlsTest, NoIdleAnimations) {
EXPECT_FALSE(did_request_redraw_);
}
+class LayerTreeHostImplWithImplicitLimitsTest : public LayerTreeHostImplTest {
+ public:
+ virtual void SetUp() OVERRIDE {
+ LayerTreeSettings settings = DefaultSettings();
+ settings.max_unused_resource_memory_percentage = 50;
+ settings.max_memory_for_prepaint_percentage = 50;
+ CreateHostImpl(settings, CreateOutputSurface());
+ }
+};
+
+TEST_F(LayerTreeHostImplWithImplicitLimitsTest, ImplicitMemoryLimits) {
+ // Set up a memory policy and percentages which could cause
+ // 32-bit integer overflows.
+ ManagedMemoryPolicy mem_policy(300 * 1024 * 1024); // 300MB
+
+ // Verify implicit limits are calculated correctly with no overflows
+ host_impl_->SetMemoryPolicy(mem_policy);
+ EXPECT_EQ(host_impl_->global_tile_state().hard_memory_limit_in_bytes,
+ 300u * 1024u * 1024u);
+ EXPECT_EQ(host_impl_->global_tile_state().soft_memory_limit_in_bytes,
+ 150u * 1024u * 1024u);
+ EXPECT_EQ(host_impl_->global_tile_state().unused_memory_limit_in_bytes,
+ 75u * 1024u * 1024u);
+}
+
} // namespace
} // namespace cc
« no previous file with comments | « cc/trees/layer_tree_host_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698