public void TestIosDeviceInfo()
        {
            JsonSerializer serializer = JsonUtils.CreateSerializer();

            IosDeviceInfo iosDeviceInfo = new IosDeviceInfo(IosDeviceName.iPhone_7);
            JObject       obj           = (JObject)JsonConvert.DeserializeObject(serializer.Serialize(iosDeviceInfo));

            Assert.AreEqual(2, obj.Count);
            Assert.AreEqual("iPhone 7", obj.Value <string>("name"));
            Assert.AreEqual("portrait", obj.Value <string>("screenOrientation"));


            iosDeviceInfo = new IosDeviceInfo(IosDeviceName.iPhone_11, ScreenOrientation.Landscape);
            obj           = (JObject)JsonConvert.DeserializeObject(serializer.Serialize(iosDeviceInfo));
            Assert.AreEqual(2, obj.Count);
            Assert.AreEqual("iPhone 11", obj.Value <string>("name"));
            Assert.AreEqual("landscape", obj.Value <string>("screenOrientation"));

            iosDeviceInfo = new IosDeviceInfo(IosDeviceName.iPhone_8, iosVersion: IosVersion.ONE_VERSION_BACK);
            obj           = (JObject)JsonConvert.DeserializeObject(serializer.Serialize(iosDeviceInfo));
            Assert.AreEqual(3, obj.Count);
            Assert.AreEqual("iPhone 8", obj.Value <string>("name"));
            Assert.AreEqual("portrait", obj.Value <string>("screenOrientation"));
            Assert.AreEqual("latest-1", obj.Value <string>("version"));

            iosDeviceInfo = new IosDeviceInfo(IosDeviceName.iPhone_X, ScreenOrientation.Landscape, IosVersion.LATEST);
            obj           = (JObject)JsonConvert.DeserializeObject(serializer.Serialize(iosDeviceInfo));
            Assert.AreEqual(3, obj.Count);
            Assert.AreEqual("iPhone X", obj.Value <string>("name"));
            Assert.AreEqual("landscape", obj.Value <string>("screenOrientation"));
            Assert.AreEqual("latest", obj.Value <string>("version"));
        }
Exemple #2
0
        public IConfiguration AddBrowser(IosDeviceInfo deviceInfo)
        {
            RenderBrowserInfo browserInfo = new RenderBrowserInfo(deviceInfo);

            browsersInfo_.Add(browserInfo);
            return(this);
        }
Exemple #3
0
        public void MergeFrom(ClientConfigurationMessage other)
        {
            if (other == null)
            {
                return;
            }
            if (other.TargetEnvId.Length != 0)
            {
                TargetEnvId = other.TargetEnvId;
            }
            if (other.ClientVersion.Length != 0)
            {
                ClientVersion = other.ClientVersion;
            }
            if (other.ClientOs != 0)
            {
                ClientOs = other.ClientOs;
            }
            if (other.OsVersion.Length != 0)
            {
                OsVersion = other.OsVersion;
            }
            if (other.DeviceModel.Length != 0)
            {
                DeviceModel = other.DeviceModel;
            }
            if (other.BuildNumber.Length != 0)
            {
                BuildNumber = other.BuildNumber;
            }
            switch (other.DeviceInfoCase)
            {
            case DeviceInfoOneofCase.IosDeviceInfo:
                if (IosDeviceInfo == null)
                {
                    IosDeviceInfo = new global::WUProtos.Networking.Requests.Messages.ClientConfigurationMessage.Types.iOSDeviceInfo();
                }
                IosDeviceInfo.MergeFrom(other.IosDeviceInfo);
                break;

            case DeviceInfoOneofCase.AndroidDeviceInfo:
                if (AndroidDeviceInfo == null)
                {
                    AndroidDeviceInfo = new global::WUProtos.Networking.Requests.Messages.ClientConfigurationMessage.Types.AndroidDeviceInfo();
                }
                AndroidDeviceInfo.MergeFrom(other.AndroidDeviceInfo);
                break;
            }

            _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
        }
