OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "cc/output/context_cache_controller.h" |
| 6 |
| 7 #include "base/memory/ptr_util.h" |
| 8 #include "cc/test/test_context_provider.h" |
| 9 #include "cc/test/test_context_support.h" |
| 10 #include "cc/test/test_web_graphics_context_3d.h" |
| 11 #include "testing/gmock/include/gmock/gmock.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 |
| 14 namespace cc { |
| 15 namespace { |
| 16 using ::testing::Mock; |
| 17 using ::testing::StrictMock; |
| 18 |
| 19 class MockContextSupport : public TestContextSupport { |
| 20 public: |
| 21 MockContextSupport() {} |
| 22 MOCK_METHOD1(SetAggressivelyFreeResources, |
| 23 void(bool aggressively_free_resources)); |
| 24 }; |
| 25 |
| 26 TEST(ContextCacheControllerTest, ScopedVisibilityBasic) { |
| 27 StrictMock<MockContextSupport> context_support; |
| 28 ContextCacheController cache_controller(&context_support); |
| 29 |
| 30 EXPECT_CALL(context_support, SetAggressivelyFreeResources(false)); |
| 31 std::unique_ptr<ContextCacheController::ScopedVisibility> visibility = |
| 32 cache_controller.ClientBecameVisible(); |
| 33 Mock::VerifyAndClearExpectations(&context_support); |
| 34 |
| 35 EXPECT_CALL(context_support, SetAggressivelyFreeResources(true)); |
| 36 cache_controller.ClientBecameNotVisible(std::move(visibility)); |
| 37 } |
| 38 |
| 39 TEST(ContextCacheControllerTest, ScopedVisibilityMulti) { |
| 40 StrictMock<MockContextSupport> context_support; |
| 41 ContextCacheController cache_controller(&context_support); |
| 42 |
| 43 EXPECT_CALL(context_support, SetAggressivelyFreeResources(false)); |
| 44 std::unique_ptr<ContextCacheController::ScopedVisibility> visibility_1 = |
| 45 cache_controller.ClientBecameVisible(); |
| 46 Mock::VerifyAndClearExpectations(&context_support); |
| 47 std::unique_ptr<ContextCacheController::ScopedVisibility> visibility_2 = |
| 48 cache_controller.ClientBecameVisible(); |
| 49 |
| 50 cache_controller.ClientBecameNotVisible(std::move(visibility_1)); |
| 51 EXPECT_CALL(context_support, SetAggressivelyFreeResources(true)); |
| 52 cache_controller.ClientBecameNotVisible(std::move(visibility_2)); |
| 53 } |
| 54 |
| 55 } // namespace |
| 56 } // namespace cc |
OLD | NEW |