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

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

Issue 10702029: Move tab functions off Browser into browser_tabstrip and browser_tabrestore. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 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/browser_tabstrip.h"
9 #include "chrome/browser/ui/constrained_window_tab_helper.h" 10 #include "chrome/browser/ui/constrained_window_tab_helper.h"
10 #include "chrome/browser/ui/tab_contents/tab_contents.h" 11 #include "chrome/browser/ui/tab_contents/tab_contents.h"
11 #include "chrome/browser/ui/webui/test_web_dialog_delegate.h" 12 #include "chrome/browser/ui/webui/test_web_dialog_delegate.h"
12 #include "chrome/common/url_constants.h" 13 #include "chrome/common/url_constants.h"
13 #include "chrome/test/base/in_process_browser_test.h" 14 #include "chrome/test/base/in_process_browser_test.h"
14 #include "chrome/test/base/ui_test_utils.h" 15 #include "chrome/test/base/ui_test_utils.h"
15 #include "content/public/browser/web_contents.h" 16 #include "content/public/browser/web_contents.h"
16 #include "content/public/browser/web_contents_observer.h" 17 #include "content/public/browser/web_contents_observer.h"
17 #include "ui/web_dialogs/constrained_web_dialog_ui.h" 18 #include "ui/web_dialogs/constrained_web_dialog_ui.h"
18 19
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 return tab_contents-> 53 return tab_contents->
53 constrained_window_tab_helper()->constrained_window_count(); 54 constrained_window_tab_helper()->constrained_window_count();
54 } 55 }
55 }; 56 };
56 57
57 // Tests that opening/closing the constrained window won't crash it. 58 // Tests that opening/closing the constrained window won't crash it.
58 IN_PROC_BROWSER_TEST_F(ConstrainedWebDialogBrowserTest, BasicTest) { 59 IN_PROC_BROWSER_TEST_F(ConstrainedWebDialogBrowserTest, BasicTest) {
59 // The delegate deletes itself. 60 // The delegate deletes itself.
60 WebDialogDelegate* delegate = new test::TestWebDialogDelegate( 61 WebDialogDelegate* delegate = new test::TestWebDialogDelegate(
61 GURL(chrome::kChromeUIConstrainedHTMLTestURL)); 62 GURL(chrome::kChromeUIConstrainedHTMLTestURL));
62 TabContents* tab_contents = browser()->GetActiveTabContents(); 63 TabContents* tab_contents = chrome::GetActiveTabContents(browser());
63 ASSERT_TRUE(tab_contents); 64 ASSERT_TRUE(tab_contents);
64 65
65 ConstrainedWebDialogDelegate* dialog_delegate = 66 ConstrainedWebDialogDelegate* dialog_delegate =
66 ui::CreateConstrainedWebDialog(browser()->profile(), 67 ui::CreateConstrainedWebDialog(browser()->profile(),
67 delegate, 68 delegate,
68 NULL, 69 NULL,
69 tab_contents); 70 tab_contents);
70 ASSERT_TRUE(dialog_delegate); 71 ASSERT_TRUE(dialog_delegate);
71 EXPECT_TRUE(dialog_delegate->window()); 72 EXPECT_TRUE(dialog_delegate->window());
72 EXPECT_EQ(1U, GetConstrainedWindowCount(tab_contents)); 73 EXPECT_EQ(1U, GetConstrainedWindowCount(tab_contents));
73 } 74 }
74 75
75 // Tests that ReleaseTabContentsOnDialogClose() works. 76 // Tests that ReleaseTabContentsOnDialogClose() works.
76 IN_PROC_BROWSER_TEST_F(ConstrainedWebDialogBrowserTest, 77 IN_PROC_BROWSER_TEST_F(ConstrainedWebDialogBrowserTest,
77 ReleaseTabContentsOnDialogClose) { 78 ReleaseTabContentsOnDialogClose) {
78 // The delegate deletes itself. 79 // The delegate deletes itself.
79 WebDialogDelegate* delegate = new test::TestWebDialogDelegate( 80 WebDialogDelegate* delegate = new test::TestWebDialogDelegate(
80 GURL(chrome::kChromeUIConstrainedHTMLTestURL)); 81 GURL(chrome::kChromeUIConstrainedHTMLTestURL));
81 TabContents* tab_contents = browser()->GetActiveTabContents(); 82 TabContents* tab_contents = chrome::GetActiveTabContents(browser());
82 ASSERT_TRUE(tab_contents); 83 ASSERT_TRUE(tab_contents);
83 84
84 ConstrainedWebDialogDelegate* dialog_delegate = 85 ConstrainedWebDialogDelegate* dialog_delegate =
85 ui::CreateConstrainedWebDialog(browser()->profile(), 86 ui::CreateConstrainedWebDialog(browser()->profile(),
86 delegate, 87 delegate,
87 NULL, 88 NULL,
88 tab_contents); 89 tab_contents);
89 ASSERT_TRUE(dialog_delegate); 90 ASSERT_TRUE(dialog_delegate);
90 scoped_ptr<TabContents> new_tab(dialog_delegate->tab()); 91 scoped_ptr<TabContents> new_tab(dialog_delegate->tab());
91 ASSERT_TRUE(new_tab.get()); 92 ASSERT_TRUE(new_tab.get());
92 ASSERT_EQ(1U, GetConstrainedWindowCount(tab_contents)); 93 ASSERT_EQ(1U, GetConstrainedWindowCount(tab_contents));
93 94
94 ConstrainedWebDialogBrowserTestObserver observer(new_tab->web_contents()); 95 ConstrainedWebDialogBrowserTestObserver observer(new_tab->web_contents());
95 dialog_delegate->ReleaseTabContentsOnDialogClose(); 96 dialog_delegate->ReleaseTabContentsOnDialogClose();
96 dialog_delegate->OnDialogCloseFromWebUI(); 97 dialog_delegate->OnDialogCloseFromWebUI();
97 98
98 ASSERT_FALSE(observer.tab_destroyed()); 99 ASSERT_FALSE(observer.tab_destroyed());
99 EXPECT_EQ(0U, GetConstrainedWindowCount(tab_contents)); 100 EXPECT_EQ(0U, GetConstrainedWindowCount(tab_contents));
100 new_tab.reset(); 101 new_tab.reset();
101 EXPECT_TRUE(observer.tab_destroyed()); 102 EXPECT_TRUE(observer.tab_destroyed());
102 } 103 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/bookmarks_ui_browsertest.cc ('k') | chrome/browser/ui/webui/feedback_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698