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 "chrome/browser/ui/views/constrained_window_views.h" |
| 6 |
5 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
6 #include "chrome/browser/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
7 #include "chrome/browser/ui/browser_commands.h" | 9 #include "chrome/browser/ui/browser_commands.h" |
8 #include "chrome/browser/ui/host_desktop.h" | 10 #include "chrome/browser/ui/host_desktop.h" |
9 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 11 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
10 #include "chrome/browser/ui/views/tab_modal_confirm_dialog_views.h" | 12 #include "chrome/browser/ui/views/tab_modal_confirm_dialog_views.h" |
11 #include "chrome/common/url_constants.h" | 13 #include "chrome/common/url_constants.h" |
12 #include "chrome/test/base/in_process_browser_test.h" | 14 #include "chrome/test/base/in_process_browser_test.h" |
13 #include "chrome/test/base/interactive_test_utils.h" | 15 #include "chrome/test/base/interactive_test_utils.h" |
14 #include "chrome/test/base/ui_test_utils.h" | 16 #include "chrome/test/base/ui_test_utils.h" |
(...skipping 29 matching lines...) Expand all Loading... |
44 #endif | 46 #endif |
45 } | 47 } |
46 | 48 |
47 private: | 49 private: |
48 DISALLOW_COPY_AND_ASSIGN(TestDialog); | 50 DISALLOW_COPY_AND_ASSIGN(TestDialog); |
49 }; | 51 }; |
50 | 52 |
51 // A helper function to create and show a web contents modal dialog. | 53 // A helper function to create and show a web contents modal dialog. |
52 scoped_ptr<TestDialog> ShowModalDialog(content::WebContents* web_contents) { | 54 scoped_ptr<TestDialog> ShowModalDialog(content::WebContents* web_contents) { |
53 scoped_ptr<TestDialog> dialog(new TestDialog()); | 55 scoped_ptr<TestDialog> dialog(new TestDialog()); |
54 views::Widget* window = views::Widget::CreateWindowAsFramelessChild( | 56 ShowWebModalDialogViews(dialog.get(), web_contents); |
55 dialog.get(), web_contents->GetNativeView()); | |
56 web_modal::WebContentsModalDialogManager::FromWebContents(web_contents)-> | |
57 ShowModalDialog(window->GetNativeView()); | |
58 return dialog.Pass(); | 57 return dialog.Pass(); |
59 } | 58 } |
60 | 59 |
61 } // namespace | 60 } // namespace |
62 | 61 |
63 typedef InProcessBrowserTest ConstrainedWindowViewTest; | 62 typedef InProcessBrowserTest ConstrainedWindowViewTest; |
64 | 63 |
65 // Tests the intial focus of tab-modal dialogs, the restoration of focus to the | 64 // Tests the intial focus of tab-modal dialogs, the restoration of focus to the |
66 // browser when they close, and that queued dialogs don't register themselves as | 65 // browser when they close, and that queued dialogs don't register themselves as |
67 // accelerator targets until they are displayed. | 66 // accelerator targets until they are displayed. |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 #endif | 207 #endif |
209 | 208 |
210 scoped_ptr<TestDialog> dialog = ShowModalDialog( | 209 scoped_ptr<TestDialog> dialog = ShowModalDialog( |
211 browser()->tab_strip_model()->GetActiveWebContents()); | 210 browser()->tab_strip_model()->GetActiveWebContents()); |
212 EXPECT_TRUE(dialog->GetWidget()->IsVisible()); | 211 EXPECT_TRUE(dialog->GetWidget()->IsVisible()); |
213 EXPECT_TRUE(ui_test_utils::SendKeyPressSync(browser(), ui::VKEY_ESCAPE, | 212 EXPECT_TRUE(ui_test_utils::SendKeyPressSync(browser(), ui::VKEY_ESCAPE, |
214 false, false, false, false)); | 213 false, false, false, false)); |
215 content::RunAllPendingInMessageLoop(); | 214 content::RunAllPendingInMessageLoop(); |
216 EXPECT_EQ(NULL, dialog->GetWidget()); | 215 EXPECT_EQ(NULL, dialog->GetWidget()); |
217 } | 216 } |
OLD | NEW |