mirror of
https://github.com/osukey/osukey.git
synced 2025-08-04 07:06:35 +09:00
Merge branch 'master' into privatise-toolbar-offset
This commit is contained in:
@ -0,0 +1,135 @@
|
||||
// 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.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Game.Audio;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osuTK.Input;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
public class TestSceneGameplaySampleTriggerSource : PlayerTestScene
|
||||
{
|
||||
private TestGameplaySampleTriggerSource sampleTriggerSource;
|
||||
protected override Ruleset CreatePlayerRuleset() => new OsuRuleset();
|
||||
|
||||
private Beatmap beatmap;
|
||||
|
||||
protected override IBeatmap CreateBeatmap(RulesetInfo ruleset)
|
||||
{
|
||||
beatmap = new Beatmap
|
||||
{
|
||||
BeatmapInfo = new BeatmapInfo
|
||||
{
|
||||
BaseDifficulty = new BeatmapDifficulty { CircleSize = 6, SliderMultiplier = 3 },
|
||||
Ruleset = ruleset
|
||||
}
|
||||
};
|
||||
|
||||
const double start_offset = 8000;
|
||||
const double spacing = 2000;
|
||||
|
||||
double t = start_offset;
|
||||
beatmap.HitObjects.AddRange(new[]
|
||||
{
|
||||
new HitCircle
|
||||
{
|
||||
// intentionally start objects a bit late so we can test the case of no alive objects.
|
||||
StartTime = t += spacing,
|
||||
Samples = new[] { new HitSampleInfo(HitSampleInfo.HIT_NORMAL) }
|
||||
},
|
||||
new HitCircle
|
||||
{
|
||||
StartTime = t += spacing,
|
||||
Samples = new[] { new HitSampleInfo(HitSampleInfo.HIT_WHISTLE) }
|
||||
},
|
||||
new HitCircle
|
||||
{
|
||||
StartTime = t += spacing,
|
||||
Samples = new[] { new HitSampleInfo(HitSampleInfo.HIT_NORMAL) },
|
||||
SampleControlPoint = new SampleControlPoint { SampleBank = "soft" },
|
||||
},
|
||||
new HitCircle
|
||||
{
|
||||
StartTime = t + spacing,
|
||||
Samples = new[] { new HitSampleInfo(HitSampleInfo.HIT_WHISTLE) },
|
||||
SampleControlPoint = new SampleControlPoint { SampleBank = "soft" },
|
||||
},
|
||||
});
|
||||
|
||||
return beatmap;
|
||||
}
|
||||
|
||||
public override void SetUpSteps()
|
||||
{
|
||||
base.SetUpSteps();
|
||||
|
||||
AddStep("Add trigger source", () => Player.HUDOverlay.Add(sampleTriggerSource = new TestGameplaySampleTriggerSource(Player.DrawableRuleset.Playfield.HitObjectContainer)));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCorrectHitObject()
|
||||
{
|
||||
HitObjectLifetimeEntry nextObjectEntry = null;
|
||||
|
||||
AddAssert("no alive objects", () => getNextAliveObject() == null);
|
||||
|
||||
AddAssert("check initially correct object", () => sampleTriggerSource.GetMostValidObject() == beatmap.HitObjects[0]);
|
||||
|
||||
AddUntilStep("get next object", () =>
|
||||
{
|
||||
var nextDrawableObject = getNextAliveObject();
|
||||
|
||||
if (nextDrawableObject != null)
|
||||
{
|
||||
nextObjectEntry = nextDrawableObject.Entry;
|
||||
InputManager.MoveMouseTo(nextDrawableObject.ScreenSpaceDrawQuad.Centre);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
AddUntilStep("hit first hitobject", () =>
|
||||
{
|
||||
InputManager.Click(MouseButton.Left);
|
||||
return nextObjectEntry.Result.HasResult;
|
||||
});
|
||||
|
||||
AddAssert("check correct object after hit", () => sampleTriggerSource.GetMostValidObject() == beatmap.HitObjects[1]);
|
||||
|
||||
AddUntilStep("check correct object after miss", () => sampleTriggerSource.GetMostValidObject() == beatmap.HitObjects[2]);
|
||||
AddUntilStep("check correct object after miss", () => sampleTriggerSource.GetMostValidObject() == beatmap.HitObjects[3]);
|
||||
|
||||
AddUntilStep("no alive objects", () => getNextAliveObject() == null);
|
||||
AddAssert("check correct object after none alive", () => sampleTriggerSource.GetMostValidObject() == beatmap.HitObjects[3]);
|
||||
}
|
||||
|
||||
private DrawableHitObject getNextAliveObject() =>
|
||||
Player.DrawableRuleset.Playfield.HitObjectContainer.AliveObjects.FirstOrDefault();
|
||||
|
||||
[Test]
|
||||
public void TestSampleTriggering()
|
||||
{
|
||||
AddRepeatStep("trigger sample", () => sampleTriggerSource.Play(), 10);
|
||||
}
|
||||
|
||||
public class TestGameplaySampleTriggerSource : GameplaySampleTriggerSource
|
||||
{
|
||||
public TestGameplaySampleTriggerSource(HitObjectContainer hitObjectContainer)
|
||||
: base(hitObjectContainer)
|
||||
{
|
||||
}
|
||||
|
||||
public new HitObject GetMostValidObject() => base.GetMostValidObject();
|
||||
}
|
||||
}
|
||||
}
|
@ -5,6 +5,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions.ObjectExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Testing;
|
||||
@ -19,6 +20,7 @@ using osu.Game.Screens.Play.HUD;
|
||||
using osu.Game.Screens.Play.PlayerSettings;
|
||||
using osu.Game.Tests.Beatmaps.IO;
|
||||
using osu.Game.Users;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Multiplayer
|
||||
{
|
||||
@ -78,7 +80,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
[Test]
|
||||
public void TestGeneral()
|
||||
{
|
||||
int[] userIds = Enumerable.Range(0, 4).Select(i => PLAYER_1_ID + i).ToArray();
|
||||
int[] userIds = getPlayerIds(4);
|
||||
|
||||
start(userIds);
|
||||
loadSpectateScreen();
|
||||
@ -314,6 +316,36 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
AddUntilStep("player 2 playing from correct point in time", () => getPlayer(PLAYER_2_ID).ChildrenOfType<DrawableRuleset>().Single().FrameStableClock.CurrentTime > 30000);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestPlayersLeaveWhileSpectating()
|
||||
{
|
||||
start(getPlayerIds(4));
|
||||
sendFrames(getPlayerIds(4), 300);
|
||||
|
||||
loadSpectateScreen();
|
||||
|
||||
for (int count = 3; count >= 0; count--)
|
||||
{
|
||||
var id = PLAYER_1_ID + count;
|
||||
|
||||
end(id);
|
||||
AddUntilStep($"{id} area grayed", () => getInstance(id).Colour != Color4.White);
|
||||
AddUntilStep($"{id} score quit set", () => getLeaderboardScore(id).HasQuit.Value);
|
||||
sendFrames(getPlayerIds(count), 300);
|
||||
}
|
||||
|
||||
Player player = null;
|
||||
|
||||
AddStep($"get {PLAYER_1_ID} player instance", () => player = getInstance(PLAYER_1_ID).ChildrenOfType<Player>().Single());
|
||||
|
||||
start(new[] { PLAYER_1_ID });
|
||||
sendFrames(PLAYER_1_ID, 300);
|
||||
|
||||
AddAssert($"{PLAYER_1_ID} player instance still same", () => getInstance(PLAYER_1_ID).ChildrenOfType<Player>().Single() == player);
|
||||
AddAssert($"{PLAYER_1_ID} area still grayed", () => getInstance(PLAYER_1_ID).Colour != Color4.White);
|
||||
AddAssert($"{PLAYER_1_ID} score quit still set", () => getLeaderboardScore(PLAYER_1_ID).HasQuit.Value);
|
||||
}
|
||||
|
||||
private void loadSpectateScreen(bool waitForPlayerLoad = true)
|
||||
{
|
||||
AddStep("load screen", () =>
|
||||
@ -333,14 +365,32 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
{
|
||||
foreach (int id in userIds)
|
||||
{
|
||||
OnlinePlayDependencies.Client.AddUser(new User { Id = id }, true);
|
||||
var user = new MultiplayerRoomUser(id)
|
||||
{
|
||||
User = new User { Id = id },
|
||||
};
|
||||
|
||||
OnlinePlayDependencies.Client.AddUser(user.User, true);
|
||||
SpectatorClient.StartPlay(id, beatmapId ?? importedBeatmapId);
|
||||
playingUsers.Add(new MultiplayerRoomUser(id));
|
||||
|
||||
playingUsers.Add(user);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void end(int userId)
|
||||
{
|
||||
AddStep($"end play for {userId}", () =>
|
||||
{
|
||||
var user = playingUsers.Single(u => u.UserID == userId);
|
||||
|
||||
OnlinePlayDependencies.Client.RemoveUser(user.User.AsNonNull());
|
||||
SpectatorClient.EndPlay(userId);
|
||||
|
||||
playingUsers.Remove(user);
|
||||
});
|
||||
}
|
||||
|
||||
private void sendFrames(int userId, int count = 10) => sendFrames(new[] { userId }, count);
|
||||
|
||||
private void sendFrames(int[] userIds, int count = 10)
|
||||
@ -374,5 +424,9 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
private Player getPlayer(int userId) => getInstance(userId).ChildrenOfType<Player>().Single();
|
||||
|
||||
private PlayerArea getInstance(int userId) => spectatorScreen.ChildrenOfType<PlayerArea>().Single(p => p.UserId == userId);
|
||||
|
||||
private GameplayLeaderboardScore getLeaderboardScore(int userId) => spectatorScreen.ChildrenOfType<GameplayLeaderboardScore>().Single(s => s.User?.Id == userId);
|
||||
|
||||
private int[] getPlayerIds(int count) => Enumerable.Range(PLAYER_1_ID, count).ToArray();
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Graphics.Cursor;
|
||||
@ -55,20 +56,24 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
{
|
||||
AddStep("create component", () =>
|
||||
{
|
||||
Child = new OsuContextMenuContainer
|
||||
Child = new PopoverContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Child = new Container
|
||||
Child = new OsuContextMenuContainer
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Width = 500,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Child = component = new LabelledColourPalette
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Child = new Container
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
ColourNamePrefix = "My colour #"
|
||||
Width = 500,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Child = component = new LabelledColourPalette
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
ColourNamePrefix = "My colour #"
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -0,0 +1,34 @@
|
||||
// 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 NUnit.Framework;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics.UserInterfaceV2;
|
||||
|
||||
namespace osu.Game.Tests.Visual.UserInterface
|
||||
{
|
||||
public class TestSceneLabelledDropdown : OsuTestScene
|
||||
{
|
||||
[Test]
|
||||
public void TestLabelledDropdown()
|
||||
=> AddStep(@"create dropdown", () => Child = new LabelledDropdown<string>
|
||||
{
|
||||
Label = @"Countdown speed",
|
||||
Items = new[]
|
||||
{
|
||||
@"Half",
|
||||
@"Normal",
|
||||
@"Double"
|
||||
},
|
||||
Description = @"This is a description"
|
||||
});
|
||||
|
||||
[Test]
|
||||
public void TestLabelledEnumDropdown()
|
||||
=> AddStep(@"create dropdown", () => Child = new LabelledEnumDropdown<BeatmapSetOnlineStatus>
|
||||
{
|
||||
Label = @"Beatmap status",
|
||||
Description = @"This is a description"
|
||||
});
|
||||
}
|
||||
}
|
25
osu.Game.Tests/Visual/UserInterface/TestSceneOsuLogo.cs
Normal file
25
osu.Game.Tests/Visual/UserInterface/TestSceneOsuLogo.cs
Normal file
@ -0,0 +1,25 @@
|
||||
// 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 NUnit.Framework;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Screens.Menu;
|
||||
|
||||
namespace osu.Game.Tests.Visual.UserInterface
|
||||
{
|
||||
public class TestSceneOsuLogo : OsuTestScene
|
||||
{
|
||||
[Test]
|
||||
public void TestBasic()
|
||||
{
|
||||
AddStep("Add logo", () =>
|
||||
{
|
||||
Child = new OsuLogo
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user