| Index: cc/test/animation_timelines_test_common.h
|
| diff --git a/cc/test/animation_timelines_test_common.h b/cc/test/animation_timelines_test_common.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..0ea13e7e9a779ab611b08c46d037d01150e7035c
|
| --- /dev/null
|
| +++ b/cc/test/animation_timelines_test_common.h
|
| @@ -0,0 +1,153 @@
|
| +// Copyright 2015 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_ANIMATION_TIMELINES_TEST_COMMON_H_
|
| +#define CC_TEST_ANIMATION_TIMELINES_TEST_COMMON_H_
|
| +
|
| +#include "cc/animation/animation.h"
|
| +#include "cc/animation/animation_delegate.h"
|
| +#include "cc/animation/animation_host.h"
|
| +#include "cc/public/mutator_host_client.h"
|
| +#include "testing/gtest/include/gtest/gtest.h"
|
| +#include "ui/gfx/geometry/scroll_offset.h"
|
| +
|
| +namespace cc {
|
| +
|
| +struct TestLayer {
|
| + TestLayer();
|
| +
|
| + void ClearMutatedProperties();
|
| +
|
| + int transform_x_;
|
| + int transform_y_;
|
| +
|
| + float opacity_;
|
| + float brightness_;
|
| + gfx::ScrollOffset scroll_offset_;
|
| +
|
| + bool mutated_properties_[Animation::LAST_TARGET_PROPERTY + 1];
|
| +};
|
| +
|
| +class TestHostClient : public MutatorHostClient {
|
| + public:
|
| + explicit TestHostClient(ThreadInstance thread_instance);
|
| + ~TestHostClient();
|
| +
|
| + void ClearMutatedProperties();
|
| +
|
| + bool IsLayerInTree(int layer_id, LayerTreeType tree_type) const override;
|
| +
|
| + void SetMutatorsNeedCommit() override;
|
| +
|
| + void SetLayerFilterMutated(int layer_id,
|
| + LayerTreeType tree_type,
|
| + const FilterOperations& filters) override;
|
| +
|
| + void SetLayerOpacityMutated(int layer_id,
|
| + LayerTreeType tree_type,
|
| + float opacity) override;
|
| +
|
| + void SetLayerTransformMutated(int layer_id,
|
| + LayerTreeType tree_type,
|
| + const gfx::Transform& transform) override;
|
| +
|
| + void SetLayerScrollOffsetMutated(
|
| + int layer_id,
|
| + LayerTreeType tree_type,
|
| + const gfx::ScrollOffset& scroll_offset) override;
|
| +
|
| + bool mutators_need_commit() const { return mutators_need_commit_; }
|
| + void set_mutators_need_commit(bool need) { mutators_need_commit_ = need; }
|
| +
|
| + void RegisterLayer(int layer_id, LayerTreeType tree_type);
|
| + void UnregisterLayer(int layer_id, LayerTreeType tree_type);
|
| +
|
| + AnimationHost* host() {
|
| + DCHECK(host_);
|
| + return host_.get();
|
| + }
|
| +
|
| + bool IsPropertyMutated(int layer_id,
|
| + LayerTreeType tree_type,
|
| + Animation::TargetProperty property) const;
|
| +
|
| + void ExpectFilterPropertyMutated(int layer_id,
|
| + LayerTreeType tree_type,
|
| + float brightness) const;
|
| + void ExpectOpacityPropertyMutated(int layer_id,
|
| + LayerTreeType tree_type,
|
| + float opacity) const;
|
| + void ExpectTransformPropertyMutated(int layer_id,
|
| + LayerTreeType tree_type,
|
| + int transform_x,
|
| + int transform_y) const;
|
| + void ExpectScrollOffsetPropertyMutated(
|
| + int layer_id,
|
| + LayerTreeType tree_type,
|
| + const gfx::ScrollOffset& scroll_offset) const;
|
| +
|
| + TestLayer* FindTestLayer(int layer_id, LayerTreeType tree_type) const;
|
| +
|
| + private:
|
| + scoped_ptr<AnimationHost> host_;
|
| +
|
| + typedef base::hash_map<int, TestLayer*> LayerIdToTestLayer;
|
| + LayerIdToTestLayer layers_in_active_tree_;
|
| + LayerIdToTestLayer layers_in_pending_tree_;
|
| +
|
| + bool mutators_need_commit_;
|
| +};
|
| +
|
| +class TestAnimationDelegate : public AnimationDelegate {
|
| + public:
|
| + TestAnimationDelegate();
|
| +
|
| + void NotifyAnimationStarted(base::TimeTicks monotonic_time,
|
| + Animation::TargetProperty target_property,
|
| + int group) override;
|
| + void NotifyAnimationFinished(base::TimeTicks monotonic_time,
|
| + Animation::TargetProperty target_property,
|
| + int group) override;
|
| + bool started_;
|
| + bool finished_;
|
| +};
|
| +
|
| +class AnimationTimelinesTest : public testing::Test {
|
| + public:
|
| + AnimationTimelinesTest();
|
| + ~AnimationTimelinesTest() override;
|
| +
|
| + protected:
|
| + void SetUp() override;
|
| +
|
| + void GetImplTimelineAndPlayerByID();
|
| +
|
| + void ReleaseRefPtrs();
|
| +
|
| + void AnimateLayersTransferEvents(base::TimeTicks time,
|
| + unsigned expect_events);
|
| +
|
| + AnimationPlayer* GetPlayerForLayerId(int layer_id);
|
| + AnimationPlayer* GetImplPlayerForLayerId(int layer_id);
|
| +
|
| + TestHostClient client_;
|
| + TestHostClient client_impl_;
|
| +
|
| + AnimationHost* host_;
|
| + AnimationHost* host_impl_;
|
| +
|
| + const int timeline_id_;
|
| + const int player_id_;
|
| + const int layer_id_;
|
| +
|
| + scoped_refptr<AnimationTimeline> timeline_;
|
| + scoped_refptr<AnimationPlayer> player_;
|
| +
|
| + scoped_refptr<AnimationTimeline> timeline_impl_;
|
| + scoped_refptr<AnimationPlayer> player_impl_;
|
| +};
|
| +
|
| +} // namespace cc
|
| +
|
| +#endif // CC_TEST_ANIMATION_TIMELINES_TEST_COMMON_H_
|
|
|