public void TestOnlineBeatmap()
        {
            if (api.IsLoggedIn)
            {
                var req = new GetBeatmapSetRequest(1);
                api.Queue(req);

                AddUntilStep("wait for api response", () => req.Result != null);

                TestUpdateableBeatmapBackgroundSprite background = null;

                AddStep("load online beatmap", () =>
                {
                    Child = background = new TestUpdateableBeatmapBackgroundSprite
                    {
                        RelativeSizeAxes = Axes.Both,
                        Beatmap          = { Value = new BeatmapInfo {
                                                 BeatmapSet = req.Result?.ToBeatmapSet(rulesets)
                                             } }
                    };
                });

                AddUntilStep("wait for load", () => background.ContentLoaded);
            }
            else
            {
                AddStep("online (login first)", () => { });
            }
        }
Example #2
0
        private void load(OsuGameBase osu, APIAccess api, RulesetStore rulesets)
        {
            Bindable <BeatmapInfo> beatmapBindable = new Bindable <BeatmapInfo>();

            var imported = ImportBeatmapTest.LoadOszIntoOsu(osu);

            Child = backgroundSprite = new TestUpdateableBeatmapBackgroundSprite {
                RelativeSizeAxes = Axes.Both
            };

            backgroundSprite.Beatmap.BindTo(beatmapBindable);

            var req = new GetBeatmapSetRequest(1);

            api.Queue(req);

            AddStep("load null beatmap", () => beatmapBindable.Value = null);
            AddUntilStep(() => backgroundSprite.ChildCount == 1, "wait for cleanup...");
            AddStep("load imported beatmap", () => beatmapBindable.Value = imported.Beatmaps.First());
            AddUntilStep(() => backgroundSprite.ChildCount == 1, "wait for cleanup...");

            if (api.IsLoggedIn)
            {
                AddUntilStep(() => req.Result != null, "wait for api response");
                AddStep("load online beatmap", () => beatmapBindable.Value = new BeatmapInfo
                {
                    BeatmapSet = req.Result?.ToBeatmapSet(rulesets)
                });
                AddUntilStep(() => backgroundSprite.ChildCount == 1, "wait for cleanup...");
            }
            else
            {
                AddStep("online (login first)", () => { });
            }
        }
        public void TestNullBeatmap()
        {
            TestUpdateableBeatmapBackgroundSprite background = null;

            AddStep("load null beatmap", () => Child = background = new TestUpdateableBeatmapBackgroundSprite {
                RelativeSizeAxes = Axes.Both
            });
            AddUntilStep("content loaded", () => background.ContentLoaded);
        }
        public void TestUnloadAndReload()
        {
            var             backgrounds     = new List <TestUpdateableBeatmapBackgroundSprite>();
            ScrollContainer scrollContainer = null;

            AddStep("create backgrounds hierarchy", () =>
            {
                FillFlowContainer backgroundFlow;

                Child = scrollContainer = new ScrollContainer
                {
                    Size  = new Vector2(500),
                    Child = backgroundFlow = new FillFlowContainer
                    {
                        RelativeSizeAxes = Axes.X,
                        AutoSizeAxes     = Axes.Y,
                        Direction        = FillDirection.Vertical,
                        Spacing          = new Vector2(10),
                        Padding          = new MarginPadding {
                            Bottom = 250
                        }
                    }
                };

                for (int i = 0; i < 25; i++)
                {
                    var background = new TestUpdateableBeatmapBackgroundSprite {
                        RelativeSizeAxes = Axes.Both
                    };

                    if (i % 2 == 0)
                    {
                        background.Beatmap.Value = testBeatmap.Beatmaps.First();
                    }

                    backgroundFlow.Add(new Container
                    {
                        RelativeSizeAxes = Axes.X,
                        Height           = 100,
                        Masking          = true,
                        Child            = background
                    });

                    backgrounds.Add(background);
                }
            });

            var loadedBackgrounds = backgrounds.Where(b => b.ContentLoaded);

            int initialLoadCount = 0;

            AddUntilStep("some loaded", () => (initialLoadCount = loadedBackgrounds.Count()) > 0);
            AddStep("scroll to bottom", () => scrollContainer.ScrollToEnd());
            AddUntilStep("some unloaded", () => loadedBackgrounds.Count() < initialLoadCount);
        }
        public void TestLocalBeatmap()
        {
            TestUpdateableBeatmapBackgroundSprite background = null;

            AddStep("load local beatmap", () =>
            {
                Child = background = new TestUpdateableBeatmapBackgroundSprite
                {
                    RelativeSizeAxes = Axes.Both,
                    Beatmap          = { Value = testBeatmap.Beatmaps.First() }
                };
            });

            AddUntilStep("wait for load", () => background.ContentLoaded);
        }