예제 #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
            }
        }
예제 #2
0
 // Get test model instance
 public override TestModelBase GetModel()
 {
     if (model)
     {
         return(model);
     }
     else
     {
         TestModelBase newModel = (TestModelBase)Activator.CreateInstance(typeof(M));
         newModel.settings = (SettingsBase)Activator.CreateInstance(typeof(S));
         return(newModel);
     }
 }
예제 #3
0
 // Find model instances of a specificed type that meet requirements
 public bool FindModelInstanceOfType(Type modelType, out TestModelBase model)
 {
     TestModelBase[] foundModels = (TestModelBase[])FindObjectsOfType(modelType);     // Find all models of type
     for (int i = 0; i < foundModels.Length; i++)                                     // Iterate found models
     {
         if (Common.IsCurrentPlatformInBitMask(foundModels[i].settings.platformMask)) // If model matches platform bitmask
         {
             model = foundModels[i];                                                  // Out model
             return(true);                                                            // Return true
         }
     }
     model = null;  // Out null
     return(false); // Return false
 }
예제 #4
0
        // Get a logic instance and set model instance on it
        TestLogicBase GetLogicInstance(string suiteName, Test activeTest, TestEntry activeEntry)
        {
            Console.Instance.Write(DebugLevel.Full, MessageLevel.Log, "Getting logic instance");                                                                         // Write to console
            TestLogicBase output;                                                                                                                                        // Create logic instance
            var           modelType = TestTypes.GetTypeFromIndex(activeEntry.typeValue);                                                                                 // Get the model type from its index

            if (!FindModelInstanceOfType(modelType, out activeModelInstance))                                                                                            // Check for model instance matching criteria
            {
                activeModelInstance = CreateNewModelInstance(modelType);                                                                                                 // Create model instance
            }
            activeModelInstance.SetLogic();                                                                                                                              // Set the logic reference on the model
            output = TestTypeManager.Instance.GetLogicInstanceFromName(activeModelInstance.logic.ToString().Replace("GraphicsTestFramework.", "").Replace("Logic", "")); // Get test  logic instance
            output.SetSuiteName(suiteName);                                                                                                                              // Set suite name on the logic
            output.SetModel(activeModelInstance);                                                                                                                        // Set the active test model in the logic
            TestTypeManager.Instance.SetActiveLogic(output);                                                                                                             // Set as active test logic
            return(output);                                                                                                                                              // Return
        }
예제 #5
0
        List <TestType> GenerateTypeListAndInstances()
        {
            string[]        testTypes = TestTypes.GetTypeStringList();                                        // Get the type list
            List <TestType> typeList  = new List <TestType>();                                                // Create new list to fill

            for (int i = 0; i < testTypes.Length; i++)                                                        // ITerate type list
            {
                TestType newType = new TestType();                                                            // Create new instance
                newType.typeName  = testTypes[i];                                                             // Set name
                newType.typeIndex = i;                                                                        // Set index
                typeList.Add(newType);                                                                        // Add to list
                TestModelBase model = (TestModelBase)Activator.CreateInstance(TestTypes.GetTypeFromIndex(i)); // Create model instance for logic references
                model.SetLogic();                                                                             // Need to set logic before generating type instances
                TestTypeManager.Instance.GenerateTestTypeInstance(model);                                     // Generate an instance object for test logic/display
            }
            return(typeList);
        }
예제 #6
0
 public abstract void SetModel(TestModelBase inputModel);
예제 #7
0
        public float waitTimer = 0f; // Track wait timing for seconds

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

        // Set test model instance
        public override void SetModel(TestModelBase inputModel)
        {
            model = (M)inputModel; // Cast to type and set
        }
