1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-23 16:07:24 +08:00
osu-lazer/osu.Game.Tests/Visual/Online/TestSceneOnlineViewContainer.cs

67 lines
2.3 KiB
C#
Raw Normal View History

2020-01-14 04:12:19 +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.Linq;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics.Sprites;
using osu.Game.Online;
using osu.Game.Online.API;
using osuTK.Graphics;
namespace osu.Game.Tests.Visual.Online
{
[TestFixture]
public class TestSceneOnlineViewContainer : OsuTestScene
{
2020-01-18 02:29:42 +08:00
private readonly OnlineViewContainer onlineView;
2020-01-14 04:12:19 +08:00
public TestSceneOnlineViewContainer()
{
Child = new Container
{
RelativeSizeAxes = Axes.Both,
2020-01-18 01:53:17 +08:00
Child = onlineView = new OnlineViewContainer(@"view dummy test content")
2020-01-14 04:12:19 +08:00
{
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{
2020-01-18 02:29:42 +08:00
new Box
2020-01-14 04:12:19 +08:00
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.Blue.Opacity(0.8f),
},
new OsuSpriteText
{
Text = "dummy online content",
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
}
}
}
};
}
[BackgroundDependencyLoader]
private void load()
{
2020-01-18 02:29:42 +08:00
AddStep("set status to offline", () => ((DummyAPIAccess)API).State = APIState.Offline);
2020-01-14 04:12:19 +08:00
2020-01-18 02:29:42 +08:00
AddAssert("children are hidden", () => !onlineView.Children.First().Parent.IsPresent);
2020-01-14 04:12:19 +08:00
2020-01-18 02:29:42 +08:00
AddStep("set status to online", () => ((DummyAPIAccess)API).State = APIState.Online);
2020-01-14 04:12:19 +08:00
2020-01-18 02:29:42 +08:00
AddAssert("children are visible", () => onlineView.Children.First().Parent.IsPresent);
AddStep("set status to connecting", () => ((DummyAPIAccess)API).State = APIState.Connecting);
AddAssert("children are hidden", () => !onlineView.Children.First().Parent.IsPresent);
2020-01-14 04:12:19 +08:00
}
}
}