Exemplo n.º 1
0
        public void Bugzilla39530PanTest()
        {
            // Got to wait for the element to be visible to the UI test framework, otherwise we get occasional
            // index out of bounds exceptions if the query for the frame and its Rect run quickly enough
            RunningApp.WaitForElement(q => q.Marked("frame"));
            AppRect frameBounds = RunningApp.Query(q => q.Marked("frame"))[0].Rect;

            RunningApp.Pan(new Drag(frameBounds, frameBounds.CenterX, frameBounds.Y + 10, frameBounds.X + 100, frameBounds.Y + 100, Drag.Direction.LeftToRight));

            RunningApp.WaitForElement(q => q.Marked("Panning: Completed"));
        }
Exemplo n.º 2
0
        public static bool RectsEqual(AppRect rectOne, AppRect rectTwo)
        {
            const float equalsTolerance = 0.1f;

            bool areEqual =
                (Math.Abs(rectOne.X - rectTwo.X) < equalsTolerance) &&
                (Math.Abs(rectOne.Y - rectTwo.Y) < equalsTolerance) &&
                (Math.Abs(rectOne.Width - rectTwo.Width) < equalsTolerance) &&
                (Math.Abs(rectOne.Height - rectTwo.Height) < equalsTolerance) &&
                (Math.Abs(rectOne.CenterX - rectTwo.CenterX) < equalsTolerance) &&
                (Math.Abs(rectOne.CenterY - rectTwo.CenterY) < equalsTolerance);

            return(areEqual);
        }
Exemplo n.º 3
0
        [ActivePlatforms(Platform.Browser | Platform.Android)]         // Test timed-out on iOS
        public void When_TextAlignment_Then_Layout_Is_Correct()
        {
            Run("UITests.Windows_UI_Xaml_Controls.TextBlockControl.TextBlock_LayoutAlignment");

            using var snapshot = this.TakeScreenshot("normal", ignoreInSnapshotCompare: true);

            for (var i = 1; i <= 10; i++)
            {
                for (var j = 1; j <= 4; j++)
                {
                    _app.Marked($"txt{i}_{j}").SetDependencyPropertyValue("Visibility", "Collapsed");
                }
            }

            using var snapshotTextHidden = this.TakeScreenshot("text_hidden", ignoreInSnapshotCompare: true);

            // This test will ensure the text "stays" in their designated zone.
            // Any overflow would indicate a problem in the text layout engine.

            for (var i = 1; i <= 10; i++)
            {
                for (var j = 1; j <= 4; j++)
                {
                    using var _ = new AssertionScope($"Text {i}_{j}");

                    var gridRect = _app.GetPhysicalRect($"grid{i}_{j}");
                    var textRect = _app.GetPhysicalRect($"rect{i}_{j}");

                    // Top
                    CheckRect(gridRect.X, gridRect.Y, gridRect.Width, textRect.Y - gridRect.Y);

                    // Bottom
                    CheckRect(gridRect.X, textRect.Bottom, gridRect.Width, gridRect.Bottom - textRect.Bottom);

                    // Left
                    CheckRect(gridRect.X, gridRect.Y, textRect.X - gridRect.X, gridRect.Height);

                    // Right
                    CheckRect(textRect.Right, gridRect.Y, gridRect.Right - textRect.Right, gridRect.Height);
                }
            }

            void CheckRect(float x, float y, float w, float h)
            {
                var r = new AppRect(x, y, w, h);

                ImageAssert.AreEqual(snapshotTextHidden, r, snapshot, r);
            }
        }
Exemplo n.º 4
0
        static AppRect ToAppRect(WindowsElement windowsElement)
        {
            var result = new AppRect
            {
                X      = windowsElement.Location.X,
                Y      = windowsElement.Location.Y,
                Height = windowsElement.Size.Height,
                Width  = windowsElement.Size.Width
            };

            result.CenterX = result.X + result.Width / 2;
            result.CenterY = result.Y + result.Height / 2;

            return(result);
        }
