mirror of
https://github.com/osukey/osukey.git
synced 2025-08-04 15:16:38 +09:00
Merge branch 'master' into websocket-chat-2
This commit is contained in:
@ -198,13 +198,13 @@ namespace osu.Game.Tests.Visual.Online
|
||||
beatmapSet = CreateAPIBeatmapSet(Ruleset.Value);
|
||||
beatmapSet.Title = "last beatmap of first page";
|
||||
|
||||
fetchFor(getManyBeatmaps(49).Append(beatmapSet).ToArray(), true);
|
||||
fetchFor(getManyBeatmaps(49).Append(new APIBeatmapSet { Title = "last beatmap of first page", OnlineID = beatmapSet.OnlineID }).ToArray(), true);
|
||||
});
|
||||
AddUntilStep("wait for loaded", () => this.ChildrenOfType<BeatmapCard>().Count() == 50);
|
||||
|
||||
AddStep("set next page", () => setSearchResponse(getManyBeatmaps(49).Prepend(beatmapSet).ToArray(), false));
|
||||
AddStep("set next page", () => setSearchResponse(getManyBeatmaps(49).Prepend(new APIBeatmapSet { Title = "this shouldn't show up", OnlineID = beatmapSet.OnlineID }).ToArray(), false));
|
||||
AddStep("scroll to end", () => overlay.ChildrenOfType<OverlayScrollContainer>().Single().ScrollToEnd());
|
||||
AddUntilStep("wait for loaded", () => this.ChildrenOfType<BeatmapCard>().Count() == 99);
|
||||
AddUntilStep("wait for loaded", () => this.ChildrenOfType<BeatmapCard>().Count() >= 99);
|
||||
|
||||
AddAssert("beatmap not duplicated", () => overlay.ChildrenOfType<BeatmapCard>().Count(c => c.BeatmapSet.Equals(beatmapSet)) == 1);
|
||||
}
|
||||
|
@ -10,10 +10,12 @@ using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Graphics.UserInterfaceV2;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Online.API.Requests;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
@ -37,14 +39,20 @@ namespace osu.Game.Tests.Visual.Online
|
||||
|
||||
private CommentsContainer commentsContainer = null!;
|
||||
|
||||
private readonly ManualResetEventSlim requestLock = new ManualResetEventSlim();
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
base.Content.AddRange(new Drawable[]
|
||||
{
|
||||
content = new OsuScrollContainer
|
||||
new PopoverContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Child = content = new OsuScrollContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both
|
||||
}
|
||||
},
|
||||
dialogOverlay
|
||||
});
|
||||
@ -80,8 +88,6 @@ namespace osu.Game.Tests.Visual.Online
|
||||
});
|
||||
}
|
||||
|
||||
private readonly ManualResetEventSlim deletionPerformed = new ManualResetEventSlim();
|
||||
|
||||
[Test]
|
||||
public void TestDeletion()
|
||||
{
|
||||
@ -105,7 +111,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
});
|
||||
AddStep("Setup request handling", () =>
|
||||
{
|
||||
deletionPerformed.Reset();
|
||||
requestLock.Reset();
|
||||
|
||||
dummyAPI.HandleRequest = request =>
|
||||
{
|
||||
@ -138,7 +144,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
|
||||
Task.Run(() =>
|
||||
{
|
||||
deletionPerformed.Wait(10000);
|
||||
requestLock.Wait(10000);
|
||||
req.TriggerSuccess(cb);
|
||||
});
|
||||
|
||||
@ -149,7 +155,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
|
||||
AddAssert("Loading spinner shown", () => commentsContainer.ChildrenOfType<LoadingSpinner>().Any(d => d.IsPresent));
|
||||
|
||||
AddStep("Complete request", () => deletionPerformed.Set());
|
||||
AddStep("Complete request", () => requestLock.Set());
|
||||
|
||||
AddUntilStep("Comment is deleted locally", () => this.ChildrenOfType<DrawableComment>().Single(x => x.Comment.Id == 1).WasDeleted);
|
||||
}
|
||||
@ -204,6 +210,74 @@ namespace osu.Game.Tests.Visual.Online
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestReport()
|
||||
{
|
||||
const string report_text = "I don't like this comment";
|
||||
DrawableComment? targetComment = null;
|
||||
CommentReportRequest? request = null;
|
||||
|
||||
addTestComments();
|
||||
AddUntilStep("Comment exists", () =>
|
||||
{
|
||||
var comments = this.ChildrenOfType<DrawableComment>();
|
||||
targetComment = comments.SingleOrDefault(x => x.Comment.Id == 2);
|
||||
return targetComment != null;
|
||||
});
|
||||
AddStep("Setup request handling", () =>
|
||||
{
|
||||
requestLock.Reset();
|
||||
|
||||
dummyAPI.HandleRequest = r =>
|
||||
{
|
||||
if (!(r is CommentReportRequest req))
|
||||
return false;
|
||||
|
||||
Task.Run(() =>
|
||||
{
|
||||
request = req;
|
||||
requestLock.Wait(10000);
|
||||
req.TriggerSuccess();
|
||||
});
|
||||
|
||||
return true;
|
||||
};
|
||||
});
|
||||
AddStep("Click the button", () =>
|
||||
{
|
||||
var btn = targetComment.ChildrenOfType<OsuSpriteText>().Single(x => x.Text == "Report");
|
||||
InputManager.MoveMouseTo(btn);
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
AddStep("Try to report", () =>
|
||||
{
|
||||
var btn = this.ChildrenOfType<ReportCommentPopover>().Single().ChildrenOfType<RoundedButton>().Single();
|
||||
InputManager.MoveMouseTo(btn);
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
AddWaitStep("Wait", 3);
|
||||
AddAssert("Nothing happened", () => this.ChildrenOfType<ReportCommentPopover>().Any());
|
||||
AddStep("Set report data", () =>
|
||||
{
|
||||
var field = this.ChildrenOfType<OsuTextBox>().Single();
|
||||
field.Current.Value = report_text;
|
||||
var reason = this.ChildrenOfType<OsuEnumDropdown<CommentReportReason>>().Single();
|
||||
reason.Current.Value = CommentReportReason.Other;
|
||||
});
|
||||
AddStep("Try to report", () =>
|
||||
{
|
||||
var btn = this.ChildrenOfType<ReportCommentPopover>().Single().ChildrenOfType<RoundedButton>().Single();
|
||||
InputManager.MoveMouseTo(btn);
|
||||
InputManager.Click(MouseButton.Left);
|
||||
});
|
||||
AddWaitStep("Wait", 3);
|
||||
AddAssert("Overlay closed", () => !this.ChildrenOfType<ReportCommentPopover>().Any());
|
||||
AddAssert("Loading spinner shown", () => targetComment.ChildrenOfType<LoadingSpinner>().Any(d => d.IsPresent));
|
||||
AddStep("Complete request", () => requestLock.Set());
|
||||
AddUntilStep("Request sent", () => request != null);
|
||||
AddAssert("Request is correct", () => request != null && request.CommentID == 2 && request.Comment == report_text && request.Reason == CommentReportReason.Other);
|
||||
}
|
||||
|
||||
private void addTestComments()
|
||||
{
|
||||
AddStep("set up response", () =>
|
||||
|
46
osu.Game.Tests/Visual/Online/TestSceneCommentReportButton.cs
Normal file
46
osu.Game.Tests/Visual/Online/TestSceneCommentReportButton.cs
Normal file
@ -0,0 +1,46 @@
|
||||
// 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 osu.Framework.Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Online.API.Requests;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Overlays.Comments;
|
||||
using osu.Game.Tests.Visual.UserInterface;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
public class TestSceneCommentReportButton : ThemeComparisonTestScene
|
||||
{
|
||||
[SetUpSteps]
|
||||
public void SetUpSteps()
|
||||
{
|
||||
AddStep("setup API", () => ((DummyAPIAccess)API).HandleRequest += req =>
|
||||
{
|
||||
switch (req)
|
||||
{
|
||||
case CommentReportRequest report:
|
||||
Scheduler.AddDelayed(report.TriggerSuccess, 1000);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
protected override Drawable CreateContent() => new PopoverContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Child = new CommentReportButton(new Comment { User = new APIUser { Username = "Someone" } })
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Scale = new Vector2(2f),
|
||||
}.With(b => Schedule(b.ShowPopover)),
|
||||
};
|
||||
}
|
||||
}
|
@ -52,8 +52,15 @@ namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
AwardedAt = DateTimeOffset.FromUnixTimeSeconds(1505741569),
|
||||
Description = "Outstanding help by being a voluntary test subject.",
|
||||
ImageUrl = "https://assets.ppy.sh/profile-badges/contributor.jpg"
|
||||
}
|
||||
ImageUrl = "https://assets.ppy.sh/profile-badges/contributor.jpg",
|
||||
Url = "https://osu.ppy.sh/wiki/en/People/Community_Contributors",
|
||||
},
|
||||
new Badge
|
||||
{
|
||||
AwardedAt = DateTimeOffset.FromUnixTimeSeconds(1505741569),
|
||||
Description = "Badge without a url.",
|
||||
ImageUrl = "https://assets.ppy.sh/profile-badges/contributor.jpg",
|
||||
},
|
||||
},
|
||||
Title = "osu!volunteer",
|
||||
Colour = "ff0000",
|
||||
|
Reference in New Issue
Block a user