Beispiel #1
0
        public void Drag()
        {
            if (WindowsVersion.IsAppVeyor())
            {
                Assert.Inconclusive("We need a Win 10 image on AppVeyor for testing touch.");
            }

            using (var app = Application.AttachOrLaunch(ExeFileName, WindowName))
            {
                var window = app.MainWindow;
                var area   = window.FindGroupBox("Touch area");
                var events = window.FindListBox("Events");

                Touch.Drag(area.Bounds.Center(), area.Bounds.TopLeft);
                var expected = new[]
                {
                    "TouchEnter Position: 99,299",
                    "PreviewTouchDown Position: 99,299",
                    "TouchDown Position: 99,299",
                    "ManipulationStarting",
                    "ManipulationStarted",
                    "PreviewTouchMove Position: -1,-1",
                    "TouchMove Position: -1,-1",
                    "ManipulationDelta",
                    "PreviewTouchUp Position: -1,-1",
                    "TouchUp Position: -1,-1",
                    "ManipulationInertiaStarting",
                    "ManipulationCompleted",
                    "TouchLeave Position: -1,-1",
                };

                CollectionAssert.AreEqual(expected, events.Items.Select(x => x.Text).ToArray());
            }
        }
Beispiel #2
0
        public void TapThenClick()
        {
            if (WindowsVersion.IsAppVeyor())
            {
                Assert.Inconclusive("We need a Win 10 image on AppVeyor for testing touch.");
            }

            using (var app = Application.AttachOrLaunch(ExeFileName, WindowName))
            {
                var window = app.MainWindow;
                var area   = window.FindGroupBox("Touch area");
                var events = window.FindListBox("Events");
                Touch.Tap(area.Bounds.Center());
                var expected = new[]
                {
                    "TouchEnter Position: 99,299",
                    "PreviewTouchDown Position: 99,299",
                    "TouchDown Position: 99,299",
                    "ManipulationStarting",
                    "ManipulationStarted",
                    "PreviewTouchUp Position: 99,299",
                    "TouchUp Position: 99,299",
                    "ManipulationInertiaStarting",
                    "ManipulationCompleted",
                    "TouchLeave Position: 99,299",
                };

                CollectionAssert.AreEqual(expected, events.Items.Select(x => x.Text).ToArray());
                User32.SetCursorPos((int)area.Bounds.Center().X + 1, (int)area.Bounds.Center().Y);
                app.MainWindow.FindButton("Clear").Click();
                CollectionAssert.IsEmpty(events.Items);
                Assert.AreEqual(CursorState.CURSOR_SHOWING, Mouse.GetCursorState());
            }
        }
        public void TapThenClickNoMove()
        {
            if (WindowsVersion.IsAppVeyor() ||
                WindowsVersion.IsAzureDevops())
            {
                Assert.Inconclusive("Not sure why this breaks on AppVeyor.");
            }

            using var app = Application.AttachOrLaunch(ExeFileName, WindowName);
            var window = app.MainWindow;
            var area   = window.FindGroupBox("Touch area");
            var events = window.FindListBox("Events");

            Touch.Tap(area.Bounds.Center());
            var expected = WindowsVersion.IsWindows10()
                ? new[]
            {
                "TouchEnter Position: 250,300",
                "PreviewTouchDown Position: 250,300",
                "TouchDown Position: 250,300",
                "ManipulationStarting",
                "ManipulationStarted",
                "StylusSystemGesture SystemGesture: Tap",
                "PreviewTouchUp Position: 250,300",
                "TouchUp Position: 250,300",
                "ManipulationInertiaStarting",
                "ManipulationCompleted",
                "TouchLeave Position: 250,300",
            }
                : new[]
            {
                "TouchEnter Position: 249,299",
                "PreviewTouchDown Position: 249,299",
                "TouchDown Position: 249,299",
                "ManipulationStarting",
                "ManipulationStarted",
                "StylusSystemGesture SystemGesture: Tap",
                "PreviewTouchUp Position: 249,299",
                "TouchUp Position: 249,299",
                "ManipulationInertiaStarting",
                "ManipulationCompleted",
                "TouchLeave Position: 249,299",
            };

            CollectionAssert.AreEqual(expected, events.Items.Select(x => x.Text).ToArray(), EventStringComparer.Default);

            window.FindButton("Clear").Click();
            window.WaitUntilResponsive();
            CollectionAssert.IsEmpty(events.Items);
            Assert.AreEqual(CursorState.CURSOR_SHOWING, Mouse.GetCursorState());
        }
Beispiel #4
0
        public void CalculatorTest()
        {
            if (WindowsVersion.IsAppVeyor() ||
                WindowsVersion.IsAzureDevops())
            {
                Assert.Inconclusive("Bug in store calc.");
            }

            using var app = StartApplication();

            // Looks like it can take a long time on CI
            app.WaitForMainWindow(TimeSpan.FromSeconds(30));
            var window = app.MainWindow;
            var calc   = WindowsVersion.IsWindows10()
                ? (ICalculator) new Win10Calc(window)
                : new LegacyCalc(window);

            Wait.For(TimeSpan.FromMilliseconds(200));

            // Switch to default mode
            Keyboard.TypeSimultaneously(Key.ALT, Key.KEY_1);
            window.WaitUntilResponsive();

            // Simple addition
            calc.Button1.Click();
            calc.Button2.Click();
            calc.Button3.Click();
            calc.Button4.Click();
            calc.ButtonAdd.Click();
            calc.Button5.Click();
            calc.Button6.Click();
            calc.Button7.Click();
            calc.Button8.Click();
            calc.ButtonEquals.Click();
            app.WaitWhileBusy();
            var result = calc.Result;

            Assert.AreEqual("6912", result);

            // Date comparison
            using (Keyboard.Hold(Key.CONTROL))
            {
                Keyboard.Type(Key.KEY_E);
            }
        }