Exemplo n.º 5
0
        public static void NavigateToTestCase(this IApp app, string testCase)
        {
            string testCasesQuery = "* marked:'" + testCase + "'";
            var    testCaseIssue  = app.Query(q => q.Raw("* marked:'TestCasesIssueList'")).FirstOrDefault();

            if (testCaseIssue != null)
            {
                AppRect scrollRect = testCaseIssue.Rect;
                app.ScrollForElement(testCasesQuery, new Drag(scrollRect, Drag.Direction.BottomToTop, Drag.DragLength.Long));
                app.Tap(q => q.Raw(testCasesQuery));
            }
            else
            {
                Debug.WriteLine(string.Format("Failed to find test case {0}", testCase));
            }
        }
Exemplo n.º 6
0
        void RelaunchApp()
        {
            App            = null;
            RunningApp.App = null;

            try {
                RunningApp.Restart();
            } catch (Exception ex) {
                // if at first you dont succeed
                RunningApp.Restart();
            }
            App = RunningApp.App;

            App.SetOrientationPortrait();
            ScreenBounds = App.RootViewRect();
            NavigateToGallery();
        }
Exemplo n.º 7
0
		void RelaunchApp ()
		{
			App = null;
			RunningApp.App = null;

			try {
				RunningApp.Restart ();
			} catch (Exception ex) {
				// if at first you dont succeed
				RunningApp.Restart ();
			}
			App = RunningApp.App;

			App.SetOrientationPortrait ();
			ScreenBounds = App.RootViewRect ();
			NavigateToGallery ();
		}
Exemplo n.º 8
0
        void RelaunchApp()
        {
            App            = null;
            RunningApp.App = null;

            try {
                RunningApp.Restart();
            } catch (Exception ex) {
                // if at first you dont succeed
                RunningApp.Restart();
            }

            // Wrap the app in ScreenshotConditional so it only takes screenshots if the SCREENSHOTS symbol is specified
            App = new ScreenshotConditionalApp(RunningApp.App);

            App.SetOrientationPortrait();
            ScreenBounds = App.RootViewRect();
            NavigateToGallery();
        }
Exemplo n.º 9
0
		void RelaunchApp ()
		{
			App = null;
			RunningApp.App = null;

			try {
				RunningApp.Restart ();
			} catch (Exception ex) {
				// if at first you dont succeed
				RunningApp.Restart ();
			}

			// Wrap the app in ScreenshotConditional so it only takes screenshots if the SCREENSHOTS symbol is specified
			App = new ScreenshotConditionalApp(RunningApp.App);

			App.SetOrientationPortrait ();
			ScreenBounds = App.RootViewRect ();
			NavigateToGallery ();
		}
Exemplo n.º 10
0
        public void When_TextTrimming_Is_Set_Then_Ellipsis_Is_Used()
        {
            Run("UITests.Windows_UI_Xaml_Controls.TextBlockControl.TextBlock_TextTrimming");

            using var snapshot = this.TakeScreenshot("ellipsisText", ignoreInSnapshotCompare: true);

            var rectOfTextWithEllipsis = _app.GetPhysicalRect("border3");
            var rectThatShouldBeBlankBecauseOfEllipsis = new AppRect(
                x: rectOfTextWithEllipsis.Right - 15,
                y: rectOfTextWithEllipsis.Y,
                width: 15,
                height: rectOfTextWithEllipsis.Height * 0.6f);

            var cyan = "#00FFFF";

            ImageAssert.HasPixels(
                snapshot,
                ExpectedPixels.UniformRect(rectThatShouldBeBlankBecauseOfEllipsis, cyan)
                .WithTolerance(PixelTolerance.None));
        }
