summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-23 15:35:17 +0000
committerphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-23 15:35:17 +0000
commit9c5eeaca38c8ff13fad449bb9d9a3263aba73c8d (patch)
treee7d55e22cac7740ae3af0a5e25834c31a6d7aa9d /chrome
parent19680aa559a1dc12112a94b09ec60155bb1360c9 (diff)
downloadchromium_src-9c5eeaca38c8ff13fad449bb9d9a3263aba73c8d.zip
chromium_src-9c5eeaca38c8ff13fad449bb9d9a3263aba73c8d.tar.gz
chromium_src-9c5eeaca38c8ff13fad449bb9d9a3263aba73c8d.tar.bz2
Add new, shiny browser test for Autocomplete (Omnibox).
To fix the Omnibox automation flakiness, I first want to be sure how the system behaves in its natural environment. The test is very basic for now. TEST=browser_tests BUG=19876 Review URL: http://codereview.chromium.org/193069 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26924 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/autocomplete/autocomplete.h2
-rw-r--r--chrome/browser/autocomplete/autocomplete_browsertest.cc95
-rw-r--r--chrome/chrome.gyp1
3 files changed, 98 insertions, 0 deletions
diff --git a/chrome/browser/autocomplete/autocomplete.h b/chrome/browser/autocomplete/autocomplete.h
index d22628b..5134f8f 100644
--- a/chrome/browser/autocomplete/autocomplete.h
+++ b/chrome/browser/autocomplete/autocomplete.h
@@ -720,6 +720,8 @@ class AutocompleteController : public ACProviderListener {
// done or the query is Stop()ed. It is safe to Start() a new query without
// Stop()ing the previous one.
//
+ // See AutocompleteInput::desired_tld() for meaning of |desired_tld|.
+ //
// |prevent_inline_autocomplete| is true if the generated result set should
// not require inline autocomplete for the default match. This is difficult
// to explain in the abstract; the practical use case is that after the user
diff --git a/chrome/browser/autocomplete/autocomplete_browsertest.cc b/chrome/browser/autocomplete/autocomplete_browsertest.cc
new file mode 100644
index 0000000..8464a82
--- /dev/null
+++ b/chrome/browser/autocomplete/autocomplete_browsertest.cc
@@ -0,0 +1,95 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/autocomplete/autocomplete.h"
+#include "chrome/browser/autocomplete/autocomplete_edit.h"
+#include "chrome/browser/autocomplete/autocomplete_edit_view.h"
+#include "chrome/browser/autocomplete/autocomplete_popup_model.h"
+#include "chrome/browser/browser.h"
+#include "chrome/browser/browser_window.h"
+#include "chrome/browser/location_bar.h"
+#include "chrome/common/url_constants.h"
+#include "chrome/test/in_process_browser_test.h"
+#include "chrome/test/ui_test_utils.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+class AutocompleteBrowserTest : public InProcessBrowserTest {
+ protected:
+ LocationBar* GetLocationBar() const {
+ return browser()->window()->GetLocationBar();
+ }
+
+ AutocompleteController* GetAutocompleteController() const {
+ return GetLocationBar()->location_entry()->model()->popup_model()->
+ autocomplete_controller();
+ }
+};
+
+IN_PROC_BROWSER_TEST_F(AutocompleteBrowserTest, Basic) {
+ LocationBar* location_bar = GetLocationBar();
+
+ EXPECT_EQ(std::wstring(), location_bar->GetInputString());
+ EXPECT_EQ(UTF8ToWide(chrome::kAboutBlankURL),
+ location_bar->location_entry()->GetText());
+ EXPECT_FALSE(location_bar->location_entry()->IsSelectAll());
+
+ location_bar->FocusLocation();
+
+ EXPECT_EQ(std::wstring(), location_bar->GetInputString());
+ EXPECT_EQ(UTF8ToWide(chrome::kAboutBlankURL),
+ location_bar->location_entry()->GetText());
+ EXPECT_TRUE(location_bar->location_entry()->IsSelectAll());
+
+ location_bar->location_entry()->SetUserText(L"chrome");
+
+ EXPECT_EQ(std::wstring(), location_bar->GetInputString());
+ EXPECT_EQ(L"chrome", location_bar->location_entry()->GetText());
+ EXPECT_FALSE(location_bar->location_entry()->IsSelectAll());
+
+ location_bar->location_entry()->RevertAll();
+
+ EXPECT_EQ(std::wstring(), location_bar->GetInputString());
+ EXPECT_EQ(UTF8ToWide(chrome::kAboutBlankURL),
+ location_bar->location_entry()->GetText());
+ EXPECT_FALSE(location_bar->location_entry()->IsSelectAll());
+
+ location_bar->location_entry()->SetUserText(L"chrome");
+ location_bar->Revert();
+
+ EXPECT_EQ(std::wstring(), location_bar->GetInputString());
+ EXPECT_EQ(UTF8ToWide(chrome::kAboutBlankURL),
+ location_bar->location_entry()->GetText());
+ EXPECT_FALSE(location_bar->location_entry()->IsSelectAll());
+}
+
+IN_PROC_BROWSER_TEST_F(AutocompleteBrowserTest, Autocomplete) {
+ LocationBar* location_bar = GetLocationBar();
+ AutocompleteController* autocomplete_controller = GetAutocompleteController();
+
+ {
+ autocomplete_controller->Start(L"chrome", std::wstring(),
+ true, false, true);
+
+ EXPECT_TRUE(autocomplete_controller->done());
+ EXPECT_EQ(std::wstring(), location_bar->GetInputString());
+ EXPECT_EQ(std::wstring(), location_bar->location_entry()->GetText());
+ EXPECT_TRUE(location_bar->location_entry()->IsSelectAll());
+ const AutocompleteResult& result = autocomplete_controller->result();
+ ASSERT_EQ(1U, result.size());
+ AutocompleteMatch match = result.match_at(0);
+ EXPECT_EQ(AutocompleteMatch::SEARCH_WHAT_YOU_TYPED, match.type);
+ EXPECT_FALSE(match.deletable);
+ }
+
+ {
+ location_bar->Revert();
+
+ EXPECT_EQ(std::wstring(), location_bar->GetInputString());
+ EXPECT_EQ(UTF8ToWide(chrome::kAboutBlankURL),
+ location_bar->location_entry()->GetText());
+ EXPECT_FALSE(location_bar->location_entry()->IsSelectAll());
+ const AutocompleteResult& result = autocomplete_controller->result();
+ EXPECT_TRUE(result.empty());
+ }
+}
diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp
index 0846bcb..0185dad 100644
--- a/chrome/chrome.gyp
+++ b/chrome/chrome.gyp
@@ -42,6 +42,7 @@
# TODO: remove this helper when we have loops in GYP
'apply_locales_cmd': ['python', 'tools/build/apply_locales.py',],
'browser_tests_sources': [
+ 'browser/autocomplete/autocomplete_browsertest.cc',
'browser/browser_browsertest.cc',
'browser/browser_init_browsertest.cc',
'browser/crash_recovery_browsertest.cc',