Ejemplo n.º 1
0
        public void When_Foreground_Changed_With_Visibility()
        {
            Run("UITests.Shared.Windows_UI_Xaml_Controls.TextBlockControl.TextBlock_Foreground_While_Collapsed");

            _app.WaitForText("FunnyTextBlock", "Look at me now");

            var blueBefore = TakeScreenshot("Before - blue");

            _app.Tap("ChangeTextBlockButton");

            var blackBefore = TakeScreenshot("Before - black");

            var textRect = _app.GetRect("FunnyTextBlock");

            ImageAssert.AssertScreenshotsAreNotEqual(blueBefore, blackBefore, textRect);

            _app.Tap("ChangeTextBlockButton");

            //_app.WaitForNoElement("FunnyTextBlock"); // This times out on WASM because view is considered to be still there when collapsed - https://github.com/unoplatform/Uno.UITest/issues/25

            _app.Tap("ChangeTextBlockButton");

            _app.WaitForElement("FunnyTextBlock");

            var blueAfter = TakeScreenshot("After - blue");

            ImageAssert.AssertScreenshotsAreEqual(blueBefore, blueAfter, textRect);
        }
Ejemplo n.º 2
0
        [ActivePlatforms(Platform.Android)]         // Disabled on iOS: https://github.com/unoplatform/uno/issues/1955
        public void Keyboard_DismissTesting()
        {
            Run(("Uno.UI.Samples.Content.UITests.ButtonTestsControl.AppBar_KeyBoard"));
            var appCommandBar  = _app.Marked("AppCommandBar");
            var buttonDisabled = _app.Marked("ButtonDisabled");
            var buttonDone     = _app.Marked("ButtonDone");
            var textBoxMessage = _app.Marked("TextBoxMessage");
            var singleTextBox  = _app.Marked("SingleTextBox");

            _app.WaitForElement(singleTextBox);

            var initial = TakeScreenshot("initial");

            singleTextBox.Tap();
            _app.Wait(2);

            // Click on AppBar Button
            var   appCommandBarPosition = appCommandBar.FirstResult().Rect;
            float xPosition             = appCommandBarPosition.Width - 90;
            float yPosition             = appCommandBarPosition.Height / 2;

            _app.TapCoordinates(appCommandBarPosition.X + xPosition, appCommandBarPosition.Y + yPosition);
            _app.Wait(3);
            _app.Back();

            var final = TakeScreenshot("final");

            ImageAssert.AssertScreenshotsAreEqual(initial, final);
        }
Ejemplo n.º 3
0
        private void TestVisualTests(string targetName, Action <IAppRect> act, params string[] expectedStates)
        {
            var initial = TakeScreenshot("Initial", ignoreInSnapshotCompare: true);
            var target  = _app.WaitForElement(targetName).Single().Rect;

            act(target);

            var final        = TakeScreenshot("Final", ignoreInSnapshotCompare: true);
            var actualStates = _app
                               .Marked("VisualStatesLog")
                               .GetDependencyPropertyValue <string>("Text")
                               .Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)
                               .Where(line => line.StartsWith(targetName))
                               .Select(line => line.Trim().Substring(targetName.Length + 1))
                               .ToArray();

            if (expectedStates?.Any() ?? false)
            {
                CollectionAssert.AreEqual(expectedStates, actualStates, StringComparer.OrdinalIgnoreCase);
            }

            // For the comparison, we compare only the location of the control (i.e. we provide the rect).
            // This is required to NOT include the visual output ot the states (on the right of the test control)
            ImageAssert.AssertScreenshotsAreEqual(initial, final, target);
        }
Ejemplo n.º 4
0
        public void TestListViewReleasedOut()
        {
            Run("UITests.Shared.Windows_UI_Input.VisualStatesTests.ListViewItem");

            var initial = TakeScreenshot("Initial");
            var rect    = _app.WaitForElement("MyListView").Single().Rect;

            // Press over and move out to release
            _app.DragCoordinates(rect.X + 10, rect.Y + 10, rect.X - 30, rect.Y);

            var final = TakeScreenshot("Final");

            ImageAssert.AssertScreenshotsAreEqual(initial, final, rect);
        }
Ejemplo n.º 5
0
        public void Measure_CollapsedShapeInSmallScrollViewer()
        {
            Run("UITests.Shared.Windows_UI_Xaml_Shapes.MeasurePage");

            var sut     = _app.WaitForElement("CollapsedInSmallScrollViewer").Single();
            var initial = TakeScreenshot("initial");

            // Try to scroll up
            _app.DragCoordinates(sut.Rect.CenterX, sut.Rect.Bottom - 5, sut.Rect.CenterX, sut.Rect.Y + 5);             // Touch scroll
            for (var i = 0; i < 10; i++)
            {
                _app.TapCoordinates(sut.Rect.Right - 5, sut.Rect.Bottom - 5);                                      // Mouse scroll
            }
            var final = TakeScreenshot("final");

            ImageAssert.AssertScreenshotsAreEqual(initial, final, sut.Rect);
        }
Ejemplo n.º 6
0
        public void PasswordBox_RevealInScrollViewer()
        {
            Run("Uno.UI.Samples.Content.UITests.TextBoxControl.PasswordBox_Reveal_Scroll");

            var passwordBox = _app.WaitForElement("MyPasswordBox").Single();
            var initial     = TakeScreenshot("initial");

            // Focus the PasswordBox
            _app.TapCoordinates(passwordBox.Rect.X + 10, passwordBox.Rect.Y);

            // Press the reveal button, and move up (so the ScrollViewer will kick in and cancel the pointer), then release
            _app.DragCoordinates(passwordBox.Rect.X + 10, passwordBox.Rect.Right - 10, passwordBox.Rect.X - 100, passwordBox.Rect.Right - 10);

            var result = TakeScreenshot("result");

            ImageAssert.AssertScreenshotsAreEqual(initial, result, passwordBox.Rect);
        }