public void OpenPythonLearningMaterialValidationTest()
        {
            Open(@"core\python\python_check_output.dyn");

            var nodeView  = NodeViewWithGuid("3bcad14e-d086-4278-9e08-ed2759ef92f3");
            var nodeModel = nodeView.ViewModel.NodeModel as PythonNodeBase;

            Assert.NotNull(nodeModel);

            //Open the python script editor
            var scriptWindow = EditPythonCode(nodeView, View);

            var learnMoreMenuItem = nodeView.MainContextMenu
                                    .Items
                                    .OfType <MenuItem>()
                                    .First(x => x.Header.ToString() == "Learn more about Python");

            Assert.IsNotNull(learnMoreMenuItem);

            //Click the button and internally the  OpenPythonLearningMaterial method is executed
            learnMoreMenuItem.RaiseEvent(new RoutedEventArgs(MenuItem.ClickEvent));

            DispatcherUtil.DoEvents();

            var learnMoreTab = this.View.ExtensionTabItems
                               .Where(x => x.Content.GetType().Equals(typeof(DocumentationBrowserView)))
                               .FirstOrDefault();

            //Validate tha the documentation browser tab is opened and visible once we clicked the button.
            Assert.IsNotNull(learnMoreTab);
            Assert.IsTrue(learnMoreTab.IsVisible);
        }
Beispiel #2
0
        public void CanOpenDocumentationBrowserWhenMoreInformationIsClicked()
        {
            DebugModes.LoadDebugModesStatusFromConfig(Path.Combine(GetTestDirectory(ExecutingDirectory), "DynamoCoreWpfTests", "python2ObsoleteMode.config"));
            DynamoModel.IsTestMode = false;

            // Act
            // open file
            var examplePath = Path.Combine(UnitTestBase.TestDirectory, @"core\python", "python.dyn");

            Open(examplePath);
            DispatcherUtil.DoEvents();

            var ironPythonDialog = this.View.GetChildrenWindowsOfType <IronPythonInfoDialog>().First();
            var viewExtensionTabsBeforeBtnClick = this.View.ExtensionTabItems.Count;

            DispatcherUtil.DoEvents();

            ironPythonDialog.MoreInformationBtn.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
            var hasDocumentationBrowserTab = this.View.ExtensionTabItems
                                             .Any(x => x.Header.ToString() == "Documentation Browser");

            DispatcherUtil.DoEvents();

            // Assert
            Assert.AreEqual(viewExtensionTabsBeforeBtnClick + 1, this.View.ExtensionTabItems.Count);
            Assert.IsTrue(hasDocumentationBrowserTab);
            DynamoModel.IsTestMode = true;
            DispatcherUtil.DoEvents();
        }
Beispiel #3
0
        public void WillLogNotificationWhenAddingAnIronPythonNode()
        {
            DebugModes.LoadDebugModesStatusFromConfig(Path.Combine(GetTestDirectory(ExecutingDirectory), "DynamoCoreWpfTests", "python2ObsoleteMode.config"));
            // Arrange
            string pythonNodeName = "Python Script";

            raisedEvents = new List <string>();
            // Act
            // open file
            this.ViewModel.Model.Logger.NotificationLogged += Logger_NotificationLogged;

            var nodesCountBeforeNodeAdded = this.ViewModel.CurrentSpace.Nodes.Count();

            this.ViewModel.ExecuteCommand(new DynamoModel.
                                          CreateNodeCommand(Guid.NewGuid().ToString(), pythonNodeName, 0, 0, false, false));

            var nodesCountAfterNodeAdded = this.ViewModel.CurrentSpace.Nodes.Count();

            // Assert
            Assert.AreEqual(nodesCountBeforeNodeAdded + 1, nodesCountAfterNodeAdded);
            Assert.AreEqual(raisedEvents.Count, 1);
            Assert.IsTrue(raisedEvents.Any(x => x.Contains(nameof(PythonMigrationViewExtension))));
            raisedEvents.Clear();
            this.ViewModel.Model.Logger.NotificationLogged -= Logger_NotificationLogged;
            DispatcherUtil.DoEvents();
        }
Beispiel #4
0
        public void PreviewBubble_HiddenDummyVerticalBoundaries()
        {
            Open(@"core\DetailedPreviewMargin_Test.dyn");

            var nodeView = NodeViewWithGuid("1382aaf9-9432-4cf0-86ae-c586d311767e");

            nodeView.PreviewControl.RaiseEvent(new RoutedEventArgs(FrameworkElement.LoadedEvent));

            // preview is hidden
            Assert.IsTrue(ElementIsInContainer(nodeView.PreviewControl.HiddenDummy, nodeView.PreviewControl, 0));

            View.Dispatcher.Invoke(() =>
            {
                nodeView.PreviewControl.BindToDataSource();
                nodeView.PreviewControl.TransitionToState(Dynamo.UI.Controls.PreviewControl.State.Condensed);
            });

            DispatcherUtil.DoEvents();

            // preview is condensed
            Assert.IsTrue(ElementIsInContainer(nodeView.PreviewControl.HiddenDummy, nodeView.PreviewControl, 0));

            View.Dispatcher.Invoke(() =>
            {
                nodeView.PreviewControl.TransitionToState(Dynamo.UI.Controls.PreviewControl.State.Expanded);
            });

            DispatcherUtil.DoEvents();

            // preview is expanded, and its size will be slighly larger than the size of node view.
            // See PR: https://github.com/DynamoDS/Dynamo/pull/6799
            Assert.IsTrue(ElementIsInContainer(nodeView.PreviewControl.HiddenDummy, nodeView, 10));
        }
