public RenderBrowserInfo(DesktopBrowserInfo desktopBrowserInfo, string baselineEnvName = null) { DesktopBrowserInfo = desktopBrowserInfo; BaselineEnvName = baselineEnvName; BrowserType = desktopBrowserInfo.BrowserType; ViewportSize = new RectangleSize(desktopBrowserInfo.ViewportSize); }
public AppOutput(string title, Location location, byte[] screenshotBytes, string screenshotUrl, string domUrl = null, RectangleSize viewport = null) { Title = title; Location = location; ScreenshotBytes = screenshotBytes; ScreenshotUrl = screenshotUrl; DomUrl = domUrl; Viewport = viewport; }
public AppOutput(string title, Location location, Bitmap image, string domUrl = null, RectangleSize viewport = null) { Title = title; Location = location; ScreenshotUrl = null; DomUrl = domUrl; Viewport = viewport; using (MemoryStream stream = new MemoryStream()) { image.Save(stream, ImageFormat.Png); ScreenshotBytes = stream.ToArray(); } }
public RectangleSize SetPositions(IReadOnlyList <Node> nodeGraph, RectangleSize currentSize) { var random = new Random(); foreach (var node in nodeGraph) { node.Position.X = Margin + random.NextDouble() * (Width - node.Width - Margin); node.Position.Y = Margin + random.NextDouble() * (Height - node.Height - Margin); Logger.LogDebug("RANDOM LAY", $"node {node.Guid}: x = {node.Position.X}, y = {node.Position.Y}"); } return(currentSize); }
public void TestCtor() { AppEnvironment ae = new AppEnvironment(); Assert.IsNull(ae.DisplaySize); Assert.IsNull(ae.HostingApp); Assert.IsNull(ae.OS); ae.DisplaySize = new RectangleSize(10, 100); Assert.True(RectangleSize.AreEqual(new RectangleSize(10, 100), ae.DisplaySize)); ae.HostingApp = "Testing app"; Assert.AreEqual("Testing app", ae.HostingApp); ae.OS = "Some OS"; Assert.AreEqual("Some OS", ae.OS); ae = new AppEnvironment("p1", "p2", new RectangleSize(1, 1)); Assert.AreEqual("p1", ae.OS); Assert.AreEqual("p2", ae.HostingApp); Assert.True(RectangleSize.AreEqual(new RectangleSize(1, 1), ae.DisplaySize)); }
public RectangleSize SetPositions(IReadOnlyList <Node> nodeGraph, RectangleSize currentSize) { const double margin = 25.0; var width = SetHorizontalPositions(nodeGraph, margin); var layers = SplitGraphByLayer(nodeGraph); var layerCount = layers.Count; var maxHeight = 0.0; for (var i = 1; i < layerCount; ++i) { var bestPermutation = GetBestPermutation(layers[i - 1], layers[i]); var newHeight = SetOrderedLayerVerticalPositions(bestPermutation, margin); maxHeight = Math.Max(maxHeight, newHeight); } return(new RectangleSize(width, maxHeight)); }
public override Bitmap GetImage() { logger_.Verbose("Getting current position..."); Point loc; double scaleRatio = eyes_.DevicePixelRatio; FrameChain currentFrameChain = eyes_.GetDriver().GetFrameChain(); IPositionProvider positionProvider = null; if (currentFrameChain.Count == 0) { IWebElement scrollRootElement = eyes_.GetCurrentFrameScrollRootElement(); positionProvider = eyes_.GetPositionProvider(logger_, StitchModes.Scroll, jsExecutor_, scrollRootElement, userAgent_); loc = positionProvider.GetCurrentPosition(); } else { loc = currentFrameChain.GetDefaultContentScrollPosition(); } Point scaledLoc = new Point((int)Math.Round(loc.X * scaleRatio), (int)Math.Round(loc.Y * scaleRatio)); Bitmap image = base.GetImage(); EyesWebDriver driver = eyes_.GetDriver(); RectangleSize originalViewportSize = EyesSeleniumUtils.GetViewportSize(logger_, driver); RectangleSize viewportSize = originalViewportSize.Scale(scaleRatio); if (image.Height > viewportSize.Height || image.Width > viewportSize.Width) { //Damn IE driver returns full page screenshot even when not asked to! logger_.Verbose("seems IE returned full page screenshot rather than only the viewport."); eyes_.DebugScreenshotProvider.Save(image, "IE"); if (!eyes_.IsCutProviderExplicitlySet) { Bitmap croppedImage = BasicImageUtils.Crop(image, new Rectangle(scaledLoc, viewportSize)); image.Dispose(); image = croppedImage; } } positionProvider?.SetPosition(loc); return(image); }
public override string ToString() { return($"{GetType().Name} shape with {Id} has following parameters:" + $"Position - {TopLeftPosition}, Size - {RectangleSize.ToString()}," + $" Perimeter - {Perimeter}, Square - {Square}\n"); }
/// <summary> /// Creates a new AppEnvironment instance. /// </summary> public AppEnvironment(string operatingSystem, string hostingApp, RectangleSize displaySize) { OS = operatingSystem; HostingApp = hostingApp; DisplaySize = displaySize; }
protected override void SetViewportSize(RectangleSize size) { }
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); }
public IConfiguration SetViewportSize(RectangleSize value) { ViewportSize = value; return(this); }
public DeviceSize(int width, int height) { Portrait = new RectangleSize(height, width); Landscape = LandscapeLeft = LandscapeRight = new RectangleSize(width, height); }
public void SetDeviceSize(RectangleSize deviceSize) { DeviceSize = deviceSize; }
public static void compareProcedure(Dictionary <string, object> actualRegion, RectangleSize expectedRegion, string type) { RectangleSize actual = new RectangleSize((int)(long)actualRegion["width"], (int)(long)actualRegion["height"]); Assert.IsTrue(RectangleSize.AreEqual(expectedRegion, actual), "Actual region with Width=" + actual.Width.ToString() + " Height=" + actual.Height.ToString() + " don't equal to expected region with Width = " + expectedRegion.Width.ToString() + " Height = " + expectedRegion.Height.ToString()); }
public new IConfiguration SetViewportSize(RectangleSize value) => (IConfiguration)base.SetViewportSize(value);
private object ModifyValue(Type type, object origValue) { object modifiedValue = origValue; if (type == typeof(string)) { modifiedValue = origValue + "_dummy"; } else if (type == typeof(bool)) { modifiedValue = !(bool)origValue; } else if (type == typeof(bool?)) { modifiedValue = ((bool?)origValue) ?? true; modifiedValue = !(bool)modifiedValue; } else if (type == typeof(BatchInfo)) { modifiedValue = new BatchInfo((origValue as BatchInfo)?.Name + "_dummy"); } else if (type == typeof(ImageMatchSettings)) { modifiedValue = new ImageMatchSettings(); } else if (type == typeof(TimeSpan)) { modifiedValue = ((TimeSpan)origValue).Add(TimeSpan.FromSeconds(1)); } else if (type == typeof(int)) { modifiedValue = ((int)origValue) + 1; } else if (type == typeof(RectangleSize)) { RectangleSize origRectSize = origValue as RectangleSize; if (origRectSize == null) { modifiedValue = new RectangleSize(); } else { modifiedValue = new RectangleSize(origRectSize.Width + 1, origRectSize.Height + 1); } } else if (type == typeof(MatchLevel)) { modifiedValue = MatchLevel.Exact; if (modifiedValue == origValue) { modifiedValue = MatchLevel.Content; } } else if (type == typeof(StitchModes)) { modifiedValue = StitchModes.CSS; if (modifiedValue == origValue) { modifiedValue = StitchModes.Scroll; } } else if (type == typeof(AccessibilityLevel)) { modifiedValue = AccessibilityLevel.AA; if (modifiedValue == origValue) { modifiedValue = AccessibilityLevel.AAA; } } else if (type == typeof(AccessibilitySettings)) { modifiedValue = new AccessibilitySettings(AccessibilityLevel.AA, AccessibilityGuidelinesVersion.WCAG_2_0); } else if (type == typeof(VisualGridOption[])) { var list = new List <VisualGridOption>() { new VisualGridOption("option1", "value1") }; if (origValue != null && list.Count == ((VisualGridOption[])origValue).Length) { list.Add(new VisualGridOption("option2", true)); } modifiedValue = list.ToArray(); } return(modifiedValue); }
public IConfiguration SetViewportSize(int width, int height) { ViewportSize = new RectangleSize(width, height); return(this); }