예제 #1
0
        // Setup the results context object
        public override void SetupResultsContext(ResultsContext context, ResultsIOData inputData, ResultsIOData inputDataB)
        {
            CleanupResultsContext();
            FrameComparisonResults inputResults = (FrameComparisonResults)logic.DeserializeResults(inputData); // Deserialize input and cast to typed results

            if (TestRunner.Instance)
            {
                if (!TestRunner.Instance.isAnalytic)
                {
                    comparisonData = (FrameComparisonComparison)logic.ProcessComparison(inputResults); // Get comparison data
                }
                else
                {
                    FrameComparisonResults inputResultsB = (FrameComparisonResults)logic.DeserializeResults(inputDataB); // Deserialize input and cast to typed results
                    comparisonData = (FrameComparisonComparison)logic.ProcessComparison(inputResultsB, inputResults);
                }
            }
            else
            {
                comparisonData = (FrameComparisonComparison)logic.ProcessComparison(inputResults);        // Get comparison data
            }
            buttons = new Button[3];                                                                      // Create button array
            for (int i = 0; i < buttons.Length; i++)                                                      // Iterate
            {
                buttons[i] = context.objects[i].GetComponent <Button>();                                  // Get the button
                int index = i;                                                                            // Set this so delegate doesnt get reference that iterates
                buttons[i].onClick.AddListener(delegate { SetTextureContext(comparisonData, index); });   // Add listener
            }
            resultsContextImage = context.objects[3].GetComponent <RawImage>();                           // Get image
            context.objects[4].GetComponent <Text>().text = comparisonData.DiffPercentage.ToString("N4"); // Set diff to field
            SetTextureContext(comparisonData, 0);                                                         // Set default
        }
예제 #2
0
        /// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------
        /// Converting to JSON
        /// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------

        /// <summary>
        /// Converts a ResultsIO class
        /// </summary>
        /// <returns>The JSO.</returns>
        /// <param name="inputData">Input data.</param>
        public static string[] ToJSON(ResultsIOData inputData)
        {
            if (inputData.resultsRow.Count <= 1)
            {
                Debug.LogWarning("Invalid ResultsIOData sent to Serializer");
                return(null);
            }
            else
            {
                string[] output      = new string[inputData.resultsRow.Count];
                string[] tableLabels = new string[inputData.resultsRow [0].resultsColumn.Count];
                for (int i = 0; i < tableLabels.Length; i++)                // column labels in string array
                {
                    tableLabels [i] = inputData.resultsRow [0].resultsColumn [i];
                }
                for (int rows = 0; rows < inputData.resultsRow.Count; rows++)
                {
                    output [rows] = "{";
                    for (int columns = 0; columns < inputData.resultsRow [rows].resultsColumn.Count; columns++)
                    {
                        string value = inputData.resultsRow [rows].resultsColumn [columns];
                        string s     = "\"" + inputData.resultsRow [0].resultsColumn [columns] + "\":\"" + value + "\"";
                        if (columns < inputData.resultsRow [0].resultsColumn.Count - 1)
                        {
                            s += ",";
                        }
                        output [rows] += s;
                    }
                    output [rows] += "}";
                }
                Console.Instance.Write(DebugLevel.Full, MessageLevel.Log, "Converted to JSON");                  // Write to console
                return(output);
            }
        }
예제 #3
0
        /// <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);
        }
예제 #4
0
        // ------------------------------------------------------------------------------------
        // Test Execution

        // Use local result in Manual mode if it exists
        public override void UseLocalResult(ResultsIOData localResult)
        {
            ResultsBase typedResult = (R)DeserializeResults(localResult); // Deserialize result to typed

            activeResultData = typedResult;                               // Set to active results
            EndTest();                                                    // End test
        }
