Skip to content

Commit

Permalink
Some cleanup of this PR
Browse files Browse the repository at this point in the history
  • Loading branch information
Jake Ginnivan committed Jul 29, 2013
1 parent a3d225a commit 885a996
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 52 deletions.
4 changes: 2 additions & 2 deletions src/TestStack.White.UnitTests/UIItems/DateFormatTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ public class DateFormatTest
[Fact]
public void DifferentDateFormats()
{
Assert.Equal(DateFormat.dayMonthYear, DateFormat.Create("-", "dd-MM-yyyy"));
Assert.Equal(DateFormat.dayMonthYear, DateFormat.Create("-", "d-M-yyyy"));
Assert.Equal(DateFormat.DayMonthYear, DateFormat.Create("-", "dd-MM-yyyy"));
Assert.Equal(DateFormat.DayMonthYear, DateFormat.Create("-", "d-M-yyyy"));
}
}
}
44 changes: 18 additions & 26 deletions src/TestStack.White/Application.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,9 @@ private Application(Process process)
/// <summary>
/// Runs the process identified by the executable and creates Application object for this executable
/// </summary>
/// <param name="executable">location of the executable</param>
/// <returns></returns>
/// <exception cref="ArgumentNullException"></exception>
/// <exception cref="WhiteException">when some error occured</exception>
/// <param name="executable">Path to the executable</param>
/// <exception cref="ArgumentNullException">No process info passed</exception>
/// <exception cref="WhiteException">White Failed to Launch or Attached to process</exception>
public static Application Launch(string executable)
{
var processStartInfo = new ProcessStartInfo(executable);
Expand All @@ -51,10 +50,8 @@ public static Application Launch(string executable)
/// <summary>
/// Lauches the process and creates and Application object for it
/// </summary>
/// <param name="processStartInfo"></param>
/// <returns></returns>
/// <exception cref="ArgumentNullException"></exception>
/// <exception cref="WhiteException">when some error occured</exception>
/// <exception cref="ArgumentNullException">No process info passed</exception>
/// <exception cref="WhiteException">White Failed to Launch or Attached to process</exception>
public static Application Launch(ProcessStartInfo processStartInfo)
{
if (string.IsNullOrEmpty(processStartInfo.WorkingDirectory)) processStartInfo.WorkingDirectory = ".";
Expand Down Expand Up @@ -93,30 +90,27 @@ public static Application Launch(ProcessStartInfo processStartInfo)
}

/// <summary>
/// Creates an Application object for existing process
/// Attaches White to an existing process by process id
/// </summary>
/// <param name="processId"></param>
/// <returns></returns>
/// <exception cref="WhiteException">when process not found</exception>
/// <exception cref="WhiteException">White Failed to Attach to process</exception>
public static Application Attach(int processId)
{
Process process = null;
Process process;
try
{
process = Process.GetProcessById(processId);
}
catch (System.ArgumentException e)
catch (ArgumentException e)
{
throw new WhiteException("Could not find process with id: " + processId, e);
}
return new Application(process);
}

/// <summary>
/// Attaches with existing process
/// Attaches White to an existing process
/// </summary>
/// <param name="process"></param>
/// <returns></returns>
/// <exception cref="WhiteException">White Failed to Attach to process</exception>
public static Application Attach(Process process)
{
return new Application(process);
Expand All @@ -125,9 +119,7 @@ public static Application Attach(Process process)
/// <summary>
/// Attaches with existing process
/// </summary>
/// <param name="executable"></param>
/// <returns></returns>
/// <exception cref="WhiteException">when process is not found</exception>
/// <exception cref="WhiteException">White Failed to Attach to process with specified name</exception>
public static Application Attach(string executable)
{
Process[] processes = Process.GetProcessesByName(executable);
Expand All @@ -142,7 +134,7 @@ public static Application Attach(string executable)
/// <returns></returns>
/// <exception cref="ArgumentException"></exception>
/// <exception cref="ArgumentNullException"></exception>
/// <exception cref="WhiteException">when some error occured</exception>
/// <exception cref="WhiteException">White Failed to Launch or Attach to process</exception>
public static Application AttachOrLaunch(ProcessStartInfo processStartInfo)
{
string processName = ReplaceLast(processStartInfo.FileName, ".exe", string.Empty);
Expand Down Expand Up @@ -181,7 +173,7 @@ public virtual ApplicationSession ApplicationSession
/// <param name="title">Title text of window displayed on desktop</param>
/// <param name="option">Option which would be used to initialize the window.</param>
/// <returns></returns>
/// <exception cref="UIItemSearchException">if your framework is not supported</exception>
/// <exception cref="UIItemSearchException">The application type is not supported by White</exception>
public virtual Window GetWindow(string title, InitializeOption option)
{
WindowSession windowSession = applicationSession.WindowSession(option);
Expand All @@ -193,7 +185,7 @@ public virtual Window GetWindow(string title, InitializeOption option)
/// </summary>
/// <param name="title">Title text of window displayed on desktop</param>
/// <returns></returns>
/// <exception cref="UIItemSearchException">if your framework is not supported</exception>
/// <exception cref="UIItemSearchException">The application type is not supported by White</exception>
public virtual Window GetWindow(string title)
{
return GetWindow(title, InitializeOption.NoCache);
Expand All @@ -205,7 +197,7 @@ public virtual Window GetWindow(string title)
/// <param name="searchCriteria"></param>
/// <param name="initializeOption">found window would be initialized with this option</param>
/// <returns></returns>
/// <exception cref="UIItemSearchException">if your framework is not supported</exception>
/// <exception cref="UIItemSearchException">The application type is not supported by White</exception>
public virtual Window GetWindow(SearchCriteria searchCriteria, InitializeOption initializeOption)
{
WindowSession windowSession = applicationSession.WindowSession(initializeOption);
Expand Down Expand Up @@ -253,7 +245,7 @@ public virtual void Kill()
/// All windows belonging to the application
/// </summary>
/// <returns></returns>
/// <exception cref="UIItemSearchException">if your framework is not supported</exception>
/// <exception cref="UIItemSearchException">The application type is not supported by White</exception>
public virtual List<Window> GetWindows()
{
return windowFactory.DesktopWindows(process, new NoApplicationSession());
Expand Down Expand Up @@ -309,7 +301,7 @@ public virtual void WaitWhileBusy()
/// </summary>
/// <param name="match"></param>
/// <param name="initializeOption">option for the window which matches the condition</param>
/// <exception cref="UIItemSearchException">if your framework is not supported</exception>
/// <exception cref="UIItemSearchException">The application type is not supported by White</exception>
public virtual Window Find(Predicate<string> match, InitializeOption initializeOption)
{
WindowSession windowSession = applicationSession.WindowSession(initializeOption);
Expand Down
2 changes: 1 addition & 1 deletion src/TestStack.White/Factory/ChildWindowFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ protected virtual AutomationElement WaitTillFound(Func<AutomationElement> find,
return element;
}

/// <exception cref="UIItemSearchException">if your framework is not supported</exception>
/// <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));
Expand Down
12 changes: 6 additions & 6 deletions src/TestStack.White/Factory/WindowFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,31 +68,31 @@ public virtual Window SplashWindow(Process process)
return new SplashWindow(element, InitializeOption.NoCache);
}

/// <exception cref="UIItemSearchException">if your framework is not supported</exception>
/// <exception cref="UIItemSearchException">The application type is not supported by White</exception>
public virtual Window CreateWindow(string title, Process process, InitializeOption option, WindowSession windowSession)
{
var message = string.Format("Couldn't find window with title {0} in process {1}{2}", title, process.Id, ", after waiting for 30 seconds");
var element = WaitTillFound(() => Finder.FindWindow(title, process.Id), message);
return Create(element, option, windowSession);
}

/// <exception cref="UIItemSearchException">if your framework is not supported</exception>
/// <exception cref="UIItemSearchException">The application type is not supported by White</exception>
public virtual Window CreateWindow(SearchCriteria searchCriteria, Process process, InitializeOption option, WindowSession windowSession)
{
var message = string.Format("Couldn't find window with SearchCriteria {0} in process {1}{2}", searchCriteria, process.Id, Constants.BusyMessage);
var element = WaitTillFound(() => Finder.FindWindow(searchCriteria, process.Id), message);
return Create(element, option, windowSession);
}

/// <exception cref="UIItemSearchException">if your framework is not supported</exception>
/// <exception cref="UIItemSearchException">The application type is not supported by White</exception>
public virtual Window FindWindow(Process process, Predicate<string> match, InitializeOption initializeOption, WindowSession windowSession)
{
string message = string.Format("Could not find window matching condition. ProcessName: {0}, ProcessId: {1}, MatchingConditionMethod: {2}, MatchingConditionTarget: {3}", process.ProcessName, process.Id, match.Method, match.Target);
var foundElement = WaitTillFound(() => FindWindowElement(process, match), message);
return Create(foundElement, initializeOption, windowSession);
}

/// <exception cref="UIItemSearchException">if your framework is not supported</exception>
/// <exception cref="UIItemSearchException">The application type is not supported by White</exception>
public virtual Window FindModalWindow(string title, Process process, InitializeOption option, AutomationElement parentWindowElement,
WindowSession windowSession)
{
Expand All @@ -102,7 +102,7 @@ public virtual Window FindModalWindow(string title, Process process, InitializeO
return Create(modalWindowElement, option, windowSession);
}

/// <exception cref="UIItemSearchException">if your framework is not supported</exception>
/// <exception cref="UIItemSearchException">The application type is not supported by White</exception>
public virtual Window FindModalWindow(SearchCriteria searchCriteria, InitializeOption option, AutomationElement parentWindowElement, WindowSession windowSession)
{
var windowFinder = new AutomationElementFinder(parentWindowElement);
Expand Down Expand Up @@ -137,7 +137,7 @@ private AutomationElement FindWindowElement(Process process, Predicate<string> m
});
}

/// <exception cref="UIItemSearchException">if your framework is not supported</exception>
/// <exception cref="UIItemSearchException">The application type is not supported by White</exception>
public virtual List<Window> DesktopWindows()
{
var windows = new List<Window>();
Expand Down
14 changes: 7 additions & 7 deletions src/TestStack.White/UIItems/DateFormat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ namespace TestStack.White.UIItems
/// </summary>
public class DateFormat
{
public static DateFormat dayMonthYear = new DateFormat(DateUnit.Day, DateUnit.Month, DateUnit.Year);
public static DateFormat dayYearMonth = new DateFormat(DateUnit.Day, DateUnit.Year, DateUnit.Month);
public static DateFormat monthDayYear = new DateFormat(DateUnit.Month, DateUnit.Day, DateUnit.Year);
public static DateFormat monthYearDay = new DateFormat(DateUnit.Month, DateUnit.Year, DateUnit.Day);
public static DateFormat yearMonthDay = new DateFormat(DateUnit.Year, DateUnit.Month, DateUnit.Day);
public static DateFormat yearDayMonth = new DateFormat(DateUnit.Year, DateUnit.Day, DateUnit.Month);
public static DateFormat DayMonthYear = new DateFormat(DateUnit.Day, DateUnit.Month, DateUnit.Year);
public static DateFormat DayYearMonth = new DateFormat(DateUnit.Day, DateUnit.Year, DateUnit.Month);
public static DateFormat MonthDayYear = new DateFormat(DateUnit.Month, DateUnit.Day, DateUnit.Year);
public static DateFormat MonthYearDay = new DateFormat(DateUnit.Month, DateUnit.Year, DateUnit.Day);
public static DateFormat YearMonthDay = new DateFormat(DateUnit.Year, DateUnit.Month, DateUnit.Day);
public static DateFormat YearDayMonth = new DateFormat(DateUnit.Year, DateUnit.Day, DateUnit.Month);

private readonly List<DateUnit> dateUnits = new List<DateUnit>();

Expand Down Expand Up @@ -49,7 +49,7 @@ public static DateFormat Create(string dateSeparator, string pattern)
return dateFormat;
}

/// <summary>
/// <summary>
/// Use ',' as separator.
/// </summary>
public static DateFormat Parse(string @string)
Expand Down
9 changes: 0 additions & 9 deletions src/TestStack.White/UIItems/IUIItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,4 @@ public interface IUIItem : ActionListener

void Enter(string value);
}

/// <summary>
/// Class which inherits this interface has a mapping to it's Automation type.
/// Used for search constraints.
/// </summary>
public interface IMappableUIItem
{

}
}
2 changes: 1 addition & 1 deletion src/TestStack.White/UIItems/WindowItems/Window.cs
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ public override VerticalSpan VerticalSpan
/// Recursively gets all the descendant windows.
/// </summary>
/// <returns></returns>
/// <exception cref="UIItemSearchException">if your framework is not supported</exception> // from ChildWindowFactory.Create
/// <exception cref="UIItemSearchException">The application type is not supported by White</exception> // from ChildWindowFactory.Create
public virtual List<Window> ModalWindows()
{
var finder = new AutomationElementFinder(automationElement);
Expand Down

0 comments on commit 885a996

Please sign in to comment.