Esempio n. 1
0
        public void TestLegacyBeatmapReplayOffsetsEncodeDecode(int beatmapVersion)
        {
            const double first_frame_time  = 2000;
            const double second_frame_time = 3000;

            var ruleset   = new OsuRuleset().RulesetInfo;
            var scoreInfo = TestResources.CreateTestScoreInfo(ruleset);
            var beatmap   = new TestBeatmap(ruleset)
            {
                BeatmapInfo =
                {
                    BeatmapVersion = beatmapVersion
                }
            };

            var score = new Score
            {
                ScoreInfo = scoreInfo,
                Replay    = new Replay
                {
                    Frames = new List <ReplayFrame>
                    {
                        new OsuReplayFrame(first_frame_time, OsuPlayfield.BASE_SIZE / 2, OsuAction.LeftButton),
                        new OsuReplayFrame(second_frame_time, OsuPlayfield.BASE_SIZE / 2, OsuAction.LeftButton)
                    }
                }
            };

            var decodedAfterEncode = encodeThenDecode(beatmapVersion, score, beatmap);

            Assert.That(decodedAfterEncode.Replay.Frames[0].Time, Is.EqualTo(first_frame_time));
            Assert.That(decodedAfterEncode.Replay.Frames[1].Time, Is.EqualTo(second_frame_time));
        }
        public void TestDisplayTeamResults(int team1Score, int team2Score)
        {
            MultiplayerResultsScreen screen = null;

            AddStep("show results screen", () =>
            {
                var rulesetInfo = new OsuRuleset().RulesetInfo;
                var beatmapInfo = CreateBeatmap(rulesetInfo).BeatmapInfo;
                var score       = TestResources.CreateTestScoreInfo(beatmapInfo);

                PlaylistItem playlistItem = new PlaylistItem
                {
                    BeatmapID = beatmapInfo.OnlineID,
                };

                SortedDictionary <int, BindableInt> teamScores = new SortedDictionary <int, BindableInt>
                {
                    { 0, new BindableInt(team1Score) },
                    { 1, new BindableInt(team2Score) }
                };

                Stack.Push(screen = new MultiplayerTeamResultsScreen(score, 1, playlistItem, teamScores));
            });

            AddUntilStep("wait for loaded", () => screen.IsLoaded);
        }
Esempio n. 3
0
        private ScoreInfo createScoreForTotalScore(long totalScore)
        {
            var score = TestResources.CreateTestScoreInfo();

            score.TotalScore = totalScore;
            return(score);
        }
Esempio n. 4
0
        public void TestBasicImportDelete()
        {
            ScoreInfo testScoreInfo = null;

            AddAssert("Initially not present", () => !topLocalRank.IsPresent);

            AddStep("Add score for current user", () =>
            {
                testScoreInfo = TestResources.CreateTestScoreInfo(importedBeatmap);

                testScoreInfo.User = API.LocalUser.Value;
                testScoreInfo.Rank = ScoreRank.B;

                scoreManager.Import(testScoreInfo);
            });

            AddUntilStep("Became present", () => topLocalRank.IsPresent);
            AddAssert("Correct rank", () => topLocalRank.Rank == ScoreRank.B);

            AddStep("Delete score", () =>
            {
                scoreManager.Delete(testScoreInfo);
            });

            AddUntilStep("Became not present", () => !topLocalRank.IsPresent);
        }
Esempio n. 5
0
 public void TestEmptyListWithSelectedScore()
 {
     createListStep(() => new ScorePanelList
     {
         SelectedScore = { Value = TestResources.CreateTestScoreInfo() }
     });
 }
        public override void SetUpSteps()
        {
            base.SetUpSteps();

            // Previous test instances of the results screen may still exist at this point so wait for
            // those screens to be cleaned up by the base SetUpSteps before re-initialising test state.
            // The the screen also holds a leased Beatmap bindable so reassigning it must happen after
            // the screen as been exited.
            AddStep("initialise user scores and beatmap", () =>
            {
                lowestScoreId   = 1;
                highestScoreId  = 1;
                requestComplete = false;
                totalCount      = 0;

                userScore            = TestResources.CreateTestScoreInfo();
                userScore.TotalScore = 0;
                userScore.Statistics = new Dictionary <HitResult, int>();

                bindHandler();

                // Beatmap is required to be an actual beatmap so the scores can get their scores correctly
                // calculated for standardised scoring, else the tests that rely on ordering will fall over.
                Beatmap.Value = CreateWorkingBeatmap(Ruleset.Value);
            });
        }
