diff options
author | jknotten@chromium.org <jknotten@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-24 08:57:13 +0000 |
---|---|---|
committer | jknotten@chromium.org <jknotten@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-24 08:57:13 +0000 |
commit | f51411b225a29bfb3d97fc011fc181c2f2ddf021 (patch) | |
tree | e273d72719a3879e5b0daac5281ef4bb1035d66d /chrome/test/automation | |
parent | 34c2eee08d599451fb1d63af28944e9d355f1c92 (diff) | |
download | chromium_src-f51411b225a29bfb3d97fc011fc181c2f2ddf021.zip chromium_src-f51411b225a29bfb3d97fc011fc181c2f2ddf021.tar.gz chromium_src-f51411b225a29bfb3d97fc011fc181c2f2ddf021.tar.bz2 |
Improve flaky ui_test AutomationProxyVisibleTest.AutocompleteMatchesTest
The omnibox requires that it is focused before text input to it will
kick off the autocompletion providers. We add code
(edit->WaitForFocus()) to the test to wait for the focus to be obtained
before setting the omnibox’s text input and proceeding with the rest of
the test.
BUG=19876
TEST=Existing
Review URL: http://codereview.chromium.org/3348021
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@60443 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/automation')
4 files changed, 27 insertions, 23 deletions
diff --git a/chrome/test/automation/autocomplete_edit_proxy.cc b/chrome/test/automation/autocomplete_edit_proxy.cc index 59c64ba..5bfd13c 100644 --- a/chrome/test/automation/autocomplete_edit_proxy.cc +++ b/chrome/test/automation/autocomplete_edit_proxy.cc @@ -20,23 +20,27 @@ bool AutocompleteEditProxy::GetText(std::wstring* text) const { NOTREACHED(); return false; } - bool result = false; - - sender_->Send(new AutomationMsg_AutocompleteEditGetText(0, handle_, &result, - text)); - + sender_->Send(new AutomationMsg_AutocompleteEditGetText( + 0, handle_, &result, text)); return result; } -bool AutocompleteEditProxy::SetText(const std::wstring& text) { +bool AutocompleteEditProxy::WaitForFocus() const { if (!is_valid()) return false; + bool edit_exists = false; + sender_->Send(new AutomationMsg_WaitForAutocompleteEditFocus( + 0, handle_, &edit_exists)); + return edit_exists; +} +bool AutocompleteEditProxy::SetText(const std::wstring& text) { + if (!is_valid()) + return false; bool result = false; - - sender_->Send(new AutomationMsg_AutocompleteEditSetText(0, handle_, text, - &result)); + sender_->Send(new AutomationMsg_AutocompleteEditSetText( + 0, handle_, text, &result)); return result; } @@ -47,18 +51,15 @@ bool AutocompleteEditProxy::IsQueryInProgress(bool* query_in_progress) const { NOTREACHED(); return false; } - bool edit_exists = false; - - sender_->Send( - new AutomationMsg_AutocompleteEditIsQueryInProgress( - 0, handle_, &edit_exists, query_in_progress)); - + sender_->Send(new AutomationMsg_AutocompleteEditIsQueryInProgress( + 0, handle_, &edit_exists, query_in_progress)); return edit_exists; } - bool AutocompleteEditProxy::WaitForQuery(int wait_timeout_ms) const { + // TODO(jknotten): use a delayed message / observer instead. + // See, for example, AutocompleteEditProxy::WaitForFocus. const TimeTicks start = TimeTicks::Now(); const TimeDelta timeout = TimeDelta::FromMilliseconds(wait_timeout_ms); bool query_in_progress; @@ -78,11 +79,8 @@ bool AutocompleteEditProxy::GetAutocompleteMatches(Matches* matches) const { NOTREACHED(); return false; } - bool edit_exists = false; - sender_->Send(new AutomationMsg_AutocompleteEditGetMatches( 0, handle_, &edit_exists, matches)); - return edit_exists; } diff --git a/chrome/test/automation/autocomplete_edit_proxy.h b/chrome/test/automation/autocomplete_edit_proxy.h index 04f63d9..cfcf291 100644 --- a/chrome/test/automation/autocomplete_edit_proxy.h +++ b/chrome/test/automation/autocomplete_edit_proxy.h @@ -142,6 +142,9 @@ class AutocompleteEditProxy : public AutomationResourceProxy { // Gets a list of autocomplete matches that have been gathered so far. bool GetAutocompleteMatches(Matches* matches) const; + // Waits for the autocomplete edit to receive focus. + bool WaitForFocus() const; + // Waits for all queries to autocomplete providers to complete. // |wait_timeout_ms| gives the number of milliseconds to wait for the query // to finish. Returns false if IPC call failed or if the function times out. diff --git a/chrome/test/automation/automation_messages_internal.h b/chrome/test/automation/automation_messages_internal.h index 2664ee6..537067f 100644 --- a/chrome/test/automation/automation_messages_internal.h +++ b/chrome/test/automation/automation_messages_internal.h @@ -1436,4 +1436,9 @@ IPC_BEGIN_MESSAGES(Automation) int /* target count */, bool /* success */) + // Waits for the autocomplete edit to receive focus. + IPC_SYNC_MESSAGE_ROUTED1_1(AutomationMsg_WaitForAutocompleteEditFocus, + int /* autocomplete edit handle */, + bool /* success */) + IPC_END_MESSAGES(Automation) diff --git a/chrome/test/automation/automation_proxy_uitest.cc b/chrome/test/automation/automation_proxy_uitest.cc index 614f37b..8c19ac7 100644 --- a/chrome/test/automation/automation_proxy_uitest.cc +++ b/chrome/test/automation/automation_proxy_uitest.cc @@ -1353,9 +1353,6 @@ TEST_F(AutomationProxyTest, AutocompleteParallelProxy) { #if defined(OS_MACOSX) // TODO(port): Implement AutocompleteEditProxy on Mac. #define AutocompleteMatchesTest DISABLED_AutocompleteMatchesTest -#else -// So flaky, http://crbug.com/19876. -#define AutocompleteMatchesTest FLAKY_AutocompleteMatchesTest #endif TEST_F(AutomationProxyVisibleTest, AutocompleteMatchesTest) { scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); @@ -1363,8 +1360,9 @@ TEST_F(AutomationProxyVisibleTest, AutocompleteMatchesTest) { scoped_refptr<AutocompleteEditProxy> edit( browser->GetAutocompleteEdit()); ASSERT_TRUE(edit.get()); - EXPECT_TRUE(browser->ApplyAccelerator(IDC_FOCUS_LOCATION)); EXPECT_TRUE(edit->is_valid()); + EXPECT_TRUE(browser->ApplyAccelerator(IDC_FOCUS_LOCATION)); + ASSERT_TRUE(edit->WaitForFocus()); EXPECT_TRUE(edit->SetText(L"Roflcopter")); EXPECT_TRUE(edit->WaitForQuery(action_max_timeout_ms())); bool query_in_progress; |