mirror of
https://github.com/osukey/osukey.git
synced 2025-08-05 07:33:55 +09:00
Merge branch 'master' into fix-hud-test-failure-2
This commit is contained in:
@ -39,7 +39,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
{
|
||||
base.SetUpSteps();
|
||||
|
||||
AddStep("load chat display", () => Child = chatDisplay = new GameplayChatDisplay
|
||||
AddStep("load chat display", () => Child = chatDisplay = new GameplayChatDisplay(SelectedRoom.Value)
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
|
@ -28,6 +28,8 @@ using osu.Game.Screens.OnlinePlay.Lounge.Components;
|
||||
using osu.Game.Screens.OnlinePlay.Match;
|
||||
using osu.Game.Screens.OnlinePlay.Multiplayer;
|
||||
using osu.Game.Screens.OnlinePlay.Multiplayer.Match;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Screens.Ranking;
|
||||
using osu.Game.Tests.Resources;
|
||||
using osu.Game.Users;
|
||||
using osuTK.Input;
|
||||
@ -430,6 +432,40 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestGameplayFlow()
|
||||
{
|
||||
createRoom(() => new Room
|
||||
{
|
||||
Name = { Value = "Test Room" },
|
||||
Playlist =
|
||||
{
|
||||
new PlaylistItem
|
||||
{
|
||||
Beatmap = { Value = beatmaps.GetWorkingBeatmap(importedSet.Beatmaps.First(b => b.RulesetID == 0)).BeatmapInfo },
|
||||
Ruleset = { Value = new OsuRuleset().RulesetInfo },
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
AddRepeatStep("click spectate button", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(this.ChildrenOfType<MultiplayerReadyButton>().Single());
|
||||
InputManager.Click(MouseButton.Left);
|
||||
}, 2);
|
||||
|
||||
AddUntilStep("wait for player", () => Stack.CurrentScreen is Player);
|
||||
|
||||
// Gameplay runs in real-time, so we need to incrementally check if gameplay has finished in order to not time out.
|
||||
for (double i = 1000; i < TestResources.QUICK_BEATMAP_LENGTH; i += 1000)
|
||||
{
|
||||
var time = i;
|
||||
AddUntilStep($"wait for time > {i}", () => this.ChildrenOfType<GameplayClockContainer>().SingleOrDefault()?.GameplayClock.CurrentTime > time);
|
||||
}
|
||||
|
||||
AddUntilStep("wait for results", () => Stack.CurrentScreen is ResultsScreen);
|
||||
}
|
||||
|
||||
private void createRoom(Func<Room> room)
|
||||
{
|
||||
AddUntilStep("wait for lounge", () => multiplayerScreen.ChildrenOfType<LoungeSubScreen>().SingleOrDefault()?.IsLoaded == true);
|
||||
|
@ -25,7 +25,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
|
||||
AddStep("initialise gameplay", () =>
|
||||
{
|
||||
Stack.Push(player = new MultiplayerPlayer(Client.CurrentMatchPlayingItem.Value, Client.Room?.Users.ToArray()));
|
||||
Stack.Push(player = new MultiplayerPlayer(Client.APIRoom, Client.CurrentMatchPlayingItem.Value, Client.Room?.Users.ToArray()));
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -42,19 +42,21 @@ namespace osu.Game.Tests.Visual.Online
|
||||
() => commentsContainer.ChildrenOfType<CommentsShowMoreButton>().Single().IsLoading);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSingleCommentsPage()
|
||||
[TestCase(false)]
|
||||
[TestCase(true)]
|
||||
public void TestSingleCommentsPage(bool withPinned)
|
||||
{
|
||||
setUpCommentsResponse(exampleComments);
|
||||
setUpCommentsResponse(getExampleComments(withPinned));
|
||||
AddStep("show comments", () => commentsContainer.ShowComments(CommentableType.Beatmapset, 123));
|
||||
AddUntilStep("show more button hidden",
|
||||
() => commentsContainer.ChildrenOfType<CommentsShowMoreButton>().Single().Alpha == 0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMultipleCommentPages()
|
||||
[TestCase(false)]
|
||||
[TestCase(true)]
|
||||
public void TestMultipleCommentPages(bool withPinned)
|
||||
{
|
||||
var comments = exampleComments;
|
||||
var comments = getExampleComments(withPinned);
|
||||
comments.HasMore = true;
|
||||
comments.TopLevelCount = 10;
|
||||
|
||||
@ -64,11 +66,12 @@ namespace osu.Game.Tests.Visual.Online
|
||||
() => commentsContainer.ChildrenOfType<CommentsShowMoreButton>().Single().Alpha == 1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMultipleLoads()
|
||||
[TestCase(false)]
|
||||
[TestCase(true)]
|
||||
public void TestMultipleLoads(bool withPinned)
|
||||
{
|
||||
var comments = exampleComments;
|
||||
int topLevelCommentCount = exampleComments.Comments.Count;
|
||||
var comments = getExampleComments(withPinned);
|
||||
int topLevelCommentCount = comments.Comments.Count;
|
||||
|
||||
AddStep("hide container", () => commentsContainer.Hide());
|
||||
setUpCommentsResponse(comments);
|
||||
@ -79,6 +82,48 @@ namespace osu.Game.Tests.Visual.Online
|
||||
() => commentsContainer.ChildrenOfType<DrawableComment>().Count() == topLevelCommentCount);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestNoComment()
|
||||
{
|
||||
var comments = getExampleComments();
|
||||
comments.Comments.Clear();
|
||||
|
||||
setUpCommentsResponse(comments);
|
||||
AddStep("show comments", () => commentsContainer.ShowComments(CommentableType.Beatmapset, 123));
|
||||
AddAssert("no comment shown", () => !commentsContainer.ChildrenOfType<DrawableComment>().Any());
|
||||
}
|
||||
|
||||
[TestCase(false)]
|
||||
[TestCase(true)]
|
||||
public void TestSingleComment(bool withPinned)
|
||||
{
|
||||
var comment = new Comment
|
||||
{
|
||||
Id = 1,
|
||||
Message = "This is a single comment",
|
||||
LegacyName = "SingleUser",
|
||||
CreatedAt = DateTimeOffset.Now,
|
||||
VotesCount = 0,
|
||||
Pinned = withPinned,
|
||||
};
|
||||
|
||||
var bundle = new CommentBundle
|
||||
{
|
||||
Comments = new List<Comment> { comment },
|
||||
IncludedComments = new List<Comment>(),
|
||||
PinnedComments = new List<Comment>(),
|
||||
};
|
||||
|
||||
if (withPinned)
|
||||
bundle.PinnedComments.Add(comment);
|
||||
|
||||
setUpCommentsResponse(bundle);
|
||||
AddStep("show comments", () => commentsContainer.ShowComments(CommentableType.Beatmapset, 123));
|
||||
AddUntilStep("wait comment load", () => commentsContainer.ChildrenOfType<DrawableComment>().Any());
|
||||
AddAssert("only one comment shown", () =>
|
||||
commentsContainer.ChildrenOfType<DrawableComment>().Count(d => d.Comment.Pinned == withPinned) == 1);
|
||||
}
|
||||
|
||||
private void setUpCommentsResponse(CommentBundle commentBundle)
|
||||
=> AddStep("set up response", () =>
|
||||
{
|
||||
@ -92,38 +137,71 @@ namespace osu.Game.Tests.Visual.Online
|
||||
};
|
||||
});
|
||||
|
||||
private CommentBundle exampleComments => new CommentBundle
|
||||
private CommentBundle getExampleComments(bool withPinned = false)
|
||||
{
|
||||
Comments = new List<Comment>
|
||||
var bundle = new CommentBundle
|
||||
{
|
||||
new Comment
|
||||
Comments = new List<Comment>
|
||||
{
|
||||
Id = 1,
|
||||
Message = "This is a comment",
|
||||
LegacyName = "FirstUser",
|
||||
CreatedAt = DateTimeOffset.Now,
|
||||
VotesCount = 19,
|
||||
RepliesCount = 1
|
||||
new Comment
|
||||
{
|
||||
Id = 1,
|
||||
Message = "This is a comment",
|
||||
LegacyName = "FirstUser",
|
||||
CreatedAt = DateTimeOffset.Now,
|
||||
VotesCount = 19,
|
||||
RepliesCount = 1
|
||||
},
|
||||
new Comment
|
||||
{
|
||||
Id = 5,
|
||||
ParentId = 1,
|
||||
Message = "This is a child comment",
|
||||
LegacyName = "SecondUser",
|
||||
CreatedAt = DateTimeOffset.Now,
|
||||
VotesCount = 4,
|
||||
},
|
||||
new Comment
|
||||
{
|
||||
Id = 10,
|
||||
Message = "This is another comment",
|
||||
LegacyName = "ThirdUser",
|
||||
CreatedAt = DateTimeOffset.Now,
|
||||
VotesCount = 0
|
||||
},
|
||||
},
|
||||
new Comment
|
||||
IncludedComments = new List<Comment>(),
|
||||
PinnedComments = new List<Comment>(),
|
||||
};
|
||||
|
||||
if (withPinned)
|
||||
{
|
||||
var pinnedComment = new Comment
|
||||
{
|
||||
Id = 5,
|
||||
ParentId = 1,
|
||||
Message = "This is a child comment",
|
||||
LegacyName = "SecondUser",
|
||||
Id = 15,
|
||||
Message = "This is pinned comment",
|
||||
LegacyName = "PinnedUser",
|
||||
CreatedAt = DateTimeOffset.Now,
|
||||
VotesCount = 4,
|
||||
},
|
||||
new Comment
|
||||
VotesCount = 999,
|
||||
Pinned = true,
|
||||
RepliesCount = 1,
|
||||
};
|
||||
|
||||
bundle.Comments.Add(pinnedComment);
|
||||
bundle.PinnedComments.Add(pinnedComment);
|
||||
|
||||
bundle.Comments.Add(new Comment
|
||||
{
|
||||
Id = 10,
|
||||
Message = "This is another comment",
|
||||
LegacyName = "ThirdUser",
|
||||
Id = 20,
|
||||
Message = "Reply to pinned comment",
|
||||
LegacyName = "AbandonedUser",
|
||||
CreatedAt = DateTimeOffset.Now,
|
||||
VotesCount = 0
|
||||
},
|
||||
},
|
||||
IncludedComments = new List<Comment>(),
|
||||
};
|
||||
VotesCount = 0,
|
||||
ParentId = 15,
|
||||
});
|
||||
}
|
||||
|
||||
return bundle;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -43,6 +43,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
AddStep(description, () =>
|
||||
{
|
||||
comment.Pinned = description == "Pinned";
|
||||
comment.Message = text;
|
||||
container.Add(new DrawableComment(comment));
|
||||
});
|
||||
@ -59,6 +60,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
private static object[] comments =
|
||||
{
|
||||
new[] { "Plain", "This is plain comment" },
|
||||
new[] { "Pinned", "This is pinned comment" },
|
||||
new[] { "Link", "Please visit https://osu.ppy.sh" },
|
||||
|
||||
new[]
|
||||
|
@ -149,6 +149,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
}
|
||||
},
|
||||
IncludedComments = new List<Comment>(),
|
||||
PinnedComments = new List<Comment>(),
|
||||
UserVotes = new List<long>
|
||||
{
|
||||
5
|
||||
@ -178,6 +179,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
},
|
||||
},
|
||||
IncludedComments = new List<Comment>(),
|
||||
PinnedComments = new List<Comment>(),
|
||||
};
|
||||
|
||||
private class TestCommentsContainer : CommentsContainer
|
||||
|
Reference in New Issue
Block a user