public void TestWrapperStopReceivingUpdatesAfterDelayedLoadCompleted()
        {
            DelayedLoadTestDrawable child = null;

            AddStep("add panel", () =>
            {
                DelayedLoadUnloadWrapper wrapper;

                Child = wrapper = new DelayedLoadUnloadWrapper(() => child = new DelayedLoadTestDrawable {
                    RelativeSizeAxes = Axes.Both
                }, 0, 1000)
                {
                    RelativeSizeAxes = Axes.X,
                    Height           = 128,
                };

                // Prevent the wrapper from receiving updates as soon as load completes, and start making it unload its contents by repositioning it offscreen.
                wrapper.DelayedLoadComplete += _ =>
                {
                    wrapper.Alpha    = 0;
                    wrapper.Position = new Vector2(-1000);
                };
            });

            // Check that the child is disposed when its async-load completes while the wrapper is masked away.
            AddUntilStep("wait for load to begin", () => child?.LoadState == LoadState.Loading);
            AddStep("allow load", () => child.AllowLoad.Set());
            AddUntilStep("drawable disposed", () => child.IsDisposed);
        }
        public void TestUnloadedWhenAsyncLoadCompletedAndMaskedAway()
        {
            BasicScrollContainer    scrollContainer = null;
            DelayedLoadTestDrawable child           = null;

            AddStep("add panel", () =>
            {
                Child = scrollContainer = new BasicScrollContainer
                {
                    Anchor = Anchor.Centre,
                    Origin = Anchor.Centre,
                    Size   = new Vector2(128),
                    Child  = new Container
                    {
                        RelativeSizeAxes = Axes.X,
                        Height           = 1000,
                        Child            = new Container
                        {
                            RelativeSizeAxes = Axes.X,
                            Height           = 128,
                            Child            = new DelayedLoadUnloadWrapper(() => child = new DelayedLoadTestDrawable {
                                RelativeSizeAxes = Axes.Both
                            }, 0, 1000)
                            {
                                RelativeSizeAxes = Axes.X,
                                Height           = 128
                            }
                        }
                    }
                };
            });

            // Check that the child is disposed when its async-load completes while the wrapper is masked away.
            AddUntilStep("wait for load to begin", () => child?.LoadState == LoadState.Loading);
            AddStep("scroll to end", () => scrollContainer.ScrollToEnd(false));
            AddStep("allow load", () => child.AllowLoad.Set());
            AddUntilStep("drawable disposed", () => child.IsDisposed);

            Drawable lastChild = null;

            AddStep("store child", () => lastChild = child);

            // Check that reuse of the child is not attempted.
            AddStep("scroll to start", () => scrollContainer.ScrollToStart(false));
            AddStep("allow load of new child", () => child.AllowLoad.Set());
            AddUntilStep("new child loaded", () => child.IsLoaded);
            AddAssert("last child not loaded", () => !lastChild.IsLoaded);
        }