public void TestAxisPan()
        {
            IJavaScriptExecutor js = Driver as IJavaScriptExecutor;

            IWebElement axis = Driver.FindElement(By.Id("axis"));

            var previousVisible = (Driver as IJavaScriptExecutor).ExecuteScript("return $('#vc').virtualCanvas('getViewport').visible;") as Dictionary<string, object>; //saving initial visible region

            ActionsExtension pan = new ActionsExtension(Driver);

            pan.MoveToElement(axis,axis.Size.Width/2,axis.Size.Height/2);
            pan.ClickAndHold();
            pan.MoveByOffset(-50, 20);
            pan.Release();
            pan.Perform(); //preforming panning

            pan.SetDefault(); // return mouse position to default

            Thread.Sleep(3000); //waiting the animation to complete

            var newVisible = (Driver as IJavaScriptExecutor).ExecuteScript("return $('#vc').virtualCanvas('getViewport').visible;") as Dictionary<string, object>; //saving new visible region after pan

            Assert.AreEqual(Convert.ToDouble(previousVisible["centerY"]), Convert.ToDouble(newVisible["centerY"])); //the Y must not be changed, as the axis pan is only horizontal
            Assert.IsTrue(Convert.ToDouble(previousVisible["centerX"]) < Convert.ToDouble(newVisible["centerX"])); //the X must ascend
        }
Exemplo n.º 2
0
        public void TestInterruptTourByPan()
        {
            IJavaScriptExecutor js = Driver as IJavaScriptExecutor;

            Thread.Sleep(2000);
            js.ExecuteScript("activateTour(tours[3]);"); // running test tour
            Thread.Sleep(500);

            var state1 = js.ExecuteScript("return {state: tour.state};") as Dictionary<string, object>;

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

            pan = new ActionsExtension(Driver);

            pan.MoveToElement(vc, vc.Size.Width / 2, vc.Size.Height / 2);
            pan.ClickAndHold();
            pan.MoveByOffset(-50, 20);
            pan.Release();
            pan.Perform(); //preforming panning

            pan.SetDefault(); // return mouse position to default

            var state2 = js.ExecuteScript("return {state: tour.state}") as Dictionary<string, object>;

            Thread.Sleep(500);

            Assert.AreEqual("play", state1["state"].ToString());
            Assert.AreEqual("pause", state2["state"].ToString());
        }
Exemplo n.º 3
0
        public void TestBreadCrumbLink()
        {
            int ellipticZoomTimeWait = 6200;
            IJavaScriptExecutor js = Driver as IJavaScriptExecutor;

            var setVis = (Driver as IJavaScriptExecutor).ExecuteScript(
                "setVisible(new VisibleRegion2d(-692.4270728052991,222750361.2049456,0.35779500398729397));" //going into Humanity timline (coordinates snapshot)
                );
            Thread.Sleep(ellipticZoomTimeWait);

            var zoomedVisible = (Driver as IJavaScriptExecutor).ExecuteScript("return $('#vc').virtualCanvas('getViewport').visible;") as Dictionary<string, object>; //saving visible region after zoom
            IWebElement crumb = Driver.FindElement(By.Id("bc_0")); //finding second bread crumb to test a link of it
            Point crumbPosition = crumb.Location;

            ActionsExtension crumbClick = new ActionsExtension(Driver);
            crumbClick.MoveByOffset(crumbPosition.X + 2, crumbPosition.Y + 2)
                .Click()
                .Perform(); //clicking on the bread crumb
            crumbClick.SetDefault(); // return mouse position to default
            Thread.Sleep(ellipticZoomTimeWait);

            var breadCrumbVisible = (Driver as IJavaScriptExecutor).ExecuteScript("return $('#vc').virtualCanvas('getViewport').visible;") as Dictionary<string, object>; //saving visible region after clicking bread crumb

            Assert.IsTrue(Convert.ToDouble(zoomedVisible["scale"]) < Convert.ToDouble(breadCrumbVisible["scale"])); //scale must ascend
        }
