// ------------------------------------------------------------------------------------
        // TestViewer

        // Setup viewer tabs
        public override TestViewerTabData[] GetViewerTabs(ResultsBase resultsObject)
        {
            var typedSettings = (FrameComparisonSettings)logic.GetModel().settings; // Set settings to local type

            TestViewerTabData[] output = new TestViewerTabData[1];                  // Create empty output (mandatory)
            switch (logic.baselineExists)                                           // Switch on baseline exists
            {
            case false:
                var localResultData = (FrameComparisonResults)resultsObject;                                                                                                   // Convert the input results object to this types class (mandatory)
                output = new TestViewerTabData[2]                                                                                                                              // Want two tabs
                {
                    new TestViewerTabData("Results Texture", TestViewerTabType.Texture, Common.ConvertStringToTexture("Tab_ResultsFrame", localResultData.resultFrame), null), // And the results texture
                    new TestViewerTabData("Live Camera", TestViewerTabType.Camera, typedSettings.captureCamera, null)                                                          // Live camera showing capture camera
                };
                break;

            case true:
                var comparisonData = (FrameComparisonLogic.ComparisonData)logic.GetComparisonData(resultsObject);                                                                                                                                      // Get the comparison data for this test in this types class (mandatory)
                SetupMaterial(comparisonData.baselineTex, comparisonData.resultsTex);                                                                                                                                                                  // Setup the material
                output = new TestViewerTabData[3]                                                                                                                                                                                                      // Want three tabs
                {
                    new TestViewerTabData("Results", TestViewerTabType.TextureSlider, new TestViewer.TextureSliderContext(comparisonData.resultsTex, "Result", comparisonData.baselineTex, "Baseline"), new TestViewerTabData.TestViewerTabStatistic[] // Create slider tab for results/baseline
                    {
                        new TestViewerTabData.TestViewerTabStatistic("Diff", comparisonData.DiffPercentage.ToString())                                                                                                                                 // Enable the statistics window and display the diff
                    }),
                    new TestViewerTabData("Comparison", TestViewerTabType.Material, material, new TestViewerTabData.TestViewerTabStatistic[]                                                                                                           // And the material for the comparison display
                    {
                        new TestViewerTabData.TestViewerTabStatistic("Diff", comparisonData.DiffPercentage.ToString())                                                                                                                                 // Enable the statistics window and display the diff
                    }),
                    new TestViewerTabData("Live Camera", TestViewerTabType.Camera, typedSettings.captureCamera, null)                                                                                                                                  // Live camera showing capture camera
                };
                break;
            }
            return(output); // Return
        }
Пример #2
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
        }
Пример #3
0
        // ------------------------------------------------------------------------------------
        // TestViewer

        // Setup viewer tabs
        public override TestViewerTabData[] GetViewerTabs(ResultsBase resultsObject)
        {
            TestViewerTabData[] output = new TestViewerTabData[1];               // Create empty output (mandatory)
            var localResultData        = (AverageFrameTimeResults)resultsObject; // Convert the input results object to this types class (mandatory)

            switch (logic.baselineExists)                                        // Switch on baseline exists
            {
            case false:
                output = new TestViewerTabData[1]                                                                                               // Only want one tab
                {
                    new TestViewerTabData("Live Camera", TestViewerTabType.DefaultCamera, null, new TestViewerTabData.TestViewerTabStatistic[1] // Set the tab to use the default camera
                    {
                        new TestViewerTabData.TestViewerTabStatistic("Average Frame Time", localResultData.avgFrameTime.ToString("N4"))         // Enable the statistics window and display the avg frame time
                    })
                };
                break;

            case true:
                var comparisonData = (AverageFrameTimeComparison)logic.ProcessComparison(resultsObject);                                        // Get the comparison data for this test in this types class (mandatory)
                output = new TestViewerTabData[1]                                                                                               // Only want one tab
                {
                    new TestViewerTabData("Live Camera", TestViewerTabType.DefaultCamera, null, new TestViewerTabData.TestViewerTabStatistic[2] // Set the tab to use the default camera
                    {
                        new TestViewerTabData.TestViewerTabStatistic("Average Frame Time", localResultData.avgFrameTime.ToString("N4")),        // Enable the statistics window and display the avg frame time
                        new TestViewerTabData.TestViewerTabStatistic("Delta", comparisonData.delta.ToString("N4"))                              // Also display the delta from the comparison
                    })
                };
                break;
            }
            return(output); // Return the tabs
        }