예제 #5
0
        // Create and expand context object
        IEnumerator ExpandContextObject(ResultsEntry inputEntry, TestDisplayBase display)
        {
            Console.Instance.Write(DebugLevel.Full, MessageLevel.Log, "Expanding context object");                                                                 // Write to console
            int entryIndex = FindEntryInDetailedResultsList(inputEntry);                                                                                           // Get index of selected entry

            activeContextEntry  = inputEntry;                                                                                                                      // Track selected entry
            activeContextObject = Instantiate(display.resultsContextPrefab, listContentRect, false);                                                               // Create context object instance
            RectTransform contextObjectRect = activeContextObject.GetComponent <RectTransform>();                                                                  // Get rect

            contextObjectRect.anchoredPosition = new Vector2(0, (entryIndex + 1) * -listEntries[0].GetComponent <RectTransform>().sizeDelta.y);                    // Set position
            listContentRect.sizeDelta          = new Vector2(listContentRect.sizeDelta.x, listContentRect.sizeDelta.y + contextObjectRect.sizeDelta.y);            // Set size
            NudgeDetailedResultsListEntries(entryIndex, -contextObjectRect.sizeDelta.y);                                                                           // Nudge entries
            ResultsContext resultsContext = activeContextObject.GetComponent <ResultsContext>();                                                                   // Get results context reference

            resultsContext.Setup(activeContextEntry);                                                                                                              // Setup base of results context
            ResultsIOData resultsDataFull = new ResultsIOData();                                                                                                   // Create output data

            yield return(StartCoroutine(ResultsIO.Instance.FetchSpecificEntry(inputEntry.resultsEntryData.resultsData, (value => { resultsDataFull = value; })))); // Get full results data // SQLCHECK

            ResultsIOData resultsDataFullB = new ResultsIOData();                                                                                                  // Create output data

            if (TestRunner.Instance)
            {
                if (TestRunner.Instance.runnerType == RunnerType.Analytic)
                {
                    yield return(StartCoroutine(SQL.SQLIO.FetchBaseline(inputEntry.resultsEntryData.resultsDataB, (value => { resultsDataFullB = value; })))); // Get full results data // SQLCHECK
                }
                else if (TestRunner.Instance.runnerType == RunnerType.AnalyticComparison)
                {
                    yield return(StartCoroutine(ResultsIO.Instance.FetchSpecificEntry(inputEntry.resultsEntryData.resultsDataB, (value => { resultsDataFullB = value; })))); // Get full results data // SQLCHECK
                }
            }
            //if(inputEntry.resultsEntryData.resultsDataB != null)
            display.SetupResultsContext(resultsContext, resultsDataFull, resultsDataFullB); // Tell Display how to setup the results context
        }
예제 #6
0
        /// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------
        /// 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);
            }
        }
예제 #7
0
        // ------------------------------------------------------------------------------------
        // ResultsViewer

        // Setup the results context object
        public override void SetupResultsContext(ResultsContext context, ResultsIOData inputData)
        {
            AverageFrameTimeResults inputResults = (AverageFrameTimeResults)logic.DeserializeResults(inputData);                               // Deserialize input and cast to typed results

            AverageFrameTimeLogic.ComparisonData comparisonData = (AverageFrameTimeLogic.ComparisonData)logic.GetComparisonData(inputResults); // Get comparison data
            context.objects[0].GetComponent <Text>().text = inputResults.avgFrameTime.ToString();                                              // Set average frame time
            context.objects[1].GetComponent <Text>().text = comparisonData.delta.ToString();                                                   // Set delta
        }
예제 #8
0
        // ------------------------------------------------------------------------------------
        // ResultsViewer

        // ------------------------------------------------------------------------------------
        // This sections controls customizing the ResultsViewers context object for this test type
        //
        // Mandatory overrides:
        // - SetupResultsContext
        // This method lets you specify the content of the results viewer context object
        // Input is an array of game object references
        // Context object contents are unique to the test type
        //
        // These method calls are already wrapped in debugs and as such do not require debugs inside them
        // However, should you want to add further debugs please use Console.Write()

        // Setup the results context object
        public override void SetupResultsContext(ResultsContext context, ResultsIOData inputData)
        {
            ExampleResults inputResults = (ExampleResults)logic.DeserializeResults(inputData);                               // Deserialize input and cast to typed results

            ExampleLogic.ComparisonData comparisonData = (ExampleLogic.ComparisonData)logic.GetComparisonData(inputResults); // Get comparison data
            context.objects[0].GetComponent <Text>().text = inputResults.SomeFloat.ToString();                               // Set float
            context.objects[1].GetComponent <Text>().text = comparisonData.SomeFloatDiff.ToString();                         // Set diff
        }
