OLD | NEW |
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 "base/file_path.h" | 5 #include "base/file_path.h" |
6 #include "base/memory/singleton.h" | 6 #include "base/memory/singleton.h" |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "base/utf_string_conversions.h" |
8 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
9 #include "chrome/browser/ui/views/html_dialog_view.h" | 10 #include "chrome/browser/ui/views/html_dialog_view.h" |
10 #include "chrome/browser/ui/webui/html_dialog_ui.h" | 11 #include "chrome/browser/ui/webui/html_dialog_ui.h" |
11 #include "chrome/common/url_constants.h" | 12 #include "chrome/common/url_constants.h" |
12 #include "chrome/test/base/in_process_browser_test.h" | 13 #include "chrome/test/base/in_process_browser_test.h" |
13 #include "chrome/test/base/ui_test_utils.h" | 14 #include "chrome/test/base/ui_test_utils.h" |
14 #include "content/browser/renderer_host/render_widget_host_view.h" | 15 #include "content/browser/renderer_host/render_widget_host_view.h" |
15 #include "content/browser/tab_contents/tab_contents.h" | 16 #include "content/browser/tab_contents/tab_contents.h" |
16 #include "testing/gmock/include/gmock/gmock.h" | 17 #include "testing/gmock/include/gmock/gmock.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
18 #include "views/widget/widget.h" | 19 #include "views/widget/widget.h" |
19 | 20 |
20 using testing::Eq; | 21 using testing::Eq; |
21 | 22 |
22 namespace { | 23 namespace { |
23 | 24 |
24 // Window non-client-area means that the minimum size for the window | 25 // Window non-client-area means that the minimum size for the window |
25 // won't be the actual minimum size - our layout and resizing code | 26 // won't be the actual minimum size - our layout and resizing code |
26 // makes sure the chrome is always visible. | 27 // makes sure the chrome is always visible. |
27 const int kMinimumWidthToTestFor = 20; | 28 const int kMinimumWidthToTestFor = 20; |
28 const int kMinimumHeightToTestFor = 30; | 29 const int kMinimumHeightToTestFor = 30; |
29 | 30 |
30 class TestHtmlDialogUIDelegate : public HtmlDialogUIDelegate { | 31 class TestHtmlDialogUIDelegate : public HtmlDialogUIDelegate { |
31 public: | 32 public: |
32 TestHtmlDialogUIDelegate() {} | 33 TestHtmlDialogUIDelegate() {} |
33 virtual ~TestHtmlDialogUIDelegate() {} | 34 virtual ~TestHtmlDialogUIDelegate() {} |
34 | 35 |
35 // HTMLDialogUIDelegate implementation: | 36 // HTMLDialogUIDelegate implementation: |
36 virtual bool IsDialogModal() const { | 37 virtual bool IsDialogModal() const OVERRIDE { |
37 return true; | 38 return true; |
38 } | 39 } |
39 virtual std::wstring GetDialogTitle() const { | 40 virtual string16 GetDialogTitle() const OVERRIDE { |
40 return std::wstring(L"Test"); | 41 return ASCIIToUTF16("Test"); |
41 } | 42 } |
42 virtual GURL GetDialogContentURL() const { | 43 virtual GURL GetDialogContentURL() const OVERRIDE { |
43 return GURL(chrome::kChromeUIChromeURLsURL); | 44 return GURL(chrome::kChromeUIChromeURLsURL); |
44 } | 45 } |
45 virtual void GetWebUIMessageHandlers( | 46 virtual void GetWebUIMessageHandlers( |
46 std::vector<WebUIMessageHandler*>* handlers) const { } | 47 std::vector<WebUIMessageHandler*>* handlers) const OVERRIDE { } |
47 virtual void GetDialogSize(gfx::Size* size) const { | 48 virtual void GetDialogSize(gfx::Size* size) const OVERRIDE { |
48 size->set_width(40); | 49 size->set_width(40); |
49 size->set_height(40); | 50 size->set_height(40); |
50 } | 51 } |
51 virtual std::string GetDialogArgs() const { | 52 virtual std::string GetDialogArgs() const OVERRIDE { |
52 return std::string(); | 53 return std::string(); |
53 } | 54 } |
54 virtual void OnDialogClosed(const std::string& json_retval) { } | 55 virtual void OnDialogClosed(const std::string& json_retval) OVERRIDE { } |
55 virtual void OnCloseContents(TabContents* source, bool* out_close_dialog) { | 56 virtual void OnCloseContents(TabContents* source, bool* out_close_dialog) |
| 57 OVERRIDE { |
56 if (out_close_dialog) | 58 if (out_close_dialog) |
57 *out_close_dialog = true; | 59 *out_close_dialog = true; |
58 } | 60 } |
59 virtual bool ShouldShowDialogTitle() const { return true; } | 61 virtual bool ShouldShowDialogTitle() const OVERRIDE { return true; } |
60 }; | 62 }; |
61 | 63 |
62 } // namespace | 64 } // namespace |
63 | 65 |
64 class HtmlDialogBrowserTest : public InProcessBrowserTest { | 66 class HtmlDialogBrowserTest : public InProcessBrowserTest { |
65 public: | 67 public: |
66 HtmlDialogBrowserTest() {} | 68 HtmlDialogBrowserTest() {} |
67 | 69 |
68 #if defined(OS_WIN) | 70 #if defined(OS_WIN) |
69 class WindowChangedObserver : public MessageLoopForUI::Observer { | 71 class WindowChangedObserver : public MessageLoopForUI::Observer { |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 WindowChangedObserver::GetInstance()); | 226 WindowChangedObserver::GetInstance()); |
225 // We use busy loop because the state is updated in notifications. | 227 // We use busy loop because the state is updated in notifications. |
226 while (html_view->state_ != HtmlDialogView::PAINTED) | 228 while (html_view->state_ != HtmlDialogView::PAINTED) |
227 MessageLoop::current()->RunAllPending(); | 229 MessageLoop::current()->RunAllPending(); |
228 | 230 |
229 EXPECT_EQ(HtmlDialogView::PAINTED, html_view->state_); | 231 EXPECT_EQ(HtmlDialogView::PAINTED, html_view->state_); |
230 | 232 |
231 MessageLoopForUI::current()->RemoveObserver( | 233 MessageLoopForUI::current()->RemoveObserver( |
232 WindowChangedObserver::GetInstance()); | 234 WindowChangedObserver::GetInstance()); |
233 } | 235 } |
OLD | NEW |