public void RunBrowserTest(WebBrowserRole role, Guid guid, string title, IRToolsSettings externalSettings, IRToolsSettings internalSettings) { var shell = Substitute.For <ICoreShell>(); var ps = Substitute.For <IProcessServices>(); var vswbs = Substitute.For <IVsWebBrowsingService>(); shell.Process().Returns(ps); shell.GetService <IVsWebBrowsingService>(typeof(SVsWebBrowsingService)).Returns(vswbs); var wbs = new WebBrowserServices(shell); wbs.OpenBrowser(role, _url); shell.Process().Received().Start(_url); ps.ClearReceivedCalls(); wbs = new WebBrowserServices(shell); wbs.OpenBrowser(role, _url); UIThreadHelper.Instance.DoEvents(); shell.Process().DidNotReceive().Start(_url); IVsWebBrowser vswb; IVsWindowFrame frame; vswbs.Received().CreateWebBrowser(Arg.Any <uint>(), guid, title, _url, null, out vswb, out frame); }
public void RunBrowserTest(WebBrowserRole role, Guid guid, string title, IRSettings externalSettings, IRSettings internalSettings) { var shell = TestCoreShell.CreateSubstitute(); var vswbs = Substitute.For <IVsWebBrowsingService>(); shell.ServiceManager .AddService(vswbs, typeof(SVsWebBrowsingService)) .AddService(externalSettings); var ps = shell.GetService <IProcessServices>(); var wbs = new WebBrowserServices(shell); wbs.OpenBrowser(role, _url); ps.Received().Start(_url); ps.ClearReceivedCalls(); shell.ServiceManager.RemoveService <IRSettings>(); shell.ServiceManager.AddService(internalSettings); wbs = new WebBrowserServices(shell); wbs.OpenBrowser(role, _url); UIThreadHelper.Instance.DoEvents(); ps.DidNotReceive().Start(_url); vswbs.Received().CreateWebBrowser(Arg.Any <uint>(), guid, title, _url, null, out var vswb, out var frame); }
private void NavigateOnIdle(WebBrowserRole role, string url) { if (!string.IsNullOrEmpty(url)) { IdleTimeAction.Create(() => { OpenVsBrowser(role, url); }, 100, typeof(WebBrowserServices), VsAppShell.Current); } }
private void NavigateOnIdle(WebBrowserRole role, string url) { if (!string.IsNullOrEmpty(url)) { IdleTimeAction.Create(() => { OpenVsBrowser(role, url); }, 100, typeof(WebBrowserServices), _coreShell.GetService <IIdleTimeService>()); } }
private Guid GetRoleGuid(WebBrowserRole role) { switch(role) { case WebBrowserRole.Help: return RGuidList.WebHelpWindowGuid; case WebBrowserRole.Shiny: return RGuidList.ShinyWindowGuid; case WebBrowserRole.Markdown: return RGuidList.MarkdownWindowGuid; } return Guid.Empty; }
public void OpenBrowser(WebBrowserRole role, string url, bool onIdle = false) { if(role == WebBrowserRole.External || IsExternal(role)) { _ps.Start(url); } else { if (onIdle) { NavigateOnIdle(role, url); } else { OpenVsBrowser(role, url); } } }
private void DoOpenVsBrowser(WebBrowserRole role, string url) { IVsWindowFrame frame; IVsWebBrowser wb; var guid = GetRoleGuid(role); if(guid == Guid.Empty) { WebBrowserService.Navigate(url, (uint)__VSWBNAVIGATEFLAGS.VSNWB_ForceNew, out frame); } else { var flags = (uint)(__VSCREATEWEBBROWSER.VSCWB_AutoShow | __VSCREATEWEBBROWSER.VSCWB_ForceNew | __VSCREATEWEBBROWSER.VSCWB_StartCustom | __VSCREATEWEBBROWSER.VSCWB_ReuseExisting); var title = GetRoleWindowTitle(role); WebBrowserService.CreateWebBrowser(flags, guid, title, url, null, out wb, out frame); } }
public RoleWindow(string html) { InitializeComponent(); WebBrowserZoomInvoker.AddZoomInvoker(WebBrowserRole); bool loaded = false; WebBrowserRole.LoadCompleted += (sender, args) => { if (!loaded) { WebBrowserRole.NavigateToString(html); loaded = true; } }; }
private bool IsExternal(WebBrowserRole role) { switch (role) { case WebBrowserRole.Help: return(Settings.WebHelpSearchBrowserType == BrowserType.External); case WebBrowserRole.Shiny: return(Settings.HtmlBrowserType == BrowserType.External); case WebBrowserRole.Markdown: return(Settings.MarkdownBrowserType == BrowserType.External); } return(false); }
private Guid GetRoleGuid(WebBrowserRole role) { switch (role) { case WebBrowserRole.Help: return(RGuidList.WebHelpWindowGuid); case WebBrowserRole.Shiny: return(RGuidList.ShinyWindowGuid); case WebBrowserRole.Markdown: return(RGuidList.MarkdownWindowGuid); } return(Guid.Empty); }
public void OpenBrowser(WebBrowserRole role, string url, bool onIdle = false) { if (role == WebBrowserRole.External || IsExternal(role)) { _ps.Start(url); } else { if (onIdle) { NavigateOnIdle(role, url); } else { OpenVsBrowser(role, url); } } }
private string GetRoleWindowTitle(WebBrowserRole role) { switch (role) { case WebBrowserRole.Help: return(Resources.WebHelpWindowTitle); case WebBrowserRole.News: return(Resources.NewsWindowTitle); case WebBrowserRole.Shiny: return(Resources.ShinyWindowTitle); case WebBrowserRole.Markdown: return(Resources.MarkdownWindowTitle); } return(null); }
public void RunBrowserTest(WebBrowserRole role, Guid guid, string title, IRToolsSettings externalSettings, IRToolsSettings internalSettings) { var vswbs = Substitute.For<IVsWebBrowsingService>(); var ps = Substitute.For<IProcessServices>(); var wbs = new WebBrowserServices(vswbs, ps, externalSettings); wbs.OpenBrowser(role, _url); ps.Received().Start(_url); ps.ClearReceivedCalls(); wbs = new WebBrowserServices(vswbs, ps, internalSettings); wbs.OpenBrowser(role, _url); UIThreadHelper.Instance.DoEvents(); ps.DidNotReceive().Start(_url); IVsWebBrowser vswb; IVsWindowFrame frame; vswbs.Received().CreateWebBrowser(Arg.Any<uint>(), guid, title, _url, null, out vswb, out frame); }
private void DoOpenVsBrowser(WebBrowserRole role, string url) { IVsWindowFrame frame; IVsWebBrowser wb; var guid = GetRoleGuid(role); if (guid == Guid.Empty) { WebBrowserService.Navigate(url, (uint)__VSWBNAVIGATEFLAGS.VSNWB_ForceNew, out frame); } else { var flags = (uint)(__VSCREATEWEBBROWSER.VSCWB_AutoShow | __VSCREATEWEBBROWSER.VSCWB_ForceNew | __VSCREATEWEBBROWSER.VSCWB_StartCustom | __VSCREATEWEBBROWSER.VSCWB_ReuseExisting); var title = GetRoleWindowTitle(role); WebBrowserService.CreateWebBrowser(flags, guid, title, url, null, out wb, out frame); } }
public void RunBrowserTest(WebBrowserRole role, Guid guid, string title, IRToolsSettings externalSettings, IRToolsSettings internalSettings) { var vswbs = Substitute.For <IVsWebBrowsingService>(); var ps = Substitute.For <IProcessServices>(); var wbs = new WebBrowserServices(vswbs, ps, externalSettings); wbs.OpenBrowser(role, _url); ps.Received().Start(_url); ps.ClearReceivedCalls(); wbs = new WebBrowserServices(vswbs, ps, internalSettings); wbs.OpenBrowser(role, _url); ps.DidNotReceive().Start(_url); IVsWebBrowser vswb; IVsWindowFrame frame; vswbs.Received().CreateWebBrowser(Arg.Any <uint>(), guid, title, _url, null, out vswb, out frame); }
private string GetRoleWindowTitle(WebBrowserRole role) { switch (role) { case WebBrowserRole.Help: return Resources.WebHelpWindowTitle; case WebBrowserRole.News: return Resources.NewsWindowTitle; case WebBrowserRole.Shiny: return Resources.ShinyWindowTitle; case WebBrowserRole.Markdown: return Resources.MarkdownWindowTitle; } return null; }
private void OpenVsBrowser(WebBrowserRole role, string url) { VsAppShell.Current.DispatchOnUIThread(() => { DoOpenVsBrowser(role, url); }); }
private void Window_Closed(object sender, EventArgs e) { WebBrowserRole.Dispose(); }
private void OpenVsBrowser(WebBrowserRole role, string url) { _coreShell.MainThread().Post(() => { DoOpenVsBrowser(role, url); }); }
private bool IsExternal(WebBrowserRole role) { switch (role) { case WebBrowserRole.Help: return Settings.WebHelpSearchBrowserType == BrowserType.External; case WebBrowserRole.Shiny: return Settings.HtmlBrowserType == BrowserType.External; case WebBrowserRole.Markdown: return Settings.MarkdownBrowserType == BrowserType.External; } return false; }