ProfileAnalyzerCaptureTests.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. using NUnit.Framework;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine.TestTools;
  5. using UnityEditor;
  6. using UnityEditorInternal;
  7. public class ProfileAnalyzerCaptureTests : ProfileAnalyzerBaseTest
  8. {
  9. [UnityTest]
  10. public IEnumerator PlayMode_Capture_ContainsNoDuplicates()
  11. {
  12. StartProfiler();
  13. yield return null;
  14. yield return null;
  15. yield return null;
  16. yield return null;
  17. yield return null;
  18. StopProfiler();
  19. // Seem to need one more frame to get the data transfered over so the profile analyzer can pull it.
  20. yield return null;
  21. //analyze the data
  22. m_SetupData.profileData = m_SetupData.profilerWindowInterface.PullFromProfiler(m_SetupData.firstFrame, m_SetupData.lastFrame);
  23. var analysis = GetAnalysisFromFrameData(m_SetupData.profileData);
  24. var analysisMarkers = analysis.GetMarkers();
  25. var analysisMarkerDict = new Dictionary<string, int>();
  26. for (int i = 0; i < analysisMarkers.Count; ++i)
  27. {
  28. int count = 0;
  29. string curName = analysisMarkers[i].name;
  30. analysisMarkerDict.TryGetValue(curName, out count);
  31. analysisMarkerDict[curName] = count + 1;
  32. }
  33. Assert.IsTrue(0 != analysisMarkerDict.Count, "analysisMarkerSet count is zero!");
  34. foreach (var entry in analysisMarkerDict)
  35. {
  36. Assert.IsTrue(1 == entry.Value, "Duplicates found in analysis marker list: " + entry.Key);
  37. }
  38. }
  39. }