Ejemplo n.º 1
0
        public void PreviousPageButtonChangingPageTest()
        {
            using (var setup = new TestSetupHelper("PagerControl Tests"))
            {
                elements = new PagerControlTestPageElements();
                VerifyPageChanged(0);
                InputHelper.LeftClick(elements.GetNextPageButton());

                InputHelper.LeftClick(elements.GetPreviousPageButton());
                VerifyPageChanged(0);

                InputHelper.LeftClick(elements.GetLastPageButton());

                InputHelper.LeftClick(elements.GetPreviousPageButton());
                VerifyPageChanged(3);

                InputHelper.LeftClick(elements.GetPreviousPageButton());
                VerifyPageChanged(2);

                InputHelper.LeftClick(elements.GetPreviousPageButton());
                VerifyPageChanged(1);

                InputHelper.LeftClick(elements.GetPreviousPageButton());
                VerifyPageChanged(0);
            }
        }
 protected void VerifyButton(UIObject button, Visibility expectedVisibility, bool shouldBeEnabled)
 {
     if (button == elements.GetFirstPageButton())
     {
         VerifyFirstPageButtonVisibility(expectedVisibility);
         VerifyFirstPageButtonIsEnabled(shouldBeEnabled);
     }
     else if (button == elements.GetPreviousPageButton())
     {
         VerifyPreviousPageButtonVisibility(expectedVisibility);
         VerifyPreviousPageButtonIsEnabled(shouldBeEnabled);
     }
     else if (button == elements.GetNextPageButton())
     {
         VerifyNextPageButtonVisibility(expectedVisibility);
         VerifyNextPageButtonIsEnabled(shouldBeEnabled);
     }
     else if (button == elements.GetLastPageButton())
     {
         VerifyLastPageButtonVisibility(expectedVisibility);
         VerifyLastPageButtonIsEnabled(shouldBeEnabled);
     }
 }
