Exemple #1
0
TEST_F(GraphicsLayerTest, updateLayerShouldFlattenTransformWithAnimations) {
  ASSERT_FALSE(m_platformLayer->hasTickingAnimationForTesting());

  std::unique_ptr<CompositorFloatAnimationCurve> curve =
      CompositorFloatAnimationCurve::create();
  curve->addKeyframe(CompositorFloatKeyframe(
      0.0, 0.0, *CubicBezierTimingFunction::preset(
                    CubicBezierTimingFunction::EaseType::EASE)));
  std::unique_ptr<CompositorAnimation> floatAnimation(
      CompositorAnimation::create(*curve, CompositorTargetProperty::OPACITY, 0,
                                  0));
  int animationId = floatAnimation->id();

  std::unique_ptr<CompositorAnimationTimeline> compositorTimeline =
      CompositorAnimationTimeline::create();
  AnimationPlayerForTesting player;

  layerTreeView()->attachCompositorAnimationTimeline(
      compositorTimeline->animationTimeline());
  compositorTimeline->playerAttached(player);

  m_platformLayer->setElementId(CompositorElementId(m_platformLayer->id(), 0));

  player.compositorPlayer()->attachElement(m_platformLayer->elementId());
  ASSERT_TRUE(player.compositorPlayer()->isElementAttached());

  player.compositorPlayer()->addAnimation(std::move(floatAnimation));

  ASSERT_TRUE(m_platformLayer->hasTickingAnimationForTesting());

  m_graphicsLayer->setShouldFlattenTransform(false);

  m_platformLayer = m_graphicsLayer->platformLayer();
  ASSERT_TRUE(m_platformLayer);

  ASSERT_TRUE(m_platformLayer->hasTickingAnimationForTesting());
  player.compositorPlayer()->removeAnimation(animationId);
  ASSERT_FALSE(m_platformLayer->hasTickingAnimationForTesting());

  m_graphicsLayer->setShouldFlattenTransform(true);

  m_platformLayer = m_graphicsLayer->platformLayer();
  ASSERT_TRUE(m_platformLayer);

  ASSERT_FALSE(m_platformLayer->hasTickingAnimationForTesting());

  player.compositorPlayer()->detachElement();
  ASSERT_FALSE(player.compositorPlayer()->isElementAttached());

  compositorTimeline->playerDestroyed(player);
  layerTreeView()->detachCompositorAnimationTimeline(
      compositorTimeline->animationTimeline());
}
Exemple #2
0
TEST_F(GraphicsLayerTest, updateLayerShouldFlattenTransformWithAnimations)
{
    ASSERT_FALSE(m_platformLayer->hasActiveAnimationForTesting());

    OwnPtr<CompositorFloatAnimationCurve> curve = adoptPtr(CompositorFactory::current().createFloatAnimationCurve());
    curve->add(CompositorFloatKeyframe(0.0, 0.0));
    OwnPtr<CompositorAnimation> floatAnimation(adoptPtr(CompositorFactory::current().createAnimation(*curve, CompositorTargetProperty::OPACITY)));
    int animationId = floatAnimation->id();

    OwnPtr<CompositorAnimationTimeline> compositorTimeline = adoptPtr(CompositorFactory::current().createAnimationTimeline());
    AnimationPlayerForTesting player;

    layerTreeView()->attachCompositorAnimationTimeline(compositorTimeline->animationTimeline());
    compositorTimeline->playerAttached(player);

    player.compositorPlayer()->attachLayer(m_platformLayer);
    ASSERT_TRUE(player.compositorPlayer()->isLayerAttached());

    player.compositorPlayer()->addAnimation(floatAnimation.leakPtr());

    ASSERT_TRUE(m_platformLayer->hasActiveAnimationForTesting());

    m_graphicsLayer->setShouldFlattenTransform(false);

    m_platformLayer = m_graphicsLayer->platformLayer();
    ASSERT_TRUE(m_platformLayer);

    ASSERT_TRUE(m_platformLayer->hasActiveAnimationForTesting());
    player.compositorPlayer()->removeAnimation(animationId);
    ASSERT_FALSE(m_platformLayer->hasActiveAnimationForTesting());

    m_graphicsLayer->setShouldFlattenTransform(true);

    m_platformLayer = m_graphicsLayer->platformLayer();
    ASSERT_TRUE(m_platformLayer);

    ASSERT_FALSE(m_platformLayer->hasActiveAnimationForTesting());

    player.compositorPlayer()->detachLayer();
    ASSERT_FALSE(player.compositorPlayer()->isLayerAttached());

    compositorTimeline->playerDestroyed(player);
    layerTreeView()->detachCompositorAnimationTimeline(compositorTimeline->animationTimeline());
}