public NavigateIfIdle ( Gecko.GeckoWebBrowser browser, string url ) : bool | ||
browser | Gecko.GeckoWebBrowser | |
url | string | |
return | bool |
public void IdleNavigation_WhenNothingHappening_ProceedsAtOnce() { var browser = new BrowserStub(); string target = "http://any old web address"; var isolator = new NavigationIsolator(); Assert.That(isolator.NavigateIfIdle(browser, target), Is.True); Assert.That(browser.NavigateTarget, Is.EqualTo(target)); browser.NormalTermination(); Assert.That(browser.EventHandlerCount, Is.EqualTo(0), "event handlers should be removed after navigation completes"); }
public void IdleNavigation_NavigationInProgress_ReturnsFalse_NeverProceeds() { var browser = new BrowserStub(); string target = "http://any old web address"; var isolator = new NavigationIsolator(); isolator.Navigate(browser, target); Assert.That(browser.NavigateTarget, Is.EqualTo(target)); string target2 = "http://some other web address"; Assert.That(isolator.NavigateIfIdle(browser, target2), Is.False); browser.NormalTermination(); Assert.That(browser.EventHandlerCount, Is.EqualTo(0), "event handlers should be removed after navigation completes"); Assert.That(browser.NavigateTarget, Is.EqualTo(target), "failed idle navigation should not happen"); }
public void RegularNavigation_DelayedProperlyByIdleNavigation() { var browser = new BrowserStub(); string target = "http://any old web address"; var isolator = new NavigationIsolator(); Assert.That(isolator.NavigateIfIdle(browser, target), Is.True); Assert.That(browser.NavigateTarget, Is.EqualTo(target)); string target2 = "http://some other web address"; isolator.Navigate(browser, target2); Assert.That(browser.NavigateTarget, Is.EqualTo(target), "Second navigation should not have proceeded at once"); browser.NormalTermination(); Assert.That(browser.NavigateTarget, Is.EqualTo(target2), "Second navigation should have proceeded when first completed"); browser.NormalTermination(); Assert.That(browser.EventHandlerCount, Is.EqualTo(0), "event handlers should be removed once last navigation completed"); }
public void SingleTask_AfterLongDelay_AllowsIdleNavigation() { var browser = new BrowserStub(); string target = "http://any old web address"; var isolator = new NavigationIsolator(); isolator.Navigate(browser, target); Assert.That(browser.NavigateTarget, Is.EqualTo(target)); string target2 = "http://some other web address"; var start = DateTime.Now; var success = false; while (!success && DateTime.Now - start < new TimeSpan(0, 0, 0, 2, 300)) { success = isolator.NavigateIfIdle(browser, target2); Application.DoEvents(); // allow timer to tick. } Assert.That(() => browser.NavigateTarget, Is.EqualTo(target2), "Idle navigation should have proceeded eventually"); Assert.That(success, "NavigateIfIdle should eventually succeed"); browser.NormalTermination(); // possibly the long-delayed notification of the first nav, but more likely the idle navigation. Assert.That(browser.EventHandlerCount, Is.EqualTo(0), "event handlers should be removed once last navigation completed"); }