Пример #4
0
        // Initialize results structure
        public override void SetResults()
        {
            results = typeof(R);                                        // Set type
            ResultsBase newData = (R)Activator.CreateInstance(results); // Create instance

            newData.common   = new ResultsDataCommon();                 // Initialize common
            activeResultData = newData;                                 // Set as active
        }
Пример #5
0
        // Enable test viewer
        public override void EnableTestViewer(ResultsBase resultsObject, TestViewerToolbar.State toolbarState)
        {
            Console.Instance.Write(DebugLevel.Full, MessageLevel.Log, this.GetType().Name + " enabling test viewer");                                               // Write to console
            string breadcrumbLabel = logic.suiteName + " - " + logic.testTypeName + " - " + resultsObject.common.GroupName + " - " + resultsObject.common.TestName; // Build breadcrumb label

            ProgressScreen.Instance.SetState(false, ProgressType.LocalSave, "");                                                                                    // Disable ProgressScreen
            TestViewer.Instance.SetState(true);                                                                                                                     // Set test viewer state
            TestViewer.Instance.UpdateBars(GetViewerTabs(resultsObject), GetResultsTimeDisplay(resultsObject), breadcrumbLabel, toolbarState);                      // Set test viewer state
        }
        // Logic for comparison process (mandatory)
        // TODO - Will use last run test model, need to get this for every call from Viewers?
        public override object ProcessComparison(ResultsBase baselineData, ResultsBase resultsData)
        {
            ComparisonData          newComparison     = new ComparisonData();                     // Create new ComparisonData instance (mandatory)
            AverageFrameTimeResults baselineDataTyped = (AverageFrameTimeResults)baselineData;    // Set baseline data to local type
            AverageFrameTimeResults resultsDataTyped  = (AverageFrameTimeResults)resultsData;     // Set results data to local type

            newComparison.delta = resultsDataTyped.avgFrameTime - baselineDataTyped.avgFrameTime; // Perform comparison logic (logic specific)
            return(newComparison);                                                                // Return (mandatory)
        }
Пример #7
0
 // Build results after main test logic is completed
 public void BuildResultsStruct(ResultsBase input)
 {
     if (input != null)                                                                                                                             // Null check
     {
         Console.Instance.Write(DebugLevel.Full, MessageLevel.Log, this.GetType().Name + " building results for test " + activeTestEntry.testName); // Write to console
         activeResultData = input;                                                                                                                  // Set active results data
     }
     TestPostProcess();                                                                                                                             // Start post-process
 }
Пример #8
0
        // Logic for comparison process (mandatory)
        // TODO - Will use last run test model, need to get this for every call from Viewers?
        public override object ProcessComparison(ResultsBase baselineData, ResultsBase resultsData)
        {
            ComparisonData newComparison     = new ComparisonData(); // Create new ComparisonData instance (mandatory)
            ExampleResults baselineDataTyped = (ExampleResults)baselineData;
            ExampleResults resultsDataTyped  = (ExampleResults)resultsData;

            newComparison.SomeFloatDiff = resultsDataTyped.SomeFloat - baselineDataTyped.SomeFloat; // Perform comparison logic (logic specific)
            return(newComparison);                                                                  // Return (mandatory)
        }
