Exemplo n.º 1
0
        /// <summary>
        /// Enables/disables running selected test(s).
        /// </summary>
        void EnableRunCurrent()
        {
            if (!_certificationMode)
            {
                tsbRunSelected.Enabled = tvTestCases.SelectedNode != null;
            }
            else
            {
                /* RunSelected in CertificationMode depends on features*/
                TreeNode node = tvTestCases.SelectedNode;
                if (node != null)
                {
                    bool bCanRunTest = true;

                    if (node.Tag != null)
                    {
                        TestInfo testInfo = (TestInfo)node.Tag;
                        if (_certificationMode)
                        {
                            bCanRunTest = FeaturesHelper.AllFeaturesSelected(testInfo);
                        }
                    }
                    else
                    {
                        bCanRunTest = GroupNodeAllowed(node);
                    }
                    tsbRunSelected.Enabled = bCanRunTest;
                }
                else
                {
                    tsbRunSelected.Enabled = false;
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Cancels test selection if forbidden (test is running, certification mode)
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tvTestCases_BeforeCheck(object sender, TreeViewCancelEventArgs e)
        {
            if (_controller.Running)
            {
                // no selection when test is running
                e.Cancel = true;
            }
            if (_certificationMode && !_bProfileBeingApplied && e.Node.Tag != null)
            {
                TestInfo testInfo = (TestInfo)e.Node.Tag;

                if (testInfo.RequirementLevel == RequirementLevel.Must ||
                    testInfo.RequirementLevel == RequirementLevel.ConditionalMust)
                {
                    // cannot unselect "Must"/"Must if" tests.
                    // (such tests are selected by default)
                    e.Cancel = true;
                }
                else if (testInfo.RequirementLevel == RequirementLevel.ConditionalShould)
                {
                    // cannot select "Should if" tests if not all features are implemented.
                    // (such tests are unselected by default)
                    bool bAllSelected = FeaturesHelper.AllFeaturesSelected(testInfo);
                    if (!bAllSelected)
                    {
                        e.Cancel = true;
                    }
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Selects default tests for certification mode.
        /// All "Must", "Should", "Optional" tests are selected.
        /// All "Must if", "Should if" tests are selected depending on features selected at the "Management" page.
        /// </summary>
        void SelectAllTests()
        {
            DeviceEnvironment environment = ContextController.GetDeviceEnvironment();

            foreach (TestInfo testInfo in _testNodes.Keys)
            {
                switch (testInfo.RequirementLevel)
                {
                case RequirementLevel.Must:
                case RequirementLevel.Should:
                case RequirementLevel.Optional:
                    _testNodes[testInfo].Checked = true;
                    break;

                case RequirementLevel.ConditionalMust:
                case RequirementLevel.ConditionalShould:
                {
                    _testNodes[testInfo].Checked = FeaturesHelper.AllFeaturesSelected(testInfo);
                }
                break;
                }
            }

            SelectTestGroups();
        }
Exemplo n.º 4
0
        /// <summary>
        /// Selects default tests for certification mode.
        /// All "Must", "Should", "Optional" tests are selected.
        /// All "Must if", "Should if" tests are selected depending on features selected at the "Management" page.
        /// </summary>
        void SelectAllTests()
        {
            foreach (TestInfo testInfo in _testNodes.Keys)
            {
                switch (testInfo.RequirementLevel)
                {
                case Tests.Common.Enums.RequirementLevel.Must:
                case Tests.Common.Enums.RequirementLevel.Should:
                case Tests.Common.Enums.RequirementLevel.Optional:
                    //System.Diagnostics.Debug.WriteLine(string.Format("Select {0}", testInfo.Name));
                    _testNodes[testInfo].Checked = true;
                    break;

                case Tests.Common.Enums.RequirementLevel.ConditionalMust:
                case Tests.Common.Enums.RequirementLevel.ConditionalShould:
                {
                    bool bClear = !FeaturesHelper.AllFeaturesSelected(testInfo);
                    _testNodes[testInfo].Checked = !bClear;
                    if (!bClear)
                    {
                        System.Diagnostics.Debug.WriteLine(string.Format("Select {0}", testInfo.Name));
                    }
                }
                break;
                }
            }

            SelectTestGroups();
        }
Exemplo n.º 5
0
        /// <summary>
        /// Checks if any of tests beneath node specified is allowed.
        /// </summary>
        /// <param name="node"></param>
        /// <returns></returns>
        bool GroupNodeAllowed(TreeNode node)
        {
            List <TestInfo> tests = new List <TestInfo>();

            AddChildNodes(node, tests);

            return(tests.Where(t => FeaturesHelper.AllFeaturesSelected(t)).FirstOrDefault() != null);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Run selected test or tests in selected group.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tsbRunSelected_Click(object sender, EventArgs e)
        {
            TreeNode node = tvTestCases.SelectedNode;

            if (node != null)
            {
                TestInfo            testInfo   = (TestInfo)node.Tag;
                TestSuiteParameters parameters = GetParameters();

                if (testInfo != null)
                {
                    parameters.TestCases.Add(testInfo);
                }
                else
                {
                    List <TestInfo> tests = new List <TestInfo>();
                    AddChildNodes(node, tests);

                    List <TestInfo> allowedTests = new List <TestInfo>();
                    if (_certificationMode)
                    {
                        allowedTests.AddRange(tests.Where(t => FeaturesHelper.AllFeaturesSelected(t)));
                    }
                    else
                    {
                        allowedTests.AddRange(tests);
                    }

                    if (parameters.InteractiveFirst)
                    {
                        parameters.TestCases.AddRange(allowedTests.OrderBy(t => !t.Interactive).ThenBy(t => t.Order));
                    }
                    else
                    {
                        parameters.TestCases.AddRange(allowedTests.OrderBy(t => t.Order));
                    }
                }
                ClearTestInfo();
                _controller.RunSingle(parameters);
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Selects child tests available for current features selection in certification mode.
        /// </summary>
        /// <param name="node"></param>
        void SelectAvailableChildTests(TreeNode node)
        {
            foreach (TreeNode child in node.Nodes)
            {
                if (child.Tag != null)
                {
                    TestInfo testInfo = (TestInfo)child.Tag;

                    switch (testInfo.RequirementLevel)
                    {
                    case RequirementLevel.Should:
                    case RequirementLevel.Optional:
                    {
                        child.Checked = node.Checked;
                    }
                    break;

                    case RequirementLevel.ConditionalShould:
                    {
                        if (node.Checked)
                        {
                            bool bClear = !FeaturesHelper.AllFeaturesSelected(testInfo);
                            _testNodes[testInfo].Checked = !bClear;
                        }
                        else
                        {
                            child.Checked = false;
                        }
                    }
                    break;
                    }
                }
                else
                {
                    // group
                    child.Checked = node.Checked;
                    CheckIfAllChildrenChecked(child);
                }
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Handles selection in tests tree.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tvTestCases_AfterSelect(object sender, TreeViewEventArgs e)
        {
            if (_controller.Running)
            {
                return;
            }

            TreeNode node = tvTestCases.SelectedNode;

            ClearTestInfo();
            if (node != null)
            {
                bool bCanRunTest = true;

                if (node.Tag != null)
                {
                    TestInfo   testInfo = (TestInfo)node.Tag;
                    TestResult log      = _controller.GetTestResult(testInfo);

                    if (log != null)
                    {
                        DisplayTestResults(log);
                    }

                    if (_certificationMode)
                    {
                        bCanRunTest = FeaturesHelper.AllFeaturesSelected(testInfo);
                    }
                }
                else
                {
                    if (_certificationMode)
                    {
                        bCanRunTest = GroupNodeAllowed(node);
                    }
                }
                tsbRunSelected.Enabled = !_controller.Running && bCanRunTest;
                //tsbRunSelected.Enabled = !_controller.Running;
            }
        }