Exemplo n.º 4
0
        public void TestGestures_MouseActivity_GestureBodyIsCorrect()
        {
            Dictionary<string, object> offset, scale;

            const int offsetX = 100;
            const int offsetY = 100;

            // Make pan gesture and check, that body of gesture is correct.
            action = new ActionsExtension(Driver);
            action.MoveByOffset(offsetX, offsetY).Perform();

            action.ClickAndHold();
            action.MoveByOffset(offsetX, offsetY);
            action.Release();
            action.Perform();

            vcPageObj.WaitAnimation();

            offset = ExecuteScriptGetJson("return offset;");

            Assert.AreEqual((double)offsetX, Convert.ToDouble(offset["xOffset"]), 5);
            Assert.AreEqual((double)offsetY, Convert.ToDouble(offset["yOffset"]), 5);

            action.SetDefault();

            // Make zoom gesture and check, that body of gesture is correct.
            GoToUrl();

            action.MoveByOffset(offsetX, offsetY).Perform();

            action.DoubleClick();
            action.Perform();

            vcPageObj.WaitAnimation();

            scale = ExecuteScriptGetJson("return scale;");

            Assert.AreEqual((double)offsetX, Convert.ToDouble(scale["xOrigin"]), 10);
            Assert.AreEqual((double)offsetY, Convert.ToDouble(scale["yOrigin"]), 10);
        }
Exemplo n.º 5
0
        public void TestMouse_MoveAndClick_Circle()
        {
            GoToUrl();

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

            actions = new ActionsExtension(Driver);
            // building mouse moves on the virtual canvas element
            actions.MoveToElement(vc, vc.Size.Width / 2, vc.Size.Height / 2);
            actions.Click();
            actions.MoveByOffset(-100, -100);
            actions.Perform();

            var res = (Driver as IJavaScriptExecutor).ExecuteScript("return isMovedIn;");
            Assert.AreNotEqual(0.0, Convert.ToDouble(res));
            res = (Driver as IJavaScriptExecutor).ExecuteScript("return isMovedOut;");
            Assert.AreNotEqual(0.0, Convert.ToDouble(res));
            res = (Driver as IJavaScriptExecutor).ExecuteScript("return isClicked;");
            Assert.AreNotEqual(0.0, Convert.ToDouble(res));
        }
Exemplo n.º 6
0
        public void TestRegimes_ClickPrehistoryLink_PrehistoryTimelineIsVisible()
        {
            Point linkPosition = vcPageObj.PrehistoryLink.Location;
            JsVisible visibleBefore = vcPageObj.GetViewport();

            action = new ActionsExtension(Driver);

            // Click on the regime link.
            action.MoveByOffset(linkPosition.X + 5, linkPosition.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);
        }
Exemplo n.º 7
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);
        }
Exemplo n.º 8
0
        public void TestRegimes_ClickCosmosBarWithOverlay_CosmosTimelineIsVisible()
        {
            Point cosmosBarPosition = vcPageObj.CosmosBar.Location;
            Point earthBarPosition = vcPageObj.EarthBar.Location;

            action = new ActionsExtension(Driver);

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

            vcPageObj.WaitAnimation();

            action.SetDefault();

            JsVisible visibleBefore = vcPageObj.GetViewport();

            // Click on the cosmos regime bar.
            action.MoveByOffset(cosmosBarPosition.X + 100, cosmosBarPosition.Y + 2).Click().Perform();

            vcPageObj.WaitAnimation();

            JsVisible visibleAfter = vcPageObj.GetViewport();
            JsTimeline timeline = GetCosmosTimeline();
            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);
        }
Exemplo n.º 9
0
        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);
        }
Exemplo n.º 10
0
        public void TestGestures_MouseActivity_GesturesGenerated()
        {
            const int offsetX = 100;
            const int offsetY = 100;

            action = new ActionsExtension(Driver);

            bool zoomHandled = (bool)ExecuteScript("return zoomHandled;"); ;
            bool panHandled = (bool)ExecuteScript("return panHandled;");
            bool pinHandled = (bool)ExecuteScript("return pinHandled;");

            Assert.IsFalse(zoomHandled);
            Assert.IsFalse(panHandled);
            Assert.IsFalse(pinHandled);

            // Pin and pan gestures.
            action.MoveToElement(vcPageObj.VirtualCanvas, offsetX, offsetY);
            action.ClickAndHold();
            action.MoveByOffset(offsetX, offsetY);
            action.Release();
            action.Perform();

            vcPageObj.WaitAnimation();

            zoomHandled = (bool)ExecuteScript("return zoomHandled;");
            panHandled = (bool)ExecuteScript("return panHandled;");
            pinHandled = (bool)ExecuteScript("return pinHandled;");

            Assert.IsFalse(zoomHandled);
            Assert.IsTrue(panHandled);
            Assert.IsTrue(pinHandled);

            // Zoom gesture.
            action.DoubleClick();
            action.Perform();

            vcPageObj.WaitAnimation();

            zoomHandled = (bool)ExecuteScript("return zoomHandled;");
            panHandled = (bool)ExecuteScript("return panHandled;");
            pinHandled = (bool)ExecuteScript("return pinHandled;");

            Assert.IsTrue(zoomHandled);
            Assert.IsTrue(panHandled);
            Assert.IsTrue(pinHandled);
        }
