mirror of
https://github.com/osukey/osukey.git
synced 2025-08-04 07:06:35 +09:00
Merge branch 'master' into editor-metadata-name-unification
This commit is contained in:
@ -10,6 +10,7 @@ using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
@ -61,6 +62,21 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
AddUntilStep("context menu is visible", () => contextMenuContainer.ChildrenOfType<OsuContextMenu>().Single().State == MenuState.Open);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSelectAndShowContextMenuOutsideBounds()
|
||||
{
|
||||
var addedObject = new HitCircle { StartTime = 100, Position = OsuPlayfield.BASE_SIZE };
|
||||
AddStep("add hitobject", () => EditorBeatmap.Add(addedObject));
|
||||
|
||||
AddStep("descale blueprint container", () => this.ChildrenOfType<HitObjectComposer>().Single().Scale = new Vector2(0.5f));
|
||||
AddStep("move mouse to bottom-right", () => InputManager.MoveMouseTo(blueprintContainer.ToScreenSpace(blueprintContainer.LayoutRectangle.BottomRight + new Vector2(10))));
|
||||
|
||||
AddStep("right click", () => InputManager.Click(MouseButton.Right));
|
||||
|
||||
AddUntilStep("hitobject selected", () => EditorBeatmap.SelectedHitObjects.Single() == addedObject);
|
||||
AddUntilStep("context menu is visible", () => contextMenuContainer.ChildrenOfType<OsuContextMenu>().Single().State == MenuState.Open);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestNudgeSelection()
|
||||
{
|
||||
|
@ -78,6 +78,21 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
AddAssert("Inner container width matches scroll container", () => innerBox.DrawWidth == scrollContainer.DrawWidth);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestZoomRangeUpdate()
|
||||
{
|
||||
AddStep("set zoom to 2", () => scrollContainer.Zoom = 2);
|
||||
AddStep("set min zoom to 5", () => scrollContainer.MinZoom = 5);
|
||||
AddAssert("zoom = 5", () => scrollContainer.Zoom == 5);
|
||||
|
||||
AddStep("set max zoom to 10", () => scrollContainer.MaxZoom = 10);
|
||||
AddAssert("zoom = 5", () => scrollContainer.Zoom == 5);
|
||||
|
||||
AddStep("set min zoom to 20", () => scrollContainer.MinZoom = 20);
|
||||
AddStep("set max zoom to 40", () => scrollContainer.MaxZoom = 40);
|
||||
AddAssert("zoom = 20", () => scrollContainer.Zoom == 20);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestZoom0()
|
||||
{
|
||||
|
@ -2,6 +2,7 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
@ -13,6 +14,7 @@ using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Overlays.Notifications;
|
||||
using osu.Game.Overlays.Toolbar;
|
||||
using osu.Game.Rulesets;
|
||||
using osuTK.Graphics;
|
||||
@ -28,21 +30,44 @@ namespace osu.Game.Tests.Visual.Menus
|
||||
[Resolved]
|
||||
private IRulesetStore rulesets { get; set; }
|
||||
|
||||
private readonly Mock<INotificationOverlay> notifications = new Mock<INotificationOverlay>();
|
||||
[Cached]
|
||||
private readonly NowPlayingOverlay nowPlayingOverlay = new NowPlayingOverlay
|
||||
{
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
Y = Toolbar.HEIGHT,
|
||||
};
|
||||
|
||||
[Cached]
|
||||
private readonly VolumeOverlay volumeOverlay = new VolumeOverlay
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
};
|
||||
|
||||
private readonly Mock<TestNotificationOverlay> notifications = new Mock<TestNotificationOverlay>();
|
||||
|
||||
private readonly BindableInt unreadNotificationCount = new BindableInt();
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
Dependencies.CacheAs(notifications.Object);
|
||||
Dependencies.CacheAs<INotificationOverlay>(notifications.Object);
|
||||
notifications.SetupGet(n => n.UnreadCount).Returns(unreadNotificationCount);
|
||||
}
|
||||
|
||||
[SetUp]
|
||||
public void SetUp() => Schedule(() =>
|
||||
{
|
||||
Child = toolbar = new TestToolbar { State = { Value = Visibility.Visible } };
|
||||
Remove(nowPlayingOverlay);
|
||||
Remove(volumeOverlay);
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
nowPlayingOverlay,
|
||||
volumeOverlay,
|
||||
toolbar = new TestToolbar { State = { Value = Visibility.Visible } },
|
||||
};
|
||||
});
|
||||
|
||||
[Test]
|
||||
@ -122,9 +147,51 @@ namespace osu.Game.Tests.Visual.Menus
|
||||
AddAssert("not scrolled", () => scroll.Current == 0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestVolumeControlViaMusicButtonScroll()
|
||||
{
|
||||
AddStep("hover toolbar music button", () => InputManager.MoveMouseTo(this.ChildrenOfType<ToolbarMusicButton>().Single()));
|
||||
|
||||
AddStep("reset volume", () => Audio.Volume.Value = 1);
|
||||
|
||||
AddRepeatStep("scroll down", () => InputManager.ScrollVerticalBy(-10), 5);
|
||||
AddAssert("volume lowered down", () => Audio.Volume.Value < 1);
|
||||
AddRepeatStep("scroll up", () => InputManager.ScrollVerticalBy(10), 5);
|
||||
AddAssert("volume raised up", () => Audio.Volume.Value == 1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestVolumeControlViaMusicButtonArrowKeys()
|
||||
{
|
||||
AddStep("hover toolbar music button", () => InputManager.MoveMouseTo(this.ChildrenOfType<ToolbarMusicButton>().Single()));
|
||||
|
||||
AddStep("reset volume", () => Audio.Volume.Value = 1);
|
||||
|
||||
AddRepeatStep("arrow down", () => InputManager.Key(Key.Down), 5);
|
||||
AddAssert("volume lowered down", () => Audio.Volume.Value < 1);
|
||||
AddRepeatStep("arrow up", () => InputManager.Key(Key.Up), 5);
|
||||
AddAssert("volume raised up", () => Audio.Volume.Value == 1);
|
||||
}
|
||||
|
||||
public class TestToolbar : Toolbar
|
||||
{
|
||||
public new Bindable<OverlayActivation> OverlayActivationMode => base.OverlayActivationMode as Bindable<OverlayActivation>;
|
||||
}
|
||||
|
||||
// interface mocks break hot reload, mocking this stub implementation instead works around it.
|
||||
// see: https://github.com/moq/moq4/issues/1252
|
||||
[UsedImplicitly]
|
||||
public class TestNotificationOverlay : INotificationOverlay
|
||||
{
|
||||
public virtual void Post(Notification notification)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void Hide()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual IBindable<int> UnreadCount => null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
56
osu.Game.Tests/Visual/Navigation/TestSceneFirstRunGame.cs
Normal file
56
osu.Game.Tests/Visual/Navigation/TestSceneFirstRunGame.cs
Normal file
@ -0,0 +1,56 @@
|
||||
// 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 NUnit.Framework;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Overlays.Notifications;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Navigation
|
||||
{
|
||||
[System.ComponentModel.Description("game with first-run setup overlay")]
|
||||
public class TestSceneFirstRunGame : OsuGameTestScene
|
||||
{
|
||||
public override void SetUpSteps()
|
||||
{
|
||||
base.SetUpSteps();
|
||||
|
||||
AddUntilStep("Wait for first-run setup", () => Game.FirstRunOverlay.State.Value == Visibility.Visible);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestImportantNotificationDoesntInterruptSetup()
|
||||
{
|
||||
AddStep("post important notification", () => Game.Notifications.Post(new SimpleNotification { Text = "Important notification" }));
|
||||
AddAssert("no notification posted", () => Game.Notifications.UnreadCount.Value == 0);
|
||||
AddAssert("first-run setup still visible", () => Game.FirstRunOverlay.State.Value == Visibility.Visible);
|
||||
|
||||
AddUntilStep("finish first-run setup", () =>
|
||||
{
|
||||
Game.FirstRunOverlay.NextButton.TriggerClick();
|
||||
return Game.FirstRunOverlay.State.Value == Visibility.Hidden;
|
||||
});
|
||||
AddWaitStep("wait for post delay", 5);
|
||||
AddAssert("notifications shown", () => Game.Notifications.State.Value == Visibility.Visible);
|
||||
AddAssert("notification posted", () => Game.Notifications.UnreadCount.Value == 1);
|
||||
}
|
||||
|
||||
protected override TestOsuGame CreateTestGame() => new FirstRunGame(LocalStorage, API);
|
||||
|
||||
private class FirstRunGame : TestOsuGame
|
||||
{
|
||||
public FirstRunGame(Storage storage, IAPIProvider api, string[] args = null)
|
||||
: base(storage, api, args)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
LocalConfig.SetValue(OsuSetting.ShowFirstRunSetup, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user