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

Unified Diff: chrome/browser/ui/toolbar/toolbar_model_unittest.cc

Issue 287543002: Remove origin chip v1 and "hide on input" v2 behavior. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix test compile Created 6 years, 7 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
Index: chrome/browser/ui/toolbar/toolbar_model_unittest.cc
diff --git a/chrome/browser/ui/toolbar/toolbar_model_unittest.cc b/chrome/browser/ui/toolbar/toolbar_model_unittest.cc
index 1807b019acf087bb63b543019989aa6836319dc0..b4e1d214f013fccfe5fcfd78a3039c0fc30aba7c 100644
--- a/chrome/browser/ui/toolbar/toolbar_model_unittest.cc
+++ b/chrome/browser/ui/toolbar/toolbar_model_unittest.cc
@@ -4,31 +4,21 @@
#include "chrome/browser/ui/toolbar/toolbar_model.h"
-#include <vector>
-
#include "base/command_line.h"
-#include "base/metrics/field_trial.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/autocomplete/autocomplete_classifier_factory.h"
#include "chrome/browser/search/search.h"
#include "chrome/browser/search_engines/search_terms_data.h"
-#include "chrome/browser/search_engines/template_url.h"
-#include "chrome/browser/search_engines/template_url_service.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/toolbar/toolbar_model.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/test/base/browser_with_test_window_test.h"
-#include "components/variations/entropy_provider.h"
#include "content/public/browser/navigation_entry.h"
-#include "content/public/browser/render_process_host.h"
-#include "content/public/browser/web_contents.h"
#include "content/public/common/ssl_status.h"
#include "content/public/common/url_constants.h"
-#include "net/base/escape.h"
-using base::ASCIIToUTF16;
// Test data ------------------------------------------------------------------
@@ -41,8 +31,6 @@ struct TestItem {
base::string16 expected_text_url_replacement_inactive;
// The expected text to display when query extraction is active.
base::string16 expected_text_query_extraction;
- // The expected text to display when the origin chip (URL removal) is active.
Justin Donnelly 2014/05/13 22:19:33 These tests still seem useful to me. Why remove t
Peter Kasting 2014/05/14 00:28:11 These tests were only being used with origin chip
Justin Donnelly 2014/05/14 16:31:43 From the point of view of these tests, v1 and v2 h
- base::string16 expected_text_origin_chip;
// The expected text to display when both query extraction and URL removal are
// active.
base::string16 expected_text_both;
@@ -51,100 +39,90 @@ struct TestItem {
} test_items[] = {
{
GURL("view-source:http://www.google.com"),
- ASCIIToUTF16("view-source:www.google.com"),
- ASCIIToUTF16("view-source:www.google.com"),
- base::string16(),
+ base::ASCIIToUTF16("view-source:www.google.com"),
+ base::ASCIIToUTF16("view-source:www.google.com"),
base::string16(),
false,
true
},
{
GURL("view-source:chrome://newtab/"),
- ASCIIToUTF16("view-source:chrome://newtab"),
- ASCIIToUTF16("view-source:chrome://newtab"),
- base::string16(),
+ base::ASCIIToUTF16("view-source:chrome://newtab"),
+ base::ASCIIToUTF16("view-source:chrome://newtab"),
base::string16(),
false,
true
},
{
GURL("chrome-extension://monkey/balls.html"),
- ASCIIToUTF16("chrome-extension://monkey/balls.html"),
- ASCIIToUTF16("chrome-extension://monkey/balls.html"),
- base::string16(),
+ base::ASCIIToUTF16("chrome-extension://monkey/balls.html"),
+ base::ASCIIToUTF16("chrome-extension://monkey/balls.html"),
base::string16(),
false,
true
},
{
GURL(content::kAboutBlankURL),
- ASCIIToUTF16(content::kAboutBlankURL),
- ASCIIToUTF16(content::kAboutBlankURL),
- base::string16(),
+ base::ASCIIToUTF16(content::kAboutBlankURL),
+ base::ASCIIToUTF16(content::kAboutBlankURL),
base::string16(),
false,
true
},
{
GURL("http://searchurl/?q=tractor+supply"),
- ASCIIToUTF16("searchurl/?q=tractor+supply"),
- ASCIIToUTF16("searchurl/?q=tractor+supply"),
- base::string16(),
+ base::ASCIIToUTF16("searchurl/?q=tractor+supply"),
+ base::ASCIIToUTF16("searchurl/?q=tractor+supply"),
base::string16(),
false,
true
},
{
GURL("http://google.com/search?q=tractor+supply&espv=1"),
- ASCIIToUTF16("google.com/search?q=tractor+supply&espv=1"),
- ASCIIToUTF16("google.com/search?q=tractor+supply&espv=1"),
- base::string16(),
+ base::ASCIIToUTF16("google.com/search?q=tractor+supply&espv=1"),
+ base::ASCIIToUTF16("google.com/search?q=tractor+supply&espv=1"),
base::string16(),
false,
true
},
{
GURL("https://google.ca/search?q=tractor+supply"),
- ASCIIToUTF16("https://google.ca/search?q=tractor+supply"),
- ASCIIToUTF16("https://google.ca/search?q=tractor+supply"),
- base::string16(),
+ base::ASCIIToUTF16("https://google.ca/search?q=tractor+supply"),
+ base::ASCIIToUTF16("https://google.ca/search?q=tractor+supply"),
base::string16(),
false,
true
},
{
GURL("https://google.com/search?q=tractor+supply"),
- ASCIIToUTF16("https://google.com/search?q=tractor+supply"),
- ASCIIToUTF16("https://google.com/search?q=tractor+supply"),
- base::string16(),
+ base::ASCIIToUTF16("https://google.com/search?q=tractor+supply"),
+ base::ASCIIToUTF16("https://google.com/search?q=tractor+supply"),
base::string16(),
false,
true
},
{
GURL("https://google.com/search?q=tractor+supply&espv=1"),
- ASCIIToUTF16("https://google.com/search?q=tractor+supply&espv=1"),
- ASCIIToUTF16("tractor supply"),
- base::string16(),
- ASCIIToUTF16("tractor supply"),
+ base::ASCIIToUTF16("https://google.com/search?q=tractor+supply&espv=1"),
+ base::ASCIIToUTF16("tractor supply"),
+ base::ASCIIToUTF16("tractor supply"),
true,
true
},
{
GURL("https://google.com/search?q=tractorsupply.com&espv=1"),
- ASCIIToUTF16("https://google.com/search?q=tractorsupply.com&espv=1"),
- ASCIIToUTF16("tractorsupply.com"),
- base::string16(),
- ASCIIToUTF16("tractorsupply.com"),
+ base::ASCIIToUTF16("https://google.com/search?q=tractorsupply.com&espv=1"),
+ base::ASCIIToUTF16("tractorsupply.com"),
+ base::ASCIIToUTF16("tractorsupply.com"),
true,
true
},
{
GURL("https://google.com/search?q=ftp://tractorsupply.ie&espv=1"),
- ASCIIToUTF16("https://google.com/search?q=ftp://tractorsupply.ie&espv=1"),
- ASCIIToUTF16("ftp://tractorsupply.ie"),
- base::string16(),
- ASCIIToUTF16("ftp://tractorsupply.ie"),
+ base::ASCIIToUTF16(
+ "https://google.com/search?q=ftp://tractorsupply.ie&espv=1"),
+ base::ASCIIToUTF16("ftp://tractorsupply.ie"),
+ base::ASCIIToUTF16("ftp://tractorsupply.ie"),
true,
true
},
@@ -171,11 +149,8 @@ class ToolbarModelTest : public BrowserWithTestWindowTest {
const base::string16& expected_text,
bool would_perform_search_term_replacement,
bool should_display_url);
- void EnableOriginChipFieldTrial();
private:
- scoped_ptr<base::FieldTrialList> field_trial_list_;
-
DISALLOW_COPY_AND_ASSIGN(ToolbarModelTest);
};
@@ -203,13 +178,6 @@ void ToolbarModelTest::SetUp() {
UIThreadSearchTermsData::SetGoogleBaseURL("http://google.com/");
}
-void ToolbarModelTest::EnableOriginChipFieldTrial() {
- field_trial_list_.reset(new base::FieldTrialList(
- new metrics::SHA1EntropyProvider("platypus")));
- base::FieldTrialList::CreateFieldTrial(
- "EmbeddedSearch", "Group1 espv:2 origin_chip:1");
-}
-
void ToolbarModelTest::NavigateAndCheckText(
const GURL& url,
const base::string16& expected_text,
@@ -305,42 +273,6 @@ TEST_F(ToolbarModelTest, ShouldDisplayURL_QueryExtraction) {
}
}
-// Test that we remove or replace URLs appropriately when the origin chip is
-// enabled.
-TEST_F(ToolbarModelTest, ShouldDisplayURL_OriginChip) {
- EnableOriginChipFieldTrial();
- AddTab(browser(), GURL(content::kAboutBlankURL));
-
- // Check each case with the origin chip enabled but query extraction disabled.
- EXPECT_TRUE(chrome::ShouldDisplayOriginChip());
- EXPECT_FALSE(chrome::IsQueryExtractionEnabled());
- for (size_t i = 0; i < arraysize(test_items); ++i) {
- const TestItem& test_item = test_items[i];
- NavigateAndCheckText(test_item.url, test_item.expected_text_origin_chip,
- false, test_item.should_display_url);
- }
-
- // Check with both enabled.
- chrome::EnableQueryExtractionForTesting();
- EXPECT_TRUE(chrome::IsQueryExtractionEnabled());
- EXPECT_TRUE(browser()->toolbar_model()->url_replacement_enabled());
- for (size_t i = 0; i < arraysize(test_items); ++i) {
- const TestItem& test_item = test_items[i];
- NavigateAndCheckText(test_item.url, test_item.expected_text_both,
- test_item.would_perform_search_term_replacement,
- test_item.should_display_url);
- }
-
- // Disabling URL replacement should reset to only showing URLs.
- browser()->toolbar_model()->set_url_replacement_enabled(false);
- for (size_t i = 0; i < arraysize(test_items); ++i) {
- const TestItem& test_item = test_items[i];
- NavigateAndCheckText(test_item.url,
- test_item.expected_text_url_replacement_inactive,
- false, test_item.should_display_url);
- }
-}
-
// Verify that search terms are extracted while the page is loading.
TEST_F(ToolbarModelTest, SearchTermsWhileLoading) {
chrome::EnableQueryExtractionForTesting();
@@ -377,7 +309,8 @@ TEST_F(ToolbarModelTest, GoogleBaseURL) {
UIThreadSearchTermsData::SetGoogleBaseURL("http://www.foo.com/");
NavigateAndCheckText(
GURL("http://www.foo.com/search?q=tractor+supply&espv=1"),
- ASCIIToUTF16("www.foo.com/search?q=tractor+supply&espv=1"), false, true);
+ base::ASCIIToUTF16("www.foo.com/search?q=tractor+supply&espv=1"), false,
+ true);
// The same URL, when specified on the command line, should allow search term
// extraction.
@@ -386,55 +319,5 @@ TEST_F(ToolbarModelTest, GoogleBaseURL) {
"http://www.foo.com/");
NavigateAndCheckText(
GURL("http://www.foo.com/search?q=tractor+supply&espv=1"),
- ASCIIToUTF16("tractor supply"), true, true);
-}
-
-// Popup windows don't have an origin chip, so test that URL display in a popup
-// ignores whether the origin chip is enabled and only respects the query
-// extraction flag.
-TEST_F(PopupToolbarModelTest, ShouldDisplayURL) {
- AddTab(browser(), GURL(content::kAboutBlankURL));
-
- // Check with neither query extraction nor the origin chip enabled.
- EXPECT_FALSE(chrome::ShouldDisplayOriginChip());
- EXPECT_FALSE(chrome::IsQueryExtractionEnabled());
- for (size_t i = 0; i < arraysize(test_items); ++i) {
- const TestItem& test_item = test_items[i];
- NavigateAndCheckText(test_item.url,
- test_item.expected_text_url_replacement_inactive,
- false, test_item.should_display_url);
- }
-
- // Check with the origin chip enabled.
- EnableOriginChipFieldTrial();
- EXPECT_TRUE(chrome::ShouldDisplayOriginChip());
- EXPECT_FALSE(chrome::IsQueryExtractionEnabled());
- for (size_t i = 0; i < arraysize(test_items); ++i) {
- const TestItem& test_item = test_items[i];
- NavigateAndCheckText(test_item.url,
- test_item.expected_text_url_replacement_inactive,
- false, test_item.should_display_url);
- }
-
- // With both origin chip and query extraction enabled, only search term
- // replacement should be performed.
- chrome::EnableQueryExtractionForTesting();
- EXPECT_TRUE(chrome::IsQueryExtractionEnabled());
- EXPECT_TRUE(browser()->toolbar_model()->url_replacement_enabled());
- for (size_t i = 0; i < arraysize(test_items); ++i) {
- const TestItem& test_item = test_items[i];
- NavigateAndCheckText(test_item.url,
- test_item.expected_text_query_extraction,
- test_item.would_perform_search_term_replacement,
- test_item.should_display_url);
- }
-
- // Disabling URL replacement should reset to only showing URLs.
- browser()->toolbar_model()->set_url_replacement_enabled(false);
- for (size_t i = 0; i < arraysize(test_items); ++i) {
- const TestItem& test_item = test_items[i];
- NavigateAndCheckText(test_item.url,
- test_item.expected_text_url_replacement_inactive,
- false, test_item.should_display_url);
- }
+ base::ASCIIToUTF16("tractor supply"), true, true);
}

Powered by Google App Engine
This is Rietveld 408576698