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
        }
예제 #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());
        }
예제 #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
        }
예제 #4
0
        public void TestTest()
        {
            action = new ActionsExtension(Driver);
            var element = Driver.FindElement(By.Id("search_button"));
            action.MoveToElement(element, 0, 0);
            action.Click();
            action.Perform();
            Thread.Sleep(1000);
            var searchTextBox = Driver.FindElement(By.Id("searchTextBox"));
            searchTextBox.SendKeys("Humanity");
            Thread.Sleep(300);

            var res = (Driver as IJavaScriptExecutor).ExecuteScript(@"return $('#loadingImage:visible').length;");
            var resInt = Convert.ToInt32(res);
            Assert.AreEqual<bool>(true, resInt > 0, "Expected loading hasn't appeared");
        }
예제 #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));
        }
예제 #6
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);
        }
예제 #7
0
        public void MinZoom(int sYear, int sMonth, int sDay, int eYear, int eMonth, int eDay, int zoom, double l)
        {
            action = new ActionsExtension(Driver);
            IWebElement vc = Driver.FindElement(By.Id("vc"));
            const int offsetX = 100;
            const int offsetY = 100;

            var d = (Driver as IJavaScriptExecutor).ExecuteScript
                        ("return $(\"#axis\").axis(\"getYearsBetweenDates\"," +
                        sYear + "," + sMonth + "," + sDay + "," + eYear + "," + eMonth + "," + eDay + ");");

            double n = Convert.ToDouble(d);
            double r = n + l;

            (Driver as IJavaScriptExecutor).ExecuteScript("$(\"#axis\").axis(\"setRange\"," + l + "," + r + ");");

            action.MoveToElement(vcPageObj.VirtualCanvas, offsetX, offsetY).Perform();
            //action.MoveByOffset(offsetX, offsetY);
            for (int k = 0; k < zoom; k++)
            {
                action.DoubleClick();
            }
            action.Perform();

            var afterZoom = (Driver as IJavaScriptExecutor).
                    ExecuteScript("return $(\"#axis\").axis(\"getRange\");");
            var azl = Convert.ToDouble((afterZoom as Dictionary<string, object>)["left"]);
            var azr = Convert.ToDouble((afterZoom as Dictionary<string, object>)["right"]);
            double z = azr - azl;

            int a1 = 123, a2 = 2, a3 = 3, b3 = 4;
            var v = (Driver as IJavaScriptExecutor).ExecuteScript
            ("return $(\"#axis\").axis(\"getYearsBetweenDates\"," +
            a1 + "," + a2 + "," + a3 + "," + a1 + "," + a2 + "," + b3 + ");");
            double w = Convert.ToDouble(v);

            Assert.IsTrue(z > w);
        }
예제 #8
0
        public void TestBreadCrumbLink()
        {
            switch (Browser)
            {
                case BrowserType.Firefox:
                    // 10.1 version of FF doesn't correctly supported by Selenium.
                    //TODO: update this test with new version of Selenium.
                    Assert.Inconclusive("10.1 version of FF doesn't correctly supported by Selenium. Test will be updated with new version of Selenium.");
                    break;
                case BrowserType.InternetExplorer:

                    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 crumb2 = Driver.FindElement(By.Id("bread_crumb_1")); //finding second bread crumb to test a link of it
                    ActionsExtension crumbClick = new ActionsExtension(Driver);
                    crumbClick.MoveToElement(crumb2, crumb2.Size.Width / 2, crumb2.Size.Height / 2);
                    crumbClick.Click();
                    crumbClick.Perform(); //clicking on the bread crumb

                    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

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

                    Assert.IsTrue(Convert.ToDouble(zoomedVisible["scale"]) < Convert.ToDouble(breadCrumbVisible["scale"])); //scale must ascend
                    break;
            }
        }
예제 #9
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);
        }
예제 #10
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);
        }
예제 #11
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);
        }
예제 #12
0
        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);
        }
예제 #13
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);
        }