Пример #9
0
        // ------------------------------------------------------------------------------------
        // Initialization

        // Setup the results structs every test
        public override void SetupResultsStructs()
        {
            ResultsBase newResultsData = (R)Activator.CreateInstance(results); // Create instance

            newResultsData.common           = Common.GetCommonResultsData();   // Initialize common
            newResultsData.common.GroupName = activeTestEntry.groupName;       // Set scene name
            newResultsData.common.TestName  = activeTestEntry.testName;        // Set test name
            newResultsData.common.Custom   += Common.CustomEntry("runID", TestRunner.runUUID);
            activeResultData = newResultsData;                                 // Set as active
        }
Пример #10
0
        // Logic for comparison process (mandatory)
        // TODO - Will use last run test model, need to get this for every call from Viewers?
        public override object ProcessComparison(ResultsBase baselineData, ResultsBase resultsData)
        {
            FrameComparisonComparison newComparison     = new FrameComparisonComparison();                                                                // Create new ComparisonData instance (mandatory)
            FrameComparisonResults    baselineDataTyped = (FrameComparisonResults)baselineData;                                                           // Set baseline data to local type
            FrameComparisonResults    resultsDataTyped  = (FrameComparisonResults)resultsData;                                                            // Set results data to local type

            newComparison.baselineTex    = Common.ConvertStringToTexture(resultsDataTyped.common.TestName + "_Reference", baselineDataTyped.resultFrame); // Convert baseline frame to Texture2D (logic specific)
            newComparison.resultsTex     = Common.ConvertStringToTexture(resultsDataTyped.common.TestName + "_Results", resultsDataTyped.resultFrame);    // Convert result frame to Texture2D (logic specific)
            newComparison.DiffPercentage = Common.GetTextureComparisonValue(newComparison.baselineTex, newComparison.resultsTex);                         // Calculate diff percentage (logic specific)
            return(newComparison);                                                                                                                        // Return (mandatory)
        }
Пример #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
        // Get a comparison result from any given result and baseline
        public override bool GetComparisonResult(ResultsBase results, ResultsBase baseline)
        {
            FrameComparisonComparison comparisonData = (FrameComparisonComparison)ProcessComparison(baseline, results);  // Prrocess comparison (mandatory)
            bool output = false;

            if (comparisonData.DiffPercentage < model.settings.passFailThreshold)  // Pass/fail decision logic (logic specific)
            {
                output = true;
            }
            else
            {
                output = false;
            }
            comparisonData = null;  // Null comparison (mandatory)
            return(output);
        }
Пример #13
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
            }
        }
Пример #14
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);
        }
Пример #15
0
        // Get time since results
        public string GetResultsTimeDisplay(ResultsBase resultsObject)
        {
            string output = "";                                                                   // Create output

            System.DateTime   resultTime = System.DateTime.Parse(resultsObject.common.DateTime);  // Parse result time
            System.DateTime   now        = System.DateTime.UtcNow;                                // Get time now
            Common.TimePeriod period     = Common.TimePeriod.Closest;                             // Create time period
            float             result     = Common.GetTimeDifference(resultTime, now, ref period); // Get time difference

            if (period == Common.TimePeriod.Second)                                               // If seconds dont return details
            {
                output = "just now";                                                              // Set output
            }
            else
            {
                output = result.ToString() + " " + period.ToString().ToLower() + "s ago"; // Set output
            }
            return("Results created " + output);                                          // Return
        }
Пример #16
0
        // ------------------------------------------------------------------------------------
        // TestViewer

        // Return default camera tab only
        public virtual TestViewerTabData[] GetViewerTabs(ResultsBase resultsObject)
        {
            return(new TestViewerTabData[1] {
                new TestViewerTabData("Default", TestViewerTabType.DefaultCamera, null, null)
            });
        }
Пример #17
0
 // Enable test viewer
 public virtual void EnableTestViewer(ResultsBase resultsObject, TestViewerToolbar.State toolbarState)
 {
 }
Пример #18
0
 public abstract object ProcessComparison(ResultsBase baselineData, ResultsBase resultsData);
Пример #19
0
 public abstract bool GetComparisonResult(ResultsBase results, ResultsBase baseline);