Exemplo n.º 11
0
		static void CenterElementInView (this IApp app, Func<AppQuery, AppQuery> element, AppRect containingView, Drag.Direction direction)
		{
			// TODO Implement horizontal centering

			if (direction == Drag.Direction.BottomToTop || direction == Drag.Direction.TopToBottom) {

				var elementBounds = app.Query (element).First ().Rect;

				bool elementCenterBelowContainerCenter = elementBounds.CenterY > containingView.CenterY;
				bool elementCenterAboveContainerCenter = elementBounds.CenterY < containingView.CenterY;

				var displacementToCenter = Math.Abs (elementBounds.CenterY - containingView.CenterY) / 2;

				// avoid drag as touch
				if (displacementToCenter < 50)
					return;

				if (elementCenterBelowContainerCenter) {
			
					var drag = new Drag (
						containingView,
						containingView.CenterX, containingView.CenterY + displacementToCenter,
						containingView.CenterX, containingView.CenterY - displacementToCenter,
						Drag.Direction.BottomToTop
						);

					app.DragCoordinates (drag.XStart, drag.YStart, drag.XEnd, drag.YEnd);

				} else if (elementCenterAboveContainerCenter) {

					var drag = new Drag (
						containingView,
						containingView.CenterX, containingView.CenterY - displacementToCenter,
						containingView.CenterX, containingView.CenterY + displacementToCenter,
						Drag.Direction.TopToBottom
						);

					app.DragCoordinates (drag.XStart, drag.YStart, drag.XEnd, drag.YEnd);
				}
			} 
		}
Exemplo n.º 12
0
        static void CenterElementInView(this IApp app, AppRect elementBounds, AppRect containingView, Drag.Direction direction)
        {
            // TODO Implement horizontal centering

            if (direction == Drag.Direction.BottomToTop || direction == Drag.Direction.TopToBottom)
            {
                bool elementCenterBelowContainerCenter = elementBounds.CenterY > containingView.CenterY;
                bool elementCenterAboveContainerCenter = elementBounds.CenterY < containingView.CenterY;

                var displacementToCenter = Math.Abs(elementBounds.CenterY - containingView.CenterY) / 2;

                // avoid drag as touch
                if (displacementToCenter < 50)
                {
                    return;
                }

                if (elementCenterBelowContainerCenter)
                {
                    var drag = new Drag(
                        containingView,
                        containingView.CenterX, containingView.CenterY + displacementToCenter,
                        containingView.CenterX, containingView.CenterY - displacementToCenter,
                        Drag.Direction.BottomToTop
                        );

                    app.DragCoordinates(drag.XStart, drag.YStart, drag.XEnd, drag.YEnd);
                }
                else if (elementCenterAboveContainerCenter)
                {
                    var drag = new Drag(
                        containingView,
                        containingView.CenterX, containingView.CenterY - displacementToCenter,
                        containingView.CenterX, containingView.CenterY + displacementToCenter,
                        Drag.Direction.TopToBottom
                        );

                    app.DragCoordinates(drag.XStart, drag.YStart, drag.XEnd, drag.YEnd);
                }
            }
        }
        public virtual void GoTo([CallerMemberName] string callerMemberName = "")
        {
            var scrollBounds = App.Query(Queries.PageWithoutNavigationBar()).First().Rect;

            // Scroll using gutter to the right of view, avoid scrolling inside of WebView
            if (PlatformViewType == PlatformViews.WebView)
            {
                scrollBounds = new AppRect
                {
                    X       = scrollBounds.Width - 20,
                    CenterX = scrollBounds.Width - 10,
                    Y       = scrollBounds.Y,
                    CenterY = scrollBounds.CenterY,
                    Width   = 20,
                    Height  = scrollBounds.Height,
                };
            }

            while (true)
            {
#if __MACOS__
                var result = App.Query(o => o.Raw(ViewQuery));
#else
                var result = App.Query(o => o.Raw(ContainerQuery));
#endif

                if (result.Any())
                {
                    break;
                }
                App.Tap(o => o.Raw("* marked:'MoveNextButton'"));
            }

            //Assert.True (App.ScrollForElement (
            //	ContainerQuery, new Drag (scrollBounds, Drag.Direction.BottomToTop, Drag.DragLength.Medium)
            //), "Failed to find element in: " + callerMemberName);

            App.Screenshot("Go to element");
        }
