Exemplo n.º 1
0
        public void TestSerializationIosSimulator()
        {
            Uri      url = new Uri("https://another.url.co.il");
            Uri      stitchingServiceUrl = new Uri("https://another.stitchingserviceuri.co.il");
            RGridDom dom = new RGridDom();
            Dictionary <string, RGridResource> resources = new Dictionary <string, RGridResource>();
            SizeMode           target   = SizeMode.FullPage;
            VisualGridSelector selector = null;

            System.Drawing.Rectangle region     = new System.Drawing.Rectangle(40, 50, 60, 70);
            IosDeviceInfo            deviceInfo = new IosDeviceInfo(IosDeviceName.iPhone_XR, ScreenOrientation.Landscape, IosVersion.ONE_VERSION_BACK);
            RenderInfo renderInfo = new RenderInfo(0, 0, target, selector, region, null, deviceInfo);

            VisualGridSelector[] selectorsToFindRegionsFor = new VisualGridSelector[0];
            bool sendDom = true;
            RenderBrowserInfo browserInfo = new RenderBrowserInfo(deviceInfo);

            RenderRequest request = new RenderRequest("id", null, url, stitchingServiceUrl, dom, resources, renderInfo,
                                                      browserInfo.Platform, browserInfo.BrowserType, null, selectorsToFindRegionsFor, sendDom, null, null, null);

            JsonSerializerSettings settings = JsonUtils.CreateSerializerSettings();

            settings.Formatting = Formatting.Indented;
            string json         = JsonConvert.SerializeObject(request, settings);
            string expectedJson = CommonUtils.ReadResourceFile("Test.Eyes.Sdk.Core.DotNet.Resources.TestRenderRequestSerializationIosDevice.json");

            Assert.AreEqual(expectedJson, json);
        }
Exemplo n.º 2
0
 public RunningTest(IEyesConnector eyes, RenderBrowserInfo browserInfo, Logger logger, RunningTestListener listener, string testId)
 {
     eyes_         = eyes;
     BrowserInfo   = browserInfo;
     Logger        = logger;
     listener_     = listener;
     taskListener_ = new VisualGridTask.TaskListener(OnTaskComplete, OnTaskFailed, OnRenderComplete);
     TestId        = testId;
 }
