From 83e9eecc4e322170854e0d06b23892df7d281031 Mon Sep 17 00:00:00 2001 From: Jake Ginnivan Date: Mon, 29 Jul 2013 19:20:34 +0100 Subject: [PATCH] Additional error check --- src/TestStack.White/UIItems/MenuItems/Menus.cs | 3 ++- src/TestStack.White/UIItems/MenuItems/PopUpMenu.cs | 8 +++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/TestStack.White/UIItems/MenuItems/Menus.cs b/src/TestStack.White/UIItems/MenuItems/Menus.cs index 9ea3650d..946d8596 100644 --- a/src/TestStack.White/UIItems/MenuItems/Menus.cs +++ b/src/TestStack.White/UIItems/MenuItems/Menus.cs @@ -12,10 +12,11 @@ namespace TestStack.White.UIItems.MenuItems { public class Menus : UIItemList { - private static readonly DictionaryMappedItemFactory Factory = new DictionaryMappedItemFactory(); + static readonly DictionaryMappedItemFactory Factory = new DictionaryMappedItemFactory(); public Menus(AutomationElement parent, ActionListener actionListener) { + if (parent == null) throw new ArgumentNullException("parent", "You must specify a parent automation id when creating a menu"); AutomationSearchCondition condition = AutomationSearchCondition.ByControlType(ControlType.MenuItem); var finder = new AutomationElementFinder(parent); finder = PerformanceHackAsPopupMenuForWin32AppComesOnDesktop(finder, parent); diff --git a/src/TestStack.White/UIItems/MenuItems/PopUpMenu.cs b/src/TestStack.White/UIItems/MenuItems/PopUpMenu.cs index dec8a059..d51eeea0 100644 --- a/src/TestStack.White/UIItems/MenuItems/PopUpMenu.cs +++ b/src/TestStack.White/UIItems/MenuItems/PopUpMenu.cs @@ -6,28 +6,26 @@ namespace TestStack.White.UIItems.MenuItems { public class PopUpMenu : UIItem { - private readonly Menus topLevelMenus; protected PopUpMenu() {} public PopUpMenu(AutomationElement automationElement, ActionListener actionListener) : base(automationElement, actionListener) { this.actionListener = actionListener; - topLevelMenus = new Menus(automationElement, actionListener); } public virtual Menus Items { - get { return topLevelMenus; } + get { return new Menus(automationElement, actionListener); } } public virtual Menu Item(params string[] text) { - return topLevelMenus.Find(text); + return Items.Find(text); } public virtual Menu ItemBy(params SearchCriteria[] path) { - return topLevelMenus.Find(path); + return Items.Find(path); } } } \ No newline at end of file