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 template <typename LayerType
>
13 class MockOcclusionTracker
: public OcclusionTracker
<LayerType
> {
14 // This class is used for testing only. It fakes just enough information to
15 // calculate unoccluded content rect and unoccluded contributing surface
16 // content rect. It calls the helper function of occlusion tracker to avoid
17 // DCHECKs since testing environment won't be set up properly to pass those.
19 MockOcclusionTracker()
20 : OcclusionTracker
<LayerType
>(gfx::Rect(0, 0, 1000, 1000)) {
21 typename OcclusionTracker
<LayerType
>::StackObject stack_obj
;
22 OcclusionTracker
<LayerType
>::stack_
.push_back(stack_obj
);
23 OcclusionTracker
<LayerType
>::stack_
.push_back(stack_obj
);
26 explicit MockOcclusionTracker(const gfx::Rect
& screen_scissor_rect
)
27 : OcclusionTracker
<LayerType
>(screen_scissor_rect
) {
28 typename OcclusionTracker
<LayerType
>::StackObject stack_obj
;
29 OcclusionTracker
<LayerType
>::stack_
.push_back(stack_obj
);
30 OcclusionTracker
<LayerType
>::stack_
.push_back(stack_obj
);
33 void set_occluded_target_rect(const gfx::Rect
& occluded
) {
34 OcclusionTracker
<LayerType
>::stack_
.back().occlusion_from_inside_target
=
38 void set_occluded_target_rect_for_contributing_surface(
39 const gfx::Rect
& occluded
) {
41 LayerType
>::stack_
[OcclusionTracker
<LayerType
>::stack_
.size() - 2]
42 .occlusion_from_inside_target
= occluded
;
46 DISALLOW_COPY_AND_ASSIGN(MockOcclusionTracker
);
51 #endif // CC_TEST_MOCK_OCCLUSION_TRACKER_H_