Exemplo n.º 3
0
        private List <RenderRequest> BuildRenderRequests_(FrameData currentFrame, IDictionary <string, RGridResource> resourceMapping)
        {
            Uri      url = currentFrame.Url;
            RGridDom dom = new RGridDom(currentFrame.Cdt, resourceMapping, url, logger_, "buildRenderRequests");

            //Create RG requests
            List <RenderRequest>   allRequestsForRG = new List <RenderRequest>();
            ICheckSettingsInternal csInternal       = (ICheckSettingsInternal)settings_;

            foreach (VisualGridTask task in taskList_)
            {
                RenderBrowserInfo browserInfo = task.BrowserInfo;
                RenderInfo        renderInfo  = new RenderInfo(browserInfo.Width, browserInfo.Height,
                                                               csInternal.GetSizeMode(), csInternal.GetTargetSelector(),
                                                               csInternal.GetTargetRegion(), browserInfo.EmulationInfo, browserInfo.IosDeviceInfo);

                List <VisualGridSelector> regionSelectors = new List <VisualGridSelector>();
                if (regionSelectors_ != null)
                {
                    foreach (VisualGridSelector[] vgs in regionSelectors_)
                    {
                        regionSelectors.AddRange(vgs);
                    }
                }

                RenderRequest request = new RenderRequest(renderingInfo_.ResultsUrl, url,
                                                          renderingInfo_.StitchingServiceUrl, dom,
                                                          resourceMapping, renderInfo, browserInfo.Platform,
                                                          browserInfo.BrowserType, csInternal.GetScriptHooks(),
                                                          regionSelectors.ToArray(), csInternal.GetSendDom() ?? false, task,
                                                          csInternal.GetVisualGridOptions());

                allRequestsForRG.Add(request);
            }
            return(allRequestsForRG);
        }
        public TestResultContainer Call(object state)
        {
            try
            {
                logger_.Log("enter - type: {0} ; name: {1}", TaskType, RunningTest.TestName);
                testResults_ = null;
                switch (TaskType)
                {
                case TaskType.Open:
                    logger_.Log("Task.run opening task");
                    if (renderResult_ != null)
                    {
                        string        userAgent  = renderResult_.UserAgent;
                        RectangleSize deviceSize = renderResult_.DeviceSize;
                        logger_.Verbose("setting device size: {0}", deviceSize);
                        EyesConnector.SetUserAgent(userAgent);
                        EyesConnector.SetDeviceSize(deviceSize);
                    }
                    else
                    {
                        // We are in exception mode - trying to do eyes.open() without first render
                        RenderBrowserInfo browserInfo = RunningTest.BrowserInfo;
                        EyesConnector.SetDeviceSize(new Size(browserInfo.Width, browserInfo.Height));
                    }
                    EyesConnector.Open(configuration_);
                    break;

                case TaskType.Check:
                    logger_.Log("Task.run check task");
                    try
                    {
                        string          imageLocation = renderResult_.ImageLocation;
                        string          domLocation   = renderResult_.DomLocation;
                        VGRegion[]      vgRegions     = renderResult_.SelectorRegions;
                        IList <IRegion> regions       = new List <IRegion>();
                        if (vgRegions != null)
                        {
                            foreach (VGRegion reg in vgRegions)
                            {
                                if (!(string.IsNullOrWhiteSpace(reg.Error)))
                                {
                                    logger_.Log("Warning: region error: {0}", reg.Error);
                                }
                                else
                                {
                                    regions.Add(reg);
                                }
                            }
                        }
                        logger_.Verbose(renderResult_.ToString());
                        if (imageLocation == null)
                        {
                            logger_.Log("CHECKING IMAGE WITH NULL LOCATION!");
                        }
                        Location location = null;
                        if (regionSelectors_.Count > 0 && regions.Count > 0)
                        {
                            VisualGridSelector[] targetSelector = regionSelectors_[regionSelectors_.Count - 1];
                            if (targetSelector.Length > 0 && "target".Equals(targetSelector[0].Category))
                            {
                                location = regions[regions.Count - 1].Location;
                            }
                        }
                        EyesConnector.MatchWindow(configuration_, imageLocation, domLocation, checkSettings_, regions,
                                                  regionSelectors_, location, renderResult_, source_);
                    }
                    catch (WebException we)
                    {
                        Stream stream            = we.Response.GetResponseStream();
                        byte[] responseBodyBytes = CommonUtils.ReadToEnd(stream);
                        string responseBodyStr   = Encoding.UTF8.GetString(responseBodyBytes);
                        logger_.Log($"Error: {we}\n{responseBodyStr}");
                    }
                    catch (Exception e)
                    {
                        logger_.Log("Error: " + e);
                    }
                    break;

                case TaskType.Close:
                    logger_.Log("Task.run close task");
                    try
                    {
                        testResults_ = EyesConnector.Close(true, configuration_);
                    }
                    catch (TestFailedException tfe)
                    {
                        logger_.Log("Test Failed: " + tfe);
                        Exception    = tfe;
                        testResults_ = tfe.TestResults;
                    }
                    catch (Exception e)
                    {
                        logger_.Log("Error: " + e);
                        Exception = e;
                    }
                    break;

                case TaskType.Abort:
                    logger_.Log("Task.run abort task");
                    testResults_ = EyesConnector.AbortIfNotClosed();
                    break;
                }
                TestResultContainer testResultContainer = new TestResultContainer(testResults_, BrowserInfo, Exception);
                NotifySuccessAllListeners();
                return(testResultContainer);
            }
            catch (Exception e)
            {
                logger_.Log("Error: " + e);
                NotifyFailureAllListeners(e);
            }
            finally
            {
                logger_.Verbose("marking {0} task as complete: {1}", TaskType, RunningTest.TestName);
                IsTaskComplete = true;
                //call the callback
            }
            return(null);
        }
Exemplo n.º 5
0
 internal RunningTest(RenderBrowserInfo browserInfo, Logger logger)
 {
     BrowserInfo = browserInfo;
     Logger      = logger;
 }