Add return animation functionality to TransitionAnimator.
Bug: 323863002
Flag: ACONFIG com.android.systemui.shared.return_animation_framework_library DISABLED
Test: Manually tested existing use cases with the flag on and off (same
behavior), added unit test
Change-Id: I391c6ae784871e17262649d0f17343ac87b6a6d4
diff --git a/packages/SystemUI/tests/AndroidManifest.xml b/packages/SystemUI/tests/AndroidManifest.xml
index 572a6c1..0dbbe63 100644
--- a/packages/SystemUI/tests/AndroidManifest.xml
+++ b/packages/SystemUI/tests/AndroidManifest.xml
@@ -224,6 +224,5 @@
<instrumentation android:name="android.testing.TestableInstrumentation"
android:targetPackage="com.android.systemui.tests"
- android:label="Tests for SystemUI">
- </instrumentation>
+ android:label="Tests for SystemUI" />
</manifest>
diff --git a/packages/SystemUI/tests/AndroidTest.xml b/packages/SystemUI/tests/AndroidTest.xml
index cd2a62d..2de5faf 100644
--- a/packages/SystemUI/tests/AndroidTest.xml
+++ b/packages/SystemUI/tests/AndroidTest.xml
@@ -23,6 +23,15 @@
<option name="force-root" value="true" />
</target_preparer>
+ <target_preparer class="com.android.tradefed.targetprep.DeviceSetup">
+ <option name="screen-always-on" value="on" />
+ </target_preparer>
+
+ <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
+ <option name="run-command" value="input keyevent KEYCODE_WAKEUP" />
+ <option name="run-command" value="wm dismiss-keyguard" />
+ </target_preparer>
+
<option name="test-suite-tag" value="apct" />
<option name="test-suite-tag" value="framework-base-presubmit" />
<option name="test-tag" value="SystemUITests" />
diff --git a/packages/SystemUI/tests/goldens/backgroundAnimationWithoutFade_whenLaunching.json b/packages/SystemUI/tests/goldens/backgroundAnimationWithoutFade_whenLaunching.json
new file mode 100644
index 0000000..60bff17
--- /dev/null
+++ b/packages/SystemUI/tests/goldens/backgroundAnimationWithoutFade_whenLaunching.json
@@ -0,0 +1,393 @@
+{
+ "frame_ids": [
+ "before",
+ 0,
+ 26,
+ 52,
+ 78,
+ 105,
+ 131,
+ 157,
+ 184,
+ 210,
+ 236,
+ 263,
+ 289,
+ 315,
+ 342,
+ 368,
+ 394,
+ 421,
+ 447,
+ 473,
+ 500
+ ],
+ "features": [
+ {
+ "name": "bounds",
+ "type": "rect",
+ "data_points": [
+ {
+ "left": 0,
+ "top": 0,
+ "right": 0,
+ "bottom": 0
+ },
+ {
+ "left": 100,
+ "top": 300,
+ "right": 200,
+ "bottom": 400
+ },
+ {
+ "left": 98,
+ "top": 293,
+ "right": 203,
+ "bottom": 407
+ },
+ {
+ "left": 91,
+ "top": 269,
+ "right": 213,
+ "bottom": 430
+ },
+ {
+ "left": 71,
+ "top": 206,
+ "right": 240,
+ "bottom": 491
+ },
+ {
+ "left": 34,
+ "top": 98,
+ "right": 283,
+ "bottom": 595
+ },
+ {
+ "left": 22,
+ "top": 63,
+ "right": 296,
+ "bottom": 629
+ },
+ {
+ "left": 15,
+ "top": 44,
+ "right": 303,
+ "bottom": 648
+ },
+ {
+ "left": 11,
+ "top": 32,
+ "right": 308,
+ "bottom": 659
+ },
+ {
+ "left": 8,
+ "top": 23,
+ "right": 311,
+ "bottom": 667
+ },
+ {
+ "left": 6,
+ "top": 18,
+ "right": 313,
+ "bottom": 673
+ },
+ {
+ "left": 5,
+ "top": 13,
+ "right": 315,
+ "bottom": 677
+ },
+ {
+ "left": 3,
+ "top": 9,
+ "right": 316,
+ "bottom": 681
+ },
+ {
+ "left": 2,
+ "top": 7,
+ "right": 317,
+ "bottom": 683
+ },
+ {
+ "left": 2,
+ "top": 5,
+ "right": 318,
+ "bottom": 685
+ },
+ {
+ "left": 1,
+ "top": 3,
+ "right": 319,
+ "bottom": 687
+ },
+ {
+ "left": 1,
+ "top": 2,
+ "right": 319,
+ "bottom": 688
+ },
+ {
+ "left": 0,
+ "top": 1,
+ "right": 320,
+ "bottom": 689
+ },
+ {
+ "left": 0,
+ "top": 0,
+ "right": 320,
+ "bottom": 690
+ },
+ {
+ "left": 0,
+ "top": 0,
+ "right": 320,
+ "bottom": 690
+ },
+ {
+ "left": 0,
+ "top": 0,
+ "right": 320,
+ "bottom": 690
+ }
+ ]
+ },
+ {
+ "name": "corner_radii",
+ "type": "cornerRadii",
+ "data_points": [
+ null,
+ {
+ "top_left_x": 10,
+ "top_left_y": 10,
+ "top_right_x": 10,
+ "top_right_y": 10,
+ "bottom_right_x": 20,
+ "bottom_right_y": 20,
+ "bottom_left_x": 20,
+ "bottom_left_y": 20
+ },
+ {
+ "top_left_x": 9.762664,
+ "top_left_y": 9.762664,
+ "top_right_x": 9.762664,
+ "top_right_y": 9.762664,
+ "bottom_right_x": 19.525328,
+ "bottom_right_y": 19.525328,
+ "bottom_left_x": 19.525328,
+ "bottom_left_y": 19.525328
+ },
+ {
+ "top_left_x": 8.969244,
+ "top_left_y": 8.969244,
+ "top_right_x": 8.969244,
+ "top_right_y": 8.969244,
+ "bottom_right_x": 17.938488,
+ "bottom_right_y": 17.938488,
+ "bottom_left_x": 17.938488,
+ "bottom_left_y": 17.938488
+ },
+ {
+ "top_left_x": 6.8709626,
+ "top_left_y": 6.8709626,
+ "top_right_x": 6.8709626,
+ "top_right_y": 6.8709626,
+ "bottom_right_x": 13.741925,
+ "bottom_right_y": 13.741925,
+ "bottom_left_x": 13.741925,
+ "bottom_left_y": 13.741925
+ },
+ {
+ "top_left_x": 3.260561,
+ "top_left_y": 3.260561,
+ "top_right_x": 3.260561,
+ "top_right_y": 3.260561,
+ "bottom_right_x": 6.521122,
+ "bottom_right_y": 6.521122,
+ "bottom_left_x": 6.521122,
+ "bottom_left_y": 6.521122
+ },
+ {
+ "top_left_x": 2.0915751,
+ "top_left_y": 2.0915751,
+ "top_right_x": 2.0915751,
+ "top_right_y": 2.0915751,
+ "bottom_right_x": 4.1831503,
+ "bottom_right_y": 4.1831503,
+ "bottom_left_x": 4.1831503,
+ "bottom_left_y": 4.1831503
+ },
+ {
+ "top_left_x": 1.4640827,
+ "top_left_y": 1.4640827,
+ "top_right_x": 1.4640827,
+ "top_right_y": 1.4640827,
+ "bottom_right_x": 2.9281654,
+ "bottom_right_y": 2.9281654,
+ "bottom_left_x": 2.9281654,
+ "bottom_left_y": 2.9281654
+ },
+ {
+ "top_left_x": 1.057313,
+ "top_left_y": 1.057313,
+ "top_right_x": 1.057313,
+ "top_right_y": 1.057313,
+ "bottom_right_x": 2.114626,
+ "bottom_right_y": 2.114626,
+ "bottom_left_x": 2.114626,
+ "bottom_left_y": 2.114626
+ },
+ {
+ "top_left_x": 0.7824335,
+ "top_left_y": 0.7824335,
+ "top_right_x": 0.7824335,
+ "top_right_y": 0.7824335,
+ "bottom_right_x": 1.564867,
+ "bottom_right_y": 1.564867,
+ "bottom_left_x": 1.564867,
+ "bottom_left_y": 1.564867
+ },
+ {
+ "top_left_x": 0.5863056,
+ "top_left_y": 0.5863056,
+ "top_right_x": 0.5863056,
+ "top_right_y": 0.5863056,
+ "bottom_right_x": 1.1726112,
+ "bottom_right_y": 1.1726112,
+ "bottom_left_x": 1.1726112,
+ "bottom_left_y": 1.1726112
+ },
+ {
+ "top_left_x": 0.4332962,
+ "top_left_y": 0.4332962,
+ "top_right_x": 0.4332962,
+ "top_right_y": 0.4332962,
+ "bottom_right_x": 0.8665924,
+ "bottom_right_y": 0.8665924,
+ "bottom_left_x": 0.8665924,
+ "bottom_left_y": 0.8665924
+ },
+ {
+ "top_left_x": 0.3145876,
+ "top_left_y": 0.3145876,
+ "top_right_x": 0.3145876,
+ "top_right_y": 0.3145876,
+ "bottom_right_x": 0.6291752,
+ "bottom_right_y": 0.6291752,
+ "bottom_left_x": 0.6291752,
+ "bottom_left_y": 0.6291752
+ },
+ {
+ "top_left_x": 0.22506618,
+ "top_left_y": 0.22506618,
+ "top_right_x": 0.22506618,
+ "top_right_y": 0.22506618,
+ "bottom_right_x": 0.45013237,
+ "bottom_right_y": 0.45013237,
+ "bottom_left_x": 0.45013237,
+ "bottom_left_y": 0.45013237
+ },
+ {
+ "top_left_x": 0.15591621,
+ "top_left_y": 0.15591621,
+ "top_right_x": 0.15591621,
+ "top_right_y": 0.15591621,
+ "bottom_right_x": 0.31183243,
+ "bottom_right_y": 0.31183243,
+ "bottom_left_x": 0.31183243,
+ "bottom_left_y": 0.31183243
+ },
+ {
+ "top_left_x": 0.100948334,
+ "top_left_y": 0.100948334,
+ "top_right_x": 0.100948334,
+ "top_right_y": 0.100948334,
+ "bottom_right_x": 0.20189667,
+ "bottom_right_y": 0.20189667,
+ "bottom_left_x": 0.20189667,
+ "bottom_left_y": 0.20189667
+ },
+ {
+ "top_left_x": 0.06496239,
+ "top_left_y": 0.06496239,
+ "top_right_x": 0.06496239,
+ "top_right_y": 0.06496239,
+ "bottom_right_x": 0.12992477,
+ "bottom_right_y": 0.12992477,
+ "bottom_left_x": 0.12992477,
+ "bottom_left_y": 0.12992477
+ },
+ {
+ "top_left_x": 0.03526497,
+ "top_left_y": 0.03526497,
+ "top_right_x": 0.03526497,
+ "top_right_y": 0.03526497,
+ "bottom_right_x": 0.07052994,
+ "bottom_right_y": 0.07052994,
+ "bottom_left_x": 0.07052994,
+ "bottom_left_y": 0.07052994
+ },
+ {
+ "top_left_x": 0.014661789,
+ "top_left_y": 0.014661789,
+ "top_right_x": 0.014661789,
+ "top_right_y": 0.014661789,
+ "bottom_right_x": 0.029323578,
+ "bottom_right_y": 0.029323578,
+ "bottom_left_x": 0.029323578,
+ "bottom_left_y": 0.029323578
+ },
+ {
+ "top_left_x": 0.0041856766,
+ "top_left_y": 0.0041856766,
+ "top_right_x": 0.0041856766,
+ "top_right_y": 0.0041856766,
+ "bottom_right_x": 0.008371353,
+ "bottom_right_y": 0.008371353,
+ "bottom_left_x": 0.008371353,
+ "bottom_left_y": 0.008371353
+ },
+ {
+ "top_left_x": 0,
+ "top_left_y": 0,
+ "top_right_x": 0,
+ "top_right_y": 0,
+ "bottom_right_x": 0,
+ "bottom_right_y": 0,
+ "bottom_left_x": 0,
+ "bottom_left_y": 0
+ }
+ ]
+ },
+ {
+ "name": "alpha",
+ "type": "int",
+ "data_points": [
+ 0,
+ 0,
+ 115,
+ 178,
+ 217,
+ 241,
+ 253,
+ 255,
+ 255,
+ 255,
+ 255,
+ 255,
+ 255,
+ 255,
+ 255,
+ 255,
+ 255,
+ 255,
+ 255,
+ 255,
+ 255
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/packages/SystemUI/tests/goldens/backgroundAnimationWithoutFade_whenReturning.json b/packages/SystemUI/tests/goldens/backgroundAnimationWithoutFade_whenReturning.json
new file mode 100644
index 0000000..ea768c0
--- /dev/null
+++ b/packages/SystemUI/tests/goldens/backgroundAnimationWithoutFade_whenReturning.json
@@ -0,0 +1,393 @@
+{
+ "frame_ids": [
+ "before",
+ 0,
+ 26,
+ 52,
+ 78,
+ 105,
+ 131,
+ 157,
+ 184,
+ 210,
+ 236,
+ 263,
+ 289,
+ 315,
+ 342,
+ 368,
+ 394,
+ 421,
+ 447,
+ 473,
+ 500
+ ],
+ "features": [
+ {
+ "name": "bounds",
+ "type": "rect",
+ "data_points": [
+ {
+ "left": 0,
+ "top": 0,
+ "right": 0,
+ "bottom": 0
+ },
+ {
+ "left": 100,
+ "top": 300,
+ "right": 200,
+ "bottom": 400
+ },
+ {
+ "left": 98,
+ "top": 293,
+ "right": 203,
+ "bottom": 407
+ },
+ {
+ "left": 91,
+ "top": 269,
+ "right": 213,
+ "bottom": 430
+ },
+ {
+ "left": 71,
+ "top": 206,
+ "right": 240,
+ "bottom": 491
+ },
+ {
+ "left": 34,
+ "top": 98,
+ "right": 283,
+ "bottom": 595
+ },
+ {
+ "left": 22,
+ "top": 63,
+ "right": 296,
+ "bottom": 629
+ },
+ {
+ "left": 15,
+ "top": 44,
+ "right": 303,
+ "bottom": 648
+ },
+ {
+ "left": 11,
+ "top": 32,
+ "right": 308,
+ "bottom": 659
+ },
+ {
+ "left": 8,
+ "top": 23,
+ "right": 311,
+ "bottom": 667
+ },
+ {
+ "left": 6,
+ "top": 18,
+ "right": 313,
+ "bottom": 673
+ },
+ {
+ "left": 5,
+ "top": 13,
+ "right": 315,
+ "bottom": 677
+ },
+ {
+ "left": 3,
+ "top": 9,
+ "right": 316,
+ "bottom": 681
+ },
+ {
+ "left": 2,
+ "top": 7,
+ "right": 317,
+ "bottom": 683
+ },
+ {
+ "left": 2,
+ "top": 5,
+ "right": 318,
+ "bottom": 685
+ },
+ {
+ "left": 1,
+ "top": 3,
+ "right": 319,
+ "bottom": 687
+ },
+ {
+ "left": 1,
+ "top": 2,
+ "right": 319,
+ "bottom": 688
+ },
+ {
+ "left": 0,
+ "top": 1,
+ "right": 320,
+ "bottom": 689
+ },
+ {
+ "left": 0,
+ "top": 0,
+ "right": 320,
+ "bottom": 690
+ },
+ {
+ "left": 0,
+ "top": 0,
+ "right": 320,
+ "bottom": 690
+ },
+ {
+ "left": 0,
+ "top": 0,
+ "right": 320,
+ "bottom": 690
+ }
+ ]
+ },
+ {
+ "name": "corner_radii",
+ "type": "cornerRadii",
+ "data_points": [
+ null,
+ {
+ "top_left_x": 10,
+ "top_left_y": 10,
+ "top_right_x": 10,
+ "top_right_y": 10,
+ "bottom_right_x": 20,
+ "bottom_right_y": 20,
+ "bottom_left_x": 20,
+ "bottom_left_y": 20
+ },
+ {
+ "top_left_x": 9.762664,
+ "top_left_y": 9.762664,
+ "top_right_x": 9.762664,
+ "top_right_y": 9.762664,
+ "bottom_right_x": 19.525328,
+ "bottom_right_y": 19.525328,
+ "bottom_left_x": 19.525328,
+ "bottom_left_y": 19.525328
+ },
+ {
+ "top_left_x": 8.969244,
+ "top_left_y": 8.969244,
+ "top_right_x": 8.969244,
+ "top_right_y": 8.969244,
+ "bottom_right_x": 17.938488,
+ "bottom_right_y": 17.938488,
+ "bottom_left_x": 17.938488,
+ "bottom_left_y": 17.938488
+ },
+ {
+ "top_left_x": 6.8709626,
+ "top_left_y": 6.8709626,
+ "top_right_x": 6.8709626,
+ "top_right_y": 6.8709626,
+ "bottom_right_x": 13.741925,
+ "bottom_right_y": 13.741925,
+ "bottom_left_x": 13.741925,
+ "bottom_left_y": 13.741925
+ },
+ {
+ "top_left_x": 3.260561,
+ "top_left_y": 3.260561,
+ "top_right_x": 3.260561,
+ "top_right_y": 3.260561,
+ "bottom_right_x": 6.521122,
+ "bottom_right_y": 6.521122,
+ "bottom_left_x": 6.521122,
+ "bottom_left_y": 6.521122
+ },
+ {
+ "top_left_x": 2.0915751,
+ "top_left_y": 2.0915751,
+ "top_right_x": 2.0915751,
+ "top_right_y": 2.0915751,
+ "bottom_right_x": 4.1831503,
+ "bottom_right_y": 4.1831503,
+ "bottom_left_x": 4.1831503,
+ "bottom_left_y": 4.1831503
+ },
+ {
+ "top_left_x": 1.4640827,
+ "top_left_y": 1.4640827,
+ "top_right_x": 1.4640827,
+ "top_right_y": 1.4640827,
+ "bottom_right_x": 2.9281654,
+ "bottom_right_y": 2.9281654,
+ "bottom_left_x": 2.9281654,
+ "bottom_left_y": 2.9281654
+ },
+ {
+ "top_left_x": 1.057313,
+ "top_left_y": 1.057313,
+ "top_right_x": 1.057313,
+ "top_right_y": 1.057313,
+ "bottom_right_x": 2.114626,
+ "bottom_right_y": 2.114626,
+ "bottom_left_x": 2.114626,
+ "bottom_left_y": 2.114626
+ },
+ {
+ "top_left_x": 0.7824335,
+ "top_left_y": 0.7824335,
+ "top_right_x": 0.7824335,
+ "top_right_y": 0.7824335,
+ "bottom_right_x": 1.564867,
+ "bottom_right_y": 1.564867,
+ "bottom_left_x": 1.564867,
+ "bottom_left_y": 1.564867
+ },
+ {
+ "top_left_x": 0.5863056,
+ "top_left_y": 0.5863056,
+ "top_right_x": 0.5863056,
+ "top_right_y": 0.5863056,
+ "bottom_right_x": 1.1726112,
+ "bottom_right_y": 1.1726112,
+ "bottom_left_x": 1.1726112,
+ "bottom_left_y": 1.1726112
+ },
+ {
+ "top_left_x": 0.4332962,
+ "top_left_y": 0.4332962,
+ "top_right_x": 0.4332962,
+ "top_right_y": 0.4332962,
+ "bottom_right_x": 0.8665924,
+ "bottom_right_y": 0.8665924,
+ "bottom_left_x": 0.8665924,
+ "bottom_left_y": 0.8665924
+ },
+ {
+ "top_left_x": 0.3145876,
+ "top_left_y": 0.3145876,
+ "top_right_x": 0.3145876,
+ "top_right_y": 0.3145876,
+ "bottom_right_x": 0.6291752,
+ "bottom_right_y": 0.6291752,
+ "bottom_left_x": 0.6291752,
+ "bottom_left_y": 0.6291752
+ },
+ {
+ "top_left_x": 0.22506618,
+ "top_left_y": 0.22506618,
+ "top_right_x": 0.22506618,
+ "top_right_y": 0.22506618,
+ "bottom_right_x": 0.45013237,
+ "bottom_right_y": 0.45013237,
+ "bottom_left_x": 0.45013237,
+ "bottom_left_y": 0.45013237
+ },
+ {
+ "top_left_x": 0.15591621,
+ "top_left_y": 0.15591621,
+ "top_right_x": 0.15591621,
+ "top_right_y": 0.15591621,
+ "bottom_right_x": 0.31183243,
+ "bottom_right_y": 0.31183243,
+ "bottom_left_x": 0.31183243,
+ "bottom_left_y": 0.31183243
+ },
+ {
+ "top_left_x": 0.100948334,
+ "top_left_y": 0.100948334,
+ "top_right_x": 0.100948334,
+ "top_right_y": 0.100948334,
+ "bottom_right_x": 0.20189667,
+ "bottom_right_y": 0.20189667,
+ "bottom_left_x": 0.20189667,
+ "bottom_left_y": 0.20189667
+ },
+ {
+ "top_left_x": 0.06496239,
+ "top_left_y": 0.06496239,
+ "top_right_x": 0.06496239,
+ "top_right_y": 0.06496239,
+ "bottom_right_x": 0.12992477,
+ "bottom_right_y": 0.12992477,
+ "bottom_left_x": 0.12992477,
+ "bottom_left_y": 0.12992477
+ },
+ {
+ "top_left_x": 0.03526497,
+ "top_left_y": 0.03526497,
+ "top_right_x": 0.03526497,
+ "top_right_y": 0.03526497,
+ "bottom_right_x": 0.07052994,
+ "bottom_right_y": 0.07052994,
+ "bottom_left_x": 0.07052994,
+ "bottom_left_y": 0.07052994
+ },
+ {
+ "top_left_x": 0.014661789,
+ "top_left_y": 0.014661789,
+ "top_right_x": 0.014661789,
+ "top_right_y": 0.014661789,
+ "bottom_right_x": 0.029323578,
+ "bottom_right_y": 0.029323578,
+ "bottom_left_x": 0.029323578,
+ "bottom_left_y": 0.029323578
+ },
+ {
+ "top_left_x": 0.0041856766,
+ "top_left_y": 0.0041856766,
+ "top_right_x": 0.0041856766,
+ "top_right_y": 0.0041856766,
+ "bottom_right_x": 0.008371353,
+ "bottom_right_y": 0.008371353,
+ "bottom_left_x": 0.008371353,
+ "bottom_left_y": 0.008371353
+ },
+ {
+ "top_left_x": 0,
+ "top_left_y": 0,
+ "top_right_x": 0,
+ "top_right_y": 0,
+ "bottom_right_x": 0,
+ "bottom_right_y": 0,
+ "bottom_left_x": 0,
+ "bottom_left_y": 0
+ }
+ ]
+ },
+ {
+ "name": "alpha",
+ "type": "int",
+ "data_points": [
+ 0,
+ 255,
+ 255,
+ 255,
+ 255,
+ 255,
+ 255,
+ 239,
+ 183,
+ 135,
+ 91,
+ 53,
+ 23,
+ 5,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/packages/SystemUI/tests/goldens/backgroundAnimation_whenLaunching.json b/packages/SystemUI/tests/goldens/backgroundAnimation_whenLaunching.json
new file mode 100644
index 0000000..608e633
--- /dev/null
+++ b/packages/SystemUI/tests/goldens/backgroundAnimation_whenLaunching.json
@@ -0,0 +1,393 @@
+{
+ "frame_ids": [
+ "before",
+ 0,
+ 26,
+ 52,
+ 78,
+ 105,
+ 131,
+ 157,
+ 184,
+ 210,
+ 236,
+ 263,
+ 289,
+ 315,
+ 342,
+ 368,
+ 394,
+ 421,
+ 447,
+ 473,
+ 500
+ ],
+ "features": [
+ {
+ "name": "bounds",
+ "type": "rect",
+ "data_points": [
+ {
+ "left": 0,
+ "top": 0,
+ "right": 0,
+ "bottom": 0
+ },
+ {
+ "left": 100,
+ "top": 300,
+ "right": 200,
+ "bottom": 400
+ },
+ {
+ "left": 98,
+ "top": 293,
+ "right": 203,
+ "bottom": 407
+ },
+ {
+ "left": 91,
+ "top": 269,
+ "right": 213,
+ "bottom": 430
+ },
+ {
+ "left": 71,
+ "top": 206,
+ "right": 240,
+ "bottom": 491
+ },
+ {
+ "left": 34,
+ "top": 98,
+ "right": 283,
+ "bottom": 595
+ },
+ {
+ "left": 22,
+ "top": 63,
+ "right": 296,
+ "bottom": 629
+ },
+ {
+ "left": 15,
+ "top": 44,
+ "right": 303,
+ "bottom": 648
+ },
+ {
+ "left": 11,
+ "top": 32,
+ "right": 308,
+ "bottom": 659
+ },
+ {
+ "left": 8,
+ "top": 23,
+ "right": 311,
+ "bottom": 667
+ },
+ {
+ "left": 6,
+ "top": 18,
+ "right": 313,
+ "bottom": 673
+ },
+ {
+ "left": 5,
+ "top": 13,
+ "right": 315,
+ "bottom": 677
+ },
+ {
+ "left": 3,
+ "top": 9,
+ "right": 316,
+ "bottom": 681
+ },
+ {
+ "left": 2,
+ "top": 7,
+ "right": 317,
+ "bottom": 683
+ },
+ {
+ "left": 2,
+ "top": 5,
+ "right": 318,
+ "bottom": 685
+ },
+ {
+ "left": 1,
+ "top": 3,
+ "right": 319,
+ "bottom": 687
+ },
+ {
+ "left": 1,
+ "top": 2,
+ "right": 319,
+ "bottom": 688
+ },
+ {
+ "left": 0,
+ "top": 1,
+ "right": 320,
+ "bottom": 689
+ },
+ {
+ "left": 0,
+ "top": 0,
+ "right": 320,
+ "bottom": 690
+ },
+ {
+ "left": 0,
+ "top": 0,
+ "right": 320,
+ "bottom": 690
+ },
+ {
+ "left": 0,
+ "top": 0,
+ "right": 320,
+ "bottom": 690
+ }
+ ]
+ },
+ {
+ "name": "corner_radii",
+ "type": "cornerRadii",
+ "data_points": [
+ null,
+ {
+ "top_left_x": 10,
+ "top_left_y": 10,
+ "top_right_x": 10,
+ "top_right_y": 10,
+ "bottom_right_x": 20,
+ "bottom_right_y": 20,
+ "bottom_left_x": 20,
+ "bottom_left_y": 20
+ },
+ {
+ "top_left_x": 9.762664,
+ "top_left_y": 9.762664,
+ "top_right_x": 9.762664,
+ "top_right_y": 9.762664,
+ "bottom_right_x": 19.525328,
+ "bottom_right_y": 19.525328,
+ "bottom_left_x": 19.525328,
+ "bottom_left_y": 19.525328
+ },
+ {
+ "top_left_x": 8.969244,
+ "top_left_y": 8.969244,
+ "top_right_x": 8.969244,
+ "top_right_y": 8.969244,
+ "bottom_right_x": 17.938488,
+ "bottom_right_y": 17.938488,
+ "bottom_left_x": 17.938488,
+ "bottom_left_y": 17.938488
+ },
+ {
+ "top_left_x": 6.8709626,
+ "top_left_y": 6.8709626,
+ "top_right_x": 6.8709626,
+ "top_right_y": 6.8709626,
+ "bottom_right_x": 13.741925,
+ "bottom_right_y": 13.741925,
+ "bottom_left_x": 13.741925,
+ "bottom_left_y": 13.741925
+ },
+ {
+ "top_left_x": 3.260561,
+ "top_left_y": 3.260561,
+ "top_right_x": 3.260561,
+ "top_right_y": 3.260561,
+ "bottom_right_x": 6.521122,
+ "bottom_right_y": 6.521122,
+ "bottom_left_x": 6.521122,
+ "bottom_left_y": 6.521122
+ },
+ {
+ "top_left_x": 2.0915751,
+ "top_left_y": 2.0915751,
+ "top_right_x": 2.0915751,
+ "top_right_y": 2.0915751,
+ "bottom_right_x": 4.1831503,
+ "bottom_right_y": 4.1831503,
+ "bottom_left_x": 4.1831503,
+ "bottom_left_y": 4.1831503
+ },
+ {
+ "top_left_x": 1.4640827,
+ "top_left_y": 1.4640827,
+ "top_right_x": 1.4640827,
+ "top_right_y": 1.4640827,
+ "bottom_right_x": 2.9281654,
+ "bottom_right_y": 2.9281654,
+ "bottom_left_x": 2.9281654,
+ "bottom_left_y": 2.9281654
+ },
+ {
+ "top_left_x": 1.057313,
+ "top_left_y": 1.057313,
+ "top_right_x": 1.057313,
+ "top_right_y": 1.057313,
+ "bottom_right_x": 2.114626,
+ "bottom_right_y": 2.114626,
+ "bottom_left_x": 2.114626,
+ "bottom_left_y": 2.114626
+ },
+ {
+ "top_left_x": 0.7824335,
+ "top_left_y": 0.7824335,
+ "top_right_x": 0.7824335,
+ "top_right_y": 0.7824335,
+ "bottom_right_x": 1.564867,
+ "bottom_right_y": 1.564867,
+ "bottom_left_x": 1.564867,
+ "bottom_left_y": 1.564867
+ },
+ {
+ "top_left_x": 0.5863056,
+ "top_left_y": 0.5863056,
+ "top_right_x": 0.5863056,
+ "top_right_y": 0.5863056,
+ "bottom_right_x": 1.1726112,
+ "bottom_right_y": 1.1726112,
+ "bottom_left_x": 1.1726112,
+ "bottom_left_y": 1.1726112
+ },
+ {
+ "top_left_x": 0.4332962,
+ "top_left_y": 0.4332962,
+ "top_right_x": 0.4332962,
+ "top_right_y": 0.4332962,
+ "bottom_right_x": 0.8665924,
+ "bottom_right_y": 0.8665924,
+ "bottom_left_x": 0.8665924,
+ "bottom_left_y": 0.8665924
+ },
+ {
+ "top_left_x": 0.3145876,
+ "top_left_y": 0.3145876,
+ "top_right_x": 0.3145876,
+ "top_right_y": 0.3145876,
+ "bottom_right_x": 0.6291752,
+ "bottom_right_y": 0.6291752,
+ "bottom_left_x": 0.6291752,
+ "bottom_left_y": 0.6291752
+ },
+ {
+ "top_left_x": 0.22506618,
+ "top_left_y": 0.22506618,
+ "top_right_x": 0.22506618,
+ "top_right_y": 0.22506618,
+ "bottom_right_x": 0.45013237,
+ "bottom_right_y": 0.45013237,
+ "bottom_left_x": 0.45013237,
+ "bottom_left_y": 0.45013237
+ },
+ {
+ "top_left_x": 0.15591621,
+ "top_left_y": 0.15591621,
+ "top_right_x": 0.15591621,
+ "top_right_y": 0.15591621,
+ "bottom_right_x": 0.31183243,
+ "bottom_right_y": 0.31183243,
+ "bottom_left_x": 0.31183243,
+ "bottom_left_y": 0.31183243
+ },
+ {
+ "top_left_x": 0.100948334,
+ "top_left_y": 0.100948334,
+ "top_right_x": 0.100948334,
+ "top_right_y": 0.100948334,
+ "bottom_right_x": 0.20189667,
+ "bottom_right_y": 0.20189667,
+ "bottom_left_x": 0.20189667,
+ "bottom_left_y": 0.20189667
+ },
+ {
+ "top_left_x": 0.06496239,
+ "top_left_y": 0.06496239,
+ "top_right_x": 0.06496239,
+ "top_right_y": 0.06496239,
+ "bottom_right_x": 0.12992477,
+ "bottom_right_y": 0.12992477,
+ "bottom_left_x": 0.12992477,
+ "bottom_left_y": 0.12992477
+ },
+ {
+ "top_left_x": 0.03526497,
+ "top_left_y": 0.03526497,
+ "top_right_x": 0.03526497,
+ "top_right_y": 0.03526497,
+ "bottom_right_x": 0.07052994,
+ "bottom_right_y": 0.07052994,
+ "bottom_left_x": 0.07052994,
+ "bottom_left_y": 0.07052994
+ },
+ {
+ "top_left_x": 0.014661789,
+ "top_left_y": 0.014661789,
+ "top_right_x": 0.014661789,
+ "top_right_y": 0.014661789,
+ "bottom_right_x": 0.029323578,
+ "bottom_right_y": 0.029323578,
+ "bottom_left_x": 0.029323578,
+ "bottom_left_y": 0.029323578
+ },
+ {
+ "top_left_x": 0.0041856766,
+ "top_left_y": 0.0041856766,
+ "top_right_x": 0.0041856766,
+ "top_right_y": 0.0041856766,
+ "bottom_right_x": 0.008371353,
+ "bottom_right_y": 0.008371353,
+ "bottom_left_x": 0.008371353,
+ "bottom_left_y": 0.008371353
+ },
+ {
+ "top_left_x": 0,
+ "top_left_y": 0,
+ "top_right_x": 0,
+ "top_right_y": 0,
+ "bottom_right_x": 0,
+ "bottom_right_y": 0,
+ "bottom_left_x": 0,
+ "bottom_left_y": 0
+ }
+ ]
+ },
+ {
+ "name": "alpha",
+ "type": "int",
+ "data_points": [
+ 0,
+ 0,
+ 115,
+ 178,
+ 217,
+ 241,
+ 253,
+ 239,
+ 183,
+ 135,
+ 91,
+ 53,
+ 23,
+ 5,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/packages/SystemUI/tests/goldens/backgroundAnimation_whenReturning.json b/packages/SystemUI/tests/goldens/backgroundAnimation_whenReturning.json
new file mode 100644
index 0000000..608e633
--- /dev/null
+++ b/packages/SystemUI/tests/goldens/backgroundAnimation_whenReturning.json
@@ -0,0 +1,393 @@
+{
+ "frame_ids": [
+ "before",
+ 0,
+ 26,
+ 52,
+ 78,
+ 105,
+ 131,
+ 157,
+ 184,
+ 210,
+ 236,
+ 263,
+ 289,
+ 315,
+ 342,
+ 368,
+ 394,
+ 421,
+ 447,
+ 473,
+ 500
+ ],
+ "features": [
+ {
+ "name": "bounds",
+ "type": "rect",
+ "data_points": [
+ {
+ "left": 0,
+ "top": 0,
+ "right": 0,
+ "bottom": 0
+ },
+ {
+ "left": 100,
+ "top": 300,
+ "right": 200,
+ "bottom": 400
+ },
+ {
+ "left": 98,
+ "top": 293,
+ "right": 203,
+ "bottom": 407
+ },
+ {
+ "left": 91,
+ "top": 269,
+ "right": 213,
+ "bottom": 430
+ },
+ {
+ "left": 71,
+ "top": 206,
+ "right": 240,
+ "bottom": 491
+ },
+ {
+ "left": 34,
+ "top": 98,
+ "right": 283,
+ "bottom": 595
+ },
+ {
+ "left": 22,
+ "top": 63,
+ "right": 296,
+ "bottom": 629
+ },
+ {
+ "left": 15,
+ "top": 44,
+ "right": 303,
+ "bottom": 648
+ },
+ {
+ "left": 11,
+ "top": 32,
+ "right": 308,
+ "bottom": 659
+ },
+ {
+ "left": 8,
+ "top": 23,
+ "right": 311,
+ "bottom": 667
+ },
+ {
+ "left": 6,
+ "top": 18,
+ "right": 313,
+ "bottom": 673
+ },
+ {
+ "left": 5,
+ "top": 13,
+ "right": 315,
+ "bottom": 677
+ },
+ {
+ "left": 3,
+ "top": 9,
+ "right": 316,
+ "bottom": 681
+ },
+ {
+ "left": 2,
+ "top": 7,
+ "right": 317,
+ "bottom": 683
+ },
+ {
+ "left": 2,
+ "top": 5,
+ "right": 318,
+ "bottom": 685
+ },
+ {
+ "left": 1,
+ "top": 3,
+ "right": 319,
+ "bottom": 687
+ },
+ {
+ "left": 1,
+ "top": 2,
+ "right": 319,
+ "bottom": 688
+ },
+ {
+ "left": 0,
+ "top": 1,
+ "right": 320,
+ "bottom": 689
+ },
+ {
+ "left": 0,
+ "top": 0,
+ "right": 320,
+ "bottom": 690
+ },
+ {
+ "left": 0,
+ "top": 0,
+ "right": 320,
+ "bottom": 690
+ },
+ {
+ "left": 0,
+ "top": 0,
+ "right": 320,
+ "bottom": 690
+ }
+ ]
+ },
+ {
+ "name": "corner_radii",
+ "type": "cornerRadii",
+ "data_points": [
+ null,
+ {
+ "top_left_x": 10,
+ "top_left_y": 10,
+ "top_right_x": 10,
+ "top_right_y": 10,
+ "bottom_right_x": 20,
+ "bottom_right_y": 20,
+ "bottom_left_x": 20,
+ "bottom_left_y": 20
+ },
+ {
+ "top_left_x": 9.762664,
+ "top_left_y": 9.762664,
+ "top_right_x": 9.762664,
+ "top_right_y": 9.762664,
+ "bottom_right_x": 19.525328,
+ "bottom_right_y": 19.525328,
+ "bottom_left_x": 19.525328,
+ "bottom_left_y": 19.525328
+ },
+ {
+ "top_left_x": 8.969244,
+ "top_left_y": 8.969244,
+ "top_right_x": 8.969244,
+ "top_right_y": 8.969244,
+ "bottom_right_x": 17.938488,
+ "bottom_right_y": 17.938488,
+ "bottom_left_x": 17.938488,
+ "bottom_left_y": 17.938488
+ },
+ {
+ "top_left_x": 6.8709626,
+ "top_left_y": 6.8709626,
+ "top_right_x": 6.8709626,
+ "top_right_y": 6.8709626,
+ "bottom_right_x": 13.741925,
+ "bottom_right_y": 13.741925,
+ "bottom_left_x": 13.741925,
+ "bottom_left_y": 13.741925
+ },
+ {
+ "top_left_x": 3.260561,
+ "top_left_y": 3.260561,
+ "top_right_x": 3.260561,
+ "top_right_y": 3.260561,
+ "bottom_right_x": 6.521122,
+ "bottom_right_y": 6.521122,
+ "bottom_left_x": 6.521122,
+ "bottom_left_y": 6.521122
+ },
+ {
+ "top_left_x": 2.0915751,
+ "top_left_y": 2.0915751,
+ "top_right_x": 2.0915751,
+ "top_right_y": 2.0915751,
+ "bottom_right_x": 4.1831503,
+ "bottom_right_y": 4.1831503,
+ "bottom_left_x": 4.1831503,
+ "bottom_left_y": 4.1831503
+ },
+ {
+ "top_left_x": 1.4640827,
+ "top_left_y": 1.4640827,
+ "top_right_x": 1.4640827,
+ "top_right_y": 1.4640827,
+ "bottom_right_x": 2.9281654,
+ "bottom_right_y": 2.9281654,
+ "bottom_left_x": 2.9281654,
+ "bottom_left_y": 2.9281654
+ },
+ {
+ "top_left_x": 1.057313,
+ "top_left_y": 1.057313,
+ "top_right_x": 1.057313,
+ "top_right_y": 1.057313,
+ "bottom_right_x": 2.114626,
+ "bottom_right_y": 2.114626,
+ "bottom_left_x": 2.114626,
+ "bottom_left_y": 2.114626
+ },
+ {
+ "top_left_x": 0.7824335,
+ "top_left_y": 0.7824335,
+ "top_right_x": 0.7824335,
+ "top_right_y": 0.7824335,
+ "bottom_right_x": 1.564867,
+ "bottom_right_y": 1.564867,
+ "bottom_left_x": 1.564867,
+ "bottom_left_y": 1.564867
+ },
+ {
+ "top_left_x": 0.5863056,
+ "top_left_y": 0.5863056,
+ "top_right_x": 0.5863056,
+ "top_right_y": 0.5863056,
+ "bottom_right_x": 1.1726112,
+ "bottom_right_y": 1.1726112,
+ "bottom_left_x": 1.1726112,
+ "bottom_left_y": 1.1726112
+ },
+ {
+ "top_left_x": 0.4332962,
+ "top_left_y": 0.4332962,
+ "top_right_x": 0.4332962,
+ "top_right_y": 0.4332962,
+ "bottom_right_x": 0.8665924,
+ "bottom_right_y": 0.8665924,
+ "bottom_left_x": 0.8665924,
+ "bottom_left_y": 0.8665924
+ },
+ {
+ "top_left_x": 0.3145876,
+ "top_left_y": 0.3145876,
+ "top_right_x": 0.3145876,
+ "top_right_y": 0.3145876,
+ "bottom_right_x": 0.6291752,
+ "bottom_right_y": 0.6291752,
+ "bottom_left_x": 0.6291752,
+ "bottom_left_y": 0.6291752
+ },
+ {
+ "top_left_x": 0.22506618,
+ "top_left_y": 0.22506618,
+ "top_right_x": 0.22506618,
+ "top_right_y": 0.22506618,
+ "bottom_right_x": 0.45013237,
+ "bottom_right_y": 0.45013237,
+ "bottom_left_x": 0.45013237,
+ "bottom_left_y": 0.45013237
+ },
+ {
+ "top_left_x": 0.15591621,
+ "top_left_y": 0.15591621,
+ "top_right_x": 0.15591621,
+ "top_right_y": 0.15591621,
+ "bottom_right_x": 0.31183243,
+ "bottom_right_y": 0.31183243,
+ "bottom_left_x": 0.31183243,
+ "bottom_left_y": 0.31183243
+ },
+ {
+ "top_left_x": 0.100948334,
+ "top_left_y": 0.100948334,
+ "top_right_x": 0.100948334,
+ "top_right_y": 0.100948334,
+ "bottom_right_x": 0.20189667,
+ "bottom_right_y": 0.20189667,
+ "bottom_left_x": 0.20189667,
+ "bottom_left_y": 0.20189667
+ },
+ {
+ "top_left_x": 0.06496239,
+ "top_left_y": 0.06496239,
+ "top_right_x": 0.06496239,
+ "top_right_y": 0.06496239,
+ "bottom_right_x": 0.12992477,
+ "bottom_right_y": 0.12992477,
+ "bottom_left_x": 0.12992477,
+ "bottom_left_y": 0.12992477
+ },
+ {
+ "top_left_x": 0.03526497,
+ "top_left_y": 0.03526497,
+ "top_right_x": 0.03526497,
+ "top_right_y": 0.03526497,
+ "bottom_right_x": 0.07052994,
+ "bottom_right_y": 0.07052994,
+ "bottom_left_x": 0.07052994,
+ "bottom_left_y": 0.07052994
+ },
+ {
+ "top_left_x": 0.014661789,
+ "top_left_y": 0.014661789,
+ "top_right_x": 0.014661789,
+ "top_right_y": 0.014661789,
+ "bottom_right_x": 0.029323578,
+ "bottom_right_y": 0.029323578,
+ "bottom_left_x": 0.029323578,
+ "bottom_left_y": 0.029323578
+ },
+ {
+ "top_left_x": 0.0041856766,
+ "top_left_y": 0.0041856766,
+ "top_right_x": 0.0041856766,
+ "top_right_y": 0.0041856766,
+ "bottom_right_x": 0.008371353,
+ "bottom_right_y": 0.008371353,
+ "bottom_left_x": 0.008371353,
+ "bottom_left_y": 0.008371353
+ },
+ {
+ "top_left_x": 0,
+ "top_left_y": 0,
+ "top_right_x": 0,
+ "top_right_y": 0,
+ "bottom_right_x": 0,
+ "bottom_right_y": 0,
+ "bottom_left_x": 0,
+ "bottom_left_y": 0
+ }
+ ]
+ },
+ {
+ "name": "alpha",
+ "type": "int",
+ "data_points": [
+ 0,
+ 0,
+ 115,
+ 178,
+ 217,
+ 241,
+ 253,
+ 239,
+ 183,
+ 135,
+ 91,
+ 53,
+ 23,
+ 5,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/packages/SystemUI/tests/src/com/android/systemui/animation/ActivityTransitionAnimatorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/animation/ActivityTransitionAnimatorTest.kt
index 75a49d7..41974f4 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/animation/ActivityTransitionAnimatorTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/animation/ActivityTransitionAnimatorTest.kt
@@ -246,6 +246,8 @@
*/
private class TestTransitionAnimatorController(override var transitionContainer: ViewGroup) :
ActivityTransitionAnimator.Controller {
+ override val isLaunching: Boolean = true
+
override fun createAnimatorState() =
TransitionAnimator.State(
top = 100,
diff --git a/packages/SystemUI/tests/src/com/android/systemui/animation/TransitionAnimatorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/animation/TransitionAnimatorTest.kt
new file mode 100644
index 0000000..c380a51
--- /dev/null
+++ b/packages/SystemUI/tests/src/com/android/systemui/animation/TransitionAnimatorTest.kt
@@ -0,0 +1,193 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.animation
+
+import android.animation.AnimatorSet
+import android.graphics.drawable.GradientDrawable
+import android.view.ViewGroup
+import android.widget.FrameLayout
+import androidx.test.ext.junit.rules.ActivityScenarioRule
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import androidx.test.filters.SmallTest
+import com.android.systemui.SysuiTestCase
+import com.android.systemui.activity.EmptyTestActivity
+import org.junit.Rule
+import org.junit.Test
+import org.junit.runner.RunWith
+import platform.test.motion.RecordedMotion
+import platform.test.motion.Sampling.Companion.evenlySampled
+import platform.test.motion.view.DrawableFeatureCaptures
+import platform.test.motion.view.ViewMotionTestRule
+import platform.test.screenshot.DeviceEmulationRule
+import platform.test.screenshot.DeviceEmulationSpec
+import platform.test.screenshot.DisplaySpec
+import platform.test.screenshot.GoldenPathManager
+import platform.test.screenshot.PathConfig
+
+@SmallTest
+@RunWith(AndroidJUnit4::class)
+class TransitionAnimatorTest : SysuiTestCase() {
+ companion object {
+ private const val GOLDENS_PATH = "frameworks/base/packages/SystemUI/tests/goldens"
+
+ private val emulationSpec =
+ DeviceEmulationSpec(
+ DisplaySpec(
+ "phone",
+ width = 320,
+ height = 690,
+ densityDpi = 160,
+ )
+ )
+ }
+
+ private val pathManager = GoldenPathManager(context, GOLDENS_PATH, pathConfig = PathConfig())
+ private val transitionAnimator =
+ TransitionAnimator(
+ ActivityTransitionAnimator.TIMINGS,
+ ActivityTransitionAnimator.INTERPOLATORS
+ )
+
+ @get:Rule(order = 0) val deviceEmulationRule = DeviceEmulationRule(emulationSpec)
+ @get:Rule(order = 1) val activityRule = ActivityScenarioRule(EmptyTestActivity::class.java)
+ @get:Rule(order = 2)
+ val motionRule =
+ ViewMotionTestRule<EmptyTestActivity>(
+ pathManager,
+ { activityRule.scenario },
+ context = context,
+ bitmapDiffer = null,
+ )
+
+ @Test
+ fun backgroundAnimation_whenLaunching() {
+ val backgroundLayer = GradientDrawable().apply { alpha = 0 }
+ val animator = setUpTest(backgroundLayer, isLaunching = true)
+
+ val recordedMotion = recordMotion(backgroundLayer, animator)
+
+ motionRule.assertThat(recordedMotion).timeSeriesMatchesGolden()
+ }
+
+ @Test
+ fun backgroundAnimation_whenReturning() {
+ val backgroundLayer = GradientDrawable().apply { alpha = 0 }
+ val animator = setUpTest(backgroundLayer, isLaunching = false)
+
+ val recordedMotion = recordMotion(backgroundLayer, animator)
+
+ motionRule.assertThat(recordedMotion).timeSeriesMatchesGolden()
+ }
+
+ @Test
+ fun backgroundAnimationWithoutFade_whenLaunching() {
+ val backgroundLayer = GradientDrawable().apply { alpha = 0 }
+ val animator =
+ setUpTest(backgroundLayer, isLaunching = true, fadeWindowBackgroundLayer = false)
+
+ val recordedMotion = recordMotion(backgroundLayer, animator)
+
+ motionRule.assertThat(recordedMotion).timeSeriesMatchesGolden()
+ }
+
+ @Test
+ fun backgroundAnimationWithoutFade_whenReturning() {
+ val backgroundLayer = GradientDrawable().apply { alpha = 0 }
+ val animator =
+ setUpTest(backgroundLayer, isLaunching = false, fadeWindowBackgroundLayer = false)
+
+ val recordedMotion = recordMotion(backgroundLayer, animator)
+
+ motionRule.assertThat(recordedMotion).timeSeriesMatchesGolden()
+ }
+
+ private fun setUpTest(
+ backgroundLayer: GradientDrawable,
+ isLaunching: Boolean,
+ fadeWindowBackgroundLayer: Boolean = true,
+ ): AnimatorSet {
+ lateinit var transitionContainer: ViewGroup
+ activityRule.scenario.onActivity { activity ->
+ transitionContainer = FrameLayout(activity).apply { setBackgroundColor(0x00FF00) }
+ activity.setContentView(transitionContainer)
+ }
+ waitForIdleSync()
+
+ val controller = TestController(transitionContainer, isLaunching)
+ val animator =
+ transitionAnimator.createAnimator(
+ controller,
+ createEndState(transitionContainer),
+ backgroundLayer,
+ fadeWindowBackgroundLayer
+ )
+ return AnimatorSet().apply {
+ duration = animator.duration
+ play(animator)
+ }
+ }
+
+ private fun createEndState(container: ViewGroup): TransitionAnimator.State {
+ val containerLocation = IntArray(2)
+ container.getLocationOnScreen(containerLocation)
+ return TransitionAnimator.State(
+ left = containerLocation[0],
+ top = containerLocation[1],
+ right = containerLocation[0] + emulationSpec.display.width,
+ bottom = containerLocation[1] + emulationSpec.display.height,
+ topCornerRadius = 0f,
+ bottomCornerRadius = 0f
+ )
+ }
+
+ private fun recordMotion(
+ backgroundLayer: GradientDrawable,
+ animator: AnimatorSet
+ ): RecordedMotion {
+ return motionRule.checkThat(animator).record(
+ backgroundLayer,
+ evenlySampled(20),
+ visualCapture = null
+ ) {
+ capture(DrawableFeatureCaptures.bounds, "bounds")
+ capture(DrawableFeatureCaptures.cornerRadii, "corner_radii")
+ capture(DrawableFeatureCaptures.alpha, "alpha")
+ }
+ }
+}
+
+/**
+ * A simple implementation of [TransitionAnimator.Controller] which throws if it is called outside
+ * of the main thread.
+ */
+private class TestController(
+ override var transitionContainer: ViewGroup,
+ override val isLaunching: Boolean
+) : TransitionAnimator.Controller {
+ override fun createAnimatorState(): TransitionAnimator.State {
+ val containerLocation = IntArray(2)
+ transitionContainer.getLocationOnScreen(containerLocation)
+ return TransitionAnimator.State(
+ left = containerLocation[0] + 100,
+ top = containerLocation[1] + 300,
+ right = containerLocation[0] + 200,
+ bottom = containerLocation[1] + 400,
+ topCornerRadius = 10f,
+ bottomCornerRadius = 20f
+ )
+ }
+}