| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <utility> | 6 #include <utility> |
| 7 | 7 |
| 8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 TemplateURLServiceFactory::GetInstance()->GetForProfile( | 75 TemplateURLServiceFactory::GetInstance()->GetForProfile( |
| 76 browser()->profile()); | 76 browser()->profile()); |
| 77 TemplateURLServiceLoader loader(template_urls); | 77 TemplateURLServiceLoader loader(template_urls); |
| 78 | 78 |
| 79 TemplateURLService::TemplateURLVector all_urls = | 79 TemplateURLService::TemplateURLVector all_urls = |
| 80 template_urls->GetTemplateURLs(); | 80 template_urls->GetTemplateURLs(); |
| 81 | 81 |
| 82 // We need to substract the default pre-populated engines that the profile is | 82 // We need to substract the default pre-populated engines that the profile is |
| 83 // set up with. | 83 // set up with. |
| 84 size_t default_index = 0; | 84 size_t default_index = 0; |
| 85 ScopedVector<TemplateURLData> prepopulate_urls = | 85 std::vector<std::unique_ptr<TemplateURLData>> prepopulate_urls = |
| 86 TemplateURLPrepopulateData::GetPrepopulatedEngines( | 86 TemplateURLPrepopulateData::GetPrepopulatedEngines( |
| 87 browser()->profile()->GetPrefs(), | 87 browser()->profile()->GetPrefs(), &default_index); |
| 88 &default_index); | |
| 89 | 88 |
| 90 EXPECT_EQ(prepopulate_urls.size(), all_urls.size()); | 89 EXPECT_EQ(prepopulate_urls.size(), all_urls.size()); |
| 91 | 90 |
| 92 std::string port(base::IntToString(embedded_test_server()->port())); | 91 std::string port(base::IntToString(embedded_test_server()->port())); |
| 93 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete( | 92 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete( |
| 94 browser(), GURL("http://www.foo.com:" + port + "/"), 1); | 93 browser(), GURL("http://www.foo.com:" + port + "/"), 1); |
| 95 | 94 |
| 96 base::string16 title; | 95 base::string16 title; |
| 97 ui_test_utils::GetCurrentTabTitle(browser(), &title); | 96 ui_test_utils::GetCurrentTabTitle(browser(), &title); |
| 98 ASSERT_EQ(base::ASCIIToUTF16("Submit handler TemplateURL scraping test"), | 97 ASSERT_EQ(base::ASCIIToUTF16("Submit handler TemplateURL scraping test"), |
| 99 title); | 98 title); |
| 100 | 99 |
| 101 content::WebContents* web_contents = | 100 content::WebContents* web_contents = |
| 102 browser()->tab_strip_model()->GetActiveWebContents(); | 101 browser()->tab_strip_model()->GetActiveWebContents(); |
| 103 content::TestNavigationObserver observer(web_contents); | 102 content::TestNavigationObserver observer(web_contents); |
| 104 EXPECT_TRUE(content::ExecuteScript(web_contents, "submit_form()")); | 103 EXPECT_TRUE(content::ExecuteScript(web_contents, "submit_form()")); |
| 105 observer.Wait(); | 104 observer.Wait(); |
| 106 | 105 |
| 107 all_urls = template_urls->GetTemplateURLs(); | 106 all_urls = template_urls->GetTemplateURLs(); |
| 108 EXPECT_EQ(prepopulate_urls.size() + 1, all_urls.size()); | 107 EXPECT_EQ(prepopulate_urls.size() + 1, all_urls.size()); |
| 109 } | 108 } |
| OLD | NEW |