OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/libgtk2ui/select_file_dialog_impl_gtk2.h" | 5 #include "chrome/browser/ui/libgtk2ui/select_file_dialog_impl_gtk2.h" |
6 | 6 |
7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
8 #include "chrome/browser/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
9 #include "chrome/browser/ui/browser_window.h" | 9 #include "chrome/browser/ui/browser_window.h" |
10 #include "chrome/browser/ui/chrome_select_file_policy.h" | 10 #include "chrome/browser/ui/chrome_select_file_policy.h" |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 int index, | 93 int index, |
94 void* params) override {} | 94 void* params) override {} |
95 private: | 95 private: |
96 // Dialog box used for opening and saving files. | 96 // Dialog box used for opening and saving files. |
97 scoped_refptr<ui::SelectFileDialog> select_file_dialog_; | 97 scoped_refptr<ui::SelectFileDialog> select_file_dialog_; |
98 | 98 |
99 DISALLOW_COPY_AND_ASSIGN(FilePicker); | 99 DISALLOW_COPY_AND_ASSIGN(FilePicker); |
100 }; | 100 }; |
101 | 101 |
102 } // namespace libgtk2ui | 102 } // namespace libgtk2ui |
| 103 |
| 104 // Test that the file-picker is modal. |
| 105 IN_PROC_BROWSER_TEST_F(BrowserSelectFileDialogTest, ModalTest) { |
| 106 // Bring the native window to the foreground. Returns true on success. |
| 107 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
| 108 ASSERT_TRUE(browser()->window()->IsActive()); |
| 109 |
| 110 // Leaks in GtkFileChooserDialog. http://crbug.com/537468 |
| 111 ANNOTATE_SCOPED_MEMORY_LEAK; |
| 112 libgtk2ui::FilePicker file_picker(browser()->window()); |
| 113 |
| 114 gfx::NativeWindow window = browser()->window()->GetNativeWindow(); |
| 115 views::Widget* widget = views::Widget::GetWidgetForNativeWindow(window); |
| 116 ASSERT_NE(nullptr, widget); |
| 117 |
| 118 // Run a nested loop until the browser window becomes inactive |
| 119 // so that the file-picker can be active. |
| 120 WidgetActivationWaiter waiter_inactive(widget, false); |
| 121 waiter_inactive.Wait(); |
| 122 EXPECT_FALSE(browser()->window()->IsActive()); |
| 123 |
| 124 ui_test_utils::ClickOnView(browser(), VIEW_ID_TAB_CONTAINER); |
| 125 // The window should not get focus due to modal dialog. |
| 126 EXPECT_FALSE(browser()->window()->IsActive()); |
| 127 |
| 128 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
| 129 EXPECT_FALSE(browser()->window()->IsActive()); |
| 130 |
| 131 ASSERT_TRUE(ui_test_utils::ShowAndFocusNativeWindow(window)); |
| 132 EXPECT_FALSE(browser()->window()->IsActive()); |
| 133 |
| 134 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( |
| 135 browser(), ui::VKEY_TAB, false, false, true, false)); |
| 136 EXPECT_FALSE(browser()->window()->IsActive()); |
| 137 |
| 138 file_picker.Close(); |
| 139 |
| 140 // Run a nested loop until the browser window becomes active. |
| 141 WidgetActivationWaiter wait_active(widget, true); |
| 142 wait_active.Wait(); |
| 143 |
| 144 ui_test_utils::ClickOnView(browser(), VIEW_ID_TAB_CONTAINER); |
| 145 EXPECT_TRUE(browser()->window()->IsActive()); |
| 146 } |
OLD | NEW |