예제 #14
0
        public void TestMouseBehavior_SingleClickOnInfodot_ZoomIntoInfodot()
        {
            // Compute coordinates of infodot on the screen.
            JsCoordinates offsetVirtual = new JsCoordinates(-3200, 400); // k = 200; time = -16 * k, vyc = 2.0 * k, radv = 0.6 * k;
            JsCoordinates offsetScreen = vcPageObj.PointVirtualToScreen(offsetVirtual);

            JsVisible visibleBefore = vcPageObj.GetViewport();

            action = new ActionsExtension(Driver);
            action.MoveToElement(vcPageObj.VirtualCanvas, (int)offsetScreen.X, (int)offsetScreen.Y).Perform();
            action.Click().Perform();

            vcPageObj.WaitAnimation();

            JsVisible visibleAfter = vcPageObj.GetViewport();
            Size vcSize = vcPageObj.VirtualCanvas.Size;
            double infodotVirtualSize = 240; // k = 200; radv = 0.6 * k;
            double infodotScreenSize = infodotVirtualSize / visibleAfter.Scale;

            // Infodot fills more than 90% of canvas' height. This condition can be regulated.
            // Also check, that center of viewport in the same point as center of the infodot.
            // It indicates, that infodot is inside of visible region and that infodot fills most of its space.
            double ratio = infodotScreenSize / vcSize.Height;

            Assert.IsTrue(ratio > 0.9 && ratio < 1);
            Assert.IsTrue(visibleAfter.CenterX == offsetVirtual.X && visibleAfter.CenterY == offsetVirtual.Y);
            Assert.AreNotEqual(visibleBefore, visibleAfter);
        }
예제 #15
0
        public void TestMouseBehavior_SingleClickOnTimeline_ZoomIntoTimeline()
        {
            // Compute coordinates of timeline's center on the screen.
            // k = 200; timeStart: -18.7 * k, timeEnd: 0, top: 0, height: 5 * k
            const double Width = 3740;
            const double Height = 1000;
            JsCoordinates offsetVirtual = new JsCoordinates(-3740 + Width / 2, 0 + Height / 2);
            JsCoordinates offsetScreen = vcPageObj.PointVirtualToScreen(offsetVirtual);

            JsVisible visibleBefore = vcPageObj.GetViewport();

            action = new ActionsExtension(Driver);
            action.MoveToElement(vcPageObj.VirtualCanvas, (int)offsetScreen.X, (int)offsetScreen.Y).Perform();
            action.Click().Perform();

            vcPageObj.WaitAnimation();

            JsVisible visibleAfter = vcPageObj.GetViewport();
            Size vcSize = vcPageObj.VirtualCanvas.Size;
            double timelineScreenWidth = Width / visibleAfter.Scale;
            double timelineScreenHeight = Height / visibleAfter.Scale;
            double timelineAspectRatio = timelineScreenWidth / timelineScreenHeight;
            double canvasAspectRatio = (double)vcSize.Width / vcSize.Height;
            double ratio = 0;

            // Check the side, that should fit the corresponding side of canvas.
            if (timelineAspectRatio >= canvasAspectRatio)
            {
                ratio = timelineScreenWidth / vcSize.Width;
            }
            else
            {
                ratio = timelineScreenHeight / vcSize.Height;
            }

            // Timeline fills more than 90% of canvas' side, but less or equal than 100% of the same side.
            // Also check, that center of viewport in the same point as center of the timeline.
            // It indicates, that timeline is inside of visible region and that timeline fills most of its space.
            Console.WriteLine(ratio);
            Assert.IsTrue(ratio > 0.9 && ratio <= 1);
            Assert.IsTrue(visibleAfter.CenterX == offsetVirtual.X && visibleAfter.CenterY == offsetVirtual.Y);
            Assert.AreNotEqual(visibleBefore, visibleAfter);
        }
예제 #16
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);
        }