Beispiel #5
0
        public void Node_PreviewUpstreamToggled_RenderingUpToDate()
        {
            var model = ViewModel.Model;

            OpenVisualizationTest("ASM_points_line.dyn");

            DispatcherUtil.DoEvents();

            //we start with all previews disabled
            //the graph is two points feeding into a line

            //ensure that visulations match our expectations
            Assert.True(BackgroundPreviewGeometry.HasNumberOfPointsCurvesAndMeshes(7, 6, 0));

            var watch3D = Model.CurrentWorkspace.FirstNodeFromWorkspace <Watch3D>();

            Assert.NotNull(watch3D);

            var view = FindFirstWatch3DNodeView();
            var vm   = view.viewModel as HelixWatch3DNodeViewModel;

            Assert.NotNull(vm);

            //flip off the line node's preview upstream
            var l1 = model.CurrentWorkspace.Nodes.First(x => x.GUID.ToString() == "7c1cecee-43ed-43b5-a4bb-5f71c50341b2");

            l1.UpdateValue(new UpdateValueParams("IsUpstreamVisible", "false"));

            Assert.True(vm.SceneItems.HasNumberOfPointsCurvesAndMeshes(0, 6, 0));
        }
Beispiel #6
0
 public void NavegaJanela(Funcionalidades funcionalidade)
 {
     if (funcionalidade == Funcionalidades.Animes)
     {
         this.NavigationService.Navigate(new Inicio());
     }
     else if (funcionalidade == Funcionalidades.Financeiro)
     {
         this.NavigationService.Navigate(new Financeiro.inicio());
     }
     else if (funcionalidade == Funcionalidades.Steam)
     {
         this.NavigationService.Navigate(new SteamJogos.Inicio());
     }
     else if (funcionalidade == Funcionalidades.Contador)
     {
         janelaPrincipal.WindowState = WindowState.Minimized;
         DispatcherUtil.Dispatcher(() =>
         {
             JanelaContador.Inicializa(janelaPrincipal);
             JanelaContador.Mostrar();
             JanelaContador.Focar();
         });
     }
 }
        private static void SetTextEditorText(ScriptEditorWindow view, string code)
        {
            var editor = view.ChildrenOfType <ICSharpCode.AvalonEdit.TextEditor>();

            editor.FirstOrDefault().Text = code;
            DispatcherUtil.DoEvents();
        }
        public void ChangingDropdownEngineDoesNotSavesCodeOrRun()
        {
            // Arrange
            var engineChange = PythonEngineVersion.CPython3;

            Open(@"core\python\python.dyn");
            (Model.CurrentWorkspace as HomeWorkspaceModel).RunSettings.RunType = Dynamo.Models.RunType.Automatic;
            Assert.AreEqual(1, (Model.CurrentWorkspace as HomeWorkspaceModel).EvaluationCount);
            var nodeView  = NodeViewWithGuid("3bcad14e-d086-4278-9e08-ed2759ef92f3");
            var nodeModel = nodeView.ViewModel.NodeModel as PythonNodeModels.PythonNodeBase;

            Assert.NotNull(nodeModel);
            var scriptWindow = EditPythonCode(nodeView, View);

            var engineSelectorComboBox = FindEditorDropDown(scriptWindow);

            // Act

            //modify code in editor
            Assert.AreEqual("ok", (nodeModel as PythonNode).Script);
            SetTextEditorText(scriptWindow, "OUT = 100");
            //theres one execution from opening the graph.
            Assert.AreEqual(1, (Model.CurrentWorkspace as HomeWorkspaceModel).EvaluationCount);
            //modify engine
            engineSelectorComboBox.SelectedItem = engineChange;
            //theres still one executions from modifying the engine, as changing engines does not trigger a run.
            Assert.AreEqual(1, (Model.CurrentWorkspace as HomeWorkspaceModel).EvaluationCount);

            //assert model code is updated.
            Assert.AreEqual("ok", (nodeModel as PythonNode).Script);

            DispatcherUtil.DoEvents();
        }
        public void OpenPythonLearningMaterial_PythonNodeFromStringValidationTest()
        {
            Open(@"core\python\pythonFromString.dyn");

            var nodeView  = NodeViewWithGuid("bad59bc8-9b49-47b6-99ee-34fa8dca91ae");
            var nodeModel = nodeView.ViewModel.NodeModel as PythonNodeBase;

            Assert.NotNull(nodeModel);

            var learnMoreMenuItem = nodeView.MainContextMenu
                                    .Items
                                    .OfType <MenuItem>()
                                    .First(x => x.Header.ToString() == "Learn more about Python");

            Assert.IsNotNull(learnMoreMenuItem);

            //Click the button and internally the  OpenPythonLearningMaterial method is executed
            learnMoreMenuItem.RaiseEvent(new RoutedEventArgs(MenuItem.ClickEvent));

            DispatcherUtil.DoEvents();

            var learnMoreTab = this.View.ExtensionTabItems
                               .Where(x => x.Content.GetType().Equals(typeof(DocumentationBrowserView)))
                               .FirstOrDefault();

            //Validate tha the documentation browser tab is opened and visible once we clicked the button.
            Assert.IsNotNull(learnMoreTab);
            Assert.IsTrue(learnMoreTab.IsVisible);
        }
 static void WaitWithDispatcher(Task <NotificationResult> task)
 {
     while (task.Status != TaskStatus.RanToCompletion && task.Status != TaskStatus.Faulted)
     {
         DispatcherUtil.DoEvents();
     }
 }
