Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1230)

Unified Diff: chrome/test/data/webui/edit_search_engine_dialog_browsertest.cc

Issue 8676008: Add automated test for the edit search engine dialog. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: File renames, address nits and add documentation. Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/test/data/webui/edit_search_engine_dialog_browsertest.cc
diff --git a/chrome/test/data/webui/edit_search_engine_dialog_browsertest.cc b/chrome/test/data/webui/edit_search_engine_dialog_browsertest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..076e989426464e4513bbf651f66def683bb46abc
--- /dev/null
+++ b/chrome/test/data/webui/edit_search_engine_dialog_browsertest.cc
@@ -0,0 +1,66 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/test/data/webui/edit_search_engine_dialog_browsertest.h"
+
+#include "base/stringprintf.h"
+#include "base/utf_string_conversions.h"
+#include "chrome/browser/search_engines/template_url.h"
+#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/webui/chrome_web_ui.h"
+#include "chrome/browser/ui/webui/edit_search_engine_dialog_webui.h"
+#include "chrome/common/url_constants.h"
+#include "chrome/test/base/test_html_dialog_observer.h"
+#include "content/browser/renderer_host/render_view_host.h"
+#include "content/browser/tab_contents/tab_contents.h"
+#include "content/browser/webui/web_ui.h"
+
+namespace {
+// Creates a Template URL for testing purposes.
+TemplateURL* CreateTestTemplateURL(int seed) {
+ TemplateURL* turl = new TemplateURL();
+ turl->SetURL(base::StringPrintf("http://www.test%d.com/", seed), 0, 0);
+ turl->set_keyword(ASCIIToUTF16(base::StringPrintf("keyword%d", seed)));
+ turl->set_short_name(ASCIIToUTF16(base::StringPrintf("short%d", seed)));
+ turl->set_safe_for_autoreplace(true);
+ GURL favicon_url("http://favicon.url");
+ turl->SetFaviconURL(favicon_url);
+ turl->set_date_created(base::Time::FromTimeT(100));
+ turl->set_last_modified(base::Time::FromTimeT(100));
+ turl->SetPrepopulateId(999999);
+ turl->set_sync_guid(base::StringPrintf("0000-0000-0000-%04d", seed));
+ return turl;
+}
+} // namesapce
Sheridan Rawlins 2011/11/30 00:14:01 nit: typo
kevers 2011/11/30 15:54:54 Done.
+
+EditSearchEngineDialogUITest::EditSearchEngineDialogUITest() {}
+
+EditSearchEngineDialogUITest::~EditSearchEngineDialogUITest() {}
+
+// TODO(kevers): Factor this out into its own non-virtual method and call it
+// with a testGenPreamble GEN line once the fix for
+// chromium:104371 is committed.
+void EditSearchEngineDialogUITest::SetUpOnMainThread() {
+ // Force the flag so that we will use the WebUI version of the Dialog.
+ ChromeWebUI::OverrideMoreWebUI(true);
+
+ // The TestHtmlDialogObserver will catch our dialog when it gets created.
+ TestHtmlDialogObserver dialog_observer;
+
+ // Show the Edit Search Engine Dialog.
+ EditSearchEngineDialogWebUI::ShowEditSearchEngineDialog(
+ CreateTestTemplateURL(0),
+ browser()->profile());
+
+ // Now we can get the WebUI object from the observer, and make some details
+ // about our test available to the JavaScript.
+ WebUI* webui = dialog_observer.GetWebUI();
+ webui->tab_contents()->render_view_host()->SetWebUIProperty(
+ "expectedUrl", chrome::kChromeUIEditSearchEngineDialogURL);
+
+ // Tell the test which WebUI instance we are dealing with and complete
+ // initialization of this test.
+ SetWebUIInstance(webui);
+ WebUIBrowserTest::SetUpOnMainThread();
+}

Powered by Google App Engine
This is Rietveld 408576698