Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Assets/Editor/CaptureTest/EditorWindowCaptureTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using System.IO;
using System.Threading;

using io.github.hatayama.UnityCliLoop.FirstPartyTools;
using io.github.hatayama.UnityCliLoop.ToolContracts;

namespace io.github.hatayama.UnityCliLoop.Dev
Expand Down
1 change: 0 additions & 1 deletion Assets/Editor/CompileCheckWindow/CompileEditorWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;

using io.github.hatayama.UnityCliLoop.Application;
using io.github.hatayama.UnityCliLoop.FirstPartyTools;
using io.github.hatayama.UnityCliLoop.ToolContracts;

Expand Down
49 changes: 25 additions & 24 deletions Assets/Tests/Editor/JsonRpcProcessorCliVersionGateTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using io.github.hatayama.UnityCliLoop.Domain;
using io.github.hatayama.UnityCliLoop.Infrastructure;
using io.github.hatayama.UnityCliLoop.ToolContracts;
using ApplicationRegistrar = io.github.hatayama.UnityCliLoop.Application.UnityCliLoopToolRegistrar;

namespace io.github.hatayama.UnityCliLoop.Tests.Editor
{
Expand Down Expand Up @@ -175,13 +176,13 @@ public async Task ProcessRequest_WhenFirstToolWaitsForMainThread_ReturnsServerBu
MainThreadSwitcher.RegisterService(dispatcher);
UnityCliLoopEditorStateSnapshot.SetPlayStateForTesting(isPlaying: false, isPaused: false);

UnityCliLoopToolRegistrarService previousService = UnityCliLoopToolRegistrar.Service;
UnityCliLoopToolRegistrarService previousService = ApplicationRegistrar.Service;
ToolSettingsService toolSettingsService = new(new ToolSettingsRepository());
UnityCliLoopToolRegistrarService service = new(
new EmptyInternalToolNameProvider(),
toolSettingsService,
new UnityCliLoopToolExecutionService());
UnityCliLoopToolRegistrar.RegisterService(service);
ApplicationRegistrar.RegisterService(service);
service.RegisterCustomTool(new SingleFlightTestTool());

Task<string> firstResponseTask = null;
Expand Down Expand Up @@ -218,7 +219,7 @@ public async Task ProcessRequest_WhenFirstToolWaitsForMainThread_ReturnsServerBu
await DrainTaskIfNeeded(firstResponseTask);
await DrainTaskIfNeeded(secondResponseTask);
UnityCliLoopEditorStateSnapshot.ClearForTesting();
UnityCliLoopToolRegistrar.RegisterService(previousService);
ApplicationRegistrar.RegisterService(previousService);
RestoreEditorMainThreadDispatcher();
}
}
Expand All @@ -231,13 +232,13 @@ public async Task ProcessRequest_WhenExecuteDynamicCodeWaitsForMainThread_Allows
MainThreadSwitcher.RegisterService(dispatcher);
UnityCliLoopEditorStateSnapshot.SetPlayStateForTesting(isPlaying: false, isPaused: false);

UnityCliLoopToolRegistrarService previousService = UnityCliLoopToolRegistrar.Service;
UnityCliLoopToolRegistrarService previousService = ApplicationRegistrar.Service;
ToolSettingsService toolSettingsService = new(new ToolSettingsRepository());
UnityCliLoopToolRegistrarService service = new(
new EmptyInternalToolNameProvider(),
toolSettingsService,
new UnityCliLoopToolExecutionService());
UnityCliLoopToolRegistrar.RegisterService(service);
ApplicationRegistrar.RegisterService(service);
service.RegisterCustomTool(new ExecuteDynamicCodeTestTool());
service.RegisterCustomTool(new SingleFlightTestTool());

