Exemple #1
0
        public void TestSerialization()
        {
            Uri      webHook             = new Uri("https://some.uri.com");
            Uri      url                 = new Uri("https://another.url.co.il");
            Uri      stitchingServiceUrl = new Uri("https://some.stitchingserviceuri.com");
            RGridDom dom                 = new RGridDom();
            Dictionary <string, RGridResource> resources = new Dictionary <string, RGridResource>();
            int                width    = 1600;
            int                height   = 1200;
            SizeMode           target   = SizeMode.FullPage;
            VisualGridSelector selector = null;

            System.Drawing.Rectangle region        = new System.Drawing.Rectangle(40, 50, 60, 70);
            EmulationBaseInfo        emulationInfo = new ChromeEmulationInfo(DeviceName.Galaxy_S5, ScreenOrientation.Portrait);
            RenderInfo  renderInfo  = new RenderInfo(width, height, target, selector, region, emulationInfo, null);
            string      platform    = "android";
            BrowserType browserName = BrowserType.IE_10;
            object      scriptHooks = null;
            string      xpath       = "//html/body/some/path/to/some/element[@with:attribute]";
            object      category    = "cat";

            VisualGridSelector[] selectorsToFindRegionsFor = new VisualGridSelector[] {
                new VisualGridSelector(xpath, category)
            };
            bool           sendDom     = true;
            TaskType       taskType    = default;
            Logger         logger      = null;
            RunningTest    runningTest = null;
            VisualGridTask task        = new VisualGridTask(taskType, logger, runningTest);

            RenderRequest request = new RenderRequest(webHook, url, stitchingServiceUrl, dom, resources, renderInfo, platform, browserName,
                                                      scriptHooks, selectorsToFindRegionsFor, sendDom, task, 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.TestRenderRequestSerialization.json");

            Assert.AreEqual(expectedJson, json);
        }
        private Size GetCorrectDeviceSize_(RenderRequest renderRequest)
        {
            Size deviceSize = configuration_.ViewportSize;

            if (deviceSize.IsEmpty)
            {
                IosDeviceInfo       iosDeviceInfo = renderRequest.RenderInfo.IosDeviceInfo;
                ChromeEmulationInfo emulationInfo = renderRequest.RenderInfo.EmulationInfo as ChromeEmulationInfo;
                if (iosDeviceInfo != null)
                {
                    IosDeviceName deviceName = iosDeviceInfo.DeviceName;
                    Dictionary <IosDeviceName, DeviceSize> iosDevicesSizes = EyesConnector.GetIosDevicesSizes();
                    if (!iosDevicesSizes.TryGetValue(deviceName, out DeviceSize deviceSizes))
                    {
                        logger_.Verbose("could not find device in list.");
                        return(Size.Empty);
                    }
                    deviceSize = iosDeviceInfo.ScreenOrientation == ScreenOrientation.Portrait
                        ? deviceSizes.Portrait
                        : deviceSizes.LandscapeLeft;
                }
                else if (emulationInfo != null)
                {
                    DeviceName deviceName = emulationInfo.DeviceName;
                    Dictionary <DeviceName, DeviceSize> emulatedDevicesSizes = EyesConnector.GetEmulatedDevicesSizes();
                    if (!emulatedDevicesSizes.TryGetValue(deviceName, out DeviceSize deviceSizes))
                    {
                        logger_.Verbose("could not find device in list.");
                        return(Size.Empty);
                    }
                    deviceSize = emulationInfo.ScreenOrientation == ScreenOrientation.Portrait
                        ? deviceSizes.Portrait
                        : deviceSizes.Landscape;
                }
            }
            return(deviceSize);
        }