Exemplo n.º 14
0
        public virtual void GoTo([CallerMemberName] string callerMemberName = "")
        {
            // Scroll using gutter to the right of view, avoid scrolling inside of WebView
            if (PlatformViewType == PlatformViews.WebView)
            {
                var scrollBounds = App.Query(Queries.PageWithoutNavigationBar()).First().Rect;

                scrollBounds = new AppRect
                {
                    X       = scrollBounds.Width - 20,
                    CenterX = scrollBounds.Width - 10,
                    Y       = scrollBounds.Y,
                    CenterY = scrollBounds.CenterY,
                    Width   = 20,
                    Height  = scrollBounds.Height,
                };
            }

            App.WaitForElement("TargetViewContainer");
            App.Tap("TargetViewContainer");
            App.EnterText(callerMemberName.Replace("_", "") + "VisualElement");
            App.Tap("GoButton");
        }
Exemplo n.º 15
0
        public void When_Text_is_Constrained_Then_Clipping_is_Applied()
        {
            Run("Uno.UI.Samples.Content.UITests.TextBlockControl.TextBlock_ConstrainedByContainer");


            // 1) Take a screenshot of the whole sample
            // 2) Switch opacity of text to zero
            // 3) Take new screenshot
            // 4) Compare Right zone -- must be identical
            // 5) Compare Bottom zone -- must be identical
            // 6) Do the same for subsequent text block in sample (1 to 5)
            //
            // +-sampleRootPanel------------+--------------+
            // |                            |              |
            // |    +-borderX---------------+              |
            // |    | [textX]Lorem ipsum... |              |
            // |    +-----------------------+  Right zone  |
            // |    |                       |              |
            // |    |    Bottom zone        |              |
            // |    |                       |              |
            // +----+-----------------------+--------------+

            // (1)
            using var sampleScreenshot = this.TakeScreenshot("fullSample", ignoreInSnapshotCompare: true);
            var sampleRect = _app.GetPhysicalRect("sampleRootPanel");

            using var _ = new AssertionScope();


            Test("text1", "border1");
            Test("text2", "border2");
            Test("text3", "border3");
            Test("text4", "border4");
            Test("text5", "border5");

            void Test(string textControl, string borderControl)
            {
                var textRect = _app.GetPhysicalRect(borderControl);

                // (2)
                _app.Marked(textControl).SetDependencyPropertyValue("Opacity", "0");

                // (3)
                using var afterScreenshot = this.TakeScreenshot("sample-" + textControl, ignoreInSnapshotCompare: true);

                // (4)
                using (var s = new AssertionScope("Right zone"))
                {
                    var rect1 = new AppRect(
                        x: textRect.Right,
                        y: sampleRect.Y,
                        width: sampleRect.Right - textRect.Right,
                        height: sampleRect.Height)
                                .DeflateBy(1f);

                    ImageAssert.AreEqual(sampleScreenshot, rect1, afterScreenshot, rect1);
                }

                // (5)
                using (var s = new AssertionScope("Bottom zone"))
                {
                    var rect2 = new AppRect(
                        x: textRect.X,
                        y: textRect.Bottom,
                        width: textRect.Width,
                        height: sampleRect.Height - textRect.Bottom)
                                .DeflateBy(1f);

                    ImageAssert.AreEqual(sampleScreenshot, rect2, afterScreenshot, rect2);
                }
            }
        }
Exemplo n.º 16
0
 protected override void TestSetup()
 {
     base.TestSetup();
     screenSize = App.Query(q => q.Marked("ActionSheetPage"))[0].Rect;
 }
Exemplo n.º 17
0
 public XamarinAppRect(AppRect rect) => this._source = rect;
Exemplo n.º 18
0
 public VisualCell(int value, AppRect coordinates)
 {
     Value       = value;
     Coordinates = coordinates;
 }