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

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

Issue 11044020: Make Web Intents picker in Views conform to latest mocks (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Move link underline into a separate CL Created 8 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 unified diff | Download patch
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 "base/memory/weak_ptr.h" 5 #include "base/memory/weak_ptr.h"
6 #include "chrome/browser/ui/browser.h" 6 #include "chrome/browser/ui/browser.h"
7 #include "chrome/browser/ui/browser_commands.h" 7 #include "chrome/browser/ui/browser_commands.h"
8 #include "chrome/browser/ui/browser_tabstrip.h" 8 #include "chrome/browser/ui/browser_tabstrip.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.h" 10 #include "chrome/browser/ui/tab_contents/tab_contents.h"
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 // accelerator targets until they are displayed. 108 // accelerator targets until they are displayed.
109 IN_PROC_BROWSER_TEST_F(ConstrainedWindowViewTest, FocusTest) { 109 IN_PROC_BROWSER_TEST_F(ConstrainedWindowViewTest, FocusTest) {
110 content::WebContents* web_contents = chrome::GetActiveWebContents(browser()); 110 content::WebContents* web_contents = chrome::GetActiveWebContents(browser());
111 ASSERT_TRUE(web_contents != NULL); 111 ASSERT_TRUE(web_contents != NULL);
112 ConstrainedWindowTabHelper* constrained_window_helper = 112 ConstrainedWindowTabHelper* constrained_window_helper =
113 ConstrainedWindowTabHelper::FromWebContents(web_contents); 113 ConstrainedWindowTabHelper::FromWebContents(web_contents);
114 ASSERT_TRUE(constrained_window_helper != NULL); 114 ASSERT_TRUE(constrained_window_helper != NULL);
115 115
116 // Create a constrained dialog. It will attach itself to tab_contents. 116 // Create a constrained dialog. It will attach itself to tab_contents.
117 scoped_ptr<TestConstrainedDialog> test_dialog1(new TestConstrainedDialog); 117 scoped_ptr<TestConstrainedDialog> test_dialog1(new TestConstrainedDialog);
118 ConstrainedWindowViews* window1 = 118 ConstrainedWindowViews* window1 = new ConstrainedWindowViews(
119 new ConstrainedWindowViews(web_contents, test_dialog1.get(), false); 119 web_contents, test_dialog1.get(), false,
120 ConstrainedWindow::GetDefaultInsets());
120 121
121 views::FocusManager* focus_manager = window1->GetFocusManager(); 122 views::FocusManager* focus_manager = window1->GetFocusManager();
122 ASSERT_TRUE(focus_manager); 123 ASSERT_TRUE(focus_manager);
123 124
124 // test_dialog1's text field should be focused. 125 // test_dialog1's text field should be focused.
125 EXPECT_EQ(test_dialog1->GetInitiallyFocusedView(), 126 EXPECT_EQ(test_dialog1->GetInitiallyFocusedView(),
126 focus_manager->GetFocusedView()); 127 focus_manager->GetFocusedView());
127 128
128 // Now create a second constrained dialog. This will also be attached to 129 // Now create a second constrained dialog. This will also be attached to
129 // tab_contents, but will remain hidden since the test_dialog1 is still 130 // tab_contents, but will remain hidden since the test_dialog1 is still
130 // showing. 131 // showing.
131 scoped_ptr<TestConstrainedDialog> test_dialog2(new TestConstrainedDialog); 132 scoped_ptr<TestConstrainedDialog> test_dialog2(new TestConstrainedDialog);
132 ConstrainedWindowViews* window2 = 133 ConstrainedWindowViews* window2 = new ConstrainedWindowViews(
133 new ConstrainedWindowViews(web_contents, test_dialog2.get(), false); 134 web_contents, test_dialog2.get(), false,
135 ConstrainedWindow::GetDefaultInsets());
134 // Should be the same focus_manager. 136 // Should be the same focus_manager.
135 ASSERT_EQ(focus_manager, window2->GetFocusManager()); 137 ASSERT_EQ(focus_manager, window2->GetFocusManager());
136 138
137 // test_dialog1's text field should still be the view that has focus. 139 // test_dialog1's text field should still be the view that has focus.
138 EXPECT_EQ(test_dialog1->GetInitiallyFocusedView(), 140 EXPECT_EQ(test_dialog1->GetInitiallyFocusedView(),
139 focus_manager->GetFocusedView()); 141 focus_manager->GetFocusedView());
140 ASSERT_EQ(2u, constrained_window_helper->constrained_window_count()); 142 ASSERT_EQ(2u, constrained_window_helper->constrained_window_count());
141 143
142 // Now send a VKEY_RETURN to the browser. This should result in closing 144 // Now send a VKEY_RETURN to the browser. This should result in closing
143 // test_dialog1. 145 // test_dialog1.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 // closed. 182 // closed.
181 IN_PROC_BROWSER_TEST_F(ConstrainedWindowViewTest, TabCloseTest) { 183 IN_PROC_BROWSER_TEST_F(ConstrainedWindowViewTest, TabCloseTest) {
182 content::WebContents* web_contents = chrome::GetActiveWebContents(browser()); 184 content::WebContents* web_contents = chrome::GetActiveWebContents(browser());
183 ASSERT_TRUE(web_contents != NULL); 185 ASSERT_TRUE(web_contents != NULL);
184 ConstrainedWindowTabHelper* constrained_window_helper = 186 ConstrainedWindowTabHelper* constrained_window_helper =
185 ConstrainedWindowTabHelper::FromWebContents(web_contents); 187 ConstrainedWindowTabHelper::FromWebContents(web_contents);
186 ASSERT_TRUE(constrained_window_helper != NULL); 188 ASSERT_TRUE(constrained_window_helper != NULL);
187 189
188 // Create a constrained dialog. It will attach itself to tab_contents. 190 // Create a constrained dialog. It will attach itself to tab_contents.
189 scoped_ptr<TestConstrainedDialog> test_dialog(new TestConstrainedDialog); 191 scoped_ptr<TestConstrainedDialog> test_dialog(new TestConstrainedDialog);
190 ConstrainedWindowViews* window = 192 ConstrainedWindowViews* window = new ConstrainedWindowViews(
191 new ConstrainedWindowViews(web_contents, test_dialog.get(), true); 193 web_contents, test_dialog.get(), true,
194 ConstrainedWindow::GetDefaultInsets());
192 195
193 bool closed = 196 bool closed =
194 browser()->tab_strip_model()->CloseTabContentsAt( 197 browser()->tab_strip_model()->CloseTabContentsAt(
195 browser()->tab_strip_model()->active_index(), 198 browser()->tab_strip_model()->active_index(),
196 TabStripModel::CLOSE_NONE); 199 TabStripModel::CLOSE_NONE);
197 EXPECT_TRUE(closed); 200 EXPECT_TRUE(closed);
198 content::RunAllPendingInMessageLoop(); 201 content::RunAllPendingInMessageLoop();
199 EXPECT_TRUE(test_dialog->done()); 202 EXPECT_TRUE(test_dialog->done());
200 } 203 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698