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

Side by Side Diff: chrome/browser/search_engines/template_url_scraper_unittest.cc

Issue 62145: Yet another scrape atttempt (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 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
« no previous file with comments | « no previous file | chrome/test/data/template_url_scraper/submit_handler/index.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
2 // source code is governed by a BSD-style license that can be found in the
3 // LICENSE file.
4
5 #include "chrome/browser/browser.h"
6 #include "chrome/browser/profile.h"
7 #include "chrome/browser/search_engines/template_url_model.h"
8 #include "chrome/browser/search_engines/template_url_prepopulate_data.h"
9 #include "chrome/common/notification_registrar.h"
10 #include "chrome/common/notification_source.h"
11 #include "chrome/common/notification_type.h"
12 #include "chrome/test/in_process_browser_test.h"
13 #include "chrome/test/ui_test_utils.h"
14 #include "net/base/host_resolver_unittest.h"
15 #include "net/base/net_util.h"
16
17 namespace {
18 class TemplateURLScraperTest : public InProcessBrowserTest {
19 public:
20 TemplateURLScraperTest() {
21 }
22
23 protected:
24 virtual void ConfigureHostMapper(net::RuleBasedHostMapper* host_mapper) {
25 InProcessBrowserTest::ConfigureHostMapper(host_mapper);
26 // We use foo.com in our tests.
27 host_mapper->AddRule("*.foo.com", "localhost");
28 }
29
30 private:
31 DISALLOW_COPY_AND_ASSIGN(TemplateURLScraperTest);
32 };
33
34 class TemplateURLModelLoader : public NotificationObserver {
35 public:
36 explicit TemplateURLModelLoader(TemplateURLModel* model) : model_(model) {
37 registrar_.Add(this, NotificationType::TEMPLATE_URL_MODEL_LOADED,
38 Source<TemplateURLModel>(model));
39 model_->Load();
40 ui_test_utils::RunMessageLoop();
41 }
42
43 virtual void Observe(NotificationType type,
44 const NotificationSource& source,
45 const NotificationDetails& details) {
46 if (type == NotificationType::TEMPLATE_URL_MODEL_LOADED &&
47 Source<TemplateURLModel>(source).ptr() == model_) {
48 MessageLoop::current()->Quit();
49 }
50 }
51
52 private:
53 NotificationRegistrar registrar_;
54
55 TemplateURLModel* model_;
56
57 DISALLOW_COPY_AND_ASSIGN(TemplateURLModelLoader);
58 };
59
60 } // namespace
61
62 /*
63 IN_PROC_BROWSER_TEST_F(TemplateURLScraperTest, ScrapeWithOnSubmit) {
64 TemplateURLModel* template_urls = browser()->profile()->GetTemplateURLModel();
65 TemplateURLModelLoader loader(template_urls);
66
67 std::vector<const TemplateURL*> all_urls = template_urls->GetTemplateURLs();
68
69 // We need to substract the default pre-populated engines that the profile is
70 // set up with.
71 size_t default_index = 0;
72 std::vector<TemplateURL*> prepopulate_urls;
73 TemplateURLPrepopulateData::GetPrepopulatedEngines(
74 browser()->profile()->GetPrefs(),
75 &prepopulate_urls,
76 &default_index);
77
78 EXPECT_EQ(prepopulate_urls.size(), all_urls.size());
79
80 scoped_refptr<HTTPTestServer> server(
81 HTTPTestServer::CreateServerWithFileRootURL(
82 L"chrome/test/data/template_url_scraper/submit_handler", L"/",
83 g_browser_process->io_thread()->message_loop()));
84 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(
85 browser(), GURL("http://www.foo.com:1337/"), 2);
86
87 all_urls = template_urls->GetTemplateURLs();
88 EXPECT_EQ(1, all_urls.size() - prepopulate_urls.size());
89 }
90 */
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/template_url_scraper/submit_handler/index.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698