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

Side by Side Diff: chrome/browser/protector/default_search_provider_change_browsertest.cc

Issue 10033017: More misc. cleanups to minimize future refactoring diffs. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/histograms.h" 9 #include "chrome/browser/protector/histograms.h"
10 #include "chrome/browser/protector/mock_protector_service.h" 10 #include "chrome/browser/protector/mock_protector_service.h"
11 #include "chrome/browser/protector/protector_service_factory.h" 11 #include "chrome/browser/protector/protector_service_factory.h"
12 #include "chrome/browser/search_engines/template_url.h" 12 #include "chrome/browser/search_engines/template_url.h"
13 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" 13 #include "chrome/browser/search_engines/template_url_prepopulate_data.h"
14 #include "chrome/browser/search_engines/template_url_service.h" 14 #include "chrome/browser/search_engines/template_url_service.h"
15 #include "chrome/browser/search_engines/template_url_service_factory.h" 15 #include "chrome/browser/search_engines/template_url_service_factory.h"
16 #include "chrome/browser/ui/browser.h" 16 #include "chrome/browser/ui/browser.h"
17 #include "chrome/common/url_constants.h" 17 #include "chrome/common/url_constants.h"
18 #include "chrome/test/base/in_process_browser_test.h" 18 #include "chrome/test/base/in_process_browser_test.h"
19 #include "chrome/test/base/ui_test_utils.h" 19 #include "chrome/test/base/ui_test_utils.h"
20 #include "googleurl/src/gurl.h" 20 #include "googleurl/src/gurl.h"
21 #include "grit/generated_resources.h" 21 #include "grit/generated_resources.h"
22 #include "ui/base/l10n/l10n_util.h" 22 #include "ui/base/l10n/l10n_util.h"
23 23
24 using ::testing::Invoke; 24 using ::testing::Invoke;
25 using ::testing::NiceMock; 25 using ::testing::NiceMock;
26 using ::testing::Return; 26 using ::testing::Return;
27 27
28 namespace protector {
29
30 namespace { 28 namespace {
31 29
32 // Keyword names and URLs used for testing. 30 // Keyword names and URLs used for testing.
33
34 const string16 example_info = ASCIIToUTF16("Example.info"); 31 const string16 example_info = ASCIIToUTF16("Example.info");
35 const string16 example_info_long = ASCIIToUTF16("ExampleSearchEngine.info"); 32 const string16 example_info_long = ASCIIToUTF16("ExampleSearchEngine.info");
36 const std::string http_example_info = "http://example.info/%s"; 33 const std::string http_example_info = "http://example.info/%s";
37 const string16 example_com = ASCIIToUTF16("Example.com"); 34 const string16 example_com = ASCIIToUTF16("Example.com");
38 const string16 example_com_long = ASCIIToUTF16("ExampleSearchEngine.com"); 35 const string16 example_com_long = ASCIIToUTF16("ExampleSearchEngine.com");
39 const std::string http_example_com = "http://example.com/%s"; 36 const std::string http_example_com = "http://example.com/%s";
40 const string16 example_net = ASCIIToUTF16("Example.net"); 37 const string16 example_net = ASCIIToUTF16("Example.net");
41 const std::string http_example_net = "http://example.net/%s"; 38 const std::string http_example_net = "http://example.net/%s";
42 39
43 // Convenience function. 40 // Convenience function.
44 TemplateURL* MakeTemplateURL(const string16& short_name, 41 TemplateURL* MakeTemplateURL(const string16& short_name,
45 const string16& keyword, 42 const string16& keyword,
46 const std::string& url) { 43 const std::string& url) {
47 TemplateURLData data; 44 TemplateURLData data;
48 data.short_name = short_name; 45 data.short_name = short_name;
49 if (keyword.empty()) 46 if (keyword.empty())
50 data.SetAutogenerateKeyword(true); 47 data.SetAutogenerateKeyword(true);
51 else 48 else
52 data.SetKeyword(keyword); 49 data.SetKeyword(keyword);
53 data.SetURL(url); 50 data.SetURL(url);
54 return new TemplateURL(data); 51 return new TemplateURL(data);
55 } 52 }
56 53
57 }; 54 };
58 55
56 namespace protector {
57
59 class DefaultSearchProviderChangeTest : public InProcessBrowserTest { 58 class DefaultSearchProviderChangeTest : public InProcessBrowserTest {
60 public: 59 public:
61 virtual void SetUpOnMainThread() OVERRIDE { 60 virtual void SetUpOnMainThread() OVERRIDE {
62 mock_protector_service_ = 61 mock_protector_service_ =
63 MockProtectorService::BuildForProfile(browser()->profile()); 62 MockProtectorService::BuildForProfile(browser()->profile());
64 63
65 // Ensure that TemplateURLService is loaded. 64 // Ensure that TemplateURLService is loaded.
66 turl_service_ = 65 turl_service_ =
67 TemplateURLServiceFactory::GetForProfile(browser()->profile()); 66 TemplateURLServiceFactory::GetForProfile(browser()->profile());
68 ui_test_utils::WaitForTemplateURLServiceToLoad(turl_service_); 67 ui_test_utils::WaitForTemplateURLServiceToLoad(turl_service_);
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 EXPECT_EQ(FindTemplateURL(http_example_info), 532 EXPECT_EQ(FindTemplateURL(http_example_info),
534 turl_service_->GetDefaultSearchProvider()); 533 turl_service_->GetDefaultSearchProvider());
535 534
536 // Discard does nothing - backup was already active. 535 // Discard does nothing - backup was already active.
537 change->Discard(browser()); 536 change->Discard(browser());
538 EXPECT_EQ(FindTemplateURL(http_example_info), 537 EXPECT_EQ(FindTemplateURL(http_example_info),
539 turl_service_->GetDefaultSearchProvider()); 538 turl_service_->GetDefaultSearchProvider());
540 } 539 }
541 540
542 } // namespace protector 541 } // namespace protector
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698