Skip to content

Commit

Permalink
Merge branch 'master' into dont-round-sv
Browse files Browse the repository at this point in the history
  • Loading branch information
peppy committed Jan 26, 2024
2 parents c9945b4 + 2778e43 commit cf97cb1
Show file tree
Hide file tree
Showing 138 changed files with 1,284 additions and 1,055 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public static class VisualTestRunner
[STAThread]
public static int Main(string[] args)
{
using (DesktopGameHost host = Host.GetSuitableDesktopHost(@"osu", new HostOptions { BindIPC = true }))
using (DesktopGameHost host = Host.GetSuitableDesktopHost(@"osu"))
{
host.Run(new OsuTestBrowser());
return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</PropertyGroup>
<ItemGroup Label="Package References">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit" Version="3.14.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
</ItemGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public static class VisualTestRunner
[STAThread]
public static int Main(string[] args)
{
using (DesktopGameHost host = Host.GetSuitableDesktopHost(@"osu", new HostOptions { BindIPC = true }))
using (DesktopGameHost host = Host.GetSuitableDesktopHost(@"osu"))
{
host.Run(new OsuTestBrowser());
return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</PropertyGroup>
<ItemGroup Label="Package References">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit" Version="3.14.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
</ItemGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public static class VisualTestRunner
[STAThread]
public static int Main(string[] args)
{
using (DesktopGameHost host = Host.GetSuitableDesktopHost(@"osu", new HostOptions { BindIPC = true }))
using (DesktopGameHost host = Host.GetSuitableDesktopHost(@"osu"))
{
host.Run(new OsuTestBrowser());
return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</PropertyGroup>
<ItemGroup Label="Package References">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit" Version="3.14.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
</ItemGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public static class VisualTestRunner
[STAThread]
public static int Main(string[] args)
{
using (DesktopGameHost host = Host.GetSuitableDesktopHost(@"osu", new HostOptions { BindIPC = true }))
using (DesktopGameHost host = Host.GetSuitableDesktopHost(@"osu"))
{
host.Run(new OsuTestBrowser());
return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</PropertyGroup>
<ItemGroup Label="Package References">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit" Version="3.14.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
</ItemGroup>
<ItemGroup>
Expand Down
13 changes: 6 additions & 7 deletions osu.Desktop.slnf
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,14 @@
"osu.Game.Tournament.Tests\\osu.Game.Tournament.Tests.csproj",
"osu.Game.Tournament\\osu.Game.Tournament.csproj",
"osu.Game\\osu.Game.csproj",

"Templates\\Rulesets\\ruleset-empty\\osu.Game.Rulesets.EmptyFreeform\\osu.Game.Rulesets.EmptyFreeform.csproj",
"Templates\\Rulesets\\ruleset-empty\\osu.Game.Rulesets.EmptyFreeform.Tests\\osu.Game.Rulesets.EmptyFreeform.Tests.csproj",
"Templates\\Rulesets\\ruleset-example\\osu.Game.Rulesets.Pippidon\\osu.Game.Rulesets.Pippidon.csproj",
"Templates\\Rulesets\\ruleset-empty\\osu.Game.Rulesets.EmptyFreeform\\osu.Game.Rulesets.EmptyFreeform.csproj",
"Templates\\Rulesets\\ruleset-example\\osu.Game.Rulesets.Pippidon.Tests\\osu.Game.Rulesets.Pippidon.Tests.csproj",
"Templates\\Rulesets\\ruleset-scrolling-empty\\osu.Game.Rulesets.EmptyScrolling\\osu.Game.Rulesets.EmptyScrolling.csproj",
"Templates\\Rulesets\\ruleset-example\\osu.Game.Rulesets.Pippidon\\osu.Game.Rulesets.Pippidon.csproj",
"Templates\\Rulesets\\ruleset-scrolling-empty\\osu.Game.Rulesets.EmptyScrolling.Tests\\osu.Game.Rulesets.EmptyScrolling.Tests.csproj",
"Templates\\Rulesets\\ruleset-scrolling-example\\osu.Game.Rulesets.Pippidon\\osu.Game.Rulesets.Pippidon.csproj",
"Templates\\Rulesets\\ruleset-scrolling-example\\osu.Game.Rulesets.Pippidon.Tests\\osu.Game.Rulesets.Pippidon.Tests.csproj"
"Templates\\Rulesets\\ruleset-scrolling-empty\\osu.Game.Rulesets.EmptyScrolling\\osu.Game.Rulesets.EmptyScrolling.csproj",
"Templates\\Rulesets\\ruleset-scrolling-example\\osu.Game.Rulesets.Pippidon.Tests\\osu.Game.Rulesets.Pippidon.Tests.csproj",
"Templates\\Rulesets\\ruleset-scrolling-example\\osu.Game.Rulesets.Pippidon\\osu.Game.Rulesets.Pippidon.csproj"
]
}
}
}
2 changes: 1 addition & 1 deletion osu.Desktop/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public static void Main(string[] args)
}
}

using (DesktopGameHost host = Host.GetSuitableDesktopHost(gameName, new HostOptions { BindIPC = !tournamentClient }))
using (DesktopGameHost host = Host.GetSuitableDesktopHost(gameName, new HostOptions { IPCPort = !tournamentClient ? OsuGame.IPC_PORT : null }))
{
if (!host.IsPrimaryInstance)
{
Expand Down
4 changes: 2 additions & 2 deletions osu.Desktop/osu.Desktop.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
<ProjectReference Include="..\osu.Game.Rulesets.Taiko\osu.Game.Rulesets.Taiko.csproj" />
</ItemGroup>
<ItemGroup Label="Package References">
<PackageReference Include="Clowd.Squirrel" Version="2.10.2" />
<PackageReference Include="Clowd.Squirrel" Version="2.11.1" />
<PackageReference Include="Mono.Posix.NETStandard" Version="1.0.0" />
<PackageReference Include="System.IO.Packaging" Version="7.0.0" />
<PackageReference Include="System.IO.Packaging" Version="8.0.0" />
<PackageReference Include="DiscordRichPresence" Version="1.2.1.24" />
</ItemGroup>
<ItemGroup Label="Resources">
Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Benchmarks/osu.Game.Benchmarks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.9" />
<PackageReference Include="nunit" Version="3.13.3" />
<PackageReference Include="nunit" Version="3.14.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Import Project="..\osu.TestProject.props" />
<ItemGroup Label="Package References">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit" Version="3.14.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
</ItemGroup>
<PropertyGroup Label="Project">
Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Catch/Scoring/CatchScoreProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ protected override double GetComboScoreChange(JudgementResult result)
return baseIncrease * Math.Min(Math.Max(0.5, Math.Log(result.ComboAfterJudgement, combo_base)), Math.Log(combo_cap, combo_base));
}

public override ScoreRank RankFromAccuracy(double accuracy)
public override ScoreRank RankFromScore(double accuracy, IReadOnlyDictionary<HitResult, int> results)
{
if (accuracy == accuracy_cutoff_x)
return ScoreRank.X;
Expand Down
38 changes: 17 additions & 21 deletions osu.Game.Rulesets.Mania.Tests/Skinning/TestSceneBarLine.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

using System;
using System.Collections.Generic;
using NUnit.Framework;
using osu.Framework.Graphics;
using osu.Game.Rulesets.Mania.Beatmaps;
using osu.Game.Rulesets.Mania.Objects;
using osu.Game.Rulesets.Mania.UI;
Expand All @@ -16,37 +14,35 @@ public partial class TestSceneBarLine : ManiaSkinnableTestScene
[Test]
public void TestMinor()
{
AddStep("Create barlines", () => recreate());
AddStep("Create barlines", recreate);
}

private void recreate(Func<IEnumerable<BarLine>>? createBarLines = null)
private void recreate()
{
var stageDefinitions = new List<StageDefinition>
{
new StageDefinition(4),
};

SetContents(_ => new ManiaPlayfield(stageDefinitions).With(s =>
SetContents(_ =>
{
if (createBarLines != null)
{
var barLines = createBarLines();

foreach (var b in barLines)
s.Add(b);
var maniaPlayfield = new ManiaPlayfield(stageDefinitions);

return;
}

for (int i = 0; i < 64; i++)
// Must be scheduled so the pool is loaded before we try and retrieve from it.
Schedule(() =>
{
s.Add(new BarLine
for (int i = 0; i < 64; i++)
{
StartTime = Time.Current + i * 500,
Major = i % 4 == 0,
});
}
}));
maniaPlayfield.Add(new BarLine
{
StartTime = Time.Current + i * 500,
Major = i % 4 == 0,
});
}
});

return maniaPlayfield;
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Import Project="..\osu.TestProject.props" />
<ItemGroup Label="Package References">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit" Version="3.14.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
</ItemGroup>
<PropertyGroup Label="Project">
Expand Down
47 changes: 24 additions & 23 deletions osu.Game.Rulesets.Osu.Tests/TestSceneDrawableJudgement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ public partial class TestSceneDrawableJudgement : OsuSkinnableTestScene
[Resolved]
private OsuConfigManager config { get; set; } = null!;

private readonly List<DrawablePool<TestDrawableOsuJudgement>> pools;
private readonly List<DrawablePool<TestDrawableOsuJudgement>> pools = new List<DrawablePool<TestDrawableOsuJudgement>>();

public TestSceneDrawableJudgement()
[TestCaseSource(nameof(validResults))]
public void Test(HitResult result)
{
pools = new List<DrawablePool<TestDrawableOsuJudgement>>();

foreach (HitResult result in Enum.GetValues(typeof(HitResult)).OfType<HitResult>().Skip(1))
showResult(result);
showResult(result);
}

private static IEnumerable<HitResult> validResults => Enum.GetValues<HitResult>().Skip(1);

[Test]
public void TestHitLightingDisabled()
{
Expand Down Expand Up @@ -72,32 +72,33 @@ private void showResult(HitResult result)
pools.Add(pool = new DrawablePool<TestDrawableOsuJudgement>(1));
else
{
pool = pools[poolIndex];

// We need to make sure neither the pool nor the judgement get disposed when new content is set, and they both share the same parent.
pool = pools[poolIndex];
((Container)pool.Parent!).Clear(false);
}

var container = new Container
{
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{
pool,
pool.Get(j => j.Apply(new JudgementResult(new HitObject
{
StartTime = Time.Current
}, new Judgement())
{
Type = result,
}, null)).With(j =>
{
j.Anchor = Anchor.Centre;
j.Origin = Anchor.Centre;
})
}
Child = pool,
};

// Must be scheduled so the pool is loaded before we try and retrieve from it.
Schedule(() =>
{
container.Add(pool.Get(j => j.Apply(new JudgementResult(new HitObject
{
StartTime = Time.Current
}, new Judgement())
{
Type = result,
}, null)).With(j =>
{
j.Anchor = Anchor.Centre;
j.Origin = Anchor.Centre;
}));
});

poolIndex++;
return container;
});
Expand Down
39 changes: 35 additions & 4 deletions osu.Game.Rulesets.Osu.Tests/TestSceneSliderApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void TestApplyNewSlider()
{
DrawableSlider dho = null;

AddStep("create slider", () => Child = dho = new DrawableSlider(prepareObject(new Slider
AddStep("create slider", () => Child = dho = new DrawableSlider(applyDefaults(new Slider
{
Position = new Vector2(256, 192),
IndexInCurrentCombo = 0,
Expand All @@ -47,7 +47,7 @@ public void TestApplyNewSlider()

AddWaitStep("wait for progression", 1);

AddStep("apply new slider", () => dho.Apply(prepareObject(new Slider
AddStep("apply new slider", () => dho.Apply(applyDefaults(new Slider
{
Position = new Vector2(256, 192),
ComboIndex = 1,
Expand Down Expand Up @@ -75,7 +75,7 @@ public void TestBallTintChangedOnAccentChange()
Child = new SkinProvidingContainer(provider)
{
RelativeSizeAxes = Axes.Both,
Child = dho = new DrawableSlider(prepareObject(new Slider
Child = dho = new DrawableSlider(applyDefaults(new Slider
{
Position = new Vector2(256, 192),
IndexInCurrentCombo = 0,
Expand All @@ -97,7 +97,38 @@ public void TestBallTintChangedOnAccentChange()
AddAssert("ball is red", () => dho.ChildrenOfType<LegacySliderBall>().Single().BallColour == Color4.Red);
}

private Slider prepareObject(Slider slider)
[Test]
public void TestIncreaseRepeatCount()
{
DrawableSlider dho = null;

AddStep("create slider", () =>
{
Child = dho = new DrawableSlider(applyDefaults(new Slider
{
Position = new Vector2(256, 192),
IndexInCurrentCombo = 0,
StartTime = Time.Current,
Path = new SliderPath(PathType.LINEAR, new[]
{
Vector2.Zero,
new Vector2(150, 100),
new Vector2(300, 0),
})
}));
});

AddStep("increase repeat count", () =>
{
dho.HitObject.RepeatCount++;
applyDefaults(dho.HitObject);
});

AddAssert("repeat got custom anchor", () =>
dho.ChildrenOfType<DrawableSliderRepeat>().Single().RelativeAnchorPosition == Vector2.Divide(dho.SliderBody!.PathOffset, dho.DrawSize));
}

private Slider applyDefaults(Slider slider)
{
slider.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
return slider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<ItemGroup Label="Package References">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="Moq" Version="4.18.4" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit" Version="3.14.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
</ItemGroup>
<PropertyGroup Label="Project">
Expand Down
Loading

0 comments on commit cf97cb1

Please sign in to comment.