diff --git a/src/VisualStudio/IntegrationTest/TestUtilities/InProcess/SolutionExplorer_InProc.cs b/src/VisualStudio/IntegrationTest/TestUtilities/InProcess/SolutionExplorer_InProc.cs index 2bee0960b4021e955c6fb2013beffa9c6e852cc4..8ea4b8df8d9896786b2885e2c7a9af1538968ccc 100644 --- a/src/VisualStudio/IntegrationTest/TestUtilities/InProcess/SolutionExplorer_InProc.cs +++ b/src/VisualStudio/IntegrationTest/TestUtilities/InProcess/SolutionExplorer_InProc.cs @@ -802,6 +802,62 @@ public void SelectItem(string itemName) solutionExplorer.Parent.Activate(); } + public void SelectItemAtPath(params string[] path) + { + var dte = (DTE2)GetDTE(); + var solutionExplorer = dte.ToolWindows.SolutionExplorer; + + var item = FindItemAtPath(solutionExplorer.UIHierarchyItems, path); + item.Select(EnvDTE.vsUISelectionType.vsUISelectionTypeSelect); + solutionExplorer.Parent.Activate(); + } + + public string[] GetChildrenOfItem(string itemName) + { + var dte = (DTE2)GetDTE(); + var solutionExplorer = dte.ToolWindows.SolutionExplorer; + + var item = FindFirstItemRecursively(solutionExplorer.UIHierarchyItems, itemName); + + return item.UIHierarchyItems + .Cast() + .Select(i => i.Name) + .ToArray(); + } + + public string[] GetChildrenOfItemAtPath(params string[] path) + { + var dte = (DTE2)GetDTE(); + var solutionExplorer = dte.ToolWindows.SolutionExplorer; + + var item = FindItemAtPath(solutionExplorer.UIHierarchyItems, path); + + return item.UIHierarchyItems + .Cast() + .Select(i => i.Name) + .ToArray(); + } + + private static EnvDTE.UIHierarchyItem FindItemAtPath( + EnvDTE.UIHierarchyItems currentItems, + string[] path) + { + EnvDTE.UIHierarchyItem item = null; + foreach (var name in path) + { + item = currentItems.Cast().FirstOrDefault(i => i.Name == name); + + if (item == null) + { + return null; + } + + currentItems = item.UIHierarchyItems; + } + + return item; + } + private static EnvDTE.UIHierarchyItem FindFirstItemRecursively( EnvDTE.UIHierarchyItems currentItems, string itemName) diff --git a/src/VisualStudio/IntegrationTest/TestUtilities/OutOfProcess/SolutionExplorer_OutOfProc.cs b/src/VisualStudio/IntegrationTest/TestUtilities/OutOfProcess/SolutionExplorer_OutOfProc.cs index 0a923d0efcafd178a62692c9bd50605d66e44080..7a4ad41a5695be63f7dbf559ae39b46b75e393d3 100644 --- a/src/VisualStudio/IntegrationTest/TestUtilities/OutOfProcess/SolutionExplorer_OutOfProc.cs +++ b/src/VisualStudio/IntegrationTest/TestUtilities/OutOfProcess/SolutionExplorer_OutOfProc.cs @@ -47,7 +47,7 @@ public void AddProject(ProjectUtils.Project projectName, string projectTemplate, public void AddProjectReference(ProjectUtils.Project fromProjectName, ProjectUtils.ProjectReference toProjectName) { - _inProc.AddProjectReference(fromProjectName.Name, toProjectName.Name); + _inProc.AddProjectReference(fromProjectName.Name, toProjectName.Name); _instance.Workspace.WaitForAsyncOperations(FeatureAttribute.Workspace); } @@ -123,9 +123,36 @@ public string[] GetProjectReferences(ProjectUtils.Project project) public string[] GetAssemblyReferences(ProjectUtils.Project project) => _inProc.GetAssemblyReferences(project.Name); + /// + /// Selects an item named by the parameter. + /// Note that this selects the first item of the given name found. In situations where + /// there may be more than one item of a given name, use + /// instead. + /// public void SelectItem(string itemName) => _inProc.SelectItem(itemName); + /// + /// Selects the specific item at the given "path". + /// + public void SelectItemAtPath(params string[] path) + => _inProc.SelectItemAtPath(path); + + /// + /// Returns the names of the immediate children of the given item. + /// Note that this uses the first item of the given name found. In situations where there + /// may be more than one item of a given name, use + /// instead. + /// + public string[] GetChildrenOfItem(string itemName) + => _inProc.GetChildrenOfItem(itemName); + + /// + /// Returns the names of the immediate children of the item at the given "path". + /// + public string[] GetChildrenOfItemAtPath(params string[] path) + => _inProc.GetChildrenOfItemAtPath(path); + public void ClearBuildOutputWindowPane() => _inProc.ClearBuildOutputWindowPane(); @@ -135,7 +162,7 @@ public void WaitForBuildToFinish() public void EditProjectFile(ProjectUtils.Project project) => _inProc.EditProjectFile(project.Name); - public void AddStandaloneFile(string fileName) + public void AddStandaloneFile(string fileName) => _inProc.AddStandaloneFile(fileName); } } \ No newline at end of file