Esempio n. 7
0
        public void TestAddManyPanelsOnBothSidesOfExpandedPanel()
        {
            var initialScore = TestResources.CreateTestScoreInfo();

            createListStep(() => new ScorePanelList());

            AddStep("add initial panel and select", () =>
            {
                list.AddScore(initialScore);
                list.SelectedScore.Value = initialScore;
            });

            AddStep("add scores after", () =>
            {
                for (int i = 0; i < 20; i++)
                {
                    list.AddScore(createScoreForTotalScore(initialScore.TotalScore - i - 1));
                }

                for (int i = 0; i < 20; i++)
                {
                    list.AddScore(createScoreForTotalScore(initialScore.TotalScore + i + 1));
                }
            });

            assertScoreState(initialScore, true);
            assertExpandedPanelCentred();
        }
Esempio n. 8
0
        public void TestChangeBeatmapWhilePresentingScore()
        {
            BeatmapInfo getPresentBeatmap() => manager.GetAllUsableBeatmapSets().Where(s => !s.DeletePending).SelectMany(s => s.Beatmaps).First(b => b.Ruleset.OnlineID == 0);
            BeatmapInfo getSwitchBeatmap() => manager.GetAllUsableBeatmapSets().Where(s => !s.DeletePending).SelectMany(s => s.Beatmaps).First(b => b.Ruleset.OnlineID == 1);

            changeRuleset(0);

            addRulesetImportStep(0);
            addRulesetImportStep(1);

            createSongSelect();

            AddUntilStep("wait for selection", () => !Beatmap.IsDefault);

            AddStep("present score", () =>
            {
                // this beatmap change should be overridden by the present.
                Beatmap.Value = manager.GetWorkingBeatmap(getSwitchBeatmap());

                songSelect.PresentScore(TestResources.CreateTestScoreInfo(getPresentBeatmap()));
            });

            AddUntilStep("wait for results screen presented", () => !songSelect.IsCurrentScreen());

            AddAssert("check beatmap is correct for score", () => Beatmap.Value.BeatmapInfo.MatchesOnlineID(getPresentBeatmap()));
            AddAssert("check ruleset is correct for score", () => Ruleset.Value.OnlineID == 0);
        }
Esempio n. 9
0
        public void TestSelectMultipleScores()
        {
            var firstScore  = TestResources.CreateTestScoreInfo();
            var secondScore = TestResources.CreateTestScoreInfo();

            firstScore.UserString  = "A";
            secondScore.UserString = "B";

            createListStep(() => new ScorePanelList());

            AddStep("add scores and select first", () =>
            {
                list.AddScore(firstScore);
                list.AddScore(secondScore);
                list.SelectedScore.Value = firstScore;
            });

            AddUntilStep("wait for load", () => list.AllPanelsVisible);

            assertScoreState(firstScore, true);
            assertScoreState(secondScore, false);

            AddStep("select second score", () =>
            {
                InputManager.MoveMouseTo(list.ChildrenOfType <ScorePanel>().Single(p => p.Score == secondScore));
                InputManager.Click(MouseButton.Left);
            });

            assertScoreState(firstScore, false);
            assertScoreState(secondScore, true);
            assertExpandedPanelCentred();
        }
        public void TestFetchWhenScrolledToTheLeft()
        {
            ScoreInfo userScore = null;

            AddStep("bind user score info handler", () =>
            {
                userScore          = TestResources.CreateTestScoreInfo();
                userScore.OnlineID = currentScoreId++;

                bindHandler(userScore: userScore);
            });

            createResults(() => userScore);

            AddStep("bind delayed handler", () => bindHandler(true));

            for (int i = 0; i < 2; i++)
            {
                int beforePanelCount = 0;

                AddStep("get panel count", () => beforePanelCount = this.ChildrenOfType <ScorePanel>().Count());
                AddStep("scroll to left", () => resultsScreen.ScorePanelList.ChildrenOfType <OsuScrollContainer>().Single().ScrollToStart(false));

                AddAssert("left loading spinner shown", () => resultsScreen.LeftSpinner.State.Value == Visibility.Visible);
                waitForDisplay();

                AddAssert($"count increased by {scores_per_result}", () => this.ChildrenOfType <ScorePanel>().Count() == beforePanelCount + scores_per_result);
                AddAssert("left loading spinner hidden", () => resultsScreen.LeftSpinner.State.Value == Visibility.Hidden);
            }
        }
