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

Unified Diff: chrome/browser/ui/views/html_dialog_view_browsertest.cc

Issue 8417005: Share TabFirstRenderWatcher with HtmlDialogView. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync Created 9 years, 2 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 side-by-side diff with in-line comments
Download patch
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..7fc77bd6ae37d65acf59a938694f32f84dfd6370 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,33 @@ namespace {
const int kMinimumWidthToTestFor = 20;
const int kMinimumHeightToTestFor = 30;
-class TestHtmlDialogUIDelegate : public HtmlDialogUIDelegate {
- public:
- TestHtmlDialogUIDelegate() {}
- virtual ~TestHtmlDialogUIDelegate() {}
+// Initial size of HTMLDialog for SizeWindow test case. They must be different
+// from the above kMinimumWidthToTestFor/kMinimumHeightToTestFor.
+const int kInitialWidth = 40;
+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_;
+
+ DISALLOW_COPY_AND_ASSIGN(TestHtmlDialogView);
};
} // namespace
@@ -132,7 +128,9 @@ class HtmlDialogBrowserTest : public InProcessBrowserTest {
#endif
IN_PROC_BROWSER_TEST_F(HtmlDialogBrowserTest, MAYBE_SizeWindow) {
- HtmlDialogUIDelegate* delegate = new TestHtmlDialogUIDelegate();
+ test::TestHtmlDialogUIDelegate* delegate = new test::TestHtmlDialogUIDelegate(
+ GURL(chrome::kChromeUIChromeURLsURL));
+ delegate->set_size(kInitialWidth, kInitialHeight);
HtmlDialogView* html_view =
new HtmlDialogView(browser()->profile(), delegate);
@@ -214,29 +212,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, DISABLED_WebContentRendered) {
+ HtmlDialogUIDelegate* delegate = new test::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();
}
« no previous file with comments | « chrome/browser/ui/views/html_dialog_view.cc ('k') | chrome/browser/ui/webui/constrained_html_ui_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698