Chromium Code Reviews| 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 "base/stringprintf.h" | |
| 6 #include "base/utf_string_conversions.h" | |
| 7 #include "chrome/browser/search_engines/template_url.h" | |
| 8 #include "chrome/browser/ui/browser.h" | |
| 9 #include "chrome/browser/ui/webui/chrome_web_ui.h" | |
| 10 #include "chrome/browser/ui/webui/edit_search_engine_dialog_webui.h" | |
| 11 #include "chrome/browser/ui/webui/web_ui_browsertest.h" | |
| 12 #include "chrome/common/url_constants.h" | |
| 13 #include "chrome/test/base/test_html_dialog_observer.h" | |
| 14 #include "content/browser/renderer_host/render_view_host.h" | |
| 15 #include "content/browser/tab_contents/tab_contents.h" | |
| 16 #include "content/browser/webui/web_ui.h" | |
| 17 | |
| 18 // Test framework for chrome/test/data/webui/edit_search_engine_dialog_test.js. | |
| 19 class EditSearchEngineDialogUITest : public WebUIBrowserTest { | |
| 20 public: | |
| 21 EditSearchEngineDialogUITest(); | |
| 22 virtual ~EditSearchEngineDialogUITest(); | |
| 23 | |
| 24 private: | |
| 25 virtual void SetUpOnMainThread() OVERRIDE; | |
| 26 }; | |
| 27 | |
| 28 namespace { | |
| 29 // Creates a Template URL for testing purposes. | |
| 30 TemplateURL* CreateTestTemplateURL(int seed) { | |
| 31 TemplateURL* turl = new TemplateURL(); | |
| 32 turl->SetURL(base::StringPrintf("http://www.test%d.com/", seed), 0, 0); | |
| 33 turl->set_keyword(ASCIIToUTF16(base::StringPrintf("keyword%d", seed))); | |
| 34 turl->set_short_name(ASCIIToUTF16(base::StringPrintf("short%d", seed))); | |
| 35 turl->set_safe_for_autoreplace(true); | |
| 36 GURL favicon_url("http://favicon.url"); | |
| 37 turl->SetFaviconURL(favicon_url); | |
| 38 turl->set_date_created(base::Time::FromTimeT(100)); | |
| 39 turl->set_last_modified(base::Time::FromTimeT(100)); | |
| 40 turl->SetPrepopulateId(999999); | |
| 41 turl->set_sync_guid(base::StringPrintf("0000-0000-0000-%04d", seed)); | |
| 42 return turl; | |
| 43 } | |
| 44 } // namesapce | |
| 45 | |
| 46 void EditSearchEngineDialogUITest::SetUpOnMainThread() { | |
|
Sheridan Rawlins
2011/11/23 20:36:26
Can you have a look at http://codereview.chromium.
kevers
2011/11/24 20:03:25
See two options here: wait until 8586009 lands and
Sheridan Rawlins
2011/11/28 22:32:45
I'll back off on doing in this CL, if you just can
kevers
2011/11/29 17:36:37
Done.
kevers
2011/11/30 15:54:54
I see that http://codereview.chromium.org/8586009/
| |
| 47 // Force the flag so that we will use the WebUI version of the Dialog. | |
| 48 ChromeWebUI::OverrideMoreWebUI(true); | |
| 49 | |
| 50 // The TestHtmlDialogObserver will catch our dialog when it gets created. | |
| 51 TestHtmlDialogObserver dialog_observer; | |
| 52 | |
| 53 // Show the Edit Search Engine Dialog. | |
| 54 EditSearchEngineDialogWebUI::ShowEditSearchEngineDialog( | |
| 55 CreateTestTemplateURL(0), | |
| 56 browser()->profile()); | |
| 57 | |
| 58 // Now we can get the WebUI object from the observer, and make some details | |
| 59 // about our test available to the JavaScript. | |
| 60 WebUI* webui = dialog_observer.GetWebUI(); | |
| 61 webui->tab_contents()->render_view_host()->SetWebUIProperty( | |
| 62 "expectedUrl", chrome::kChromeUIEditSearchEngineDialogURL); | |
| 63 | |
| 64 // Tell the test which WebUI instance we are dealing with and complete | |
| 65 // initialization of this test. | |
| 66 SetWebUIInstance(webui); | |
| 67 WebUIBrowserTest::SetUpOnMainThread(); | |
| 68 } | |
| OLD | NEW |