2019-10-30 08:45:05 +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.
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Game.Overlays.Comments;
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Game.Online.API.Requests.Responses;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.Online
|
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
|
|
|
|
public class TestSceneVotePill : OsuTestScene
|
|
|
|
|
{
|
|
|
|
|
public override IReadOnlyList<Type> RequiredTypes => new[]
|
|
|
|
|
{
|
|
|
|
|
typeof(VotePill)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
private VotePill votePill;
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load()
|
|
|
|
|
{
|
|
|
|
|
var userComment = new Comment
|
|
|
|
|
{
|
|
|
|
|
IsVoted = false,
|
2019-10-30 09:16:14 +08:00
|
|
|
|
UserId = API.LocalUser.Value.Id,
|
2019-10-30 08:45:05 +08:00
|
|
|
|
VotesCount = 10,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var randomComment = new Comment
|
|
|
|
|
{
|
|
|
|
|
IsVoted = false,
|
2019-10-30 09:16:14 +08:00
|
|
|
|
UserId = 4444,
|
2019-10-30 08:45:05 +08:00
|
|
|
|
VotesCount = 2,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
AddStep("User comment", () => addVotePill(userComment));
|
|
|
|
|
AddStep("Click", () => votePill.Click());
|
2019-10-30 09:31:09 +08:00
|
|
|
|
AddAssert("Not loading", () => !votePill.IsLoading);
|
2019-10-30 09:16:14 +08:00
|
|
|
|
|
|
|
|
|
AddStep("Random comment", () => addVotePill(randomComment));
|
|
|
|
|
AddStep("Click", () => votePill.Click());
|
2019-10-30 09:31:09 +08:00
|
|
|
|
AddAssert("Loading", () => votePill.IsLoading);
|
2019-10-30 09:16:14 +08:00
|
|
|
|
|
2019-10-30 08:47:17 +08:00
|
|
|
|
AddStep("Log out", API.Logout);
|
2019-10-30 09:16:14 +08:00
|
|
|
|
AddStep("Random comment", () => addVotePill(randomComment));
|
2019-10-30 08:47:17 +08:00
|
|
|
|
AddStep("Click", () => votePill.Click());
|
2019-10-30 09:31:09 +08:00
|
|
|
|
AddAssert("Not loading", () => !votePill.IsLoading);
|
2019-10-30 08:45:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void addVotePill(Comment comment)
|
|
|
|
|
{
|
|
|
|
|
Clear();
|
|
|
|
|
Add(votePill = new VotePill(comment)
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|