Esempio n. 1
0
        public void TestUrlNavigation_OpenAbsoluteBookmark_NavigatesToBookmark()
        {
            /* Arrange
             * Select a random timeline or exhibit.
             * Generate absolute bookmark url.
             */
            string entityType = (rnd.Next() % 2 == 0) ? "timeline" : "infodot";
            var l = getEntityIds(entityType);
            string id = l[rnd.Next(l.Count)];

            // get relative bookmark url of the timeline/exhibit
            var js = Driver as IJavaScriptExecutor;
            var bookmarkUrl = js.ExecuteScript("return vcelementToNavString(vc.virtualCanvas('findElement', '" + id + "'));");

            // update viewport according to the choosen timeline/exhibit
            GoToUrl(this.StartPage + "#" + bookmarkUrl);
            vcPageObj = new VirtualCanvasComponent(Driver);
            vcPageObj.WaitContentLoading();

            //get absolute bookmark url of the timeline/exhibit
            js = Driver as IJavaScriptExecutor;
            bookmarkUrl = js.ExecuteScript("var el = vc.virtualCanvas('findElement','" + id + "'); var vp = vc.virtualCanvas('getViewport'); return vcelementToNavString(el, vp);");

            /* Act
             * Go to bookmark url.
             */
            GoToUrl(this.StartPage + "#" + bookmarkUrl);
            vcPageObj = new VirtualCanvasComponent(Driver);
            vcPageObj.WaitContentLoading();

            var bookmarkItem = new
            {
                x = Convert.ToDouble(js.ExecuteScript("return vc.virtualCanvas('findElement','" + id + "').x;")),
                y = Convert.ToDouble(js.ExecuteScript("return vc.virtualCanvas('findElement','" + id + "').y;")),
                width = Convert.ToDouble(js.ExecuteScript("return vc.virtualCanvas('findElement','" + id + "').width;")),
                height = Convert.ToDouble(js.ExecuteScript("return vc.virtualCanvas('findElement','" + id + "').height;"))
            };

            var bookmarkItemCenterX = bookmarkItem.x + bookmarkItem.width / 2;
            var bookmarkItemCenterY = bookmarkItem.y + bookmarkItem.height / 2;

            js = Driver as IJavaScriptExecutor;
            var viewportCenterX = Convert.ToDouble(js.ExecuteScript("return vc.virtualCanvas('getViewport').visible.centerX;"));
            var viewportCenterY = Convert.ToDouble(js.ExecuteScript("return vc.virtualCanvas('getViewport').visible.centerY;"));

            /* Assert
             * Verify that the timeline/exhibit specified
             * in the absolute bookmark url is visible.
             */
            Assert.AreEqual(viewportCenterX, bookmarkItemCenterX, 1);
            Assert.AreEqual(viewportCenterY, bookmarkItemCenterY, 1);
        }
Esempio n. 2
0
        public void TestRegimes_RefreshPage_NavigatorBarSavedItState()
        {
            // generate random visible
            Random rnd = new Random();
            double centerX = -65000000 * rnd.NextDouble();
            double centerY = 300000 * rnd.NextDouble();
            double scale = 500 * rnd.NextDouble();

            // performing EllipticalZoom animation to generated visible and wait until animation is over.
            IJavaScriptExecutor js = Driver as IJavaScriptExecutor;
            js.ExecuteScript("setVisible(new VisibleRegion2d(" + centerX + ", " + centerY + ", " + scale + "));");

            Thread.Sleep(AnimationDuration);

            // save current width and left CSS properties
            var regimeNavigator = Driver.FindElement(By.Id("regime_navigator"));
            var savedState = new Dictionary<string, object>();
            savedState.Add("left", regimeNavigator.GetCssValue("left"));
            savedState.Add("width", regimeNavigator.GetCssValue("width"));

            // save current url
            var URL = Driver.Url;

            // reload page
            GoToUrl(this.StartPage);
            var vcPageObj = new VirtualCanvasComponent(Driver);
            vcPageObj.WaitContentLoading();
            GoToUrl(URL);
            vcPageObj.WaitContentLoading();

            // get width and left CSS properties after page reloading
            regimeNavigator = Driver.FindElement(By.Id("regime_navigator"));
            var newState = new Dictionary<string, object>();
            newState.Add("left", regimeNavigator.GetCssValue("left"));
            newState.Add("width", regimeNavigator.GetCssValue("width"));

            // check that old and new width and left CSS properties are the same.
            Assert.AreEqual(savedState["left"], newState["left"], "ERROR: CSS 'left' changed.");
            Assert.AreEqual(savedState["width"], newState["width"], "ERROR: CSS 'width' changed.");
        }