Beispiel #11
0
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            VisualStateManager.GoToState(this, "Normal", false);
            var _trans = this.GetTemplateChild("translate") as TranslateTransform;

            _container                 = this.GetTemplateChild("Container") as FrameworkElement;
            _container.Tapped         += _container_Tapped;
            _container.PointerPressed += _container_PointerPressed;

            _root = base.GetTemplateChild("root") as Grid;
            if (_isTapDismiss)
            {
                if (_root != null)
                {
                    if (Background == null)
                    {
                        Background = new SolidColorBrush(Colors.Transparent);
                    }
                    _root.ManipulationMode = ManipulationModes.All;
                    _root.Tapped          += _container_Tapped;
                    _root.PointerPressed  += _container_PointerPressed;
                }
            }
            else
            {
                _root.Background = null;
                Background       = null;
            }

            var _closeSb = this.GetTemplateChild("PopupCloseStoryboard") as Storyboard;

            if (_closeSb != null)
            {
                _closeSb.Completed += _closeSb_Completed;
            }

            this.Opacity = 0.0;

            DispatcherUtil.Run(Dispatcher, () =>
            {
                if (double.IsNaN(PRange))
                {
                    PRange = _mode == Mode.Bottom ? _container.ActualHeight : _container.ActualWidth;
                }
                InitTrans(_trans);

                this.Opacity = 1.0;

                var content = Content as FrameworkElement;
                if (content.Opacity == 0.0)
                {
                    content.Opacity = 1.0;
                }

                VisualStateManager.GoToState(this, "Open", true);
            }, Windows.UI.Core.CoreDispatcherPriority.High);
        }
        public void ClipboardService_CreditCard()
        {
            var service     = GetClipboardService();
            var dataService = ServiceLocator.GetService <DataService>();

            var dataObject = new DataObject();

            dataObject.SetText("  4974- 0411-3456- 7895 ");
            var entry1 = new ClipboardHookEventArgs(dataObject, false, DateTime.Now.Ticks);

            DispatcherUtil.ExecuteOnDispatcherThread(() =>
            {
                service.ClipboardHook_ClipboardChanged(null, entry1);
            }, 100);
            Task.Delay(300).Wait();
            DispatcherUtil.DoEvents();

            Assert.AreEqual(dataService.DataEntries.Count, 0);

            DispatcherUtil.ExecuteOnDispatcherThread(() =>
            {
                service.ClipboardHook_ClipboardChanged(null, entry1);
            }, 100);
            Task.Delay(300).Wait();
            DispatcherUtil.DoEvents();
            Assert.AreEqual(dataService.DataEntries.Count, 1);
            Assert.AreEqual(DataHelper.FromBase64 <string>(dataService.DataEntries.First().Thumbnail.Value), "4974-••••-••••-7895");

            dataObject = new DataObject();
            dataObject.SetText("  4974- 0411-3451- 7895 ");
            entry1 = new ClipboardHookEventArgs(dataObject, false, DateTime.Now.Ticks);

            DispatcherUtil.ExecuteOnDispatcherThread(() =>
            {
                service.ClipboardHook_ClipboardChanged(null, entry1);
            }, 100);
            Task.Delay(300).Wait();
            DispatcherUtil.DoEvents();
            Assert.AreEqual(dataService.DataEntries.Count, 1);

            DispatcherUtil.ExecuteOnDispatcherThread(() =>
            {
                service.ClipboardHook_ClipboardChanged(null, entry1);
            }, 100);
            Task.Delay(300).Wait();
            DispatcherUtil.DoEvents();
            Assert.AreEqual(dataService.DataEntries.Count, 2);

            TestUtilities.GetSettingProvider().AvoidCreditCard = false;

            DispatcherUtil.ExecuteOnDispatcherThread(() =>
            {
                service.ClipboardHook_ClipboardChanged(null, entry1);
            }, 100);
            Task.Delay(300).Wait();
            DispatcherUtil.DoEvents();
            Assert.AreEqual(dataService.DataEntries.Count, 3);
        }
        public void CanChangeEngineFromScriptEditorDropDown()
        {
            // Arrange
            var expectedAvailableEngines = new List <string>()
            {
                PythonEngineManager.CPython3EngineName,
                PythonEngineManager.IronPython2EngineName,
            };
            var expectedDefaultEngine = PythonEngineManager.IronPython2EngineName;
            var engineChange          = PythonEngineManager.CPython3EngineName;

            Open(@"core\python\python.dyn");

            var nodeView  = NodeViewWithGuid("3bcad14e-d086-4278-9e08-ed2759ef92f3");
            var nodeModel = nodeView.ViewModel.NodeModel as PythonNodeBase;

            Assert.NotNull(nodeModel);

            var scriptWindow = EditPythonCode(nodeView, View);

            var engineSelectorComboBox = FindEditorDropDown(scriptWindow);

            // Act
            var engineBeforeChange = engineSelectorComboBox.SelectedItem;
            var comboBoxEngines    = engineSelectorComboBox.Items.SourceCollection;
            var engineAfterChange  = engineSelectorComboBox.SelectedItem = engineChange;

            // Assert
            Assert.AreEqual(engineSelectorComboBox.Visibility, Visibility.Visible);
            CollectionAssert.AreEqual(expectedAvailableEngines, comboBoxEngines);
            Assert.AreEqual(expectedDefaultEngine, engineBeforeChange);
            Assert.AreEqual(engineSelectorComboBox.SelectedItem, PythonEngineManager.CPython3EngineName);

            //Assert that selecting an engine from drop-down without saving won't update the engine.
            Assert.AreEqual(nodeModel.EngineName, engineBeforeChange);
            Assert.AreEqual(scriptWindow.CachedEngine, engineAfterChange);

            //Clicking save button to actually update the engine.
            var saveButton = scriptWindow.FindName("SaveScriptChangesButton") as Button;

            saveButton.RaiseEvent(new RoutedEventArgs(ButtonBase.ClickEvent));
            Assert.AreEqual(nodeModel.EngineName, engineAfterChange);
            var engineMenuItem = nodeView.MainContextMenu
                                 .Items
                                 .OfType <MenuItem>()
                                 .First(x => x.Header.ToString() == "Python Engine Version");
            var ironPython2MenuItem = engineMenuItem.Items
                                      .OfType <MenuItem>()
                                      .First(x => x.Header.ToString() == PythonNodeModels.Properties.Resources.PythonNodeContextMenuEngineVersionTwo);
            var cPython3MenuItem = engineMenuItem.Items
                                   .OfType <MenuItem>()
                                   .First(x => x.Header.ToString() == PythonNodeModels.Properties.Resources.PythonNodeContextMenuEngineVersionThree);

            Assert.AreEqual(false, ironPython2MenuItem.IsChecked);
            Assert.AreEqual(true, cPython3MenuItem.IsChecked);
            DispatcherUtil.DoEvents();
        }
        public void IsolatedColoredLinesBecomesTransparent()
        {
            OpenVisualizationTest("Display.ByGeometryColorPointsLines.dyn");

            var ws = ViewModel.Model.CurrentWorkspace as HomeWorkspaceModel;

            RunCurrentModel();
            DispatcherUtil.DoEvents();
            //get all points
            var lines            = BackgroundPreviewGeometry.OfType <DynamoLineGeometryModel3D>();
            var lineColors       = lines.SelectMany(x => x.Geometry.Colors);
            var blueLinesCount   = lineColors.Where(x => x == Colors.Blue.ToColor4()).Count();;
            var yellowLinesCount = lineColors.Where(x => x == new Color3(1, 1, 0).ToColor4()).Count();

            Assert.AreEqual(14897 * 2, blueLinesCount);
            Assert.AreEqual(14895 * 2, yellowLinesCount);

            ViewModel.BackgroundPreviewViewModel.IsolationMode = true;
            DispatcherUtil.DoEvents();
            //everything should be isolated.
            //assert that point colors have low alpha
            lineColors = lines.SelectMany(x => x.Geometry.Colors);
            //isolate sets Alpha to .3 currently
            var isolatedColors = lineColors.Where(x => x.Alpha < .4f).Count();

            Assert.AreEqual(29791 * 2, isolatedColors);

            //select points
            var lineDisplayNode = Model.CurrentWorkspace.Nodes.Where(x => x.GUID == Guid.Parse("09ddd3ecea454984a37349f1266a247d")).First();

            DynamoSelection.Instance.ClearSelection();
            DynamoSelection.Instance.Selection.Add(lineDisplayNode);
            DispatcherUtil.DoEvents();
            //assert points are no longer isolated
            lineColors       = lines.SelectMany(x => x.Geometry.Colors);
            blueLinesCount   = lineColors.Where(x => x == Colors.Blue.ToColor4()).Count();;
            yellowLinesCount = lineColors.Where(x => x == new Color3(1, 1, 0).ToColor4()).Count();
            Assert.AreEqual(14897 * 2, blueLinesCount);
            Assert.AreEqual(14895 * 2, yellowLinesCount);

            DynamoSelection.Instance.ClearSelection();
            DispatcherUtil.DoEvents();
            //isolated again.
            lineColors = lines.SelectMany(x => x.Geometry.Colors);
            //isolate sets Alpha to .3 currently
            isolatedColors = lineColors.Where(x => x.Alpha < .4f).Count();
            Assert.AreEqual(29791 * 2, isolatedColors);

            //unisolate
            ViewModel.BackgroundPreviewViewModel.IsolationMode = false;
            DispatcherUtil.DoEvents();
            lineColors       = lines.SelectMany(x => x.Geometry.Colors);
            blueLinesCount   = lineColors.Where(x => x == Colors.Blue.ToColor4()).Count();;
            yellowLinesCount = lineColors.Where(x => x == new Color3(1, 1, 0).ToColor4()).Count();
            Assert.AreEqual(14897 * 2, blueLinesCount);
            Assert.AreEqual(14895 * 2, yellowLinesCount);
        }
        public void IsolatedColoredPtsBecomesTransparent()
        {
            OpenVisualizationTest("Display.ByGeometryColorPointsLines.dyn");

            var ws = ViewModel.Model.CurrentWorkspace as HomeWorkspaceModel;

            RunCurrentModel();
            DispatcherUtil.DoEvents();
            //get all points
            var points         = BackgroundPreviewGeometry.OfType <DynamoPointGeometryModel3D>();
            var pointColors    = points.SelectMany(x => x.Geometry.Colors);
            var bluePtsCount   = pointColors.Where(x => x == Colors.Blue.ToColor4()).Count();;
            var yellowPtsCount = pointColors.Where(x => x == new Color3(1, 1, 0).ToColor4()).Count();

            Assert.AreEqual(14896, bluePtsCount);
            Assert.AreEqual(14895, yellowPtsCount);

            ViewModel.BackgroundPreviewViewModel.IsolationMode = true;
            DispatcherUtil.DoEvents();
            //everything should be isolated.
            //assert that point colors have low alpha
            pointColors = points.SelectMany(x => x.Geometry.Colors);
            //isolate sets Alpha to .3 currently
            var isolatedColors = pointColors.Where(x => x.Alpha < .4f).Count();

            Assert.AreEqual(29791, isolatedColors);

            //select points
            var pointDisplayNode = Model.CurrentWorkspace.Nodes.Where(x => x.GUID == Guid.Parse("9af882721af64514883ce7390fcfe523")).First();

            DynamoSelection.Instance.ClearSelection();
            DynamoSelection.Instance.Selection.Add(pointDisplayNode);
            DispatcherUtil.DoEvents();
            //assert points are no longer isolated
            pointColors    = points.SelectMany(x => x.Geometry.Colors);
            bluePtsCount   = pointColors.Where(x => x == Colors.Blue.ToColor4()).Count();;
            yellowPtsCount = pointColors.Where(x => x == new Color3(1, 1, 0).ToColor4()).Count();
            Assert.AreEqual(14896, bluePtsCount);
            Assert.AreEqual(14895, yellowPtsCount);

            DynamoSelection.Instance.ClearSelection();
            DispatcherUtil.DoEvents();
            //isolated again.
            pointColors = points.SelectMany(x => x.Geometry.Colors);
            //isolate sets Alpha to .3 currently
            isolatedColors = pointColors.Where(x => x.Alpha < .4f).Count();
            Assert.AreEqual(29791, isolatedColors);

            //unisolate
            ViewModel.BackgroundPreviewViewModel.IsolationMode = false;
            DispatcherUtil.DoEvents();
            pointColors    = points.SelectMany(x => x.Geometry.Colors);
            bluePtsCount   = pointColors.Where(x => x == Colors.Blue.ToColor4()).Count();;
            yellowPtsCount = pointColors.Where(x => x == new Color3(1, 1, 0).ToColor4()).Count();
            Assert.AreEqual(14896, bluePtsCount);
            Assert.AreEqual(14895, yellowPtsCount);
        }
