Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(449)

Unified Diff: components/omnibox/browser/omnibox_edit_unittest.cc

Issue 2046263002: Fix DCHECK. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cleanup
Patch Set: Simplify behavior Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/omnibox/browser/omnibox_edit_model.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/omnibox/browser/omnibox_edit_unittest.cc
diff --git a/components/omnibox/browser/omnibox_edit_unittest.cc b/components/omnibox/browser/omnibox_edit_unittest.cc
index f6e932ab45596e813a980e2db3ece28118ea6858..95bafb637fb16a7d4fd094821372434e27c1981f 100644
--- a/components/omnibox/browser/omnibox_edit_unittest.cc
+++ b/components/omnibox/browser/omnibox_edit_unittest.cc
@@ -11,12 +11,12 @@
#include "components/omnibox/browser/autocomplete_classifier.h"
#include "components/omnibox/browser/autocomplete_controller.h"
#include "components/omnibox/browser/autocomplete_scheme_classifier.h"
-#include "components/omnibox/browser/history_url_provider.h"
#include "components/omnibox/browser/mock_autocomplete_provider_client.h"
#include "components/omnibox/browser/omnibox_client.h"
#include "components/omnibox/browser/omnibox_edit_controller.h"
#include "components/omnibox/browser/omnibox_edit_model.h"
#include "components/omnibox/browser/omnibox_view.h"
+#include "components/omnibox/browser/search_provider.h"
#include "components/search_engines/search_terms_data.h"
#include "components/search_engines/template_url_service.h"
#include "components/search_engines/template_url_service_client.h"
@@ -140,6 +140,10 @@ class TestingOmniboxClient : public OmniboxClient {
TestingOmniboxClient();
~TestingOmniboxClient() override;
+ const AutocompleteMatch& alternate_nav_match() const {
+ return alternate_nav_match_;
+ }
+
// OmniboxClient:
std::unique_ptr<AutocompleteProviderClient> CreateAutocompleteProviderClient()
override;
@@ -148,6 +152,7 @@ class TestingOmniboxClient : public OmniboxClient {
const base::string16& text,
const AutocompleteMatch& match,
const AutocompleteMatch& alternate_nav_match) override {
+ alternate_nav_match_ = alternate_nav_match;
return nullptr;
}
bool CurrentPageExists() const override { return true; }
@@ -205,6 +210,7 @@ class TestingOmniboxClient : public OmniboxClient {
SessionID session_id_;
TestingSchemeClassifier scheme_classifier_;
AutocompleteClassifier autocomplete_classifier_;
+ AutocompleteMatch alternate_nav_match_;
DISALLOW_COPY_AND_ASSIGN(TestingOmniboxClient);
};
@@ -373,3 +379,30 @@ TEST_F(OmniboxEditTest, InlineAutocompleteText) {
EXPECT_EQ(base::ASCIIToUTF16("hello"), view().GetText());
EXPECT_EQ(base::string16(), view().inline_autocomplete_text());
}
+
+// This verifies the fix for a bug where calling OpenMatch() with a valid
+// alternate nav URL would fail a DCHECK if the input began with "http://".
+// The failure was due to erroneously trying to strip the scheme from the
+// resulting fill_into_edit. Alternate nav matches are never shown, so there's
+// no need to ever try and strip this scheme.
+TEST_F(OmniboxEditTest, AlternateNavHasHTTP) {
+ const TestingOmniboxClient* client =
+ static_cast<TestingOmniboxClient*>(model()->client());
+ const AutocompleteMatch match(
+ model()->autocomplete_controller()->search_provider(), 0, false,
+ AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED);
+ const GURL alternate_nav_url("http://ab%20cd/");
+
+ model()->OnSetFocus(false); // Avoids DCHECK in OpenMatch().
+ model()->SetUserText(base::ASCIIToUTF16("http://ab cd"));
+ model()->OpenMatch(match, CURRENT_TAB, alternate_nav_url, base::string16(),
+ 0);
+ EXPECT_TRUE(AutocompleteInput::HasHTTPScheme(
+ client->alternate_nav_match().fill_into_edit));
+
+ model()->SetUserText(base::ASCIIToUTF16("ab cd"));
+ model()->OpenMatch(match, CURRENT_TAB, alternate_nav_url, base::string16(),
+ 0);
+ EXPECT_TRUE(AutocompleteInput::HasHTTPScheme(
+ client->alternate_nav_match().fill_into_edit));
+}
« no previous file with comments | « components/omnibox/browser/omnibox_edit_model.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698