Skip to content

Commit

Permalink
Port offset-*-interpolation-*.html to wpt
Browse files Browse the repository at this point in the history
Most of these has corresponding tests in wpt/ already, this CL adds
some additional test cases that is not covered in wpt/.

Bug: 900581
Change-Id: I534b55582814b31cc0e3368afcf69eeefb45e661
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1763250
Commit-Queue: Xida Chen <[email protected]>
Reviewed-by: Stephen McGruer <[email protected]>
Cr-Commit-Position: refs/heads/master@{#689917}
  • Loading branch information
xidachen authored and chromium-wpt-export-bot committed Aug 23, 2019
1 parent 863ab8e commit 00832c4
Show file tree
Hide file tree
Showing 5 changed files with 456 additions and 14 deletions.
68 changes: 61 additions & 7 deletions css/motion/animation/offset-anchor-interpolation.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,11 @@
<script src="/resources/testharnessreport.js"></script>
<script src="/css/support/interpolation-testcommon.js"></script>
<style>
body {
width: 500px;
height: 500px;
transform: rotate(0deg);
.parent {
offset-anchor: 30px 10px;
}
div {
width: 10px;
height: 10px;
.target {
offset-anchor: 10px 30px;
}
</style>
</head>
Expand Down Expand Up @@ -67,6 +64,63 @@
from: 'right 10px top 20%',
to: 'auto'
});

test_interpolation({
property: 'offset-anchor',
from: neutralKeyframe,
to: '20px 20px',
}, [
{at: -0.3, expect: '7px 33px'},
{at: 0, expect: '10px 30px'},
{at: 0.3, expect: '13px 27px'},
{at: 0.6, expect: '16px 24px'},
{at: 1, expect: '20px 20px'},
{at: 1.5, expect: '25px 15px'},
]);

test_no_interpolation({
property: 'offset-anchor',
from: 'initial',
to: '60% 40%',
});

test_interpolation({
property: 'offset-anchor',
from: 'inherit',
to: '20px 20px',
}, [
{at: -0.3, expect: '33px 7px'},
{at: 0, expect: '30px 10px'},
{at: 0.3, expect: '27px 13px'},
{at: 0.6, expect: '24px 16px'},
{at: 1, expect: '20px 20px'},
{at: 1.5, expect: '15px 25px'},
]);

test_no_interpolation({
property: 'offset-anchor',
from: 'unset',
to: '50% 10px',
});

test_interpolation({
property: 'offset-anchor',
from: '0% 50%',
to: '100% 150%'
}, [
{at: -0.3, expect: '-30% 20%'},
{at: 0, expect: '0% 50%'},
{at: 0.3, expect: '30% 80%'},
{at: 0.6, expect: '60% 110%'},
{at: 1, expect: '100% 150%'},
{at: 1.5, expect: '150% 200%'}
]);

test_no_interpolation({
property: 'offset-anchor',
from: 'auto',
to: '20px 20px',
});
</script>
</body>
</html>
80 changes: 80 additions & 0 deletions css/motion/animation/offset-distance-interpolation.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,21 @@
<script src="/resources/testharnessreport.js"></script>
<script src="/css/support/interpolation-testcommon.js"></script>
</head>
<style>
.parent {
offset-distance: 30px;
}
.target {
width: 10px;
height: 10px;
background-color: black;
offset-path: path("M0 0H 400");
offset-distance: 10px;
}
.expected {
background-color: green;
}
</style>
<body>
<script>
test_interpolation({
Expand Down Expand Up @@ -50,6 +65,71 @@
{at: 1, expect: 'calc(50px + 100%)'},
{at: 2, expect: 'calc(130px + 180%)'}
]);

test_interpolation({
property: 'offset-distance',
from: neutralKeyframe,
to: '20px',
}, [
{at: -0.3, expect: '7px'},
{at: 0, expect: '10px'},
{at: 0.3, expect: '13px'},
{at: 0.6, expect: '16px'},
{at: 1, expect: '20px'},
{at: 1.5, expect: '25px'},
]);

test_interpolation({
property: 'offset-distance',
from: 'initial',
to: '20px',
}, [
{at: -0.3, expect: '-6px'},
{at: 0, expect: '0px'},
{at: 0.3, expect: '6px'},
{at: 0.6, expect: '12px'},
{at: 1, expect: '20px'},
{at: 1.5, expect: '30px'},
]);

test_interpolation({
property: 'offset-distance',
from: 'inherit',
to: '20px',
}, [
{at: -0.3, expect: '33px'},
{at: 0, expect: '30px'},
{at: 0.3, expect: '27px'},
{at: 0.6, expect: '24px'},
{at: 1, expect: '20px'},
{at: 1.5, expect: '15px'},
]);

test_interpolation({
property: 'offset-distance',
from: 'unset',
to: '20px',
}, [
{at: -0.3, expect: '-6px'},
{at: 0, expect: '0px'},
{at: 0.3, expect: '6px'},
{at: 0.6, expect: '12px'},
{at: 1, expect: '20px'},
{at: 1.5, expect: '30px'},
]);

test_interpolation({
property: 'offset-distance',
from: '10px',
to: '100%',
}, [
{at: -0.3, expect: 'calc(13px + -30%)'},
{at: 0, expect: 'calc(0% + 10px)'},
{at: 0.3, expect: 'calc(7px + 30%)'},
{at: 0.6, expect: 'calc(4px + 60%)'},
{at: 1, expect: '100%'},
{at: 1.5, expect: 'calc(-5px + 150%)'},
]);
</script>
</body>
</html>
106 changes: 106 additions & 0 deletions css/motion/animation/offset-interpolation.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="help" href="https://drafts.fxtf.org/motion-1/#offset-shorthand">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/css/support/interpolation-testcommon.js"></script>
</head>
<body>
<script>
test_interpolation({
property: 'offset',
from: 'path("M0 200H 700") 500px 800deg',
to: 'path("M0 300H 700 Z") 600px 900deg',
method: 'CSS Transitions',
}, [
{at: -0.3, expect: 'path("M0 300H 700 Z") 470px 770deg'},
{at: 0, expect: 'path("M0 300H 700 Z") 500px 800deg'},
{at: 0.3, expect: 'path("M0 300H 700 Z") 530px 830deg'},
{at: 0.6, expect: 'path("M0 300H 700 Z") 560px 860deg'},
{at: 1, expect: 'path("M0 300H 700 Z") 600px 900deg'},
{at: 1.5, expect: 'path("M0 300H 700 Z") 650px 950deg'},
]);

test_interpolation({
property: 'offset',
from: 'path("M0 0H 200") 500px auto',
to: 'path("M0 0H 300") 600px 0deg',
method: 'CSS Transitions',
}, [
{at: -0.3, expect: 'path("M0 0H 170") 470px 0deg'},
{at: 0, expect: 'path("M0 0H 200") 500px 0deg'},
{at: 0.3, expect: 'path("M0 0H 230") 530px 0deg'},
{at: 0.6, expect: 'path("M0 0H 260") 560px 0deg'},
{at: 1, expect: 'path("M0 0H 300") 600px 0deg'},
{at: 1.5, expect: 'path("M0 0H 350") 650px 0deg'},
]);

test_interpolation({
property: 'offset',
from: 'path("M0 200H 700") 500px 800deg',
to: 'path("M0 300H 700 Z") 600px 900deg',
method: 'CSS Animations',
}, [
{at: -0.3, expect: 'path("M0 200H 700") 470px 770deg'},
{at: 0, expect: 'path("M0 200H 700") 500px 800deg'},
{at: 0.3, expect: 'path("M0 200H 700") 530px 830deg'},
{at: 0.6, expect: 'path("M0 300H 700 Z") 560px 860deg'},
{at: 1, expect: 'path("M0 300H 700 Z") 600px 900deg'},
{at: 1.5, expect: 'path("M0 300H 700 Z") 650px 950deg'},
]);

test_interpolation({
property: 'offset',
from: 'path("M0 0H 200") 500px auto',
to: 'path("M0 0H 300") 600px 0deg',
method: 'CSS Animations',
}, [
{at: -0.3, expect: 'path("M0 0H 170") 470px auto'},
{at: 0, expect: 'path("M0 0H 200") 500px auto'},
{at: 0.3, expect: 'path("M0 0H 230") 530px auto'},
{at: 0.6, expect: 'path("M0 0H 260") 560px 0deg'},
{at: 1, expect: 'path("M0 0H 300") 600px 0deg'},
{at: 1.5, expect: 'path("M0 0H 350") 650px 0deg'},
]);

test_interpolation({
property: 'offset',
from: 'path("M0 200H 700") 500px 800deg',
to: 'path("M0 300H 700 Z") 600px 900deg',
method: 'Web Animations',
}, [
{at: -0.3, expect: 'path("M0 200H 700") 470px 770deg'},
{at: 0, expect: 'path("M0 200H 700") 500px 800deg'},
{at: 0.3, expect: 'path("M0 200H 700") 530px 830deg'},
{at: 0.6, expect: 'path("M0 300H 700 Z") 560px 860deg'},
{at: 1, expect: 'path("M0 300H 700 Z") 600px 900deg'},
{at: 1.5, expect: 'path("M0 300H 700 Z") 650px 950deg'},
]);

test_interpolation({
property: 'offset',
from: 'path("M0 0V 200") 500px auto',
to: 'path("M0 0H 300") 600px 0deg',
method: 'Web Animations',
}, [
{at: -0.3, expect: 'path("M0 0V 200") 470px auto'},
{at: 0, expect: 'path("M0 0V 200") 500px auto'},
{at: 0.3, expect: 'path("M0 0V 200") 530px auto'},
{at: 0.6, expect: 'path("M0 0H 300") 560px 0deg'},
{at: 1, expect: 'path("M0 0H 300") 600px 0deg'},
{at: 1.5, expect: 'path("M0 0H 300") 650px 0deg'},
]);

// Regression test for crbug.com/994489
test_interpolation({
property: 'offset',
from: 'path("M0 0H 200") 500px auto',
to: 'path("M0 0H 300") 600px 0deg',
}, [
{at: 3.40282e+038, expect: 'path("M0 0H 3.4e+38") 3.36e+07px 0deg'},
]);
</script>
</body>
</html>
68 changes: 61 additions & 7 deletions css/motion/animation/offset-position-interpolation.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,11 @@
<script src="/resources/testharnessreport.js"></script>
<script src="/css/support/interpolation-testcommon.js"></script>
<style>
body {
width: 500px;
height: 500px;
transform: rotate(0deg);
.parent {
offset-position: 30px 10px;
}
div {
width: 10px;
height: 10px;
.target {
offset-position: 10px 30px;
}
</style>
</head>
Expand Down Expand Up @@ -67,6 +64,63 @@
from: 'right 10px top 20%',
to: 'auto'
});

test_interpolation({
property: 'offset-position',
from: neutralKeyframe,
to: '20px 20px',
}, [
{at: -0.3, expect: '7px 33px'},
{at: 0, expect: '10px 30px'},
{at: 0.3, expect: '13px 27px'},
{at: 0.6, expect: '16px 24px'},
{at: 1, expect: '20px 20px'},
{at: 1.5, expect: '25px 15px'},
]);

test_no_interpolation({
property: 'offset-position',
from: 'initial',
to: '20px 20px',
});

test_interpolation({
property: 'offset-position',
from: 'inherit',
to: '20px 20px',
}, [
{at: -0.3, expect: '33px 7px'},
{at: 0, expect: '30px 10px'},
{at: 0.3, expect: '27px 13px'},
{at: 0.6, expect: '24px 16px'},
{at: 1, expect: '20px 20px'},
{at: 1.5, expect: '15px 25px'},
]);

test_no_interpolation({
property: 'offset-position',
from: 'unset',
to: '20px 20px',
});

test_interpolation({
property: 'offset-position',
from: '0% 50%',
to: '100% 150%'
}, [
{at: -0.3, expect: '-30% 20%'},
{at: 0, expect: '0% 50%'},
{at: 0.3, expect: '30% 80%'},
{at: 0.6, expect: '60% 110%'},
{at: 1, expect: '100% 150%'},
{at: 1.5, expect: '150% 200%'}
]);

test_no_interpolation({
property: 'offset-position',
from: 'auto',
to: '20px 20px',
});
</script>
</body>
</html>
Loading

0 comments on commit 00832c4

Please sign in to comment.