Beispiel #16
0
        private static ICSharpCode.AvalonEdit.TextEditor FindCodeEditor(ScriptEditorWindow view)
        {
            DispatcherUtil.DoEvents();
            var windowGrid = view.Content as Grid;
            var codeEditor = windowGrid
                             .ChildrenOfType <ICSharpCode.AvalonEdit.TextEditor>()
                             .First();

            return(codeEditor);
        }
Beispiel #17
0
        public async Task CloudStorageService_Synchronize_DeletedLocallyAndRemotely()
        {
            /*
             * Scenario :
             * There is a data on the server and the same data locally.
             * We delete it from local. It must be deleted on the server too.
             */

            var dataService              = GetDataService();
            var cloudStorageService      = GetCloudStorageService();
            var cloudStorageProviderMock = GetCloudStorageProviderMock();
            var service = GetClipboardService();

            var dataObject = new DataObject();

            dataObject.SetText("Hello", TextDataFormat.UnicodeText);
            dataObject.SetText("Hello", TextDataFormat.Text);
            var entry1 = new ClipboardHookEventArgs(dataObject, false, DateTime.Now.Ticks);

            DispatcherUtil.ExecuteOnDispatcherThread(() => service.ClipboardHook_ClipboardChanged(null, entry1), 100);
            await Task.Delay(300);

            DispatcherUtil.DoEvents();

            Assert.AreEqual(1, dataService.Cache.Count);
            Assert.AreEqual(1, dataService.DataEntries.Count);
            Assert.IsTrue(dataService.Cache.All(cacheDataEntry => cacheDataEntry.Status == DataEntryStatus.Added));

            await cloudStorageService.SynchronizeAsync();

            var cloudDataEntries = await GetDataEntriesFromServerAsync();

            Assert.AreEqual(1, cloudDataEntries.Count);
            Assert.IsTrue(dataService.Cache.All(cacheDataEntry => cacheDataEntry.Status == DataEntryStatus.DidNotChanged));

            var filesOnServer = Directory.GetFiles(cloudStorageProviderMock.TemporaryFolder);

            Assert.AreEqual(3, filesOnServer.Length);

            await dataService.RemoveDataAsync(dataService.DataEntries.First().Identifier, dataService.DataEntries.First().DataIdentifiers);

            Assert.AreEqual(1, dataService.Cache.Count);
            Assert.AreEqual(0, dataService.DataEntries.Count);
            Assert.IsTrue(dataService.Cache.All(cacheDataEntry => cacheDataEntry.Status == DataEntryStatus.Deleted));

            await cloudStorageService.SynchronizeAsync();

            cloudDataEntries = await GetDataEntriesFromServerAsync();

            Assert.AreEqual(0, cloudDataEntries.Count);
            Assert.AreEqual(0, dataService.Cache.Count);

            filesOnServer = Directory.GetFiles(cloudStorageProviderMock.TemporaryFolder);
            Assert.AreEqual(1, filesOnServer.Length);
        }
