Exemplo n.º 1
0
        int activeTestLogic;                                     // Track the active logic

        // ------------------------------------------------------------------------------------
        // Instance Management

        // Generate script instances for a type (Called by TestStructure)
        public void GenerateTestTypeInstance(TestModelBase model)
        {
            string typeName = model.logic.ToString().Replace("GraphicsTestFramework.", "").Replace("Logic", "");         // Get type name from logic name

            Console.Instance.Write(DebugLevel.Full, MessageLevel.Log, "Generating test type instances for " + typeName); // Write to console
            Transform instanceParent = Master.Instance.transform.Find("TestRunners");                                    // Find instance parent

            if (instanceParent)                                                                                          // If it exists
            {
                if (!instanceParent.Find(typeName))                                                                      // If instance doesnt already exist
                {
                    GameObject newChild = new GameObject();                                                              // Create a gameobject to hold the instance
                    newChild.transform.SetParent(instanceParent);                                                        // Set parent
                    newChild.name = typeName;                                                                            // Set gameobject name
                    TestLogicBase logic = (TestLogicBase)newChild.AddComponent(model.logic);                             // Add logic component
                    logic.SetupLogic();                                                                                  // Run setup on logic
                    logic.SetName();                                                                                     // Set name on logic
                    logic.SetDisplay();                                                                                  // Set display on logic
                    logic.SetResults();                                                                                  // Set results type on logic
                    TestDisplayBase display = (TestDisplayBase)newChild.AddComponent(logic.display);                     // Add display component
                    display.SetLogic(logic);                                                                             // Set logic on display
                    display.GetResultsContextObject();                                                                   // Get context object for results entry
                    AddType(logic);                                                                                      // Add to type list
                }
            }
            else
            {
                Console.Instance.Write(DebugLevel.Critical, MessageLevel.Log, "Test Runner parent not found! Aborting"); // Write to console
            }
        }
Exemplo n.º 2
0
        // ------------------------------------------------------------------------------------
        // Detailed Results List

        // Generate main list
        IEnumerator GenerateDetailedResultsList()
        {
            Console.Instance.Write(DebugLevel.Full, MessageLevel.Log, "Generating list"); // Write to console
            yield return(null);

            ClearDetailedResultsList();                                                                                                             // Clear current list
            ClearDetailedResultsTitleEntryLists();                                                                                                  // Clear title lists
            DestroyContextEntry();                                                                                                                  // Destroy the context object
            TestLogicBase logic         = null;                                                                                                     // Track previous logic
            string        previousSuite = "";                                                                                                       // Track previous suite
            string        previousType  = "";                                                                                                       // Track previous type

            for (int i = 0; i < filteredResultsEntries.Count; i++)                                                                                  // Iterate filtered results
            {
                if (previousSuite != filteredResultsEntries[i].testEntry.suiteName || previousType != filteredResultsEntries[i].testEntry.typeName) // New suite or type
                {
                    GenerateNewTitleEntry(filteredResultsEntries[i].testEntry);                                                                     // Generate new title entry
                }
                if (!logic || filteredResultsEntries[i].testEntry.typeName != previousType)                                                         // If logic doesnt match previous type
                {
                    logic = TestTypeManager.Instance.GetLogicInstanceFromName(filteredResultsEntries[i].testEntry.typeName);                        // Get logic instance
                }
                previousSuite = filteredResultsEntries[i].testEntry.suiteName;                                                                      // Track previous suite
                previousType  = filteredResultsEntries[i].testEntry.typeName;                                                                       // Track previous type
                ResultsEntry newEntry = GenerateResultsEntry(resultsEntryPrefab);                                                                   // Generate a ResultsEntry
                newEntry.Setup(filteredResultsEntries[i], logic);                                                                                   // Setup the instance
                if (entryHeight == 0)                                                                                                               // Track entry height
                {
                    entryHeight = newEntry.GetComponent <RectTransform>().sizeDelta.y;
                }
                listHeight -= entryHeight;                                                     // Track height for next entry
            }
            listContentRect.sizeDelta = new Vector2(listContentRect.sizeDelta.x, -listHeight); // Set content rect size
        }
Exemplo n.º 3
0
        // ------------------------------------------------------------------------------------
        // Test Execution

        // Start an individual test (called by TestRunner)
        public void StartTest(TestEntry inputTest, RunnerType runnerType)
        {
            Console.Instance.Write(DebugLevel.Logic, MessageLevel.Log, "Starting test " + inputTest.testName);                        // Write to console
            activeTest = SuiteManager.GetTest(inputTest);                                                                             // Get the active test
            TestLogicBase activeTestLogic = GetLogicInstance(SuiteManager.GetSuiteName(inputTest.suiteIndex), activeTest, inputTest); // Get active test logic instance

            StartCoroutine(activeTestLogic.SetupTest(inputTest, runnerType));                                                         // Setup test
        }
