Esempio n. 1
0
 private void WaitForAppReady(RHostClientHelpTestApp clientApp)
 {
     for (int i = 0; i < 100 && !clientApp.Ready; i++)
     {
         DoIdle(200);
     }
 }
Esempio n. 2
0
 private void ShowHelp(string command, VsRHostScript hostScript, RHostClientHelpTestApp clientApp) {
     clientApp.Ready = false;
     using (var request = hostScript.Session.BeginInteractionAsync().Result) {
         request.RespondAsync(command).SilenceException<RException>();
     }
     WaitForAppReady(clientApp);
 }
Esempio n. 3
0
 private async Task ExecCommandAsync(RHostClientHelpTestApp clientApp, int commandId) {
     await UIThreadHelper.Instance.InvokeAsync(() => {
         object o = new object();
         clientApp.Component.Controller.Invoke(RGuidList.RCmdSetGuid, commandId, null, ref o);
     });
     clientApp.Ready.Wait(5000);
 }
Esempio n. 4
0
        private async Task ShowHelpAsync(string command, VsRHostScript hostScript, RHostClientHelpTestApp clientApp)
        {
            clientApp.Reset();
            await hostScript.Session.ExecuteAsync($"rtvs:::show_help({command.ToRStringLiteral()})").SilenceException <RException>();

            await clientApp.WaitForReadyAndRenderedAsync(DoIdle, nameof(HelpTest));
        }
Esempio n. 5
0
        private async Task ExecCommandAsync(RHostClientHelpTestApp clientApp, IAsyncCommand command)
        {
            clientApp.Reset();
            await UIThreadTools.InUI(command.InvokeAsync);

            await clientApp.WaitForReadyAndRenderedAsync(DoIdle, nameof(HelpTest));
        }
Esempio n. 6
0
 private void ShowHelp(string command, VsRHostScript hostScript, RHostClientHelpTestApp clientApp)
 {
     clientApp.Ready = false;
     hostScript.Session.ExecuteAsync($"rtvs:::show_help({command.ToRStringLiteral()})")
     .SilenceException <RException>()
     .DoNotWait();
     WaitForAppReady(clientApp);
 }
Esempio n. 7
0
 private void ExecCommand(RHostClientHelpTestApp clientApp, int commandId) {
     UIThreadHelper.Instance.Invoke(() => {
         clientApp.Ready = false;
         object o = new object();
         clientApp.Component.Controller.Invoke(RGuidList.RCmdSetGuid, commandId, null, ref o);
     });
     WaitForAppReady(clientApp);
 }
Esempio n. 8
0
 private void ShowHelp(string command, VsRHostScript hostScript, RHostClientHelpTestApp clientApp)
 {
     clientApp.Ready = false;
     using (var request = hostScript.Session.BeginInteractionAsync().Result) {
         request.RespondAsync(command).SilenceException <RException>();
     }
     WaitForAppReady(clientApp);
 }
Esempio n. 9
0
 private void ExecCommand(RHostClientHelpTestApp clientApp, int commandId)
 {
     UIThreadHelper.Instance.Invoke(() => {
         clientApp.Ready = false;
         object o        = new object();
         clientApp.Component.Controller.Invoke(RGuidList.RCmdSetGuid, commandId, null, ref o);
     });
     WaitForAppReady(clientApp);
 }
Esempio n. 10
0
        private async Task ExecCommandAsync(RHostClientHelpTestApp clientApp, int commandId)
        {
            clientApp.Reset();
            await UIThreadHelper.Instance.InvokeAsync(() => {
                object o = new object();
                clientApp.Component.Controller.Invoke(RGuidList.RCmdSetGuid, commandId, null, ref o);
            });

            await clientApp.WaitForReadyAndRenderedAsync((ms) => DoIdle(ms), nameof(HelpTest));
        }
Esempio n. 11
0
        private async Task<string> GetBackgroundColorAsync(IHelpVisualComponent component, RHostClientHelpTestApp clientApp) {
            string color = "red";

            await WaitForReadyAndRenderedAsync(clientApp);
            await UIThreadHelper.Instance.InvokeAsync(() => {
                IHTMLElement2 body = component.Browser.Document.Body.DomElement as IHTMLElement2;
                color = body.currentStyle.backgroundColor as string;
            });

            return color;
        }
Esempio n. 12
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");
                }
            }
        }
Esempio n. 13
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");

                }
            }
        }
Esempio n. 14
0
        public async Task HelpTest()
        {
            var clientApp = new RHostClientHelpTestApp();
            await HostScript.InitializeAsync(clientApp);

            using (new ControlTestScript(typeof(HelpVisualComponent), _services)) {
                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, new HelpPreviousCommand(component));

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

                await ExecCommandAsync(clientApp, new HelpNextCommand(component));

                clientApp.Uri.PathAndQuery.Should().Be("/library/stats/html/lm.html");

                await ExecCommandAsync(clientApp, new HelpHomeCommand(VsAppShell.Current.Services));

                clientApp.Uri.PathAndQuery.Should().Be("/doc/html/index.html");
            }
        }
