/// <summary> /// Retrieves a baseline file. /// </summary> /// <returns>The baseline.</returns> /// <param name="suiteName">Suite name.</param> /// <param name="testType">Test type.</param> /// <param name="inputData">Input data.</param> public ResultsIOData RetrieveBaseline(string suiteName, string testType, ResultsDataCommon inputData) { //string rawJSONdata = LocalIO.Instance.FetchDataFile (suiteName, testType, inputData, true);//fetch string from file ResultsIOData data = LocalIO.Instance.FetchDataFile(suiteName, testType, inputData, true); //JSONHelper.FromJSON (rawJSONdata);//take JSON convert to ResultsIOData //REORG return(data); }
/// <summary> /// Fetchs the local data file. /// </summary> /// <returns>The data file.</returns> /// <param name="suite">Suite.</param> /// <param name="testType">Test type.</param> /// <param name="resultsDataCommon">Results data common.</param> /// <param name="baseline">If set to <c>true</c> baseline.</param> public ResultsIOData FetchDataFile(string suite, string testType, ResultsDataCommon resultsDataCommon, bool baseline) { Console.Instance.Write(DebugLevel.Full, MessageLevel.Log, "Beginning fetch process"); // Write to console string filePath = dataPath + "/" + suite + "/" + resultsDataCommon.Platform + "_" + resultsDataCommon.API + "/" + resultsDataCommon.RenderPipe + "/" + testType; string fileName = "_" + resultsDataCommon.GroupName + "_" + resultsDataCommon.TestName + ".txt"; if (baseline) { fileName = baselinePrefix + fileName; } else { fileName = resultsCurrentPrefix + fileName; } if (!Directory.Exists(filePath)) { Console.Instance.Write(DebugLevel.Critical, MessageLevel.Log, "Directory for baseline does not exist, please pull latest baselines or create them"); // Write to console return(null); } else { Console.Instance.Write(DebugLevel.Full, MessageLevel.Log, "Directory for baseline exists, attempting to fetch requested baseline"); // Write to console if (!File.Exists(filePath + "/" + fileName)) { Console.Instance.Write(DebugLevel.Full, MessageLevel.Log, "Baseline file does not exist for the requested test, please make sure you pull the latest or create them"); // Write to console return(null); } else { string[] fileLines = File.ReadAllLines(filePath + "/" + fileName); return(ResultsIO.Instance.GenerateRIOD(fileLines, suite, testType)); } } }
/// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ /// Writing data - TODO wip /// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ /// <summary> /// Writes the data files. /// </summary> /// <returns>The data files.</returns> /// <param name="suite">Suite.</param> /// <param name="testType">Test type.</param> /// <param name="resultIOdata">Result I odata.</param> /// <param name="data">Data.</param> /// <param name="filetype">Filetype.</param> public IEnumerator WriteDataFiles(ResultsIOData resultIOdata, fileType filetype) { if (resultIOdata.resultsRow.Count != 0) { string suite = resultIOdata.suite; string testType = resultIOdata.testType; ResultsDataCommon common = ResultsIO.Instance.GenerateRDC(resultIOdata.resultsRow[0].resultsColumn.ToArray()); string[] fields = resultIOdata.fieldNames.ToArray(); Console.Instance.Write(DebugLevel.File, MessageLevel.Log, "Beginning to write data for suite " + suite + " of the testType " + testType + " which contains " + resultIOdata.resultsRow.Count + " files to write"); // Write to console string platformAPI = common.Platform + "_" + common.API; string filePath = CreateDataDirectory(suite, platformAPI, common.RenderPipe, testType); string prefix = ""; int suiteBaselineDataIndex = -1; if (filetype == fileType.Baseline) { //if it's a baseline file we need to update latest baseline timesstamp prefix = baselinePrefix; ResultsIO.Instance.UpdateBaselineDictionary(suite, common.Platform, common.API, common.RenderPipe, out suiteBaselineDataIndex); } else { prefix = resultsCurrentPrefix; } List <string> data = new List <string>(); //list to create string for local file //iterate through all the results in the current ResultsIOData for (int i = 0; i < resultIOdata.resultsRow.Count; i++) { common = ResultsIO.Instance.GenerateRDC(resultIOdata.resultsRow[i].resultsColumn.ToArray()); data.Clear(); //clear data for new file for (int f = 0; f < fields.Length; f++) { //adding the data(values) and fields together data.Add(fields[f]); //add the field name data.Add(resultIOdata.resultsRow[i].resultsColumn[f]); //add the value } if (!Directory.Exists(filePath)) // check to see ig folder exists if not create it { Directory.CreateDirectory(filePath); } string fileName = prefix + "_" + common.GroupName + "_" + common.TestName + ".txt"; //name the file File.WriteAllLines(filePath + "/" + fileName, data.ToArray()); //write the contents of data line by line while (!File.Exists(filePath + "/" + fileName)) { Console.Instance.Write(DebugLevel.File, MessageLevel.Log, "Writing..."); // Write to console yield return(new WaitForEndOfFrame()); } //update baseline dictionary(not a dictionary) if baseline if (filetype == fileType.Baseline) { ResultsIO.Instance.BaselineDictionaryEntry(suiteBaselineDataIndex, testType, common.GroupName, common.TestName, common.DateTime); } } Console.Instance.Write(DebugLevel.Full, MessageLevel.Log, "Wrote " + resultIOdata.resultsRow.Count + " files to disk"); // Write to console //Write baseline dictionary for suite and update timestamp TODO might need work/tweaking if (filetype == fileType.Baseline) { yield return(StartCoroutine(UpdateSuiteDataFiles())); } yield return(null); } }
public ResultsDataCommon SwitchPlatformAPI(string platform, string api) { ResultsDataCommon output = this.Clone(); output.Platform = platform; output.API = api; return(output); }
/// <summary> /// Fetchs the local data file. /// </summary> /// <returns>The data file.</returns> /// <param name="suite">Suite.</param> /// <param name="testType">Test type.</param> /// <param name="resultsDataCommon">Results data common.</param> /// <param name="baseline">If set to <c>true</c> baseline.</param> public ResultsIOData FetchDataFile(string suite, string testType, ResultsDataCommon resultsDataCommon, bool baseline, bool full) { Console.Instance.Write(DebugLevel.Full, MessageLevel.Log, "Beginning fetch process"); // Write to console string filePath = dataPath + "/" + suite + "/" + resultsDataCommon.Platform + "_" + resultsDataCommon.API + "/" + resultsDataCommon.RenderPipe + "/" + testType; string fileName = "_" + resultsDataCommon.GroupName + "_" + resultsDataCommon.TestName + ".txt"; if (baseline) { fileName = baselinePrefix + fileName; } else { fileName = resultsCurrentPrefix + fileName; } if (!Directory.Exists(filePath)) { Console.Instance.Write(DebugLevel.Critical, MessageLevel.Log, "Directory for baseline does not exist:" + filePath); // Write to console return(null); } else { Console.Instance.Write(DebugLevel.Full, MessageLevel.Log, "Directory for baseline exists, attempting to fetch requested baseline"); // Write to console if (!File.Exists(filePath + "/" + fileName)) { Console.Instance.Write(DebugLevel.Full, MessageLevel.Log, "Baseline file does not exist for the requested test:" + filePath + "/" + fileName); // Write to console return(null); } else { string[] fileLines; if (!full) { fileLines = File.ReadAllLines(filePath + "/" + fileName); List <string> lines = new List <string>(); int commonEnd = 0; for (int i = 0; i < fileLines.Length; i++) { if (commonEnd == 0) { lines.Add(fileLines[i]); } if (fileLines[i] == "Custom" && i % 2 == 0) { commonEnd = 1; } } fileLines = lines.ToArray(); } else { fileLines = File.ReadAllLines(filePath + "/" + fileName); } return(ResultsIO.Instance.GenerateRIOD(fileLines, suite, testType)); } } }
// ------------------------------------------------------------------------------------ // Test Type Specific Methods // Just get some dummy result data for the example ExampleResults GetDummyData(ResultsDataCommon common) { ExampleResults output = new ExampleResults(); output.common = common; output.SomeFloat = UnityEngine.Random.value; output.SomeInt = Mathf.RoundToInt(output.SomeFloat); return(output); }
// Update is called once per frame public void UpdateInformation() { sysCommonData = Common.GetCommonResultsData(); foreach (InformationEntry ie in informationEntries) { switch (ie.source) { case InformationSource.SystemData: { PopulateInfo(ie.text, FetchInfo(ie.fields, ie.split, ie.splitIndex)); break; } case InformationSource.CommonData: { PopulateInfo(ie.text, FetchInfo(ie.fields, ie.split, ie.splitIndex)); break; } case InformationSource.AlternativeBaseline: { AltBaselineSettings altSettings = Master.Instance.GetCurrentPlatformAPI(); if (ie.fields == CommonFields.Platform) { ie.text.text = altSettings.Platform; if (altSettings.Platform != sysCommonData.Platform) { ie.text.color = Color.yellow; } else { ie.text.color = Color.white; } } else if (ie.fields == CommonFields.API) { ie.text.text = altSettings.API; if (altSettings.API != sysCommonData.API) { ie.text.color = Color.yellow; } else { ie.text.color = Color.white; } } else { ie.text.text = "N/A"; ie.text.color = Color.red; } break; } } } }
// Logic for creating results data (mandatory override) public override IEnumerator ProcessResult() { var typedSettings = (FrameComparisonSettings)model.settings; // Set settings to local type if (!typedSettings.useBackBuffer) { typedSettings.captureCamera.targetTexture = temporaryRt; // Set capture cameras target texture to temporary RT (logic specific) dummyCamera.enabled = true; } else { ProgressScreen.Instance.progressObject.SetActive(false); // Hide the UI breifly to do the capture menuCamera.enabled = false; } var m_TempData = (FrameComparisonResults)GetResultsStruct(); // Get a results struct (mandatory) yield return(WaitForTimer()); // Wait for timer if (typedSettings.useBackBuffer) { if (Debug.developerConsoleVisible) { Debug.ClearDeveloperConsole(); // Clear the dev console if it's visible before capturing the backbuffer. } BackBufferCapture(); } else { doCapture = true; // Perform OnRenderImage logic (logic specific) } do { yield return(null); } while (resultsTexture == null); // Wait for OnRenderImage logic to complete (logic specific) m_TempData.resultFrame = Common.ConvertTextureToString(resultsTexture, typedSettings.imageQuality); // Convert results texture to Base64 String and save to results data if (baselineExists) // Comparison (mandatory) { AltBaselineSettings altBaselineSettings = Master.Instance.GetCurrentPlatformAPI(); // current chosen API/plafrom ResultsDataCommon m_BaselineData = m_TempData.common.SwitchPlatformAPI(altBaselineSettings.Platform, altBaselineSettings.API); // makes new ResultsDataCommon to grab baseline FrameComparisonResults referenceData = (FrameComparisonResults)DeserializeResults(ResultsIO.Instance.RetrieveEntry(suiteName, testTypeName, m_BaselineData, true, true)); // Deserialize baseline data (mandatory) m_TempData.common.PassFail = GetComparisonResult(m_TempData, referenceData); // Get comparison results } if (typedSettings.useBackBuffer) { ProgressScreen.Instance.progressObject.SetActive(true); // Show progress screen again menuCamera.enabled = true; } else { dummyCamera.enabled = false; } Cleanup(); // Cleanup (logic specific) BuildResultsStruct(m_TempData); // Submit (mandatory) }
ResultsDataCommon BuildResultsDataCommon(string sceneName, string testName, string pipeline) { ResultsDataCommon common = new ResultsDataCommon(); SystemData systemData = Master.Instance.GetSystemData(); common.Platform = systemData.Platform; common.API = systemData.API; common.RenderPipe = pipeline; common.GroupName = sceneName; common.TestName = testName; return(common); }
ResultsDataCommon BuildResultsDataCommon(string sceneName, string testName) { ResultsDataCommon common = new ResultsDataCommon(); SystemData systemData = Master.Instance.GetSystemData(); common.Platform = systemData.Platform; common.API = systemData.API; common.RenderPipe = "Standard Legacy"; // TODO - Implement SRP support common.GroupName = sceneName; common.TestName = testName; return(common); }
//Convert list of strings to ResultsDataCommon public ResultsDataCommon GenerateRDC(string[] inputData) { var common = new ResultsDataCommon(); //blank common data BindingFlags bindingFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static; FieldInfo[] commonFields = typeof(ResultsDataCommon).GetFields(bindingFlags); for (int cf = 0; cf < commonFields.Length; cf++) { string value = inputData[cf]; FieldInfo fieldInfo = common.GetType().GetField(commonFields[cf].Name); fieldInfo.SetValue(common, Convert.ChangeType(value, fieldInfo.FieldType)); } return(common); }
// ------------------------------------------------------------------------------------ // Comparison Methods // Get comparison data public object ProcessComparison(ResultsBase resultsData) { AltBaselineSettings altBaselineSettings = Master.Instance.GetCurrentPlatformAPI(); // current chosen API/plafrom ResultsDataCommon m_BaselineData = resultsData.common.SwitchPlatformAPI(altBaselineSettings.Platform, altBaselineSettings.API); // makes new ResultsDataCommon to grab baseline ResultsIOData baselineFetch = ResultsIO.Instance.RetrieveEntry(suiteName, testTypeName, m_BaselineData, true, true); // Get baseline data if (baselineFetch != null) // If successful { ResultsBase baselineData = (ResultsBase)DeserializeResults(baselineFetch); // Convert to results class return(ProcessComparison(baselineData, resultsData)); // Process comparison } else { return(null); // Return fail } }
// ------------------------------------------------------------------------------------ // Get Common Data // Get common data about platform and version public static ResultsDataCommon GetCommonResultsData() { Console.Instance.Write(DebugLevel.Full, MessageLevel.Log, "Getting common results data"); // Write to console ResultsDataCommon output = new ResultsDataCommon(); // Create new class instance output.DateTime = Master.Instance.GetSystemTime().ToString(dateTimeFormat); // Get SystemTime from Master SystemData systemData = Master.Instance.GetSystemData(); // Get SystemData from Master output.UnityVersion = systemData.UnityVersion; // Extract from SystemData output.AppVersion = systemData.AppVersion; // Extract from SystemData output.OS = systemData.OS; // Extract from SystemData output.Device = systemData.Device; // Extract from SystemData output.Platform = systemData.Platform; // Extract from SystemData output.API = systemData.API; // Extract from SystemData output.RenderPipe = GetRenderPipelineName(); // Get the currently assigned pipeline output.Custom = ""; // Futureproof return(output); // Return }
// Logic for creating results data public override IEnumerator ProcessResult() { var m_TempData = (ExampleResults)GetResultsStruct(); // Must get results struct and cast to this logics results type (mandatory) yield return(WaitForTimer()); // Wait for timer var typedSettings = (ExampleSettings)model.settings; // Set settings to local type (mandatory) m_TempData = GetDummyData(m_TempData.common); // Just get some dummy data for the example (logic specific) if (baselineExists) // Comparison (mandatory) { AltBaselineSettings altBaselineSettings = Master.Instance.GetCurrentPlatformAPI(); // current chosen API/plafrom ResultsDataCommon m_BaselineData = m_TempData.common.SwitchPlatformAPI(altBaselineSettings.Platform, altBaselineSettings.API); // makes new ResultsDataCommon to grab baseline ExampleResults referenceData = (ExampleResults)DeserializeResults(ResultsIO.Instance.RetrieveEntry(suiteName, testTypeName, m_TempData.common, true, true)); // Deserialize baseline data (mandatory) m_TempData.common.PassFail = GetComparisonResult(m_TempData, referenceData); // Get comparison results } BuildResultsStruct(m_TempData); // Submit (mandatory) }
public ResultsDataCommon Clone() { ResultsDataCommon output = new ResultsDataCommon(); output.DateTime = this.DateTime; output.UnityVersion = this.UnityVersion; output.AppVersion = this.AppVersion; output.OS = this.OS; output.Device = this.Device; output.Platform = this.Platform; output.API = this.API; output.RenderPipe = this.RenderPipe; output.GroupName = this.GroupName; output.TestName = this.TestName; output.PassFail = this.PassFail; output.Custom = this.Custom; return(output); }
// ------------------------------------------------------------------------------------ // Serialization // TODO - Clean and comment (DANGER) // Deserialize ResultsIOData(string arrays) to ResultsData(class) public override object DeserializeResults(ResultsIOData resultsIOData) { //var resultData = Convert.ChangeType(activeBaselineData, results); // Create instance (Old - Used from base class) ResultsBase resultData = (R)Activator.CreateInstance(results); // Create instance var common = new ResultsDataCommon(); //blank common data BindingFlags bindingFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static; FieldInfo[] commonFields = typeof(ResultsDataCommon).GetFields(bindingFlags); FieldInfo[] customFields = results.GetFields(bindingFlags); List <string> commonDataRaw = resultsIOData.resultsRow[0].resultsColumn.GetRange(0, commonFields.Length); List <string> resultsDataRaw = resultsIOData.resultsRow[0].resultsColumn.GetRange(commonFields.Length, resultsIOData.resultsRow[0].resultsColumn.Count - (commonFields.Length)); for (int f = 0; f < customFields.Length; f++) { if (f == 0) { //do the common class for (int cf = 0; cf < commonFields.Length; cf++) { string value = commonDataRaw[cf]; FieldInfo fieldInfo = common.GetType().GetField(commonFields[cf].Name); fieldInfo.SetValue(common, Convert.ChangeType(value, fieldInfo.FieldType)); } } else { var value = resultsDataRaw[(f) - 1]; FieldInfo fieldInfo = resultData.GetType().GetField(customFields[0].Name); // TODO - Why did this become 0? if (fieldInfo.FieldType.IsArray) // This handles arrays { Type type = resultData.GetType().GetField(customFields[f].Name).FieldType.GetElementType(); GenerateGenericArray(fieldInfo, resultData.GetType(), resultData, type, value); } else // Non array types { fieldInfo.SetValue(resultData, Convert.ChangeType(value, fieldInfo.FieldType)); } } } resultData.common = common; // Assign common return(resultData); }
/// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ /// Getters /// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ public IEnumerator FetchSpecificEntry(ResultsIOData inputData, Action <ResultsIOData> outdata) { ResultsIOData data = new ResultsIOData();//ResultsIOData to send back to resultsIO for local processing string suite = inputData.suite; string testType = inputData.testType; List <string> common = inputData.resultsRow[0].resultsColumn; common.Add(""); ResultsDataCommon RDC = GenerateRDC(common.ToArray()); ResultsIOData localData = LocalIO.Instance.FetchDataFile(suite, testType, RDC, inputData.baseline, true); if (localData == null) { yield return(StartCoroutine(SQL.SQLIO.FetchSpecificEntry(inputData, (value => { data = value; })))); } else { data = localData; } outdata(data); }
// ------------------------------------------------------------------------------------ // Execution Overrides // Logic for creating results data (mandatory override) public override IEnumerator ProcessResult() { var m_TempData = (AverageFrameTimeResults)GetResultsStruct(); // Get a results struct (mandatory) var typedSettings = (AverageFrameTimeSettings)model.settings; // Set settings to local type yield return(WaitForTimer()); // Wait for timer Timestamp(false); // Perform a timestamp (logic specific) for (int i = 0; i < typedSettings.sampleFrames; i++) // Wait for requested sample frame count (logic specific) { yield return(new WaitForEndOfFrame()); } m_TempData.avgFrameTime = Timestamp(true); // Perform a timestamp (logic specific) if (baselineExists) // Comparison (mandatory) { AltBaselineSettings altBaselineSettings = Master.Instance.GetCurrentPlatformAPI(); // current chosen API/plafrom ResultsDataCommon m_BaselineData = m_TempData.common.SwitchPlatformAPI(altBaselineSettings.Platform, altBaselineSettings.API); // makes new ResultsDataCommon to grab baseline AverageFrameTimeResults referenceData = (AverageFrameTimeResults)DeserializeResults(ResultsIO.Instance.RetrieveEntry(suiteName, testTypeName, m_BaselineData, true, true)); // Deserialize baseline data (mandatory) m_TempData.common.PassFail = GetComparisonResult(m_TempData, referenceData); // Get comparison result } BuildResultsStruct(m_TempData); // Submit (mandatory) }
static ResultsDataCommon ArrayToResultsDataCommon(string[] splitData) { ResultsDataCommon RDC = new ResultsDataCommon(); for (int i = 0; i < splitData.Length; i++) { switch (i) { case 1: RDC.DateTime = splitData [i]; break; case 3: RDC.UnityVersion = splitData [i]; break; case 5: RDC.AppVersion = splitData [i]; break; case 7: RDC.OS = splitData [i]; break; case 9: RDC.Device = splitData [i]; break; case 11: RDC.Platform = splitData [i]; break; case 13: RDC.API = splitData [i]; break; case 15: RDC.RenderPipe = splitData [i]; break; case 17: RDC.GroupName = splitData [i]; break; case 19: RDC.TestName = splitData [i]; break; case 21: RDC.PassFail = bool.Parse(splitData [i]); break; case 23: RDC.Custom = splitData [i]; break; default: break; } } return(RDC); }
// ------------------------------------------------------------------------------------ // Serialization // TODO - Clean and comment (DANGER) // Serialize ResultsData(class) to ResultsIOData(string arrays) public ResultsIOData SerializeResults() { ResultsIOData output = new ResultsIOData(); output.resultsRow.Add(new ResultsIORow()); BindingFlags bindingFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static; FieldInfo[] commonFields = typeof(ResultsDataCommon).GetFields(bindingFlags); FieldInfo[] customFields = results.GetFields(bindingFlags); //Store field names into the ResultsIOData for (int f = 0; f < commonFields.Length; f++) { output.fieldNames.Add(commonFields[f].Name); } for (int f = 0; f < customFields.Length - 1; f++) { output.fieldNames.Add(customFields[f].Name); } output.resultsRow[0].resultsColumn = new List <string>(); ResultsDataCommon resultsCommonTemplate = new ResultsDataCommon(); for (int f = 0; f < commonFields.Length; f++) { var typedResult = Convert.ChangeType(activeResultData, results); // TODO - Why does this work... FieldInfo typedCommonField = typedResult.GetType().GetField("common"); // TODO - Why does this work... var typedCommonValue = Convert.ChangeType(typedCommonField.GetValue(typedResult), resultsCommonTemplate.GetType()); // TODO - Why does this work... var commonResult = typedCommonValue.GetType().GetField(commonFields[f].Name).GetValue(typedCommonValue); output.resultsRow[0].resultsColumn.Add(commonResult.ToString()); } for (int f = 0; f < customFields.Length - 1; f++) { var customResult = activeResultData.GetType().GetField(customFields[f].Name).GetValue(activeResultData); if (activeResultData.GetType().GetField(customFields[f].Name).FieldType.IsArray) //If its an array (tough to handle) { Array a = (Array)activeResultData.GetType().GetField(customFields[f].Name).GetValue(activeResultData); if (a != null) // Null check incase custom results werent set on an array { string[] stringArray = new string[a.Length]; for (int i = 0; i < a.Length; i++) { stringArray[i] = a.GetValue(i).ToString(); } customResult = Common.ConvertStringArrayToString(stringArray); output.resultsRow[0].resultsColumn.Add(customResult.ToString()); } else // Write blank when custom results werent set on an array { customResult = ""; } } else if (customResult != null) //If its a non-array type that has had values set { output.resultsRow[0].resultsColumn.Add(customResult.ToString()); } else //If its a non-array type that has not had values set { output.resultsRow[0].resultsColumn.Add(""); } } Console.Instance.Write(DebugLevel.Full, MessageLevel.Log, GetType().Name + " generated resultsIO data"); // Write to console return(output); }
public void SetAndUpdateInformation(ResultsDataCommon rdc) { commmonData = rdc; UpdateInformation(); }
// Generate a list of results based on selected filters public IEnumerator GenerateFilteredResultList() { Console.Instance.Write(DebugLevel.Full, MessageLevel.Log, "Filtering results"); // Write to console filteredResultsEntries.Clear(); // Clear current TestStructure.Structure structure = TestStructure.Instance.GetStructure(); // Get structure for (int su = 0; su < structure.suites.Count; su++) // Iterate suites { if (su == suitesDropdown.value - 1 || suitesDropdown.value == 0) // If passes suites filter { string suiteName = structure.suites[su].suiteName; // Get suite name for (int ty = 0; ty < structure.suites[su].types.Count; ty++) // Iterate types { int typeIndex = structure.suites[su].types[ty].typeIndex; // Get type index if (typeIndex == typesDropdown.value - 1 || typesDropdown.value == 0) // If passes types filter { string typeName = structure.suites[su].types[ty].typeName; // Get type name for (int gr = 0; gr < structure.suites[su].types[ty].groups.Count; gr++) // Iterate groups { string groupName = structure.suites[su].types[ty].groups[gr].groupName; // Get group name for (int te = 0; te < structure.suites[su].types[ty].groups[gr].tests.Count; te++) // Iterate tests { string testName = structure.suites[su].types[ty].groups[gr].tests[te].testName; // Get test name string scenePath = structure.suites[su].types[ty].groups[gr].tests[te].scenePath; // Get scene path ResultsDataCommon common = BuildResultsDataCommon(groupName, testName); // Build results data common to retrieve results ResultsIOData data = ResultsIO.Instance.RetrieveResult(suiteName, typeName, common); // Retrieve results data if (resultsDropdown.value != 0) // If filtering based on results { int passFail = 2; // Set default state (no results) if (data != null) // If results data exists { passFail = data.resultsRow[0].resultsColumn[21] == "True" ? 0 : 1; // Set pass fail state } switch (resultsDropdown.value) { case 1: // Pass if (passFail == 0) { filteredResultsEntries.Add(new ResultsEntryData(new TestEntry(suiteName, groupName, scenePath, typeName, testName, typeIndex, su, gr, ty, te), data)); // Add to list } break; case 2: // Fail if (passFail == 1) { filteredResultsEntries.Add(new ResultsEntryData(new TestEntry(suiteName, groupName, scenePath, typeName, testName, typeIndex, su, gr, ty, te), data)); // Add to list } break; case 3: // Ran if (passFail != 2) { filteredResultsEntries.Add(new ResultsEntryData(new TestEntry(suiteName, groupName, scenePath, typeName, testName, typeIndex, su, gr, ty, te), data)); // Add to list } break; case 4: // Not Ran if (passFail == 2) { filteredResultsEntries.Add(new ResultsEntryData(new TestEntry(suiteName, groupName, scenePath, typeName, testName, typeIndex, su, gr, ty, te), data)); // Add to list } break; } } else { filteredResultsEntries.Add(new ResultsEntryData(new TestEntry(suiteName, groupName, scenePath, typeName, testName, typeIndex, su, gr, ty, te), data)); // Add to list } yield return(null); } } } } } } }
public void GetSlackResultsMessage() { List <Attachment> attachments = new List <Attachment>(); Attachment attachment = new Attachment("", false); string previousSuiteName = ""; int localTestCount = 0; int localFailCount = 0; int globalTestCount = 0; int globalFailCount = 0; bool resultsFound = false; for (int i = 0; i < TestRunner.Instance.runner.tests.Count; i++) { TestEntry currentEntry = TestRunner.Instance.runner.tests[i]; if (currentEntry.suiteName != previousSuiteName) { previousSuiteName = currentEntry.suiteName; if (resultsFound == true) { attachment.text += "Ran " + localTestCount.ToString() + ", Passed " + (localTestCount - localFailCount).ToString() + ", Failed " + localFailCount.ToString(); attachments.Add(attachment); globalTestCount += localTestCount; globalFailCount += localFailCount; localTestCount = 0; localFailCount = 0; } attachment = new Attachment(currentEntry.suiteName + ": ", true); } ResultsDataCommon common = BuildResultsDataCommon(currentEntry.groupName, currentEntry.testName); // Build results data common to retrieve results ResultsIOData data = ResultsIO.Instance.RetrieveResult(currentEntry.suiteName, currentEntry.typeName, common); // Retrieve results data if (data != null) { resultsFound = true; localTestCount++; //search for PassFail field to avoid hardcoding int passFailIndex = -1; for (int f = 0; f < data.fieldNames.Count; f++) { if (data.fieldNames [f] == "PassFail") { passFailIndex = f; } } if (data.resultsRow[0].resultsColumn[passFailIndex] == "False") { localFailCount++; attachment.passFail = false; } } } if (TestRunner.Instance.runner.tests.Count > 0) { attachment.text += "Ran " + localTestCount.ToString() + ", Passed " + (localTestCount - localFailCount).ToString() + ", Failed " + localFailCount.ToString(); attachments.Add(attachment); globalTestCount += localTestCount; globalFailCount += localFailCount; } SystemData sysData = Master.Instance.GetSystemData(); string message = "*UTF completed run. Ran " + globalTestCount.ToString() + ", Passed " + (globalTestCount - globalFailCount).ToString() + ", Failed " + globalFailCount.ToString() + "*" + Environment.NewLine + "_" + sysData.Device + "_" + Environment.NewLine + "_" + sysData.Platform + " - " + sysData.API + "_" + Environment.NewLine + "_" + sysData.UnityVersion + "_"; Attachment[] attachmentArray = attachments.ToArray(); currentMessage = new Message(message, attachmentArray); }