Chromium Code Reviews| 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 |