예제 #1
0
        /// <summary>
        /// Deletes the UI object with the specified path from UIMap.
        /// </summary>
        /// <param name="uiMapFile">The UI map file.</param>
        /// <param name="path">The path.</param>
        public void DeleteUIObject(string path)
        {
            // find element
            UIObject element = this.FindUIObject(path);

            if (element == null)
            {
                return;
            }

            // find references in actions and delete them (backwards, since we're deleting elements in collection)
            for (int i = this.UITest.ExecuteActions.Actions.Count - 1; i >= 0; i--)
            {
                UITestAction action = this.UITest.ExecuteActions.Actions[i];

                if ((action.UIObjectName != null) && (action.UIObjectName.StartsWith(path)))
                {
                    this.UITest.ExecuteActions.Delete(action.Id);
                    this.IsModified = true;
                }
            }

            if (element is TopLevelElement)
            {
                // assuming only one UIMap in a file...
                this.UITest.Maps[0].TopLevelWindows.Remove(element as TopLevelElement);
            }
            else
            {
                // source element parent
                string   srcParentPath = path.Substring(0, path.LastIndexOf('.'));
                UIObject srcParent     = this.FindUIObject(srcParentPath);
                if (srcParent == null)
                {
                    throw new NullReferenceException(String.Format("Could not find source parent UIObject with path '{0}'", srcParentPath));
                }

                // delete object itself
                srcParent.Descendants.Remove(element);
            }

            this.IsModified = true;
        }
예제 #2
0
 public override string GetPropertyForAction(UITestControl uiTestControl, UITestAction action)
 {
     throw new NotSupportedException();
 }