// 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 }
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); }
// 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 }
// 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 }