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

Unified Diff: cc/output/context_cache_controller_unittest.cc

Issue 2278283003: Refactor client visibility handling (Closed)
Patch Set: fix compositor_unittests Created 4 years, 4 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: cc/output/context_cache_controller_unittest.cc
diff --git a/cc/output/context_cache_controller_unittest.cc b/cc/output/context_cache_controller_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..9b682d5f2fb7d4634660b947d0ba9d8fe6bd2408
--- /dev/null
+++ b/cc/output/context_cache_controller_unittest.cc
@@ -0,0 +1,53 @@
+// Copyright (c) 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 "cc/output/context_cache_controller.h"
+
+#include "base/memory/ptr_util.h"
+#include "cc/test/test_context_provider.h"
+#include "cc/test/test_context_support.h"
+#include "cc/test/test_web_graphics_context_3d.h"
+#include "testing/gmock/include/gmock/gmock.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace cc {
+namespace {
+using ::testing::Mock;
+using ::testing::StrictMock;
+
+class MockContextSupport : public TestContextSupport {
+ public:
+ MockContextSupport() {}
+ MOCK_METHOD1(SetAggressivelyFreeResources,
+ void(bool aggressively_free_resources));
+};
+
+TEST(ContextCacheControllerTest, ScopedVisibilityBasic) {
+ StrictMock<MockContextSupport> context_support;
+ ContextCacheController cache_controller(&context_support);
+
+ EXPECT_CALL(context_support, SetAggressivelyFreeResources(false));
+ auto visibility = cache_controller.ClientBecameVisible();
danakj 2016/08/26 23:49:08 the type of |visiblity| is not actually mentioned
ericrk 2016/08/29 22:43:22 sure - but it's sooo long :P
+ Mock::VerifyAndClearExpectations(&context_support);
+
+ EXPECT_CALL(context_support, SetAggressivelyFreeResources(true));
+ cache_controller.ClientBecameNotVisible(std::move(visibility));
+}
+
+TEST(ContextCacheControllerTest, ScopedVisibilityMulti) {
+ StrictMock<MockContextSupport> context_support;
+ ContextCacheController cache_controller(&context_support);
+
+ EXPECT_CALL(context_support, SetAggressivelyFreeResources(false));
+ auto visibility_1 = cache_controller.ClientBecameVisible();
+ Mock::VerifyAndClearExpectations(&context_support);
+ auto visibility_2 = cache_controller.ClientBecameVisible();
+
+ cache_controller.ClientBecameNotVisible(std::move(visibility_1));
+ EXPECT_CALL(context_support, SetAggressivelyFreeResources(true));
+ cache_controller.ClientBecameNotVisible(std::move(visibility_2));
+}
+
+} // namespace
+} // namespace cc

Powered by Google App Engine
This is Rietveld 408576698