Exemplo n.º 4
0
        // ------------------------------------------------------------------------------------
        // Set Data

        // Add a new test type
        void AddType(TestLogicBase inputLogic)
        {
            Console.Instance.Write(DebugLevel.Full, MessageLevel.Log, "Adding new TestType of " + inputLogic.name); // Write to console
            TestType newType = new TestType();                                                                      // Create new class instance

            newType.typeName      = inputLogic.name;                                                                // Set name from input
            newType.logicInstance = inputLogic;                                                                     // Set instance from input
            typeList.Add(newType);                                                                                  // Add to list
        }
Exemplo n.º 5
0
 // Set the active test logic
 public void SetActiveLogic(TestLogicBase inputLogic)
 {
     Console.Instance.Write(DebugLevel.Full, MessageLevel.Log, "Setting active test logic to " + inputLogic.name); // Write to console
     for (int i = 0; i < typeList.Count; i++)                                                                      // Iterate types
     {
         if (typeList[i].logicInstance == inputLogic)                                                              // If logic instance is equal to input
         {
             activeTestLogic = i;                                                                                  // Set as active
         }
     }
 }
Exemplo n.º 6
0
        // ------------------------------------------------------------------------------------
        // Test Execution

        // Start an individual test (called by TestRunner)
        public void StartTest(TestEntry inputTest, RunnerType runnerType)
        {
            Console.Instance.Write(DebugLevel.Logic, MessageLevel.Log, "Starting test " + inputTest.testName); // Write to console
            TestLogicBase activeTestLogic = null;

            if (!isAnalytic)                                                                                    // If not analytic mode
            {
                activeTest      = SuiteManager.GetTest(inputTest);                                              // Get the active test from suite manager
                activeTestLogic = GetLogicInstance(SuiteManager.GetSuiteName(inputTest.suiteIndex), inputTest); // Get active test logic instance
            }
            else
            {
                activeTest      = Common.GenerateTestFromTestEntry(inputTest);                                                     // Get the active test from structure
                activeTestLogic = GetLogicInstance(TestStructure.Instance.GetSuiteNameFromIndex(inputTest.suiteIndex), inputTest); // Get active test logic instance
            }
            StartCoroutine(activeTestLogic.SetupTest(inputTest, runnerType));                                                      // Setup test
        }
Exemplo n.º 7
0
        // Setup the entry
        public void Setup(ResultsEntryData inputData, TestLogicBase inputLogic)
        {
            Console.Instance.Write(DebugLevel.Full, MessageLevel.Log, "Setting up results entry"); // Write to console
            resultsEntryData   = inputData;                                                        // Track resultsEntry data
            logic              = inputLogic;                                                       // Track logic instance
            groupNameText.text = resultsEntryData.testEntry.groupName;                             // Set group name label
            testNameText.text  = resultsEntryData.testEntry.testName;                              // Set test name label

            int passFail = 2;                                                                      // Set default state (no results)

            if (resultsEntryData.resultsData != null)                                              // If results data exists
            {
                int passFailIndex = -1;
                for (int f = 0; f < resultsEntryData.resultsData.fieldNames.Count; f++)
                {
                    if (resultsEntryData.resultsData.fieldNames[f] == "PassFail")
                    {
                        passFailIndex = f;
                    }
                }
                passFail = resultsEntryData.resultsData.resultsRow[0].resultsColumn[passFailIndex] == "True" ? 1 : 0; // Set pass fail state
            }

            switch (passFail)                                                    // Switch on pass fail
            {
            case 0:                                                              //Fail
                passFailText.text        = "FAIL";                               // Set passfail label
                passFailBackground.color = Menu.Instance.colors[4];              // Set passfail object color
                expandButton.onClick.AddListener(delegate { ToggleContext(); }); // Add expand button listener
                break;

            case 1:                                                              // Pass
                passFailText.text        = "PASS";                               // Set passfail label
                passFailBackground.color = Menu.Instance.colors[3];              // Set passfail object color
                expandButton.onClick.AddListener(delegate { ToggleContext(); }); // Add expand button listener
                break;

            case 2:                                                  // No results
                passFailText.text         = "NONE";                  // Set passfail label
                passFailBackground.color  = Menu.Instance.colors[1]; // Set passfail object color
                expandButton.interactable = false;                   // Disable expand button
                break;
            }
        }
Exemplo n.º 8
0
        }                            // Reference to the tests logic

        // ------------------------------------------------------------------------------------
        // Set Methods

        // Set test logic instance
        public override void SetLogic(TestLogicBase inputLogic)
        {
            logic = (L)inputLogic; // Cast to type and set
        }
Exemplo n.º 9
0
        public GameObject resultsContextPrefab; // Reference to prefab for results screen context dropdown

        // ------------------------------------------------------------------------------------
        // Initialization

        // Set test logic instance
        public abstract void SetLogic(TestLogicBase inputLogic);