diff options
author | mmoss@chromium.org <mmoss@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-11 20:33:46 +0000 |
---|---|---|
committer | mmoss@chromium.org <mmoss@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-11 20:33:46 +0000 |
commit | b2f9016277dd867f7d2cd1c7b0be3e3d6ba2bfa3 (patch) | |
tree | d3e3fcb1e00d47f6c41375693812cd4c495a9bd8 /chrome/browser | |
parent | 01eca4a3d31c0302fcbdba1913361ab5dbeec716 (diff) | |
download | chromium_src-b2f9016277dd867f7d2cd1c7b0be3e3d6ba2bfa3.zip chromium_src-b2f9016277dd867f7d2cd1c7b0be3e3d6ba2bfa3.tar.gz chromium_src-b2f9016277dd867f7d2cd1c7b0be3e3d6ba2bfa3.tar.bz2 |
Add option to disable BrowserWindowGtk debounce timer during tests.
This is needed to fix a timing issue in browser_tests
OmniboxApiTest.Basic on the new Lucid builders. The browser window's
configure events are coming in at an unpredictable rate, causing the
debounce timer to expire prematurely, which results in an apparent
window resize/move, which causes the omnibox autocomplete popup to
close, which makes the test think there are no autocomplete results,
giving an error like:
chrome/browser/extensions/extension_omnibox_apitest.cc:129: Failure
Value of: result.size()
Actual: 0
Expected: 5U
BUG=
TEST=browser_tests succeeds on Lucid builders
Review URL: http://codereview.chromium.org/6825010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81147 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/extensions/extension_omnibox_apitest.cc | 12 | ||||
-rw-r--r-- | chrome/browser/ui/gtk/browser_window_gtk.cc | 16 | ||||
-rw-r--r-- | chrome/browser/ui/gtk/browser_window_gtk.h | 11 |
3 files changed, 35 insertions, 4 deletions
diff --git a/chrome/browser/extensions/extension_omnibox_apitest.cc b/chrome/browser/extensions/extension_omnibox_apitest.cc index 34ee945..5daf3a6 100644 --- a/chrome/browser/extensions/extension_omnibox_apitest.cc +++ b/chrome/browser/extensions/extension_omnibox_apitest.cc @@ -22,6 +22,10 @@ #include "chrome/test/ui_test_utils.h" #include "content/common/notification_type.h" +#if defined(TOOLKIT_GTK) +#include "chrome/browser/ui/gtk/browser_window_gtk.h" +#endif + // Basic test is flaky on ChromeOS. // http://crbug.com/52929 #if defined(OS_CHROMEOS) @@ -86,6 +90,14 @@ IN_PROC_BROWSER_TEST_F(OmniboxApiTest, MAYBE_Basic) { LocationBar* location_bar = GetLocationBar(); AutocompleteController* autocomplete_controller = GetAutocompleteController(); +#if defined(TOOLKIT_GTK) + // Disable the timer because, on Lucid at least, it triggers resize/move + // behavior in the browser window, which dismisses the autocomplete popup + // before the results can be read. + static_cast<BrowserWindowGtk*>( + browser()->window())->DisableDebounceTimerForTests(true); +#endif + // Test that our extension's keyword is suggested to us when we partially type // it. { diff --git a/chrome/browser/ui/gtk/browser_window_gtk.cc b/chrome/browser/ui/gtk/browser_window_gtk.cc index ca3509f..43cfae6 100644 --- a/chrome/browser/ui/gtk/browser_window_gtk.cc +++ b/chrome/browser/ui/gtk/browser_window_gtk.cc @@ -278,6 +278,7 @@ BrowserWindowGtk::BrowserWindowGtk(Browser* browser) maximize_after_show_(false), suppress_window_raise_(false), accel_group_(NULL), + debounce_timer_disabled_(false), infobar_arrow_model_(this) { } @@ -1327,10 +1328,11 @@ gboolean BrowserWindowGtk::OnConfigure(GtkWidget* widget, // reconfigure event in a short while. // We don't use Reset() because the timer may not yet be running. // (In that case Stop() is a no-op.) - window_configure_debounce_timer_.Stop(); - window_configure_debounce_timer_.Start(base::TimeDelta::FromMilliseconds( - kDebounceTimeoutMilliseconds), this, - &BrowserWindowGtk::OnDebouncedBoundsChanged); + if (!debounce_timer_disabled_) + window_configure_debounce_timer_.Stop(); + window_configure_debounce_timer_.Start(base::TimeDelta::FromMilliseconds( + kDebounceTimeoutMilliseconds), this, + &BrowserWindowGtk::OnDebouncedBoundsChanged); return FALSE; } @@ -1448,6 +1450,12 @@ bool BrowserWindowGtk::ShouldShowWindowIcon() const { return browser_->SupportsWindowFeature(Browser::FEATURE_TITLEBAR); } +void BrowserWindowGtk::DisableDebounceTimerForTests(bool is_disabled) { + debounce_timer_disabled_ = is_disabled; + if (is_disabled) + window_configure_debounce_timer_.Stop(); +} + void BrowserWindowGtk::AddFindBar(FindBarGtk* findbar) { gtk_floating_container_add_floating( GTK_FLOATING_CONTAINER(render_area_floating_container_), diff --git a/chrome/browser/ui/gtk/browser_window_gtk.h b/chrome/browser/ui/gtk/browser_window_gtk.h index 0dcfa6e..d7509bb 100644 --- a/chrome/browser/ui/gtk/browser_window_gtk.h +++ b/chrome/browser/ui/gtk/browser_window_gtk.h @@ -166,6 +166,10 @@ class BrowserWindowGtk : public BrowserWindow, bool ShouldShowWindowIcon() const; + // This should only be called from tests where the debounce timeout introduces + // timing issues. + void DisableDebounceTimerForTests(bool is_disabled); + // Add the find bar widget to the window hierarchy. void AddFindBar(FindBarGtk* findbar); @@ -499,6 +503,13 @@ class BrowserWindowGtk : public BrowserWindow, scoped_ptr<FullscreenExitBubbleGtk> fullscreen_exit_bubble_; + // If true, the debounce timer won't be used and OnDebounceBoundsChanged won't + // be called. This should only be enabled in tests where the debounce timeout + // introduces timing issues (e.g. in OmniBoxApiTest it dismisses the + // autocomplete popup before the results can be read) and the final window + // position is unimportant. + bool debounce_timer_disabled_; + // The model that tracks the paint state of the arrow for the infobar // directly below the toolbar. InfoBarArrowModel infobar_arrow_model_; |