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

Side by Side Diff: chrome/browser/ui/views/html_dialog_view_browsertest.cc

Issue 7024032: Wait showing html dialog until renderer finish painting after page is loaded. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: " Created 9 years, 6 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/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
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);
oshima 2011/06/07 19:10:09 this has to be some real page so that it gets pain
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
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->GetMessageBoxRootWindow(),
217 gfx::Rect(), html_view);
218 // Test if the state transitions INITIALIZED -> LOADED -> PAINTED in this
219 // order.
220 EXPECT_EQ(HtmlDialogView::INITIALIZED, html_view->state_);
221
222 html_view->InitDialog();
223 html_view->window()->Show();
224
225 MessageLoopForUI::current()->AddObserver(
226 WindowChangedObserver::GetInstance());
227 // We use busy loop because the state is updated in notifications.
228 while (html_view->state_ == HtmlDialogView::INITIALIZED)
229 MessageLoop::current()->RunAllPending();
230 EXPECT_EQ(HtmlDialogView::LOADED, html_view->state_);
231
232 while (html_view->state_ == HtmlDialogView::LOADED)
233 MessageLoop::current()->RunAllPending();
234
235 EXPECT_EQ(HtmlDialogView::PAINTED, html_view->state_);
236
237 MessageLoopForUI::current()->RemoveObserver(
238 WindowChangedObserver::GetInstance());
239 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/html_dialog_view.cc ('k') | chrome/browser/ui/views/keyboard_overlay_dialog_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698