Expand Down Expand Up @@ -286,7 +287,7 @@ public async Task ProcessRequest_WhenExecuteDynamicCodeWaitsForMainThread_Allows
await DrainTaskIfNeeded(secondDynamicCodeTask);
await DrainTaskIfNeeded(otherToolTask);
UnityCliLoopEditorStateSnapshot.ClearForTesting();
UnityCliLoopToolRegistrar.RegisterService(previousService);
ApplicationRegistrar.RegisterService(previousService);
RestoreEditorMainThreadDispatcher();
}
}
Expand All @@ -295,13 +296,13 @@ public async Task ProcessRequest_WhenExecuteDynamicCodeWaitsForMainThread_Allows
public async Task ProcessRequest_WhenCompileWaitsForDomainReload_KeepsAcceptedRequestAliveAfterDisconnect()
{
// Verifies long compile waits are allowed to persist their result after the CLI response deadline closes.
UnityCliLoopToolRegistrarService previousService = UnityCliLoopToolRegistrar.Service;
UnityCliLoopToolRegistrarService previousService = ApplicationRegistrar.Service;
ToolSettingsService toolSettingsService = new(new ToolSettingsRepository());
UnityCliLoopToolRegistrarService service = new(
new EmptyInternalToolNameProvider(),
toolSettingsService,
new UnityCliLoopToolExecutionService());
UnityCliLoopToolRegistrar.RegisterService(service);
ApplicationRegistrar.RegisterService(service);
service.RegisterCustomTool(new CompileDispatchPolicyTestTool());

bool cancelOnClientDisconnect = true;
Expand All @@ -326,21 +327,21 @@ public async Task ProcessRequest_WhenCompileWaitsForDomainReload_KeepsAcceptedRe
}
finally
{
UnityCliLoopToolRegistrar.RegisterService(previousService);
ApplicationRegistrar.RegisterService(previousService);
}
}

[Test]
public async Task ProcessRequest_WhenCompileOmitsReloadWait_KeepsAcceptedRequestAliveAfterDisconnect()
{
// Verifies missing compile reload-wait params preserve the default wait contract.
UnityCliLoopToolRegistrarService previousService = UnityCliLoopToolRegistrar.Service;
UnityCliLoopToolRegistrarService previousService = ApplicationRegistrar.Service;
ToolSettingsService toolSettingsService = new(new ToolSettingsRepository());
UnityCliLoopToolRegistrarService service = new(
new EmptyInternalToolNameProvider(),
toolSettingsService,
new UnityCliLoopToolExecutionService());
UnityCliLoopToolRegistrar.RegisterService(service);
ApplicationRegistrar.RegisterService(service);
service.RegisterCustomTool(new CompileDispatchPolicyTestTool());

bool cancelOnClientDisconnect = true;
Expand All @@ -362,21 +363,21 @@ public async Task ProcessRequest_WhenCompileOmitsReloadWait_KeepsAcceptedRequest
}
finally
{
UnityCliLoopToolRegistrar.RegisterService(previousService);
ApplicationRegistrar.RegisterService(previousService);
}
}

[Test]
public async Task ProcessRequest_WhenCompileDoesNotWaitForDomainReload_CancelsOnClientDisconnect()
{
// Verifies fire-and-forget compile requests still cancel when the CLI connection goes away.
UnityCliLoopToolRegistrarService previousService = UnityCliLoopToolRegistrar.Service;
UnityCliLoopToolRegistrarService previousService = ApplicationRegistrar.Service;
ToolSettingsService toolSettingsService = new(new ToolSettingsRepository());
UnityCliLoopToolRegistrarService service = new(
new EmptyInternalToolNameProvider(),
toolSettingsService,
new UnityCliLoopToolExecutionService());
UnityCliLoopToolRegistrar.RegisterService(service);
ApplicationRegistrar.RegisterService(service);
service.RegisterCustomTool(new CompileDispatchPolicyTestTool());

bool cancelOnClientDisconnect = false;
Expand All @@ -401,21 +402,21 @@ public async Task ProcessRequest_WhenCompileDoesNotWaitForDomainReload_CancelsOn
}
finally
{
UnityCliLoopToolRegistrar.RegisterService(previousService);
ApplicationRegistrar.RegisterService(previousService);
}
}

