mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 07:42:57 +08:00
Merge pull request #22515 from Susko3/use-ipc-archive-importer
Allow importing beatmaps via file associations on desktop platforms
This commit is contained in:
commit
67ec3199c5
@ -29,6 +29,7 @@ namespace osu.Desktop
|
||||
internal partial class OsuGameDesktop : OsuGame
|
||||
{
|
||||
private OsuSchemeLinkIPCChannel? osuSchemeLinkIPCChannel;
|
||||
private ArchiveImportIPCChannel? archiveImportIPCChannel;
|
||||
|
||||
public OsuGameDesktop(string[]? args = null)
|
||||
: base(args)
|
||||
@ -123,6 +124,7 @@ namespace osu.Desktop
|
||||
LoadComponentAsync(new ElevatedPrivilegesChecker(), Add);
|
||||
|
||||
osuSchemeLinkIPCChannel = new OsuSchemeLinkIPCChannel(Host, this);
|
||||
archiveImportIPCChannel = new ArchiveImportIPCChannel(Host, this);
|
||||
}
|
||||
|
||||
public override void SetHost(GameHost host)
|
||||
@ -181,6 +183,7 @@ namespace osu.Desktop
|
||||
{
|
||||
base.Dispose(isDisposing);
|
||||
osuSchemeLinkIPCChannel?.Dispose();
|
||||
archiveImportIPCChannel?.Dispose();
|
||||
}
|
||||
|
||||
private class SDL2BatteryInfo : BatteryInfo
|
||||
|
@ -1,6 +1,7 @@
|
||||
// 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.IO;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework;
|
||||
@ -14,6 +15,8 @@ using osu.Game.Online.API;
|
||||
using osu.Game.Online.API.Requests;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Overlays.Notifications;
|
||||
using osu.Game.Tests.Resources;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Navigation
|
||||
{
|
||||
@ -23,11 +26,13 @@ namespace osu.Game.Tests.Visual.Navigation
|
||||
{
|
||||
private HeadlessGameHost ipcSenderHost = null!;
|
||||
|
||||
private OsuSchemeLinkIPCChannel osuSchemeLinkIPCReceiver = null!;
|
||||
private OsuSchemeLinkIPCChannel osuSchemeLinkIPCSender = null!;
|
||||
private ArchiveImportIPCChannel archiveImportIPCSender = null!;
|
||||
|
||||
private const int requested_beatmap_set_id = 1;
|
||||
|
||||
protected override TestOsuGame CreateTestGame() => new IpcGame(LocalStorage, API);
|
||||
|
||||
[Resolved]
|
||||
private GameHost gameHost { get; set; } = null!;
|
||||
|
||||
@ -56,11 +61,11 @@ namespace osu.Game.Tests.Visual.Navigation
|
||||
return false;
|
||||
};
|
||||
});
|
||||
AddStep("create IPC receiver channel", () => osuSchemeLinkIPCReceiver = new OsuSchemeLinkIPCChannel(gameHost, Game));
|
||||
AddStep("create IPC sender channel", () =>
|
||||
AddStep("create IPC sender channels", () =>
|
||||
{
|
||||
ipcSenderHost = new HeadlessGameHost(gameHost.Name, new HostOptions { BindIPC = true });
|
||||
osuSchemeLinkIPCSender = new OsuSchemeLinkIPCChannel(ipcSenderHost);
|
||||
archiveImportIPCSender = new ArchiveImportIPCChannel(ipcSenderHost);
|
||||
});
|
||||
}
|
||||
|
||||
@ -72,15 +77,50 @@ namespace osu.Game.Tests.Visual.Navigation
|
||||
AddUntilStep("beatmap overlay showing content", () => Game.ChildrenOfType<BeatmapSetOverlay>().FirstOrDefault()?.Header.BeatmapSet.Value.OnlineID == requested_beatmap_set_id);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestArchiveImportLinkIPCChannel()
|
||||
{
|
||||
string? beatmapFilepath = null;
|
||||
|
||||
AddStep("import beatmap via IPC", () => archiveImportIPCSender.ImportAsync(beatmapFilepath = TestResources.GetQuickTestBeatmapForImport()).WaitSafely());
|
||||
AddUntilStep("import complete notification was presented", () => Game.Notifications.ChildrenOfType<ProgressCompletionNotification>().Count(), () => Is.EqualTo(1));
|
||||
AddAssert("original file deleted", () => File.Exists(beatmapFilepath), () => Is.False);
|
||||
}
|
||||
|
||||
public override void TearDownSteps()
|
||||
{
|
||||
AddStep("dispose IPC receiver", () => osuSchemeLinkIPCReceiver.Dispose());
|
||||
AddStep("dispose IPC sender", () =>
|
||||
AddStep("dispose IPC senders", () =>
|
||||
{
|
||||
osuSchemeLinkIPCSender.Dispose();
|
||||
archiveImportIPCSender.Dispose();
|
||||
ipcSenderHost.Dispose();
|
||||
});
|
||||
base.TearDownSteps();
|
||||
}
|
||||
|
||||
private partial class IpcGame : TestOsuGame
|
||||
{
|
||||
private OsuSchemeLinkIPCChannel? osuSchemeLinkIPCChannel;
|
||||
private ArchiveImportIPCChannel? archiveImportIPCChannel;
|
||||
|
||||
public IpcGame(Storage storage, IAPIProvider api, string[]? args = null)
|
||||
: base(storage, api, args)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
osuSchemeLinkIPCChannel = new OsuSchemeLinkIPCChannel(Host, this);
|
||||
archiveImportIPCChannel = new ArchiveImportIPCChannel(Host, this);
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
base.Dispose(isDisposing);
|
||||
osuSchemeLinkIPCChannel?.Dispose();
|
||||
archiveImportIPCChannel?.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user