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/DynamoCoreWpf/Interfaces/IWatchHandler.cs b/src/DynamoCoreWpf/Interfaces/IWatchHandler.cs index 1f0d0daa730..8c0b6af20dc 100644 --- a/src/DynamoCoreWpf/Interfaces/IWatchHandler.cs +++ b/src/DynamoCoreWpf/Interfaces/IWatchHandler.cs @@ -1,15 +1,18 @@ -using System; + +using System; using System.Collections; using System.Collections.Generic; using System.Globalization; using System.Linq; -using Dynamo.Configuration; +using Newtonsoft.Json.Linq; + using Dynamo.Extensions; using Dynamo.ViewModels; using Dynamo.Wpf.Properties; using ProtoCore.DSASM; using ProtoCore.Mirror; using ProtoCore.Utils; +using Newtonsoft.Json; namespace Dynamo.Interfaces { @@ -83,7 +86,18 @@ private WatchViewModel ProcessThing(object value, ProtoCore.RuntimeCore runtimeC return node; } + if (value is JObject obj) + { + var dict = ConvertJObjectToDictionary(obj); + var node = new WatchViewModel(dict.Keys.Any() ? WatchViewModel.DICTIONARY : WatchViewModel.EMPTY_DICTIONARY, tag, RequestSelectGeometry, true); + + foreach (var e in dict.Keys.Zip(dict.Values, (key, val) => new { key, val })) + { + node.Children.Add(ProcessThing(e.val, runtimeCore, tag + ":" + e.key, showRawData, callback)); + } + return node; + } if (!(value is string) && value is IEnumerable) { var list = (value as IEnumerable).Cast().ToList(); @@ -122,6 +136,23 @@ private WatchViewModel ProcessThing(object value, ProtoCore.RuntimeCore runtimeC return new WatchViewModel(value, tag, RequestSelectGeometry); } + private static Dictionary ConvertJObjectToDictionary(JObject jObject) + { + var settings = new JsonSerializerSettings + { + // Add any specific settings you need here + NullValueHandling = NullValueHandling.Ignore, + MissingMemberHandling = MissingMemberHandling.Ignore, + TypeNameHandling = TypeNameHandling.None + }; + + var json = jObject.ToString(); + var dictionary = JsonConvert.DeserializeObject>(json, settings); + + return dictionary; + } + + private WatchViewModel ProcessThing(double value, ProtoCore.RuntimeCore runtimeCore, string tag, bool showRawData, WatchHandlerCallback callback) { return new WatchViewModel(value, tag, RequestSelectGeometry); diff --git a/src/DynamoCoreWpf/Properties/Resources.Designer.cs b/src/DynamoCoreWpf/Properties/Resources.Designer.cs index db297060f6e..2aea4a65d07 100644 --- a/src/DynamoCoreWpf/Properties/Resources.Designer.cs +++ b/src/DynamoCoreWpf/Properties/Resources.Designer.cs @@ -7383,6 +7383,15 @@ public static string PackageUnknownCompatibilityFilterTooltip { } } + /// + /// Looks up a localized string similar to The compatibility of this version with your setup has not been verified. It may or may not work as expected. . + /// + public static string PackageUnknownCompatibilityVersionDownloadMsg { + get { + return ResourceManager.GetString("PackageUnknownCompatibilityVersionDownloadMsg", resourceCulture); + } + } + /// /// Looks up a localized string similar to None. /// diff --git a/src/DynamoCoreWpf/Properties/Resources.en-US.resx b/src/DynamoCoreWpf/Properties/Resources.en-US.resx index c56fb15cb74..2335adba2ba 100644 --- a/src/DynamoCoreWpf/Properties/Resources.en-US.resx +++ b/src/DynamoCoreWpf/Properties/Resources.en-US.resx @@ -1332,7 +1332,7 @@ You can always redownload the package. No node could be found with that Id. - + No group could be found with that Id. @@ -4057,15 +4057,12 @@ To make this file into a new template, save it to a different folder, then move Compatible with your current setup - + Incompatible with your current setup Unknown compatibility with your current setup - - Size - This version should be compatible with your current setup @@ -4105,4 +4102,7 @@ To make this file into a new template, save it to a different folder, then move Versions marked with .x include all versions in the specified major or minor release - + + The compatibility of this version with your setup has not been verified. It may or may not work as expected. + + \ No newline at end of file diff --git a/src/DynamoCoreWpf/Properties/Resources.resx b/src/DynamoCoreWpf/Properties/Resources.resx index b3745002746..41f89c7c712 100644 --- a/src/DynamoCoreWpf/Properties/Resources.resx +++ b/src/DynamoCoreWpf/Properties/Resources.resx @@ -1924,7 +1924,7 @@ Do you want to install the latest Dynamo update? No node could be found with that Id. - + No group could be found with that Id. @@ -4044,15 +4044,12 @@ To make this file into a new template, save it to a different folder, then move Compatible with your current setup - + Incompatible with your current setup Unknown compatibility with your current setup - - Size - This version should be compatible with your current setup @@ -4092,4 +4089,7 @@ To make this file into a new template, save it to a different folder, then move Versions marked with .x include all versions in the specified major or minor release - + + The compatibility of this version with your setup has not been verified. It may or may not work as expected. + + \ No newline at end of file diff --git a/src/DynamoCoreWpf/PublicAPI.Unshipped.txt b/src/DynamoCoreWpf/PublicAPI.Unshipped.txt index 8105ae556f7..cd08503d771 100644 --- a/src/DynamoCoreWpf/PublicAPI.Unshipped.txt +++ b/src/DynamoCoreWpf/PublicAPI.Unshipped.txt @@ -5224,6 +5224,7 @@ static Dynamo.Wpf.Properties.Resources.PackageUploadStateError.get -> string static Dynamo.Wpf.Properties.Resources.PackageUploadStateReady.get -> string static Dynamo.Wpf.Properties.Resources.PackageUploadStateUploaded.get -> string static Dynamo.Wpf.Properties.Resources.PackageUploadStateUploading.get -> string +static Dynamo.Wpf.Properties.Resources.PackageUnknownCompatibilityVersionDownloadMsg.get -> string static Dynamo.Wpf.Properties.Resources.PackageUseNewerDynamoMessageBoxTitle.get -> string static Dynamo.Wpf.Properties.Resources.PackageUseOlderDynamoMessageBoxTitle.get -> string static Dynamo.Wpf.Properties.Resources.PackageViewContextMenuLoadText.get -> string diff --git a/src/DynamoCoreWpf/ViewModels/PackageManager/PackageManagerClientViewModel.cs b/src/DynamoCoreWpf/ViewModels/PackageManager/PackageManagerClientViewModel.cs index 72ca5560f80..14fa58bd383 100644 --- a/src/DynamoCoreWpf/ViewModels/PackageManager/PackageManagerClientViewModel.cs +++ b/src/DynamoCoreWpf/ViewModels/PackageManager/PackageManagerClientViewModel.cs @@ -751,10 +751,31 @@ internal async void ExecutePackageDownload(string name, PackageVersion package, string msg; MessageBoxResult result; - var compatible = PackageManagerSearchElement.CalculateCompatibility(package.compatibility_matrix); - if (compatible == false && !DynamoModel.IsTestMode) + // initialize default download consent message + msg = String.IsNullOrEmpty(installPath) ? + String.Format(Resources.MessageConfirmToInstallPackage, name, package.version) : + String.Format(Resources.MessageConfirmToInstallPackageToFolder, name, package.version, installPath); + + // Calculate compatibility and display a single download consent across cases + var compatible = PackageManagerSearchElement.CalculateCompatibility(package.compatibility_matrix); + + // Unknown package compatibility with current Dynamo env, this is expected to be the most popular case for now + if (compatible == null && !DynamoModel.IsTestMode) { - msg = Resources.PackageManagerIncompatibleVersionDownloadMsg; + msg = msg + "\n\n" + Resources.PackageUnknownCompatibilityVersionDownloadMsg; + result = MessageBoxService.Show(ViewModelOwner, msg, + Resources.PackageDownloadConfirmMessageBoxTitle, + MessageBoxButton.OKCancel, MessageBoxImage.Question); + + if (result != MessageBoxResult.OK) + { + return; + } + } + // Package incompatible with current Dynamo env + else if (compatible == false && !DynamoModel.IsTestMode) + { + msg = msg + "\n\n" + Resources.PackageManagerIncompatibleVersionDownloadMsg; result = MessageBoxService.Show(ViewModelOwner, msg, Resources.PackageManagerIncompatibleVersionDownloadTitle, MessageBoxButton.OKCancel, MessageBoxImage.Warning); @@ -764,14 +785,13 @@ internal async void ExecutePackageDownload(string name, PackageVersion package, return; } } - - msg = String.IsNullOrEmpty(installPath) ? - String.Format(Resources.MessageConfirmToInstallPackage, name, package.version) : - String.Format(Resources.MessageConfirmToInstallPackageToFolder, name, package.version, installPath); - - result = MessageBoxService.Show(ViewModelOwner, msg, - Resources.PackageDownloadConfirmMessageBoxTitle, - MessageBoxButton.OKCancel, MessageBoxImage.Question); + // Package compatible with current Dynamo env + else + { + result = MessageBoxService.Show(ViewModelOwner, msg, + Resources.PackageDownloadConfirmMessageBoxTitle, + MessageBoxButton.OKCancel, MessageBoxImage.Question); + } var pmExt = DynamoViewModel.Model.GetPackageManagerExtension(); if (result == MessageBoxResult.OK) @@ -898,8 +918,8 @@ internal async void ExecutePackageDownload(string name, PackageVersion package, var containsPackagesThatTargetOtherHosts = PackageManagerExtension.CheckIfPackagesTargetOtherHosts(newPackageHeaders); - // if any do, notify user and allow cancellation - if (containsPackagesThatTargetOtherHosts) + // if unknown compatibility, and package target other hosts, notify user and allow cancellation + if (compatible == null && containsPackagesThatTargetOtherHosts) { var res = MessageBoxService.Show(ViewModelOwner, Resources.MessagePackageTargetOtherHosts, @@ -957,11 +977,11 @@ internal async void ExecutePackageDownload(string name, PackageVersion package, } } } - catch(ArgumentException ex) + catch (ArgumentException ex) { DynamoConsoleLogger.OnLogMessageToDynamoConsole($"exception while trying to compare version info between package and dynamo {ex}"); } - catch(FormatException ex) + catch (FormatException ex) { DynamoConsoleLogger.OnLogMessageToDynamoConsole($"exception while trying to compare version info between package and dynamo {ex}"); } diff --git a/src/DynamoCoreWpf/ViewModels/Preview/WatchViewModel.cs b/src/DynamoCoreWpf/ViewModels/Preview/WatchViewModel.cs index 733859f8db7..1e0106e9f2d 100644 --- a/src/DynamoCoreWpf/ViewModels/Preview/WatchViewModel.cs +++ b/src/DynamoCoreWpf/ViewModels/Preview/WatchViewModel.cs @@ -273,6 +273,12 @@ private static string GetStringFromObject(object obj) return ((DateTime)obj).ToString(PreferenceSettings.DefaultDateFormat, CultureInfo.InvariantCulture); case TypeCode.Object: return ObjectToLabelString(obj); + case TypeCode.Byte: + return ((byte)obj).ToString(CultureInfo.InvariantCulture); + case TypeCode.UInt32: + return ((uint)obj).ToString(CultureInfo.InvariantCulture); + case TypeCode.UInt64: + return ((ulong)obj).ToString(CultureInfo.InvariantCulture); default: return (string)obj; }; @@ -313,6 +319,12 @@ private string GetDisplayType(object obj) return nameof(TypeCode.Object); case TypeCode.String: return nameof(TypeCode.String); + case TypeCode.Byte: + return nameof(TypeCode.Byte); + case TypeCode.UInt32: + return nameof(TypeCode.UInt32); + case TypeCode.UInt64: + return nameof(TypeCode.UInt64); case TypeCode.Empty: return String.Empty; default: diff --git a/src/DynamoCoreWpf/Views/Core/DynamoView.xaml.cs b/src/DynamoCoreWpf/Views/Core/DynamoView.xaml.cs index 02b9eb2d533..bd0f4c8f381 100644 --- a/src/DynamoCoreWpf/Views/Core/DynamoView.xaml.cs +++ b/src/DynamoCoreWpf/Views/Core/DynamoView.xaml.cs @@ -2378,6 +2378,8 @@ private void HandlePackageManagerWindowClosed(object sender, EventArgs e) var cmd = Analytics.TrackCommandEvent("PackageManager"); cmd.Dispose(); + + this.Activate(); } /// diff --git a/src/DynamoCoreWpf/Views/Core/NoteView.xaml.cs b/src/DynamoCoreWpf/Views/Core/NoteView.xaml.cs index ba7fb5523c9..69ab8994412 100644 --- a/src/DynamoCoreWpf/Views/Core/NoteView.xaml.cs +++ b/src/DynamoCoreWpf/Views/Core/NoteView.xaml.cs @@ -23,7 +23,7 @@ public partial class NoteView : IViewModelView /// /// Special keys definition in note /// - internal Key[] specialKeys = { Key.OemMinus, Key.Tab, Key.Enter }; + internal Key[] specialKeys = { Key.OemMinus, Key.Subtract, Key.Tab, Key.Enter }; public NoteViewModel ViewModel { get; private set; } @@ -210,7 +210,7 @@ private void noteTextBox_LostFocus(object sender, RoutedEventArgs e) private void noteTextBox_PreviewKeyDown(object sender, KeyEventArgs e) { - if (!specialKeys.Contains(e.Key)) + if (!specialKeys.Contains(e.Key) || Keyboard.Modifiers == System.Windows.Input.ModifierKeys.Shift) { return; } @@ -232,6 +232,9 @@ private void noteTextBox_PreviewKeyDown(object sender, KeyEventArgs e) case Key.OemMinus: textBox.Text = BulletDashHandler(text, caretIndex); break; + case Key.Subtract: + textBox.Text = BulletDashHandler(text, caretIndex); + break; case Key.Tab: textBox.Text = BulletTabHandler(text, caretIndex); break; diff --git a/src/DynamoCoreWpf/Views/Preview/WatchTree.xaml.cs b/src/DynamoCoreWpf/Views/Preview/WatchTree.xaml.cs index 3b7ebe12b60..24d2bda1b4b 100644 --- a/src/DynamoCoreWpf/Views/Preview/WatchTree.xaml.cs +++ b/src/DynamoCoreWpf/Views/Preview/WatchTree.xaml.cs @@ -22,7 +22,7 @@ public partial class WatchTree : UserControl private readonly double widthPerCharacter = 7.5; private static readonly int defaultHeightSize = 200; private readonly int minWidthSize = 100; - private readonly int minHeightSize = 38; + private readonly int minHeightSize = 40; private readonly int minHeightForList = 83; public WatchTree(WatchViewModel vm) 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/CoreNodeModelsWpf/NodeViewCustomizations/Watch.cs b/src/Libraries/CoreNodeModelsWpf/NodeViewCustomizations/Watch.cs index e227b1ac4e8..32404cec368 100644 --- a/src/Libraries/CoreNodeModelsWpf/NodeViewCustomizations/Watch.cs +++ b/src/Libraries/CoreNodeModelsWpf/NodeViewCustomizations/Watch.cs @@ -63,8 +63,8 @@ public void CustomizeView(Watch nodeModel, NodeView nodeView) ResetWatch(); - watchTree.Width = nodeModel.WatchWidth == 0 ? watchTree.Width : nodeModel.WatchWidth; - watchTree.Height = nodeModel.WatchHeight == 0 ? watchTree.Height : nodeModel.WatchHeight; + watchTree.Width = nodeModel.WatchWidth < watchTree.Width ? watchTree.Width : nodeModel.WatchWidth; + watchTree.Height = nodeModel.WatchHeight < watchTree.Height ? watchTree.Height : nodeModel.WatchHeight; //Store width and height info of the node in the dictionary. Watch.NodeSizes[watch.GUID] = new Tuple(nodeModel.WatchWidth, nodeModel.WatchHeight); 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 43c61a4af5a..7c28cb5a5c2 100644 --- a/test/DynamoCoreWpfTests/SplashScreenTests.cs +++ b/test/DynamoCoreWpfTests/SplashScreenTests.cs @@ -68,7 +68,6 @@ void WebView_NavigationCompleted(object sender, Microsoft.Web.WebView2.Core.Core }); Task.Delay(1000).Wait(); - } ss.webView.NavigationCompleted += WebView_NavigationCompleted; @@ -86,7 +85,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/DynamoCoreWpfTests/WatchNodeTests.cs b/test/DynamoCoreWpfTests/WatchNodeTests.cs index 374d0048442..b279c7465ab 100644 --- a/test/DynamoCoreWpfTests/WatchNodeTests.cs +++ b/test/DynamoCoreWpfTests/WatchNodeTests.cs @@ -23,6 +23,7 @@ protected override void GetLibrariesToPreload(List libraries) libraries.Add("VMDataBridge.dll"); libraries.Add("ProtoGeometry.dll"); libraries.Add("DesignScriptBuiltin.dll"); + libraries.Add("DSCoreNodes.dll"); libraries.Add("FunctionObject.ds"); libraries.Add("FFITarget.dll"); base.GetLibrariesToPreload(libraries); @@ -363,6 +364,83 @@ public void WatchMultiReturnNodeOrder() Assert.AreEqual("1", children[3].NodeLabel); } + [Test] + public void WatchDictionaryByteValuesDisplaysCorrectly() + { + string openPath = Path.Combine(TestDirectory, @"core\watch\WatchDictionaryByteValuesDisplaysCorrectly.dyn"); + ViewModel.OpenCommand.Execute(openPath); + ViewModel.HomeSpace.Run(); + + var watchNode = ViewModel.Model.CurrentWorkspace.FirstNodeFromWorkspace(); + var watchVM = ViewModel.WatchHandler.GenerateWatchViewModelForData( + watchNode.CachedValue, watchNode.OutPorts.Select(p => p.Name), + ViewModel.Model.EngineController.LiveRunnerRuntimeCore, + watchNode.AstIdentifierForPreview.Name, true); + + var list = watchVM.Children; + Assert.AreEqual(1, list.Count); + var children = list[0].Children; + Assert.AreEqual(12, children.Count); + Assert.AreEqual("Byte", children[0].ValueType); + Assert.AreEqual("72", children[0].NodeLabel); + } + + [Test] + public void WatchDictionaryUintValuesDisplaysCorrectly() + { + string openPath = Path.Combine(TestDirectory, @"core\watch\WatchDictionaryUintValuesDisplaysCorrectly.dyn"); + ViewModel.OpenCommand.Execute(openPath); + ViewModel.HomeSpace.Run(); + + var watchNode = ViewModel.Model.CurrentWorkspace.FirstNodeFromWorkspace(); + var watchVM = ViewModel.WatchHandler.GenerateWatchViewModelForData( + watchNode.CachedValue, watchNode.OutPorts.Select(p => p.Name), + ViewModel.Model.EngineController.LiveRunnerRuntimeCore, + watchNode.AstIdentifierForPreview.Name, true); + + var list = watchVM.Children; + Assert.AreEqual(1, list.Count); + var children = list[0].Children; + Assert.AreEqual(5, children.Count); + Assert.AreEqual("UInt32", children[0].ValueType); + Assert.AreEqual("3", children[2].NodeLabel); + + var uint64node = ViewModel.Model.CurrentWorkspace.GetDSFunctionNodeFromWorkspace("DummyZeroTouchClass.PreviewUint64Dictionary"); + var vm = ViewModel.WatchHandler.GenerateWatchViewModelForData( + uint64node.CachedValue, watchNode.OutPorts.Select(p => p.Name), + ViewModel.Model.EngineController.LiveRunnerRuntimeCore, + watchNode.AstIdentifierForPreview.Name, true); + + list = vm.Children; + Assert.AreEqual(1, list.Count); + children = list[0].Children; + Assert.AreEqual(5, children.Count); + Assert.AreEqual("UInt64", children[0].ValueType); + Assert.AreEqual("3", children[2].NodeLabel); + } + + [Test] + public void WatchDictionaryJSONValuesDisplaysCorrectly() + { + + string openPath = Path.Combine(TestDirectory, @"core\watch\WatchDictionaryJSONValuesDisplaysCorrectly.dyn"); + ViewModel.OpenCommand.Execute(openPath); + ViewModel.HomeSpace.Run(); + + var watchNode = ViewModel.Model.CurrentWorkspace.FirstNodeFromWorkspace(); + var watchVM = ViewModel.WatchHandler.GenerateWatchViewModelForData( + watchNode.CachedValue, watchNode.OutPorts.Select(p => p.Name), + ViewModel.Model.EngineController.LiveRunnerRuntimeCore, + watchNode.AstIdentifierForPreview.Name, true); + + var list = watchVM.Children; + Assert.AreEqual(1, list.Count); + var children = list[0].Children; + Assert.AreEqual(2, children.Count); + Assert.AreEqual("String", children[0].ValueType); + Assert.AreEqual("value1", children[0].NodeLabel); + } + [Test] public void WatchNestedDictionaryPreviewFromMlutiReturnNode() { @@ -393,6 +471,19 @@ public void WatchNestedDictionaryPreviewFromMlutiReturnNode() } [Test] + public void WatchNodeWithBadSize() + { + string openPath = Path.Combine(TestDirectory, @"core\watch\WatchNodeBadSize.dyn"); + ViewModel.OpenCommand.Execute(openPath); + ViewModel.HomeSpace.Run(); + + var watchNode = ViewModel.Model.CurrentWorkspace.NodeFromWorkspace("355685ad-754c-400f-ac75-53a56c7d5423") as Watch; + + Assert.AreEqual(100, watchNode.Width); + Assert.AreEqual(100, watchNode.Height); + } + + [Test] public void GetNodeLabelTree() { // Arrange diff --git a/test/Engine/FFITarget/DummyZeroTouchClass.cs b/test/Engine/FFITarget/DummyZeroTouchClass.cs index 966d1b2bce8..a4d1f421221 100644 --- a/test/Engine/FFITarget/DummyZeroTouchClass.cs +++ b/test/Engine/FFITarget/DummyZeroTouchClass.cs @@ -1,4 +1,8 @@ -using Dynamo.Graph.Nodes; +using Dynamo.Graph.Nodes; +using System.Text; +using System; +using System.Collections.Generic; +using Newtonsoft.Json.Linq; namespace FFITarget { @@ -14,5 +18,46 @@ public int FunctionWithoutDescription(int a) { return 0; } + + public static Dictionary PreviewByteDictionary() + { + // Example base64 encoded string + string encodedString = "SGVsbG8gV29ybGQh"; + + byte[] decodedBytes = Convert.FromBase64String(encodedString); + var result = new Dictionary(); + result.Add("decodedBytes", decodedBytes); + + return result; + } + + public static Dictionary PreviewUint32Dictionary() + { + var uintArray = new uint[] { 1, 2, 3, 4, 5 }; + var result = new Dictionary(); + result.Add("uint32List", uintArray); + + return result; + } + + public static Dictionary PreviewUint64Dictionary() + { + var uintArray = new ulong[] { 1, 2, 3, 4, 5 }; + var result = new Dictionary(); + result.Add("uint64List", uintArray); + + return result; + } + + public static Dictionary PreviewJSONDictionary() + { + var json = new JObject(); + json.Add("key1", "value1"); + json.Add("key2", "value2"); + var result = new Dictionary(); + result.Add("json", json); + + return result; + } } } 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 @@ - + diff --git a/test/core/watch/WatchDictionaryByteValuesDisplaysCorrectly.dyn b/test/core/watch/WatchDictionaryByteValuesDisplaysCorrectly.dyn new file mode 100644 index 00000000000..107211068dd --- /dev/null +++ b/test/core/watch/WatchDictionaryByteValuesDisplaysCorrectly.dyn @@ -0,0 +1,150 @@ +{ + "Uuid": "8a5b5d45-b86d-4b1f-9d04-bec0e4fefd1c", + "IsCustomNode": false, + "Description": "", + "Name": "WatchDictionaryByteValuesDisplaysCorrectly", + "ElementResolver": { + "ResolutionMap": {} + }, + "Inputs": [], + "Outputs": [], + "Nodes": [ + { + "ConcreteType": "CoreNodeModels.Watch, CoreNodeModels", + "WatchWidth": 200.0, + "WatchHeight": 200.0, + "Id": "e72bcbe3c45044399237b0f63ff261cd", + "NodeType": "ExtensionNode", + "Inputs": [ + { + "Id": "3f76a802ad484a90b7a466783baad45a", + "Name": "", + "Description": "Node to show output from", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Outputs": [ + { + "Id": "fa2127ef2e864999aae8a00dcc13489f", + "Name": "", + "Description": "Node output", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Replication": "Disabled", + "Description": "Visualizes a node's output" + }, + { + "ConcreteType": "Dynamo.Graph.Nodes.ZeroTouch.DSFunction, DynamoCore", + "Id": "95889388fba84e11bc8905dcf80c10ea", + "NodeType": "FunctionNode", + "Inputs": [], + "Outputs": [ + { + "Id": "19ff13f87d5d4ac28736af66e0a80e0b", + "Name": "var[]..[]", + "Description": "var[]..[]", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "FunctionSignature": "FFITarget.DummyZeroTouchClass.PreviewByteDictionary", + "Replication": "Auto", + "Description": "DummyZeroTouchClass.PreviewByteDictionary ( ): var[]..[]" + } + ], + "Connectors": [ + { + "Start": "19ff13f87d5d4ac28736af66e0a80e0b", + "End": "3f76a802ad484a90b7a466783baad45a", + "Id": "35653deefde54d4297e35836f25c4282", + "IsHidden": "False" + } + ], + "Dependencies": [], + "NodeLibraryDependencies": [ + { + "Name": "FFITarget.dll", + "ReferenceType": "ZeroTouch", + "Nodes": [ + "95889388fba84e11bc8905dcf80c10ea" + ] + } + ], + "EnableLegacyPolyCurveBehavior": true, + "Thumbnail": "", + "GraphDocumentationURL": null, + "ExtensionWorkspaceData": [ + { + "ExtensionGuid": "28992e1d-abb9-417f-8b1b-05e053bee670", + "Name": "Properties", + "Version": "3.5", + "Data": {} + } + ], + "Author": "", + "Linting": { + "activeLinter": "None", + "activeLinterId": "7b75fb44-43fd-4631-a878-29f4d5d8399a", + "warningCount": 0, + "errorCount": 0 + }, + "Bindings": [], + "View": { + "Dynamo": { + "ScaleFactor": 1.0, + "HasRunWithoutCrash": true, + "IsVisibleInDynamoLibrary": true, + "Version": "3.5.0.6885", + "RunType": "Automatic", + "RunPeriod": "1000" + }, + "Camera": { + "Name": "_Background Preview", + "EyeX": -17.0, + "EyeY": 24.0, + "EyeZ": 50.0, + "LookX": 12.0, + "LookY": -13.0, + "LookZ": -58.0, + "UpX": 0.0, + "UpY": 1.0, + "UpZ": 0.0 + }, + "ConnectorPins": [], + "NodeViews": [ + { + "Id": "e72bcbe3c45044399237b0f63ff261cd", + "Name": "Watch", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Excluded": false, + "ShowGeometry": true, + "X": 558.0000000000003, + "Y": 134.0 + }, + { + "Id": "95889388fba84e11bc8905dcf80c10ea", + "Name": "DummyZeroTouchClass.PreviewByteDictionary", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Excluded": false, + "ShowGeometry": true, + "X": 78.00000000000006, + "Y": 363.2 + } + ], + "Annotations": [], + "X": 0.0, + "Y": 0.0, + "Zoom": 1.0 + } +} \ No newline at end of file diff --git a/test/core/watch/WatchDictionaryJSONValuesDisplaysCorrectly.dyn b/test/core/watch/WatchDictionaryJSONValuesDisplaysCorrectly.dyn new file mode 100644 index 00000000000..971382e7455 --- /dev/null +++ b/test/core/watch/WatchDictionaryJSONValuesDisplaysCorrectly.dyn @@ -0,0 +1,150 @@ +{ + "Uuid": "882d7929-ed69-4315-a1c7-4265dd1cf731", + "IsCustomNode": false, + "Description": "", + "Name": "WatchDictionaryJSONValuesDisplaysCorrectly", + "ElementResolver": { + "ResolutionMap": {} + }, + "Inputs": [], + "Outputs": [], + "Nodes": [ + { + "ConcreteType": "Dynamo.Graph.Nodes.ZeroTouch.DSFunction, DynamoCore", + "Id": "8246737ac9fe4734bec2dc1e03edf5b3", + "NodeType": "FunctionNode", + "Inputs": [], + "Outputs": [ + { + "Id": "466559bf56254b1dbd8eabbb0e268a3b", + "Name": "var[]..[]", + "Description": "var[]..[]", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "FunctionSignature": "FFITarget.DummyZeroTouchClass.PreviewJSONDictionary", + "Replication": "Auto", + "Description": "DummyZeroTouchClass.PreviewJSONDictionary ( ): var[]..[]" + }, + { + "ConcreteType": "CoreNodeModels.Watch, CoreNodeModels", + "WatchWidth": 200.0, + "WatchHeight": 200.0, + "Id": "4b9d2903cc064ae3a06f7acc38be558e", + "NodeType": "ExtensionNode", + "Inputs": [ + { + "Id": "5000cb01edf64754a616d5df4daea236", + "Name": "", + "Description": "Node to show output from", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Outputs": [ + { + "Id": "3270aefb6c6a4b85b4d478681db49a9b", + "Name": "", + "Description": "Node output", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Replication": "Disabled", + "Description": "Visualizes a node's output" + } + ], + "Connectors": [ + { + "Start": "466559bf56254b1dbd8eabbb0e268a3b", + "End": "5000cb01edf64754a616d5df4daea236", + "Id": "5dbe3adc97154ee0a5118b5bc835bd01", + "IsHidden": "False" + } + ], + "Dependencies": [], + "NodeLibraryDependencies": [ + { + "Name": "FFITarget.dll", + "ReferenceType": "ZeroTouch", + "Nodes": [ + "8246737ac9fe4734bec2dc1e03edf5b3" + ] + } + ], + "EnableLegacyPolyCurveBehavior": true, + "Thumbnail": "", + "GraphDocumentationURL": null, + "ExtensionWorkspaceData": [ + { + "ExtensionGuid": "28992e1d-abb9-417f-8b1b-05e053bee670", + "Name": "Properties", + "Version": "3.5", + "Data": {} + } + ], + "Author": "", + "Linting": { + "activeLinter": "None", + "activeLinterId": "7b75fb44-43fd-4631-a878-29f4d5d8399a", + "warningCount": 0, + "errorCount": 0 + }, + "Bindings": [], + "View": { + "Dynamo": { + "ScaleFactor": 1.0, + "HasRunWithoutCrash": true, + "IsVisibleInDynamoLibrary": true, + "Version": "3.5.0.6885", + "RunType": "Automatic", + "RunPeriod": "1000" + }, + "Camera": { + "Name": "_Background Preview", + "EyeX": -17.0, + "EyeY": 24.0, + "EyeZ": 50.0, + "LookX": 12.0, + "LookY": -13.0, + "LookZ": -58.0, + "UpX": 0.0, + "UpY": 1.0, + "UpZ": 0.0 + }, + "ConnectorPins": [], + "NodeViews": [ + { + "Id": "8246737ac9fe4734bec2dc1e03edf5b3", + "Name": "DummyZeroTouchClass.PreviewJSONDictionary", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Excluded": false, + "ShowGeometry": true, + "X": 49.200000000000045, + "Y": 378.40000000000003 + }, + { + "Id": "4b9d2903cc064ae3a06f7acc38be558e", + "Name": "Watch", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Excluded": false, + "ShowGeometry": true, + "X": 596.4000000000001, + "Y": 298.40000000000003 + } + ], + "Annotations": [], + "X": 0.0, + "Y": 0.0, + "Zoom": 1.0 + } +} \ No newline at end of file diff --git a/test/core/watch/WatchDictionaryUintValuesDisplaysCorrectly.dyn b/test/core/watch/WatchDictionaryUintValuesDisplaysCorrectly.dyn new file mode 100644 index 00000000000..9b02ec0eaff --- /dev/null +++ b/test/core/watch/WatchDictionaryUintValuesDisplaysCorrectly.dyn @@ -0,0 +1,181 @@ +{ + "Uuid": "44be9033-1237-4074-b64a-04f5e4fbee18", + "IsCustomNode": false, + "Description": "", + "Name": "WatchDictionaryUintValuesDisplaysCorrectly", + "ElementResolver": { + "ResolutionMap": {} + }, + "Inputs": [], + "Outputs": [], + "Nodes": [ + { + "ConcreteType": "Dynamo.Graph.Nodes.ZeroTouch.DSFunction, DynamoCore", + "Id": "8d612f62bebf419589a97630e5e73b3a", + "NodeType": "FunctionNode", + "Inputs": [], + "Outputs": [ + { + "Id": "7913bacafb0f40ee98667b04201f9df6", + "Name": "var[]..[]", + "Description": "var[]..[]", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "FunctionSignature": "FFITarget.DummyZeroTouchClass.PreviewUint32Dictionary", + "Replication": "Auto", + "Description": "DummyZeroTouchClass.PreviewUint32Dictionary ( ): var[]..[]" + }, + { + "ConcreteType": "Dynamo.Graph.Nodes.ZeroTouch.DSFunction, DynamoCore", + "Id": "17acde4c2c694eb89899762b354f43c1", + "NodeType": "FunctionNode", + "Inputs": [], + "Outputs": [ + { + "Id": "d9441f516a66418cb13ea4821e5507a2", + "Name": "var[]..[]", + "Description": "var[]..[]", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "FunctionSignature": "FFITarget.DummyZeroTouchClass.PreviewUint64Dictionary", + "Replication": "Auto", + "Description": "DummyZeroTouchClass.PreviewUint64Dictionary ( ): var[]..[]" + }, + { + "ConcreteType": "CoreNodeModels.Watch, CoreNodeModels", + "WatchWidth": 200.0, + "WatchHeight": 200.0, + "Id": "a1bfb653f17646f29a61a04800c4f676", + "NodeType": "ExtensionNode", + "Inputs": [ + { + "Id": "b094c0d545624c62b4672a37fcd67b5b", + "Name": "", + "Description": "Node to show output from", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Outputs": [ + { + "Id": "5e41ed049fb9415b951ce368b74f38de", + "Name": "", + "Description": "Node output", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Replication": "Disabled", + "Description": "Visualizes a node's output" + } + ], + "Connectors": [ + { + "Start": "7913bacafb0f40ee98667b04201f9df6", + "End": "b094c0d545624c62b4672a37fcd67b5b", + "Id": "73ac3909d5884216b2acae31d21fbcc2", + "IsHidden": "False" + } + ], + "Dependencies": [], + "NodeLibraryDependencies": [ + { + "Name": "FFITarget.dll", + "ReferenceType": "ZeroTouch", + "Nodes": [ + "8d612f62bebf419589a97630e5e73b3a", + "17acde4c2c694eb89899762b354f43c1" + ] + } + ], + "EnableLegacyPolyCurveBehavior": true, + "Thumbnail": "", + "GraphDocumentationURL": null, + "ExtensionWorkspaceData": [ + { + "ExtensionGuid": "28992e1d-abb9-417f-8b1b-05e053bee670", + "Name": "Properties", + "Version": "3.5", + "Data": {} + } + ], + "Author": "", + "Linting": { + "activeLinter": "None", + "activeLinterId": "7b75fb44-43fd-4631-a878-29f4d5d8399a", + "warningCount": 0, + "errorCount": 0 + }, + "Bindings": [], + "View": { + "Dynamo": { + "ScaleFactor": 1.0, + "HasRunWithoutCrash": true, + "IsVisibleInDynamoLibrary": true, + "Version": "3.5.0.6885", + "RunType": "Automatic", + "RunPeriod": "1000" + }, + "Camera": { + "Name": "_Background Preview", + "EyeX": -17.0, + "EyeY": 24.0, + "EyeZ": 50.0, + "LookX": 12.0, + "LookY": -13.0, + "LookZ": -58.0, + "UpX": 0.0, + "UpY": 1.0, + "UpZ": 0.0 + }, + "ConnectorPins": [], + "NodeViews": [ + { + "Id": "8d612f62bebf419589a97630e5e73b3a", + "Name": "DummyZeroTouchClass.PreviewUint32Dictionary", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Excluded": false, + "ShowGeometry": true, + "X": 29.199999999999875, + "Y": 187.20000000000005 + }, + { + "Id": "17acde4c2c694eb89899762b354f43c1", + "Name": "DummyZeroTouchClass.PreviewUint64Dictionary", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Excluded": false, + "ShowGeometry": true, + "X": 92.40000000000003, + "Y": 579.6 + }, + { + "Id": "a1bfb653f17646f29a61a04800c4f676", + "Name": "Watch", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Excluded": false, + "ShowGeometry": true, + "X": 560.4, + "Y": 185.20000000000005 + } + ], + "Annotations": [], + "X": 0.0, + "Y": 0.0, + "Zoom": 1.0 + } +} \ No newline at end of file diff --git a/test/core/watch/WatchNodeBadSize.dyn b/test/core/watch/WatchNodeBadSize.dyn new file mode 100644 index 00000000000..dd9400a475a --- /dev/null +++ b/test/core/watch/WatchNodeBadSize.dyn @@ -0,0 +1,142 @@ +{ + "Uuid": "2d99f611-7d17-4fbe-8e39-8fbd77cd1ecf", + "IsCustomNode": false, + "Description": "", + "Name": "WatchNodeBadSize", + "ElementResolver": { + "ResolutionMap": {} + }, + "Inputs": [], + "Outputs": [], + "Nodes": [ + { + "ConcreteType": "CoreNodeModels.Watch, CoreNodeModels", + "WatchWidth": 50.0, + "WatchHeight": 38.0, + "Id": "355685ad754c400fac7553a56c7d5423", + "NodeType": "ExtensionNode", + "Inputs": [ + { + "Id": "7feffa6f77e34900b45cb33858ad4e7a", + "Name": "", + "Description": "Node to show output from", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Outputs": [ + { + "Id": "1d550c1aba7845b0be174dedaae60253", + "Name": "", + "Description": "Node output", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Replication": "Disabled", + "Description": "Visualizes a node's output" + }, + { + "ConcreteType": "Dynamo.Graph.Nodes.CodeBlockNodeModel, DynamoCore", + "Id": "ca31ea53b3b94751b7a5254fb6cdb7b9", + "NodeType": "CodeBlockNode", + "Inputs": [], + "Outputs": [ + { + "Id": "1adc5b91c52c4f87bbb113222f5c760b", + "Name": "", + "Description": "Value of expression at line 1", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Replication": "Disabled", + "Description": "Allows for DesignScript code to be authored directly", + "Code": "1..10;" + } + ], + "Connectors": [ + { + "Start": "1adc5b91c52c4f87bbb113222f5c760b", + "End": "7feffa6f77e34900b45cb33858ad4e7a", + "Id": "0f111a8fa2d84185aeeeee4ba37c718a", + "IsHidden": "False" + } + ], + "Dependencies": [], + "NodeLibraryDependencies": [], + "EnableLegacyPolyCurveBehavior": true, + "Thumbnail": "", + "GraphDocumentationURL": null, + "ExtensionWorkspaceData": [ + { + "ExtensionGuid": "28992e1d-abb9-417f-8b1b-05e053bee670", + "Name": "Properties", + "Version": "3.5", + "Data": {} + } + ], + "Author": "", + "Linting": { + "activeLinter": "None", + "activeLinterId": "7b75fb44-43fd-4631-a878-29f4d5d8399a", + "warningCount": 0, + "errorCount": 0 + }, + "Bindings": [], + "View": { + "Dynamo": { + "ScaleFactor": 1.0, + "HasRunWithoutCrash": true, + "IsVisibleInDynamoLibrary": true, + "Version": "3.4.1.7435", + "RunType": "Automatic", + "RunPeriod": "1000" + }, + "Camera": { + "Name": "_Background Preview", + "EyeX": -17.0, + "EyeY": 24.0, + "EyeZ": 50.0, + "LookX": 12.0, + "LookY": -13.0, + "LookZ": -58.0, + "UpX": 0.0, + "UpY": 1.0, + "UpZ": 0.0 + }, + "ConnectorPins": [], + "NodeViews": [ + { + "Id": "355685ad754c400fac7553a56c7d5423", + "Name": "Watch", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Excluded": false, + "ShowGeometry": true, + "X": 626.0, + "Y": 261.5 + }, + { + "Id": "ca31ea53b3b94751b7a5254fb6cdb7b9", + "Name": "Code Block", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Excluded": false, + "ShowGeometry": true, + "X": 268.0, + "Y": 267.0 + } + ], + "Annotations": [], + "X": 0.0, + "Y": 0.0, + "Zoom": 1.0 + } +} \ No newline at end of file