OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
6 #include "base/metrics/histogram.h" | 6 #include "base/metrics/histogram.h" |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "chrome/browser/protector/base_setting_change.h" | 9 #include "chrome/browser/protector/base_setting_change.h" |
10 #include "chrome/browser/protector/histograms.h" | 10 #include "chrome/browser/protector/histograms.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 const std::string http_example_com_no_search_terms = | 43 const std::string http_example_com_no_search_terms = |
44 "http://example.com/"; | 44 "http://example.com/"; |
45 const std::string example_com_domain = "example.com"; | 45 const std::string example_com_domain = "example.com"; |
46 const string16 example_net = ASCIIToUTF16("Example.net"); | 46 const string16 example_net = ASCIIToUTF16("Example.net"); |
47 const std::string http_example_net = "http://example.net/?q={searchTerms}"; | 47 const std::string http_example_net = "http://example.net/?q={searchTerms}"; |
48 const std::string example_domain = "example.net"; | 48 const std::string example_domain = "example.net"; |
49 | 49 |
50 const BaseSettingChange::DisplayName kNoDisplayName( | 50 const BaseSettingChange::DisplayName kNoDisplayName( |
51 BaseSettingChange::kDefaultNamePriority, string16()); | 51 BaseSettingChange::kDefaultNamePriority, string16()); |
52 | 52 |
53 // Convenience function. | |
54 TemplateURL* MakeTemplateURL(const string16& short_name, | |
55 const string16& keyword, | |
56 const std::string& url) { | |
57 TemplateURLData data; | |
58 data.short_name = short_name; | |
59 if (keyword.empty()) | |
60 data.SetAutogenerateKeyword(true); | |
61 else | |
62 data.SetKeyword(keyword); | |
63 data.SetURL(url); | |
64 return new TemplateURL(data); | |
65 } | |
66 | |
67 } // namespace | 53 } // namespace |
68 | 54 |
69 class DefaultSearchProviderChangeTest : public InProcessBrowserTest { | 55 class DefaultSearchProviderChangeTest : public InProcessBrowserTest { |
70 public: | 56 public: |
71 virtual void SetUpOnMainThread() OVERRIDE { | 57 virtual void SetUpOnMainThread() OVERRIDE { |
72 mock_protector_service_ = | 58 Profile* profile = browser()->profile(); |
73 MockProtectorService::BuildForProfile(browser()->profile()); | 59 mock_protector_service_ = MockProtectorService::BuildForProfile(profile); |
74 | 60 |
75 // Ensure that TemplateURLService is loaded. | 61 // Ensure that TemplateURLService is loaded. |
76 turl_service_ = | 62 turl_service_ = TemplateURLServiceFactory::GetForProfile(profile); |
77 TemplateURLServiceFactory::GetForProfile(browser()->profile()); | |
78 ui_test_utils::WaitForTemplateURLServiceToLoad(turl_service_); | 63 ui_test_utils::WaitForTemplateURLServiceToLoad(turl_service_); |
79 | 64 |
80 prepopulated_url_.reset( | 65 prepopulated_url_.reset( |
81 TemplateURLPrepopulateData::GetPrepopulatedDefaultSearch(NULL)); | 66 TemplateURLPrepopulateData::GetPrepopulatedDefaultSearch(NULL)); |
82 } | 67 } |
83 | 68 |
84 virtual void CleanUpOnMainThread() OVERRIDE { | 69 virtual void CleanUpOnMainThread() OVERRIDE { |
85 EXPECT_CALL(*mock_protector_service_, Shutdown()); | 70 EXPECT_CALL(*mock_protector_service_, Shutdown()); |
86 } | 71 } |
87 | 72 |
| 73 TemplateURL* MakeTemplateURL(const string16& short_name, |
| 74 const string16& keyword, |
| 75 const std::string& url) { |
| 76 TemplateURLData data; |
| 77 data.short_name = short_name; |
| 78 if (keyword.empty()) |
| 79 data.SetAutogenerateKeyword(true); |
| 80 else |
| 81 data.SetKeyword(keyword); |
| 82 data.SetURL(url); |
| 83 return new TemplateURL(browser()->profile(), data); |
| 84 } |
| 85 |
88 const TemplateURL* FindTemplateURL(const std::string& search_url) { | 86 const TemplateURL* FindTemplateURL(const std::string& search_url) { |
89 TemplateURLService::TemplateURLVector urls = | 87 TemplateURLService::TemplateURLVector urls = |
90 turl_service_->GetTemplateURLs(); | 88 turl_service_->GetTemplateURLs(); |
91 for (TemplateURLService::TemplateURLVector::const_iterator | 89 for (TemplateURLService::TemplateURLVector::const_iterator |
92 it = urls.begin(); it != urls.end(); ++it) { | 90 it = urls.begin(); it != urls.end(); ++it) { |
93 if ((*it)->url() == search_url) | 91 if ((*it)->url() == search_url) |
94 return *it; | 92 return *it; |
95 } | 93 } |
96 return NULL; | 94 return NULL; |
97 } | 95 } |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 // Most common case: current default search provider exists, backup is valid, | 154 // Most common case: current default search provider exists, backup is valid, |
157 // they are different. | 155 // they are different. |
158 TemplateURL* backup_url = | 156 TemplateURL* backup_url = |
159 MakeTemplateURL(example_info, ASCIIToUTF16("a"), http_example_info); | 157 MakeTemplateURL(example_info, ASCIIToUTF16("a"), http_example_info); |
160 int backup_histogram_id = protector::GetSearchProviderHistogramID(backup_url); | 158 int backup_histogram_id = protector::GetSearchProviderHistogramID(backup_url); |
161 TemplateURL* current_url = | 159 TemplateURL* current_url = |
162 MakeTemplateURL(example_com, ASCIIToUTF16("b"), http_example_com); | 160 MakeTemplateURL(example_com, ASCIIToUTF16("b"), http_example_com); |
163 int current_histogram_id = | 161 int current_histogram_id = |
164 protector::GetSearchProviderHistogramID(current_url); | 162 protector::GetSearchProviderHistogramID(current_url); |
165 | 163 |
166 turl_service_->Add(new TemplateURL(backup_url->data())); | 164 Profile* profile = browser()->profile(); |
| 165 turl_service_->Add(new TemplateURL(profile, backup_url->data())); |
167 AddAndSetDefault(current_url); | 166 AddAndSetDefault(current_url); |
168 | 167 |
169 scoped_ptr<BaseSettingChange> change( | 168 scoped_ptr<BaseSettingChange> change( |
170 CreateDefaultSearchProviderChange(current_url, backup_url)); | 169 CreateDefaultSearchProviderChange(current_url, backup_url)); |
171 ASSERT_TRUE(change.get()); | 170 ASSERT_TRUE(change.get()); |
172 ASSERT_TRUE(change->Init(browser()->profile())); | 171 ASSERT_TRUE(change->Init(profile)); |
173 | 172 |
174 // Verify that backup is active. | 173 // Verify that backup is active. |
175 EXPECT_EQ(FindTemplateURL(http_example_info), | 174 EXPECT_EQ(FindTemplateURL(http_example_info), |
176 turl_service_->GetDefaultSearchProvider()); | 175 turl_service_->GetDefaultSearchProvider()); |
177 | 176 |
178 // Verify histograms. | 177 // Verify histograms. |
179 ExpectHistogramCount(kProtectorHistogramSearchProviderHijacked, | 178 ExpectHistogramCount(kProtectorHistogramSearchProviderHijacked, |
180 current_histogram_id, 1); | 179 current_histogram_id, 1); |
181 ExpectHistogramCount(kProtectorHistogramSearchProviderRestored, | 180 ExpectHistogramCount(kProtectorHistogramSearchProviderRestored, |
182 backup_histogram_id, 1); | 181 backup_histogram_id, 1); |
(...skipping 26 matching lines...) Expand all Loading... |
209 // Verify that search provider names that are too long are not displayed. | 208 // Verify that search provider names that are too long are not displayed. |
210 TemplateURL* backup_url = | 209 TemplateURL* backup_url = |
211 MakeTemplateURL(example_info, ASCIIToUTF16("a"), http_example_info); | 210 MakeTemplateURL(example_info, ASCIIToUTF16("a"), http_example_info); |
212 TemplateURL* backup_url_long = | 211 TemplateURL* backup_url_long = |
213 MakeTemplateURL(example_info_long, ASCIIToUTF16("a"), http_example_info); | 212 MakeTemplateURL(example_info_long, ASCIIToUTF16("a"), http_example_info); |
214 TemplateURL* current_url = | 213 TemplateURL* current_url = |
215 MakeTemplateURL(example_com, ASCIIToUTF16("b"), http_example_com); | 214 MakeTemplateURL(example_com, ASCIIToUTF16("b"), http_example_com); |
216 TemplateURL* current_url_long = | 215 TemplateURL* current_url_long = |
217 MakeTemplateURL(example_com_long, ASCIIToUTF16("b"), http_example_com); | 216 MakeTemplateURL(example_com_long, ASCIIToUTF16("b"), http_example_com); |
218 | 217 |
| 218 Profile* profile = browser()->profile(); |
219 { | 219 { |
220 // Backup name too long. | 220 // Backup name too long. |
221 turl_service_->Add(new TemplateURL(backup_url_long->data())); | 221 turl_service_->Add(new TemplateURL(profile, backup_url_long->data())); |
222 AddAndSetDefault(current_url); | 222 AddAndSetDefault(current_url); |
223 | 223 |
224 scoped_ptr<BaseSettingChange> change( | 224 scoped_ptr<BaseSettingChange> change( |
225 CreateDefaultSearchProviderChange(current_url, backup_url_long)); | 225 CreateDefaultSearchProviderChange(current_url, backup_url_long)); |
226 ASSERT_TRUE(change.get()); | 226 ASSERT_TRUE(change.get()); |
227 ASSERT_TRUE(change->Init(browser()->profile())); | 227 ASSERT_TRUE(change->Init(profile)); |
228 | 228 |
229 // Verify text messages. | 229 // Verify text messages. |
230 EXPECT_EQ(GetBubbleMessage(), change->GetBubbleMessage()); | 230 EXPECT_EQ(GetBubbleMessage(), change->GetBubbleMessage()); |
231 EXPECT_EQ(GetChangeSearchButtonText(example_com), | 231 EXPECT_EQ(GetChangeSearchButtonText(example_com), |
232 change->GetApplyButtonText()); | 232 change->GetApplyButtonText()); |
233 EXPECT_EQ(GetKeepSearchButtonText(), change->GetDiscardButtonText()); | 233 EXPECT_EQ(GetKeepSearchButtonText(), change->GetDiscardButtonText()); |
234 EXPECT_EQ(example_com_domain, change->GetNewSettingURL().host()); | 234 EXPECT_EQ(example_com_domain, change->GetNewSettingURL().host()); |
235 EXPECT_EQ(example_com, change->GetApplyDisplayName().second); | 235 EXPECT_EQ(example_com, change->GetApplyDisplayName().second); |
236 } | 236 } |
237 | 237 |
238 { | 238 { |
239 // Current name too long. | 239 // Current name too long. |
240 turl_service_->Add(new TemplateURL(backup_url->data())); | 240 turl_service_->Add(new TemplateURL(profile, backup_url->data())); |
241 AddAndSetDefault(current_url_long); | 241 AddAndSetDefault(current_url_long); |
242 | 242 |
243 scoped_ptr<BaseSettingChange> change( | 243 scoped_ptr<BaseSettingChange> change( |
244 CreateDefaultSearchProviderChange(current_url_long, backup_url)); | 244 CreateDefaultSearchProviderChange(current_url_long, backup_url)); |
245 ASSERT_TRUE(change.get()); | 245 ASSERT_TRUE(change.get()); |
246 ASSERT_TRUE(change->Init(browser()->profile())); | 246 ASSERT_TRUE(change->Init(profile)); |
247 | 247 |
248 // Verify text messages. | 248 // Verify text messages. |
249 EXPECT_EQ(GetBubbleMessage(), change->GetBubbleMessage()); | 249 EXPECT_EQ(GetBubbleMessage(), change->GetBubbleMessage()); |
250 EXPECT_EQ(GetChangeSearchButtonText(), change->GetApplyButtonText()); | 250 EXPECT_EQ(GetChangeSearchButtonText(), change->GetApplyButtonText()); |
251 EXPECT_EQ(GetKeepSearchButtonText(example_info), | 251 EXPECT_EQ(GetKeepSearchButtonText(example_info), |
252 change->GetDiscardButtonText()); | 252 change->GetDiscardButtonText()); |
253 EXPECT_EQ(example_com_domain, change->GetNewSettingURL().host()); | 253 EXPECT_EQ(example_com_domain, change->GetNewSettingURL().host()); |
254 EXPECT_EQ(kNoDisplayName, change->GetApplyDisplayName()); | 254 EXPECT_EQ(kNoDisplayName, change->GetApplyDisplayName()); |
255 } | 255 } |
256 } | 256 } |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 turl_service_->GetDefaultSearchProvider()); | 423 turl_service_->GetDefaultSearchProvider()); |
424 } | 424 } |
425 | 425 |
426 IN_PROC_BROWSER_TEST_F(DefaultSearchProviderChangeTest, | 426 IN_PROC_BROWSER_TEST_F(DefaultSearchProviderChangeTest, |
427 BackupValidCurrentRemoved) { | 427 BackupValidCurrentRemoved) { |
428 // Backup is valid, no current search provider. | 428 // Backup is valid, no current search provider. |
429 TemplateURL* backup_url = | 429 TemplateURL* backup_url = |
430 MakeTemplateURL(example_info, ASCIIToUTF16("a"), http_example_info); | 430 MakeTemplateURL(example_info, ASCIIToUTF16("a"), http_example_info); |
431 int backup_histogram_id = protector::GetSearchProviderHistogramID(backup_url); | 431 int backup_histogram_id = protector::GetSearchProviderHistogramID(backup_url); |
432 | 432 |
433 turl_service_->Add(new TemplateURL(backup_url->data())); | 433 Profile* profile = browser()->profile(); |
| 434 turl_service_->Add(new TemplateURL(profile, backup_url->data())); |
434 turl_service_->SetDefaultSearchProvider(NULL); | 435 turl_service_->SetDefaultSearchProvider(NULL); |
435 | 436 |
436 scoped_ptr<BaseSettingChange> change( | 437 scoped_ptr<BaseSettingChange> change( |
437 CreateDefaultSearchProviderChange(NULL, backup_url)); | 438 CreateDefaultSearchProviderChange(NULL, backup_url)); |
438 ASSERT_TRUE(change.get()); | 439 ASSERT_TRUE(change.get()); |
439 ASSERT_TRUE(change->Init(browser()->profile())); | 440 ASSERT_TRUE(change->Init(profile)); |
440 | 441 |
441 // Verify that backup is active. | 442 // Verify that backup is active. |
442 EXPECT_EQ(FindTemplateURL(http_example_info), | 443 EXPECT_EQ(FindTemplateURL(http_example_info), |
443 turl_service_->GetDefaultSearchProvider()); | 444 turl_service_->GetDefaultSearchProvider()); |
444 | 445 |
445 // Verify histograms. | 446 // Verify histograms. |
446 ExpectHistogramCount(kProtectorHistogramSearchProviderHijacked, | 447 ExpectHistogramCount(kProtectorHistogramSearchProviderHijacked, |
447 protector::GetSearchProviderHistogramID(NULL), 1); | 448 protector::GetSearchProviderHistogramID(NULL), 1); |
448 ExpectHistogramCount(kProtectorHistogramSearchProviderRestored, | 449 ExpectHistogramCount(kProtectorHistogramSearchProviderRestored, |
449 backup_histogram_id, 1); | 450 backup_histogram_id, 1); |
(...skipping 23 matching lines...) Expand all Loading... |
473 // Backup is valid, current search provider has no search terms. | 474 // Backup is valid, current search provider has no search terms. |
474 TemplateURL* backup_url = | 475 TemplateURL* backup_url = |
475 MakeTemplateURL(example_info, ASCIIToUTF16("a"), http_example_info); | 476 MakeTemplateURL(example_info, ASCIIToUTF16("a"), http_example_info); |
476 int backup_histogram_id = protector::GetSearchProviderHistogramID(backup_url); | 477 int backup_histogram_id = protector::GetSearchProviderHistogramID(backup_url); |
477 TemplateURL* current_url = | 478 TemplateURL* current_url = |
478 MakeTemplateURL(example_com, ASCIIToUTF16("b"), | 479 MakeTemplateURL(example_com, ASCIIToUTF16("b"), |
479 http_example_com_no_search_terms); | 480 http_example_com_no_search_terms); |
480 int current_histogram_id = | 481 int current_histogram_id = |
481 protector::GetSearchProviderHistogramID(current_url); | 482 protector::GetSearchProviderHistogramID(current_url); |
482 | 483 |
483 turl_service_->Add(new TemplateURL(backup_url->data())); | 484 Profile* profile = browser()->profile(); |
| 485 turl_service_->Add(new TemplateURL(profile, backup_url->data())); |
484 // TODO(ivankr): this may become unsupported soon. | 486 // TODO(ivankr): this may become unsupported soon. |
485 AddAndSetDefault(current_url); | 487 AddAndSetDefault(current_url); |
486 | 488 |
487 scoped_ptr<BaseSettingChange> change( | 489 scoped_ptr<BaseSettingChange> change( |
488 CreateDefaultSearchProviderChange(current_url, backup_url)); | 490 CreateDefaultSearchProviderChange(current_url, backup_url)); |
489 ASSERT_TRUE(change.get()); | 491 ASSERT_TRUE(change.get()); |
490 ASSERT_TRUE(change->Init(browser()->profile())); | 492 ASSERT_TRUE(change->Init(profile)); |
491 | 493 |
492 // Verify that backup is active. | 494 // Verify that backup is active. |
493 EXPECT_EQ(FindTemplateURL(http_example_info), | 495 EXPECT_EQ(FindTemplateURL(http_example_info), |
494 turl_service_->GetDefaultSearchProvider()); | 496 turl_service_->GetDefaultSearchProvider()); |
495 | 497 |
496 // Verify histograms. | 498 // Verify histograms. |
497 ExpectHistogramCount(kProtectorHistogramSearchProviderHijacked, | 499 ExpectHistogramCount(kProtectorHistogramSearchProviderHijacked, |
498 current_histogram_id, 1); | 500 current_histogram_id, 1); |
499 ExpectHistogramCount(kProtectorHistogramSearchProviderRestored, | 501 ExpectHistogramCount(kProtectorHistogramSearchProviderRestored, |
500 backup_histogram_id, 1); | 502 backup_histogram_id, 1); |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
606 DefaultSearchProviderChangedByUser) { | 608 DefaultSearchProviderChangedByUser) { |
607 // Default search provider is changed by user while the error is active. | 609 // Default search provider is changed by user while the error is active. |
608 // Setup is the same as in BackupValid test case. | 610 // Setup is the same as in BackupValid test case. |
609 TemplateURL* backup_url = | 611 TemplateURL* backup_url = |
610 MakeTemplateURL(example_info, ASCIIToUTF16("a"), http_example_info); | 612 MakeTemplateURL(example_info, ASCIIToUTF16("a"), http_example_info); |
611 TemplateURL* current_url = | 613 TemplateURL* current_url = |
612 MakeTemplateURL(example_com, ASCIIToUTF16("b"), http_example_com); | 614 MakeTemplateURL(example_com, ASCIIToUTF16("b"), http_example_com); |
613 TemplateURL* new_url = | 615 TemplateURL* new_url = |
614 MakeTemplateURL(example_net, ASCIIToUTF16("c"), http_example_net); | 616 MakeTemplateURL(example_net, ASCIIToUTF16("c"), http_example_net); |
615 | 617 |
616 turl_service_->Add(new TemplateURL(backup_url->data())); | 618 Profile* profile = browser()->profile(); |
| 619 turl_service_->Add(new TemplateURL(profile, backup_url->data())); |
617 AddAndSetDefault(current_url); | 620 AddAndSetDefault(current_url); |
618 | 621 |
619 scoped_ptr<BaseSettingChange> change( | 622 scoped_ptr<BaseSettingChange> change( |
620 CreateDefaultSearchProviderChange(current_url, backup_url)); | 623 CreateDefaultSearchProviderChange(current_url, backup_url)); |
621 ASSERT_TRUE(change.get()); | 624 ASSERT_TRUE(change.get()); |
622 ASSERT_TRUE(change->Init(browser()->profile())); | 625 ASSERT_TRUE(change->Init(profile)); |
623 | 626 |
624 // Verify that backup is active. | 627 // Verify that backup is active. |
625 EXPECT_EQ(FindTemplateURL(http_example_info), | 628 EXPECT_EQ(FindTemplateURL(http_example_info), |
626 turl_service_->GetDefaultSearchProvider()); | 629 turl_service_->GetDefaultSearchProvider()); |
627 | 630 |
628 // Verify that changing search provider externally dismissed the change. | 631 // Verify that changing search provider externally dismissed the change. |
629 EXPECT_CALL(*mock_protector_service_, DismissChange(change.get())); | 632 EXPECT_CALL(*mock_protector_service_, DismissChange(change.get())); |
630 AddAndSetDefault(new_url); | 633 AddAndSetDefault(new_url); |
631 } | 634 } |
632 | 635 |
633 IN_PROC_BROWSER_TEST_F(DefaultSearchProviderChangeTest, | 636 IN_PROC_BROWSER_TEST_F(DefaultSearchProviderChangeTest, |
634 CurrentSearchProviderRemovedByUser) { | 637 CurrentSearchProviderRemovedByUser) { |
635 // Current search provider is removed by user while the error is active. | 638 // Current search provider is removed by user while the error is active. |
636 // Setup is the same as in BackupValid test case. | 639 // Setup is the same as in BackupValid test case. |
637 TemplateURL* backup_url = | 640 TemplateURL* backup_url = |
638 MakeTemplateURL(example_info, ASCIIToUTF16("a"), http_example_info); | 641 MakeTemplateURL(example_info, ASCIIToUTF16("a"), http_example_info); |
639 TemplateURL* current_url = | 642 TemplateURL* current_url = |
640 MakeTemplateURL(example_com, ASCIIToUTF16("b"), http_example_com); | 643 MakeTemplateURL(example_com, ASCIIToUTF16("b"), http_example_com); |
641 | 644 |
642 turl_service_->Add(new TemplateURL(backup_url->data())); | 645 Profile* profile = browser()->profile(); |
| 646 turl_service_->Add(new TemplateURL(profile, backup_url->data())); |
643 AddAndSetDefault(current_url); | 647 AddAndSetDefault(current_url); |
644 | 648 |
645 scoped_ptr<BaseSettingChange> change( | 649 scoped_ptr<BaseSettingChange> change( |
646 CreateDefaultSearchProviderChange(current_url, backup_url)); | 650 CreateDefaultSearchProviderChange(current_url, backup_url)); |
647 ASSERT_TRUE(change.get()); | 651 ASSERT_TRUE(change.get()); |
648 ASSERT_TRUE(change->Init(browser()->profile())); | 652 ASSERT_TRUE(change->Init(profile)); |
649 | 653 |
650 // Verify that backup is active. | 654 // Verify that backup is active. |
651 EXPECT_EQ(FindTemplateURL(http_example_info), | 655 EXPECT_EQ(FindTemplateURL(http_example_info), |
652 turl_service_->GetDefaultSearchProvider()); | 656 turl_service_->GetDefaultSearchProvider()); |
653 | 657 |
654 turl_service_->Remove(current_url); | 658 turl_service_->Remove(current_url); |
655 | 659 |
656 // Verify that text messages altered after removing |current_url|. | 660 // Verify that text messages altered after removing |current_url|. |
657 EXPECT_EQ(GetBubbleMessage(), change->GetBubbleMessage()); | 661 EXPECT_EQ(GetBubbleMessage(), change->GetBubbleMessage()); |
658 EXPECT_EQ(GetOpenSettingsButtonText(), change->GetApplyButtonText()); | 662 EXPECT_EQ(GetOpenSettingsButtonText(), change->GetApplyButtonText()); |
659 EXPECT_EQ(GetKeepSearchButtonText(example_info), | 663 EXPECT_EQ(GetKeepSearchButtonText(example_info), |
660 change->GetDiscardButtonText()); | 664 change->GetDiscardButtonText()); |
661 EXPECT_EQ(GURL(), change->GetNewSettingURL()); | 665 EXPECT_EQ(GURL(), change->GetNewSettingURL()); |
662 EXPECT_EQ(kNoDisplayName, change->GetApplyDisplayName()); | 666 EXPECT_EQ(kNoDisplayName, change->GetApplyDisplayName()); |
663 | 667 |
664 // Verify that search engine settings are opened by Apply. | 668 // Verify that search engine settings are opened by Apply. |
665 ExpectSettingsOpened(chrome::kSearchEnginesSubPage); | 669 ExpectSettingsOpened(chrome::kSearchEnginesSubPage); |
666 change->Apply(browser()); | 670 change->Apply(browser()); |
667 EXPECT_EQ(FindTemplateURL(http_example_info), | 671 EXPECT_EQ(FindTemplateURL(http_example_info), |
668 turl_service_->GetDefaultSearchProvider()); | 672 turl_service_->GetDefaultSearchProvider()); |
669 | 673 |
670 // Discard does nothing - backup was already active. | 674 // Discard does nothing - backup was already active. |
671 change->Discard(browser()); | 675 change->Discard(browser()); |
672 EXPECT_EQ(FindTemplateURL(http_example_info), | 676 EXPECT_EQ(FindTemplateURL(http_example_info), |
673 turl_service_->GetDefaultSearchProvider()); | 677 turl_service_->GetDefaultSearchProvider()); |
674 } | 678 } |
675 | 679 |
676 } // namespace protector | 680 } // namespace protector |
OLD | NEW |