1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 09:27:29 +08:00

Removed unnecessary methods, changed tests, and moved LimitedCapacityQueue.cs to a more generic namespace.

This commit is contained in:
Terochi 2022-11-19 16:53:35 +01:00
parent a25c94d567
commit eff6c7be64
5 changed files with 6 additions and 38 deletions

View File

@ -6,10 +6,10 @@
using System;
using osu.Game.Rulesets.Difficulty.Preprocessing;
using osu.Game.Rulesets.Difficulty.Skills;
using osu.Game.Rulesets.Difficulty.Utils;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Taiko.Difficulty.Preprocessing;
using osu.Game.Rulesets.Taiko.Objects;
using osu.Game.Utils;
namespace osu.Game.Rulesets.Taiko.Difficulty.Skills
{

View File

@ -5,7 +5,7 @@
using System;
using NUnit.Framework;
using osu.Game.Rulesets.Difficulty.Utils;
using osu.Game.Utils;
namespace osu.Game.Tests.NonVisual
{

View File

@ -1,9 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
#nullable disable
using System.Linq;
using NUnit.Framework;
using osu.Framework.Graphics;
using osu.Framework.Input;
@ -21,8 +18,8 @@ namespace osu.Game.Tests.Visual.UserInterface
private int messageCounter;
private HistoryTextBox box;
private OsuSpriteText text;
private HistoryTextBox box = null!;
private OsuSpriteText text = null!;
[SetUp]
public void SetUp()
@ -70,7 +67,6 @@ namespace osu.Game.Tests.Visual.UserInterface
public void TestEmptyHistory()
{
AddStep("Set text", () => box.Text = temp);
AddAssert("History is empty", () => !box.GetMessageHistory().Any());
AddStep("Move down", () => InputManager.Key(Key.Down));
AddAssert("Text is the same", () => box.Text == temp);
@ -106,16 +102,12 @@ namespace osu.Game.Tests.Visual.UserInterface
{
addMessages(5);
AddStep("Set text", () => box.Text = temp);
AddAssert("History saved as <5-1>", () =>
Enumerable.Range(0, 5).Select(number => $"Message {5 - number}").SequenceEqual(box.GetMessageHistory()));
AddStep("Move down", () => InputManager.Key(Key.Down));
AddAssert("Text is the same", () => box.Text == temp);
addMessages(2);
AddStep("Set text", () => box.Text = temp);
AddAssert("Overrode history to <7-3>", () =>
Enumerable.Range(0, 5).Select(number => $"Message {7 - number}").SequenceEqual(box.GetMessageHistory()));
AddRepeatStep("Move Up", () => InputManager.Key(Key.Up), 5);
AddAssert("Same as 3rd message", () => box.Text == "Message 3");
@ -130,18 +122,6 @@ namespace osu.Game.Tests.Visual.UserInterface
AddAssert("Same as temp message", () => box.Text == temp);
}
[Test]
public void TestOverrideFullHistory()
{
addMessages(5);
AddAssert("History saved as <5-1>", () =>
Enumerable.Range(0, 5).Select(number => $"Message {5 - number}").SequenceEqual(box.GetMessageHistory()));
addMessages(6);
AddAssert("Overrode history to <11-7>", () =>
Enumerable.Range(0, 5).Select(number => $"Message {11 - number}").SequenceEqual(box.GetMessageHistory()));
}
[Test]
public void TestResetIndex()
{

View File

@ -1,9 +1,8 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System.Collections.Generic;
using osu.Framework.Input.Events;
using osu.Game.Rulesets.Difficulty.Utils;
using osu.Game.Utils;
using osuTK.Input;
namespace osu.Game.Graphics.UserInterface
@ -12,15 +11,6 @@ namespace osu.Game.Graphics.UserInterface
{
private readonly LimitedCapacityQueue<string> messageHistory;
public IEnumerable<string> GetMessageHistory()
{
if (HistoryCount == 0)
yield break;
for (int i = HistoryCount - 1; i >= 0; i--)
yield return messageHistory[i];
}
public int HistoryCount => messageHistory.Count;
private int selectedIndex;
@ -28,8 +18,6 @@ namespace osu.Game.Graphics.UserInterface
private string originalMessage = string.Empty;
private bool everythingSelected;
public string GetOldMessage(int index) => messageHistory[HistoryCount - index - 1];
public HistoryTextBox(int capacity = 100)
{
messageHistory = new LimitedCapacityQueue<string>(capacity);

View File

@ -7,7 +7,7 @@ using System;
using System.Collections;
using System.Collections.Generic;
namespace osu.Game.Rulesets.Difficulty.Utils
namespace osu.Game.Utils
{
/// <summary>
/// An indexed queue with limited capacity.