/// <summary> /// Applies the test framework styles to the control. /// </summary> /// <param name="control">The control reference.</param> public override void ApplyStyle(HtmlControl control) { // For all controls, set the default font and size WebBrowserTestPage.SetDefaultFont(control); WebBrowserTestPage.SetDefaultFontSize(control); }
/// <summary> /// Adds a row to the table. /// </summary> /// <param name="property">The property cell.</param> /// <param name="value">The value cell.</param> /// <returns>Returns the row HtmlControl.</returns> public HtmlControl AddRow(HtmlControl property, HtmlControl value) { HtmlControl row = new HtmlControl(HtmlTag.Tr); row.Controls.Add(CreateCell(property)); row.Controls.Add(CreateCell(value)); _body.Controls.Add(row); return row; }
/// <summary> /// Makes a control transparent. Works with several browsers. /// </summary> /// <param name="control">The control.</param> /// <param name="opacity">The opacity amount.</param> private static void MakeTransparent(HtmlControl control, int opacity) { control.SetStyleAttribute("filter", "alpha(opacity=" + opacity + ")"); control.SetStyleAttribute("-moz-opacity", "." + opacity); control.SetStyleAttribute("opacity", "." + opacity); }
/// <summary> /// Sets the font size of the control to be the default size for the /// test framework. /// </summary> /// <param name="control">The managed HTML control.</param> public static void SetDefaultFontSize(HtmlControl control) { control.Font.Size = new FontUnit(DefaultFontSize); }
/// <summary> /// Sets the font of the control to be the default fixed-size font for /// the test framework. /// </summary> /// <param name="control">The managed HTML control.</param> public static void SetDefaultFixedFont(HtmlControl control) { control.Font.Names = _defaultFixedFontFamilies; }
/// <summary> /// Initializes the HtmlTestPage Control with a specific minimum plugin /// size requirement. /// </summary> /// <param name="minimumPluginWidth">The minimum width that the plugin /// can be sized to.</param> /// <param name="minimumPluginHeight">The minimum height that the plugin /// can be sized to.</param> /// <param name="testColumnWidth">The width to allocate for the test /// column.</param> /// <param name="permitResizing">A value indicating whether to allow /// the plugin and page to resize the contents.</param> public WebBrowserTestPage(int minimumPluginWidth, int minimumPluginHeight, int testColumnWidth, bool permitResizing) { PrepareApplicationFonts(); _testColumnWidth = testColumnWidth; _minimumPluginSize = new Size<int>(minimumPluginWidth, minimumPluginHeight); _pluginContainer = new HtmlControl(HtmlPage.Plugin.Parent); _plugin = new HtmlControl(HtmlPage.Plugin); CalculatePreferredPluginSize(); if (permitResizing) { ResizeSilverlightPlugin(); } // Appended directly into the document body _testColumn = new HtmlTestColumn(_testColumnWidth, ImplicitPadding, _browserClientSize.Height); HtmlPage.Document.Body.AppendChild(_testColumn); }
/// <summary> /// Applies the styles to the control. Derived classes can customize /// the type, tag, or other properties of the controls to limit when the /// styles are applied. /// </summary> /// <param name="control">The control reference.</param> public virtual void ApplyStyle(HtmlControl control) { // The default implementation does nothing }
/// <summary> /// Initializes the component. /// </summary> private void InitializeComponent() { _body = new HtmlControl(HtmlTag.Tbody); Controls.Add(_body); }
/// <summary> /// Creates a cell element with content. /// </summary> /// <param name="content">The content of the cell.</param> /// <returns>Returns the cell.</returns> private static HtmlControl CreateCell(HtmlControl content) { HtmlControl cell = new HtmlControl(HtmlTag.Td); cell.Controls.Add(content); return cell; }
/// <summary> /// Adds a row to the table. /// </summary> /// <param name="property">The property value.</param> /// <param name="value">The string value.</param> /// <returns>Returns the row HtmlControl.</returns> public HtmlControl AddRow(string property, HtmlControl value) { return AddRow(new Paragraph(property), value); }
/// <summary> /// Adds the copy information action. /// </summary> /// <param name="actions">The action container.</param> private void AddCopyAction(HtmlControl actions) { HtmlAnchor copy = new HtmlAnchor( "Copy result details", delegate(object sender, HtmlEventArgs args) { //HtmlPage.Window.Alert(Inspector.Result.ToString()); }); StyleActionLink(copy); actions.Controls.Add(copy); }
/// <summary> /// Adds the retry action link. /// </summary> /// <param name="actions">The action container.</param> private void AddRetryAction(HtmlControl actions) { HtmlAnchor rerun = new HtmlAnchor( "Retry this test", delegate(object sender, HtmlEventArgs args) { RetryTestRunFilter retryFilter = new RetryTestRunFilter(Inspector.Result.TestClass, Inspector.Result.TestMethod); UnitTestHarness ut = UnitTestHarness; if (ut != null) { ut.RestartRunDispatcher(); ut.EnqueueTestAssembly(Inspector.Result.TestClass.Assembly, retryFilter); } }); StyleActionLink(rerun); actions.Controls.Add(rerun); }
/// <summary> /// Apply bold formatting to all sub-controls in a row. /// </summary> /// <param name="row">Row control.</param> private static void BoldRow(HtmlControl row) { for (int i = 0; i < row.Controls.Count; ++i) { HtmlControl c = row.Controls[i] as HtmlControl; if (c != null) { c.Font.Bold = true; } } }
/// <summary> /// Records a failure and modifies the web page to allow linking between /// the failure summary, and also next and previous failure /// functionality. /// </summary> /// <param name="method">Unit test provider's method reference.</param> /// <param name="methodNextSpan">Span that will contain the next button.</param> public void AddMethodFailure(ITestMethod method, HtmlControl methodNextSpan) { string id = PrefixIdentifier + _summary.GenerateNextFailureId().ToString(CultureInfo.InvariantCulture); HtmlAnchor anchor = new HtmlAnchor(id); StyleAnchor(anchor); anchor.Id = id; methodNextSpan.Controls.Add(anchor); // Link to the previous failure //--- if (_summary.FirstFailureEntry != null) { HtmlAnchor prev = new HtmlAnchor(); StyleAnchor(prev); prev.Href = "#" + _summary.LastFailureEntry.Id; prev.Title = "Previous Failure"; prev.Font.Underline = false; prev.ForegroundColor = Color.White; prev.InnerHtml = "↑"; methodNextSpan.Controls.Add(prev); } // Link to the next failure //--- if (_summary.LastFailureEntry != null) { HtmlAnchor next = new HtmlAnchor(); StyleAnchor(next); next.Href = "#" + id; next.Title = "Next Failure"; next.Font.Underline = false; next.ForegroundColor = Color.White; next.InnerHtml = " ↓"; _summary.LastFailureEntry.Element.Controls.Add(next); } // The failure summary link //--- HtmlAnchor link = new HtmlAnchor(); StyleAnchor(link); link.Href = "#" + id; link.Display = CssDisplay.Block; link.InnerHtml = method.Name; Controls.Add(link); // Store this most recent failure's data //--- _summary.LastFailureEntry = new FailureEntry { Id = id, Element = methodNextSpan }; // Set the first entry if this is the first //--- if (_summary.FirstFailureEntry == null) { _summary.FirstFailureEntry = _summary.LastFailureEntry; } }
/// <summary> /// Adds a failure visually. /// </summary> /// <param name="testClass">Test class metadata object.</param> /// <param name="method">Method metadata object.</param> /// <param name="methodNextSpan">The next method to work with.</param> public void AddFailure( ITestClass testClass, ITestMethod method, HtmlControl methodNextSpan) { if (_lastId == 0) { FirstFailure(); } if (false == _classes.ContainsKey(testClass)) { _classes[testClass] = new FailureControl(testClass, this); Controls.Add(_classes[testClass]); } _classes[testClass].AddMethodFailure(method, methodNextSpan); }