Esempio n. 15
0
        public void HelpTest()
        {
            var clientApp       = new RHostClientHelpTestApp();
            var historyProvider = RHistoryProviderStubFactory.CreateDefault();

            using (var hostScript = new VsRHostScript(clientApp)) {
                using (var script = new ControlTestScript(typeof(HelpWindowVisualComponent))) {
                    DoIdle(100);

                    var activeViewTrackerMock       = new ActiveTextViewTrackerMock("  plot", RContentTypeDefinition.ContentType);
                    var activeReplTrackerMock       = new ActiveRInteractiveWindowTrackerMock();
                    var sessionProvider             = VsAppShell.Current.ExportProvider.GetExportedValue <IRSessionProvider>();
                    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, activeReplTrackerMock);

                    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);
                }
            }
        }
Esempio n. 16
0
        public async Task HelpTest()
        {
            var clientApp = new RHostClientHelpTestApp();
            await HostScript.InitializeAsync(clientApp);

            using (new ControlTestScript(typeof(HelpVisualComponent))) {
                DoIdle(100);

                var activeViewTrackerMock = new ActiveTextViewTrackerMock("  plot", RContentTypeDefinition.ContentType);
                var activeReplTrackerMock = new ActiveRInteractiveWindowTrackerMock();

                var interactiveWorkflow = Substitute.For <IRInteractiveWorkflow>();
                interactiveWorkflow.RSession.Returns(HostScript.Session);

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

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

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

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

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

                    clientApp.Ready.Reset();
                    cmd.Invoke();
                });

                await clientApp.WaitForReadyAndRenderedAsync((ms) => DoIdle(ms), nameof(HelpTest));

                clientApp.Uri.IsLoopback.Should().Be(true);
                clientApp.Uri.PathAndQuery.Should().Be("/library/graphics/html/plot.html");
            }
        }
Esempio n. 17
0
        public async Task HelpTest() {
            var clientApp = new RHostClientHelpTestApp();
            await HostScript.InitializeAsync(clientApp);
            using (new ControlTestScript(typeof(HelpVisualComponent))) {
                DoIdle(100);

                var activeViewTrackerMock = new ActiveTextViewTrackerMock("  plot", RContentTypeDefinition.ContentType);
                var activeReplTrackerMock = new ActiveRInteractiveWindowTrackerMock();

                var interactiveWorkflow = Substitute.For<IRInteractiveWorkflow>();
                interactiveWorkflow.RSession.Returns(HostScript.Session);

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

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

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

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

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

                    clientApp.Ready.Reset();
                    cmd.Invoke();
                });

                await WaitForReadyAndRenderedAsync(clientApp);

                clientApp.Uri.IsLoopback.Should().Be(true);
                clientApp.Uri.PathAndQuery.Should().Be("/library/graphics/html/plot.html");
            }
        }
Esempio n. 18
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");
            }
        }
Esempio n. 19
0
        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);
                }
            }
        }
Esempio n. 20
0
 private async Task ShowHelpAsync(string command, VsRHostScript hostScript, RHostClientHelpTestApp clientApp) {
     clientApp.Ready.Reset();
     await hostScript.Session.ExecuteAsync($"rtvs:::show_help({command.ToRStringLiteral()})").SilenceException<RException>();
     await WaitForReadyAndRenderedAsync(clientApp);
 }
Esempio n. 21
0
 private void WaitForAppReady(RHostClientHelpTestApp clientApp) {
     for (int i = 0; i < 100 && !clientApp.Ready; i++) {
         DoIdle(200);
     }
 }
Esempio n. 22
0
        private async Task <string> GetBackgroundColorAsync(IHelpVisualComponent component, RHostClientHelpTestApp clientApp)
        {
            string color = "red";

            await clientApp.WaitForReadyAndRenderedAsync(DoIdle, nameof(HelpTest));

            await UIThreadHelper.Instance.InvokeAsync(() => {
                IHTMLElement2 body = component.Browser.Document.Body.DomElement as IHTMLElement2;
                color = body.currentStyle.backgroundColor as string;
            });

            return(color);
        }
Esempio n. 23
0
 private async Task WaitForReadyAndRenderedAsync(RHostClientHelpTestApp clientApp) {
     await UIThreadHelper.Instance.InvokeAsync(() => DoIdle(500));
     clientApp.Ready.Wait(5000);
     await UIThreadHelper.Instance.InvokeAsync(() => DoIdle(500));
 }
Esempio n. 24
0
 public override async Task InitializeAsync()
 {
     _clientApp = new RHostClientHelpTestApp();
     await _hostScript.InitializeAsync(_clientApp);
 }