Наследование: Microsoft.R.Host.Client.Test.Script.RHostScript
Пример #1
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);
 }
Пример #2
0
        public void DefaultDirectoryTest() {
            string myDocs = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            string actual;
            using (var script = new VsRHostScript(_sessionProvider)) {
                var cmd = new WorkingDirectoryCommand(_interactiveWorkflow);
                cmd.InitializationTask.Wait();
                cmd.UserDirectory.Should().BeEquivalentTo(myDocs);
                actual = script.Session.GetRWorkingDirectoryAsync().Result;
            };

            actual.Should().Be(myDocs);
        }
Пример #3
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");

                }
            }
        }
Пример #4
0
        public async Task ValidateEncodings() {
            var etc = new EncodingTypeConverter();
            var codePages = etc.GetStandardValues();
            using (var sessionProvider = new RSessionProvider(TestCoreServices.CreateReal())) {
                await sessionProvider.TrySwitchBrokerAsync(nameof(ValidateEncodings));
                using (var script = new VsRHostScript(sessionProvider)) {
                    foreach (var cp in codePages) {
                        if ((int)cp > 0) {
                            var expression = Invariant($"Sys.setlocale('LC_CTYPE', '.{cp}')\n");
                            using (var inter = await script.Session.BeginInteractionAsync()) {
                                await inter.RespondAsync(expression);
                            }

                            var res = await script.Session.EvaluateAsync("Sys.getlocale()", REvaluationKind.Normal);
                            var s = res.Result.ToString();

                            s.Should().NotBeNull().And.Contain(cp.ToString());
                        }
                    }
                }
            }
        }
Пример #5
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);
 }
Пример #6
0
 public HostBasedInteractiveTest(bool async, IRSessionCallback callback = null) {
     HostScript = new VsRHostScript(SessionProvider, async, callback);
 }