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

Unified Diff: chrome/browser/search/search_unittest.cc

Issue 23522025: InstantExtended: add a finch flag to disable Instant Extended on SRP. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add tests. Created 7 years, 3 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 | « chrome/browser/search/search.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/search/search_unittest.cc
diff --git a/chrome/browser/search/search_unittest.cc b/chrome/browser/search/search_unittest.cc
index a93532f98ad38c5c41bcf20a379c0df4f2d17c2d..041ac29e0b15124da1f0c12b1fd73644526a7928 100644
--- a/chrome/browser/search/search_unittest.cc
+++ b/chrome/browser/search/search_unittest.cc
@@ -224,6 +224,35 @@ TEST_F(ShouldHideTopVerbatimTest, DisableByFlag) {
EXPECT_FALSE(ShouldHideTopVerbatimMatch());
}
+typedef InstantExtendedAPIEnabledTest ShouldSuppressInstantExtendedOnSRPTest;
+
+TEST_F(ShouldSuppressInstantExtendedOnSRPTest, NotSet) {
+ ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
+ "InstantExtended", "Group1 espv:2"));
+ EXPECT_FALSE(ShouldSuppressInstantExtendedOnSRP());
+ EXPECT_TRUE(IsInstantExtendedAPIEnabled());
+ EXPECT_TRUE(IsQueryExtractionEnabled());
+ EXPECT_EQ(2ul, EmbeddedSearchPageVersion());
+}
+
+TEST_F(ShouldSuppressInstantExtendedOnSRPTest, NotSuppressOnSRP) {
+ ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
+ "InstantExtended", "Group1 espv:2 suppress_on_srp:0"));
+ EXPECT_FALSE(ShouldSuppressInstantExtendedOnSRP());
+ EXPECT_TRUE(IsInstantExtendedAPIEnabled());
+ EXPECT_TRUE(IsQueryExtractionEnabled());
+ EXPECT_EQ(2ul, EmbeddedSearchPageVersion());
+}
+
+TEST_F(ShouldSuppressInstantExtendedOnSRPTest, SuppressOnSRP) {
+ ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
+ "InstantExtended", "Group1 espv:2 suppress_on_srp:1"));
+ EXPECT_TRUE(ShouldSuppressInstantExtendedOnSRP());
+ EXPECT_TRUE(IsInstantExtendedAPIEnabled());
+ EXPECT_FALSE(IsQueryExtractionEnabled());
+ EXPECT_EQ(2ul, EmbeddedSearchPageVersion());
+}
+
class SearchTest : public BrowserWithTestWindowTest {
protected:
virtual void SetUp() OVERRIDE {
@@ -352,6 +381,32 @@ TEST_F(SearchTest, ShouldAssignURLToInstantRendererExtendedEnabled) {
}
}
+TEST_F(SearchTest, ShouldAssignURLToInstantRendererExtendedEnabledNotOnSRP) {
+ ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
+ "InstantExtended", "Group1 espv:2 suppress_on_srp:1"));
+
+ const SearchTestCase kTestCases[] = {
+ {chrome::kChromeSearchLocalNtpUrl, true, ""},
+ {"https://foo.com/instant?strk", true, ""},
+ {"https://foo.com/instant#strk", true, ""},
+ {"https://foo.com/instant?strk=0", true, ""},
+ {"https://foo.com/url?strk", false, "Disabled on SRP"},
+ {"https://foo.com/alt?strk", false, "Disabled ON SRP"},
+ {"http://foo.com/instant", false, "Non-HTTPS"},
+ {"http://foo.com/instant?strk", false, "Non-HTTPS"},
+ {"http://foo.com/instant?strk=1", false, "Non-HTTPS"},
+ {"https://foo.com/instant", false, "No search terms replacement"},
+ {"https://foo.com/?strk", false, "Non-exact path"},
+ };
+
+ for (size_t i = 0; i < arraysize(kTestCases); ++i) {
+ const SearchTestCase& test = kTestCases[i];
+ EXPECT_EQ(test.expected_result,
+ ShouldAssignURLToInstantRenderer(GURL(test.url), profile()))
+ << test.url << " " << test.comment;
+ }
+}
+
TEST_F(SearchTest, ShouldUseProcessPerSiteForInstantURL) {
EnableInstantExtendedAPIForTesting();
« no previous file with comments | « chrome/browser/search/search.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698