diff --git a/src/DynamoCore/DynamoCore.csproj b/src/DynamoCore/DynamoCore.csproj index e3a020c22b6..91aed2cbfe1 100644 --- a/src/DynamoCore/DynamoCore.csproj +++ b/src/DynamoCore/DynamoCore.csproj @@ -32,9 +32,9 @@ - - - + + + diff --git a/src/DynamoCore/Logging/DynamoAnalyticsClient.cs b/src/DynamoCore/Logging/DynamoAnalyticsClient.cs index 98138164e73..29c2a498ec2 100644 --- a/src/DynamoCore/Logging/DynamoAnalyticsClient.cs +++ b/src/DynamoCore/Logging/DynamoAnalyticsClient.cs @@ -193,7 +193,7 @@ public void TrackEvent(Actions action, Categories category, string description, { serviceInitialized.Wait(); - lock(trackEventLockObj) + lock (trackEventLockObj) { if (!ReportingAnalytics) return; @@ -403,7 +403,7 @@ public void EndEventTask(Task taskToEnd) Task.Run(() => { - lock(trackEventLockObj) + lock (trackEventLockObj) { taskToEnd.Wait(); taskToEnd.Result.Dispose(); @@ -417,7 +417,7 @@ public IDisposable TrackFileOperationEvent(string filepath, Actions operation, i serviceInitialized.Wait(); if (!ReportingAnalytics) return Disposable; - lock(trackEventLockObj) + lock (trackEventLockObj) { var e = new FileOperationEvent() { @@ -469,7 +469,13 @@ public void Dispose() // If the Analytics Client was initialized, shut it down. // Otherwise skip this step because it would cause an exception. if (Service.IsInitialized) - Service.ShutDown(); + { + // Lock shutdown sequence in case other tracking calls might be executing concurently. + lock (trackEventLockObj) + { + Service.ShutDown(); + } + } if (Session != null) { diff --git a/src/DynamoCoreWpf/DynamoCoreWpf.csproj b/src/DynamoCoreWpf/DynamoCoreWpf.csproj index 7d80fe710f0..5836dc0cac1 100644 --- a/src/DynamoCoreWpf/DynamoCoreWpf.csproj +++ b/src/DynamoCoreWpf/DynamoCoreWpf.csproj @@ -189,7 +189,7 @@ - + diff --git a/src/DynamoManipulation/DynamoManipulation.csproj b/src/DynamoManipulation/DynamoManipulation.csproj index e8f3d407f85..e86ca814ccd 100644 --- a/src/DynamoManipulation/DynamoManipulation.csproj +++ b/src/DynamoManipulation/DynamoManipulation.csproj @@ -40,7 +40,7 @@ - + diff --git a/src/Libraries/Analysis/Analysis.csproj b/src/Libraries/Analysis/Analysis.csproj index a9189785549..983d6c156d3 100644 --- a/src/Libraries/Analysis/Analysis.csproj +++ b/src/Libraries/Analysis/Analysis.csproj @@ -18,7 +18,7 @@ - + {7858fa8c-475f-4b8e-b468-1f8200778cf8} DynamoCore diff --git a/src/Libraries/CoreNodes/CoreNodes.csproj b/src/Libraries/CoreNodes/CoreNodes.csproj index 223751e0342..b869dba6632 100644 --- a/src/Libraries/CoreNodes/CoreNodes.csproj +++ b/src/Libraries/CoreNodes/CoreNodes.csproj @@ -19,7 +19,7 @@ - + diff --git a/src/Libraries/DSOfficeUtilities/Excel.cs b/src/Libraries/DSOfficeUtilities/Excel.cs index 154cee680a0..e290f67eba1 100644 --- a/src/Libraries/DSOfficeUtilities/Excel.cs +++ b/src/Libraries/DSOfficeUtilities/Excel.cs @@ -105,7 +105,7 @@ public static bool ExcelProcessRunning { get { - return Process.GetProcessesByName("EXCEL").Length != 0; + return GetExcelProcess(_app) != null; } } @@ -123,21 +123,39 @@ public static bool HasValidExcelReference /// private static void TryQuitAndCleanup(bool saveWorkbooks) { - if (HasValidExcelReference) + try { - if (ExcelProcessRunning) + if (HasValidExcelReference) { - App.Workbooks.Cast().ToList().ForEach((wb) => wb.Close(saveWorkbooks)); - App.Quit(); - } + if (ExcelProcessRunning) + { + App.Workbooks.Cast().ToList().ForEach((wb) => wb.Close(saveWorkbooks)); + App.Quit(); + } - while (Marshal.ReleaseComObject(_app) > 0) - { + while (Marshal.ReleaseComObject(_app) > 0) + { - } + } - _app = null; + GetExcelProcess(App).Kill(); + } + } + catch (Exception e) + { + Console.WriteLine(e.ToString()); } + _app = null; + } + + [DllImport("user32.dll")] + static extern int GetWindowThreadProcessId(int hWnd, out int lpdwProcessId); + + internal static Process GetExcelProcess(Application excelApp) + { + int id; + GetWindowThreadProcessId(excelApp.Hwnd, out id); + return Process.GetProcessById(id); } internal static void OnProcessExit(object sender, EventArgs eventArgs) diff --git a/src/Libraries/GeometryColor/GeometryColor.csproj b/src/Libraries/GeometryColor/GeometryColor.csproj index 4061e095be1..53856db2e6e 100644 --- a/src/Libraries/GeometryColor/GeometryColor.csproj +++ b/src/Libraries/GeometryColor/GeometryColor.csproj @@ -14,7 +14,7 @@ MSB3539;CS1591;NUnit2005;NUnit2007;CS0618;CS0612;CS0672 - + diff --git a/src/Libraries/GeometryUI/GeometryUI.csproj b/src/Libraries/GeometryUI/GeometryUI.csproj index 438e98e3518..4fecec31f69 100644 --- a/src/Libraries/GeometryUI/GeometryUI.csproj +++ b/src/Libraries/GeometryUI/GeometryUI.csproj @@ -17,7 +17,7 @@ - + diff --git a/src/Libraries/GeometryUIWpf/GeometryUIWpf.csproj b/src/Libraries/GeometryUIWpf/GeometryUIWpf.csproj index 6f59bff65f7..4421309dddc 100644 --- a/src/Libraries/GeometryUIWpf/GeometryUIWpf.csproj +++ b/src/Libraries/GeometryUIWpf/GeometryUIWpf.csproj @@ -21,7 +21,7 @@ - + diff --git a/src/Libraries/Tesellation/Tessellation.csproj b/src/Libraries/Tesellation/Tessellation.csproj index 351559b3d5b..eb747a835e3 100644 --- a/src/Libraries/Tesellation/Tessellation.csproj +++ b/src/Libraries/Tesellation/Tessellation.csproj @@ -14,7 +14,7 @@ MSB3539;CS1591;NUnit2005;NUnit2007;CS0618;CS0612;CS0672 - + diff --git a/src/Tools/NodeDocumentationMarkdownGenerator/NodeDocumentationMarkdownGenerator.csproj b/src/Tools/NodeDocumentationMarkdownGenerator/NodeDocumentationMarkdownGenerator.csproj index eb807071d97..50c9e1a1fdc 100644 --- a/src/Tools/NodeDocumentationMarkdownGenerator/NodeDocumentationMarkdownGenerator.csproj +++ b/src/Tools/NodeDocumentationMarkdownGenerator/NodeDocumentationMarkdownGenerator.csproj @@ -13,8 +13,7 @@ - - + diff --git a/test/DynamoCoreTests/DynamoCoreTests.csproj b/test/DynamoCoreTests/DynamoCoreTests.csproj index 1e6124bce11..678a9b0f7c0 100644 --- a/test/DynamoCoreTests/DynamoCoreTests.csproj +++ b/test/DynamoCoreTests/DynamoCoreTests.csproj @@ -49,7 +49,6 @@ all compile; build; native; contentfiles; analyzers; buildtransitive - @@ -139,18 +138,10 @@ - - - - - - - - - - - - - - + + + + + + diff --git a/test/DynamoCoreTests/Logging/AnalyticsServiceTest.cs b/test/DynamoCoreTests/Logging/AnalyticsServiceTest.cs index 3d77c350e6e..1bed49dcc97 100644 --- a/test/DynamoCoreTests/Logging/AnalyticsServiceTest.cs +++ b/test/DynamoCoreTests/Logging/AnalyticsServiceTest.cs @@ -2,13 +2,10 @@ using System.Collections.Generic; using System.Diagnostics; using System.IO; -using System.Linq; using System.Reflection; using System.Runtime.InteropServices; using System.Threading; -using Microsoft.Diagnostics.Runtime; using NUnit.Framework; -using System.Runtime.Versioning; namespace Dynamo.Tests.Loggings { @@ -41,43 +38,32 @@ public void DisableAnalytics() { DynamoShapeManager.Utilities.GetInstalledAsmVersion2(versions, ref locatedPath, coreDirectory); } + try { - Assert.DoesNotThrow(() => - { + dynamoCLI = Process.Start(new ProcessStartInfo(Path.Combine(coreDirectory, "DynamoCLI.exe"), $"--GeometryPath \"{locatedPath}\" -k --DisableAnalytics -o \"{openPath}\" ") { UseShellExecute = true }); - dynamoCLI = Process.Start(new ProcessStartInfo(Path.Combine(coreDirectory, "DynamoCLI.exe"), $"--GeometryPath \"{locatedPath}\" -k --DisableAnalytics -o \"{openPath}\" ") { UseShellExecute = true }); - - Thread.Sleep(5000);// Wait 5 seconds to open the dyn - Assert.IsFalse(dynamoCLI.HasExited); - var dt = DataTarget.AttachToProcess(dynamoCLI.Id, false); - var assemblies = dt - .ClrVersions - .Select(dtClrVersion => dtClrVersion.CreateRuntime()) - .SelectMany(runtime => runtime.AppDomains.SelectMany(runtimeAppDomain => runtimeAppDomain.Modules)) - .Select(clrModule => clrModule.AssemblyName) - .Distinct() - .Where(x => x != null) - .ToList(); + Thread.Sleep(5000);// Wait 5 seconds to open the dyn + Assert.IsFalse(dynamoCLI.HasExited); - var firstASMmodulePath = string.Empty; - foreach (string module in assemblies) + var firstASMmodulePath = string.Empty; + foreach (ProcessModule module in dynamoCLI.Modules) + { + if (module.ModuleName.IndexOf("Analytics.dll", StringComparison.OrdinalIgnoreCase) != -1) { - if (module.IndexOf("Analytics", StringComparison.OrdinalIgnoreCase) != -1) - { - Assert.Fail("Analytics module was loaded"); - } - if (module.IndexOf("AdpSDKCSharpWrapper", StringComparison.OrdinalIgnoreCase) != -1) - { - Assert.Fail("ADP module was loaded"); - } + Assert.Fail("Analytics module was loaded"); } - }); + if (module.ModuleName.IndexOf("AdpSDKCSharpWrapper.dll", StringComparison.OrdinalIgnoreCase) != -1) + { + Assert.Fail("ADP module was loaded"); + } + module.Dispose(); + } } finally { - dynamoCLI?.Kill(); + dynamoCLI?.Dispose(); } } @@ -116,35 +102,28 @@ public void DisableAnalyticsViaNoNetWorkMode() dynamoCLI = Process.Start(new ProcessStartInfo(Path.Combine(coreDirectory, "DynamoCLI.exe"), $"--GeometryPath \"{locatedPath}\" -k --NoNetworkMode -o \"{openPath}\" ") { UseShellExecute = true }); Thread.Sleep(5000);// Wait 5 seconds to open the dyn + Assert.IsFalse(dynamoCLI.HasExited); - var dt = DataTarget.AttachToProcess(dynamoCLI.Id, false); - var assemblies = dt - .ClrVersions - .Select(dtClrVersion => dtClrVersion.CreateRuntime()) - .SelectMany(runtime => runtime.AppDomains.SelectMany(runtimeAppDomain => runtimeAppDomain.Modules)) - .Select(clrModule => clrModule.AssemblyName) - .Distinct() - .Where(x => x != null) - .ToList(); var firstASMmodulePath = string.Empty; - foreach (string module in assemblies) + foreach (ProcessModule module in dynamoCLI.Modules) { - if (module.IndexOf("Analytics", StringComparison.OrdinalIgnoreCase) != -1) + if (module.ModuleName.IndexOf("Analytics.dll", StringComparison.OrdinalIgnoreCase) != -1) { Assert.Fail("Analytics module was loaded"); } - if (module.IndexOf("AdpSDKCSharpWrapper", StringComparison.OrdinalIgnoreCase) != -1) + if (module.ModuleName.IndexOf("AdpSDKCSharpWrapper.dll", StringComparison.OrdinalIgnoreCase) != -1) { Assert.Fail("ADP module was loaded"); } + module.Dispose(); } }); } finally { - dynamoCLI?.Kill(); + dynamoCLI?.Dispose(); } } } diff --git a/test/DynamoCoreWpfTests/PreviewBubbleTests.cs b/test/DynamoCoreWpfTests/PreviewBubbleTests.cs index f6412e1a4f6..2ca88df7760 100644 --- a/test/DynamoCoreWpfTests/PreviewBubbleTests.cs +++ b/test/DynamoCoreWpfTests/PreviewBubbleTests.cs @@ -49,7 +49,7 @@ public void PreviewBubbleVisible_MouseMoveOverNode() var nodeView = NodeViewWithGuid("7828a9dd-88e6-49f4-9ed3-72e355f89bcc"); nodeView.PreviewControl.RaiseEvent(new RoutedEventArgs(FrameworkElement.LoadedEvent)); - RaiseMouseEnterOnNode(nodeView); + RaiseMouseEnterOnNode(nodeView, () => nodeView.PreviewControl.IsCondensed); Assert.IsTrue(nodeView.PreviewControl.IsCondensed); } @@ -61,7 +61,7 @@ public void PreviewBubbleVisible_MouseMoveOverNode_InCustomWorkspace() var nodeView = NodeViewWithGuid("9ce91e89-c087-49cd-9fd9-540cca086475"); nodeView.PreviewControl.RaiseEvent(new RoutedEventArgs(FrameworkElement.LoadedEvent)); - RaiseMouseEnterOnNode(nodeView); + RaiseMouseEnterOnNode(nodeView, () => nodeView.PreviewControl.IsHidden); Assert.IsTrue(nodeView.PreviewControl.IsHidden); } @@ -73,11 +73,11 @@ public void PreviewBubbleVisible_MouseMoveOutOfNode() var nodeView = NodeViewWithGuid("7828a9dd-88e6-49f4-9ed3-72e355f89bcc"); nodeView.PreviewControl.RaiseEvent(new RoutedEventArgs(FrameworkElement.LoadedEvent)); - RaiseMouseEnterOnNode(nodeView); + RaiseMouseEnterOnNode(nodeView, () => nodeView.PreviewControl.IsCondensed); Assert.IsTrue(nodeView.PreviewControl.IsCondensed); - RaiseMouseLeaveNode(nodeView); + RaiseMouseLeaveNode(nodeView, () => nodeView.PreviewControl.IsHidden); Assert.IsTrue(nodeView.PreviewControl.IsHidden); } @@ -90,7 +90,7 @@ public void PreviewBubbleHidden_OnFrozenNode() nodeView.ViewModel.IsFrozen = true; nodeView.PreviewControl.RaiseEvent(new RoutedEventArgs(FrameworkElement.LoadedEvent)); - RaiseMouseEnterOnNode(nodeView); + RaiseMouseEnterOnNode(nodeView, () => nodeView.PreviewControl.IsHidden); Assert.IsTrue(nodeView.PreviewControl.IsHidden); } @@ -264,7 +264,7 @@ public void Watch_PreviewAllowanceDisabled() var nodeView = NodeViewWithGuid("456e57f3-d06f-4a53-9771-27188ee9cb40"); - RaiseMouseEnterOnNode(nodeView); + RaiseMouseEnterOnNode(nodeView, () => nodeView.PreviewControl.IsHidden); Assert.IsTrue(nodeView.PreviewControl.IsHidden); } @@ -512,17 +512,17 @@ public void PreviewBubble_ToggleShowPreviewBubbles() nodeView.PreviewControl.RaiseEvent(new RoutedEventArgs(FrameworkElement.LoadedEvent)); - RaiseMouseEnterOnNode(nodeView); + RaiseMouseEnterOnNode(nodeView, () => nodeView.PreviewControl.IsCondensed); Assert.IsTrue(nodeView.PreviewControl.IsCondensed, "Compact preview bubble is not shown"); - RaiseMouseLeaveNode(nodeView); + RaiseMouseLeaveNode(nodeView, () => nodeView.PreviewControl.IsHidden); Assert.IsTrue(nodeView.PreviewControl.IsHidden, "Preview bubble is not hidden"); // turn off preview bubbles ViewModel.PreferencesViewModel.ShowPreviewBubbles = false; Assert.IsFalse(ViewModel.PreferencesViewModel.ShowPreviewBubbles, "Preview bubbles have not been turned off"); - RaiseMouseEnterOnNode(nodeView); + RaiseMouseEnterOnNode(nodeView, () => nodeView.PreviewControl.IsHidden); Assert.IsTrue(nodeView.PreviewControl.IsHidden, "Preview bubble is not hidden"); } @@ -554,6 +554,8 @@ public void PreviewBubble_UnpinAllPreviewBubble() RaiseMouseEnterOnNode(previewBubble.bubbleTools); RaiseLeftMouseClick(previewBubble.pinIconBorder); + DispatcherUtil.DoEventsLoop(() => previewBubble.IsExpanded && previewBubble.StaysOpen); + // Assert the bubble is expanded and pinned Assert.IsTrue(previewBubble.IsExpanded, "Expanded preview bubble should be shown"); Assert.IsTrue(previewBubble.StaysOpen, "Expanded preview bubble should be pinned"); @@ -604,16 +606,16 @@ public void PreviewBubble_ShowExpandedPreview_MultiReturnNode() previewBubble.bubbleTools.RaiseEvent(new RoutedEventArgs(FrameworkElement.LoadedEvent)); // open preview bubble - RaiseMouseEnterOnNode(nodeView); + RaiseMouseEnterOnNode(nodeView, () => previewBubble.IsCondensed); Assert.IsTrue(previewBubble.IsCondensed, "Compact preview bubble should be shown"); Assert.AreEqual(Visibility.Collapsed, previewBubble.bubbleTools.Visibility, "Pin icon should not be shown"); // hover preview bubble to see pin icon - RaiseMouseEnterOnNode(previewBubble); + RaiseMouseEnterOnNode(previewBubble, () => previewBubble.bubbleTools.Visibility == Visibility.Visible); Assert.AreEqual(Visibility.Visible, previewBubble.bubbleTools.Visibility, "Pin icon should be shown"); // expand preview bubble - RaiseMouseEnterOnNode(previewBubble.bubbleTools); + RaiseMouseEnterOnNode(previewBubble.bubbleTools, () => previewBubble.IsExpanded); Assert.IsTrue(previewBubble.IsExpanded, "Expanded preview bubble should be shown"); } @@ -627,7 +629,7 @@ public void PreviewBubble_ShownForColorRange() nodeView.PreviewControl.RaiseEvent(new RoutedEventArgs(FrameworkElement.LoadedEvent)); // open preview bubble - RaiseMouseEnterOnNode(nodeView); + RaiseMouseEnterOnNode(nodeView, () => !nodeView.PreviewControl.IsHidden); Assert.IsFalse(nodeView.PreviewControl.IsHidden, "Preview bubble for color range should be shown"); } @@ -956,24 +958,24 @@ private bool ElementIsInContainerWithEpsilonCompare(FrameworkElement element, Fr return epsilonEqual(relativePosition.X, 0) && (element.ActualWidth <= container.ActualWidth); } - private void RaiseMouseEnterOnNode(IInputElement nv) + private void RaiseMouseEnterOnNode(IInputElement nv, Func check = null) { View.Dispatcher.Invoke(() => { nv.RaiseEvent(new MouseEventArgs(Mouse.PrimaryDevice, 0) { RoutedEvent = Mouse.MouseEnterEvent }); }); - DispatcherUtil.DoEvents(); + DispatcherUtil.DoEventsLoop(check); } - private void RaiseMouseLeaveNode(IInputElement nv) + private void RaiseMouseLeaveNode(IInputElement nv, Func check = null) { View.Dispatcher.Invoke(() => { nv.RaiseEvent(new MouseEventArgs(Mouse.PrimaryDevice, 0) { RoutedEvent = Mouse.MouseLeaveEvent }); }); - DispatcherUtil.DoEvents(); + DispatcherUtil.DoEventsLoop(check); } private void RaiseLeftMouseClick(IInputElement nv) diff --git a/test/DynamoCoreWpfTests/SplashScreenTests.cs b/test/DynamoCoreWpfTests/SplashScreenTests.cs index 5d4ac8602c9..088e2ec64c2 100644 --- a/test/DynamoCoreWpfTests/SplashScreenTests.cs +++ b/test/DynamoCoreWpfTests/SplashScreenTests.cs @@ -85,6 +85,7 @@ public void SplashScreen_CloseExplicitPropIsCorrect3() ss.CloseWindow(); Assert.IsTrue(ss.CloseWasExplicit); } + [Test] //note that this test sends a windows close message directly to the window //but skips the JS interop that users rely on to close the window - so that is not tested by this test. @@ -113,7 +114,6 @@ void WebView_NavigationCompleted(object sender, Microsoft.Web.WebView2.Core.Core }); Task.Delay(1000).Wait(); - } ss.webView.NavigationCompleted += WebView_NavigationCompleted; @@ -131,7 +131,6 @@ void WindowClosed(object sender, EventArgs e) ss.Closed -= WindowClosed; - Assert.IsNull(ss.webView);// Make sure webview2 was disposed Assert.IsTrue(windowClosed);// Make sure the window was closed } } diff --git a/test/DynamoCoreWpfTests/ViewExtensions/NotificationsExtensionTests.cs b/test/DynamoCoreWpfTests/ViewExtensions/NotificationsExtensionTests.cs index 54915f00909..b270607e082 100644 --- a/test/DynamoCoreWpfTests/ViewExtensions/NotificationsExtensionTests.cs +++ b/test/DynamoCoreWpfTests/ViewExtensions/NotificationsExtensionTests.cs @@ -22,21 +22,25 @@ public void PressNotificationButtonAndShowPopup() notificationsButton.RaiseEvent(new RoutedEventArgs(ButtonBase.ClickEvent)); var notificationExtension = this.View.viewExtensionManager.ViewExtensions.OfType().FirstOrDefault(); + NotificationUI notificationUI = null; + // Wait for the NotificationCenterController webview2 control to finish initialization DispatcherUtil.DoEventsLoop(() => { - return notificationExtension.notificationCenterController.initState == DynamoUtilities.AsyncMethodState.Done; - }); - - Assert.AreEqual(DynamoUtilities.AsyncMethodState.Done, notificationExtension.notificationCenterController.initState); - - NotificationUI notificationUI = PresentationSource.CurrentSources.OfType() - .Select(h => h.RootVisual) - .OfType() - .Select(f => f.Parent) - .OfType() - .FirstOrDefault(p => p.IsOpen); + if (notificationExtension.notificationCenterController.initState == DynamoUtilities.AsyncMethodState.Done) + { + notificationUI = PresentationSource.CurrentSources.OfType() + .Select(h => h.RootVisual) + .OfType() + .Select(f => f.Parent) + .OfType() + .FirstOrDefault(p => p.IsOpen); + return notificationUI != null; + } + return false; + }, 180); + Assert.NotNull(notificationUI, "Notification popup not part of the dynamo visual tree"); var webView = notificationUI.FindName("webView"); Assert.NotNull(webView, "WebView framework element not found."); diff --git a/test/Libraries/AnalysisTests/AnalysisTests.csproj b/test/Libraries/AnalysisTests/AnalysisTests.csproj index 711ad1ddb83..03149c60dfc 100644 --- a/test/Libraries/AnalysisTests/AnalysisTests.csproj +++ b/test/Libraries/AnalysisTests/AnalysisTests.csproj @@ -10,7 +10,7 @@ AnalysisTests - + diff --git a/test/Libraries/DynamoPythonTests/DynamoPythonTests.csproj b/test/Libraries/DynamoPythonTests/DynamoPythonTests.csproj index 9e61a9b0c11..1024fb371e0 100644 --- a/test/Libraries/DynamoPythonTests/DynamoPythonTests.csproj +++ b/test/Libraries/DynamoPythonTests/DynamoPythonTests.csproj @@ -18,7 +18,7 @@ - + diff --git a/test/Libraries/GeometryColorTests/GeometryColorTests.csproj b/test/Libraries/GeometryColorTests/GeometryColorTests.csproj index 9f728a91f64..dc46cabd505 100644 --- a/test/Libraries/GeometryColorTests/GeometryColorTests.csproj +++ b/test/Libraries/GeometryColorTests/GeometryColorTests.csproj @@ -10,7 +10,7 @@ DisplayTests - + diff --git a/test/Libraries/SystemTestServices/DispatcherUtil.cs b/test/Libraries/SystemTestServices/DispatcherUtil.cs index f5b6f22c3e7..2469b55ac05 100644 --- a/test/Libraries/SystemTestServices/DispatcherUtil.cs +++ b/test/Libraries/SystemTestServices/DispatcherUtil.cs @@ -1,5 +1,6 @@ using System; using System.Threading; +using System.Threading.Tasks; using System.Windows.Threading; namespace DynamoCoreWpfTests.Utility @@ -24,25 +25,31 @@ public static void DoEvents() /// the check function returns true. /// /// When check returns true, the even loop is stopped. - public static void DoEventsLoop(Func check = null, int timeoutSeconds = 20) + public static void DoEventsLoop(Func check = null, int timeoutSeconds = 60) { - int max_count = timeoutSeconds * 10; + var cts = new CancellationTokenSource(); + var token = cts.Token; + + Task.Delay(timeoutSeconds * 1000).ContinueWith(t => + { + cts.Cancel(); + cts.Dispose(); + }); - int count = 0; while (true) { - if (check != null && check()) + if (token.IsCancellationRequested) { return; } - if (count >= max_count) + + if (check != null && check()) { return; } - DispatcherUtil.DoEvents(); + DoEvents(); Thread.Sleep(100); - count++; } } diff --git a/test/Libraries/TestServices/TestServices.csproj b/test/Libraries/TestServices/TestServices.csproj index e6ff1a1f18c..cf82de7b34b 100644 --- a/test/Libraries/TestServices/TestServices.csproj +++ b/test/Libraries/TestServices/TestServices.csproj @@ -10,7 +10,7 @@ TestServices - + diff --git a/test/Libraries/WorkflowTests/DynamoSamples.cs b/test/Libraries/WorkflowTests/DynamoSamples.cs index f1d7b7aa679..deb16ec9f8e 100644 --- a/test/Libraries/WorkflowTests/DynamoSamples.cs +++ b/test/Libraries/WorkflowTests/DynamoSamples.cs @@ -5,6 +5,8 @@ using Autodesk.DesignScript.Geometry; using CoreNodeModels.Input; using Dynamo.Graph.Nodes; +using Dynamo.Graph.Workspaces; +using Dynamo.Models; using NUnit.Framework; namespace Dynamo.Tests @@ -520,7 +522,9 @@ public void ImportExport_CSV_to_Stuff() [Test, Category("ExcelTest"), Category("ExcelTestInterop")] public void ImportExport_Data_To_Excel() { - OpenSampleModel(@"en-US\ImportExport\ImportExport_Data To Excel.dyn"); + CurrentDynamoModel.ExecuteCommand(new DynamoModel.OpenFileCommand( + Path.Combine(SampleDirectory, @"en-US\ImportExport\ImportExport_Data To Excel.dyn"), + true)); var filename = CurrentDynamoModel.CurrentWorkspace.FirstNodeFromWorkspace(); @@ -536,28 +540,34 @@ public void ImportExport_Data_To_Excel() AssertPreviewCount(lineNodeID, 65); // Killing excel process if there is any after running the graph. - Process[] procs = Process.GetProcessesByName("excel"); - foreach (Process proc in procs) - proc.Kill(); - + foreach (var process in Process.GetProcessesByName("EXCEL")) + { + if (process.MainWindowTitle.Equals("icosohedron_points - Excel")) + { + process.Kill(); + break; + } + } } [Test, Category("ExcelTestInterop"), Category("Failure")] - //Todo Ritesh: Locally passing but failing on CI. - //After fixing issue with this test case add Smoke Test Category. + //Todo Ritesh: Locally passing but failing on CI. + //After fixing issue with this test case add Smoke Test Category. public void ImportExport_Excel_to_Dynamo() { - OpenSampleModel(@"en-US\ImportExport\ImportExport_Excel to Dynamo.dyn"); + CurrentDynamoModel.ExecuteCommand(new DynamoModel.OpenFileCommand( + Path.Combine(SampleDirectory, @"en-US\ImportExport\ImportExport_Excel to Dynamo.dyn"), + true)); var filename = CurrentDynamoModel.CurrentWorkspace.FirstNodeFromWorkspace(); - string resultPath = SampleDirectory + "Data\\helix.xlsx"; + string inputFile = Path.Combine(SampleDirectory, "Data\\helix.xlsx"); //we cannot count on this path never changing as the samples path //must be updated to match dynamo version number - filename.Value = resultPath; + filename.Value = inputFile; - //RunCurrentModel(); + RunCurrentModel(); const string lineNodeID = "d538c147-b79f-4f11-9c00-1efd7f9b3c09"; AssertPreviewCount(lineNodeID, 201); @@ -570,9 +580,14 @@ public void ImportExport_Excel_to_Dynamo() } // Killing excel process if there is any after running the graph. - Process[] procs = Process.GetProcessesByName("excel"); - foreach (Process proc in procs) - proc.Kill(); + foreach (var process in Process.GetProcessesByName("EXCEL")) + { + if (process.MainWindowTitle.Equals("helix - Excel")) + { + process.Kill(); + break; + } + } } } } diff --git a/test/Libraries/WorkflowTests/WorkflowTests.csproj b/test/Libraries/WorkflowTests/WorkflowTests.csproj index f613593c6b4..1d95b8f1a8b 100644 --- a/test/Libraries/WorkflowTests/WorkflowTests.csproj +++ b/test/Libraries/WorkflowTests/WorkflowTests.csproj @@ -14,7 +14,7 @@ - +