Skip to content

Commit

Permalink
Updated copyrights and added documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
ianleeduckworth committed Feb 4, 2019
1 parent 2ffb49f commit 883d622
Show file tree
Hide file tree
Showing 30 changed files with 345 additions and 64 deletions.
2 changes: 1 addition & 1 deletion EazyE2E/Configuration/Config.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//Copyright 2018 Ian Duckworth
//Copyright 2019 Ian Duckworth

using System;
using System.Configuration;
Expand Down
10 changes: 4 additions & 6 deletions EazyE2E/EazyE2E.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,19 @@
<metadata>
<!-- Required elements-->
<id>EazyE2E</id>
<version>1.0.4</version>
<version>1.0.5</version>
<description>Easy and powerful WPF application automation</description>
<authors>Ian Duckworth</authors>
<licenseUrl>https://ianleeduckworth.github.io/eazy-e2e/license.html</licenseUrl>
<projectUrl>https://ianleeduckworth.github.io/eazy-e2e/index.html</projectUrl>
<owners>Ian Duckworth</owners>
<!-- Optional elements -->
<copyright>Copyright (c) 2018 Ian Duckworth</copyright>
<copyright>Copyright (c) 2019 Ian Duckworth</copyright>
<tags>WPF Automation UIAutomation</tags>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
<releaseNotes>
EazyE2E 1.0.4 Release Notes
1. Updated Argumets property to be a getter only. Also modified EzProcess.StartProcess to include an optional string to pass arguments when the process is started
2. Added new EzProcess constructor which creates an EzProcess instance based on a System.Diagnostics.Process
3. Added a new method to EzProcess called AttachToExistingProcess. It is static so it can be used to create an instance of EzProcess
EazyE2E 1.0.5 Release Notes
1. Updated documenation and copyrights
</releaseNotes>
</metadata>
<!-- Optional 'files' node -->
Expand Down
2 changes: 1 addition & 1 deletion EazyE2E/Element/EzElement.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//Copyright 2018 Ian Duckworth
//Copyright 2019 Ian Duckworth

using System;
using System.Collections;
Expand Down
5 changes: 4 additions & 1 deletion EazyE2E/Element/EzGrid.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
//Copyright 2018 Ian Duckworth
//Copyright 2019 Ian Duckworth

using System.Windows.Automation;
using EazyE2E.Configuration;
using EazyE2E.Helper;