Esempio n. 3
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);
        }
Esempio n. 4
0
 public void TestInitialize()
 {
     GoToUrl();
     vcPageObj = new VirtualCanvasComponent(Driver);
     vcPageObj.WaitContentLoading();
 }
        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_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_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. 8
0
 public void TestInitialize()
 {
     GoToUrl();
     vcPage = new VirtualCanvasComponent(Driver);
 }
Esempio n. 9
0
        public void TestMinZoom()
        {
            GoToUrl();

            vcPageObj = new VirtualCanvasComponent(Driver);

            MinZoom(4, 2, 27, 4, 2, 29, 7, 4.4);
            MinZoom(2000, 2, 27, 2000, 3, 1, 32, 2000.3843);
            MinZoom(1439, 7, 3, 1439, 7, 5, 1, 234.123);
            MinZoom(24, 4, 5, 24, 3, 8, 2, 34.0);
            MinZoom(1439, 7, 3, 1439, 7, 5, 1, 234.123);
        }
Esempio n. 10
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. 11
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. 12
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);
        }
Esempio n. 13
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. 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);
        }
Esempio n. 15
0
        public void TestUrlNavigation_SharingOfBibliographyWindow_BibliographyWindowOpened()
        {
            /* Arrange
             * Select a random exhibit.
             * Generate absolute bookmark url.
             */
            string entityType = "infodot";
            var l = getEntityIds(entityType);
            string id = l[rnd.Next(l.Count)];

            // get relative bookmark url of the exhibit
            var js = Driver as IJavaScriptExecutor;
            // TODO: Remove '@' at the end of this string aftre it will be fixed in scripts of cz
            var bookmarkUrl = js.ExecuteScript("return vcelementToNavString(vc.virtualCanvas('findElement', '" + id + "'));");

            // update viewport according to the choosen exhibit
            GoToUrl(this.StartPage + "#" + bookmarkUrl);
            vcPageObj = new VirtualCanvasComponent(Driver);
            vcPageObj.WaitContentLoading();

            var bibliography = id + "__bibliography";

            // get screen coordinates of
            var visible = GetVisibleForCanvasElement(js, bibliography);
            var canvasElement = Driver.FindElement(By.Id("vc"));
            var biblWindowElement = Driver.FindElement(By.Id("bibliographyBack"));

            // check that bibliography window is hidden at this moment
            string windowDisplay = biblWindowElement.GetCssValue("display");
            Assert.AreEqual(windowDisplay, "none", "ERROR: Bibliography window is visible but it shouldn't.");

            var action = new ActionsExtension(Driver);
            action.MoveToElement(canvasElement, Convert.ToInt32(visible["x"]) + 5, Convert.ToInt32(visible["y"]) + 5)
                .Click()
                .Perform();

            // check that bibliography window is visible now
            windowDisplay = canvasElement.GetCssValue("display");
            Assert.AreNotEqual(windowDisplay, "none", "ERROR: Bibliography window is not visible but it should.");
            var URL = Driver.Url;

            // change URL to reload page
            GoToUrl(this.StartPage);
            vcPageObj.WaitContentLoading();

            // open shared bibliography link
            GoToUrl(URL);
            vcPageObj.WaitContentLoading();

            // check that bibliography window is visible now
            biblWindowElement = Driver.FindElement(By.Id("bibliographyBack"));
            windowDisplay = biblWindowElement.GetCssValue("display");
            Assert.AreNotEqual(windowDisplay, "none", "ERROR: Share failed. Bibliography window is not visible but it should.");
        }