예제 #17
0
        public void TestMouseBehavior_SingleClickOnContentItem_ZoomIntoContentItem()
        {
            Thread.Sleep(5000);
            // Compute coordinates of infodot on the screen.
            JsCoordinates offsetVirtual = new JsCoordinates(-3200, 400); // k = 200; time = -16 * k, vyc = 2.0 * k, radv = 0.6 * k;
            JsCoordinates offsetScreen = vcPageObj.PointVirtualToScreen(offsetVirtual);

            JsVisible visibleBefore = vcPageObj.GetViewport();

            // Click on the infodot and wait animation.
            action = new ActionsExtension(Driver);
            action.MoveToElement(vcPageObj.VirtualCanvas, (int)offsetScreen.X, (int)offsetScreen.Y).Perform();
            action.Click().Perform();

            vcPageObj.WaitAnimation();

            action.SetDefault();

            offsetScreen = vcPageObj.PointVirtualToScreen(offsetVirtual);

            // Click on the content item.
            action.MoveToElement(vcPageObj.VirtualCanvas, (int)offsetScreen.X, (int)offsetScreen.Y).Perform();
            vcPageObj.WaitAnimation();
            action.Click().Perform();

            vcPageObj.WaitAnimation();

            JsVisible visibleAfter = vcPageObj.GetViewport();
            Size vcSize = vcPageObj.VirtualCanvas.Size;

            // From Javascript code:
            //
            // var _rad = 450.0 / 2.0; //489.0 / 2.0;
            // var k = 1.0 / _rad;
            // var _wc = 260.0 * k;
            // var _hc = 270.0 * k;

            // Width = _wc * rad, Height = _hc * rad, rad = 120.

            const double Width = 1.155555555555556 * 120;
            const double Height = 1.2 * 120;

            double contentItemScreenWidth = Width / visibleAfter.Scale;
            double contentItemScreenHeight = Height / visibleAfter.Scale;
            double contentItemAspectRatio = contentItemScreenWidth / contentItemScreenHeight;
            double canvasAspectRatio = (double)vcSize.Width / vcSize.Height;
            double ratio = 0;

            // Check the side, that should fit the corresponding side of canvas.
            if (contentItemAspectRatio >= canvasAspectRatio)
            {
                ratio = contentItemScreenWidth / vcSize.Width;
            }
            else
            {
                ratio = contentItemScreenHeight / vcSize.Height;
            }

            // Content item fills more than 90% of canvas' side, but less or equal than 100% of the same side.
            // Also check, that center of viewport in the same point as center of the timeline.
            // It indicates, that timeline is inside of visible region and that timeline fills most of its space.
            Assert.IsTrue(ratio > 0.9 && ratio <= 1);
            Assert.IsTrue(visibleAfter.CenterX == offsetVirtual.X && visibleAfter.CenterY == offsetVirtual.Y);
            Assert.AreNotEqual(visibleBefore, visibleAfter);
        }
예제 #18
0
        public void TestMouseBehavior_HoverOverInfodot_HighlightAndPreview()
        {
            // Compute coordinates of infodot on the screen.
            JsCoordinates offsetVirtual = new JsCoordinates(-3200, 400); // k = 200; time = -16 * k, vyc = 2.0 * k, radv = 0.6 * k
            JsCoordinates offsetScreen = vcPageObj.PointVirtualToScreen(offsetVirtual);

            // Get the color of stroke and its width.
            string colorBefore = (string)ExecuteScript("return infodot.settings.strokeStyle;");
            double lineWidthBefore = ExecuteScriptGetNumber("return infodot.settings.lineWidth;");

            action = new ActionsExtension(Driver);
            action.MoveToElement(vcPageObj.VirtualCanvas, (int)offsetScreen.X, (int)offsetScreen.Y).Perform();

            // Get the color of stroke and its width.
            string colorAfter = (string)ExecuteScript("return infodot.settings.strokeStyle;");
            double lineWidthAfter = ExecuteScriptGetNumber("return infodot.settings.lineWidth;");

            Assert.AreNotEqual(colorBefore, colorAfter);
            Assert.IsTrue(lineWidthAfter > lineWidthBefore);
        }
