| OLD | NEW | 
|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 #include "chrome/browser/ui/search/search.h" | 5 #include "chrome/browser/ui/search/search.h" | 
|  | 6 | 
|  | 7 #include "chrome/browser/search_engines/template_url.h" | 
|  | 8 #include "chrome/browser/search_engines/template_url_service.h" | 
|  | 9 #include "chrome/browser/search_engines/template_url_service_factory.h" | 
|  | 10 #include "chrome/browser/search_engines/template_url_service_test_util.h" | 
|  | 11 #include "chrome/test/base/testing_profile.h" | 
| 6 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" | 
| 7 | 13 | 
| 8 namespace chrome { | 14 namespace chrome { | 
| 9 namespace search { | 15 namespace search { | 
| 10 | 16 | 
| 11 TEST(EmbeddedSearchFieldTrialTest, GetFieldTrialInfo) { | 17 TEST(EmbeddedSearchFieldTrialTest, GetFieldTrialInfo) { | 
| 12   FieldTrialFlags flags; | 18   FieldTrialFlags flags; | 
| 13   uint64 group_number = 0; | 19   uint64 group_number = 0; | 
| 14   const uint64 ZERO = 0; | 20   const uint64 ZERO = 0; | 
| 15 | 21 | 
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 55       "moose", "default", flags)); | 61       "moose", "default", flags)); | 
| 56 | 62 | 
| 57   group_number = 0; | 63   group_number = 0; | 
| 58   flags.clear(); | 64   flags.clear(); | 
| 59   GetFieldTrialInfo( | 65   GetFieldTrialInfo( | 
| 60       "Group77 bar:1 baz:7 cat:dogs DISABLED", &flags, &group_number); | 66       "Group77 bar:1 baz:7 cat:dogs DISABLED", &flags, &group_number); | 
| 61   EXPECT_EQ(ZERO, group_number); | 67   EXPECT_EQ(ZERO, group_number); | 
| 62   EXPECT_EQ(ZERO, flags.size()); | 68   EXPECT_EQ(ZERO, flags.size()); | 
| 63 } | 69 } | 
| 64 | 70 | 
|  | 71 TEST(EmbeddedSearchPageVersionTest, BailsWithBadTemplateURL) { | 
|  | 72   EnableInstantExtendedAPIForTesting(); | 
|  | 73 | 
|  | 74   TemplateURLServiceTestUtil test_util; | 
|  | 75   test_util.SetUp(); | 
|  | 76   test_util.VerifyLoad(); | 
|  | 77   TemplateURLData data; | 
|  | 78   data.SetURL("http://google.com/?q={searchTerms}"); | 
|  | 79   data.instant_url = "http://google.com/instant#q={searchTerms}"; | 
|  | 80   TemplateURL* url = new TemplateURL(test_util.profile(), data); | 
|  | 81   test_util.model()->Add(url); | 
|  | 82   test_util.model()->SetDefaultSearchProvider(url); | 
|  | 83   ASSERT_EQ(url, test_util.model()->GetDefaultSearchProvider()); | 
|  | 84   ASSERT_TRUE(TemplateURLServiceFactory::GetForProfile(test_util.profile())-> | 
|  | 85       FindNewDefaultSearchProvider() != NULL); | 
|  | 86 | 
|  | 87   EXPECT_EQ(0U, chrome::search::EmbeddedSearchPageVersion( | 
|  | 88       test_util.profile()->GetOriginalProfile())); | 
|  | 89   test_util.TearDown(); | 
|  | 90 } | 
|  | 91 | 
|  | 92 TEST(EmbeddedSearchPageVersionTest, DoesNotBailWithGoodTemplateURL) { | 
|  | 93   EnableInstantExtendedAPIForTesting(); | 
|  | 94 | 
|  | 95   TemplateURLServiceTestUtil test_util; | 
|  | 96   test_util.SetUp(); | 
|  | 97   test_util.VerifyLoad(); | 
|  | 98   TemplateURLData data; | 
|  | 99   data.SetURL("http://google.com/?q={searchTerms}"); | 
|  | 100   data.instant_url = "http://google.com/instant#q={searchTerms}" | 
|  | 101       "{google:instantExtendedEnabledParameter}"; | 
|  | 102   TemplateURL* url = new TemplateURL(test_util.profile(), data); | 
|  | 103   test_util.model()->Add(url); | 
|  | 104   test_util.model()->SetDefaultSearchProvider(url); | 
|  | 105   ASSERT_EQ(url, test_util.model()->GetDefaultSearchProvider()); | 
|  | 106   ASSERT_TRUE(TemplateURLServiceFactory::GetForProfile(test_util.profile())-> | 
|  | 107       FindNewDefaultSearchProvider() != NULL); | 
|  | 108 | 
|  | 109   EXPECT_NE(0U, chrome::search::EmbeddedSearchPageVersion( | 
|  | 110       test_util.profile()->GetOriginalProfile())); | 
|  | 111   test_util.TearDown(); | 
|  | 112 } | 
|  | 113 | 
| 65 }  // namespace search | 114 }  // namespace search | 
| 66 }  // namespace chrome | 115 }  // namespace chrome | 
| OLD | NEW | 
|---|