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

Side by Side Diff: chrome/browser/ui/webui/constrained_html_ui_browsertest.cc

Issue 7461136: Convert HtmlDialogUIDelegate::GetDialogTitle() to string16. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more fixes Created 9 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/test/ui/ui_test.h" 5 #include "chrome/test/ui/ui_test.h"
6 6
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/ui/browser.h" 10 #include "chrome/browser/ui/browser.h"
10 #include "chrome/browser/ui/webui/constrained_html_ui.h" 11 #include "chrome/browser/ui/webui/constrained_html_ui.h"
11 #include "chrome/browser/ui/webui/html_dialog_ui.h" 12 #include "chrome/browser/ui/webui/html_dialog_ui.h"
12 #include "chrome/common/url_constants.h" 13 #include "chrome/common/url_constants.h"
13 #include "chrome/test/base/in_process_browser_test.h" 14 #include "chrome/test/base/in_process_browser_test.h"
14 #include "chrome/test/base/ui_test_utils.h" 15 #include "chrome/test/base/ui_test_utils.h"
15 #include "content/browser/renderer_host/render_widget_host_view.h" 16 #include "content/browser/renderer_host/render_widget_host_view.h"
16 #include "content/browser/tab_contents/tab_contents.h" 17 #include "content/browser/tab_contents/tab_contents.h"
17 #include "testing/gmock/include/gmock/gmock.h" 18 #include "testing/gmock/include/gmock/gmock.h"
18 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
19 20
20 using testing::Eq; 21 using testing::Eq;
21 22
22 namespace { 23 namespace {
23 24
24 class TestHtmlDialogUIDelegate : public HtmlDialogUIDelegate { 25 class TestHtmlDialogUIDelegate : public HtmlDialogUIDelegate {
25 public: 26 public:
26 TestHtmlDialogUIDelegate() {} 27 TestHtmlDialogUIDelegate() {}
27 virtual ~TestHtmlDialogUIDelegate() {} 28 virtual ~TestHtmlDialogUIDelegate() {}
28 29
29 // HTMLDialogUIDelegate implementation: 30 // HTMLDialogUIDelegate implementation:
30 virtual bool IsDialogModal() const { 31 virtual bool IsDialogModal() const OVERRIDE {
31 return true; 32 return true;
32 } 33 }
33 virtual std::wstring GetDialogTitle() const { 34 virtual string16 GetDialogTitle() const OVERRIDE {
34 return std::wstring(L"Test"); 35 return UTF8ToUTF16("Test");
35 } 36 }
36 virtual GURL GetDialogContentURL() const { 37 virtual GURL GetDialogContentURL() const OVERRIDE {
37 return GURL(chrome::kChromeUIConstrainedHTMLTestURL); 38 return GURL(chrome::kChromeUIConstrainedHTMLTestURL);
38 } 39 }
39 virtual void GetWebUIMessageHandlers( 40 virtual void GetWebUIMessageHandlers(
40 std::vector<WebUIMessageHandler*>* handlers) const {} 41 std::vector<WebUIMessageHandler*>* handlers) const OVERRIDE {}
41 virtual void GetDialogSize(gfx::Size* size) const { 42 virtual void GetDialogSize(gfx::Size* size) const OVERRIDE {
42 size->set_width(400); 43 size->set_width(400);
43 size->set_height(400); 44 size->set_height(400);
44 } 45 }
45 virtual std::string GetDialogArgs() const { 46 virtual std::string GetDialogArgs() const OVERRIDE {
46 return std::string(); 47 return std::string();
47 } 48 }
48 virtual void OnDialogClosed(const std::string& json_retval) { } 49 virtual void OnDialogClosed(const std::string& json_retval) OVERRIDE { }
49 virtual void OnCloseContents(TabContents* source, bool* out_close_dialog) { 50 virtual void OnCloseContents(TabContents* source, bool* out_close_dialog)
51 OVERRIDE {
50 if (out_close_dialog) 52 if (out_close_dialog)
51 *out_close_dialog = true; 53 *out_close_dialog = true;
52 } 54 }
53 virtual bool ShouldShowDialogTitle() const { return true; } 55 virtual bool ShouldShowDialogTitle() const OVERRIDE { return true; }
54 }; 56 };
55 57
56 } // namespace 58 } // namespace
57 59
58 class ConstrainedHtmlDialogBrowserTest : public InProcessBrowserTest { 60 class ConstrainedHtmlDialogBrowserTest : public InProcessBrowserTest {
59 public: 61 public:
60 ConstrainedHtmlDialogBrowserTest() {} 62 ConstrainedHtmlDialogBrowserTest() {}
61 }; 63 };
62 64
63 // Tests that opening/closing the constrained window won't crash it. 65 // Tests that opening/closing the constrained window won't crash it.
64 IN_PROC_BROWSER_TEST_F(ConstrainedHtmlDialogBrowserTest, BasicTest) { 66 IN_PROC_BROWSER_TEST_F(ConstrainedHtmlDialogBrowserTest, BasicTest) {
65 // The delegate deletes itself. 67 // The delegate deletes itself.
66 HtmlDialogUIDelegate* delegate = new TestHtmlDialogUIDelegate(); 68 HtmlDialogUIDelegate* delegate = new TestHtmlDialogUIDelegate();
67 TabContents* tab_contents = browser()->GetSelectedTabContents(); 69 TabContents* tab_contents = browser()->GetSelectedTabContents();
68 ASSERT_TRUE(tab_contents != NULL); 70 ASSERT_TRUE(tab_contents != NULL);
69 71
70 ConstrainedHtmlUI::CreateConstrainedHtmlDialog(browser()->profile(), 72 ConstrainedHtmlUI::CreateConstrainedHtmlDialog(browser()->profile(),
71 delegate, 73 delegate,
72 tab_contents); 74 tab_contents);
73 75
74 ASSERT_EQ(1U, tab_contents->constrained_window_count()); 76 ASSERT_EQ(1U, tab_contents->constrained_window_count());
75 } 77 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/collected_cookies_ui_delegate.cc ('k') | chrome/browser/ui/webui/html_dialog_ui.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698