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(); |