OLD | NEW |
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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 | 135 |
136 // test_dialog1's text field should still be the view that has focus. | 136 // test_dialog1's text field should still be the view that has focus. |
137 EXPECT_EQ(test_dialog1->GetInitiallyFocusedView(), | 137 EXPECT_EQ(test_dialog1->GetInitiallyFocusedView(), |
138 focus_manager->GetFocusedView()); | 138 focus_manager->GetFocusedView()); |
139 ASSERT_EQ(2u, constrained_window_helper->constrained_window_count()); | 139 ASSERT_EQ(2u, constrained_window_helper->constrained_window_count()); |
140 | 140 |
141 // Now send a VKEY_RETURN to the browser. This should result in closing | 141 // Now send a VKEY_RETURN to the browser. This should result in closing |
142 // test_dialog1. | 142 // test_dialog1. |
143 EXPECT_TRUE(focus_manager->ProcessAccelerator( | 143 EXPECT_TRUE(focus_manager->ProcessAccelerator( |
144 ui::Accelerator(ui::VKEY_RETURN, ui::EF_NONE))); | 144 ui::Accelerator(ui::VKEY_RETURN, ui::EF_NONE))); |
145 ui_test_utils::RunAllPendingInMessageLoop(); | 145 content::RunAllPendingInMessageLoop(); |
146 | 146 |
147 EXPECT_TRUE(test_dialog1->done()); | 147 EXPECT_TRUE(test_dialog1->done()); |
148 EXPECT_FALSE(test_dialog2->done()); | 148 EXPECT_FALSE(test_dialog2->done()); |
149 EXPECT_EQ(1u, constrained_window_helper->constrained_window_count()); | 149 EXPECT_EQ(1u, constrained_window_helper->constrained_window_count()); |
150 | 150 |
151 // test_dialog2 will be shown. Focus should be on test_dialog2's text field. | 151 // test_dialog2 will be shown. Focus should be on test_dialog2's text field. |
152 EXPECT_EQ(test_dialog2->GetInitiallyFocusedView(), | 152 EXPECT_EQ(test_dialog2->GetInitiallyFocusedView(), |
153 focus_manager->GetFocusedView()); | 153 focus_manager->GetFocusedView()); |
154 | 154 |
155 int tab_with_constrained_window = browser()->active_index(); | 155 int tab_with_constrained_window = browser()->active_index(); |
156 | 156 |
157 // Create a new tab. | 157 // Create a new tab. |
158 chrome::NewTab(browser()); | 158 chrome::NewTab(browser()); |
159 | 159 |
160 // The constrained dialog should no longer be selected. | 160 // The constrained dialog should no longer be selected. |
161 EXPECT_NE(test_dialog2->GetInitiallyFocusedView(), | 161 EXPECT_NE(test_dialog2->GetInitiallyFocusedView(), |
162 focus_manager->GetFocusedView()); | 162 focus_manager->GetFocusedView()); |
163 | 163 |
164 chrome::ActivateTabAt(browser(), tab_with_constrained_window, false); | 164 chrome::ActivateTabAt(browser(), tab_with_constrained_window, false); |
165 | 165 |
166 // Activating the previous tab should bring focus to the constrained window. | 166 // Activating the previous tab should bring focus to the constrained window. |
167 EXPECT_EQ(test_dialog2->GetInitiallyFocusedView(), | 167 EXPECT_EQ(test_dialog2->GetInitiallyFocusedView(), |
168 focus_manager->GetFocusedView()); | 168 focus_manager->GetFocusedView()); |
169 | 169 |
170 // Send another VKEY_RETURN, closing test_dialog2 | 170 // Send another VKEY_RETURN, closing test_dialog2 |
171 EXPECT_TRUE(focus_manager->ProcessAccelerator( | 171 EXPECT_TRUE(focus_manager->ProcessAccelerator( |
172 ui::Accelerator(ui::VKEY_RETURN, ui::EF_NONE))); | 172 ui::Accelerator(ui::VKEY_RETURN, ui::EF_NONE))); |
173 ui_test_utils::RunAllPendingInMessageLoop(); | 173 content::RunAllPendingInMessageLoop(); |
174 EXPECT_TRUE(test_dialog2->done()); | 174 EXPECT_TRUE(test_dialog2->done()); |
175 EXPECT_EQ(0u, constrained_window_helper->constrained_window_count()); | 175 EXPECT_EQ(0u, constrained_window_helper->constrained_window_count()); |
176 } | 176 } |
OLD | NEW |