| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 1253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1264 EXPECT_TRUE(minimize_waiter.Wait()); | 1264 EXPECT_TRUE(minimize_waiter.Wait()); |
| 1265 | 1265 |
| 1266 PropertyWaiter restore_waiter( | 1266 PropertyWaiter restore_waiter( |
| 1267 base::Bind(&Widget::IsMinimized, base::Unretained(widget)), false); | 1267 base::Bind(&Widget::IsMinimized, base::Unretained(widget)), false); |
| 1268 widget->Restore(); | 1268 widget->Restore(); |
| 1269 EXPECT_TRUE(restore_waiter.Wait()); | 1269 EXPECT_TRUE(restore_waiter.Wait()); |
| 1270 | 1270 |
| 1271 widget->CloseNow(); | 1271 widget->CloseNow(); |
| 1272 } | 1272 } |
| 1273 | 1273 |
| 1274 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && !defined(OS_WIN) |
| 1275 // TODO(warx): Investigate the flakiness on OS_WIN (crbug.com/729331). |
| 1276 // Tests that when a desktop native widget has modal transient child, it should |
| 1277 // avoid restore focused view itself as the modal transient child window will do |
| 1278 // that, thus avoids having multiple focused view visually (crbug.com/727641). |
| 1279 TEST_F(WidgetTestInteractive, DesktopNativeWidgetWithModalTransientChild) { |
| 1280 // Create a top level desktop native widget. |
| 1281 Widget* top_level = CreateWidget(); |
| 1282 |
| 1283 Textfield* textfield = new Textfield; |
| 1284 textfield->SetBounds(0, 0, 200, 20); |
| 1285 top_level->GetRootView()->AddChildView(textfield); |
| 1286 ShowSync(top_level); |
| 1287 textfield->RequestFocus(); |
| 1288 EXPECT_TRUE(textfield->HasFocus()); |
| 1289 |
| 1290 // Create a modal dialog. |
| 1291 // This instance will be destroyed when the dialog is destroyed. |
| 1292 ModalDialogDelegate* dialog_delegate = |
| 1293 new ModalDialogDelegate(ui::MODAL_TYPE_WINDOW); |
| 1294 Widget* modal_dialog_widget = DialogDelegate::CreateDialogWidget( |
| 1295 dialog_delegate, nullptr, top_level->GetNativeView()); |
| 1296 modal_dialog_widget->SetBounds(gfx::Rect(0, 0, 100, 10)); |
| 1297 Textfield* dialog_textfield = new Textfield; |
| 1298 dialog_textfield->SetBounds(0, 0, 50, 5); |
| 1299 modal_dialog_widget->GetRootView()->AddChildView(dialog_textfield); |
| 1300 // Dialog widget doesn't need a ShowSync as it gains active status |
| 1301 // synchronously. |
| 1302 modal_dialog_widget->Show(); |
| 1303 dialog_textfield->RequestFocus(); |
| 1304 EXPECT_TRUE(dialog_textfield->HasFocus()); |
| 1305 EXPECT_FALSE(textfield->HasFocus()); |
| 1306 |
| 1307 DeactivateSync(top_level); |
| 1308 EXPECT_FALSE(dialog_textfield->HasFocus()); |
| 1309 EXPECT_FALSE(textfield->HasFocus()); |
| 1310 |
| 1311 // After deactivation and activation of top level widget, only modal dialog |
| 1312 // should restore focused view. |
| 1313 ActivateSync(top_level); |
| 1314 EXPECT_TRUE(dialog_textfield->HasFocus()); |
| 1315 EXPECT_FALSE(textfield->HasFocus()); |
| 1316 |
| 1317 top_level->CloseNow(); |
| 1318 } |
| 1319 #endif // defined(USE_AURA) && !defined(OS_CHROMEOS) && !defined(OS_WIN) |
| 1320 |
| 1274 namespace { | 1321 namespace { |
| 1275 | 1322 |
| 1276 // Helper class for CaptureLostTrackingWidget to store whether | 1323 // Helper class for CaptureLostTrackingWidget to store whether |
| 1277 // OnMouseCaptureLost has been invoked for a widget. | 1324 // OnMouseCaptureLost has been invoked for a widget. |
| 1278 class CaptureLostState { | 1325 class CaptureLostState { |
| 1279 public: | 1326 public: |
| 1280 CaptureLostState() : got_capture_lost_(false) {} | 1327 CaptureLostState() : got_capture_lost_(false) {} |
| 1281 | 1328 |
| 1282 bool GetAndClearGotCaptureLost() { | 1329 bool GetAndClearGotCaptureLost() { |
| 1283 bool value = got_capture_lost_; | 1330 bool value = got_capture_lost_; |
| (...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1863 | 1910 |
| 1864 ui::KeyEvent key_event2(key_event); | 1911 ui::KeyEvent key_event2(key_event); |
| 1865 widget->OnKeyEvent(&key_event2); | 1912 widget->OnKeyEvent(&key_event2); |
| 1866 EXPECT_FALSE(key_event2.stopped_propagation()); | 1913 EXPECT_FALSE(key_event2.stopped_propagation()); |
| 1867 | 1914 |
| 1868 widget->CloseNow(); | 1915 widget->CloseNow(); |
| 1869 } | 1916 } |
| 1870 | 1917 |
| 1871 } // namespace test | 1918 } // namespace test |
| 1872 } // namespace views | 1919 } // namespace views |
| OLD | NEW |