OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/test/data/webui/edit_search_engine_dialog_browsertest.h" |
| 6 |
| 7 #include "base/stringprintf.h" |
| 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/browser/search_engines/template_url.h" |
| 10 #include "chrome/browser/ui/browser.h" |
| 11 #include "chrome/browser/ui/webui/chrome_web_ui.h" |
| 12 #include "chrome/browser/ui/webui/edit_search_engine_dialog_webui.h" |
| 13 #include "chrome/common/url_constants.h" |
| 14 #include "chrome/test/base/test_html_dialog_observer.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" |
| 18 |
| 19 namespace { |
| 20 |
| 21 // Creates a Template URL for testing purposes. |
| 22 TemplateURL* CreateTestTemplateURL(int seed) { |
| 23 TemplateURL* turl = new TemplateURL(); |
| 24 turl->SetURL(base::StringPrintf("http://www.test%d.com/", seed), 0, 0); |
| 25 turl->set_keyword(ASCIIToUTF16(base::StringPrintf("keyword%d", seed))); |
| 26 turl->set_short_name(ASCIIToUTF16(base::StringPrintf("short%d", seed))); |
| 27 turl->set_safe_for_autoreplace(true); |
| 28 GURL favicon_url("http://favicon.url"); |
| 29 turl->SetFaviconURL(favicon_url); |
| 30 turl->set_date_created(base::Time::FromTimeT(100)); |
| 31 turl->set_last_modified(base::Time::FromTimeT(100)); |
| 32 turl->SetPrepopulateId(999999); |
| 33 turl->set_sync_guid(base::StringPrintf("0000-0000-0000-%04d", seed)); |
| 34 return turl; |
| 35 } |
| 36 |
| 37 } // namespace |
| 38 |
| 39 EditSearchEngineDialogUITest::EditSearchEngineDialogUITest() {} |
| 40 |
| 41 EditSearchEngineDialogUITest::~EditSearchEngineDialogUITest() {} |
| 42 |
| 43 void EditSearchEngineDialogUITest::ShowSearchEngineDialog() { |
| 44 // Force the flag so that we will use the WebUI version of the Dialog. |
| 45 ChromeWebUI::OverrideMoreWebUI(true); |
| 46 |
| 47 // The TestHtmlDialogObserver will catch our dialog when it gets created. |
| 48 TestHtmlDialogObserver dialog_observer(this); |
| 49 |
| 50 // Show the Edit Search Engine Dialog. |
| 51 EditSearchEngineDialogWebUI::ShowEditSearchEngineDialog( |
| 52 CreateTestTemplateURL(0), |
| 53 browser()->profile()); |
| 54 |
| 55 // Now we can get the WebUI object from the observer, and make some details |
| 56 // about our test available to the JavaScript. |
| 57 WebUI* webui = dialog_observer.GetWebUI(); |
| 58 webui->tab_contents()->render_view_host()->SetWebUIProperty( |
| 59 "expectedUrl", chrome::kChromeUIEditSearchEngineDialogURL); |
| 60 |
| 61 // Tell the test which WebUI instance we are dealing with and complete |
| 62 // initialization of this test. |
| 63 SetWebUIInstance(webui); |
| 64 WebUIBrowserTest::SetUpOnMainThread(); |
| 65 } |
OLD | NEW |