Exemplo n.º 11
0
        public void TestMouseBehavior_Panning_VisibleChangedCorrectly()
        {
            const int offsetX = 100;
            const int offsetY = 100;

            action = new ActionsExtension(Driver);
            JsVisible visibleBefore = vcPageObj.GetViewport();
            JsVisible visibleAfter;

            action.MoveToElement(vcPageObj.VirtualCanvas, offsetX, offsetY);
            action.ClickAndHold();
            action.MoveByOffset(offsetX, offsetY);
            action.Release();
            action.Perform();

            vcPageObj.WaitAnimation();
            visibleAfter = vcPageObj.GetViewport();

            JsCoordinates offsetScreen;
            JsCoordinates offsetVirtual;

            // Firefox browser had an inaccuracy in 3px.
            offsetScreen = (Browser == BrowserType.Firefox) ? new JsCoordinates(offsetX - 3, offsetY - 3) : new JsCoordinates(offsetX, offsetY);
            offsetVirtual = vcPageObj.VectorScreenToVirtual(offsetScreen);
            Assert.AreEqual(visibleBefore.CenterX - offsetVirtual.X, visibleAfter.CenterX, 1);
            Assert.AreEqual(visibleBefore.CenterY - offsetVirtual.Y, visibleAfter.CenterY, 1);
        }
Exemplo n.º 12
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);
        }
Exemplo n.º 13
0
        public void TestUrlNavigation_Pan_UrlChanges()
        {
            IWebElement vcElem = Driver.FindElement(By.Id("vc"));
            Assert.IsNotNull(vcElem, "err: cannot find canvas element");
            var vc = new VirtualCanvasComponent(Driver);
            double widthInSc = vcElem.Size.Width;

            // pan to get absolute url from relative initial url
            action = new ActionsExtension(Driver);
            action.MoveToElement(vcElem, 1, 1);
            action.ClickAndHold();
            action.MoveByOffset((int)widthInSc / 8, 0);
            action.Release();
            action.Perform();
            vc.WaitAnimation();

            string urlBefore = new Uri(Driver.Url).ToString();

            // pan to get update absolute url
            action = new ActionsExtension(Driver);
            action.MoveToElement(vcElem, 1, 1);
            action.ClickAndHold();
            action.MoveByOffset((int)widthInSc / 8, 0);
            action.Release();
            action.Perform();
            vc.WaitAnimation();

            string urlAfter = new Uri(Driver.Url).ToString();

            Assert.AreNotEqual(urlBefore, urlAfter);
        }
Exemplo n.º 14
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);
        }
Exemplo n.º 15
0
        public void TestBreadCrumbTimelineClick()
        {
            int ellipticZoomTimeWait = 6200;
            IJavaScriptExecutor js = Driver as IJavaScriptExecutor;

            var setVis = (Driver as IJavaScriptExecutor).ExecuteScript(
                "setVisible(new VisibleRegion2d(-6850000000,3388966248.683534,8124234.157802994));" //going into Canvas timeline (coordinates snapshot)
                );
            Thread.Sleep(ellipticZoomTimeWait);

            Point crumbPosition = new Point(688, 198); //timeline

            ActionsExtension crumbClick = new ActionsExtension(Driver);
            crumbClick.MoveByOffset(crumbPosition.X, crumbPosition.Y)
                .Click()
                .Perform(); //clicking on the bread crumb
            crumbClick.SetDefault(); // return mouse position to default
            Thread.Sleep(ellipticZoomTimeWait);

            var idResTimeline = js.ExecuteScript("return breadCrumbs[1].vcElement.id");
            Assert.AreEqual("t91", idResTimeline); //"Stelliferous (Starry) Epoch" id timeline
        }