Skip to content

Commit

Permalink
Added IUIItem.GetParent<T>() extension method
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan.danilov-econ authored and ivan.danilov-econ committed Aug 5, 2013
1 parent 78356df commit 15da64d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/TestStack.White/TestStack.White.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@
<Compile Include="UIA\AutomationPatterns.cs" />
<Compile Include="UIA\WindowsPointX.cs" />
<Compile Include="UIA\RectX.cs" />
<Compile Include="UIItems\UIItemExtensions.cs" />
<Compile Include="UIItems\Custom\CustomUIItemType.cs" />
<Compile Include="UIItems\Finders\AutomationElementProperty.cs" />
<Compile Include="UIItems\Finders\ControlTypeProperty.cs" />
Expand Down
18 changes: 18 additions & 0 deletions src/TestStack.White/UIItems/UIItemExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System.Windows.Automation;
using TestStack.White.Factory;

namespace TestStack.White.UIItems
{
public static class UIItemExtensions
{
// DictionaryMappedItemFactory does not have any state and could be shared
private static readonly UIItemFactory ItemFactory = new DictionaryMappedItemFactory();

public static T GetParent<T>(this IUIItem thisItem) where T : IUIItem
{
var parent = TreeWalker.ControlViewWalker.GetParent(thisItem.AutomationElement);
var uiItem = ItemFactory.Create(parent, thisItem.ActionListener);
return (T) UIItemProxyFactory.Create(uiItem, uiItem.ActionListener);
}
}
}

0 comments on commit 15da64d

Please sign in to comment.