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

Unified Diff: chrome/browser/dom_ui/constrained_html_ui_browsertest.cc

Issue 3790013: Add a test for ConstrainedHtmlUI. (Closed) Base URL: http://git.chromium.org/git/chromium.git
Patch Set: Created 10 years, 2 months 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
« no previous file with comments | « no previous file | chrome/browser/dom_ui/dom_ui_factory.cc » ('j') | chrome/chrome_tests.gypi » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/dom_ui/constrained_html_ui_browsertest.cc
diff --git a/chrome/browser/dom_ui/constrained_html_ui_browsertest.cc b/chrome/browser/dom_ui/constrained_html_ui_browsertest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..cc21bfa26f412cb3e9bf0af200932fc28abe3bda
--- /dev/null
+++ b/chrome/browser/dom_ui/constrained_html_ui_browsertest.cc
@@ -0,0 +1,74 @@
+// Copyright (c) 2010 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/ui/ui_test.h"
+
+#include "base/file_path.h"
+#include "base/message_loop.h"
+#include "chrome/browser/browser_thread.h"
+#include "chrome/browser/dom_ui/constrained_html_ui.h"
+#include "chrome/browser/dom_ui/html_dialog_ui.h"
+#include "chrome/browser/renderer_host/render_widget_host_view.h"
+#include "chrome/browser/tab_contents/tab_contents.h"
+#include "chrome/common/url_constants.h"
+#include "chrome/test/in_process_browser_test.h"
+#include "chrome/test/ui_test_utils.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "testing/gmock/include/gmock/gmock.h"
+
+using testing::Eq;
+
+namespace {
+
+class TestHtmlDialogUIDelegate : public HtmlDialogUIDelegate {
+ public:
+ TestHtmlDialogUIDelegate() {}
+ virtual ~TestHtmlDialogUIDelegate() {}
+
+ // HTMLDialogUIDelegate implementation:
+ virtual bool IsDialogModal() const {
+ return true;
+ }
+ virtual std::wstring GetDialogTitle() const {
+ return std::wstring(L"Test");
+ }
+ virtual GURL GetDialogContentURL() const {
+ return GURL(chrome::kChromeUIConstrainedHTMLTestURL);
+ }
+ virtual void GetDOMMessageHandlers(
+ std::vector<DOMMessageHandler*>* handlers) const {}
+ virtual void GetDialogSize(gfx::Size* size) const {
+ size->set_width(400);
+ size->set_height(400);
+ }
+ virtual std::string GetDialogArgs() const {
+ return std::string();
+ }
+ virtual void OnDialogClosed(const std::string& json_retval) { }
+ virtual void OnCloseContents(TabContents* source, bool* out_close_dialog) {
+ if (out_close_dialog)
+ *out_close_dialog = true;
+ }
+};
+
+} // namespace
+
+class ConstrainedHtmlDialogBrowserTest : public InProcessBrowserTest {
+ public:
+ ConstrainedHtmlDialogBrowserTest() {}
+};
+
+// Tests that opening/closing the constrained window won't crash it.
+IN_PROC_BROWSER_TEST_F(ConstrainedHtmlDialogBrowserTest, BasicTest) {
+ // The delegate deletes itself.
+ HtmlDialogUIDelegate* delegate = new TestHtmlDialogUIDelegate();
+ TabContents* tab_contents = browser()->GetSelectedTabContents();
+ ASSERT_TRUE(tab_contents != NULL);
+
+ ConstrainedHtmlUI::CreateConstrainedHtmlDialog(browser()->profile(),
+ delegate,
+ tab_contents);
+
+ ASSERT_EQ(1U, tab_contents->constrained_window_count());
+}
« no previous file with comments | « no previous file | chrome/browser/dom_ui/dom_ui_factory.cc » ('j') | chrome/chrome_tests.gypi » ('J')

Powered by Google App Engine
This is Rietveld 408576698