-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* VS2019 added to supported version range Resolves #36 * Improved sanity checks to simplify debugging migration to async package #36 * Improved sanity checks to simplify debugging migration to async package #36 * Improved sanity checks to simplify debugging migration to async package #36 * Improved sanity checks to simplify debugging migration to async package #36 * Improved sanity checks to simplify debugging migration to async package #36 * Cleanup * Improved sanity checks to simplify debugging migration to async package #36 * Improved sanity checks to simplify debugging migration to async package #36 * Improved sanity checks to simplify debugging migration to async package #36 * Begun backward incompatible(!) upgrade of VS references to support VS 2015+ async package load #36 * Working XPath in statusbar #36 * Moved all suitable extension initialization logic out of the VS package class #36 * Cleanup * Search now working with async package #36 * Cleanup * Reworked command visibility Commands are now hidden until package is loaded or visibility constraints are satisfied. #36 * Failing attempts at using VisibilityConstraints to control command visibility #36 * Fixed autoload behavior of package and commands #36 * Removed unused visibility constraints #36 * Statusbar related code moved to separate namespace for clarity * Changed code to allow for "early" configuration initialization required by the StatusbarAdapter, while allowing IConfiguration to be initialized "late" by async package load #36 * Fixed constructor usage * Cleanup * Test marked as ignored for now * Cleanup * Configuration related code moved to separate namespace for clarity * XPathSetting moved to Configuration * Begun implementing configuration end-to-end tests * Further work in progress * Improved Tools and Options menu interaction * Fixed options menu item text * Working automation model * Running/failing tests * Working tests, failing due to VS quotation mark completion when inserting/"typing" XML * Working tests * Begun refactoring XML file creation to use temporary files Working "against" VIsual Studio editor functionality is too cumbersome and prone to error when taking additional extensions into account. * Begun implementing "Open File" interactions * Working "Open File" interaction logic * Begun enablling tests * Solved directory name selection issue * Cleanup * Automation model for statusbar added * Tests successful * Reduced redundant setup steps * Cleanup * Reduced duplicate test setup * Cleanup * Reduced duplicate setup steps * Fixed slow context menu entry lookup * Version number and release notes updated #36 * Supported VS version range updated to exclude VS 2013 and earlier
- Loading branch information
1 parent
3998ac0
commit 0b22b99
Showing
44 changed files
with
622 additions
and
357 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
ReasonCodeExample.XPathTools.Tests/Configuration/ConfigurationTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using System.Windows.Forms; | ||
using NUnit.Framework; | ||
using ReasonCodeExample.XPathTools.Tests.Statusbar; | ||
using ReasonCodeExample.XPathTools.Tests.VisualStudioIntegration; | ||
using ReasonCodeExample.XPathTools.VisualStudioIntegration; | ||
|
||
namespace ReasonCodeExample.XPathTools.Tests.Configuration | ||
{ | ||
[TestFixture] | ||
[Category(TestCategory.Integration)] | ||
public class ConfigurationTests | ||
{ | ||
private readonly VisualStudioExperimentalInstance _visualStudio = new VisualStudioExperimentalInstance(); | ||
|
||
[OneTimeSetUp] | ||
public void StartVisualStudio() | ||
{ | ||
_visualStudio.ReStart(); | ||
var xml = "<a><b id='hello'><c/></b><b id='world'><c/></b></a>"; | ||
var xmlElementIndex = 41; | ||
_visualStudio.OpenXmlFile(xml, xmlElementIndex); | ||
} | ||
|
||
[OneTimeTearDown] | ||
public void StopVisualStudio() | ||
{ | ||
_visualStudio.Stop(); | ||
} | ||
|
||
[TestCase(XPathFormat.Generic, "/a/b/c")] | ||
[TestCase(XPathFormat.Absolute, "/a[1]/b[2]/c[1]")] | ||
[TestCase(XPathFormat.Distinct, "/a/b[@id='world']/c")] | ||
public void StatusbarXPathFormatChangesWhenConfigurationIsChanged(XPathFormat xpathFormat, string expectedXPath) | ||
{ | ||
// Arrange | ||
var configuration = new XPathToolsDialogPageAutomationModel(_visualStudio); | ||
|
||
// Act | ||
configuration.SetStatusbarXPathFormat(xpathFormat); | ||
SendKeys.SendWait("{LEFT}{RIGHT}"); // Move the caret to trigger a statusbar update | ||
|
||
// Assert | ||
var statusbar = new StatusbarAutomationModel(_visualStudio.MainWindow); | ||
Assert.That(statusbar.GetText(), Is.EqualTo(expectedXPath)); | ||
} | ||
} | ||
} |
95 changes: 95 additions & 0 deletions
95
ReasonCodeExample.XPathTools.Tests/Configuration/XPathToolsDialogPageAutomationModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
using ReasonCodeExample.XPathTools.Tests.VisualStudioIntegration; | ||
using ReasonCodeExample.XPathTools.VisualStudioIntegration; | ||
using System.Windows.Automation; | ||
using System.Windows.Forms; | ||
|
||
namespace ReasonCodeExample.XPathTools.Tests.Configuration | ||
{ | ||
internal class XPathToolsDialogPageAutomationModel | ||
{ | ||
private readonly VisualStudioExperimentalInstance _visualStudio; | ||
private readonly AutomationElement _mainWindow; | ||
|
||
public XPathToolsDialogPageAutomationModel(VisualStudioExperimentalInstance visualStudio) | ||
{ | ||
_visualStudio = visualStudio; | ||
_mainWindow = visualStudio.MainWindow; | ||
} | ||
|
||
private bool IsOpen | ||
{ | ||
get | ||
{ | ||
return OptionsDialog != null; | ||
} | ||
} | ||
|
||
private AutomationElement OptionsDialog | ||
{ | ||
get | ||
{ | ||
return _mainWindow.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.NameProperty, "Options", PropertyConditionFlags.IgnoreCase)); | ||
} | ||
} | ||
|
||
private void Open() | ||
{ | ||
var toolsMenu = OpenToolsMenu(); | ||
|
||
var optionsDialog = OpenOptionsDialog(toolsMenu); | ||
|
||
SetXPathToolsSettingsFocus(optionsDialog); | ||
} | ||
|
||
private AutomationElement OpenToolsMenu() | ||
{ | ||
var toolsMenu = _visualStudio.FindMenuItem("Tools"); | ||
toolsMenu.LeftClick(); | ||
return toolsMenu; | ||
} | ||
|
||
private AutomationElement OpenOptionsDialog(AutomationElement toolsMenu) | ||
{ | ||
var optionsMenuEntry = _visualStudio.FindMenuItem("Options...", toolsMenu); | ||
optionsMenuEntry.LeftClick(); | ||
|
||
var optionsDialog = _mainWindow.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.NameProperty, "Options")); | ||
return optionsDialog; | ||
} | ||
|
||
private void SetXPathToolsSettingsFocus(AutomationElement optionsDialog) | ||
{ | ||
var xpathToolsSettings = optionsDialog.FindDescendantByText("XPath Tools"); | ||
xpathToolsSettings.SetFocus(); | ||
xpathToolsSettings.LeftClick(); | ||
var propertiesWindow = optionsDialog.FindDescendant(new PropertyCondition(AutomationElement.NameProperty, "Properties Window", PropertyConditionFlags.IgnoreCase)); | ||
propertiesWindow.LeftClick(); | ||
} | ||
|
||
private void Close() | ||
{ | ||
if (IsOpen) | ||
{ | ||
OptionsDialog.FindDescendantByText("OK").LeftClick(); | ||
} | ||
} | ||
|
||
public void SetStatusbarXPathFormat(XPathFormat format) | ||
{ | ||
// Ensure options dialog is closed before starting interaction sequence | ||
Close(); | ||
|
||
// Open the XPath options dialog page | ||
Open(); | ||
|
||
// Move to the last setting - this assumes that the XPath Tools settings page has focus and has 6 settings | ||
SendKeys.SendWait("{DOWN 6}"); | ||
|
||
// Select the desired format - requires all formats to start with a different letter! | ||
var firstLetter = format.ToString()[0].ToString(); | ||
SendKeys.SendWait(firstLetter); | ||
|
||
Close(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
ReasonCodeExample.XPathTools.Tests/Statusbar/StatusbarAdapterTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using NUnit.Framework; | ||
using ReasonCodeExample.XPathTools.Tests.VisualStudioIntegration; | ||
|
||
namespace ReasonCodeExample.XPathTools.Tests.Statusbar | ||
{ | ||
[TestFixture] | ||
[Category(TestCategory.Integration)] | ||
public class StatusbarAdapterTests | ||
{ | ||
private readonly VisualStudioExperimentalInstance _visualStudio = new VisualStudioExperimentalInstance(); | ||
|
||
[OneTimeSetUp] | ||
public void StartVisualStudio() | ||
{ | ||
_visualStudio.ReStart(); | ||
} | ||
|
||
[OneTimeTearDown] | ||
public void StopVisualStudio() | ||
{ | ||
_visualStudio.Stop(); | ||
} | ||
|
||
[Test] | ||
public void StatusbarShowsXPath() | ||
{ | ||
// Arrange | ||
var xml = "<e1><e2><e3 /></e2></e1>"; | ||
var caretPosition = 11; | ||
var expectedXPath = "/e1/e2/e3"; | ||
_visualStudio.OpenXmlFile(xml, caretPosition); | ||
|
||
// Act | ||
var statusbar = new StatusbarAutomationModel(_visualStudio.MainWindow); | ||
|
||
// Assert | ||
Assert.That(statusbar.GetText(), Is.EqualTo(expectedXPath)); | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
ReasonCodeExample.XPathTools.Tests/Statusbar/StatusbarAutomationModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System.Windows.Automation; | ||
using ReasonCodeExample.XPathTools.Tests.VisualStudioIntegration; | ||
|
||
namespace ReasonCodeExample.XPathTools.Tests.Statusbar | ||
{ | ||
internal class StatusbarAutomationModel | ||
{ | ||
private readonly AutomationElement _mainWindow; | ||
|
||
public StatusbarAutomationModel(AutomationElement mainWindow) | ||
{ | ||
_mainWindow = mainWindow; | ||
} | ||
|
||
public string GetText() | ||
{ | ||
var liveTextBlock = _mainWindow.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.ClassNameProperty, "LiveTextBlock")); | ||
return liveTextBlock.GetText(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace ReasonCodeExample.XPathTools.Tests | ||
{ | ||
internal static class TestCategory | ||
{ | ||
public const string Integration = "Integration"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.