public void ChangeSelectedIndex()
        {
            using var app = Application.Launch("Gu.Wpf.FlipView.Demo.exe", "FlipViewWindow");
            var window        = app.MainWindow;
            var flipView      = window.FindFirstDescendant(Conditions.ByAutomationId("FlipView"));
            var browseBack    = flipView.FindButton("BrowseBackButton");
            var browseForward = flipView.FindButton("BrowseForwardButton");
            var dummyButton   = window.FindButton("DummyButton");
            var selectedIndex = window.FindSlider("SelectedIndex");

            Assert.AreEqual(false, browseBack.IsEnabled);
            Assert.AreEqual(true, browseForward.IsEnabled);
            Assert.AreEqual(0, selectedIndex.Value);

            selectedIndex.Value = 1;
            dummyButton.Click();
            Assert.AreEqual(true, browseBack.IsEnabled);
            Assert.AreEqual(true, browseForward.IsEnabled);
            Assert.AreEqual(1, selectedIndex.Value);

            selectedIndex.Value = 3;
            dummyButton.Click();
            Assert.AreEqual(true, browseBack.IsEnabled);
            Assert.AreEqual(false, browseForward.IsEnabled);
            Assert.AreEqual(3, selectedIndex.Value);
        }
Beispiel #2
0
        public void BrowseBackAndForward()
        {
            using (var app = Application.Launch(Info.CreateStartInfo("FlipViewBoundWindow")))
            {
                var window        = app.MainWindow;
                var flipView      = window.FindFirstDescendant(Conditions.ByAutomationId("FlipView"));
                var browseBack    = flipView.FindButton("BrowseBackButton");
                var browseForward = flipView.FindButton("BrowseForwardButton");
                var dummyButton   = window.FindButton("DummyButton");
                var status        = window.FindTextBlock("Status");
                dummyButton.Click();
                window.WaitUntilResponsive();
                Assert.AreEqual("SelectedIndex: 0 SelectedItem: Johan Larsson", status.Text);
                Assert.AreEqual(false, browseBack.IsEnabled);
                Assert.AreEqual(true, browseForward.IsEnabled);

                browseForward.Click();
                window.WaitUntilResponsive();
                Assert.AreEqual(true, browseBack.IsEnabled);
                Assert.AreEqual(true, browseForward.IsEnabled);
                Assert.AreEqual("SelectedIndex: 1 SelectedItem: Erik Svensson", status.Text);

                browseBack.Click();
                window.WaitUntilResponsive();
                Assert.AreEqual(false, browseBack.IsEnabled);
                Assert.AreEqual(true, browseForward.IsEnabled);
                Assert.AreEqual("SelectedIndex: 0 SelectedItem: Johan Larsson", status.Text);

                browseForward.Click();
                window.WaitUntilResponsive();
                Assert.AreEqual(true, browseBack.IsEnabled);
                Assert.AreEqual(true, browseForward.IsEnabled);
                Assert.AreEqual("SelectedIndex: 1 SelectedItem: Erik Svensson", status.Text);

                browseForward.Click();
                window.WaitUntilResponsive();
                Assert.AreEqual(true, browseBack.IsEnabled);
                Assert.AreEqual(true, browseForward.IsEnabled);
                Assert.AreEqual("SelectedIndex: 2 SelectedItem: Reed Forkmann", status.Text);

                browseForward.Click();
                Wait.UntilInputIsProcessed();
                Assert.AreEqual(true, browseBack.IsEnabled);
                Assert.AreEqual(false, browseForward.IsEnabled);
                Assert.AreEqual("SelectedIndex: 3 SelectedItem: Cat Incremented", status.Text);

                browseBack.Click();
                window.WaitUntilResponsive();
                Assert.AreEqual(true, browseBack.IsEnabled);
                Assert.AreEqual(true, browseForward.IsEnabled);
                Assert.AreEqual("SelectedIndex: 2 SelectedItem: Reed Forkmann", status.Text);
            }
        }
        public void BrowseBackAndForward()
        {
            using (var app = Application.Launch(Info.CreateStartInfo("FlipViewWindow")))
            {
                var window        = app.MainWindow;
                var flipView      = window.FindFirstDescendant(Conditions.ByAutomationId("FlipView"));
                var browseBack    = flipView.FindButton("BrowseBackButton");
                var browseForward = flipView.FindButton("BrowseForwardButton");
                var dummyButton   = window.FindButton("DummyButton");
                var selectedIndex = window.FindSlider("SelectedIndex");
                dummyButton.Click();
                Assert.AreEqual(0, selectedIndex.Value);
                Assert.AreEqual(false, browseBack.IsEnabled);
                Assert.AreEqual(true, browseForward.IsEnabled);

                browseForward.Click();
                Assert.AreEqual(true, browseBack.IsEnabled);
                Assert.AreEqual(true, browseForward.IsEnabled);
                Assert.AreEqual(1, selectedIndex.Value);

                browseBack.Click();
                Assert.AreEqual(false, browseBack.IsEnabled);
                Assert.AreEqual(true, browseForward.IsEnabled);
                Assert.AreEqual(0, selectedIndex.Value);

                browseForward.Click();
                Assert.AreEqual(true, browseBack.IsEnabled);
                Assert.AreEqual(true, browseForward.IsEnabled);
                Assert.AreEqual(1, selectedIndex.Value);

                browseForward.Click();
                Assert.AreEqual(true, browseBack.IsEnabled);
                Assert.AreEqual(true, browseForward.IsEnabled);
                Assert.AreEqual(2, selectedIndex.Value);

                browseForward.Click();
                Assert.AreEqual(true, browseBack.IsEnabled);
                Assert.AreEqual(false, browseForward.IsEnabled);
                Assert.AreEqual(3, selectedIndex.Value);

                browseBack.Click();
                Assert.AreEqual(true, browseBack.IsEnabled);
                Assert.AreEqual(true, browseForward.IsEnabled);
                Assert.AreEqual(2, selectedIndex.Value);
            }
        }