예제 #8
0
        // Generate test structure
        // - Loads all scenes and gets data from test lists
        // - Reorganises for menu layout
        IEnumerator GenerateStructure()
        {
            yield return(null);                                                                               // TODO - Remove

            testStructure = new Structure();                                                                  // Create new test structure instance

            string[]        testTypes = TestTypes.GetTypeStringList();                                        // Get the type list
            List <TestType> typeList  = new List <TestType>();                                                // Create new list to fill

            for (int i = 0; i < testTypes.Length; i++)                                                        // ITerate type list
            {
                TestType newType = new TestType();                                                            // Create new instance
                newType.typeName  = testTypes[i];                                                             // Set name
                newType.typeIndex = i;                                                                        // Set index
                typeList.Add(newType);                                                                        // Add to list
                TestModelBase model = (TestModelBase)Activator.CreateInstance(TestTypes.GetTypeFromIndex(i)); // Create model instance for logic references
                model.SetLogic();                                                                             // Need to set logic before generating type instances
                TestTypeManager.Instance.GenerateTestTypeInstance(model);                                     // Generate an instance object for test logic/display
            }
            ProjectSettings projectSettings = SuiteManager.GetProjectSettings();                              // Get the suite list

            if (projectSettings == null)                                                                      // If no suite list found
            {
                StopAllCoroutines();                                                                          // Abort
            }
            for (int su = 0; su < projectSettings.suiteList.Count; su++)                                      // Iterate suites on suite list
            {
                Suite newSuite = new Suite();                                                                 // Create new suite instance
                newSuite.suiteName = projectSettings.suiteList[su].suiteName;                                 // Set suite name from suite list
                newSuite.types     = CloneTestTypeList(typeList);                                             // Clone the type list
                for (int gr = 0; gr < projectSettings.suiteList[su].groups.Count; gr++)                       // Iterate groups
                {
                    for (int te = 0; te < projectSettings.suiteList[su].groups[gr].tests.Count; te++)         // Iterate tests
                    {
                        GraphicsTestFramework.Test test = projectSettings.suiteList[su].groups[gr].tests[te]; // Get test
                        if (Common.IsTestApplicable(test))
                        {
                            int[] types = TestTypeManager.Instance.GetTypeSelectionFromBitMask(test.testTypes);                                     // Get type array from test's bitmask
                            for (int ty = 0; ty < types.Length; ty++)                                                                               // Iterate types of the test
                            {
                                Group newGroup = FindDuplicateGroupInType(newSuite, types[ty], projectSettings.suiteList[su].groups[gr].groupName); // Find duplicate groups in the type
                                if (newGroup == null)                                                                                               // If not found
                                {
                                    newGroup           = new Group();                                                                               // Create a new group instance
                                    newGroup.groupName = projectSettings.suiteList[su].groups[gr].groupName;                                        // Set group name
                                    FindDuplicateTypeInSuite(newSuite, types[ty]).groups.Add(newGroup);                                             // Add the group to the type
                                }
                                Test     newTest   = new Test();                                                                                    // Create new test instance
                                string[] pathSplit = projectSettings.suiteList[su].groups[gr].tests[te].scenePath.Split('/');                       // Split path for scene name
                                newTest.testName  = pathSplit[pathSplit.Length - 1].Replace(".unity", "");;                                         // Set test name
                                newTest.scenePath = projectSettings.suiteList[su].groups[gr].tests[te].scenePath;                                   // Set scene path
                                newGroup.tests.Add(newTest);                                                                                        // Add test to scene
                            }
                        }
                    }
                }
                for (int ty = 0; ty < newSuite.types.Count; ty++) // Iterate types
                {
                    if (newSuite.types[ty].groups.Count == 0)     // If empty
                    {
                        newSuite.types.RemoveAt(ty);              // Remove it
                    }
                }
                newSuite.types.TrimExcess();                                                                 // Trim the types list
                testStructure.suites.Add(newSuite);                                                          // Add to suites list
            }
            m_IsGenerated = true;                                                                            // Set generated
            Console.Instance.Write(DebugLevel.Logic, MessageLevel.Log, "TestStructure finished generating"); // Write to console
            ProgressScreen.Instance.SetState(false, ProgressType.LocalLoad, "");                             // Disable ProgressScreen
        }