Esempio n. 1
0
        public void TestRegimes_ClickPrehistoryBarNoOverlay_PrehistoryTimelineIsVisible()
        {
            var vc = new VirtualCanvasComponent(Driver);
            vc.SetVisible(new JsVisible(-21.173972602739752, 226047946.84065938, 0.02607632093933464));
            vc.UpdateViewport();
            Thread.Sleep(100);

            Point barPosition = vcPageObj.PrehistoryBar.Location;
            JsVisible visibleBefore = vcPageObj.GetViewport();

            action = new ActionsExtension(Driver);

            // Click on the regime bar.
            action.MoveByOffset(barPosition.X + 5, barPosition.Y + 2).Click().Perform();

            vcPageObj.WaitAnimation();

            JsVisible visibleAfter = vcPageObj.GetViewport();
            JsTimeline timeline = GetPrehistoryTimeline();
            double width = timeline.right - timeline.left;
            JsCoordinates timelineCenter = new JsCoordinates(timeline.left + width / 2, timeline.y + timeline.height / 2);

            Assert.IsTrue(IsTimlineInFullSize(visibleAfter, timeline));
            Assert.AreEqual(visibleAfter.CenterX, timelineCenter.X, AnimationImplicity);
            Assert.AreEqual(visibleAfter.CenterY, timelineCenter.Y, AnimationImplicity);
            Assert.AreNotEqual(visibleBefore, visibleAfter);
        }
        public void TestViewportController_ZoomForcesViewportToExceedMinPermittedZoomIn_ViewportDoesNotExceedMinPermittedZoomIn()
        {
            GoToUrl();

            double zoomFactor = ExecuteScriptGetNumber(@"return window.zoomLevelFactor;");
            dynamic timelines = ExecuteScript("return window.deeperZoomConstraints;");

            for (int i = 0; i < timelines.Count; i++)
            {
                /* Arrange
                 * Set up the viewport such that a zoom gesture
                 * forces the viewport to exceed the minimum zoomin level.
                 */
                Driver.Navigate().Refresh();

                IWebElement vcElem = Driver.FindElement(By.Id("vc"));

                dynamic timeline = timelines[i];
                double left = timeline["left"];
                double right = timeline["right"];
                double minScale = timeline["scale"];
                double aboveMinScale = minScale * zoomFactor;

                // for all scale in [minScale, aboveMinScale) => scale / zoomFactor < minScale
                Random rnd = new Random();
                double scale = minScale + rnd.NextDouble() * (aboveMinScale - minScale);

                var vc = new VirtualCanvasComponent(Driver);
                vc.SetVisible(new JsVisible((left + right) / 2, 0, scale));
                vc.UpdateViewport();

                /* Act
                 * ZoomIn.
                 */
                ActionsExtension act = new ActionsExtension(Driver);
                act.MoveToElement(vcElem, 10, 10);
                act.DoubleClick();
                act.Perform();
                vc.WaitAnimation();

                /* Assert
                 * Verify that the viewport after zooming doesn't
                 * exceed the minimum zoomin level.
                 */
                var vp = vc.GetViewport();
                Assert.IsTrue(vp.Scale >= minScale);
            }
        }
        public void TestViewportController_PanForcesViewportToExceedLeftBorder_ViewportDoesNotExceedLeftBorder()
        {
            /* Arrange
             * Set up the viewport such that a pan of width
             * forces the viewport to exceed the left border.
             */
            GoToUrl();

            IWebElement vcElem = Driver.FindElement(By.Id("vc"));
            double widthInSc = vcElem.Size.Width - 2;   // border of 1 px on each side
            double widthInVc = 1.37 * Ga;
            double scale = widthInVc / widthInSc;       // 1/10 the age of the universe

            double minLeftCenterX = ExecuteScriptGetNumber(@"return window.maxPermitedTimeRange.left;");

            var vc = new VirtualCanvasComponent(Driver);
            vc.SetVisible(new JsVisible(-13 * Ga, 0, scale));
            vc.UpdateViewport();

            /* Act
             * Pan by width to the right.
             */
            Vector pan = new Vector(widthInSc, 0);
            ActionsExtension act = new ActionsExtension(Driver);
            act.MoveToElement(vcElem, 0, 0);
            act.ClickAndHold();
            act.MoveByOffset(Convert.ToInt32(pan.X), Convert.ToInt32(pan.Y));
            act.Release();
            act.Perform();
            vc.WaitAnimation();

            /* Without the horizontal contraints the viewport centerX will exceed minLeftCenterX
             * after a pan of width as (-13Ga + -1.37Ga < 13.7Ga).
             * With the contraints in place viewport centerX is limited to minLeftCenterX.
             */

            /* Assert
             * Verify that the viewport centerX after
             * panning doesn't exceed the minLeftCenterX.
             */
            var vp = vc.GetViewport();
            double vpCenterX = vp.CenterX;

            Assert.AreEqual(minLeftCenterX, vpCenterX, 5);
        }
        public void TestViewportController_ZoomForcesViewportToExceedMaxPermittedZoomOut_ViewportDoesNotExceedMaxPermittedZoomOut()
        {
            /* Arrange
             * Set up the viewport such that a zoom gesture
             * forces the viewport to exceed maximum zoomout level.
             */
            GoToUrl();

            IWebElement vcElem = Driver.FindElement(By.Id("vc"));
            double width = vcElem.Size.Width - 2; // border of 1 px on each side

            double additionalPermitedPixels = ExecuteScriptGetNumber(@"return window.timelinesAbsenceInterval;");
            double zoomFactor = ExecuteScriptGetNumber(@"return window.zoomLevelFactor;");

            double maxScaleWithoutPadding = 13.7 * Ga / width;
            double maxScale = (13.7 * Ga + 2 * additionalPermitedPixels * maxScaleWithoutPadding) / width;
            double belowMaxScale = maxScale / zoomFactor;

            // for all scale in (belowMaxScale, maxScale] => scale * zoomFactor > maxScale
            Random rnd = new Random();
            double scale = belowMaxScale + rnd.NextDouble() * (maxScale - belowMaxScale);

            var vc = new VirtualCanvasComponent(Driver);
            vc.SetVisible(new JsVisible(-13.7 * Ga / 2, 0, scale));
            vc.UpdateViewport();

            /* Act
             * ZoomOut.
             */
            ExecuteScript(@"setZoomOut()");
            ActionsExtension act = new ActionsExtension(Driver);
            act.MoveToElement(vcElem, 10, 10);
            act.DoubleClick();
            act.Perform();
            vc.WaitAnimation();

            /* Assert
             * Verify that the viewport after zooming doesn't
             * exceed the maximum zoomout level.
             */
            var vp = vc.GetViewport();
            Assert.IsTrue(vp.Scale <= maxScale);
        }
