PlayModeRunnerCallback.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using NUnit.Framework;
  2. using NUnit.Framework.Interfaces;
  3. namespace UnityEngine.TestTools.TestRunner.Callbacks
  4. {
  5. [AddComponentMenu("")]
  6. internal class PlayModeRunnerCallback : MonoBehaviour, ITestRunnerListener
  7. {
  8. private TestResultRenderer m_ResultRenderer;
  9. public void RunFinished(ITestResult testResults)
  10. {
  11. Application.logMessageReceivedThreaded -= LogRecieved;
  12. if (Camera.main == null)
  13. {
  14. gameObject.AddComponent<Camera>();
  15. }
  16. m_ResultRenderer = new TestResultRenderer(testResults);
  17. m_ResultRenderer.ShowResults();
  18. }
  19. public void TestFinished(ITestResult result)
  20. {
  21. }
  22. public void OnGUI()
  23. {
  24. if (m_ResultRenderer != null)
  25. m_ResultRenderer.Draw();
  26. }
  27. public void RunStarted(ITest testsToRun)
  28. {
  29. Application.logMessageReceivedThreaded += LogRecieved;
  30. }
  31. public void TestStarted(ITest test)
  32. {
  33. }
  34. private void LogRecieved(string message, string stacktrace, LogType type)
  35. {
  36. if (TestContext.Out != null)
  37. TestContext.Out.WriteLine(message);
  38. }
  39. }
  40. }