예제 #19
0
        public void TestMouseBehavior_HoverOverContentItem_Highlight()
        {
            // Compute coordinates of infodot on the screen.
            JsCoordinates offsetVirtual = new JsCoordinates(-3200, 400); // k = 200; time = -16 * k, vyc = 2.0 * k, radv = 0.6 * k;
            JsCoordinates offsetScreen = vcPageObj.PointVirtualToScreen(offsetVirtual);

            // Click on the infodot and wait animation.
            action = new ActionsExtension(Driver);
            action.MoveToElement(vcPageObj.VirtualCanvas, (int)offsetScreen.X, (int)offsetScreen.Y).Perform();
            action.Click().Perform();

            vcPageObj.WaitAnimation();

            action.SetDefault();

            string colorBefore = (string)ExecuteScript("return majorBorder.settings.strokeStyle;");

            offsetScreen = vcPageObj.PointVirtualToScreen(offsetVirtual);

            // Mouse move over the content item.
            action.MoveToElement(vcPageObj.VirtualCanvas, (int)offsetScreen.X, (int)offsetScreen.Y).Perform();

            string colorAfter = (string)ExecuteScript("return majorBorder.settings.strokeStyle;");

            Assert.AreNotEqual(colorBefore, colorAfter);
        }
예제 #20
0
        public void TestMouseBehavior_DoubleClickOnCanvas_NextLevelOfZoom()
        {
            const int offsetX = 100;
            const int offsetY = 100;

            action = new ActionsExtension(Driver);

            // NOTE: Uses user environment variable SELENIUM_SCR.
            WebDriverScreenshotMaker.SaveScreenshot(Driver, "TestMouseBehaviour", "SingleClickCanvasBefore", ImageFormat.Png, true);

            action.MoveToElement(vcPageObj.VirtualCanvas, offsetX, offsetY);
            action.DoubleClick();
            action.Perform();

            vcPageObj.WaitAnimation();
            WebDriverScreenshotMaker.SaveScreenshot(Driver, "TestMouseBehaviour", "SingleClickCanvasAfter", ImageFormat.Png, true);
        }
예제 #21
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);
        }
예제 #22
0
        public void TestSearch_SearchQueries_ScreenshotsCreated()
        {
            // Get titles.
            string[] titles = GetTitlesFromResponseDump();

            // Get random titles or range of titles from collection.
            List<string> searchQueries = (RandomRegimeOn) ? GetRandomTitles(titles) : GetRangeOfTitles(titles);

            // Click on the Search button and wait until it expands.
            vcPageObj.SearchButton.Click();
            Thread.Sleep(WaitSearchMenuExpandingMs);

            action = new ActionsExtension(Driver);

            // Regular expression to remove invalid filename characters of screenshots.
            string invalidFileNameChars = new string(Path.GetInvalidFileNameChars());
            Regex regex = new Regex(string.Format("[{0}]", Regex.Escape(invalidFileNameChars)));

            // For alert handling.
            IAlert alert = null;
            bool alertIsActive = false;

            // Enter search queries and click on them.
            foreach (string query in searchQueries)
            {
                alertIsActive = false;

                vcPageObj.EnterSearchQuery(query);
                Thread.Sleep(WaitResultsMs);

                // Move mouse arrow to result and click on it.
                WebDriverWait wait = new WebDriverWait(Driver, TimeSpan.FromMilliseconds(WaitTimeOutMs));

                try
                {
                    IWebElement result = wait.Until<IWebElement>((d) =>
                    {
                        // Return dynamically created search result.
                        return Driver.FindElement(By.XPath(SearchResultXPath));
                    });

                    action.Click(result).Perform();
                    vcPageObj.WaitAnimation();
                }
                catch (TimeoutException)
                {
                    Console.WriteLine("NOT FOUND: " + query);
                }

                // Handling of alert messages.
                try
                {
                    alert = Driver.SwitchTo().Alert();
                    alertIsActive = true;
                    alert.Accept();
                    Console.WriteLine("ALERT: " + query);
                }
                catch (NoAlertPresentException)
                {
                    Console.WriteLine("OK: " + query);
                }

                // Save screenshot of search result. If alert had appeared, then add special string to filename of screenshot.
                // NOTE: Uses user environment variable SELENIUM_SCR.
                if (alertIsActive)
                {
                    WebDriverScreenshotMaker.SaveScreenshot(Driver, "TestSearch", alertString + regex.Replace(query, ""), ImageFormat.Png, true);
                }
                else
                {
                    WebDriverScreenshotMaker.SaveScreenshot(Driver, "TestSearch", regex.Replace(query, ""), ImageFormat.Png, true);
                }

                action.SetDefault();
                vcPageObj.ClearSearchTextBox();
            }
        }
