Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(338)

Side by Side Diff: third_party/WebKit/Source/core/animation/AnimationTest.cpp

Issue 2890953002: [SPv1] Always set a CompositorElementId on main graphics layers; use PaintLayer id. (Closed)
Patch Set: none Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013, Google Inc. All rights reserved. 2 * Copyright (c) 2013, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 21 matching lines...) Expand all
32 32
33 #include <memory> 33 #include <memory>
34 #include "core/animation/AnimationClock.h" 34 #include "core/animation/AnimationClock.h"
35 #include "core/animation/AnimationTimeline.h" 35 #include "core/animation/AnimationTimeline.h"
36 #include "core/animation/CompositorPendingAnimations.h" 36 #include "core/animation/CompositorPendingAnimations.h"
37 #include "core/animation/ElementAnimations.h" 37 #include "core/animation/ElementAnimations.h"
38 #include "core/animation/KeyframeEffect.h" 38 #include "core/animation/KeyframeEffect.h"
39 #include "core/dom/DOMNodeIds.h" 39 #include "core/dom/DOMNodeIds.h"
40 #include "core/dom/Document.h" 40 #include "core/dom/Document.h"
41 #include "core/dom/QualifiedName.h" 41 #include "core/dom/QualifiedName.h"
42 #include "core/layout/LayoutTestHelper.h"
43 #include "core/paint/PaintLayer.h"
42 #include "core/testing/DummyPageHolder.h" 44 #include "core/testing/DummyPageHolder.h"
43 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" 45 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h"
44 #include "platform/weborigin/KURL.h" 46 #include "platform/weborigin/KURL.h"
45 #include "testing/gtest/include/gtest/gtest.h" 47 #include "testing/gtest/include/gtest/gtest.h"
46 48
47 namespace blink { 49 namespace blink {
48 50
49 class AnimationAnimationTest : public ::testing::Test { 51 class AnimationAnimationTest : public RenderingTest {
50 protected: 52 public:
53 AnimationAnimationTest()
54 : RenderingTest(SingleChildLocalFrameClient::Create()) {}
55
51 void SetUp() override { 56 void SetUp() override {
57 RenderingTest::SetUp();
52 SetUpWithoutStartingTimeline(); 58 SetUpWithoutStartingTimeline();
53 StartTimeline(); 59 StartTimeline();
54 } 60 }
55 61
56 void SetUpWithoutStartingTimeline() { 62 void SetUpWithoutStartingTimeline() {
57 page_holder = DummyPageHolder::Create(); 63 page_holder = DummyPageHolder::Create();
58 document = &page_holder->GetDocument(); 64 document = &page_holder->GetDocument();
59 document->GetAnimationClock().ResetTimeForTesting(); 65 document->GetAnimationClock().ResetTimeForTesting();
60 timeline = AnimationTimeline::Create(document.Get()); 66 timeline = AnimationTimeline::Create(document.Get());
61 timeline->ResetForTesting(); 67 timeline->ResetForTesting();
(...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after
784 EXPECT_TRUE(std::isnan(animation->startTime())); 790 EXPECT_TRUE(std::isnan(animation->startTime()));
785 animation->pause(); 791 animation->pause();
786 EXPECT_EQ(Animation::kPending, animation->PlayStateInternal()); 792 EXPECT_EQ(Animation::kPending, animation->PlayStateInternal());
787 EXPECT_EQ(0, animation->currentTime()); 793 EXPECT_EQ(0, animation->currentTime());
788 EXPECT_TRUE(std::isnan(animation->startTime())); 794 EXPECT_TRUE(std::isnan(animation->startTime()));
789 } 795 }
790 796
791 TEST_F(AnimationAnimationTest, NoCompositeWithoutCompositedElementId) { 797 TEST_F(AnimationAnimationTest, NoCompositeWithoutCompositedElementId) {
792 ScopedSlimmingPaintV2ForTest enable_s_pv2(true); 798 ScopedSlimmingPaintV2ForTest enable_s_pv2(true);
793 799
794 Persistent<Element> element_composited = document->createElement("foo"); 800 SetBodyInnerHTML(
795 Persistent<Element> element_not_composited = document->createElement("bar"); 801 "<div id='foo' style='position: relative'></div>"
802 "<div id='bar' style='position: relative'></div>");
803
804 LayoutObject* object_composited = GetLayoutObjectByElementId("foo");
805 LayoutObject* object_not_composited = GetLayoutObjectByElementId("bar");
796 806
797 Optional<CompositorElementIdSet> composited_element_ids = 807 Optional<CompositorElementIdSet> composited_element_ids =
798 CompositorElementIdSet(); 808 CompositorElementIdSet();
799 CompositorElementId expected_compositor_element_id = 809 CompositorElementId expected_compositor_element_id =
800 CompositorElementIdFromDOMNodeId( 810 CompositorElementIdFromPaintLayerId(
801 DOMNodeIds::IdForNode(element_composited), 811 ToLayoutBoxModelObject(object_composited)->Layer()->UniqueId(),
802 CompositorElementIdNamespace::kPrimary); 812 CompositorElementIdNamespace::kPrimary);
803 composited_element_ids->insert(expected_compositor_element_id); 813 composited_element_ids->insert(expected_compositor_element_id);
804 814
805 Timing timing; 815 Timing timing;
806 timing.iteration_duration = 30; 816 timing.iteration_duration = 30;
807 timing.playback_rate = 1; 817 timing.playback_rate = 1;
808 KeyframeEffect* keyframe_effect_composited = 818 KeyframeEffect* keyframe_effect_composited = KeyframeEffect::Create(
809 KeyframeEffect::Create(element_composited.Get(), nullptr, timing); 819 ToElement(object_composited->GetNode()), nullptr, timing);
810 Animation* animation_composited = timeline->Play(keyframe_effect_composited); 820 Animation* animation_composited = timeline->Play(keyframe_effect_composited);
811 KeyframeEffect* keyframe_effect_not_composited = 821 KeyframeEffect* keyframe_effect_not_composited = KeyframeEffect::Create(
812 KeyframeEffect::Create(element_not_composited.Get(), nullptr, timing); 822 ToElement(object_not_composited->GetNode()), nullptr, timing);
813 Animation* animation_not_composited = 823 Animation* animation_not_composited =
814 timeline->Play(keyframe_effect_not_composited); 824 timeline->Play(keyframe_effect_not_composited);
815 825
816 SimulateFrame(0, composited_element_ids); 826 SimulateFrame(0, composited_element_ids);
817 EXPECT_TRUE(animation_composited->CanStartAnimationOnCompositor( 827 EXPECT_TRUE(animation_composited->CanStartAnimationOnCompositor(
818 composited_element_ids)); 828 composited_element_ids));
819 EXPECT_FALSE(animation_not_composited->CanStartAnimationOnCompositor( 829 EXPECT_FALSE(animation_not_composited->CanStartAnimationOnCompositor(
820 composited_element_ids)); 830 composited_element_ids));
821 } 831 }
822 832
823 } // namespace blink 833 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698