예제 #1
0
        // ------------------------------------------------------------------------------------
        // Buttons

        // Called every time a list entry is clicked (button listener)
        public void OnListEntryClick(MenuListEntry clicked)
        {
            Console.Instance.Write(DebugLevel.Full, MessageLevel.Log, "Clicked: List entry"); // Write to console
            if (clicked.entryData.id.currentLevel < 3)                                        // Selecting any level with children
            {
                ClearList();                                                                  // Clear the list
                GenerateBreadcrumb(clicked.entryData);                                        // Generate a new breadcrumb
                MenuTestEntry id = CloneMenuTestEntry(clicked.entryData.id);                  // Clone the entry data of the clicked entry
                id.currentLevel++;                                                            // Increment current level
                selectedId = id;                                                              // Set selected id
                GenerateList();                                                               // Generate a new list
                CheckRunButtonStatus();                                                       // Check run button status
            }
            else // Selecting a single test (no children)
            {
                MenuTestEntry id = CloneMenuTestEntry(clicked.entryData.id);          // Clone the entry data of the clicked entry
                id.currentLevel++;                                                    // Increment current level
                selectedId = id;                                                      // Set selected id
                if (selectedTest != null)                                             // If there is a selected test
                {
                    selectedTest.mainButton.GetComponent <Image>().color = colors[2]; // Reset its color
                }
                selectedTest = clicked;                                               // Set this as selected test
                selectedTest.mainButton.GetComponent <Image>().color = colors[1];     // Set its color
                CheckViewButtonStatus();                                              // Check view button status
            }
        }
예제 #2
0
        // Load the currently selected test for view
        void LoadSelectedTest()
        {
            Console.Instance.Write(DebugLevel.Full, MessageLevel.Log, "Loading selected test"); // Write to console
            MenuTestEntry selectedEntry = Menu.Instance.GetSelectedEntry();                     // Get selected menu entry

            currentTestIndex = FindSelectedTestIndex(selectedEntry);                            // Find selected entry in runner (will be -1 in failure case)
            StartCoroutine(LoadTest());                                                         // Start load
        }
예제 #3
0
        // ------------------------------------------------------------------------------------
        // Helper Methods

        // Clone a MenuTestEntry class
        public MenuTestEntry CloneMenuTestEntry(MenuTestEntry input)
        {
            MenuTestEntry output = new MenuTestEntry();

            output.suiteId      = input.suiteId;
            output.typeId       = input.typeId;
            output.groupId      = input.groupId;
            output.testId       = input.testId;
            output.currentLevel = input.currentLevel;
            return(output);
        }
예제 #4
0
        // Called every time a breadcrumb entry is clicked (button listener)
        public void OnBreadcrumbEntryClick(MenuBreadcrumbEntry clicked)
        {
            Console.Instance.Write(DebugLevel.Full, MessageLevel.Log, "Clicked: Breadcrumb entry"); // Write to console
            MenuEntryData entryData = CloneMenuEntryData(clicked.entryData);                        // Clone the entry data of the clicked entry

            ClearList();                                                                            // Clear the list
            selectedId = entryData.id;                                                              // Set selected id
            GenerateBreadcrumb(clicked.entryData);                                                  // Generate new breadcrumb
            selectedId.currentLevel++;                                                              // Increment current level
            GenerateList();                                                                         // Generate a new list
            CheckViewButtonStatus();                                                                // Check view button status
        }
예제 #5
0
        // ------------------------------------------------------------------------------------
        // Helper Methods

        // Find the runner index of the selected test
        int FindSelectedTestIndex(MenuTestEntry selectedEntry)
        {
            Console.Instance.Write(DebugLevel.Full, MessageLevel.Log, "Finding selected test index"); // Write to console
            for (int i = 0; i < runner.tests.Count; i++)                                              // Iterate tests
            {
                if (runner.tests[i].suiteIndex == selectedEntry.suiteId &&
                    runner.tests[i].groupIndex == selectedEntry.groupId &&
                    runner.tests[i].typeIndex == selectedEntry.typeId &&
                    runner.tests[i].testIndex == selectedEntry.testId) // If all data matches
                {
                    return(i);                                         // Return it
                }
            }
            Console.Instance.Write(DebugLevel.Critical, MessageLevel.LogError, "Test index not found!"); // Write to console
            return(-1);                                                                                  // Return failure
        }