Beispiel #4
0
        public void WhenSourceIsSetToEmpty()
        {
            using var app = Application.Launch("Gu.Wpf.FlipView.Demo.exe", "FlipViewBoundWindow");
            var window        = app.MainWindow;
            var flipView      = window.FindFirstDescendant(Conditions.ByAutomationId("FlipView"));
            var browseBack    = flipView.FindButton("BrowseBackButton");
            var browseForward = flipView.FindButton("BrowseForwardButton");
            var status        = window.FindTextBlock("Status");
            var setEmpty      = window.FindButton("Set empty");
            var reset         = window.FindButton("Reset");

            Assert.AreEqual("SelectedIndex: 0 SelectedItem: Johan Larsson", status.Text);

            setEmpty.Click();
            Assert.AreEqual("SelectedIndex: -1 SelectedItem: ", status.Text);
            Assert.AreEqual(false, browseBack.IsEnabled);
            Assert.AreEqual(false, browseForward.IsEnabled);

            reset.Click();
            Assert.AreEqual("SelectedIndex: 0 SelectedItem: Johan Larsson", status.Text);
            Assert.AreEqual(false, browseBack.IsEnabled);
            Assert.AreEqual(true, browseForward.IsEnabled);
        }
Beispiel #5
0
        public void WhenSourceIsCleared()
        {
            using (var app = Application.Launch(Info.CreateStartInfo("FlipViewBoundWindow")))
            {
                var window        = app.MainWindow;
                var flipView      = window.FindFirstDescendant(Conditions.ByAutomationId("FlipView"));
                var browseBack    = flipView.FindButton("BrowseBackButton");
                var browseForward = flipView.FindButton("BrowseForwardButton");
                var status        = window.FindTextBlock("Status");
                var clear         = window.FindButton("Clear");
                var reset         = window.FindButton("Reset");
                Assert.AreEqual("SelectedIndex: 0 SelectedItem: Johan Larsson", status.Text);

                clear.Click();
                Assert.AreEqual("SelectedIndex: -1 SelectedItem: ", status.Text);
                Assert.AreEqual(false, browseBack.IsEnabled);
                Assert.AreEqual(false, browseForward.IsEnabled);

                reset.Click();
                Assert.AreEqual("SelectedIndex: 0 SelectedItem: Johan Larsson", status.Text);
                Assert.AreEqual(false, browseBack.IsEnabled);
                Assert.AreEqual(true, browseForward.IsEnabled);
            }
        }
Beispiel #6
0
 public T Value()
 {
     return(this.FindFirst(TreeScope.Children, Conditions.ByAutomationId("PART_Value"), x => this.wrap(x)));
 }