Exemple #4
0
        //[Test]
        public void TestUFGVisualViewport_UnitTest()
        {
            JsonSerializer serializer = JsonUtils.CreateSerializer();
            IWebDriver     driver     = SeleniumUtils.CreateChromeDriver();
            EyesRunner     runner     = new VisualGridRunner(10);
            Eyes           eyes       = new Eyes(runner);

            TestUtils.SetupLogging(eyes);
            eyes.visualGridEyes_.EyesConnectorFactory = new Mock.MockEyesConnectorFactory();
            Configuration config        = eyes.GetConfiguration();
            IosDeviceInfo iosDeviceInfo = new IosDeviceInfo(IosDeviceName.iPhone_11_Pro);

            config.AddBrowser(iosDeviceInfo);
            eyes.SetConfiguration(config);
            try
            {
                eyes.Open(driver, "Eyes Selenium SDK", "Eyes Selenium SDK - UFG Visual Viewport Test");
                Mock.MockEyesConnector   mockEyesConnector   = (Mock.MockEyesConnector)eyes.visualGridEyes_.eyesConnector_;
                Mock.MockServerConnector mockServerConnector = new Mock.MockServerConnector(eyes.Logger, new Uri(eyes.ServerUrl));
                EyesConnector            eyesConnector       = new EyesConnector(eyes.Logger, new RenderBrowserInfo(iosDeviceInfo), config)
                {
                    runningSession_ = new RunningSession(),
                    ServerConnector = mockServerConnector
                };
                mockEyesConnector.WrappedConnector = eyesConnector;

                string inputJson = CommonUtils.ReadResourceFile("Test.Eyes.Selenium.DotNet.Resources.Misc.TestUFGVisualViewport_Input.json");
                RenderStatusResults renderStatusResults = serializer.Deserialize <RenderStatusResults>(inputJson);
                mockEyesConnector.SetRenderStatusResultsList(renderStatusResults);

                driver.Url = "https://applitools.github.io/demo/TestPages/DynamicResolution/desktop.html";
                eyes.Check(Target.Window().Fully());
                eyes.Close();

                runner.GetAllTestResults();

                Assert.AreEqual(1, mockServerConnector.MatchWindowCalls.Count);
                MatchWindowData matchWindowData = mockServerConnector.MatchWindowCalls[0];
                AppOutput       appOutput       = matchWindowData.AppOutput;
                Assert.AreEqual(980, appOutput.Viewport.Width);
                Assert.AreEqual(1659, appOutput.Viewport.Height);
                Assert.IsNotNull(mockEyesConnector.DeviceSize);
                Assert.AreEqual(375, mockEyesConnector.DeviceSize.Width);
                Assert.AreEqual(812, mockEyesConnector.DeviceSize.Height);
            }
            finally
            {
                eyes.AbortIfNotClosed();
                driver.Quit();
            }
        }
Exemple #5
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (TargetEnvId.Length != 0)
            {
                hash ^= TargetEnvId.GetHashCode();
            }
            if (ClientVersion.Length != 0)
            {
                hash ^= ClientVersion.GetHashCode();
            }
            if (ClientOs != 0)
            {
                hash ^= ClientOs.GetHashCode();
            }
            if (OsVersion.Length != 0)
            {
                hash ^= OsVersion.GetHashCode();
            }
            if (DeviceModel.Length != 0)
            {
                hash ^= DeviceModel.GetHashCode();
            }
            if (deviceInfoCase_ == DeviceInfoOneofCase.IosDeviceInfo)
            {
                hash ^= IosDeviceInfo.GetHashCode();
            }
            if (deviceInfoCase_ == DeviceInfoOneofCase.AndroidDeviceInfo)
            {
                hash ^= AndroidDeviceInfo.GetHashCode();
            }
            if (BuildNumber.Length != 0)
            {
                hash ^= BuildNumber.GetHashCode();
            }
            hash ^= (int)deviceInfoCase_;
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Exemple #6
0
        public void TestUFGVisualViewport()
        {
            JsonSerializer serializer = JsonUtils.CreateSerializer();
            IWebDriver     driver     = SeleniumUtils.CreateChromeDriver();
            EyesRunner     runner     = new VisualGridRunner(10);
            Eyes           eyes       = new Eyes(runner);

            TestUtils.SetupLogging(eyes);
            Configuration config        = eyes.GetConfiguration();
            IosDeviceInfo iosDeviceInfo = new IosDeviceInfo(IosDeviceName.iPhone_11_Pro);

            config.AddBrowser(iosDeviceInfo);
            eyes.SetConfiguration(config);
            try
            {
                eyes.Open(driver, "Eyes Selenium SDK", "Eyes Selenium SDK - UFG Visual Viewport Test");

                string inputJson = CommonUtils.ReadResourceFile("Test.Eyes.Selenium.DotNet.Resources.Misc.TestUFGVisualViewport_Input.json");
                RenderStatusResults renderStatusResults = serializer.Deserialize <RenderStatusResults>(inputJson);

                driver.Url = "https://applitools.github.io/demo/TestPages/DynamicResolution/desktop.html";
                eyes.Check(Target.Window().Fully());
                eyes.Close(false);

                TestResultsSummary resultsSummary = runner.GetAllTestResults(false);
                Assert.AreEqual(1, resultsSummary.Count);
                TestResults    results        = resultsSummary[0].TestResults;
                SessionResults sessionResults = TestUtils.GetSessionResults(eyes.ApiKey, results);

                Assert.AreEqual(1, sessionResults.ActualAppOutput.Length);
                ActualAppOutput appOutput = sessionResults.ActualAppOutput[0];
                Assert.AreEqual(980, appOutput.Image.Viewport.Width);
                Assert.AreEqual(1659, appOutput.Image.Viewport.Height);

                Assert.AreEqual(375, sessionResults.Env.DisplaySize.Width);
                Assert.AreEqual(812, sessionResults.Env.DisplaySize.Height);
            }
            finally
            {
                eyes.AbortIfNotClosed();
                driver.Quit();
            }
        }