Beispiel #18
0
        public void PreviewBubbleVisible_OpenFile()
        {
            Open(@"core\PinnedNodeWorkspace.dyn");
            var nodeView = NodeViewWithGuid("c86f23ca-2a32-49b5-97c9-d82504801483");

            nodeView.PreviewControl.RaiseEvent(new RoutedEventArgs(FrameworkElement.LoadedEvent));

            DispatcherUtil.DoEvents();

            Assert.IsTrue(nodeView.PreviewControl.IsExpanded);
        }
Beispiel #19
0
 private async void BitmapImageFailed(object sender, EventArgs e)
 {
     await DispatcherUtil.RunAsync(Dispatcher, () =>
     {
         var handler = ImageFailed;
         if (handler != null)
         {
             handler(this, e);
         }
     });
 }
Beispiel #20
0
        private static ComboBox FindEditorDropDown(ScriptEditorWindow view)
        {
            DispatcherUtil.DoEvents();
            // after simulating the click event get the opened Script editor window
            // and fetch the EngineSelector dropdown
            var windowGrid             = view.Content as Grid;
            var engineSelectorComboBox = windowGrid
                                         .ChildrenOfType <ComboBox>()
                                         .First(x => x.Name == "EngineSelectorComboBox");

            return(engineSelectorComboBox);
        }
        private void RaiseMouseLeaveNode(IInputElement nv)
        {
            View.Dispatcher.Invoke(() =>
            {
                nv.RaiseEvent(new MouseEventArgs(Mouse.PrimaryDevice, 0)
                {
                    RoutedEvent = Mouse.MouseLeaveEvent
                });
            });

            DispatcherUtil.DoEvents();
        }
