-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from DeNA/stop-when-error-immediately-thrown
Fix not stopping and reporting when error occurred
- Loading branch information
Showing
18 changed files
with
742 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright (c) 2023 DeNA Co., Ltd. | ||
// This software is released under the MIT License. | ||
|
||
using System.Threading; | ||
using Cysharp.Threading.Tasks; | ||
using DeNA.Anjin.Agents; | ||
using UnityEngine; | ||
using UnityEngine.EventSystems; | ||
|
||
namespace DeNA.Anjin.TestDoubles | ||
{ | ||
/// <summary> | ||
/// A test double for agent. This agent immediately click game objects that have the name specified | ||
/// </summary> | ||
public class StubClickAgent : AbstractAgent | ||
{ | ||
/// <summary> | ||
/// A name of game objects to click | ||
/// </summary> | ||
[SerializeField] public string targetName; | ||
|
||
|
||
/// <inheritdoc /> | ||
public override UniTask Run(CancellationToken token) | ||
{ | ||
foreach (var obj in FindObjectsByType<GameObject>(FindObjectsSortMode.None)) | ||
{ | ||
if (obj.name != targetName) | ||
{ | ||
continue; | ||
} | ||
|
||
var target = obj; | ||
if (!target.TryGetComponent<IPointerClickHandler>(out var handler)) | ||
{ | ||
Debug.LogWarning( | ||
$"{target.name} did not have any components that derived {nameof(IPointerClickHandler)}" | ||
); | ||
continue; | ||
} | ||
|
||
handler.OnPointerClick(new PointerEventData(EventSystem.current)); | ||
} | ||
|
||
return UniTask.CompletedTask; | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright (c) 2023 DeNA Co., Ltd. | ||
// This software is released under the MIT License. | ||
|
||
using System; | ||
using System.Threading; | ||
using UnityEngine; | ||
using UnityEngine.EventSystems; | ||
|
||
namespace DeNA.Anjin.TestDoubles | ||
{ | ||
/// <summary> | ||
/// A test stub throw errors when clicked | ||
/// </summary> | ||
[AddComponentMenu("")] | ||
public class StubThrowingErrorOnClick : MonoBehaviour, IPointerClickHandler | ||
{ | ||
public void OnPointerClick(PointerEventData eventData) | ||
{ | ||
throw new Exception($"TEST on thread #{Thread.CurrentThread.ManagedThreadId}"); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
33 changes: 33 additions & 0 deletions
33
Tests/TestAssets/AutopilotSettingsForFacingImmediatelyError.asset
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
%YAML 1.1 | ||
%TAG !u! tag:unity3d.com,2011: | ||
--- !u!114 &11400000 | ||
MonoBehaviour: | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
m_GameObject: {fileID: 0} | ||
m_Enabled: 1 | ||
m_EditorHideFlags: 0 | ||
m_Script: {fileID: 11500000, guid: c7a1731caa574ed4b9334b7d52febe27, type: 3} | ||
m_Name: AutopilotSettingsForFacingImmediatelyError | ||
m_EditorClassIdentifier: | ||
description: | ||
sceneAgentMaps: | ||
- scenePath: Packages/com.dena.anjin/Tests/TestScenes/Error.unity | ||
agent: {fileID: 11400000, guid: 9a5c6d18335194c1b9f8e162695d73fd, type: 2} | ||
fallbackAgent: {fileID: 0} | ||
observerAgent: {fileID: 0} | ||
lifespanSec: 0 | ||
randomSeed: | ||
timeScale: 1 | ||
junitReportPath: | ||
slackToken: | ||
slackChannels: | ||
mentionSubTeamIDs: | ||
addHereInSlackMessage: 0 | ||
handleException: 1 | ||
handleError: 1 | ||
handleAssert: 1 | ||
handleWarning: 0 | ||
ignoreMessages: [] |
8 changes: 8 additions & 0 deletions
8
Tests/TestAssets/AutopilotSettingsForFacingImmediatelyError.asset.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
%YAML 1.1 | ||
%TAG !u! tag:unity3d.com,2011: | ||
--- !u!114 &11400000 | ||
MonoBehaviour: | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
m_GameObject: {fileID: 0} | ||
m_Enabled: 1 | ||
m_EditorHideFlags: 0 | ||
m_Script: {fileID: 11500000, guid: fcc96872a9564f89be6b16a814ad0034, type: 3} | ||
m_Name: StubClickAgentForTests | ||
m_EditorClassIdentifier: | ||
description: | ||
targetName: ThrowErrorFromMainThreadOnClick |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
%YAML 1.1 | ||
%TAG !u! tag:unity3d.com,2011: | ||
--- !u!114 &11400000 | ||
MonoBehaviour: | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
m_GameObject: {fileID: 0} | ||
m_Enabled: 1 | ||
m_EditorHideFlags: 0 | ||
m_Script: {fileID: 11500000, guid: bc82cbd7e5b6404da291e090ed1f4eba, type: 3} | ||
m_Name: StubImmediatelyErrorAgentForTests | ||
m_EditorClassIdentifier: | ||
description: |
8 changes: 8 additions & 0 deletions
8
Tests/TestAssets/StubImmediatelyErrorAgentForTests.asset.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.