예제 #9
0
        // Submit results data to ResultsIO
        public void SubmitResults(int baseline)
        {
            ProgressScreen.Instance.SetState(true, ProgressType.LocalSave, "Submitting results");                                                           // Enable ProgressScreen
            ResultsIOData output = SerializeResults();                                                                                                      // Serialize activeResultsData

            Console.Instance.Write(DebugLevel.Logic, MessageLevel.Log, this.GetType().Name + " sending data to ResultsIO for " + activeTestEntry.testName); // Write to console
            StartCoroutine(ResultsIO.Instance.ProcessResults(activeTestEntry.suiteName, activeTestEntry.typeName /*testTypeName*/, output, baseline));      // Send data to ResultsIO
        }
예제 #10
0
 // Return an ResultsCommon index from a Field Name input
 public static int FindResultsDataIOFieldIdByName(ResultsIOData results, string name)
 {
     for (int i = 0; i < results.fieldNames.Count; i++) // Iterate field names
     {
         if (results.fieldNames[i] == name)             // If matches query
         {
             return(i);                                 // Return
         }
     }
     return(-1); // Fail
 }
예제 #11
0
        // ------------------------------------------------------------------------------------
        // Comparison Methods

        // Get comparison data
        public object GetComparisonData(ResultsBase resultsData)
        {
            ResultsIOData baselineFetch = ResultsIO.Instance.RetrieveBaseline(suiteName, testTypeName, resultsData.common); // 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
            }
        }
예제 #12
0
        // ------------------------------------------------------------------------------------
        // 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
            }
        }
예제 #13
0
        //Generates a single result from a string array to a ResultsIOData
        public ResultsIOData GenerateRIOD(string[] inputData, string suite, string testType)
        {
            ResultsIOData RD  = new ResultsIOData();
            ResultsIORow  row = new ResultsIORow();

            row.resultsColumn = new List <string> ();
            RD.resultsRow.Add(row);
            RD.suite    = suite;
            RD.testType = testType;

            for (int i = 0; i < inputData.Length / 2; i++)
            {
                RD.fieldNames.Add(inputData[i * 2]);
                RD.resultsRow [0].resultsColumn.Add(inputData [(i * 2) + 1]);
            }
            return(RD);
        }
예제 #14
0
        // Analytic comparson logic
        public override IEnumerator ProcessAnalyticComparison()
        {
            ResultsIOData resultsA = new ResultsIOData();                                                                                                                 // Create results A

            yield return(StartCoroutine(SQL.SQLIO.FetchSpecificEntry(TestStructure.Instance.RequestAnalyticData(0, activeTestEntry), (value => { resultsA = value; })))); // Get full results A // SQLCHECK

            var           rawResultsA = (R)DeserializeResults(resultsA);                                                                                                  // Deserialize
            ResultsIOData resultsB    = new ResultsIOData();                                                                                                              // Create results A

            yield return(StartCoroutine(SQL.SQLIO.FetchSpecificEntry(TestStructure.Instance.RequestAnalyticData(1, activeTestEntry), (value => { resultsB = value; })))); // Get full results A // SQLCHECK

            var  rawResultsB = (R)DeserializeResults(resultsB);                                                                                                           // Deserialize
            bool passFail    = GetComparisonResult(rawResultsA, rawResultsB);                                                                                             // Get Comparison result

            resultsA.resultsRow[0].resultsColumn[Common.FindResultsDataIOFieldIdByName(resultsA, "PassFail")] = passFail.ToString();                                      // Set pass fail
            EndTest();                                                                                                                                                    // End test
        }
예제 #15
0
        // ------------------------------------------------------------------------------------
        // 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);
        }