Beispiel #22
0
        private void tagGeometryWhenClickingItem(int[] indexes, int expectedNumberOfLabels,
                                                 string nodeNickName, Func <NodeView, NodeModel> getGeometryOwnerNode, bool expandPreviewBubble = false)
        {
            OpenVisualizationTest("MAGN_3815.dyn");
            RunCurrentModel();
            DispatcherUtil.DoEvents();
            Assert.AreEqual(3, Model.CurrentWorkspace.Nodes.Count());
            var nodeView = View.ChildrenOfType <NodeView>().First(nv => nv.ViewModel.NickName == nodeNickName);

            Assert.IsNotNull(nodeView, "NodeView has not been found by given nickname: " + nodeNickName);

            if (expandPreviewBubble)
            {
                nodeView.PreviewControl.RaiseEvent(new RoutedEventArgs(FrameworkElement.LoadedEvent));
                View.Dispatcher.Invoke(() =>
                {
                    nodeView.PreviewControl.BindToDataSource();
                    nodeView.PreviewControl.TransitionToState(Dynamo.UI.Controls.PreviewControl.State.Condensed);
                    nodeView.PreviewControl.TransitionToState(Dynamo.UI.Controls.PreviewControl.State.Expanded);
                });

                DispatcherUtil.DoEvents();
            }

            var treeViewItem = nodeView.ChildOfType <TreeViewItem>();

            // find TreeViewItem by given index in multi-dimentional array
            foreach (var index in indexes)
            {
                treeViewItem = treeViewItem.ChildrenOfType <TreeViewItem>().ElementAt(index);
            }

            // click on the found TreeViewItem
            View.Dispatcher.Invoke(() =>
            {
                treeViewItem.RaiseEvent(new MouseButtonEventArgs(Mouse.PrimaryDevice, 0, MouseButton.Left)
                {
                    RoutedEvent = Mouse.MouseDownEvent
                });
            });

            DispatcherUtil.DoEvents();

            // check if label has been added to corresponding geometry
            var helix    = ViewModel.BackgroundPreviewViewModel as HelixWatch3DViewModel;
            var labelKey = getGeometryOwnerNode(nodeView).AstIdentifierForPreview.Name + ":text";

            Assert.IsTrue(helix.Model3DDictionary.ContainsKey(labelKey), "Label has not been added to selected geometry item");
            var geometry = (helix.Model3DDictionary[labelKey] as GeometryModel3D).Geometry as BillboardText3D;

            Assert.AreEqual(expectedNumberOfLabels, geometry.TextInfo.Count);
        }
        public void DisplayByGeometryColorHasColoredPointsPreviewToggled()
        {
            OpenVisualizationTest("Display.ByGeometryColorPointsLines.dyn");

            var ws = ViewModel.Model.CurrentWorkspace as HomeWorkspaceModel;

            RunCurrentModel();
            DispatcherUtil.DoEvents();
            //get all points
            var points         = BackgroundPreviewGeometry.OfType <DynamoPointGeometryModel3D>();
            var pointColors    = points.SelectMany(x => x.Geometry.Colors);
            var bluePtsCount   = pointColors.Where(x => x == Colors.Blue.ToColor4()).Count();;
            var yellowPtsCount = pointColors.Where(x => x == new Color3(1, 1, 0).ToColor4()).Count();

            Assert.AreEqual(14896, bluePtsCount);
            Assert.AreEqual(14895, yellowPtsCount);

            var pointDisplayNode = Model.CurrentWorkspace.Nodes.Where(x => x.GUID == Guid.Parse("9af882721af64514883ce7390fcfe523")).First();

            //select
            DynamoSelection.Instance.ClearSelection();
            DynamoSelection.Instance.Selection.Add(pointDisplayNode);
            DispatcherUtil.DoEvents();

            var selectedColorCount = pointColors.Where(x => x == HelixWatch3DNodeViewModel.SelectedMaterial.DiffuseColor).Count();

            Assert.AreEqual(29791, selectedColorCount);

            //disable preview of the pts node
            pointDisplayNode.UpdateValue(new UpdateValueParams("IsVisible", false.ToString()));
            DispatcherUtil.DoEvents();

            Assert.True(BackgroundPreviewGeometry.OfType <DynamoPointGeometryModel3D>()
                        .All(pt => pt.Visibility == System.Windows.Visibility.Hidden));

            pointDisplayNode.UpdateValue(new UpdateValueParams("IsVisible", true.ToString()));
            DispatcherUtil.DoEvents();

            //TODO this is unexpected but matches master behavior.
            //selectedColorCount = pointColors.Where(x => x == HelixWatch3DNodeViewModel.SelectedMaterial.DiffuseColor).Count();
            //Assert.AreEqual(29791, selectedColorCount);

            //deselect
            DynamoSelection.Instance.ClearSelection();
            DispatcherUtil.DoEvents();

            pointColors    = points.SelectMany(x => x.Geometry.Colors);
            bluePtsCount   = pointColors.Where(x => x == Colors.Blue.ToColor4()).Count();;
            yellowPtsCount = pointColors.Where(x => x == new Color3(1, 1, 0).ToColor4()).Count();
            Assert.AreEqual(14896, bluePtsCount);
            Assert.AreEqual(14895, yellowPtsCount);
        }
