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

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

Issue 10551002: TabContentsWrapper -> TabContents, part 56. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Not killing GetSelectedWebContents yet 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
« no previous file with comments | « chrome/browser/ui/views/frame/browser_view.cc ('k') | chrome/browser/ui/zoom/zoom_controller.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.h"
11 #include "chrome/browser/ui/webui/test_web_dialog_delegate.h" 11 #include "chrome/browser/ui/webui/test_web_dialog_delegate.h"
12 #include "chrome/common/url_constants.h" 12 #include "chrome/common/url_constants.h"
13 #include "chrome/test/base/in_process_browser_test.h" 13 #include "chrome/test/base/in_process_browser_test.h"
14 #include "chrome/test/base/ui_test_utils.h" 14 #include "chrome/test/base/ui_test_utils.h"
15 #include "content/public/browser/web_contents.h" 15 #include "content/public/browser/web_contents.h"
16 #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" 17 #include "ui/web_dialogs/constrained_web_dialog_ui.h"
18 18
19 using content::WebContents; 19 using content::WebContents;
20 using ui::ConstrainedWebDialogDelegate; 20 using ui::ConstrainedWebDialogDelegate;
(...skipping 20 matching lines...) Expand all
41 bool tab_destroyed_; 41 bool tab_destroyed_;
42 }; 42 };
43 43
44 } // namespace 44 } // namespace
45 45
46 class ConstrainedWebDialogBrowserTest : public InProcessBrowserTest { 46 class ConstrainedWebDialogBrowserTest : public InProcessBrowserTest {
47 public: 47 public:
48 ConstrainedWebDialogBrowserTest() {} 48 ConstrainedWebDialogBrowserTest() {}
49 49
50 protected: 50 protected:
51 size_t GetConstrainedWindowCount(TabContentsWrapper* wrapper) const { 51 size_t GetConstrainedWindowCount(TabContents* tab_contents) const {
52 return wrapper->constrained_window_tab_helper()->constrained_window_count(); 52 return tab_contents->
53 constrained_window_tab_helper()->constrained_window_count();
53 } 54 }
54 }; 55 };
55 56
56 // Tests that opening/closing the constrained window won't crash it. 57 // Tests that opening/closing the constrained window won't crash it.
57 IN_PROC_BROWSER_TEST_F(ConstrainedWebDialogBrowserTest, BasicTest) { 58 IN_PROC_BROWSER_TEST_F(ConstrainedWebDialogBrowserTest, BasicTest) {
58 // The delegate deletes itself. 59 // The delegate deletes itself.
59 WebDialogDelegate* delegate = new test::TestWebDialogDelegate( 60 WebDialogDelegate* delegate = new test::TestWebDialogDelegate(
60 GURL(chrome::kChromeUIConstrainedHTMLTestURL)); 61 GURL(chrome::kChromeUIConstrainedHTMLTestURL));
61 TabContentsWrapper* wrapper = browser()->GetSelectedTabContentsWrapper(); 62 TabContents* tab_contents = browser()->GetActiveTabContents();
62 ASSERT_TRUE(wrapper); 63 ASSERT_TRUE(tab_contents);
63 64
64 ConstrainedWebDialogDelegate* dialog_delegate = 65 ConstrainedWebDialogDelegate* dialog_delegate =
65 ui::CreateConstrainedWebDialog(browser()->profile(), 66 ui::CreateConstrainedWebDialog(browser()->profile(),
66 delegate, 67 delegate,
67 NULL, 68 NULL,
68 wrapper); 69 tab_contents);
69 ASSERT_TRUE(dialog_delegate); 70 ASSERT_TRUE(dialog_delegate);
70 EXPECT_TRUE(dialog_delegate->window()); 71 EXPECT_TRUE(dialog_delegate->window());
71 EXPECT_EQ(1U, GetConstrainedWindowCount(wrapper)); 72 EXPECT_EQ(1U, GetConstrainedWindowCount(tab_contents));
72 } 73 }
73 74
74 // Tests that ReleaseTabContentsOnDialogClose() works. 75 // Tests that ReleaseTabContentsOnDialogClose() works.
75 IN_PROC_BROWSER_TEST_F(ConstrainedWebDialogBrowserTest, 76 IN_PROC_BROWSER_TEST_F(ConstrainedWebDialogBrowserTest,
76 ReleaseTabContentsOnDialogClose) { 77 ReleaseTabContentsOnDialogClose) {
77 // The delegate deletes itself. 78 // The delegate deletes itself.
78 WebDialogDelegate* delegate = new test::TestWebDialogDelegate( 79 WebDialogDelegate* delegate = new test::TestWebDialogDelegate(
79 GURL(chrome::kChromeUIConstrainedHTMLTestURL)); 80 GURL(chrome::kChromeUIConstrainedHTMLTestURL));
80 TabContentsWrapper* wrapper = browser()->GetSelectedTabContentsWrapper(); 81 TabContents* tab_contents = browser()->GetActiveTabContents();
81 ASSERT_TRUE(wrapper); 82 ASSERT_TRUE(tab_contents);
82 83
83 ConstrainedWebDialogDelegate* dialog_delegate = 84 ConstrainedWebDialogDelegate* dialog_delegate =
84 ui::CreateConstrainedWebDialog(browser()->profile(), 85 ui::CreateConstrainedWebDialog(browser()->profile(),
85 delegate, 86 delegate,
86 NULL, 87 NULL,
87 wrapper); 88 tab_contents);
88 ASSERT_TRUE(dialog_delegate); 89 ASSERT_TRUE(dialog_delegate);
89 scoped_ptr<TabContentsWrapper> new_tab(dialog_delegate->tab()); 90 scoped_ptr<TabContents> new_tab(dialog_delegate->tab());
90 ASSERT_TRUE(new_tab.get()); 91 ASSERT_TRUE(new_tab.get());
91 ASSERT_EQ(1U, GetConstrainedWindowCount(wrapper)); 92 ASSERT_EQ(1U, GetConstrainedWindowCount(tab_contents));
92 93
93 ConstrainedWebDialogBrowserTestObserver observer(new_tab->web_contents()); 94 ConstrainedWebDialogBrowserTestObserver observer(new_tab->web_contents());
94 dialog_delegate->ReleaseTabContentsOnDialogClose(); 95 dialog_delegate->ReleaseTabContentsOnDialogClose();
95 dialog_delegate->OnDialogCloseFromWebUI(); 96 dialog_delegate->OnDialogCloseFromWebUI();
96 97
97 ASSERT_FALSE(observer.tab_destroyed()); 98 ASSERT_FALSE(observer.tab_destroyed());
98 EXPECT_EQ(0U, GetConstrainedWindowCount(wrapper)); 99 EXPECT_EQ(0U, GetConstrainedWindowCount(tab_contents));
99 new_tab.reset(); 100 new_tab.reset();
100 EXPECT_TRUE(observer.tab_destroyed()); 101 EXPECT_TRUE(observer.tab_destroyed());
101 } 102 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/browser_view.cc ('k') | chrome/browser/ui/zoom/zoom_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698