Merge pull request #6 from sboulema/master

Add option to only notify on failed tests
This commit is contained in:
thecoderok 2015-12-23 20:45:12 -08:00
commit 03bf16efd7
8 changed files with 66 additions and 16 deletions

1
.gitignore vendored
View File

@ -155,3 +155,4 @@ $RECYCLE.BIN/
# Mac desktop service store files # Mac desktop service store files
.DS_Store .DS_Store
/VsDingExtensionProject/pingme.txt /VsDingExtensionProject/pingme.txt
/VsDingExtensionProject/*.csdat

View File

@ -1,6 +1,8 @@
 
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012 # Visual Studio 14
VisualStudioVersion = 14.0.24720.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{5BD9D4DB-8683-4698-8D24-01EE7306F73A}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{5BD9D4DB-8683-4698-8D24-01EE7306F73A}"
ProjectSection(SolutionItems) = preProject ProjectSection(SolutionItems) = preProject
IntegrationTests.testsettings = IntegrationTests.testsettings IntegrationTests.testsettings = IntegrationTests.testsettings

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0"> <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup> <PropertyGroup>
<MinimumVisualStudioVersion>11.0</MinimumVisualStudioVersion> <MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">11.0</VisualStudioVersion> <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">11.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
<FileUpgradeFlags> <FileUpgradeFlags>
@ -56,6 +56,9 @@
<Reference Include="Microsoft.VisualStudio.Shell.Interop.11.0"> <Reference Include="Microsoft.VisualStudio.Shell.Interop.11.0">
<EmbedInteropTypes>true</EmbedInteropTypes> <EmbedInteropTypes>true</EmbedInteropTypes>
</Reference> </Reference>
<Reference Include="Microsoft.VisualStudio.TestWindow.Core">
<HintPath>$(DevEnvDir)\CommonExtensions\Microsoft\TestWindow\Microsoft.VisualStudio.TestWindow.Core.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.TextManager.Interop" /> <Reference Include="Microsoft.VisualStudio.TextManager.Interop" />
<Reference Include="Microsoft.VisualStudio.Shell.11.0" /> <Reference Include="Microsoft.VisualStudio.Shell.11.0" />
<Reference Include="Microsoft.VisualStudio.Shell.Immutable.10.0" /> <Reference Include="Microsoft.VisualStudio.Shell.Immutable.10.0" />

View File

@ -22,7 +22,12 @@ namespace VitaliiGanzha.VsDingExtension
[Category("Beeps")] [Category("Beeps")]
[DisplayName("Tests")] [DisplayName("Tests")]
[Description("Beep when a test run is completed")] [Description("Beep when a test run is completed")]
public bool IsBuildOnTestComplete { get; set; } public bool IsBeepOnTestComplete { get; set; }
[Category("Beeps")]
[DisplayName("Failed Tests")]
[Description("Beep only when a test failed")]
public bool IsBeepOnTestFailed { get; set; }
[DisplayName("Only when in background")] [DisplayName("Only when in background")]
[Description("Beep only when Visual Studio does not have focus")] [Description("Beep only when Visual Studio does not have focus")]
@ -32,13 +37,19 @@ namespace VitaliiGanzha.VsDingExtension
[Description("Show tray notifications for enabled events")] [Description("Show tray notifications for enabled events")]
public bool ShowTrayNotifications { get; set; } public bool ShowTrayNotifications { get; set; }
[DisplayName("Tray notifications message")]
[Description("Show message how to disable tray notifications")]
public bool ShowTrayDisableMessage { get; set; }
public OptionsDialog() public OptionsDialog()
{ {
IsBeepOnBreakpointHit = true; IsBeepOnBreakpointHit = true;
IsBeepOnBuildComplete = true; IsBeepOnBuildComplete = true;
IsBuildOnTestComplete = true; IsBeepOnTestComplete = true;
IsBeepOnTestFailed = false;
ShowTrayNotifications = true; ShowTrayNotifications = true;
IsBeepOnlyWhenVisualStudioIsInBackground = false; IsBeepOnlyWhenVisualStudioIsInBackground = false;
ShowTrayDisableMessage = true;
} }
} }
} }

View File

@ -1,7 +1,7 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// This code was generated by a tool. // This code was generated by a tool.
// Runtime Version:4.0.30319.18449 // Runtime Version:4.0.30319.42000
// //
// Changes to this file may cause incorrect behavior and will be lost if // Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated. // the code is regenerated.

View File

@ -1,10 +1,15 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="12.0"> <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="12.0">
<PropertyGroup> <PropertyGroup>
<MinimumVisualStudioVersion>12.0</MinimumVisualStudioVersion> <MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">12.0</VisualStudioVersion> <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">12.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
<TargetFrameworkProfile /> <TargetFrameworkProfile />
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>12.0</OldToolsVersion>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<ApplicationIcon>speaker.ico</ApplicationIcon> <ApplicationIcon>speaker.ico</ApplicationIcon>
@ -58,6 +63,9 @@
<Reference Include="Microsoft.VisualStudio.Shell.Interop.12.0"> <Reference Include="Microsoft.VisualStudio.Shell.Interop.12.0">
<EmbedInteropTypes>true</EmbedInteropTypes> <EmbedInteropTypes>true</EmbedInteropTypes>
</Reference> </Reference>
<Reference Include="Microsoft.VisualStudio.TestWindow.Core">
<HintPath>$(DevEnvDir)\CommonExtensions\Microsoft\TestWindow\Microsoft.VisualStudio.TestWindow.Core.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestWindow.Interfaces"> <Reference Include="Microsoft.VisualStudio.TestWindow.Interfaces">
<HintPath>$(DevEnvDir)\CommonExtensions\Microsoft\TestWindow\Microsoft.VisualStudio.TestWindow.Interfaces.dll</HintPath> <HintPath>$(DevEnvDir)\CommonExtensions\Microsoft\TestWindow\Microsoft.VisualStudio.TestWindow.Interfaces.dll</HintPath>
</Reference> </Reference>

View File

@ -15,6 +15,7 @@
using Microsoft.VisualStudio.ComponentModelHost; using Microsoft.VisualStudio.ComponentModelHost;
using Microsoft.VisualStudio.Shell; using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.TestWindow.Extensibility; using Microsoft.VisualStudio.TestWindow.Extensibility;
using Microsoft.VisualStudio.TestWindow.Controller;
using Process = System.Diagnostics.Process; using Process = System.Diagnostics.Process;
@ -101,6 +102,11 @@
} }
private void HandleEventSafe(SoundPlayer soundPlayer, string messageText) private void HandleEventSafe(SoundPlayer soundPlayer, string messageText)
{
HandleEventSafe(soundPlayer, messageText, ToolTipIcon.Info);
}
private void HandleEventSafe(SoundPlayer soundPlayer, string messageText, ToolTipIcon icon)
{ {
if (!ShouldPerformNotificationAction()) if (!ShouldPerformNotificationAction())
{ {
@ -108,25 +114,33 @@
} }
PlaySoundSafe(soundPlayer); PlaySoundSafe(soundPlayer);
ShowNotifyMessage(messageText); ShowNotifyMessage(messageText, icon);
} }
private void ShowNotifyMessage(string messageText) private void ShowNotifyMessage(string messageText)
{
ShowNotifyMessage(messageText, ToolTipIcon.Info);
}
private void ShowNotifyMessage(string messageText, ToolTipIcon icon)
{ {
if (!_options.ShowTrayNotifications) if (!_options.ShowTrayNotifications)
{ {
return; return;
} }
if (Options.ShowTrayDisableMessage)
{
string autoAppendMessage = System.Environment.NewLine + "You can disable this notification in:" + System.Environment.NewLine + "Tools->Options->Ding->Show tray notifications"; string autoAppendMessage = System.Environment.NewLine + "You can disable this notification in:" + System.Environment.NewLine + "Tools->Options->Ding->Show tray notifications";
messageText = string.Format("{0}{1}", messageText, autoAppendMessage); messageText = string.Format("{0}{1}", messageText, autoAppendMessage);
}
System.Threading.Tasks.Task.Run(async () => System.Threading.Tasks.Task.Run(async () =>
{ {
var tray = new NotifyIcon var tray = new NotifyIcon
{ {
Icon = SystemIcons.Application, Icon = SystemIcons.Application,
BalloonTipIcon = ToolTipIcon.Info, BalloonTipIcon = icon,
BalloonTipText = messageText, BalloonTipText = messageText,
BalloonTipTitle = "Visual Studio Ding extension", BalloonTipTitle = "Visual Studio Ding extension",
Visible = true Visible = true
@ -163,11 +177,22 @@
private void OperationStateOnStateChanged(object sender, OperationStateChangedEventArgs operationStateChangedEventArgs) private void OperationStateOnStateChanged(object sender, OperationStateChangedEventArgs operationStateChangedEventArgs)
{ {
if (Options.IsBuildOnTestComplete && operationStateChangedEventArgs.State.HasFlag(TestOperationStates.TestExecutionFinished)) if (Options.IsBeepOnTestComplete && operationStateChangedEventArgs.State.HasFlag(TestOperationStates.TestExecutionFinished))
{
if (Options.IsBeepOnTestFailed)
{
var testOperation = ((TestRunRequest)operationStateChangedEventArgs.Operation);
if (testOperation.DominantTestState == TestState.Failed)
{
HandleEventSafe(testCompleteSoundPlayer, "Test execution failed!", ToolTipIcon.Error);
}
}
else
{ {
HandleEventSafe(testCompleteSoundPlayer, "Test execution has been completed."); HandleEventSafe(testCompleteSoundPlayer, "Test execution has been completed.");
} }
} }
}
#endregion #endregion
private bool ApplicationIsActivated() private bool ApplicationIsActivated()

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011"> <PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
<Metadata> <Metadata>
<Identity Id="26ba08d0-0d25-4479-8684-3054dd122876" Version="1.5" Language="en-US" Publisher="Vitalii Ganzha" /> <Identity Id="26ba08d0-0d25-4479-8684-3054dd122876" Version="1.6" Language="en-US" Publisher="Vitalii Ganzha" />
<DisplayName>Visual Studio Ding extension</DisplayName> <DisplayName>Visual Studio Ding extension</DisplayName>
<Description xml:space="preserve">This small extension will play notification sounds when following events occur: <Description xml:space="preserve">This small extension will play notification sounds when following events occur:
- Build Complete - Build Complete