Chromium Code Reviews| Index: chrome/browser/ui/views/html_dialog_view_browsertest.cc |
| diff --git a/chrome/browser/ui/views/html_dialog_view_browsertest.cc b/chrome/browser/ui/views/html_dialog_view_browsertest.cc |
| index ab273218d42f3b88b13d7521c80484aebc3277b2..271b1d830ab00593c6a699d5e3d233739e18f85a 100644 |
| --- a/chrome/browser/ui/views/html_dialog_view_browsertest.cc |
| +++ b/chrome/browser/ui/views/html_dialog_view_browsertest.cc |
| @@ -8,7 +8,7 @@ |
| #include "base/utf_string_conversions.h" |
| #include "chrome/browser/ui/browser.h" |
| #include "chrome/browser/ui/views/html_dialog_view.h" |
| -#include "chrome/browser/ui/webui/html_dialog_ui.h" |
| +#include "chrome/browser/ui/webui/test_html_dialog_ui_delegate.h" |
| #include "chrome/common/url_constants.h" |
| #include "chrome/test/base/in_process_browser_test.h" |
| #include "chrome/test/base/ui_test_utils.h" |
| @@ -28,37 +28,29 @@ namespace { |
| const int kMinimumWidthToTestFor = 20; |
| const int kMinimumHeightToTestFor = 30; |
| -class TestHtmlDialogUIDelegate : public HtmlDialogUIDelegate { |
| - public: |
| - TestHtmlDialogUIDelegate() {} |
| - virtual ~TestHtmlDialogUIDelegate() {} |
| +const int kInitialWidth = 40; |
|
oshima
2011/11/01 18:28:27
add documents for these variables (simple descript
xiyuan
2011/11/01 20:18:15
Done.
|
| +const int kInitialHeight = 40; |
| - // HTMLDialogUIDelegate implementation: |
| - virtual bool IsDialogModal() const OVERRIDE { |
| - return true; |
| - } |
| - virtual string16 GetDialogTitle() const OVERRIDE { |
| - return ASCIIToUTF16("Test"); |
| - } |
| - virtual GURL GetDialogContentURL() const OVERRIDE { |
| - return GURL(chrome::kChromeUIChromeURLsURL); |
| - } |
| - virtual void GetWebUIMessageHandlers( |
| - std::vector<WebUIMessageHandler*>* handlers) const OVERRIDE { } |
| - virtual void GetDialogSize(gfx::Size* size) const OVERRIDE { |
| - size->set_width(40); |
| - size->set_height(40); |
| +class TestHtmlDialogView: public HtmlDialogView { |
| + public: |
| + TestHtmlDialogView(Profile* profile, HtmlDialogUIDelegate* delegate) |
| + : HtmlDialogView(profile, delegate), |
| + painted_(false) { |
| } |
| - virtual std::string GetDialogArgs() const OVERRIDE { |
| - return std::string(); |
| + |
| + bool painted() const { |
| + return painted_; |
| } |
| - virtual void OnDialogClosed(const std::string& json_retval) OVERRIDE { } |
| - virtual void OnCloseContents(TabContents* source, bool* out_close_dialog) |
| - OVERRIDE { |
| - if (out_close_dialog) |
| - *out_close_dialog = true; |
| + |
| + protected: |
| + virtual void OnTabMainFrameFirstRender() OVERRIDE { |
| + HtmlDialogView::OnTabMainFrameFirstRender(); |
| + painted_ = true; |
| + MessageLoop::current()->Quit(); |
| } |
| - virtual bool ShouldShowDialogTitle() const OVERRIDE { return true; } |
| + |
| + private: |
| + bool painted_; |
| }; |
|
oshima
2011/11/01 18:28:27
DISALLOW_COPY_AND_ASSIGN
xiyuan
2011/11/01 20:18:15
Done.
|
| } // namespace |
| @@ -132,7 +124,9 @@ class HtmlDialogBrowserTest : public InProcessBrowserTest { |
| #endif |
| IN_PROC_BROWSER_TEST_F(HtmlDialogBrowserTest, MAYBE_SizeWindow) { |
| - HtmlDialogUIDelegate* delegate = new TestHtmlDialogUIDelegate(); |
| + TestHtmlDialogUIDelegate* delegate = new TestHtmlDialogUIDelegate( |
| + GURL(chrome::kChromeUIChromeURLsURL)); |
| + delegate->set_size(kInitialWidth, kInitialHeight); |
| HtmlDialogView* html_view = |
| new HtmlDialogView(browser()->profile(), delegate); |
| @@ -214,29 +208,25 @@ IN_PROC_BROWSER_TEST_F(HtmlDialogBrowserTest, MAYBE_SizeWindow) { |
| } |
| // This is timing out about 5~10% of runs. See crbug.com/86059. |
| -IN_PROC_BROWSER_TEST_F(HtmlDialogBrowserTest, DISABLED_TestStateTransition) { |
| - HtmlDialogUIDelegate* delegate = new TestHtmlDialogUIDelegate(); |
| +IN_PROC_BROWSER_TEST_F(HtmlDialogBrowserTest, WebContentRendered) { |
| + HtmlDialogUIDelegate* delegate = new TestHtmlDialogUIDelegate( |
| + GURL(chrome::kChromeUIChromeURLsURL)); |
| - HtmlDialogView* html_view = |
| - new HtmlDialogView(browser()->profile(), delegate); |
| + TestHtmlDialogView* html_view = |
| + new TestHtmlDialogView(browser()->profile(), delegate); |
| TabContents* tab_contents = browser()->GetSelectedTabContents(); |
| ASSERT_TRUE(tab_contents != NULL); |
| views::Widget::CreateWindowWithParent(html_view, |
| tab_contents->GetDialogRootWindow()); |
| - // Test if the state transitions from INITIALIZED to -> PAINTED |
| - EXPECT_EQ(HtmlDialogView::INITIALIZED, html_view->state_); |
| + EXPECT_TRUE(html_view->initialized_); |
| html_view->InitDialog(); |
| html_view->GetWidget()->Show(); |
| - MessageLoopForUI::current()->AddObserver( |
| - WindowChangedObserver::GetInstance()); |
| - // We use busy loop because the state is updated in notifications. |
| - while (html_view->state_ != HtmlDialogView::PAINTED) |
| - MessageLoop::current()->RunAllPending(); |
| + // TestHtmlDialogView::OnTabMainFrameFirstRender() will Quit(). |
| + MessageLoopForUI::current()->Run(); |
| - EXPECT_EQ(HtmlDialogView::PAINTED, html_view->state_); |
| + EXPECT_TRUE(html_view->painted()); |
| - MessageLoopForUI::current()->RemoveObserver( |
| - WindowChangedObserver::GetInstance()); |
| + html_view->GetWidget()->Close(); |
| } |