mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 06:57:39 +08:00
commit
3f2512295c
@ -54,6 +54,6 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.1230.0" />
|
||||
<PackageReference Include="ppy.osu.Framework.Android" Version="2020.111.0" />
|
||||
<PackageReference Include="ppy.osu.Framework.Android" Version="2020.118.0" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
@ -5,6 +5,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
@ -25,7 +26,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
typeof(ChannelTabControl),
|
||||
};
|
||||
|
||||
private readonly ChannelTabControl channelTabControl;
|
||||
private readonly TestTabControl channelTabControl;
|
||||
|
||||
public TestSceneChannelTabControl()
|
||||
{
|
||||
@ -37,7 +38,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
Anchor = Anchor.Centre,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
channelTabControl = new ChannelTabControl
|
||||
channelTabControl = new TestTabControl
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Origin = Anchor.Centre,
|
||||
@ -73,32 +74,40 @@ namespace osu.Game.Tests.Visual.Online
|
||||
channelTabControl.Current.ValueChanged += channel => currentText.Text = "Currently selected channel: " + channel.NewValue;
|
||||
|
||||
AddStep("Add random private channel", addRandomPrivateChannel);
|
||||
AddAssert("There is only one channels", () => channelTabControl.Items.Count() == 2);
|
||||
AddAssert("There is only one channels", () => channelTabControl.Items.Count == 2);
|
||||
AddRepeatStep("Add 3 random private channels", addRandomPrivateChannel, 3);
|
||||
AddAssert("There are four channels", () => channelTabControl.Items.Count() == 5);
|
||||
AddAssert("There are four channels", () => channelTabControl.Items.Count == 5);
|
||||
AddStep("Add random public channel", () => addChannel(RNG.Next().ToString()));
|
||||
|
||||
AddRepeatStep("Select a random channel", () => channelTabControl.Current.Value = channelTabControl.Items.ElementAt(RNG.Next(channelTabControl.Items.Count() - 1)), 20);
|
||||
AddRepeatStep("Select a random channel", () =>
|
||||
{
|
||||
List<Channel> validChannels = channelTabControl.Items.Where(c => !(c is ChannelSelectorTabItem.ChannelSelectorTabChannel)).ToList();
|
||||
channelTabControl.SelectChannel(validChannels[RNG.Next(0, validChannels.Count)]);
|
||||
}, 20);
|
||||
|
||||
Channel channelBefore = channelTabControl.Items.First();
|
||||
AddStep("set first channel", () => channelTabControl.Current.Value = channelBefore);
|
||||
Channel channelBefore = null;
|
||||
AddStep("set first channel", () => channelTabControl.SelectChannel(channelBefore = channelTabControl.Items.First(c => !(c is ChannelSelectorTabItem.ChannelSelectorTabChannel))));
|
||||
|
||||
AddStep("select selector tab", () => channelTabControl.Current.Value = channelTabControl.Items.Last());
|
||||
AddStep("select selector tab", () => channelTabControl.SelectChannel(channelTabControl.Items.Single(c => c is ChannelSelectorTabItem.ChannelSelectorTabChannel)));
|
||||
AddAssert("selector tab is active", () => channelTabControl.ChannelSelectorActive.Value);
|
||||
|
||||
AddAssert("check channel unchanged", () => channelBefore == channelTabControl.Current.Value);
|
||||
|
||||
AddStep("set second channel", () => channelTabControl.Current.Value = channelTabControl.Items.Skip(1).First());
|
||||
AddStep("set second channel", () => channelTabControl.SelectChannel(channelTabControl.Items.GetNext(channelBefore)));
|
||||
AddAssert("selector tab is inactive", () => !channelTabControl.ChannelSelectorActive.Value);
|
||||
|
||||
AddUntilStep("remove all channels", () =>
|
||||
{
|
||||
var first = channelTabControl.Items.First();
|
||||
if (first is ChannelSelectorTabItem.ChannelSelectorTabChannel)
|
||||
return true;
|
||||
foreach (var item in channelTabControl.Items.ToList())
|
||||
{
|
||||
if (item is ChannelSelectorTabItem.ChannelSelectorTabChannel)
|
||||
continue;
|
||||
|
||||
channelTabControl.RemoveChannel(first);
|
||||
return false;
|
||||
channelTabControl.RemoveChannel(item);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
AddAssert("selector tab is active", () => channelTabControl.ChannelSelectorActive.Value);
|
||||
@ -117,5 +126,10 @@ namespace osu.Game.Tests.Visual.Online
|
||||
Type = ChannelType.Public,
|
||||
Name = name
|
||||
});
|
||||
|
||||
private class TestTabControl : ChannelTabControl
|
||||
{
|
||||
public void SelectChannel(Channel channel) => base.SelectTab(TabMap[channel]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
// 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.Graphics;
|
||||
@ -62,7 +61,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
waitForCurrent();
|
||||
pushNext();
|
||||
waitForCurrent();
|
||||
AddAssert(@"only 2 items", () => breadcrumbs.Items.Count() == 2);
|
||||
AddAssert(@"only 2 items", () => breadcrumbs.Items.Count == 2);
|
||||
AddStep(@"exit current", () => screenStack.CurrentScreen.Exit());
|
||||
AddAssert(@"current screen is first", () => startScreen == screenStack.CurrentScreen);
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
|
||||
AddStep("Select random", () =>
|
||||
{
|
||||
selector.Current.Value = selector.Items.ElementAt(RNG.Next(selector.Items.Count()));
|
||||
selector.Current.Value = selector.Items.ElementAt(RNG.Next(selector.Items.Count));
|
||||
});
|
||||
AddStep("Toggle disabled state", () => selector.Current.Disabled = !selector.Current.Disabled);
|
||||
}
|
||||
|
@ -81,7 +81,10 @@ namespace osu.Game.Overlays.Chat.Tabs
|
||||
RemoveItem(channel);
|
||||
|
||||
if (Current.Value == channel)
|
||||
Current.Value = Items.FirstOrDefault();
|
||||
{
|
||||
// Prefer non-selector channels first
|
||||
Current.Value = Items.FirstOrDefault(c => !(c is ChannelSelectorTabItem.ChannelSelectorTabChannel)) ?? Items.FirstOrDefault();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void SelectTab(TabItem<Channel> tab)
|
||||
|
@ -23,7 +23,7 @@
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.1230.0" />
|
||||
<PackageReference Include="ppy.osu.Framework" Version="2020.111.0" />
|
||||
<PackageReference Include="ppy.osu.Framework" Version="2020.118.0" />
|
||||
<PackageReference Include="Sentry" Version="1.2.0" />
|
||||
<PackageReference Include="SharpCompress" Version="0.24.0" />
|
||||
<PackageReference Include="NUnit" Version="3.12.0" />
|
||||
|
@ -74,7 +74,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup Label="Package References">
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.1230.0" />
|
||||
<PackageReference Include="ppy.osu.Framework.iOS" Version="2020.111.0" />
|
||||
<PackageReference Include="ppy.osu.Framework.iOS" Version="2020.118.0" />
|
||||
</ItemGroup>
|
||||
<!-- Xamarin.iOS does not automatically handle transitive dependencies from NuGet packages. -->
|
||||
<ItemGroup Label="Transitive Dependencies">
|
||||
@ -82,7 +82,7 @@
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.6" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||
<PackageReference Include="ppy.osu.Framework" Version="2020.111.0" />
|
||||
<PackageReference Include="ppy.osu.Framework" Version="2020.118.0" />
|
||||
<PackageReference Include="SharpCompress" Version="0.24.0" />
|
||||
<PackageReference Include="NUnit" Version="3.12.0" />
|
||||
<PackageReference Include="SharpRaven" Version="2.4.0" />
|
||||
|
Loading…
Reference in New Issue
Block a user