Ejemplo n.º 3
0
        public void NumberPanelChangingPageTest2()
        {
            using (var setup = new TestSetupHelper("PagerControl Tests"))
            {
                elements = new PagerControlTestPageElements();

                VerifyPageChanged(0);

                SetNumberPanelDisplayMode();
                VerifyNumberPanelDisplayMode();

                InputHelper.LeftClick(elements.GetNextPageButton());
                VerifyPageChanged(1);
                VerifyNumberPanelContent("12345");

                InputHelper.LeftClick(elements.GetLastPageButton());
                VerifyPageChanged(4);
                VerifyNumberPanelContent("12345");

                InputHelper.LeftClick(elements.GetPreviousPageButton());
                VerifyPageChanged(3);
                VerifyNumberPanelContent("12345");

                InputHelper.LeftClick(elements.GetPreviousPageButton());
                VerifyPageChanged(2);
                VerifyNumberPanelContent("12345");

                ChangeNumberOfPages();
                VerifyNumberOfPages("100");

                InputHelper.LeftClick(elements.GetFirstPageButton());
                VerifyPageChanged(0);
                VerifyNumberPanelContent("12345More100");

                InputHelper.LeftClick(elements.GetNextPageButton());
                VerifyPageChanged(1);
                VerifyNumberPanelContent("12345More100");

                InputHelper.LeftClick(elements.GetNextPageButton());
                VerifyPageChanged(2);
                VerifyNumberPanelContent("12345More100");

                InputHelper.LeftClick(elements.GetNextPageButton());
                VerifyPageChanged(3);
                VerifyNumberPanelContent("12345More100");

                InputHelper.LeftClick(elements.GetNextPageButton());
                VerifyPageChanged(4);
                VerifyNumberPanelContent("1More456More100");

                InputHelper.LeftClick(elements.GetNextPageButton());
                VerifyPageChanged(5);
                VerifyNumberPanelContent("1More567More100");

                InputHelper.LeftClick(elements.GetLastPageButton());
                VerifyPageChanged(99);

                VerifyNumberPanelContent("1More96979899100");

                InputHelper.LeftClick(elements.GetPreviousPageButton());
                VerifyPageChanged(98);
                VerifyNumberPanelContent("1More96979899100");

                InputHelper.LeftClick(elements.GetPreviousPageButton());
                VerifyPageChanged(97);
                VerifyNumberPanelContent("1More96979899100");

                InputHelper.LeftClick(elements.GetPreviousPageButton());
                VerifyPageChanged(96);
                VerifyNumberPanelContent("1More96979899100");

                InputHelper.LeftClick(elements.GetPreviousPageButton());
                VerifyPageChanged(95);
                VerifyNumberPanelContent("1More959697More100");
            }
        }
        protected void ButtonVisibilityOptionsTest(string buttonNamePrefix)
        {
            SetButtonVisibilityModeFunction SetButtonVisibilityMode;
            UIObject buttonBeingTested;

            using (var setup = new TestSetupHelper("PagerControl Tests"))
            {
                elements = new PagerControlTestPageElements();
                switch (buttonNamePrefix)
                {
                case "First":
                    SetButtonVisibilityMode = SetFirstPageButtonVisibilityMode;
                    buttonBeingTested       = elements.GetFirstPageButton();
                    break;

                case "Previous":
                    SetButtonVisibilityMode = SetPreviousPageButtonVisibilityMode;
                    buttonBeingTested       = elements.GetPreviousPageButton();
                    break;

                case "Next":
                    SetButtonVisibilityMode = SetNextPageButtonVisibilityMode;
                    buttonBeingTested       = elements.GetNextPageButton();
                    break;

                case "Last":
                    SetButtonVisibilityMode = SetLastPageButtonVisibilityMode;
                    buttonBeingTested       = elements.GetLastPageButton();
                    break;

                default:
                    Log.Warning("This test is being skipped because the button string was not one of these four strings: [First, Previous, Next, Last]");
                    return;
                }

                VerifyPageChanged(0);

                foreach (ButtonVisibilityModes visMode in Enum.GetValues(typeof(ButtonVisibilityModes)))
                {
                    SetButtonVisibilityMode(visMode);
                    GetLastPage();
                    // If we're not on the first page then navigate to the first page.
                    if (GetCurrentPageAsInt() != 0)
                    {
                        SelectValueInPagerComboBox(0);
                        VerifyPageChanged(0);
                    }

                    var expectedVisibility = ((visMode == ButtonVisibilityModes.None) ||
                                              (visMode == ButtonVisibilityModes.HiddenOnEdge &&
                                               (buttonNamePrefix == "First" || buttonNamePrefix == "Previous"))) ? Visibility.Collapsed : Visibility.Visible;

                    var expectedIsEnableValue = (buttonNamePrefix == "First" || buttonNamePrefix == "Previous") ? false : true;

                    VerifyButton(buttonBeingTested, expectedVisibility, expectedIsEnableValue);

                    SelectValueInPagerComboBox(1);
                    VerifyPageChanged(1);

                    expectedVisibility    = (visMode == ButtonVisibilityModes.None) ? Visibility.Collapsed : Visibility.Visible;
                    expectedIsEnableValue = true;

                    VerifyButton(buttonBeingTested, expectedVisibility, expectedIsEnableValue);

                    SelectValueInPagerComboBox(GetLastPageAsInt() - 1);
                    VerifyPageChanged(GetLastPageAsInt() - 1);

                    expectedVisibility = ((visMode == ButtonVisibilityModes.None) ||
                                          (visMode == ButtonVisibilityModes.HiddenOnEdge &&
                                           (buttonNamePrefix == "Next" || buttonNamePrefix == "Last"))) ? Visibility.Collapsed : Visibility.Visible;

                    expectedIsEnableValue = (buttonNamePrefix == "Next" || buttonNamePrefix == "Last") ? false : true;

                    VerifyButton(buttonBeingTested, expectedVisibility, expectedIsEnableValue);
                }
            }
        }