예제 #1
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));
        }
예제 #2
0
        private async Task ExecCommandAsync(RHostClientHelpTestApp clientApp, IAsyncCommand command)
        {
            clientApp.Reset();
            await UIThreadTools.InUI(command.InvokeAsync);

            await clientApp.WaitForReadyAndRenderedAsync(DoIdle, nameof(HelpTest));
        }
예제 #3
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));
        }
예제 #4
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);
        }
예제 #5
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");
            }
        }