Esempio n. 5
0
        public void TestGesture_ZoomWithInertialMotion_ViewportUpdatesCorrectly()
        {
            IWebElement vcElem = Driver.FindElement(By.Id("vc"));
            int width = vcElem.Size.Width;
            int height = vcElem.Size.Height;

            // center infodot as reference
            var vc = new VirtualCanvasComponent(Driver);
            vc.SetVisible(new JsVisible(-3194.8898068225376, 401.0288546497742, 0.38537988462392836));
            vc.UpdateViewport();

            Random rnd = new Random();
            Point zoomPt = new Point(rnd.Next(0, width), rnd.Next(0, height));

            JsCoordinates p1 = vc.PointScreenToVirtual(new JsCoordinates(zoomPt.X, zoomPt.Y));

            ActionsExtension act = new ActionsExtension(Driver);
            act.MoveToElement(vcElem, Convert.ToInt32(zoomPt.X), Convert.ToInt32(zoomPt.Y));
            act.DoubleClick();
            act.Perform();
            vc.WaitAnimation();

            JsCoordinates p2 = vc.PointVirtualToScreen(p1);

            // Assert that the zoom-pt remains fixed after zooming.
            Assert.AreEqual(zoomPt.X, p2.X, 5);
            Assert.AreEqual(zoomPt.Y, p2.Y, 5);
        }
