コード例 #1
0
 // Get a type index from its type name
 public int GetTestTypeIndexFromName(string name)
 {
     string[] stringArray = TestTypes.GetTypeStringList(); // Get list of type string
     for (int i = 0; i < stringArray.Length; i++)          // Iterate
     {
         if (stringArray[i] == name)                       // If matches query
         {
             return(i);                                    // Return index
         }
     }
     return(-1); // Return fail
 }
コード例 #2
0
        // Get type names and generate dropdown content
        void GenerateTypesDropdown()
        {
            Console.Instance.Write(DebugLevel.Full, MessageLevel.Log, "Generating types dropdown"); // Write to console
            List <Dropdown.OptionData> options = new List <Dropdown.OptionData>();                  // Create new options list

            options.Add(Common.ConvertStringToDropdownOptionData("All Types"));
            string[] types = TestTypes.GetTypeStringList();                      // Get type names
            for (int i = 0; i < types.Length; i++)                               // Iterate types
            {
                options.Add(Common.ConvertStringToDropdownOptionData(types[i])); // Convert string to option data and add
            }
            typesDropdown.options = options;                                     // Add options
        }
コード例 #3
0
        // Get an array of selected test types from a bit mask
        public int[] GetTypeSelectionFromBitMask(int bitMask)
        {
            int        length  = TestTypes.GetTypeStringList().Length; // Get length of type list
            List <int> intList = new List <int>();                     // Create int list to track

            for (int i = 0; i < length; i++)                           // Iterate type list
            {
                if (bitMask == (bitMask | (1 << i)))                   // If bit mask returns true
                {
                    intList.Add(i);                                    // Add to list
                }
            }
            return(intList.ToArray()); // Return list as array
        }
コード例 #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
ファイル: TestStructure.cs プロジェクト: luco2018/UTF_Core
        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
        // Get a type name from its type index
        // TODO - Move these methods to a unique ID
        public string GetTestTypeNameFromIndex(int index)
        {
            Type type = TestTypes.GetTypeFromIndex(index);                                      // Get the type at that index

            return(type.ToString().Replace("GraphicsTestFramework.", "").Replace("Model", "")); // Return the type name of the requested index
        }
コード例 #7
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
        }