| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/test/data/webui/edit_search_engine_dialog_browsertest.h" | 5 #include "chrome/test/data/webui/edit_search_engine_dialog_browsertest.h" |
| 6 | 6 |
| 7 #include "base/stringprintf.h" | 7 #include "base/stringprintf.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/browser/search_engines/template_url.h" | 9 #include "chrome/browser/search_engines/template_url.h" |
| 10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
| 11 #include "chrome/browser/ui/webui/chrome_web_ui.h" | 11 #include "chrome/browser/ui/webui/chrome_web_ui.h" |
| 12 #include "chrome/browser/ui/webui/edit_search_engine_dialog_webui.h" | 12 #include "chrome/browser/ui/webui/edit_search_engine_dialog_webui.h" |
| 13 #include "chrome/common/url_constants.h" | 13 #include "chrome/common/url_constants.h" |
| 14 #include "chrome/test/base/test_html_dialog_observer.h" | 14 #include "chrome/test/base/test_html_dialog_observer.h" |
| 15 #include "content/browser/renderer_host/render_view_host.h" | 15 #include "content/browser/renderer_host/render_view_host.h" |
| 16 #include "content/browser/tab_contents/tab_contents.h" | |
| 17 #include "content/browser/webui/web_ui.h" | 16 #include "content/browser/webui/web_ui.h" |
| 17 #include "content/public/browser/web_contents.h" |
| 18 | 18 |
| 19 namespace { | 19 namespace { |
| 20 | 20 |
| 21 // Creates a Template URL for testing purposes. | 21 // Creates a Template URL for testing purposes. |
| 22 TemplateURL* CreateTestTemplateURL(int seed) { | 22 TemplateURL* CreateTestTemplateURL(int seed) { |
| 23 TemplateURL* turl = new TemplateURL(); | 23 TemplateURL* turl = new TemplateURL(); |
| 24 turl->SetURL(base::StringPrintf("http://www.test%d.com/", seed), 0, 0); | 24 turl->SetURL(base::StringPrintf("http://www.test%d.com/", seed), 0, 0); |
| 25 turl->set_keyword(ASCIIToUTF16(base::StringPrintf("keyword%d", seed))); | 25 turl->set_keyword(ASCIIToUTF16(base::StringPrintf("keyword%d", seed))); |
| 26 turl->set_short_name(ASCIIToUTF16(base::StringPrintf("short%d", seed))); | 26 turl->set_short_name(ASCIIToUTF16(base::StringPrintf("short%d", seed))); |
| 27 turl->set_safe_for_autoreplace(true); | 27 turl->set_safe_for_autoreplace(true); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 48 TestHtmlDialogObserver dialog_observer(this); | 48 TestHtmlDialogObserver dialog_observer(this); |
| 49 | 49 |
| 50 // Show the Edit Search Engine Dialog. | 50 // Show the Edit Search Engine Dialog. |
| 51 EditSearchEngineDialogWebUI::ShowEditSearchEngineDialog( | 51 EditSearchEngineDialogWebUI::ShowEditSearchEngineDialog( |
| 52 CreateTestTemplateURL(0), | 52 CreateTestTemplateURL(0), |
| 53 browser()->profile()); | 53 browser()->profile()); |
| 54 | 54 |
| 55 // Now we can get the WebUI object from the observer, and make some details | 55 // Now we can get the WebUI object from the observer, and make some details |
| 56 // about our test available to the JavaScript. | 56 // about our test available to the JavaScript. |
| 57 WebUI* webui = dialog_observer.GetWebUI(); | 57 WebUI* webui = dialog_observer.GetWebUI(); |
| 58 webui->tab_contents()->GetRenderViewHost()->SetWebUIProperty( | 58 webui->web_contents()->GetRenderViewHost()->SetWebUIProperty( |
| 59 "expectedUrl", chrome::kChromeUIEditSearchEngineDialogURL); | 59 "expectedUrl", chrome::kChromeUIEditSearchEngineDialogURL); |
| 60 | 60 |
| 61 // Tell the test which WebUI instance we are dealing with and complete | 61 // Tell the test which WebUI instance we are dealing with and complete |
| 62 // initialization of this test. | 62 // initialization of this test. |
| 63 SetWebUIInstance(webui); | 63 SetWebUIInstance(webui); |
| 64 WebUIBrowserTest::SetUpOnMainThread(); | 64 WebUIBrowserTest::SetUpOnMainThread(); |
| 65 } | 65 } |
| OLD | NEW |