Skip to content

Commit

Permalink
Merge pull request TestStack#361 from TestStack/various-cleanups
Browse files Browse the repository at this point in the history
Deleted unused files, renamed some interfaces to begin with an "I"
  • Loading branch information
Roemer committed Jan 5, 2016
2 parents 1476b5a + 88edd06 commit 12d16f3
Show file tree
Hide file tree
Showing 157 changed files with 265 additions and 347 deletions.
2 changes: 1 addition & 1 deletion src/TestStack.White.UITests/ControlTests/MyDateUIItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace TestStack.White.UITests.ControlTests
[ControlTypeMapping(CustomUIItemType.Custom, WindowsFramework.Wpf)]
public class MyDateUIItem : CustomUIItem
{
public MyDateUIItem(AutomationElement automationElement, ActionListener actionListener) : base(automationElement, actionListener) { }
public MyDateUIItem(AutomationElement automationElement, IActionListener actionListener) : base(automationElement, actionListener) { }

protected MyDateUIItem() { }

Expand Down
4 changes: 2 additions & 2 deletions src/TestStack.White.UITests/ControlTests/Table/TableTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ public void FindAllTest()
[Test]
public void IsInTopTest()
{
Assert.That(((TableVerticalScrollOffset)table).IsOnTop, Is.True);
Assert.That(((ITableVerticalScrollOffset)table).IsOnTop, Is.True);
table.Rows[table.Rows.Count - 1].Select();
Assert.That(((TableVerticalScrollOffset)table).IsOnTop, Is.False);
Assert.That(((ITableVerticalScrollOffset)table).IsOnTop, Is.False);
}
}
}
2 changes: 1 addition & 1 deletion src/TestStack.White.WebBrowser/FirefoxFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace TestStack.White.WebBrowser
{
public class FirefoxFactory : SpecializedWindowFactory
public class FirefoxFactory : ISpecializedWindowFactory
{
public static void Plugin()
{
Expand Down
2 changes: 1 addition & 1 deletion src/TestStack.White.WebBrowser/InternetExplorerFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace TestStack.White.WebBrowser
{
public class InternetExplorerFactory : SpecializedWindowFactory
public class InternetExplorerFactory : ISpecializedWindowFactory
{
public static void Plugin()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public override PopUpMenu Popup
get { throw new System.NotSupportedException(); }
}

protected override ActionListener ChildrenActionListener
protected override IActionListener ChildrenActionListener
{
get { return this; }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ public class AutomationSearchConditionFactory
public virtual List<AutomationSearchCondition> GetWindowSearchConditions(int processId)
{
return new List<AutomationSearchCondition>
{AutomationSearchCondition.GetWindowSearchCondition(processId, ControlType.Window),
AutomationSearchCondition.GetWindowSearchCondition(processId, ControlType.Pane)};
{
AutomationSearchCondition.GetWindowSearchCondition(processId, ControlType.Window),
AutomationSearchCondition.GetWindowSearchCondition(processId, ControlType.Pane)
};
}
}
}
3 changes: 0 additions & 3 deletions src/TestStack.White/CoreTestTemplate.cs

This file was deleted.

29 changes: 14 additions & 15 deletions src/TestStack.White/Desktop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ private static Desktop Create()
return new Desktop(AutomationElement.RootElement, new NullActionListener(), InitializeOption.NoCache, new NullWindowSession());
}

private Desktop(AutomationElement automationElement, ActionListener actionListener, InitializeOption initializeOption,
WindowSession windowSession) : base(automationElement, actionListener, initializeOption, windowSession)
private Desktop(AutomationElement automationElement, IActionListener actionListener, InitializeOption initializeOption, WindowSession windowSession)
: base(automationElement, actionListener, initializeOption, windowSession)
{
finder = new AutomationElementFinder(automationElement);
}
Expand All @@ -38,12 +38,11 @@ private ListControl IconsList
{
get
{
AutomationElement element =
finder.Child(new[]
{
AutomationSearchCondition.ByControlType(ControlType.Pane).OfName("Program Manager"),
AutomationSearchCondition.ByControlType(ControlType.List).OfName("Desktop")
});
AutomationElement element = finder.Child(new[]
{
AutomationSearchCondition.ByControlType(ControlType.Pane).OfName("Program Manager"),
AutomationSearchCondition.ByControlType(ControlType.List).OfName("Desktop")
});
return new ListControl(element, new ProcessActionListener(element));
}
}
Expand All @@ -59,7 +58,7 @@ public virtual List<Window> Windows()
}

/// <summary>
/// Captures a screenshot of the entire desktop, and returns the bitmap
/// Captures a screenshot of the entire desktop and returns the bitmap
/// </summary>
public static Bitmap CaptureScreenshot()
{
Expand All @@ -68,7 +67,7 @@ public static Bitmap CaptureScreenshot()
}

/// <summary>
/// Captures a screenshot of the provided boundary, and returns the bitmap
/// Captures a screenshot of the provided boundary and returns the bitmap
/// </summary>
/// <param name="bounds">Screen rectangle to capture</param>
public static Bitmap CaptureScreenshot(Rect bounds)
Expand All @@ -80,24 +79,24 @@ public static Bitmap CaptureScreenshot(Rect bounds)
/// <summary>
/// Takes a screenshot of the provided boundary, and saves it to disk
/// </summary>
/// <param name="bounds"></param>
/// <param name="bounds">Screen rectangle to capture</param>
/// <param name="filename">The fullname of the file (including extension)</param>
/// <param name="imageFormat"></param>
/// <param name="imageFormat">The format of the image</param>
public static void TakeScreenshot(Rect bounds, string filename, ImageFormat imageFormat)
{
var bitmap = CaptureScreenshot(bounds);
bitmap.Save(filename, imageFormat);
bitmap.Save(filename, imageFormat);
}

/// <summary>
/// Takes a screenshot of the entire desktop, and saves it to disk
/// </summary>
/// <param name="filename">The fullname of the file (including extension)</param>
/// <param name="imageFormat"></param>
/// <param name="imageFormat">The format of the image</param>
public static void TakeScreenshot(string filename, ImageFormat imageFormat)
{
var bitmap = CaptureScreenshot();
bitmap.Save(filename, ImageFormat.Png);
bitmap.Save(filename, imageFormat);
}
}
}
4 changes: 2 additions & 2 deletions src/TestStack.White/Factory/ChildWindowFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public abstract class ChildWindowFactory
{
protected readonly AutomationElementFinder Finder;

protected static readonly List<SpecializedWindowFactory> SpecializedWindowFactories = new List<SpecializedWindowFactory>();
protected static readonly List<ISpecializedWindowFactory> SpecializedWindowFactories = new List<ISpecializedWindowFactory>();

protected ChildWindowFactory(AutomationElementFinder finder)
{
Expand Down Expand Up @@ -47,7 +47,7 @@ protected virtual AutomationElement WaitTillFound(Func<AutomationElement> find,
/// <exception cref="UIItemSearchException">The application type is not supported by White</exception>
internal static Window Create(AutomationElement element, InitializeOption option, WindowSession windowSession)
{
SpecializedWindowFactory specializedWindowFactory = SpecializedWindowFactories.Find(factory => factory.DoesSpecializeInThis(element));
ISpecializedWindowFactory specializedWindowFactory = SpecializedWindowFactories.Find(factory => factory.DoesSpecializeInThis(element));
if (specializedWindowFactory != null)
{
return specializedWindowFactory.Create(element, option, windowSession);
Expand Down
8 changes: 4 additions & 4 deletions src/TestStack.White/Factory/DictionaryMappedItemFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@

namespace TestStack.White.Factory
{
public class DictionaryMappedItemFactory : UIItemFactory
public class DictionaryMappedItemFactory : IUIItemFactory
{
public virtual IUIItem Create(AutomationElement automationElement, ActionListener actionListener)
public virtual IUIItem Create(AutomationElement automationElement, IActionListener actionListener)
{
if (automationElement == null) return null;
return Create(automationElement, ControlDictionary.Instance.GetTestControlType(automationElement), actionListener);
}

public virtual IUIItem Create(AutomationElement automationElement, ActionListener actionListener, Type customItemType)
public virtual IUIItem Create(AutomationElement automationElement, IActionListener actionListener, Type customItemType)
{
if (automationElement == null) return null;
if (customItemType != null) return Create(automationElement, customItemType, actionListener);
return Create(automationElement, actionListener);
}

private IUIItem Create(AutomationElement automationElement, Type itemType, ActionListener actionListener)
private IUIItem Create(AutomationElement automationElement, Type itemType, IActionListener actionListener)
{
if (itemType == null) return null;
return (IUIItem) Activator.CreateInstance(itemType, automationElement, actionListener);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace TestStack.White.Factory
{
public interface SpecializedWindowFactory
public interface ISpecializedWindowFactory
{
bool DoesSpecializeInThis(AutomationElement windowElement);
Window Create(AutomationElement automationElement, InitializeOption initializeOption, WindowSession session);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

namespace TestStack.White.Factory
{
public interface UIItemFactory
public interface IUIItemFactory
{
IUIItem Create(AutomationElement automationElement, ActionListener actionListener);
IUIItem Create(AutomationElement automationElement, IActionListener actionListener);
}
}
4 changes: 2 additions & 2 deletions src/TestStack.White/Factory/ListViewCellFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

namespace TestStack.White.Factory
{
public class ListViewCellFactory : UIItemFactory
public class ListViewCellFactory : IUIItemFactory
{
public virtual IUIItem Create(AutomationElement automationElement, ActionListener actionListener)
public virtual IUIItem Create(AutomationElement automationElement, IActionListener actionListener)
{
return new ListViewCell(automationElement, actionListener);
}
Expand Down
16 changes: 8 additions & 8 deletions src/TestStack.White/Factory/PrimaryUIItemFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ public virtual ToolTip ToolTip
}
}

public virtual TitleBar GetTitleBar(ActionListener actionListener)
public virtual TitleBar GetTitleBar(IActionListener actionListener)
{
AutomationElement titleElement = Finder.Child(AutomationSearchCondition.ByControlType(ControlType.TitleBar));
if (titleElement == null) return null;
return new TitleBar(titleElement, actionListener);
}

public virtual PopUpMenu WPFPopupMenu(ActionListener actionListener)
public virtual PopUpMenu WPFPopupMenu(IActionListener actionListener)
{
var searchConditions = new[]
{
Expand All @@ -46,13 +46,13 @@ public virtual PopUpMenu WPFPopupMenu(ActionListener actionListener)
return popUpMenu;
}

public virtual bool TryGetPopupMenu(ActionListener actionListener, out PopUpMenu popUpMenu)
public virtual bool TryGetPopupMenu(IActionListener actionListener, out PopUpMenu popUpMenu)
{
var searchConditions = new[] {AutomationSearchCondition.ByControlType(ControlType.Menu).OfName("DropDown")};
return TryGetPopupMenu(searchConditions, actionListener, out popUpMenu);
}

private bool TryGetPopupMenu(AutomationSearchCondition[] searchConditions, ActionListener actionListener, out PopUpMenu popUpMenu)
private bool TryGetPopupMenu(AutomationSearchCondition[] searchConditions, IActionListener actionListener, out PopUpMenu popUpMenu)
{
var element = Retry.For(() => Finder.Child(searchConditions), CoreAppXmlConfiguration.Instance.PopupTimeout(), TimeSpan.FromMilliseconds(100));
if (element == null)
Expand All @@ -64,7 +64,7 @@ private bool TryGetPopupMenu(AutomationSearchCondition[] searchConditions, Actio
return true;
}

public virtual IUIItem Create(SearchCriteria searchCriteria, ActionListener actionListener)
public virtual IUIItem Create(SearchCriteria searchCriteria, IActionListener actionListener)
{
if (searchCriteria.IsIndexed)
{
Expand All @@ -75,18 +75,18 @@ public virtual IUIItem Create(SearchCriteria searchCriteria, ActionListener acti
searchCriteria.CustomItemType);
}

public virtual UIItemCollection CreateAll(SearchCriteria searchCriteria, ActionListener actionListener)
public virtual UIItemCollection CreateAll(SearchCriteria searchCriteria, IActionListener actionListener)
{
return new UIItemCollection(Finder.Descendants(searchCriteria.AutomationSearchCondition), actionListener, searchCriteria.CustomItemType);
}

public virtual Image WinFormImage(string primaryIdentification, ActionListener actionListener)
public virtual Image WinFormImage(string primaryIdentification, IActionListener actionListener)
{
AutomationElement element = Finder.Descendant(SearchCriteria.ByAutomationId(primaryIdentification).AutomationCondition);
return new Image(element, actionListener);
}

public virtual UIItemCollection ItemsWithin(Rect bounds, ActionListener actionListener)
public virtual UIItemCollection ItemsWithin(Rect bounds, IActionListener actionListener)
{
var collection = new UIItemCollection();
List<AutomationElement> descendants = Finder.Descendants(AutomationSearchCondition.All);
Expand Down
4 changes: 2 additions & 2 deletions src/TestStack.White/Factory/TableCellFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ namespace TestStack.White.Factory
public class TableCellFactory
{
private readonly AutomationElement tableElement;
private readonly ActionListener actionListener;
private readonly IActionListener actionListener;
private List<AutomationElement> customControlTypes;

public TableCellFactory(AutomationElement tableElement, ActionListener actionListener)
public TableCellFactory(AutomationElement tableElement, IActionListener actionListener)
{
this.tableElement = tableElement;
this.actionListener = actionListener;
Expand Down
4 changes: 2 additions & 2 deletions src/TestStack.White/Factory/TableHeaderFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

namespace TestStack.White.Factory
{
public class TableHeaderFactory : UIItemFactory
public class TableHeaderFactory : IUIItemFactory
{
public virtual IUIItem Create(AutomationElement automationElement, ActionListener actionListener)
public virtual IUIItem Create(AutomationElement automationElement, IActionListener actionListener)
{
return new TableHeader(automationElement, actionListener);
}
Expand Down
2 changes: 1 addition & 1 deletion src/TestStack.White/Factory/TableRowFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public TableRowFactory(AutomationElementFinder automationElementFinder)
this.automationElementFinder = automationElementFinder;
}

public virtual TableRows CreateRows(ActionListener actionListener, TableHeader tableHeader)
public virtual TableRows CreateRows(IActionListener actionListener, TableHeader tableHeader)
{
List<AutomationElement> rowElements = GetRowElements();
return new TableRows(rowElements, actionListener, tableHeader, new TableCellFactory(automationElementFinder.AutomationElement, actionListener));
Expand Down
2 changes: 1 addition & 1 deletion src/TestStack.White/Factory/UIItemProxyFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace TestStack.White.Factory
{
public static class UIItemProxyFactory
{
public static IUIItem Create(IUIItem item, ActionListener actionListener)
public static IUIItem Create(IUIItem item, IActionListener actionListener)
{
return (IUIItem) DynamicProxyGenerator.Instance.CreateProxy(item.GetType(), new CoreInterceptor(item, actionListener));
}
Expand Down
4 changes: 2 additions & 2 deletions src/TestStack.White/Factory/WindowFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static WindowFactory Desktop
get { return new WindowFactory(new AutomationElementFinder(AutomationElement.RootElement)); }
}

public virtual PopUpMenu PopUp(ActionListener actionListener)
public virtual PopUpMenu PopUp(IActionListener actionListener)
{
return new PopUpMenu(Finder.AutomationElement, actionListener);
}
Expand Down Expand Up @@ -152,7 +152,7 @@ private void AddWindowsBy(List<Window> windows, ControlType controlType)
windows.AddRange(children.Select(childElement => Create(childElement, InitializeOption.NoCache, new NullWindowSession())));
}

public static void AddSpecializedWindowFactory(SpecializedWindowFactory specializedWindowFactory)
public static void AddSpecializedWindowFactory(ISpecializedWindowFactory specializedWindowFactory)
{
SpecializedWindowFactories.Add(specializedWindowFactory);
}
Expand Down
Loading

0 comments on commit 12d16f3

Please sign in to comment.