Esempio n. 11
0
        public void TestHigherScoreSet()
        {
            ScoreInfo testScoreInfo = null;

            AddAssert("Initially not present", () => !topLocalRank.IsPresent);

            AddStep("Add score for current user", () =>
            {
                testScoreInfo = TestResources.CreateTestScoreInfo(importedBeatmap);

                testScoreInfo.User = API.LocalUser.Value;
                testScoreInfo.Rank = ScoreRank.B;

                scoreManager.Import(testScoreInfo);
            });

            AddUntilStep("Became present", () => topLocalRank.IsPresent);
            AddUntilStep("Correct rank", () => topLocalRank.Rank == ScoreRank.B);

            AddStep("Add higher score for current user", () =>
            {
                var testScoreInfo2 = TestResources.CreateTestScoreInfo(importedBeatmap);

                testScoreInfo2.User       = API.LocalUser.Value;
                testScoreInfo2.Rank       = ScoreRank.S;
                testScoreInfo2.TotalScore = testScoreInfo.TotalScore + 1;

                scoreManager.Import(testScoreInfo2);
            });

            AddUntilStep("Correct rank", () => topLocalRank.Rank == ScoreRank.S);
        }
Esempio n. 12
0
        public void TestMapWithKnownMapper()
        {
            var author = new RealmUser {
                Username = "******"
            };

            AddStep("show example score", () => showPanel(TestResources.CreateTestScoreInfo(createTestBeatmap(author))));
        }
Esempio n. 13
0
        public void TestScoreWithPositionStatistics()
        {
            var score = TestResources.CreateTestScoreInfo();

            score.HitEvents = createPositionDistributedHitEvents();

            loadPanel(score);
        }
Esempio n. 14
0
        public void TestScoreWithTimeStatistics()
        {
            var score = TestResources.CreateTestScoreInfo();

            score.HitEvents = TestSceneHitEventTimingDistributionGraph.CreateDistributedHitEvents();

            loadPanel(score);
        }
Esempio n. 15
0
        public void TestContractedPanel()
        {
            var score = TestResources.CreateTestScoreInfo();

            score.Accuracy = 0.925;
            score.Rank     = ScoreRank.A;

            addPanelStep(score, PanelState.Contracted);
        }
        public void TestScoreSerialisationWithoutSettings()
        {
            var score = new SubmittableScore(TestResources.CreateTestScoreInfo());

            string serialised = JsonConvert.SerializeObject(score);

            Assert.That(serialised, Contains.Substring("large_tick_hit"));
            Assert.That(serialised, Contains.Substring("\"rank\":\"S\""));
        }
Esempio n. 17
0
 public void TestExcessMods()
 {
     AddStep("show excess mods score", () =>
     {
         var score  = TestResources.CreateTestScoreInfo();
         score.Mods = score.BeatmapInfo.Ruleset.CreateInstance().CreateAllMods().ToArray();
         showPanel(CreateWorkingBeatmap(CreateBeatmap(new OsuRuleset().RulesetInfo)), score);
     });
 }
Esempio n. 18
0
        public void TestAllHitResults()
        {
            var score = TestResources.CreateTestScoreInfo();

            score.Statistics[HitResult.Perfect] = 350;
            score.Statistics[HitResult.Ok]      = 200;

            addPanelStep(score);
        }
        public void TestScoreSerialisationViaExtensionMethod()
        {
            var score = new SubmittableScore(TestResources.CreateTestScoreInfo());

            string serialised = score.Serialize();

            Assert.That(serialised, Contains.Substring("large_tick_hit"));
            Assert.That(serialised, Contains.Substring("\"rank\": \"S\""));
        }
Esempio n. 20
0
        public void TestSSRank()
        {
            var score = TestResources.CreateTestScoreInfo();

            score.Accuracy = 1;
            score.Rank     = ScoreRank.X;

            addPanelStep(score);
        }
Esempio n. 21
0
        public void TestMapWithUnknownMapper()
        {
            AddStep("show example score", () => showPanel(TestResources.CreateTestScoreInfo(createTestBeatmap(new RealmUser()))));

            AddAssert("mapped by text not present", () =>
                      this.ChildrenOfType <OsuSpriteText>().All(spriteText => !containsAny(spriteText.Text.ToString(), "mapped", "by")));

            AddAssert("play time displayed", () => this.ChildrenOfType <ExpandedPanelMiddleContent.PlayedOnText>().Any());
        }