예제 #23
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);
        }
예제 #24
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);
        }
예제 #25
0
        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);
            }
        }
예제 #26
0
        public void TestBreadCrumbs_BreadCrumbLinkColorIsCorrect()
        {
            GoToUrl("http://localhost:4949/cz.htm#/t55/e165/c477");

            IWebElement breadCrumb = Driver.FindElement(By.Id("bread_crumb_0"));
            ActionsExtension action = new ActionsExtension(Driver);
            switch (Browser)
            {
                case BrowserType.Firefox: // 10.1 version of FF doesn't correctly supported by Selenium.
                    //TODO: update this test with new version of Selenium.
                    Assert.Inconclusive("10.1 version of FF doesn't correctly supported by Selenium. Test will be updated with new version of Selenium.");
                    break;
                case BrowserType.InternetExplorer:
                    var colorBefore = (string)(Driver as IJavaScriptExecutor).ExecuteScript(
                    "var currentColor = $('#bread_crumb_0').css('color');" + // Get the color of breadcrumb link.
                    "return currentColor;"); // Return the color.

                    // Hover mouse over breadcrumb link.
                    action.MoveToElement(breadCrumb, breadCrumb.Size.Width / 2, breadCrumb.Size.Height / 2)
                        .Perform();
                    // Hover mouse out from breadcrumb link.
                    action.SetDefault();

                    var colorAfter = (string)(Driver as IJavaScriptExecutor).ExecuteScript(
                    "var currentColor = $('#bread_crumb_0').css('color');" + // Get the color of breadcrumb link after it was hover by mouse.
                    "return currentColor;"); // Return the color.

                    // Check that initial and current color are the same.
                    Assert.AreEqual(colorBefore, colorAfter);
                    break;
            }
        }
예제 #27
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);
        }
예제 #28
0
        public void TestBreadCrumbs_HoverMouseOverBreadCrumb_BreadCrumbHighlighted()
        {
            GoToUrl("http://localhost:4949/cz.htm#/t55/e165/c477");

            IWebElement breadCrumb = Driver.FindElement(By.Id("bread_crumb_0"));
            ActionsExtension action = new ActionsExtension(Driver);
            switch (Browser)
            {
                case BrowserType.Firefox: // 10.1 version of FF doesn't correctly supported by Selenium.
                    //TODO: update this test with new version of Selenium.
                    Assert.Inconclusive("10.1 version of FF doesn't correctly supported by Selenium. Test will be updated with new version of Selenium.");
                    break;
                case BrowserType.InternetExplorer:
                    // Hover mouse over breadcrumb link.
                    action.MoveToElement(breadCrumb, breadCrumb.Size.Width / 2, breadCrumb.Size.Height / 2)
                        .Perform();

                    var res = (bool)(Driver as IJavaScriptExecutor).ExecuteScript(
                    "var currentColor = $('#bread_crumb_0').css('color');" + // Get the color of breadcrumb link.
                    "return currentColor == 'rgb(255, 255, 255)';"); // Check that this color is rgb(255,255,255). Return result.
                    action.SetDefault();
                    // Check that color is corret.
                    Assert.IsTrue(res);
                    break;
            }
        }
예제 #29
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);
        }
예제 #30
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);
        }