Beispiel #24
0
        public async Task CloudStorageService_Synchronize_SynchronizedThenCannotSynchronize()
        {
            /*
             * Scenario :
             * We add one real data to the local data and we synchronize. Then we set this data to "cannot synchronize".
             * The data must be removed from the server.
             */

            var dataService              = GetDataService();
            var cloudStorageService      = GetCloudStorageService();
            var cloudStorageProviderMock = GetCloudStorageProviderMock();
            var service = GetClipboardService();

            var dataObject = new DataObject();

            dataObject.SetText("Hello", TextDataFormat.UnicodeText);
            dataObject.SetText("Hello", TextDataFormat.Text);
            var entry1 = new ClipboardHookEventArgs(dataObject, false, DateTime.Now.Ticks);

            DispatcherUtil.ExecuteOnDispatcherThread(() => service.ClipboardHook_ClipboardChanged(null, entry1), 100);
            await Task.Delay(300);

            DispatcherUtil.DoEvents();

            await cloudStorageService.SynchronizeAsync();

            var cloudDataEntries = await GetDataEntriesFromServerAsync();

            Assert.AreEqual(1, cloudDataEntries.Count);
            Assert.AreEqual(1, dataService.DataEntries.Count);
            Assert.AreEqual(1, dataService.Cache.Count);
            Assert.AreEqual(DataEntryStatus.DidNotChanged, dataService.Cache.First().Status);

            var filesOnServer = Directory.GetFiles(cloudStorageProviderMock.TemporaryFolder);

            Assert.AreEqual(3, filesOnServer.Length);

            dataService.DataEntries.First().CanSynchronize = false;

            await cloudStorageService.SynchronizeAsync();

            cloudDataEntries = await GetDataEntriesFromServerAsync();

            Assert.AreEqual(0, cloudDataEntries.Count);
            Assert.AreEqual(1, dataService.DataEntries.Count);
            Assert.AreEqual(1, dataService.Cache.Count);
            Assert.AreEqual(DataEntryStatus.DidNotChanged, dataService.Cache.First().Status);

            filesOnServer = Directory.GetFiles(cloudStorageProviderMock.TemporaryFolder);
            Assert.AreEqual(1, filesOnServer.Length);
            Assert.IsTrue(filesOnServer.First().EndsWith(".clipboard"));
        }
Beispiel #25
0
        public void Watch3D_FirstRun()
        {
            OpenVisualizationTest("FirstRunWatch3D.dyn");

            // Clear the dispatcher to ensure that the
            // view is created.
            DispatcherUtil.DoEvents();

            var view = FindFirstWatch3DNodeView();
            var vm   = view.ViewModel as HelixWatch3DNodeViewModel;

            Assert.AreEqual(vm.SceneItems.Count(), 3);
        }
Beispiel #26
0
        private static ScriptEditorWindow EditPythonCode(NodeView nodeView, DynamoView window)
        {
            DispatcherUtil.DoEvents();
            // get the `Edit...` menu item from the nodes context menu so we can simulate the click event.
            var editMenuItem = nodeView.MainContextMenu
                               .Items
                               .Cast <MenuItem>()
                               .First(x => x.Header.ToString() == "Edit...");

            editMenuItem.RaiseEvent(new RoutedEventArgs(MenuItem.ClickEvent));
            DispatcherUtil.DoEvents();
            return(window.GetChildrenWindowsOfType <ScriptEditorWindow>().First());
        }