Esempio n. 22
0
        public void TestResultsWithPlayer(double accuracy, ScoreRank rank)
        {
            TestResultsScreen screen = null;

            var score = TestResources.CreateTestScoreInfo();

            score.Accuracy = accuracy;
            score.Rank     = rank;

            AddStep("load results", () => Child = new TestResultsContainer(screen = createResultsScreen(score)));
            AddUntilStep("wait for loaded", () => screen.IsLoaded);
            AddAssert("retry overlay present", () => screen.RetryOverlay != null);
        }
Esempio n. 23
0
        public void TestAddManyNonExpandedPanels()
        {
            createListStep(() => new ScorePanelList());

            AddStep("add many scores", () =>
            {
                for (int i = 0; i < 20; i++)
                {
                    list.AddScore(TestResources.CreateTestScoreInfo());
                }
            });

            assertFirstPanelCentred();
        }
Esempio n. 24
0
        public void TestAddPanelAfterSelectingScore()
        {
            var score = TestResources.CreateTestScoreInfo();

            createListStep(() => new ScorePanelList
            {
                SelectedScore = { Value = score }
            });

            AddStep("add panel", () => list.AddScore(score));

            assertScoreState(score, true);
            assertExpandedPanelCentred();
        }
Esempio n. 25
0
        public void TestRulesetWithNoPerformanceCalculator()
        {
            var ruleset = new RulesetWithNoPerformanceCalculator();
            var score   = TestResources.CreateTestScoreInfo(ruleset.RulesetInfo);

            AddStep("load results", () => Child = new TestResultsContainer(createResultsScreen(score)));
            AddUntilStep("wait for load", () => this.ChildrenOfType <ScorePanelList>().Single().AllPanelsVisible);

            AddAssert("PP displayed as 0", () =>
            {
                var performance = this.ChildrenOfType <PerformanceStatistic>().Single();
                var counter     = performance.ChildrenOfType <StatisticCounter>().Single();
                return(counter.Current.Value == 0);
            });
        }
Esempio n. 26
0
        public void TestDisplayResults()
        {
            MultiplayerResultsScreen screen = null;

            AddStep("show results screen", () =>
            {
                var rulesetInfo = new OsuRuleset().RulesetInfo;
                var beatmapInfo = CreateBeatmap(rulesetInfo).BeatmapInfo;
                var score       = TestResources.CreateTestScoreInfo(beatmapInfo);

                Stack.Push(screen = new MultiplayerResultsScreen(score, 1, new PlaylistItem(beatmapInfo)));
            });

            AddUntilStep("wait for loaded", () => screen.IsLoaded);
        }
Esempio n. 27
0
        public void TestExpandAndContract()
        {
            var score = TestResources.CreateTestScoreInfo();

            score.Accuracy = 0.925;
            score.Rank     = ScoreRank.A;

            addPanelStep(score, PanelState.Contracted);
            AddWaitStep("wait for transition", 10);

            AddStep("expand panel", () => panel.State = PanelState.Expanded);
            AddWaitStep("wait for transition", 10);

            AddStep("contract panel", () => panel.State = PanelState.Contracted);
            AddWaitStep("wait for transition", 10);
        }
Esempio n. 28
0
        public void TestAddPanelBeforeSelectingScore()
        {
            var score = TestResources.CreateTestScoreInfo();

            createListStep(() => new ScorePanelList());

            AddStep("add panel", () => list.AddScore(score));

            assertScoreState(score, false);
            assertFirstPanelCentred();

            AddStep("select score", () => list.SelectedScore.Value = score);

            assertScoreState(score, true);
            assertExpandedPanelCentred();
        }
Esempio n. 29
0
        public void TestAddScoreImmediately()
        {
            var score = TestResources.CreateTestScoreInfo();

            createListStep(() =>
            {
                var newList = new ScorePanelList {
                    SelectedScore = { Value = score }
                };
                newList.AddScore(score);
                return(newList);
            });

            assertScoreState(score, true);
            assertExpandedPanelCentred();
        }
Esempio n. 30
0
            protected override APIRequest FetchScores(Action <IEnumerable <ScoreInfo> > scoresCallback)
            {
                var scores = new List <ScoreInfo>();

                for (int i = 0; i < 20; i++)
                {
                    var score = TestResources.CreateTestScoreInfo();
                    score.TotalScore += 10 - i;
                    score.Hash        = $"test{i}";
                    scores.Add(score);
                }

                scoresCallback?.Invoke(scores);

                return(null);
            }