1 // Copyright 2014 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.
5 #ifndef CC_TEST_MOCK_OCCLUSION_TRACKER_H_
6 #define CC_TEST_MOCK_OCCLUSION_TRACKER_H_
8 #include "cc/trees/occlusion_tracker.h"
12 class MockOcclusionTracker
: public OcclusionTracker
{
13 // This class is used for testing only. It fakes just enough information to
14 // calculate unoccluded content rect and unoccluded contributing surface
15 // content rect. It calls the helper function of occlusion tracker to avoid
16 // DCHECKs since testing environment won't be set up properly to pass those.
18 MockOcclusionTracker() : OcclusionTracker(gfx::Rect(0, 0, 1000, 1000)) {
19 OcclusionTracker::StackObject stack_obj
;
20 OcclusionTracker::stack_
.push_back(stack_obj
);
21 OcclusionTracker::stack_
.push_back(stack_obj
);
24 explicit MockOcclusionTracker(const gfx::Rect
& screen_scissor_rect
)
25 : OcclusionTracker(screen_scissor_rect
) {
26 OcclusionTracker::StackObject stack_obj
;
27 OcclusionTracker::stack_
.push_back(stack_obj
);
28 OcclusionTracker::stack_
.push_back(stack_obj
);
31 void set_occluded_target_rect(const gfx::Rect
& occluded
) {
32 OcclusionTracker::stack_
.back().occlusion_from_inside_target
= occluded
;
35 void set_occluded_target_rect_for_contributing_surface(
36 const gfx::Rect
& occluded
) {
37 OcclusionTracker::stack_
[OcclusionTracker::stack_
.size() - 2]
38 .occlusion_from_inside_target
= occluded
;
42 DISALLOW_COPY_AND_ASSIGN(MockOcclusionTracker
);
47 #endif // CC_TEST_MOCK_OCCLUSION_TRACKER_H_