Merge branch 'master' into infrastructure

This commit is contained in:
Dean Herbert 2019-11-09 16:23:58 +09:00 committed by GitHub
commit 45e1501c02
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 86 additions and 6 deletions

View File

@ -53,6 +53,6 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.1010.0" />
<PackageReference Include="ppy.osu.Framework.Android" Version="2019.1106.0" />
<PackageReference Include="ppy.osu.Framework.Android" Version="2019.1108.0" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,76 @@
// 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.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;
[Test]
public void TestUserCommentPill()
{
AddStep("Log in", logIn);
AddStep("User comment", () => addVotePill(getUserComment()));
AddStep("Click", () => votePill.Click());
AddAssert("Not loading", () => !votePill.IsLoading);
}
[Test]
public void TestRandomCommentPill()
{
AddStep("Log in", logIn);
AddStep("Random comment", () => addVotePill(getRandomComment()));
AddStep("Click", () => votePill.Click());
AddAssert("Loading", () => votePill.IsLoading);
}
[Test]
public void TestOfflineRandomCommentPill()
{
AddStep("Log out", API.Logout);
AddStep("Random comment", () => addVotePill(getRandomComment()));
AddStep("Click", () => votePill.Click());
AddAssert("Not loading", () => !votePill.IsLoading);
}
private void logIn() => API.Login("localUser", "password");
private Comment getUserComment() => new Comment
{
IsVoted = false,
UserId = API.LocalUser.Value.Id,
VotesCount = 10,
};
private Comment getRandomComment() => new Comment
{
IsVoted = false,
UserId = 4444,
VotesCount = 2,
};
private void addVotePill(Comment comment)
{
Clear();
Add(votePill = new VotePill(comment)
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
});
}
}
}

View File

@ -48,8 +48,6 @@ public VotePill(Comment comment)
{
this.comment = comment;
Action = onAction;
AutoSizeAxes = Axes.X;
Height = 20;
LoadingAnimationSize = new Vector2(10);
@ -60,6 +58,9 @@ private void load(OsuColour colours)
{
AccentColour = borderContainer.BorderColour = sideNumber.Colour = colours.GreenLight;
hoverLayer.Colour = Color4.Black.Opacity(0.5f);
if (api.IsLoggedIn && api.LocalUser.Value.Id != comment.UserId)
Action = onAction;
}
protected override void LoadComplete()
@ -157,6 +158,9 @@ protected override void OnHoverLost(HoverLostEvent e)
private void updateDisplay()
{
if (Action == null)
return;
if (isVoted.Value)
{
hoverLayer.FadeTo(IsHovered ? 1 : 0);

View File

@ -21,7 +21,7 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.1010.0" />
<PackageReference Include="ppy.osu.Framework" Version="2019.1106.0" />
<PackageReference Include="ppy.osu.Framework" Version="2019.1108.0" />
<PackageReference Include="SharpCompress" Version="0.24.0" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="SharpRaven" Version="2.4.0" />

View File

@ -73,8 +73,8 @@
</ItemGroup>
<ItemGroup Label="Package References">
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.1010.0" />
<PackageReference Include="ppy.osu.Framework" Version="2019.1106.0" />
<PackageReference Include="ppy.osu.Framework.iOS" Version="2019.1106.0" />
<PackageReference Include="ppy.osu.Framework" Version="2019.1108.0" />
<PackageReference Include="ppy.osu.Framework.iOS" Version="2019.1108.0" />
<PackageReference Include="SharpCompress" Version="0.24.0" />
<PackageReference Include="NUnit" Version="3.11.0" />
<PackageReference Include="SharpRaven" Version="2.4.0" />