Inheritance: Microsoft.Common.Core.Test.Script.TestScript, IDisposable
        public void VariableGrid_ConstructorTest02() {
            VisualTreeObject actual = null;
            using (var hostScript = new VariableRHostScript()) {
                using (var script = new ControlTestScript(typeof(VariableGridHost))) {
                    DoIdle(100);

                    EvaluationWrapper wrapper = null;
                    Task.Run(async () => {
                        hostScript.VariableProvider.Subscribe(
                            0,
                            "grid.test",
                            (r) => wrapper = new EvaluationWrapper(r));

                        await hostScript.EvaluateAsync("grid.test <- matrix(1:10, 2, 5)");
                    }).Wait();

                    DoIdle(2000);

                    wrapper.Should().NotBeNull();

                    UIThreadHelper.Instance.Invoke(() => {
                        var host = (VariableGridHost)script.Control;
                        host.SetEvaluation(wrapper);
                    });

                    DoIdle(1000);

                    actual = VisualTreeObject.Create(script.Control);
                }
            }
            ViewTreeDump.CompareVisualTrees(_files, actual, "VariableGrid02");
        }
Example #2
0
        public async Task SortTest02() {
            VisualTreeObject actual = null;
            using (var script = new ControlTestScript(typeof(VariableGridHost))) {
                await PrepareControl(_hostScript, script, "grid.test <- mtcars");
                UIThreadHelper.Instance.Invoke(() => {
                    var grid = VisualTreeTestExtensions.FindFirstVisualChildOfType<VisualGrid>(script.Control);

                    var header = VisualTreeTestExtensions.FindFirstVisualChildOfType<HeaderTextVisual>(script.Control); // mpg
                    header = VisualTreeTestExtensions.FindNextVisualSiblingOfType<HeaderTextVisual>(header); // cyl
                    header.Should().NotBeNull();

                    grid.ToggleSort(header, false);
                    DoIdle(200);

                    header = VisualTreeTestExtensions.FindNextVisualSiblingOfType<HeaderTextVisual>(header); // disp
                    header = VisualTreeTestExtensions.FindNextVisualSiblingOfType<HeaderTextVisual>(header); // hp

                    grid.ToggleSort(header, add: true);
                    grid.ToggleSort(header, add: true);
                    DoIdle(200);
                });

                actual = VisualTreeObject.Create(script.Control);
                ViewTreeDump.CompareVisualTrees(_files, actual, "VariableGridSorted02");
            }
        }
Example #3
0
 public async Task ConstructorTest() {
     VisualTreeObject actual = null;
     using (var script = new ControlTestScript(typeof(VariableGridHost))) {
         await PrepareControl(_hostScript, script, "grid.test <- matrix(1:10, 2, 5)");
         actual = VisualTreeObject.Create(script.Control);
         ViewTreeDump.CompareVisualTrees(_files, actual, "VariableGrid02");
     }
 }
Example #4
0
 public async Task SimpleFunctionTest() {
     VisualTreeObject actual = null;
     using (var script = new ControlTestScript(typeof(VariableView))) {
         DoIdle(100);
         await HostScript.Session.ExecuteAsync("x <- lm");
         DoIdle(1000);
         actual = VisualTreeObject.Create(script.Control);
     }
     ViewTreeDump.CompareVisualTrees(_files, actual, "VariableExplorer04");
 }
Example #5
0
 public async Task SortTest01() {
     VisualTreeObject actual = null;
     using (var script = new ControlTestScript(typeof(VariableGridHost))) {
         await PrepareControl(_hostScript, script, "grid.test <- matrix(1:10, 2, 5)");
         var header = VisualTreeTestExtensions.FindFirstVisualChildOfType<HeaderTextVisual>(script.Control);
         var grid = VisualTreeTestExtensions.FindFirstVisualChildOfType<VisualGrid>(script.Control);
         header.Should().NotBeNull();
         await UIThreadHelper.Instance.InvokeAsync(() => {
             grid.ToggleSort(header, false);
             DoIdle(200);
             grid.ToggleSort(header, false);
         });
         DoIdle(200);
         actual = VisualTreeObject.Create(script.Control);
         ViewTreeDump.CompareVisualTrees(_files, actual, "VariableGridSorted01");
     }
 }
Example #6
0
        public void HelpTest() {
            var clientApp = new RHostClientHelpTestApp();
            using (var hostScript = new VsRHostScript(clientApp)) {
                using (var script = new ControlTestScript(typeof(HelpWindowVisualComponent))) {
                    DoIdle(100);

                    var component = ControlWindow.Component as IHelpWindowVisualComponent;
                    component.Should().NotBeNull();

                    component.VisualTheme = "Dark.css";
                    clientApp.Component = component;

                    ShowHelp("?plot\n", hostScript, clientApp);
                    clientApp.Uri.IsLoopback.Should().Be(true);
                    clientApp.Uri.PathAndQuery.Should().Be("/library/graphics/html/plot.html");

                    GetBackgroundColor(component.Browser).Should().Be(darkThemeCssColor);

                    UIThreadHelper.Instance.Invoke(() => {
                        component.Browser.Refresh();
                        WaitForDocumentComplete(component.Browser);
                    });
                    GetBackgroundColor(component.Browser).Should().Be(darkThemeCssColor);

                    component.VisualTheme = "Light.css";
                    ShowHelp("?lm\n", hostScript, clientApp);
                    clientApp.Uri.PathAndQuery.Should().Be("/library/stats/html/lm.html");

                    GetBackgroundColor(component.Browser).Should().Be("white");

                    ExecCommand(clientApp, RPackageCommandId.icmdHelpPrevious);
                    clientApp.Uri.PathAndQuery.Should().Be("/library/graphics/html/plot.html");

                    ExecCommand(clientApp, RPackageCommandId.icmdHelpNext);
                    clientApp.Uri.PathAndQuery.Should().Be("/library/stats/html/lm.html");

                    ExecCommand(clientApp, RPackageCommandId.icmdHelpHome);
                    clientApp.Uri.PathAndQuery.Should().Be("/doc/html/index.html");

                }
            }
        }
