From 584d60c9b232b6491075e9db80b236f1f9aae609 Mon Sep 17 00:00:00 2001 From: syogakusya Date: Fri, 10 Jul 2026 11:55:49 +0900 Subject: [PATCH 1/4] =?UTF-8?q?fix:=20UnityTest=E3=81=A7=E3=81=AE=E3=82=B9?= =?UTF-8?q?=E3=82=AF=E3=83=AA=E3=83=BC=E3=83=B3=E3=82=B7=E3=83=A7=E3=83=83?= =?UTF-8?q?=E3=83=88=E6=92=AE=E5=BD=B1=E3=81=AE=E4=BF=AE=E6=AD=A3=E3=81=AE?= =?UTF-8?q?=E3=81=9F=E3=82=81=E3=81=AB=E3=80=81=E3=81=BE=E3=81=9A=E3=83=88?= =?UTF-8?q?=E3=82=B0=E3=83=AB=E3=83=9C=E3=82=BF=E3=83=B3=E8=A6=81=E7=B4=A0?= =?UTF-8?q?=E3=82=92=E3=82=AF=E3=83=AA=E3=83=83=E3=82=AF=E3=81=A7=E3=81=8D?= =?UTF-8?q?=E3=81=9F=E3=81=8B=E3=81=AE=E3=82=A2=E3=82=B5=E3=83=BC=E3=83=88?= =?UTF-8?q?=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Tests/TestBase.cs | 26 +++++++++++--------------- Assets/Tests/UssTest.cs | 16 +++++++++++++--- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/Assets/Tests/TestBase.cs b/Assets/Tests/TestBase.cs index 932d861..ca35258 100644 --- a/Assets/Tests/TestBase.cs +++ b/Assets/Tests/TestBase.cs @@ -10,7 +10,7 @@ namespace DebugToolkit.Tests { public abstract class TestBase { - protected readonly InputTestFixture Input = new(); + private readonly InputTestFixture _input = new(); public virtual void OneTimeSetUp() { @@ -29,14 +29,14 @@ public virtual async Task SetUp() Object.DestroyImmediate(document.gameObject); } - Input.Setup(); + _input.Setup(); InputSystem.settings.backgroundBehavior = InputSettings.BackgroundBehavior.IgnoreFocus; await SceneManager.LoadSceneAsync("DefaultTests", LoadSceneMode.Additive); } public virtual async Task TearDown() { - Input.TearDown(); + _input.TearDown(); InputSystem.settings.backgroundBehavior = InputSettings.BackgroundBehavior.ResetAndDisableNonBackgroundDevices; var testScene = SceneManager.GetSceneByName("DefaultTests"); if (testScene.isLoaded) @@ -46,28 +46,24 @@ public virtual async Task TearDown() } [Test] - public void InputNullTest() - { - Assert.That(Input, Is.Not.Null); - } + public void InputNullTest() => Assert.That(_input, Is.Not.Null); private static EditorWindow GetGameView() => EditorWindow.GetWindow(System.Type.GetType("UnityEditor.GameView,UnityEditor")); protected async Awaitable ClickAtPositionAsync(Mouse mouse, Vector2 position) { - Input.Set(mouse.position, position); - Input.Click(mouse.leftButton); - // Wait for two frames to ensure InputSystem events are processed - await Awaitable.NextFrameAsync(); - await Awaitable.NextFrameAsync(); + _input.Set(mouse.position, position); + _input.Click(mouse.leftButton); + // Wait for ensure InputSystem events are processed + await Awaitable.WaitForSecondsAsync(0.1f); } protected async Awaitable ScrollAtPositionAsync(Mouse mouse, Vector2 position, Vector2 scrollDelta) { - Input.Set(mouse.position, position); - Input.Set(mouse.scroll, scrollDelta); - await Awaitable.NextFrameAsync(); + _input.Set(mouse.position, position); + _input.Set(mouse.scroll, scrollDelta); + await Awaitable.WaitForSecondsAsync(0.1f); } } } \ No newline at end of file diff --git a/Assets/Tests/UssTest.cs b/Assets/Tests/UssTest.cs index ea04f8a..19ee8e8 100644 --- a/Assets/Tests/UssTest.cs +++ b/Assets/Tests/UssTest.cs @@ -42,13 +42,21 @@ public override async Task TearDown() public async Task UssWindow_AllElementsTest() { var window = _debugViewUssTest.Root.AddWindow("UssWindowTest"); - var scrollview = new ScrollView(); - window.Add(scrollview); - AddAllUIElements(scrollview); + var scrollView = new ScrollView(); + window.Add(scrollView); + AddAllUIElements(scrollView); var mouse = InputSystem.AddDevice(); + + var toggle = _debugViewUssTest.Root.GetFirstOfType(); + Assert.That(toggle, Is.Not.Null); + Assert.That(toggle.value, Is.False, "Toggle should be false initially"); + await ClickAtPositionAsync(mouse, new Vector2(133, 865)); + // ここで実際にボタンが押せたかアサート + Assert.That(toggle.value, Is.True, "Not Push the Button"); + await CaptureScreenAsync(nameof(UssWindow_AllElementsTest) + "_scroll-before"); await ScrollAtPositionAsync(mouse, new Vector2(525, 430), new Vector2(0, -100)); @@ -83,6 +91,8 @@ private static async Awaitable CaptureScreenAsync(string fineName) await Awaitable.EndOfFrameAsync(); var result = Path.Combine(directoryPath, fineName + ".png"); + + // スクリーンショット撮影 ScreenCapture.CaptureScreenshot(result); Debug.Log($"Screenshot captured: {result}"); return result; From 813e1ed72122f5b9c113f4e1652ea0b1fc346a24 Mon Sep 17 00:00:00 2001 From: syogakusya Date: Thu, 16 Jul 2026 23:11:56 +0900 Subject: [PATCH 2/4] =?UTF-8?q?fix:=20=E3=83=9E=E3=82=A6=E3=82=B9=E3=82=AF?= =?UTF-8?q?=E3=83=AA=E3=83=83=E3=82=AF=E3=81=A8=E3=82=B9=E3=82=AF=E3=83=AD?= =?UTF-8?q?=E3=83=BC=E3=83=AB=E3=81=AE=E5=BE=85=E6=A9=9F=E3=82=92=E8=AA=BF?= =?UTF-8?q?=E7=AF=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Tests/TestBase.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Assets/Tests/TestBase.cs b/Assets/Tests/TestBase.cs index ca35258..c955c56 100644 --- a/Assets/Tests/TestBase.cs +++ b/Assets/Tests/TestBase.cs @@ -56,14 +56,14 @@ protected async Awaitable ClickAtPositionAsync(Mouse mouse, Vector2 position) _input.Set(mouse.position, position); _input.Click(mouse.leftButton); // Wait for ensure InputSystem events are processed - await Awaitable.WaitForSecondsAsync(0.1f); + await Awaitable.NextFrameAsync(); } protected async Awaitable ScrollAtPositionAsync(Mouse mouse, Vector2 position, Vector2 scrollDelta) { _input.Set(mouse.position, position); _input.Set(mouse.scroll, scrollDelta); - await Awaitable.WaitForSecondsAsync(0.1f); + await Awaitable.NextFrameAsync(); } } } \ No newline at end of file From 160d26374e1f45073aaadc5810902b49c0bdb213 Mon Sep 17 00:00:00 2001 From: syogakusya Date: Thu, 16 Jul 2026 23:11:56 +0900 Subject: [PATCH 3/4] =?UTF-8?q?fix:=20=E3=83=9E=E3=82=A6=E3=82=B9=E3=82=AF?= =?UTF-8?q?=E3=83=AA=E3=83=83=E3=82=AF=E3=81=A8=E3=82=B9=E3=82=AF=E3=83=AD?= =?UTF-8?q?=E3=83=BC=E3=83=AB=E3=81=AE=E5=BE=85=E6=A9=9F=E3=82=92=E8=AA=BF?= =?UTF-8?q?=E7=AF=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Tests/TestBase.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Assets/Tests/TestBase.cs b/Assets/Tests/TestBase.cs index ca35258..625b0b5 100644 --- a/Assets/Tests/TestBase.cs +++ b/Assets/Tests/TestBase.cs @@ -56,14 +56,15 @@ protected async Awaitable ClickAtPositionAsync(Mouse mouse, Vector2 position) _input.Set(mouse.position, position); _input.Click(mouse.leftButton); // Wait for ensure InputSystem events are processed - await Awaitable.WaitForSecondsAsync(0.1f); + await Awaitable.NextFrameAsync(); + await Awaitable.NextFrameAsync(); } protected async Awaitable ScrollAtPositionAsync(Mouse mouse, Vector2 position, Vector2 scrollDelta) { _input.Set(mouse.position, position); _input.Set(mouse.scroll, scrollDelta); - await Awaitable.WaitForSecondsAsync(0.1f); + await Awaitable.NextFrameAsync(); } } } \ No newline at end of file From 7b4c70c97f80fd3e8f995e75f81402cafbae1817 Mon Sep 17 00:00:00 2001 From: syogakusya Date: Fri, 17 Jul 2026 00:12:42 +0900 Subject: [PATCH 4/4] =?UTF-8?q?fix:=20=E3=83=86=E3=82=B9=E3=83=88=E3=81=A7?= =?UTF-8?q?=E3=81=AE=E3=82=AF=E3=83=AA=E3=83=83=E3=82=AF=E5=BA=A7=E6=A8=99?= =?UTF-8?q?=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Tests/CustomElementTest.cs | 6 +++--- Assets/Tests/UssTest.cs | 14 +++++++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Assets/Tests/CustomElementTest.cs b/Assets/Tests/CustomElementTest.cs index 167de29..5f2a9bb 100644 --- a/Assets/Tests/CustomElementTest.cs +++ b/Assets/Tests/CustomElementTest.cs @@ -91,13 +91,13 @@ public async Task ConsoleView_SearchAndCategorizeMessages_WorksCorrectly( Assert.That(items.Count, Is.GreaterThanOrEqualTo(3), "There are fewer than 3 items in the ListView."); var mouse = InputSystem.AddDevice(); - await ClickAtPositionAsync(mouse, new Vector2(positionX0, 824)); + await ClickAtPositionAsync(mouse, new Vector2(positionX0, 852)); var filteredItems = listView.itemsSource; Assert.That(filteredItems, Is.Not.Null, "1: The type of the filter result is incorrect."); Assert.That(filteredItems.Count, Is.EqualTo(2), "1: The search results are not filtered correctly."); - await ClickAtPositionAsync(mouse, new Vector2(positionX1, 824)); + await ClickAtPositionAsync(mouse, new Vector2(positionX1, 852)); filteredItems = listView.itemsSource; Assert.That(filteredItems, Is.Not.Null, "2: The type of the filter result is incorrect."); @@ -105,7 +105,7 @@ public async Task ConsoleView_SearchAndCategorizeMessages_WorksCorrectly( var logEntry = filteredItems[0] as (string, string, LogType, DateTime)?; Assert.That(logEntry?.Item3, Is.EqualTo(type), "2: The log type of the filter result is not a warning."); - await ClickAtPositionAsync(mouse, new Vector2(positionX2, 824)); + await ClickAtPositionAsync(mouse, new Vector2(positionX2, 852)); filteredItems = listView.itemsSource; Assert.That(filteredItems, Is.Not.Null, "3: The type of the filter result is incorrect."); diff --git a/Assets/Tests/UssTest.cs b/Assets/Tests/UssTest.cs index 19ee8e8..22b0aa6 100644 --- a/Assets/Tests/UssTest.cs +++ b/Assets/Tests/UssTest.cs @@ -48,11 +48,11 @@ public async Task UssWindow_AllElementsTest() var mouse = InputSystem.AddDevice(); - var toggle = _debugViewUssTest.Root.GetFirstOfType(); + var toggle = _debugViewUssTest.Root.Query().First(); Assert.That(toggle, Is.Not.Null); Assert.That(toggle.value, Is.False, "Toggle should be false initially"); - await ClickAtPositionAsync(mouse, new Vector2(133, 865)); + await ClickAtPositionAsync(mouse, new Vector2(133, 910)); // ここで実際にボタンが押せたかアサート Assert.That(toggle.value, Is.True, "Not Push the Button"); @@ -74,7 +74,15 @@ public async Task UssTab_AllElementsTest() AddAllUIElements(tab1); var mouse = InputSystem.AddDevice(); - await ClickAtPositionAsync(mouse, new Vector2(133, 865)); + var toggle = _debugViewUssTest.Root.Query().First(); + + Assert.That(toggle, Is.Not.Null); + Assert.That(toggle.value, Is.False, "Toggle should be false initially"); + + await ClickAtPositionAsync(mouse, new Vector2(133, 910)); + + // ここで実際にボタンが押せたかアサート + Assert.That(toggle.value, Is.True, "Not Push the Button"); await CaptureScreenAsync(nameof(UssTab_AllElementsTest) + "_scroll-before");