예제 #6
0
 // Get a list of entries at a specific level
 public MenuEntryData[] GetEntries(MenuTestEntry input) // TODO - Can we shorten this?
 {
     MenuEntryData[] output = null;
     if (input.currentLevel == 0)
     {
         output = new MenuEntryData[testStructure.suites.Count];
     }
     for (int su = 0; su < testStructure.suites.Count; su++)
     {
         if (input.currentLevel == 0)
         {
             MenuEntryData entry = new MenuEntryData();
             MenuTestEntry id    = Menu.Instance.CloneMenuTestEntry(input);
             id.suiteId           = su;                      // Replace relevent data
             entry.entryName      = testStructure.suites[su].suiteName;
             entry.selectionState = testStructure.suites[su].selectionState;
             entry.id             = id;
             output[su]           = entry;
         }
         if (input.currentLevel >= 1)
         {
             if (su == input.suiteId)
             {
                 if (input.currentLevel == 1)
                 {
                     output = new MenuEntryData[testStructure.suites[su].types.Count];
                 }
                 for (int ty = 0; ty < testStructure.suites[su].types.Count; ty++)
                 {
                     if (input.currentLevel == 1 && su == input.suiteId)
                     {
                         MenuEntryData entry = new MenuEntryData();
                         MenuTestEntry id    = Menu.Instance.CloneMenuTestEntry(input);
                         id.currentLevel      = 1;                       // Replace relevent data
                         id.suiteId           = su;                      // Replace relevent data
                         id.typeId            = ty;                      // Replace relevent data
                         entry.entryName      = testStructure.suites[su].types[ty].typeName;
                         entry.selectionState = testStructure.suites[su].types[ty].selectionState;
                         entry.id             = id;
                         output[ty]           = entry;
                     }
                     if (input.currentLevel >= 2)
                     {
                         if (ty == input.typeId)
                         {
                             if (input.currentLevel == 2)
                             {
                                 output = new MenuEntryData[testStructure.suites[su].types[ty].groups.Count];
                             }
                             for (int gr = 0; gr < testStructure.suites[su].types[ty].groups.Count; gr++)
                             {
                                 if (input.currentLevel == 2 && ty == input.typeId)
                                 {
                                     MenuEntryData entry = new MenuEntryData();
                                     MenuTestEntry id    = Menu.Instance.CloneMenuTestEntry(input);
                                     id.currentLevel      = 2;                       // Replace relevent data
                                     id.suiteId           = su;                      // Replace relevent data
                                     id.typeId            = ty;                      // Replace relevent data
                                     id.groupId           = gr;                      // Replace relevent data
                                     entry.entryName      = testStructure.suites[su].types[ty].groups[gr].groupName;
                                     entry.selectionState = testStructure.suites[su].types[ty].groups[gr].selectionState;
                                     entry.id             = id;
                                     output[gr]           = entry;
                                 }
                                 if (input.currentLevel >= 3)
                                 {
                                     if (gr == input.groupId)
                                     {
                                         if (input.currentLevel == 3)
                                         {
                                             output = new MenuEntryData[testStructure.suites[su].types[ty].groups[gr].tests.Count];
                                         }
                                         for (int te = 0; te < testStructure.suites[su].types[ty].groups[gr].tests.Count; te++)
                                         {
                                             if (input.currentLevel == 3 && gr == input.groupId)
                                             {
                                                 MenuEntryData entry = new MenuEntryData();
                                                 MenuTestEntry id    = Menu.Instance.CloneMenuTestEntry(input);
                                                 id.currentLevel      = 3;                       // Replace relevent data
                                                 id.suiteId           = su;                      // Replace relevent data
                                                 id.typeId            = ty;                      // Replace relevent data
                                                 id.groupId           = gr;                      // Replace relevent data
                                                 id.testId            = te;                      // Replace relevent data
                                                 entry.entryName      = testStructure.suites[su].types[ty].groups[gr].tests[te].testName;
                                                 entry.selectionState = testStructure.suites[su].types[ty].groups[gr].tests[te].selectionState;
                                                 entry.id             = id;
                                                 output[te]           = entry;
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     Console.Instance.Write(DebugLevel.Full, MessageLevel.Log, "Returned entry list for level " + input.currentLevel); // Write to console
     return(output);
 }