Esempio n. 6
0
        public void TestGesture_PanWithInertialMotion_ViewportUpdatesCorrectly()
        {
            IWebElement vcElem = Driver.FindElement(By.Id("vc"));
            int width = vcElem.Size.Width;
            int height = vcElem.Size.Height;

            // center infodot as reference
            var vc = new VirtualCanvasComponent(Driver);
            vc.SetVisible(new JsVisible(-3194.8898068225376, 401.0288546497742, 0.38537988462392836));
            vc.UpdateViewport();

            Random rnd = new Random();
            Point panStart = new Point(rnd.Next(0, width), rnd.Next(0, height));
            Point panEnd = new Point(rnd.Next(0, width), rnd.Next(0, height));
            Vector pan = new Vector(panEnd.X - panStart.X, panEnd.Y - panStart.Y);

            JsCoordinates p1 = vc.PointScreenToVirtual(new JsCoordinates(panStart.X, panStart.Y));

            ActionsExtension act = new ActionsExtension(Driver);
            act.MoveToElement(vcElem, panStart.X, panStart.Y);
            act.ClickAndHold();
            act.MoveByOffset(Convert.ToInt32(pan.X), Convert.ToInt32(pan.Y));
            act.Release();
            act.Perform();
            vc.WaitAnimation();

            JsCoordinates p2 = vc.PointVirtualToScreen(p1);

            // Assert that start-pt wrt the newViewport corresponds to end-pt in the oldViewport
            Assert.AreEqual(panEnd.X, p2.X, 5);
            Assert.AreEqual(panEnd.Y, p2.Y, 5);
        }
Esempio n. 7
0
        public void TestGesture_ZoomWithInertialMotion_ViewportUpdatesCorrectly()
        {
            IWebElement vcElem = Driver.FindElement(By.Id("vc"));
            Assert.IsNotNull(vcElem, "err: cannot find canvas element");
            Assert.IsTrue(vcElem.Size.Width > 10 && vcElem.Size.Height > 10, "err: canvas size should be atleast (10px,10px) to run test");

            int width = vcElem.Size.Width - 10; // assuming a max border width of 5px on each side
            int height = vcElem.Size.Height - 10;

            VirtualCanvasComponent vc = new VirtualCanvasComponent(Driver);
            vc.SetVisible(new JsVisible(-3194.8898068225376, 401.0288546497742, 0.38537988462392836));
            vc.UpdateViewport();

            Random rnd = new Random();
            Point zoomPt = new Point(rnd.Next(0, width), rnd.Next(0, height));
            zoomPt.Offset(5, 5);

            JsCoordinates p1 = vc.PointScreenToVirtual(new JsCoordinates(zoomPt.X, zoomPt.Y));

            action = new ActionsExtension(Driver);
            action.MoveToElement(vcElem, Convert.ToInt32(zoomPt.X), Convert.ToInt32(zoomPt.Y));
            action.DoubleClick();
            action.Perform();
            vc.WaitAnimation();

            JsCoordinates p2 = vc.PointVirtualToScreen(p1);

            // Assert that the zoom-pt remains fixed after zooming.
            Assert.AreEqual(zoomPt.X, p2.X, 5);
            Assert.AreEqual(zoomPt.Y, p2.Y, 5);
        }
Esempio n. 8
0
        public void TestGesture_PanWithInertialMotion_ViewportUpdatesCorrectly()
        {
            IWebElement vcElem = Driver.FindElement(By.Id("vc"));
            Assert.IsNotNull(vcElem, "err: cannot find canvas element");
            Assert.IsTrue(vcElem.Size.Width > 10 && vcElem.Size.Height > 10, "err: canvas size should be atleast (10px,10px) to run test");

            int width = vcElem.Size.Width - 10; // assuming a max border width of 5px on each side
            int height = vcElem.Size.Height - 10;

            VirtualCanvasComponent vc = new VirtualCanvasComponent(Driver);
            vc.SetVisible(new JsVisible(-3194.8898068225376, 401.0288546497742, 0.38537988462392836));
            vc.UpdateViewport();

            Random rnd = new Random();
            Point panStart = new Point(rnd.Next(width), rnd.Next(height));
            panStart.Offset(5, 5);
            Point panEnd = new Point(rnd.Next(width), rnd.Next(height));
            panEnd.Offset(5, 5);
            Vector pan = new Vector(panEnd.X - panStart.X, panEnd.Y - panStart.Y);

            JsCoordinates p1 = vc.PointScreenToVirtual(new JsCoordinates(panStart.X, panStart.Y));

            action = new ActionsExtension(Driver);
            action.MoveToElement(vcElem, panStart.X, panStart.Y);
            action.ClickAndHold();
            action.MoveByOffset(Convert.ToInt32(pan.X), Convert.ToInt32(pan.Y));
            action.Release();
            action.Perform();
            vc.WaitAnimation();

            JsCoordinates p2 = vc.PointVirtualToScreen(p1);

            // Assert that start-pt wrt the newViewport corresponds to end-pt in the oldViewport
            Assert.AreEqual(panEnd.X, p2.X, 5);
            Assert.AreEqual(panEnd.Y, p2.Y, 5);
        }