@@ -687,6 +687,66 @@ void main() {
687687 expect (() => pumpFrame (phase: EnginePhase .composite), returnsNormally);
688688 });
689689
690+ test ('Offstage implements paintsChild correctly' , () {
691+ final RenderBox box = RenderConstrainedBox (additionalConstraints: const BoxConstraints .tightFor (width: 20 ));
692+ final RenderBox parent = RenderConstrainedBox (additionalConstraints: const BoxConstraints .tightFor (width: 20 ));
693+ final RenderOffstage offstage = RenderOffstage (offstage: false , child: box);
694+ parent.adoptChild (offstage);
695+
696+ expect (offstage.paintsChild (box), true );
697+
698+ offstage.offstage = true ;
699+
700+ expect (offstage.paintsChild (box), false );
701+ });
702+
703+ test ('Opacity implements paintsChild correctly' , () {
704+ final RenderBox box = RenderConstrainedBox (additionalConstraints: const BoxConstraints .tightFor (width: 20 ));
705+ final RenderBox parent = RenderConstrainedBox (additionalConstraints: const BoxConstraints .tightFor (width: 20 ));
706+ final RenderOpacity opacity = RenderOpacity (child: box);
707+ parent.adoptChild (opacity);
708+
709+ expect (opacity.paintsChild (box), true );
710+
711+ opacity.opacity = 0 ;
712+
713+ expect (opacity.paintsChild (box), false );
714+ });
715+
716+ test ('AnimatedOpacity sets paint matrix to zero when alpha == 0' , () {
717+ final RenderBox box = RenderConstrainedBox (additionalConstraints: const BoxConstraints .tightFor (width: 20 ));
718+ final RenderBox parent = RenderConstrainedBox (additionalConstraints: const BoxConstraints .tightFor (width: 20 ));
719+ final AnimationController opacityAnimation = AnimationController (value: 1 , vsync: FakeTickerProvider ());
720+ final RenderAnimatedOpacity opacity = RenderAnimatedOpacity (opacity: opacityAnimation, child: box);
721+ parent.adoptChild (opacity);
722+
723+ // Make it listen to the animation.
724+ opacity.attach (PipelineOwner ());
725+
726+ expect (opacity.paintsChild (box), true );
727+
728+ opacityAnimation.value = 0 ;
729+
730+ expect (opacity.paintsChild (box), false );
731+ });
732+
733+ test ('AnimatedOpacity sets paint matrix to zero when alpha == 0 (sliver)' , () {
734+ final RenderSliver sliver = RenderSliverToBoxAdapter (child: RenderConstrainedBox (additionalConstraints: const BoxConstraints .tightFor (width: 20 )));
735+ final RenderBox parent = RenderConstrainedBox (additionalConstraints: const BoxConstraints .tightFor (width: 20 ));
736+ final AnimationController opacityAnimation = AnimationController (value: 1 , vsync: FakeTickerProvider ());
737+ final RenderSliverAnimatedOpacity opacity = RenderSliverAnimatedOpacity (opacity: opacityAnimation, sliver: sliver);
738+ parent.adoptChild (opacity);
739+
740+ // Make it listen to the animation.
741+ opacity.attach (PipelineOwner ());
742+
743+ expect (opacity.paintsChild (sliver), true );
744+
745+ opacityAnimation.value = 0 ;
746+
747+ expect (opacity.paintsChild (sliver), false );
748+ });
749+
690750 test ('RenderCustomClip extenders respect clipBehavior when asked to describeApproximateClip' , () {
691751 final RenderBox child = RenderConstrainedBox (additionalConstraints: const BoxConstraints .tightFor (width: 200 , height: 200 ));
692752 final RenderClipRect renderClipRect = RenderClipRect (clipBehavior: Clip .none, child: child);
0 commit comments