Commit b35eaf8f authored by Tom McKee's avatar Tom McKee Committed by Commit Bot

Add a Mock of cc::MutatorHost for testability

Change-Id: Ife1b3c2ca46f19361cf8f92da41528c2c55649c7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2015343Reviewed-by: default avatarRobert Flack <flackr@chromium.org>
Commit-Queue: Tom McKee <tommckee@chromium.org>
Cr-Commit-Position: refs/heads/master@{#735026}
parent 9b174c64
......@@ -482,6 +482,8 @@ cc_test_static_library("test_support") {
"test/layer_tree_test.h",
"test/mock_layer_tree_mutator.cc",
"test/mock_layer_tree_mutator.h",
"test/mock_mutator_host.cc",
"test/mock_mutator_host.h",
"test/mock_occlusion_tracker.h",
"test/paint_op_helper.h",
"test/pixel_comparator.cc",
......@@ -674,6 +676,7 @@ cc_test("cc_unittests") {
"resources/resource_pool_unittest.cc",
"scheduler/scheduler_state_machine_unittest.cc",
"scheduler/scheduler_unittest.cc",
"test/mock_mutator_host_unittest.cc",
"tiles/checker_image_tracker_unittest.cc",
"tiles/decoded_image_tracker_unittest.cc",
"tiles/gpu_image_decode_cache_unittest.cc",
......
// Copyright 2020 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/test/mock_mutator_host.h"
#include "cc/trees/property_tree.h"
namespace cc {
MockMutatorHost::MockMutatorHost() = default;
MockMutatorHost::~MockMutatorHost() = default;
} // namespace cc
// Copyright 2020 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.
#ifndef CC_TEST_MOCK_MUTATOR_HOST_H_
#define CC_TEST_MOCK_MUTATOR_HOST_H_
#include <memory>
#include "cc/trees/mutator_host.h"
#include "testing/gmock/include/gmock/gmock.h"
namespace cc {
class MockMutatorHost : public MutatorHost {
public:
MockMutatorHost();
~MockMutatorHost();
MOCK_CONST_METHOD1(CreateImplInstance, std::unique_ptr<MutatorHost>(bool));
MOCK_METHOD0(ClearMutators, void());
MOCK_METHOD1(UpdateRegisteredElementIds, void(ElementListType changed_list));
MOCK_METHOD0(InitClientAnimationState, void());
MOCK_METHOD2(RegisterElementId, void(ElementId, ElementListType));
MOCK_METHOD2(UnregisterElementId,
void(ElementId element_id, ElementListType list_type));
MOCK_METHOD1(SetMutatorHostClient, void(MutatorHostClient* client));
MOCK_METHOD1(SetLayerTreeMutator,
void(std::unique_ptr<LayerTreeMutator> mutator));
MOCK_METHOD1(PushPropertiesTo, void(MutatorHost* host_impl));
MOCK_METHOD1(SetSupportsScrollAnimations,
void(bool supports_scroll_animations));
MOCK_METHOD1(SetScrollAnimationDurationForTesting,
void(base::TimeDelta duration));
MOCK_CONST_METHOD0(NeedsTickAnimations, bool());
MOCK_METHOD1(ActivateAnimations, bool(MutatorEvents* events));
MOCK_METHOD3(TickAnimations,
bool(base::TimeTicks monotonic_time,
const ScrollTree& scroll_tree,
bool is_active_tree));
MOCK_METHOD2(TickScrollAnimations,
void(base::TimeTicks monotonic_time,
const ScrollTree& scroll_tree));
MOCK_METHOD0(TickWorkletAnimations, void());
MOCK_METHOD2(UpdateAnimationState,
bool(bool start_ready_animations, MutatorEvents* events));
MOCK_METHOD1(TakeTimeUpdatedEvents, void(MutatorEvents* events));
MOCK_METHOD0(PromoteScrollTimelinesPendingToActive, void());
MOCK_METHOD0(CreateEvents, std::unique_ptr<MutatorEvents>());
MOCK_METHOD1(SetAnimationEvents, void(std::unique_ptr<MutatorEvents> events));
MOCK_CONST_METHOD1(ScrollOffsetAnimationWasInterrupted,
bool(ElementId element_id));
MOCK_CONST_METHOD2(IsAnimatingFilterProperty,
bool(ElementId element_id, ElementListType list_type));
MOCK_CONST_METHOD2(IsAnimatingBackdropFilterProperty,
bool(ElementId element_id, ElementListType list_type));
MOCK_CONST_METHOD2(IsAnimatingOpacityProperty,
bool(ElementId element_id, ElementListType list_type));
MOCK_CONST_METHOD2(IsAnimatingTransformProperty,
bool(ElementId element_id, ElementListType list_type));
MOCK_CONST_METHOD2(HasPotentiallyRunningFilterAnimation,
bool(ElementId element_id, ElementListType list_type));
MOCK_CONST_METHOD2(HasPotentiallyRunningBackdropFilterAnimation,
bool(ElementId element_id, ElementListType list_type));
MOCK_CONST_METHOD2(HasPotentiallyRunningOpacityAnimation,
bool(ElementId element_id, ElementListType list_type));
MOCK_CONST_METHOD2(HasPotentiallyRunningTransformAnimation,
bool(ElementId element_id, ElementListType list_type));
MOCK_CONST_METHOD2(HasAnyAnimationTargetingProperty,
bool(ElementId element_id, TargetProperty::Type property));
MOCK_CONST_METHOD1(AnimationsPreserveAxisAlignment,
bool(ElementId element_id));
MOCK_CONST_METHOD4(GetAnimationScales,
void(ElementId element_id,
ElementListType list_type,
float* maximum_scale,
float* starting_scale));
MOCK_CONST_METHOD1(IsElementAnimating, bool(ElementId element_id));
MOCK_CONST_METHOD1(HasTickingKeyframeModelForTesting,
bool(ElementId element_id));
MOCK_METHOD5(ImplOnlyAutoScrollAnimationCreate,
void(ElementId element_id,
const gfx::ScrollOffset& target_offset,
const gfx::ScrollOffset& current_offset,
float autoscroll_velocity,
base::TimeDelta animation_start_offset));
MOCK_METHOD5(ImplOnlyScrollAnimationCreate,
void(ElementId element_id,
const gfx::ScrollOffset& target_offset,
const gfx::ScrollOffset& current_offset,
base::TimeDelta delayed_by,
base::TimeDelta animation_start_offset));
MOCK_METHOD4(ImplOnlyScrollAnimationUpdateTarget,
bool(const gfx::Vector2dF& scroll_delta,
const gfx::ScrollOffset& max_scroll_offset,
base::TimeTicks frame_monotonic_time,
base::TimeDelta delayed_by));
MOCK_METHOD0(ScrollAnimationAbort, void());
MOCK_CONST_METHOD0(IsImplOnlyScrollAnimating, bool());
MOCK_CONST_METHOD0(CompositedAnimationsCount, size_t());
MOCK_CONST_METHOD0(MainThreadAnimationsCount, size_t());
MOCK_CONST_METHOD0(HasCustomPropertyAnimations, bool());
MOCK_CONST_METHOD0(CurrentFrameHadRAF, bool());
MOCK_CONST_METHOD0(NextFrameHasPendingRAF, bool());
};
} // namespace cc
#endif // CC_TEST_MOCK_MUTATOR_HOST_H_
// Copyright 2020 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/test/mock_mutator_host.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace cc {
TEST(TestMockMutatorHost, ConstructAndPoke) {
MockMutatorHost mock;
EXPECT_CALL(mock, NextFrameHasPendingRAF).Times(1);
mock.NextFrameHasPendingRAF();
}
} // namespace cc
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment