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
.DS_Store
/VsDingExtensionProject/pingme.txt
/VsDingExtensionProject/*.csdat

View File

@ -1,6 +1,8 @@

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}"
ProjectSection(SolutionItems) = preProject
IntegrationTests.testsettings = IntegrationTests.testsettings

View File

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

View File

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

View File

@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 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
// the code is regenerated.

View File

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

View File

@ -15,9 +15,10 @@
using Microsoft.VisualStudio.ComponentModelHost;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.TestWindow.Extensibility;
using Microsoft.VisualStudio.TestWindow.Controller;
using Process = System.Diagnostics.Process;
[PackageRegistration(UseManagedResourcesOnly = true)]
[InstalledProductRegistration("#110", "#112", "1.1", IconResourceID = 400)]
[Guid(GuidList.guidVsDingExtensionProjectPkgString)]
@ -67,7 +68,7 @@
}
};
debugEvents.OnEnterBreakMode += delegate(dbgEventReason reason, ref dbgExecutionAction action)
debugEvents.OnEnterBreakMode += delegate (dbgEventReason reason, ref dbgExecutionAction action)
{
if (reason != dbgEventReason.dbgEventReasonStep && Options.IsBeepOnBreakpointHit)
{
@ -101,6 +102,11 @@
}
private void HandleEventSafe(SoundPlayer soundPlayer, string messageText)
{
HandleEventSafe(soundPlayer, messageText, ToolTipIcon.Info);
}
private void HandleEventSafe(SoundPlayer soundPlayer, string messageText, ToolTipIcon icon)
{
if (!ShouldPerformNotificationAction())
{
@ -108,25 +114,33 @@
}
PlaySoundSafe(soundPlayer);
ShowNotifyMessage(messageText);
ShowNotifyMessage(messageText, icon);
}
private void ShowNotifyMessage(string messageText)
{
ShowNotifyMessage(messageText, ToolTipIcon.Info);
}
private void ShowNotifyMessage(string messageText, ToolTipIcon icon)
{
if (!_options.ShowTrayNotifications)
{
return;
}
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);
if (Options.ShowTrayDisableMessage)
{
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);
}
System.Threading.Tasks.Task.Run(async () =>
{
var tray = new NotifyIcon
{
Icon = SystemIcons.Application,
BalloonTipIcon = ToolTipIcon.Info,
BalloonTipIcon = icon,
BalloonTipText = messageText,
BalloonTipTitle = "Visual Studio Ding extension",
Visible = true
@ -163,9 +177,20 @@
private void OperationStateOnStateChanged(object sender, OperationStateChangedEventArgs operationStateChangedEventArgs)
{
if (Options.IsBuildOnTestComplete && operationStateChangedEventArgs.State.HasFlag(TestOperationStates.TestExecutionFinished))
if (Options.IsBeepOnTestComplete && operationStateChangedEventArgs.State.HasFlag(TestOperationStates.TestExecutionFinished))
{
HandleEventSafe(testCompleteSoundPlayer, "Test execution has been completed.");
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.");
}
}
}
#endregion
@ -180,7 +205,7 @@
var procId = Process.GetCurrentProcess().Id;
int activeProcId;
GetWindowThreadProcessId(activatedHandle, out activeProcId);
return activeProcId == procId;
return activeProcId == procId;
}
public void Dispose()

View File

@ -1,7 +1,7 @@
<?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">
<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>
<Description xml:space="preserve">This small extension will play notification sounds when following events occur:
- Build Complete