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

Side by Side Diff: chrome/browser/ui/webui/constrained_web_dialog_ui_browsertest.cc

Issue 10448066: Move the web dialogs code to src/ui/web_dialogs from src/chrome (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/ui/browser.h" 8 #include "chrome/browser/ui/browser.h"
9 #include "chrome/browser/ui/constrained_window_tab_helper.h" 9 #include "chrome/browser/ui/constrained_window_tab_helper.h"
10 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 10 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
11 #include "chrome/browser/ui/webui/constrained_web_dialog_ui.h"
12 #include "chrome/browser/ui/webui/test_web_dialog_delegate.h" 11 #include "chrome/browser/ui/webui/test_web_dialog_delegate.h"
13 #include "chrome/common/url_constants.h" 12 #include "chrome/common/url_constants.h"
14 #include "chrome/test/base/in_process_browser_test.h" 13 #include "chrome/test/base/in_process_browser_test.h"
15 #include "chrome/test/base/ui_test_utils.h" 14 #include "chrome/test/base/ui_test_utils.h"
16 #include "content/public/browser/web_contents.h" 15 #include "content/public/browser/web_contents.h"
17 #include "content/public/browser/web_contents_observer.h" 16 #include "content/public/browser/web_contents_observer.h"
17 #include "ui/web_dialogs/constrained_web_dialog_ui.h"
18 18
19 using content::WebContents; 19 using content::WebContents;
20 using ui::ConstrainedWebDialogDelegate;
21 using ui::WebDialogDelegate;
20 22
21 namespace { 23 namespace {
22 24
23 class ConstrainedWebDialogBrowserTestObserver 25 class ConstrainedWebDialogBrowserTestObserver
24 : public content::WebContentsObserver { 26 : public content::WebContentsObserver {
25 public: 27 public:
26 explicit ConstrainedWebDialogBrowserTestObserver(WebContents* contents) 28 explicit ConstrainedWebDialogBrowserTestObserver(WebContents* contents)
27 : content::WebContentsObserver(contents), 29 : content::WebContentsObserver(contents),
28 tab_destroyed_(false) { 30 tab_destroyed_(false) {
29 } 31 }
(...skipping 23 matching lines...) Expand all
53 55
54 // Tests that opening/closing the constrained window won't crash it. 56 // Tests that opening/closing the constrained window won't crash it.
55 IN_PROC_BROWSER_TEST_F(ConstrainedWebDialogBrowserTest, BasicTest) { 57 IN_PROC_BROWSER_TEST_F(ConstrainedWebDialogBrowserTest, BasicTest) {
56 // The delegate deletes itself. 58 // The delegate deletes itself.
57 WebDialogDelegate* delegate = new test::TestWebDialogDelegate( 59 WebDialogDelegate* delegate = new test::TestWebDialogDelegate(
58 GURL(chrome::kChromeUIConstrainedHTMLTestURL)); 60 GURL(chrome::kChromeUIConstrainedHTMLTestURL));
59 TabContentsWrapper* wrapper = browser()->GetSelectedTabContentsWrapper(); 61 TabContentsWrapper* wrapper = browser()->GetSelectedTabContentsWrapper();
60 ASSERT_TRUE(wrapper); 62 ASSERT_TRUE(wrapper);
61 63
62 ConstrainedWebDialogDelegate* dialog_delegate = 64 ConstrainedWebDialogDelegate* dialog_delegate =
63 ConstrainedWebDialogUI::CreateConstrainedWebDialog(browser()->profile(), 65 ui::CreateConstrainedWebDialog(browser()->profile(),
64 delegate, 66 delegate,
65 NULL, 67 NULL,
66 wrapper); 68 wrapper);
67 ASSERT_TRUE(dialog_delegate); 69 ASSERT_TRUE(dialog_delegate);
68 EXPECT_TRUE(dialog_delegate->window()); 70 EXPECT_TRUE(dialog_delegate->window());
69 EXPECT_EQ(1U, GetConstrainedWindowCount(wrapper)); 71 EXPECT_EQ(1U, GetConstrainedWindowCount(wrapper));
70 } 72 }
71 73
72 // Tests that ReleaseTabContentsOnDialogClose() works. 74 // Tests that ReleaseTabContentsOnDialogClose() works.
73 IN_PROC_BROWSER_TEST_F(ConstrainedWebDialogBrowserTest, 75 IN_PROC_BROWSER_TEST_F(ConstrainedWebDialogBrowserTest,
74 ReleaseTabContentsOnDialogClose) { 76 ReleaseTabContentsOnDialogClose) {
75 // The delegate deletes itself. 77 // The delegate deletes itself.
76 WebDialogDelegate* delegate = new test::TestWebDialogDelegate( 78 WebDialogDelegate* delegate = new test::TestWebDialogDelegate(
77 GURL(chrome::kChromeUIConstrainedHTMLTestURL)); 79 GURL(chrome::kChromeUIConstrainedHTMLTestURL));
78 TabContentsWrapper* wrapper = browser()->GetSelectedTabContentsWrapper(); 80 TabContentsWrapper* wrapper = browser()->GetSelectedTabContentsWrapper();
79 ASSERT_TRUE(wrapper); 81 ASSERT_TRUE(wrapper);
80 82
81 ConstrainedWebDialogDelegate* dialog_delegate = 83 ConstrainedWebDialogDelegate* dialog_delegate =
82 ConstrainedWebDialogUI::CreateConstrainedWebDialog(browser()->profile(), 84 ui::CreateConstrainedWebDialog(browser()->profile(),
83 delegate, 85 delegate,
84 NULL, 86 NULL,
85 wrapper); 87 wrapper);
86 ASSERT_TRUE(dialog_delegate); 88 ASSERT_TRUE(dialog_delegate);
87 scoped_ptr<TabContentsWrapper> new_tab(dialog_delegate->tab()); 89 scoped_ptr<TabContentsWrapper> new_tab(dialog_delegate->tab());
88 ASSERT_TRUE(new_tab.get()); 90 ASSERT_TRUE(new_tab.get());
89 ASSERT_EQ(1U, GetConstrainedWindowCount(wrapper)); 91 ASSERT_EQ(1U, GetConstrainedWindowCount(wrapper));
90 92
91 ConstrainedWebDialogBrowserTestObserver observer(new_tab->web_contents()); 93 ConstrainedWebDialogBrowserTestObserver observer(new_tab->web_contents());
92 dialog_delegate->ReleaseTabContentsOnDialogClose(); 94 dialog_delegate->ReleaseTabContentsOnDialogClose();
93 dialog_delegate->OnDialogCloseFromWebUI(); 95 dialog_delegate->OnDialogCloseFromWebUI();
94 96
95 ASSERT_FALSE(observer.tab_destroyed()); 97 ASSERT_FALSE(observer.tab_destroyed());
96 EXPECT_EQ(0U, GetConstrainedWindowCount(wrapper)); 98 EXPECT_EQ(0U, GetConstrainedWindowCount(wrapper));
97 new_tab.reset(); 99 new_tab.reset();
98 EXPECT_TRUE(observer.tab_destroyed()); 100 EXPECT_TRUE(observer.tab_destroyed());
99 } 101 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/constrained_web_dialog_ui.cc ('k') | chrome/browser/ui/webui/feedback_ui.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698