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 "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/memory/singleton.h" | 8 #include "base/memory/singleton.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "chrome/browser/ui/views/html_dialog_view.h" | 10 #include "chrome/browser/ui/views/html_dialog_view.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 virtual ~TestHtmlDialogUIDelegate() {} | 35 virtual ~TestHtmlDialogUIDelegate() {} |
36 | 36 |
37 // HTMLDialogUIDelegate implementation: | 37 // HTMLDialogUIDelegate implementation: |
38 virtual bool IsDialogModal() const { | 38 virtual bool IsDialogModal() const { |
39 return true; | 39 return true; |
40 } | 40 } |
41 virtual std::wstring GetDialogTitle() const { | 41 virtual std::wstring GetDialogTitle() const { |
42 return std::wstring(L"Test"); | 42 return std::wstring(L"Test"); |
43 } | 43 } |
44 virtual GURL GetDialogContentURL() const { | 44 virtual GURL GetDialogContentURL() const { |
45 return GURL(chrome::kAboutBlankURL); | 45 return GURL(chrome::kAboutAboutURL); |
46 } | 46 } |
47 virtual void GetWebUIMessageHandlers( | 47 virtual void GetWebUIMessageHandlers( |
48 std::vector<WebUIMessageHandler*>* handlers) const { } | 48 std::vector<WebUIMessageHandler*>* handlers) const { } |
49 virtual void GetDialogSize(gfx::Size* size) const { | 49 virtual void GetDialogSize(gfx::Size* size) const { |
50 size->set_width(40); | 50 size->set_width(40); |
51 size->set_height(40); | 51 size->set_height(40); |
52 } | 52 } |
53 virtual std::string GetDialogArgs() const { | 53 virtual std::string GetDialogArgs() const { |
54 return std::string(); | 54 return std::string(); |
55 } | 55 } |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 | 198 |
199 html_view->MoveContents(tab_contents, set_bounds); | 199 html_view->MoveContents(tab_contents, set_bounds); |
200 ui_test_utils::RunMessageLoop(); | 200 ui_test_utils::RunMessageLoop(); |
201 actual_bounds = html_view->GetWidget()->GetClientAreaScreenBounds(); | 201 actual_bounds = html_view->GetWidget()->GetClientAreaScreenBounds(); |
202 EXPECT_LT(0, actual_bounds.width()); | 202 EXPECT_LT(0, actual_bounds.width()); |
203 EXPECT_LT(0, actual_bounds.height()); | 203 EXPECT_LT(0, actual_bounds.height()); |
204 | 204 |
205 MessageLoopForUI::current()->RemoveObserver( | 205 MessageLoopForUI::current()->RemoveObserver( |
206 WindowChangedObserver::GetInstance()); | 206 WindowChangedObserver::GetInstance()); |
207 } | 207 } |
| 208 |
| 209 IN_PROC_BROWSER_TEST_F(HtmlDialogBrowserTest, TestStateTransition) { |
| 210 HtmlDialogUIDelegate* delegate = new TestHtmlDialogUIDelegate(); |
| 211 |
| 212 HtmlDialogView* html_view = |
| 213 new HtmlDialogView(browser()->profile(), delegate); |
| 214 TabContents* tab_contents = browser()->GetSelectedTabContents(); |
| 215 ASSERT_TRUE(tab_contents != NULL); |
| 216 views::Window::CreateChromeWindow(tab_contents->GetDialogRootWindow(), |
| 217 gfx::Rect(), html_view); |
| 218 // Test if the state transitions from INITIALIZED to -> PAINTED |
| 219 EXPECT_EQ(HtmlDialogView::INITIALIZED, html_view->state_); |
| 220 |
| 221 html_view->InitDialog(); |
| 222 html_view->window()->Show(); |
| 223 |
| 224 MessageLoopForUI::current()->AddObserver( |
| 225 WindowChangedObserver::GetInstance()); |
| 226 // We use busy loop because the state is updated in notifications. |
| 227 while (html_view->state_ != HtmlDialogView::PAINTED) |
| 228 MessageLoop::current()->RunAllPending(); |
| 229 |
| 230 EXPECT_EQ(HtmlDialogView::PAINTED, html_view->state_); |
| 231 |
| 232 MessageLoopForUI::current()->RemoveObserver( |
| 233 WindowChangedObserver::GetInstance()); |
| 234 } |
OLD | NEW |