Beispiel #27
0
        public void WorkspaceWithMultiplePythonEnginesUpdatesCorrectlyViaContextHandler()
        {
            // open test graph
            Open(@"core\python\WorkspaceWithMultiplePythonEngines.dyn");

            var nodeModels = ViewModel.Model.CurrentWorkspace.Nodes.Where(n => n.NodeType == "PythonScriptNode");
            List <PythonNode> pythonNodes = nodeModels.Cast <PythonNode>().ToList();
            var pynode1     = pythonNodes.ElementAt(0);
            var pynode2     = pythonNodes.ElementAt(1);
            var pynode1view = NodeViewWithGuid("d060e68f-510f-43fe-8990-c2c1ba7e0f80");
            var pynode2view = NodeViewWithGuid("4050d23e-529c-43e9-b614-0506d8adb06b");


            Assert.AreEqual(new List <string> {
                "2.7.9", "2.7.9"
            }, pynode2.CachedValue.GetElements().Select(x => x.Data));

            SetEngineViaContextMenu(pynode1view, PythonEngineVersion.CPython3);

            Assert.IsTrue(ViewModel.Model.CurrentWorkspace.HasUnsavedChanges);
            Assert.AreEqual(new List <string> {
                "3.8.3", "2.7.9"
            }, pynode2.CachedValue.GetElements().Select(x => x.Data));

            SetEngineViaContextMenu(pynode2view, PythonEngineVersion.CPython3);

            Assert.IsTrue(ViewModel.Model.CurrentWorkspace.HasUnsavedChanges);
            Assert.AreEqual(new List <string> {
                "3.8.3", "3.8.3"
            }, pynode2.CachedValue.GetElements().Select(x => x.Data));

            SetEngineViaContextMenu(pynode1view, PythonEngineVersion.IronPython2);
            SetEngineViaContextMenu(pynode2view, PythonEngineVersion.IronPython2);

            Assert.IsTrue(ViewModel.Model.CurrentWorkspace.HasUnsavedChanges);
            Assert.AreEqual(new List <string> {
                "2.7.9", "2.7.9"
            }, pynode2.CachedValue.GetElements().Select(x => x.Data));
            DispatcherUtil.DoEvents();

            Model.CurrentWorkspace.Undo();
            Assert.AreEqual(new List <string> {
                "2.7.9", "3.8.3"
            }, pynode2.CachedValue.GetElements().Select(x => x.Data));
            DispatcherUtil.DoEvents();
            Model.CurrentWorkspace.Undo();
            Assert.AreEqual(new List <string> {
                "3.8.3", "3.8.3"
            }, pynode2.CachedValue.GetElements().Select(x => x.Data));
            DispatcherUtil.DoEvents();
        }
        public void DisplayByGeometryColorHasColoredPointsCanSwitchBetweenMultipleNodesAndSelectionUpdates()
        {
            OpenVisualizationTest("Display.ByGeometryColorPoints_Selection.dyn");

            var ws = ViewModel.Model.CurrentWorkspace as HomeWorkspaceModel;

            RunCurrentModel();
            DispatcherUtil.DoEvents();
            //get all points
            var points      = BackgroundPreviewGeometry.OfType <DynamoPointGeometryModel3D>();
            var pointColors = points.SelectMany(x => x.Geometry.Colors);
            var green       = pointColors.Where(x => x == new Color3(0, 1, 0).ToColor4()).Count();
            var red         = pointColors.Where(x => x == new Color3(1, 0, 0).ToColor4()).Count();

            Assert.AreEqual(1331, green);
            Assert.AreEqual(216, red);

            var redPtsNode   = ws.Nodes.Where(x => x.Name == "red").FirstOrDefault();
            var greenPtsNode = ws.Nodes.Where(x => x.Name == "green").FirstOrDefault();

            //select red node
            DynamoSelection.Instance.ClearSelection();
            DynamoSelection.Instance.Selection.Add(redPtsNode);
            DispatcherUtil.DoEvents();

            //assert no red points.
            pointColors = points.SelectMany(x => x.Geometry.Colors);
            green       = pointColors.Where(x => x == new Color3(0, 1, 0).ToColor4()).Count();
            red         = pointColors.Where(x => x == new Color3(1, 0, 0).ToColor4()).Count();
            Assert.AreEqual(1331, green);
            Assert.AreEqual(0, red);

            //select green node
            DynamoSelection.Instance.ClearSelection();
            DynamoSelection.Instance.Selection.Add(greenPtsNode);
            DispatcherUtil.DoEvents();

            pointColors = points.SelectMany(x => x.Geometry.Colors);
            green       = pointColors.Where(x => x == new Color3(0, 1, 0).ToColor4()).Count();
            red         = pointColors.Where(x => x == new Color3(1, 0, 0).ToColor4()).Count();
            Assert.AreEqual(0, green);
            Assert.AreEqual(216, red);

            //select both
            DynamoSelection.Instance.Selection.Add(redPtsNode);
            pointColors = points.SelectMany(x => x.Geometry.Colors);
            green       = pointColors.Where(x => x == new Color3(0, 1, 0).ToColor4()).Count();
            red         = pointColors.Where(x => x == new Color3(1, 0, 0).ToColor4()).Count();
            Assert.AreEqual(0, green);
            Assert.AreEqual(0, red);
        }
Beispiel #29
0
        public void ZIndex_NodeAsMemberOfGroup()
        {
            // Reset zindex to start value.
            Dynamo.ViewModels.NodeViewModel.StaticZIndex = 3;
            Open(@"UI\CoreUINodes.dyn");

            var nodeView = NodeViewWithGuid("b8c2a62f-f1ce-4327-8d98-c4e0cc0ebed4");

            //Select the node for group
            DynamoSelection.Instance.Selection.Add(nodeView.ViewModel.NodeModel);

            //Create a Group around that node
            ViewModel.AddAnnotationCommand.Execute(null);
            var annotation = ViewModel.HomeSpaceViewModel.Annotations.First();

            Assert.IsNotNull(annotation);

            // Index of first node == 4.
            Assert.AreEqual(4, nodeView.ViewModel.ZIndex);
            Assert.AreEqual(3 + ViewModel.HomeSpace.Nodes.Count(), Dynamo.ViewModels.NodeViewModel.StaticZIndex);

            var dispatcherOperation = View.Dispatcher.BeginInvoke(new Action(
                                                                      () => nodeView.RaiseEvent(new MouseEventArgs(Mouse.PrimaryDevice, 0)
            {
                RoutedEvent = Mouse.MouseEnterEvent
            })));

            DispatcherUtil.DoEvents();

            dispatcherOperation.Completed += (s, args) =>
            {
                // After mouse enter node should have The highest index.
                Assert.AreEqual(nodeView.ViewModel.ZIndex, Dynamo.ViewModels.NodeViewModel.StaticZIndex);
                Assert.AreEqual(2, annotation.ZIndex);
            };

            dispatcherOperation = View.Dispatcher.BeginInvoke(new Action(
                                                                  () => nodeView.RaiseEvent(new MouseEventArgs(Mouse.PrimaryDevice, 0)
            {
                RoutedEvent = Mouse.MouseLeaveEvent
            })));
            DispatcherUtil.DoEvents();

            dispatcherOperation.Completed += (s, args) =>
            {
                // After mouse leave node should have the old index.
                Assert.AreEqual(4, nodeView.ViewModel.ZIndex);
                Assert.AreEqual(2, annotation.ZIndex);
            };
        }
Beispiel #30
0
        private void RightClick(IInputElement element)
        {
            element.RaiseEvent(new MouseButtonEventArgs(Mouse.PrimaryDevice, 0, MouseButton.Right)
            {
                RoutedEvent = Mouse.MouseDownEvent
            });

            element.RaiseEvent(new MouseButtonEventArgs(Mouse.PrimaryDevice, 0, MouseButton.Right)
            {
                RoutedEvent = Mouse.MouseUpEvent
            });

            DispatcherUtil.DoEvents();
        }