[Test]
public async Task ProcessRequest_WhenCompileUsesCamelCaseNoReloadWait_CancelsOnClientDisconnect()
{
// Verifies JSON-RPC compile dispatch policy matches the camelCase tool deserializer contract.
UnityCliLoopToolRegistrarService previousService = UnityCliLoopToolRegistrar.Service;
UnityCliLoopToolRegistrarService previousService = ApplicationRegistrar.Service;
ToolSettingsService toolSettingsService = new(new ToolSettingsRepository());
UnityCliLoopToolRegistrarService service = new(
new EmptyInternalToolNameProvider(),
toolSettingsService,
new UnityCliLoopToolExecutionService());
UnityCliLoopToolRegistrar.RegisterService(service);
ApplicationRegistrar.RegisterService(service);
service.RegisterCustomTool(new CompileDispatchPolicyTestTool());

bool cancelOnClientDisconnect = false;
Expand All @@ -440,7 +441,7 @@ public async Task ProcessRequest_WhenCompileUsesCamelCaseNoReloadWait_CancelsOnC
}
finally
{
UnityCliLoopToolRegistrar.RegisterService(previousService);
ApplicationRegistrar.RegisterService(previousService);
}
}

Expand All @@ -451,13 +452,13 @@ public async Task ProcessRequest_AfterGetHierarchyReturns_AllowsImmediateGetLogs
CapturingMainThreadDispatcher dispatcher = new();
MainThreadSwitcher.RegisterService(dispatcher);

UnityCliLoopToolRegistrarService previousService = UnityCliLoopToolRegistrar.Service;
UnityCliLoopToolRegistrarService previousService = ApplicationRegistrar.Service;
ToolSettingsService toolSettingsService = new(new ToolSettingsRepository());
UnityCliLoopToolRegistrarService service = new(
new EmptyInternalToolNameProvider(),
toolSettingsService,
new UnityCliLoopToolExecutionService());
UnityCliLoopToolRegistrar.RegisterService(service);
ApplicationRegistrar.RegisterService(service);

string hierarchyResponse = null;
Task<string> hierarchyResponseTask = null;
Expand Down Expand Up @@ -502,7 +503,7 @@ public async Task ProcessRequest_AfterGetHierarchyReturns_AllowsImmediateGetLogs
await DrainTaskIfNeeded(hierarchyResponseTask);
await DrainTaskIfNeeded(logsResponseTask);
DeleteHierarchyFileFromResponse(hierarchyResponse);
UnityCliLoopToolRegistrar.RegisterService(previousService);
ApplicationRegistrar.RegisterService(previousService);
RestoreEditorMainThreadDispatcher();
}
}
Expand Down Expand Up @@ -547,13 +548,13 @@ public async Task ProcessRequest_WhenMainThreadSwitchIsCanceled_ReleasesExecutio
CapturingMainThreadDispatcher dispatcher = new();
MainThreadSwitcher.RegisterService(dispatcher);

UnityCliLoopToolRegistrarService previousService = UnityCliLoopToolRegistrar.Service;
UnityCliLoopToolRegistrarService previousService = ApplicationRegistrar.Service;
ToolSettingsService toolSettingsService = new(new ToolSettingsRepository());
UnityCliLoopToolRegistrarService service = new(
new EmptyInternalToolNameProvider(),
toolSettingsService,
new UnityCliLoopToolExecutionService());
UnityCliLoopToolRegistrar.RegisterService(service);
ApplicationRegistrar.RegisterService(service);
service.RegisterCustomTool(new SingleFlightTestTool());

using CancellationTokenSource cancellationSource = new CancellationTokenSource();
Expand Down Expand Up @@ -590,7 +591,7 @@ public async Task ProcessRequest_WhenMainThreadSwitchIsCanceled_ReleasesExecutio
dispatcher.RunContinuations();
await DrainTaskIfNeeded(canceledResponseTask);
await DrainTaskIfNeeded(secondResponseTask);
UnityCliLoopToolRegistrar.RegisterService(previousService);
ApplicationRegistrar.RegisterService(previousService);
RestoreEditorMainThreadDispatcher();
}
}
Expand Down
2 changes: 1 addition & 1 deletion Assets/Tests/Editor/MainThreadSwitcherTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using UnityEngine;
using UnityEngine.TestTools;

using io.github.hatayama.UnityCliLoop.Application;
using io.github.hatayama.UnityCliLoop.ToolContracts;