namespace EazyE2E.Element
{
/// <summary>
/// Houses all functionality for grid elements. Note that the underlying element must have a ControlType of DataGrid
/// </summary>
public class EzGrid : EzElement
{
private readonly GridPattern _gridPattern;
Expand Down
7 changes: 5 additions & 2 deletions EazyE2E/Element/EzGridItem.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
//Copyright 2018 Ian Duckworth
//Copyright 2019 Ian Duckworth

using System.Windows.Automation;
using EazyE2E.Configuration;
using EazyE2E.Helper;

namespace EazyE2E.Element
{
public class EzGridItem : EzElement
/// <summary>
/// Houses all functionality for grid item elements. Note that the underlying element must have a ControlType of DataItem
/// </summary>
public class EzGridItem : EzElement
{
private readonly GridItemPattern _gridItemPattern;

Expand Down
74 changes: 65 additions & 9 deletions EazyE2E/Element/EzList.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//Copyright 2018 Ian Duckworth
//Copyright 2019 Ian Duckworth

using System.Collections.Generic;
using System.Linq;
Expand All @@ -8,7 +8,10 @@

namespace EazyE2E.Element
{
public class EzList : EzElement
/// <summary>
/// Houses all functionality for list elements. Note that the underlying element must have a ControlType of List
/// </summary>
public class EzList : EzElement
{
private readonly ScrollPattern _scrollPattern;
private readonly SelectionPattern _selectionPattern;
Expand All @@ -20,7 +23,7 @@ public class EzList : EzElement
public EzList(EzElement element) : base(element)
{
TypeChecker.CheckElementType(element.BackingAutomationElement, ControlType.List);
_scrollPattern = element.BackingAutomationElement.GetCurrentPattern(System.Windows.Automation.ScrollPattern.Pattern) as ScrollPattern;
_scrollPattern = element.BackingAutomationElement.GetCurrentPattern(ScrollPattern.Pattern) as ScrollPattern;
_selectionPattern = element.BackingAutomationElement.GetCurrentPattern(SelectionPattern.Pattern) as SelectionPattern;
}

Expand All @@ -31,7 +34,7 @@ public EzList(EzElement element) : base(element)
public EzList(EzRoot root) : base(root)
{
TypeChecker.CheckElementType(root.RootElement.BackingAutomationElement, ControlType.List);
_scrollPattern = root.RootElement.BackingAutomationElement.GetCurrentPattern(System.Windows.Automation.ScrollPattern.Pattern) as ScrollPattern;
_scrollPattern = root.RootElement.BackingAutomationElement.GetCurrentPattern(ScrollPattern.Pattern) as ScrollPattern;
_selectionPattern = root.RootElement.BackingAutomationElement.GetCurrentPattern(SelectionPattern.Pattern) as SelectionPattern;
}

Expand All @@ -42,7 +45,7 @@ public EzList(EzRoot root) : base(root)
public EzList(AutomationElement element) : base(element)
{
TypeChecker.CheckElementType(element, ControlType.List);
_scrollPattern = element.GetCurrentPattern(System.Windows.Automation.ScrollPattern.Pattern) as ScrollPattern;
_scrollPattern = element.GetCurrentPattern(ScrollPattern.Pattern) as ScrollPattern;
_selectionPattern = element.GetCurrentPattern(SelectionPattern.Pattern) as SelectionPattern;
}

Expand All @@ -55,43 +58,96 @@ public EzList(AutomationElement element) : base(element)
/// </summary>
public SelectionPattern SelectionPattern => Config.ExposeBackingWindowsPatterns ? _selectionPattern : null;

/// <summary>
/// Current amount that the element is scrolled vertically
/// </summary>
public double VerticalScrollPct => _scrollPattern.Current.VerticalScrollPercent;

/// <summary>
/// Current amount that the element is scrolled horizontally
/// </summary>
public double HorizontalScrollPct => _scrollPattern.Current.HorizontalScrollPercent;
public double VerticalViewSize => _scrollPattern.Current.VerticalViewSize;
public double HorizontalViewSize => _scrollPattern.Current.HorizontalViewSize;

/// <summary>
/// The vertical size of the viewable region as a percentage of the total content area within the UI Automation element
/// </summary>
public double VerticalViewSize => _scrollPattern.Current.VerticalViewSize;

/// <summary>
/// The horizontal size of the viewable region as a percentage of the total content area within the UI Automation element.
/// </summary>
public double HorizontalViewSize => _scrollPattern.Current.HorizontalViewSize;

/// <summary>
/// Whether or not a user can select multiple items in a list simultaneously
/// </summary>
public bool CanSelectMultiple => _selectionPattern.Current.CanSelectMultiple;

/// <summary>
/// Whether or not an item in the list must be selected
/// </summary>
public bool IsSelectionRequired => _selectionPattern.Current.IsSelectionRequired;

/// <summary>
/// All currently selected items in the list
/// </summary>
public IEnumerable<EzElement> SelectedItems => GetSelection();

/// <summary>
/// Scrolls vertically by a specified amount
/// </summary>
/// <param name="amount"></param>
public void ScrollVertical(ScrollAmount amount)
{
_scrollPattern.Scroll(ScrollAmount.NoAmount, amount);
}

/// <summary>
/// Scrolls horizontally by a specified amount
/// </summary>
/// <param name="amount"></param>
public void ScrollHorizontal(ScrollAmount amount)
{
if (_scrollPattern.Current.HorizontallyScrollable)
_scrollPattern.Scroll(amount, ScrollAmount.NoAmount);
}

/// <summary>
/// Scrolls horizontally and vertically at the same time by specified amounts
/// </summary>
/// <param name="horizontalAmount"></param>
/// <param name="verticalAmount"></param>
public void ScrollHorizontalAndVertical(ScrollAmount horizontalAmount, ScrollAmount verticalAmount)
{
if (_scrollPattern.Current.VerticallyScrollable && _scrollPattern.Current.HorizontallyScrollable)
_scrollPattern.Scroll(horizontalAmount, verticalAmount);
}

/// <summary>
/// Sets the horizontal scroll to a specific percent
/// </summary>
/// <param name="percent"></param>
public void SetHorizontalScrollPct(double percent)
{
if (_scrollPattern.Current.HorizontallyScrollable)
_scrollPattern.SetScrollPercent(percent, System.Windows.Automation.ScrollPattern.NoScroll);
_scrollPattern.SetScrollPercent(percent, ScrollPattern.NoScroll);
}

/// <summary>
/// Sets the vertical scroll to a specific percent
/// </summary>
/// <param name="percent"></param>
public void SetVerticalScrollPct(double percent)
{
if (_scrollPattern.Current.VerticallyScrollable)
_scrollPattern.SetScrollPercent(System.Windows.Automation.ScrollPattern.NoScroll, percent);
_scrollPattern.SetScrollPercent(ScrollPattern.NoScroll, percent);
}

/// <summary>
/// Sets the horizontal and vertical scrolls to specified percents simultaneiously
/// </summary>
/// <param name="horizontalPercent"></param>
/// <param name="verticalPercent"></param>
public void SetVerticalAndHorizontalScrollPct(double horizontalPercent, double verticalPercent)
{
if (_scrollPattern.Current.VerticallyScrollable && _scrollPattern.Current.HorizontallyScrollable)
Expand Down
24 changes: 20 additions & 4 deletions EazyE2E/Element/EzListItem.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
//Copyright 2018 Ian Duckworth
//Copyright 2019 Ian Duckworth

using System.Windows.Automation;
using EazyE2E.Configuration;
using EazyE2E.Helper;

namespace EazyE2E.Element
{
public class EzListItem : EzElement
/// <summary>
/// Houses all functionality for list item elements. Note that the underlying element must have a ControlType of ListItem
/// </summary>
public class EzListItem : EzElement
{
private readonly SelectionItemPattern _selectionItemPattern;
private readonly ScrollItemPattern _scrollItemPattern;
Expand All @@ -16,6 +19,10 @@ public class EzListItem : EzElement

private bool _parentCanSelectMultiple;

/// <summary>
/// Creates a new instance of EzListItem based on EzElement
/// </summary>
/// <param name="element"></param>
public EzListItem(EzElement element) : base(element)
{
TypeChecker.CheckElementType(element.BackingAutomationElement, ControlType.ListItem);
Expand All @@ -26,7 +33,12 @@ public EzListItem(EzElement element) : base(element)

SetBackingProperties();
}
public EzListItem(EzRoot root) : base(root)

/// <summary>
/// Creates a new instance of EzListItem based on EzRoot
/// </summary>
/// <param name="root"></param>
public EzListItem(EzRoot root) : base(root)
{
TypeChecker.CheckElementType(root.RootElement.BackingAutomationElement, ControlType.ListItem);
_selectionItemPattern = root.RootElement.BackingAutomationElement.GetCurrentPattern(SelectionItemPattern.Pattern) as SelectionItemPattern;
Expand All @@ -37,7 +49,11 @@ public EzListItem(EzRoot root) : base(root)
SetBackingProperties();
}

public EzListItem(AutomationElement element) : base(element)
/// <summary>
/// Creates a new instance of EzListItem based on AutomationElement from Windows' automation framework
/// </summary>
/// <param name="element"></param>
public EzListItem(AutomationElement element) : base(element)
{
TypeChecker.CheckElementType(element, ControlType.ListItem);
_selectionItemPattern = element.GetCurrentPattern(SelectionItemPattern.Pattern) as SelectionItemPattern;
Expand Down
5 changes: 4 additions & 1 deletion EazyE2E/Element/EzRootElement.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//Copyright 2018 Ian Duckworth
//Copyright 2019 Ian Duckworth

using System;
using System.Runtime.InteropServices;
Expand All @@ -7,6 +7,9 @@

namespace EazyE2E.Element
{
/// <summary>
/// Represents the root element of an application. When traversing the UI tree, this represents the highest level node
/// </summary>
public class EzRoot
{
private readonly EzProcess _process;
Expand Down
2 changes: 1 addition & 1 deletion EazyE2E/Element/EzText.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//Copyright 2018 Ian Duckworth
//Copyright 2019 Ian Duckworth

using System;
using System.Windows.Automation;
Expand Down
6 changes: 5 additions & 1 deletion EazyE2E/ElementHelper/EzTextResult.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
//Copyright 2018 Ian Duckworth
//Copyright 2019 Ian Duckworth

using System;

namespace EazyE2E.ElementHelper
{
/// <summary>
/// Houses the result of EzText.HandleResult
/// </summary>
/// <typeparam name="T"></typeparam>
public class EzTextResult<T>
{
/// <summary>
Expand Down
5 changes: 4 additions & 1 deletion EazyE2E/Enums/MemoryType.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
//Copyright 2018 Ian Duckworth
//Copyright 2019 Ian Duckworth

namespace EazyE2E.Enums
{
/// <summary>
/// Memoyr types that can be measured
/// </summary>
public enum MemoryType
{
NonpagedSystemMemorySize,
Expand Down
5 changes: 4 additions & 1 deletion EazyE2E/Enums/PropertyType.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
//Copyright 2018 Ian Duckworth
//Copyright 2019 Ian Duckworth

namespace EazyE2E.Enums
{
/// <summary>
/// Different property types that can be searched by
/// </summary>
public enum PropertyType
{
AutomationId,
Expand Down
5 changes: 4 additions & 1 deletion EazyE2E/Enums/SearchType.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
//Copyright 2018 Ian Duckworth
//Copyright 2019 Ian Duckworth

namespace EazyE2E.Enums
{
/// <summary>
/// Different ways that the UI tree can be traversed
/// </summary>
public enum SearchType
{
Children,
Expand Down
16 changes: 15 additions & 1 deletion EazyE2E/Equality/ControlTypeEqualityCompare.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
//Copyright 2018 Ian Duckworth
//Copyright 2019 Ian Duckworth

using System.Collections.Generic;
using System.Windows.Automation;

namespace EazyE2E.Equality
{
/// <summary>
/// Allows for an equality comparison to determine if control types are equal
/// </summary>
public class ControlTypeEqualityCompare : IEqualityComparer<ControlType>
{
/// <summary>
/// Determines if two instances of ControlType are equal
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
/// <returns></returns>
public bool Equals(ControlType x, ControlType y)
{
if (x == null && y == null) return true;
Expand All @@ -17,6 +26,11 @@ public bool Equals(ControlType x, ControlType y)
x.Id == y.Id;
}

/// <summary>
/// Gets a custom hash code based on ControlType passed in
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>
public int GetHashCode(ControlType obj)
{
var lc = string.IsNullOrEmpty(obj.LocalizedControlType) ? 0 : obj.LocalizedControlType.GetHashCode();
Expand Down
Loading

0 comments on commit 883d622

Please sign in to comment.