2021-07-12 15:15:26 +08:00
|
|
|
|
// 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.
|
|
|
|
|
|
2022-04-12 18:26:02 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using Moq;
|
2021-07-12 15:15:26 +08:00
|
|
|
|
using NUnit.Framework;
|
2022-04-12 18:26:02 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
2021-07-12 15:15:26 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
2021-11-04 17:02:44 +08:00
|
|
|
|
using osu.Game.Online.API.Requests.Responses;
|
2022-04-12 18:26:02 +08:00
|
|
|
|
using osu.Game.Online.Multiplayer;
|
|
|
|
|
using osu.Game.Online.Rooms;
|
2021-07-13 15:02:18 +08:00
|
|
|
|
using osu.Game.Screens.OnlinePlay.Lounge.Components;
|
2021-07-12 15:15:26 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.Multiplayer
|
|
|
|
|
{
|
2022-04-12 18:26:02 +08:00
|
|
|
|
public partial class TestSceneRankRangePill : OsuTestScene
|
2021-07-12 15:15:26 +08:00
|
|
|
|
{
|
2022-04-12 18:26:02 +08:00
|
|
|
|
private readonly Mock<MultiplayerClient> multiplayerClient = new Mock<MultiplayerClient>();
|
|
|
|
|
|
|
|
|
|
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) =>
|
2022-04-13 08:36:44 +08:00
|
|
|
|
// not used directly in component, but required due to it inheriting from OnlinePlayComposite.
|
2022-04-12 18:26:02 +08:00
|
|
|
|
new CachedModelDependencyContainer<Room>(base.CreateChildDependencies(parent));
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load()
|
2021-07-12 15:15:26 +08:00
|
|
|
|
{
|
2022-04-12 18:26:02 +08:00
|
|
|
|
Dependencies.CacheAs(multiplayerClient.Object);
|
|
|
|
|
|
2021-07-12 15:15:26 +08:00
|
|
|
|
Child = new RankRangePill
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre
|
|
|
|
|
};
|
2022-04-12 18:26:02 +08:00
|
|
|
|
}
|
2021-07-12 15:15:26 +08:00
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestSingleUser()
|
|
|
|
|
{
|
2022-04-12 18:26:02 +08:00
|
|
|
|
setupRoomWithUsers(new APIUser
|
2021-07-12 15:15:26 +08:00
|
|
|
|
{
|
2022-04-12 18:26:02 +08:00
|
|
|
|
Id = 2,
|
|
|
|
|
Statistics = { GlobalRank = 1234 }
|
2021-07-12 15:15:26 +08:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestMultipleUsers()
|
|
|
|
|
{
|
2022-04-12 18:26:02 +08:00
|
|
|
|
setupRoomWithUsers(
|
|
|
|
|
new APIUser
|
2021-07-12 15:15:26 +08:00
|
|
|
|
{
|
|
|
|
|
Id = 2,
|
|
|
|
|
Statistics = { GlobalRank = 1234 }
|
2022-04-12 18:26:02 +08:00
|
|
|
|
},
|
|
|
|
|
new APIUser
|
2021-07-12 15:15:26 +08:00
|
|
|
|
{
|
|
|
|
|
Id = 3,
|
|
|
|
|
Statistics = { GlobalRank = 3333 }
|
2022-04-12 18:26:02 +08:00
|
|
|
|
},
|
|
|
|
|
new APIUser
|
2021-07-12 15:15:26 +08:00
|
|
|
|
{
|
|
|
|
|
Id = 4,
|
|
|
|
|
Statistics = { GlobalRank = 4321 }
|
|
|
|
|
});
|
|
|
|
|
}
|
2021-08-05 20:40:09 +08:00
|
|
|
|
|
|
|
|
|
[TestCase(1, 10)]
|
|
|
|
|
[TestCase(10, 100)]
|
|
|
|
|
[TestCase(100, 1000)]
|
|
|
|
|
[TestCase(1000, 10000)]
|
|
|
|
|
[TestCase(10000, 100000)]
|
|
|
|
|
[TestCase(100000, 1000000)]
|
|
|
|
|
[TestCase(1000000, 10000000)]
|
|
|
|
|
public void TestRange(int min, int max)
|
|
|
|
|
{
|
2022-04-12 18:26:02 +08:00
|
|
|
|
setupRoomWithUsers(
|
|
|
|
|
new APIUser
|
2021-08-05 20:40:09 +08:00
|
|
|
|
{
|
|
|
|
|
Id = 2,
|
|
|
|
|
Statistics = { GlobalRank = min }
|
2022-04-12 18:26:02 +08:00
|
|
|
|
},
|
|
|
|
|
new APIUser
|
2021-08-05 20:40:09 +08:00
|
|
|
|
{
|
|
|
|
|
Id = 3,
|
|
|
|
|
Statistics = { GlobalRank = max }
|
|
|
|
|
});
|
2022-04-12 18:26:02 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void setupRoomWithUsers(params APIUser[] users)
|
|
|
|
|
{
|
|
|
|
|
AddStep("setup room", () =>
|
|
|
|
|
{
|
|
|
|
|
multiplayerClient.SetupGet(m => m.Room).Returns(new MultiplayerRoom(0)
|
|
|
|
|
{
|
|
|
|
|
Users = new List<MultiplayerRoomUser>(users.Select(apiUser => new MultiplayerRoomUser(apiUser.Id) { User = apiUser }))
|
|
|
|
|
});
|
2021-08-05 20:40:09 +08:00
|
|
|
|
|
2022-04-12 18:26:02 +08:00
|
|
|
|
multiplayerClient.Raise(m => m.RoomUpdated -= null);
|
2021-08-05 20:40:09 +08:00
|
|
|
|
});
|
|
|
|
|
}
|
2021-07-12 15:15:26 +08:00
|
|
|
|
}
|
|
|
|
|
}
|