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

Side by Side Diff: cc/output/context_cache_controller_unittest.cc

Issue 2278283003: Refactor client visibility handling (Closed)
Patch Set: fix compositor_unittests Created 4 years, 3 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 unified diff | Download patch
OLDNEW
(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 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
32 Mock::VerifyAndClearExpectations(&context_support);
33
34 EXPECT_CALL(context_support, SetAggressivelyFreeResources(true));
35 cache_controller.ClientBecameNotVisible(std::move(visibility));
36 }
37
38 TEST(ContextCacheControllerTest, ScopedVisibilityMulti) {
39 StrictMock<MockContextSupport> context_support;
40 ContextCacheController cache_controller(&context_support);
41
42 EXPECT_CALL(context_support, SetAggressivelyFreeResources(false));
43 auto visibility_1 = cache_controller.ClientBecameVisible();
44 Mock::VerifyAndClearExpectations(&context_support);
45 auto visibility_2 = cache_controller.ClientBecameVisible();
46
47 cache_controller.ClientBecameNotVisible(std::move(visibility_1));
48 EXPECT_CALL(context_support, SetAggressivelyFreeResources(true));
49 cache_controller.ClientBecameNotVisible(std::move(visibility_2));
50 }
51
52 } // namespace
53 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698