mirror of
https://github.com/osukey/osukey.git
synced 2025-08-04 15:16:38 +09:00
Merge branch 'master' into localisable-filter-items
This commit is contained in:
@ -185,10 +185,7 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
|
||||
private class SnapProvider : IDistanceSnapProvider
|
||||
{
|
||||
public SnapResult FindSnappedPosition(Vector2 screenSpacePosition) =>
|
||||
new SnapResult(screenSpacePosition, null);
|
||||
|
||||
public SnapResult FindSnappedPositionAndTime(Vector2 screenSpacePosition) => new SnapResult(screenSpacePosition, 0);
|
||||
public SnapResult FindSnappedPositionAndTime(Vector2 screenSpacePosition, SnapType snapType = SnapType.Grids) => new SnapResult(screenSpacePosition, 0);
|
||||
|
||||
public Bindable<double> DistanceSpacingMultiplier { get; } = new BindableDouble(1);
|
||||
|
||||
|
@ -5,6 +5,8 @@ using System;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Threading;
|
||||
using JetBrains.Annotations;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
@ -31,7 +33,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
[TestFixture]
|
||||
public class TestSceneChatOverlayV2 : OsuManualInputManagerTestScene
|
||||
{
|
||||
private ChatOverlayV2 chatOverlay;
|
||||
private TestChatOverlayV2 chatOverlay;
|
||||
private ChannelManager channelManager;
|
||||
|
||||
private APIUser testUser;
|
||||
@ -61,7 +63,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
Children = new Drawable[]
|
||||
{
|
||||
channelManager,
|
||||
chatOverlay = new ChatOverlayV2 { RelativeSizeAxes = Axes.Both },
|
||||
chatOverlay = new TestChatOverlayV2 { RelativeSizeAxes = Axes.Both },
|
||||
},
|
||||
};
|
||||
});
|
||||
@ -365,19 +367,19 @@ namespace osu.Game.Tests.Visual.Online
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TextBoxRetainsFocus()
|
||||
public void TestTextBoxRetainsFocus()
|
||||
{
|
||||
AddStep("Show overlay", () => chatOverlay.Show());
|
||||
AddAssert("TextBox is focused", () => InputManager.FocusedDrawable == chatOverlayTextBox);
|
||||
AddStep("Join channel 1", () => channelManager.JoinChannel(testChannel1));
|
||||
AddStep("Select channel 1", () => clickDrawable(getChannelListItem(testChannel1)));
|
||||
AddAssert("TextBox is focused", () => InputManager.FocusedDrawable == chatOverlayTextBox);
|
||||
AddStep("Click drawable channel", () => clickDrawable(currentDrawableChannel));
|
||||
AddAssert("TextBox is focused", () => InputManager.FocusedDrawable == chatOverlayTextBox);
|
||||
AddStep("Click selector", () => clickDrawable(chatOverlay.ChildrenOfType<ChannelListSelector>().Single()));
|
||||
AddAssert("TextBox is focused", () => InputManager.FocusedDrawable == chatOverlayTextBox);
|
||||
AddStep("Click listing", () => clickDrawable(chatOverlay.ChildrenOfType<ChannelListing>().Single()));
|
||||
AddAssert("TextBox is focused", () => InputManager.FocusedDrawable == chatOverlayTextBox);
|
||||
AddStep("Click drawable channel", () => clickDrawable(currentDrawableChannel));
|
||||
AddAssert("TextBox is focused", () => InputManager.FocusedDrawable == chatOverlayTextBox);
|
||||
AddStep("Click channel list", () => clickDrawable(chatOverlay.ChildrenOfType<ChannelList>().Single()));
|
||||
AddAssert("TextBox is focused", () => InputManager.FocusedDrawable == chatOverlayTextBox);
|
||||
AddStep("Click top bar", () => clickDrawable(chatOverlay.ChildrenOfType<ChatOverlayTopBar>().Single()));
|
||||
@ -386,6 +388,34 @@ namespace osu.Game.Tests.Visual.Online
|
||||
AddAssert("TextBox is not focused", () => InputManager.FocusedDrawable == null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSlowLoadingChannel()
|
||||
{
|
||||
AddStep("Show overlay (slow-loading)", () =>
|
||||
{
|
||||
chatOverlay.Show();
|
||||
chatOverlay.SlowLoading = true;
|
||||
});
|
||||
AddStep("Join channel 1", () => channelManager.JoinChannel(testChannel1));
|
||||
AddAssert("Channel 1 loading", () => !channelIsVisible && chatOverlay.GetSlowLoadingChannel(testChannel1).LoadState == LoadState.Loading);
|
||||
|
||||
AddStep("Join channel 2", () => channelManager.JoinChannel(testChannel2));
|
||||
AddStep("Select channel 2", () => clickDrawable(getChannelListItem(testChannel2)));
|
||||
AddAssert("Channel 2 loading", () => !channelIsVisible && chatOverlay.GetSlowLoadingChannel(testChannel2).LoadState == LoadState.Loading);
|
||||
|
||||
AddStep("Finish channel 1 load", () => chatOverlay.GetSlowLoadingChannel(testChannel1).LoadEvent.Set());
|
||||
AddAssert("Channel 1 ready", () => chatOverlay.GetSlowLoadingChannel(testChannel1).LoadState == LoadState.Ready);
|
||||
AddAssert("Channel 1 not displayed", () => !channelIsVisible);
|
||||
|
||||
AddStep("Finish channel 2 load", () => chatOverlay.GetSlowLoadingChannel(testChannel2).LoadEvent.Set());
|
||||
AddAssert("Channel 2 loaded", () => chatOverlay.GetSlowLoadingChannel(testChannel2).IsLoaded);
|
||||
AddAssert("Channel 2 displayed", () => channelIsVisible && currentDrawableChannel.Channel == testChannel2);
|
||||
|
||||
AddStep("Select channel 1", () => clickDrawable(getChannelListItem(testChannel1)));
|
||||
AddAssert("Channel 1 loaded", () => chatOverlay.GetSlowLoadingChannel(testChannel1).IsLoaded);
|
||||
AddAssert("Channel 1 displayed", () => channelIsVisible && currentDrawableChannel.Channel == testChannel1);
|
||||
}
|
||||
|
||||
private bool listingIsVisible =>
|
||||
chatOverlay.ChildrenOfType<ChannelListing>().Single().State.Value == Visibility.Visible;
|
||||
|
||||
@ -432,5 +462,35 @@ namespace osu.Game.Tests.Visual.Online
|
||||
Topic = $"We talk about the number {id} here",
|
||||
Type = ChannelType.Public,
|
||||
};
|
||||
|
||||
private class TestChatOverlayV2 : ChatOverlayV2
|
||||
{
|
||||
public bool SlowLoading { get; set; }
|
||||
|
||||
public SlowLoadingDrawableChannel GetSlowLoadingChannel(Channel channel) => DrawableChannels.OfType<SlowLoadingDrawableChannel>().Single(c => c.Channel == channel);
|
||||
|
||||
protected override ChatOverlayDrawableChannel CreateDrawableChannel(Channel newChannel)
|
||||
{
|
||||
return SlowLoading
|
||||
? new SlowLoadingDrawableChannel(newChannel)
|
||||
: new ChatOverlayDrawableChannel(newChannel);
|
||||
}
|
||||
}
|
||||
|
||||
private class SlowLoadingDrawableChannel : ChatOverlayDrawableChannel
|
||||
{
|
||||
public readonly ManualResetEventSlim LoadEvent = new ManualResetEventSlim();
|
||||
|
||||
public SlowLoadingDrawableChannel([NotNull] Channel channel)
|
||||
: base(channel)
|
||||
{
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
LoadEvent.Wait(10000);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,48 @@
|
||||
// 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.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Moq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Overlays.FirstRunSetup;
|
||||
|
||||
namespace osu.Game.Tests.Visual.UserInterface
|
||||
{
|
||||
public class TestSceneFirstRunScreenImportFromStable : OsuManualInputManagerTestScene
|
||||
{
|
||||
[Cached]
|
||||
private OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Purple);
|
||||
|
||||
private readonly Mock<LegacyImportManager> legacyImportManager = new Mock<LegacyImportManager>();
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
legacyImportManager.Setup(m => m.GetImportCount(It.IsAny<StableContent>(), It.IsAny<CancellationToken>())).Returns(() => Task.FromResult(RNG.Next(0, 256)));
|
||||
|
||||
Dependencies.CacheAs(legacyImportManager.Object);
|
||||
}
|
||||
|
||||
public TestSceneFirstRunScreenImportFromStable()
|
||||
{
|
||||
AddStep("load screen", () =>
|
||||
{
|
||||
Child = new PopoverContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new ScreenStack(new ScreenImportFromStable())
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user