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

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

Issue 11884037: InstantExtended: Bail on TemplateURLs with no espv. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments. Created 7 years, 11 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
« chrome/browser/ui/search/search.cc ('K') | « chrome/browser/ui/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/ui/search/search_unittest.cc
diff --git a/chrome/browser/ui/search/search_unittest.cc b/chrome/browser/ui/search/search_unittest.cc
index 8aaad4f4790458789535e0526faa4b424300eba6..661fde266b5e06444ffd673dd2f40b07729d85f8 100644
--- a/chrome/browser/ui/search/search_unittest.cc
+++ b/chrome/browser/ui/search/search_unittest.cc
@@ -3,6 +3,12 @@
// found in the LICENSE file.
#include "chrome/browser/ui/search/search.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/search_engines/template_url_service_test_util.h"
+#include "chrome/test/base/testing_profile.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace chrome {
@@ -62,5 +68,48 @@ TEST(EmbeddedSearchFieldTrialTest, GetFieldTrialInfo) {
EXPECT_EQ(ZERO, flags.size());
}
+TEST(EmbeddedSearchPageVersionTest, BailsWithBadTemplateURL) {
+ EnableInstantExtendedAPIForTesting();
+
+ TemplateURLServiceTestUtil test_util;
+ test_util.SetUp();
+ test_util.VerifyLoad();
+ TemplateURLData data;
+ data.SetURL("http://google.com/?q={searchTerms}");
+ data.instant_url = "http://google.com/instant#q={searchTerms}";
+ TemplateURL* url = new TemplateURL(test_util.profile(), data);
+ test_util.model()->Add(url);
+ test_util.model()->SetDefaultSearchProvider(url);
+ ASSERT_EQ(url, test_util.model()->GetDefaultSearchProvider());
+ ASSERT_TRUE(TemplateURLServiceFactory::GetForProfile(test_util.profile())->
dhollowa 2013/01/16 17:30:05 nit: ASSERT_NE(static_cast<...>(NULL), TemplateURL
Jered 2013/01/16 18:37:28 Done.
+ FindNewDefaultSearchProvider() != NULL);
+
+ EXPECT_EQ(0U, chrome::search::EmbeddedSearchPageVersion(
+ test_util.profile()->GetOriginalProfile()));
+ test_util.TearDown();
+}
+
+TEST(EmbeddedSearchPageVersionTest, DoesNotBailWithGoodTemplateURL) {
+ EnableInstantExtendedAPIForTesting();
+
+ TemplateURLServiceTestUtil test_util;
+ test_util.SetUp();
+ test_util.VerifyLoad();
+ TemplateURLData data;
+ data.SetURL("http://google.com/?q={searchTerms}");
+ data.instant_url = "http://google.com/instant#q={searchTerms}"
+ "{google:instantExtendedEnabledParameter}";
dhollowa 2013/01/16 17:30:05 This wouldn't cover the case when espv=0 I suppose
Jered 2013/01/16 18:37:28 The logic I'm adding only needs to know that the s
+ TemplateURL* url = new TemplateURL(test_util.profile(), data);
+ test_util.model()->Add(url);
+ test_util.model()->SetDefaultSearchProvider(url);
+ ASSERT_EQ(url, test_util.model()->GetDefaultSearchProvider());
+ ASSERT_TRUE(TemplateURLServiceFactory::GetForProfile(test_util.profile())->
dhollowa 2013/01/16 17:30:05 nit: ASSERT_NE... as above.
Jered 2013/01/16 18:37:28 Done.
+ FindNewDefaultSearchProvider() != NULL);
+
+ EXPECT_NE(0U, chrome::search::EmbeddedSearchPageVersion(
+ test_util.profile()->GetOriginalProfile()));
+ test_util.TearDown();
+}
+
} // namespace search
} // namespace chrome
« chrome/browser/ui/search/search.cc ('K') | « chrome/browser/ui/search/search.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698