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 // Creates a Template URL for testing purposes. | |
21 TemplateURL* CreateTestTemplateURL(int seed) { | |
22 TemplateURL* turl = new TemplateURL(); | |
23 turl->SetURL(base::StringPrintf("http://www.test%d.com/", seed), 0, 0); | |
24 turl->set_keyword(ASCIIToUTF16(base::StringPrintf("keyword%d", seed))); | |
25 turl->set_short_name(ASCIIToUTF16(base::StringPrintf("short%d", seed))); | |
26 turl->set_safe_for_autoreplace(true); | |
27 GURL favicon_url("http://favicon.url"); | |
28 turl->SetFaviconURL(favicon_url); | |
29 turl->set_date_created(base::Time::FromTimeT(100)); | |
30 turl->set_last_modified(base::Time::FromTimeT(100)); | |
31 turl->SetPrepopulateId(999999); | |
32 turl->set_sync_guid(base::StringPrintf("0000-0000-0000-%04d", seed)); | |
33 return turl; | |
34 } | |
35 } // namesapce | |
Sheridan Rawlins
2011/11/30 00:14:01
nit: typo
kevers
2011/11/30 15:54:54
Done.
| |
36 | |
37 EditSearchEngineDialogUITest::EditSearchEngineDialogUITest() {} | |
38 | |
39 EditSearchEngineDialogUITest::~EditSearchEngineDialogUITest() {} | |
40 | |
41 // TODO(kevers): Factor this out into its own non-virtual method and call it | |
42 // with a testGenPreamble GEN line once the fix for | |
43 // chromium:104371 is committed. | |
44 void EditSearchEngineDialogUITest::SetUpOnMainThread() { | |
45 // Force the flag so that we will use the WebUI version of the Dialog. | |
46 ChromeWebUI::OverrideMoreWebUI(true); | |
47 | |
48 // The TestHtmlDialogObserver will catch our dialog when it gets created. | |
49 TestHtmlDialogObserver dialog_observer; | |
50 | |
51 // Show the Edit Search Engine Dialog. | |
52 EditSearchEngineDialogWebUI::ShowEditSearchEngineDialog( | |
53 CreateTestTemplateURL(0), | |
54 browser()->profile()); | |
55 | |
56 // Now we can get the WebUI object from the observer, and make some details | |
57 // about our test available to the JavaScript. | |
58 WebUI* webui = dialog_observer.GetWebUI(); | |
59 webui->tab_contents()->render_view_host()->SetWebUIProperty( | |
60 "expectedUrl", chrome::kChromeUIEditSearchEngineDialogURL); | |
61 | |
62 // Tell the test which WebUI instance we are dealing with and complete | |
63 // initialization of this test. | |
64 SetWebUIInstance(webui); | |
65 WebUIBrowserTest::SetUpOnMainThread(); | |
66 } | |
OLD | NEW |