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

Unified Diff: cc/output/context_cache_controller_unittest.cc

Issue 2278283003: Refactor client visibility handling (Closed)
Patch Set: more fixes 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
« no previous file with comments | « cc/output/context_cache_controller.cc ('k') | cc/output/context_provider.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..39f8d1e0ab1ebb7e10d0ebc90dda6f1dcc7ef034
--- /dev/null
+++ b/cc/output/context_cache_controller_unittest.cc
@@ -0,0 +1,56 @@
+// 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));
+ std::unique_ptr<ContextCacheController::ScopedVisibility> visibility =
+ cache_controller.ClientBecameVisible();
+ 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));
+ std::unique_ptr<ContextCacheController::ScopedVisibility> visibility_1 =
+ cache_controller.ClientBecameVisible();
+ Mock::VerifyAndClearExpectations(&context_support);
+ std::unique_ptr<ContextCacheController::ScopedVisibility> 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
« no previous file with comments | « cc/output/context_cache_controller.cc ('k') | cc/output/context_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698