Exemplo n.º 1
0
        public async Task HistoryActivate()
        {
            using (_plotManager.GetOrCreateVisualComponent(_plotHistoryVisualComponentContainerFactory, 0)) {
                var plot1to10 = await GetExpectedImageAsync("bmp", 600, 500, 96, "plot1-10", "plot(1:10)");

                var plot2to10 = await GetExpectedImageAsync("bmp", 600, 500, 96, "plot2-10", "plot(2:10)");

                await InitializeGraphicsDevice();
                await ExecuteAndWaitForPlotsAsync(new string[] {
                    "plot(1:10)",
                    "plot(2:10)",
                });

                var deviceVC        = _plotManager.GetPlotVisualComponent(_plotManager.ActiveDevice);
                var historyVC       = _plotManager.HistoryVisualComponent;
                var historyCommands = new RPlotHistoryCommands(_workflow, historyVC);

                historyCommands.ActivatePlot.Should().BeDisabled();

                // Select and activate the first plot
                historyVC.SelectedPlots = new[] { _plotManager.ActiveDevice.GetPlotAt(0) };
                historyCommands.ActivatePlot.Should().BeEnabled();
                var plotReceivedTask = EventTaskSources.IRPlotDevice.PlotAddedOrUpdated.Create(_plotManager.ActiveDevice);
                await historyCommands.ActivatePlot.InvokeAsync();

                await plotReceivedTask;

                var bs = _plotManager.ActiveDevice.ActivePlot.Image as BitmapSource;
                bs.Should().HaveSamePixels(plot1to10);

                _ui.LastShownErrorMessage.Should().BeNullOrEmpty();
            }
        }
Exemplo n.º 2
0
        public async Task ResizePlotError()
        {
            using (_plotVisual.GetOrCreateVisualComponent(_plotHistoryVisualComponentContainerFactory, 0)) {
                await _workflow.RSession.HostStarted.Should().BeCompletedAsync(50000);
                await InitializeGraphicsDevice();
                await ExecuteAndWaitForPlotsAsync(new string[] {
                    "plot(mtcars)",
                });

                var plotVC = _plotVisual.GetPlotVisualComponent(_plotVisual.ActiveDevice);

                var expectedSize = GetPixelSize(600, 500);
                var bs           = _plotVisual.ActiveDevice.ActivePlot.Image as BitmapSource;
                bs.PixelWidth.Should().Be((int)expectedSize.Width);
                bs.PixelHeight.Should().Be((int)expectedSize.Height);

                var plotReceivedTask = EventTaskSources.IRPlotDevice.PlotAddedOrUpdated.Create(_plotVisual.ActiveDevice);

                // mtcars cannot be rendered at 200
                _plotVisualComponent.Control.Width = 200;

                await plotReceivedTask;

                _plotVisual.ActiveDevice.ActivePlot.Image.Should().BeNull();

                // Plot history should have only one entry after a plot rendered ok followed by error
                var historyVC = (RPlotHistoryVisualComponent)_plotVisual.HistoryVisualComponent;
                var historyVM = (RPlotHistoryViewModel)historyVC.Control.DataContext;
                historyVM.Entries.Count.Should().Be(1);
                historyVM.Entries[0].PlotImage.Should().NotBeNull();
            }
        }