예제 #16
0
        /// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------
        /// Processing fresh test data
        /// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------

        /// <summary>
        /// Processes the results, saving local txt files and pushing to cloud.
        /// </summary>
        /// <param name="suiteName">Suite name.</param>
        /// <param name="testType">Test type.</param>
        /// <param name="inputData">Input data.</param>
        /// <param name="baseline">Baseline data?</param>
        public IEnumerator ProcessResults(string suiteName, string testType, ResultsIOData inputData, int baseline)
        {
            ProgressScreen.Instance.SetState(true, ProgressType.CloudSave, "Saving cloud data");

            inputData.suite    = suiteName;
            inputData.testType = testType;
            int uploaded = -1;

            if (writeCloud)
            {
                string sheetName;
                if (baseline == 1) //Cloud upload for baseline
                {
                    sheetName = suiteName + "_" + testType + "_Baseline";
                }
                else                 //cloud upload for results
                {
                    sheetName = suiteName + "_" + testType + "_Results";
                }
                StartCoroutine(SQL.SQLIO.AddEntry(inputData, sheetName, baseline, (value) => { uploaded = value; }));                 // SQLCHECK
                while (uploaded == -1)
                {
                    yield return(null);
                }
            }
            else
            {
                uploaded = 1;
            }

            ProgressScreen.Instance.SetState(true, ProgressType.LocalSave, "Saving local data");

            if (writeLocal)
            {
                fileType ft = baseline == 1 ? fileType.Baseline : fileType.Result;
                if (uploaded == 1)                 // if the entry uploaded fine
                {
                    StartCoroutine(LocalIO.Instance.WriteDataFiles(inputData, ft));
                }
            }

            BroadcastEndResultsSave();
        }
예제 #17
0
        IEnumerator FetchFilteredResults()
        {
            ProgressScreen.Instance.SetState(true, ProgressType.CloudLoad, "Fetching Cloud Data"); //Show loading screen
            ResultsIOData[] riodA = new ResultsIOData[0];
            yield return(StartCoroutine(FetchFilterData(value => { riodA = value; })));

            ResultsIOData[] riodB = new ResultsIOData[0];
            if (comparison)
            {
                yield return(StartCoroutine(FetchFilterData(value => { riodB = value; })));
            }
            else
            {
                riodB = riodA;
            }
            ProgressScreen.Instance.SetState(false, ProgressType.CloudLoad, "null"); //Show loading screen
            canvas.SetActive(false);                                                 //turn off the filter menu
            StartCoroutine(TestStructure.Instance.GenerateAnalyticStructure(riodA));
            //StartCoroutine(TestStructure.Instance.GenerateAnalyticStructure(riodA, riodB));
        }
예제 #18
0
        /// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------
        /// 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);
        }
예제 #19
0
        /// <summary>
        /// Converts JSON to the ResultsIO class.
        /// </summary>
        /// <returns>A ResultsIO is returned.</returns>
        /// <param name="inputData">Input unformatted JSON string.</param>
        public static ResultsIOData FromJSON(string inputData)
        {
            if (inputData != null)
            {
                string[]      splitData = JSONToStringArray(inputData);
                ResultsIOData data      = new ResultsIOData();            //new ResultsIOData
                ResultsIORow  row       = new ResultsIORow();
                data.resultsRow.Add(row);

                for (int i = 0; i < splitData.Length; i++)
                {
                    int    cur   = i;
                    string entry = splitData [cur];
                    data.resultsRow [0].resultsColumn.Add(entry);
                }
                return(data);
            }
            else
            {
                return(null);
            }
        }
예제 #20
0
        // Setup the results context object
        public override void SetupResultsContext(ResultsContext context, ResultsIOData inputData, ResultsIOData inputDataB)
        {
            AverageFrameTimeResults inputResults = (AverageFrameTimeResults)logic.DeserializeResults(inputData); // Deserialize input and cast to typed results

            if (TestRunner.Instance)
            {
                if (!TestRunner.Instance.isAnalytic)
                {
                    comparisonData = (AverageFrameTimeComparison)logic.ProcessComparison(inputResults); // Get comparison data
                }
                else
                {
                    AverageFrameTimeResults inputResultsB = (AverageFrameTimeResults)logic.DeserializeResults(inputDataB); // Deserialize input and cast to typed results
                    comparisonData = (AverageFrameTimeComparison)logic.ProcessComparison(inputResultsB, inputResults);
                }
            }
            else
            {
                comparisonData = (AverageFrameTimeComparison)logic.ProcessComparison(inputResults); // Get comparison data
            }

            context.objects[0].GetComponent <Text>().text = inputResults.avgFrameTime.ToString("N4"); // Set average frame time
            context.objects[1].GetComponent <Text>().text = comparisonData.delta.ToString("N4");      // Set delta
        }