namespace io.github.hatayama.UnityCliLoop.Tests.Editor
{
Expand Down
21 changes: 12 additions & 9 deletions Assets/Tests/Editor/OnionAssemblyDependencyTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void PlatformResultTypes_WhenLoaded_CompileUnderDomainAssembly()

Assert.That(validationResultAssemblyName, Is.EqualTo(ToolContractsAssemblyName));
Assert.That(forceCompileUnknownResultAssemblyName, Is.EqualTo(ToolContractsAssemblyName));
Assert.That(serviceResultAssemblyName, Is.EqualTo(DomainAssemblyName));
Assert.That(serviceResultAssemblyName, Is.EqualTo(ToolContractsAssemblyName));
}

[Test]
Expand Down Expand Up @@ -233,7 +233,7 @@ public void ToolCorePolicy_WhenLoaded_CompilesUnderDomainAssembly()
Assert.That(registryAssemblyName, Is.EqualTo(DomainAssemblyName));
Assert.That(internalToolNameProviderAssemblyName, Is.EqualTo(DomainAssemblyName));
Assert.That(classifierAssemblyName, Is.EqualTo(DomainAssemblyName));
Assert.That(catalogItemAssemblyName, Is.EqualTo(DomainAssemblyName));
Assert.That(catalogItemAssemblyName, Is.EqualTo(ToolContractsAssemblyName));
Assert.That(domainReloadServiceAssemblyName, Is.EqualTo(DomainAssemblyName));
}

Expand Down Expand Up @@ -384,18 +384,18 @@ public void FindGameObjectsUseCase_WhenLoaded_CompilesUnderApplicationAssembly()
}

[Test]
public void ScreenshotTypes_WhenLoaded_CompileUnderFirstPartyToolsAssembly()
public void ScreenshotContracts_WhenLoaded_CompileUnderToolContractsAssembly()
{
// Tests that bundled screenshot implementation types stay inside the first-party tool assembly.
// Tests that screenshot public contracts are exposed from the shared ToolContracts assembly.
string serviceAssemblyName = typeof(IUnityCliLoopScreenshotService).Assembly.GetName().Name;
string requestAssemblyName = typeof(UnityCliLoopScreenshotRequest).Assembly.GetName().Name;
string resultAssemblyName = typeof(UnityCliLoopScreenshotResult).Assembly.GetName().Name;
string elementAssemblyName = typeof(UIElementInfo).Assembly.GetName().Name;

Assert.That(serviceAssemblyName, Does.StartWith(FirstPartyToolsAssemblyNamePrefix));
Assert.That(requestAssemblyName, Does.StartWith(FirstPartyToolsAssemblyNamePrefix));
Assert.That(resultAssemblyName, Does.StartWith(FirstPartyToolsAssemblyNamePrefix));
Assert.That(elementAssemblyName, Does.StartWith(FirstPartyToolsAssemblyNamePrefix));
Assert.That(serviceAssemblyName, Is.EqualTo(ToolContractsAssemblyName));
Assert.That(requestAssemblyName, Is.EqualTo(ToolContractsAssemblyName));
Assert.That(resultAssemblyName, Is.EqualTo(ToolContractsAssemblyName));
Assert.That(elementAssemblyName, Is.EqualTo(ToolContractsAssemblyName));
}

[Test]
Expand Down Expand Up @@ -1205,7 +1205,10 @@ private static string[] ReadResolvedReferences(string relativeAsmdefPath)

private static bool IsPublicAutoReferencedAssembly(string assemblyName)
{
return string.Equals(assemblyName, ToolContractsAssemblyName, StringComparison.Ordinal) ||
return string.Equals(assemblyName, ApplicationAssemblyName, StringComparison.Ordinal) ||
string.Equals(assemblyName, DomainAssemblyName, StringComparison.Ordinal) ||
string.Equals(assemblyName, ScreenshotAssemblyName, StringComparison.Ordinal) ||
string.Equals(assemblyName, ToolContractsAssemblyName, StringComparison.Ordinal) ||
string.Equals(assemblyName, PausePointsRuntimeAssemblyName, StringComparison.Ordinal);
}

Expand Down
Loading
Loading