예제 #1
0
        public void TestRegimes_ClickCosmosLink_CosmosTimelineIsVisible()
        {
            Point cosmosLinkPosition = vcPageObj.CosmosLink.Location;
            Point earthLinkPosition  = vcPageObj.EarthLink.Location;

            action = new ActionsExtension(Driver);

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

            vcPageObj.WaitAnimation();

            action.SetDefault();

            JsVisible visibleBefore = vcPageObj.GetViewport();

            // Click on the cosmos regime link.
            action.MoveByOffset(cosmosLinkPosition.X + 5, cosmosLinkPosition.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, 1);
            Assert.AreEqual(visibleAfter.CenterY, timelineCenter.Y, 1);
            Assert.AreNotEqual(visibleBefore, visibleAfter);
        }
예제 #2
0
        public void TestRegimes_ClickEarthBarNoOverlay_EarthTimelineIsVisible()
        {
            var vc = new VirtualCanvasComponent(Driver);

            vc.SetVisible(new JsVisible(-21.173972602739752, 226047946.84065938, 0.02607632093933464));
            vc.UpdateViewport();
            Thread.Sleep(100);

            Point     barPosition   = vcPageObj.EarthBar.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       = GetEarthTimeline();
            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);
        }
예제 #3
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);
        }
예제 #4
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);
        }
예제 #5
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);
        }
예제 #6
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);
        }
예제 #7
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);
        }
예제 #8
0
        public JsCoordinates VectorVirtualToScreen(JsCoordinates v)
        {
            // var vp = $("#id").virtualCanvas("getViewport");
            // return vp.vectorVirtualToScreen(v.X, v.Y);
            StringBuilder script = new StringBuilder("var vp = $('#");

            script.Append(virtualCanvas.GetAttribute("id"));
            script.Append("').virtualCanvas('getViewport');");
            script.AppendLine("return vp.vectorVirtualToScreen(");
            script.AppendFormat("{0},{1});", v.X, v.Y);

            string json = JSONHelper.Stringify(jsExecutor.ExecuteScript(script.ToString()) as Dictionary <string, object>);

            return((JsCoordinates)JSONHelper.Parse(typeof(JsCoordinates), json));
        }
예제 #9
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();

            // Enable onmouseclick handler.
            ExecuteScript("timelineClickOn();");

            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);
        }
예제 #10
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);
        }
예제 #11
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);
        }
예제 #12
0
        public void TestRegimes_ClickHumanityLink_HumanityTimelineIsVisible()
        {
            Point     linkPosition  = vcPageObj.HumanityLink.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       = GetHumanityTimeline();
            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);
        }
예제 #13
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);
        }