예제 #21
0
        // Setup the results context object
        public override void SetupResultsContext(ResultsContext context, ResultsIOData inputData, ResultsIOData inputDataB)
        {
            ExampleResults inputResults = (ExampleResults)logic.DeserializeResults(inputData); // Deserialize input and cast to typed results

            if (TestRunner.Instance)
            {
                if (!TestRunner.Instance.isAnalytic)
                {
                    comparisonData = (ExampleComparison)logic.ProcessComparison(inputResults); // Get comparison data
                }
                else
                {
                    ExampleResults inputResultsB = (ExampleResults)logic.DeserializeResults(inputDataB); // Deserialize input and cast to typed results
                    comparisonData = (ExampleComparison)logic.ProcessComparison(inputResultsB, inputResults);
                }
            }
            else
            {
                comparisonData = (ExampleComparison)logic.ProcessComparison(inputResults); // Get comparison data
            }

            context.objects[0].GetComponent <Text>().text = inputResults.SomeFloat.ToString();       // Set float
            context.objects[1].GetComponent <Text>().text = comparisonData.SomeFloatDiff.ToString(); // Set diff
        }
예제 #22
0
        /// <summary>
        /// Converts multiple JSON strings to the ResultsIO class, populating multiple results rows.
        /// </summary>
        /// <returns>A ResultsIO is returned.</returns>
        /// <param name="inputData">Array of unformatted JSON strings.</param>
        public static ResultsIOData FromJSON(string[] inputData)
        {
            if (inputData.Length != 0)
            {
                ResultsIOData data = new ResultsIOData();                 //new ResultsIOData

                for (int a = 0; a < inputData.Length; a++)
                {
                    string[] splitData = JSONToStringArray(inputData [a]);
                    for (int i = 0; i < splitData.Length; i++)
                    {
                        data.resultsRow.Add(new ResultsIORow());
                        int    cur   = i;
                        string entry = splitData [cur];
                        data.resultsRow [a].resultsColumn.Add(entry);
                    }
                }
                return(data);
            }
            else
            {
                return(null);
            }
        }