Example #7
0
        public async Task HelpTest() {
            var clientApp = new RHostClientHelpTestApp();
            await HostScript.InitializeAsync(clientApp);
            using (var script = new ControlTestScript(typeof(HelpVisualComponent))) {
                DoIdle(100);

                var component = ControlWindow.Component as IHelpVisualComponent;
                component.Should().NotBeNull();

                component.VisualTheme = "Dark.css";
                await UIThreadHelper.Instance.InvokeAsync(() => {
                    clientApp.Component = component;
                });

                await ShowHelpAsync("plot", HostScript, clientApp);

                clientApp.Uri.IsLoopback.Should().Be(true);
                clientApp.Uri.PathAndQuery.Should().Be("/library/graphics/html/plot.html");
                (await GetBackgroundColorAsync(component, clientApp)).Should().Be(darkThemeCssColor);

                component.VisualTheme = "Light.css";
                await ShowHelpAsync("lm", HostScript, clientApp);
                clientApp.Uri.PathAndQuery.Should().Be("/library/stats/html/lm.html");

                (await GetBackgroundColorAsync(component, clientApp)).Should().Be("white");

                await ExecCommandAsync(clientApp, RPackageCommandId.icmdHelpPrevious);
                clientApp.Uri.PathAndQuery.Should().Be("/library/graphics/html/plot.html");

                await ExecCommandAsync(clientApp, RPackageCommandId.icmdHelpNext);
                clientApp.Uri.PathAndQuery.Should().Be("/library/stats/html/lm.html");

                await ExecCommandAsync(clientApp, RPackageCommandId.icmdHelpHome);
                await WaitForReadyAndRenderedAsync(clientApp);
                clientApp.Uri.PathAndQuery.Should().Be("/doc/html/index.html");
            }
        }
        public void HelpTest() {
            var clientApp = new RHostClientHelpTestApp();
            var sessionProvider = VsAppShell.Current.ExportProvider.GetExportedValue<IRSessionProvider>();
            var historyProvider = RHistoryProviderStubFactory.CreateDefault();
            using (var hostScript = new RHostScript(sessionProvider, clientApp)) {
                using (var script = new ControlTestScript(typeof(HelpWindowVisualComponent))) {
                    DoIdle(100);

                    var activeViewTrackerMock = new ActiveTextViewTrackerMock("  plot", RContentTypeDefinition.ContentType);
                    var interactiveWorkflowProvider = TestRInteractiveWorkflowProviderFactory.Create(sessionProvider, activeTextViewTracker: activeViewTrackerMock);
                    var interactiveWorkflow = interactiveWorkflowProvider.GetOrCreate();

                    var component = ControlWindow.Component as IHelpWindowVisualComponent;
                    component.Should().NotBeNull();

                    component.VisualTheme = "Light.css";
                    clientApp.Component = component;

                    var view = activeViewTrackerMock.GetLastActiveTextView(RContentTypeDefinition.ContentType);
                    var cmd = new ShowHelpOnCurrentCommand(interactiveWorkflow, activeViewTrackerMock);

                    cmd.Should().BeVisibleAndDisabled();
                    view.Caret.MoveTo(new SnapshotPoint(view.TextBuffer.CurrentSnapshot, 3));

                    cmd.Should().BeVisibleAndEnabled();
                    cmd.Text.Should().EndWith("plot");

                    cmd.Invoke();
                    WaitForAppReady(clientApp);

                    clientApp.Uri.IsLoopback.Should().Be(true);
                    clientApp.Uri.PathAndQuery.Should().Be("/library/graphics/html/plot.html");

                    DoIdle(500);
                }
            }
        }
Example #9
0
        private async Task PrepareControl(VariableRHostScript hostScript, ControlTestScript script, string expression) {
            DoIdle(100);

            var result = await hostScript.EvaluateAsync(expression);
            VariableViewModel wrapper = new VariableViewModel(result, VsAppShell.Current.ExportProvider.GetExportedValue<IObjectDetailsViewerAggregator>());

            DoIdle(2000);

            wrapper.Should().NotBeNull();

            UIThreadHelper.Instance.Invoke(() => {
                var host = (VariableGridHost)script.Control;
                host.SetEvaluation(wrapper);
            });

            DoIdle(1000);
        }
 public void VariableGrid_ConstructorTest01() {
     using (var script = new ControlTestScript(typeof(VariableGridHost))) {
         var actual = VisualTreeObject.Create(script.Control);
         ViewTreeDump.CompareVisualTrees(_files, actual, "VariableExplorer01");
     }
 }