예제 #23
0
        public IEnumerator GenerateAnalyticStructure(ResultsIOData[] resultsA, ResultsIOData[] resultsB)
        {
            yield return(null);

            testStructure = new Structure();                                                                  // Create new test structure instance
            List <TestType> typeList = GenerateTypeListAndInstances();                                        // Generate type list and create instances

            int groupColumn = Common.FindResultsDataIOFieldIdByName(resultsA[0], "GroupName");                // Get group column ID

            if (groupColumn == -1)                                                                            // If error return
            {
                Console.Instance.Write(DebugLevel.Critical, MessageLevel.LogError, "GroupName ID not found"); // Debug
            }
            int testColumn = Common.FindResultsDataIOFieldIdByName(resultsA[0], "TestName");                  // Get test column ID

            if (testColumn == -1)                                                                             // If error return
            {
                Console.Instance.Write(DebugLevel.Critical, MessageLevel.LogError, "TestName ID not found");  // Debug
            }
            for (int i = 0; i < resultsA.Length; i++)
            {
                Debug.LogWarning(resultsA[i].testType);
                string suiteName = resultsA[i].suite;
                Suite  suite     = FindDuplicateSuiteInStructure(suiteName);
                if (suite == null)
                {
                    suite           = new Suite();                 // Create new suite instance
                    suite.suiteName = suiteName;                   // Set suite name
                    suite.types     = CloneTestTypeList(typeList); // Clone the type list
                    testStructure.suites.Add(suite);               // Add to suites list
                }
                //iterate through all the tests in ResultsIOData.Rows
                for (int row = 0; row < resultsA[i].resultsRow.Count; row++)
                {
                    string groupName = resultsA[i].resultsRow[row].resultsColumn[groupColumn];                       // Get group name
                    int    typeIndex = TestTypeManager.Instance.GetTestTypeIndexFromName(resultsA[i].testType);      // Get type index
                    if (typeIndex == -1)                                                                             // If error return
                    {
                        Console.Instance.Write(DebugLevel.Critical, MessageLevel.LogError, "TestType ID not found"); // Debug
                    }
                    Group group = FindDuplicateGroupInType(suite, typeIndex, groupName);
                    if (group == null)
                    {
                        group           = new Group();            // Create new group instance
                        group.groupName = groupName;              // Set group name
                        suite.types[typeIndex].groups.Add(group); // Add to groups list
                    }

                    string      testName = resultsA[i].resultsRow[row].resultsColumn[testColumn]; // Get test name
                    TestResults test     = new TestResults();                                     // Create new TestResults
                    test.testName = testName;                                                     // Set test name

                    //create resultsIOdata for this single row
                    ResultsIOData riodA = new ResultsIOData();
                    riodA.suite      = resultsA[i].suite;
                    riodA.testType   = resultsA[i].testType;
                    riodA.baseline   = resultsA[i].baseline;
                    riodA.fieldNames = resultsA[i].fieldNames;
                    riodA.resultsRow.Add(resultsA[i].resultsRow[row]);
                    test.dataA = riodA;   // Set results data A

                    if (resultsB != null) // If analytic comparison
                    {
                        ResultsIOData riodB = new ResultsIOData();
                        riodB.suite      = resultsB[i].suite;
                        riodB.testType   = resultsB[i].testType;
                        riodB.baseline   = resultsB[i].baseline;
                        riodB.fieldNames = resultsB[i].fieldNames;
                        riodB.resultsRow.Add(resultsB[i].resultsRow[row]);
                        test.dataB = riodB; // Set results data B
                    }
                    else
                    {
                        ResultsIOData riodB = new ResultsIOData();
                        riodB.suite      = resultsA[i].suite;
                        riodB.testType   = resultsA[i].testType;
                        riodB.baseline   = true; //resultsA[i].baseline; // TODO - Should be true
                        riodB.fieldNames = resultsA[i].fieldNames;
                        riodB.resultsRow.Add(resultsA[i].resultsRow[row]);
                        test.dataB = riodB; // Set results data A
                    }
                    group.tests.Add(test);  // Add to group
                }
            }
            // Reiterate suites to remove empty type entries
            for (int i = 0; i < testStructure.suites.Count; i++)
            {
                for (int ty = 0; ty < testStructure.suites[i].types.Count; ty++) // Iterate types
                {
                    if (testStructure.suites[i].types[ty].groups.Count == 0)     // If empty
                    {
                        testStructure.suites[i].types.RemoveAt(ty);              // Remove it
                    }
                }
                testStructure.suites[i].types.TrimExcess();                                                          // Trim the types list
            }
            Console.Instance.Write(DebugLevel.Logic, MessageLevel.Log, "AnalyticTestStructure finished generating"); // Write to console

            if (resultsB == null)                                                                                    // If analytic
            {
                Menu.Instance.GenerateTestRunner(RunnerType.Analytic);                                               // Generate anyaltic test runner
            }
            else // If analytic comparison
            {
                Menu.Instance.GenerateTestRunner(RunnerType.AnalyticComparison);
            }
        }
예제 #24
0
 // Deserialize ResultsIOData(string arrays) to ResultsData(class)
 public virtual object DeserializeResults(ResultsIOData resultsIOData)
 {
     return(new object());
 }
예제 #25
0
        // ------------------------------------------------------------------------------------
        // 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);
        }
예제 #26
0
        // 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);
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #27
0
 public abstract void UseLocalResult(ResultsIOData localResult);
예제 #28
0
 // Setup the results context entry
 public abstract void SetupResultsContext(ResultsContext contextObject, ResultsIOData inputData, ResultsIOData inputDataB);
예제 #29
0
 public ResultsEntryData(TestEntry inputEntry, ResultsIOData inputData, ResultsIOData inputDataB)
 {
     testEntry    = inputEntry;
     resultsData  = inputData;
     resultsDataB = inputDataB;
 }
예제 #30
0
        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);
        }