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

Side by Side Diff: ui/views/widget/widget_interactive_uitest.cc

Issue 2921253002: Revert of desktop_aura: do not restore focused view if it has modal transient child (Closed)
Patch Set: Created 3 years, 6 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
« no previous file with comments | « ui/views/widget/desktop_aura/desktop_native_widget_aura.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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(USE_AURA) && !defined(OS_CHROMEOS)
1275 // Tests that when a desktop native widget has modal transient child, it should
1276 // avoid restore focused view itself as the modal transient child window will do
1277 // that, thus avoids having multiple focused view visually (crbug.com/727641).
1278 TEST_F(WidgetTestInteractive, DesktopNativeWidgetWithModalTransientChild) {
1279 // Create a top level desktop native widget.
1280 Widget* top_level = CreateWidget();
1281
1282 Textfield* textfield = new Textfield;
1283 textfield->SetBounds(0, 0, 200, 20);
1284 top_level->GetRootView()->AddChildView(textfield);
1285 ShowSync(top_level);
1286 textfield->RequestFocus();
1287 EXPECT_TRUE(textfield->HasFocus());
1288
1289 // Create a modal dialog.
1290 // This instance will be destroyed when the dialog is destroyed.
1291 ModalDialogDelegate* dialog_delegate =
1292 new ModalDialogDelegate(ui::MODAL_TYPE_WINDOW);
1293 Widget* modal_dialog_widget = DialogDelegate::CreateDialogWidget(
1294 dialog_delegate, nullptr, top_level->GetNativeView());
1295 modal_dialog_widget->SetBounds(gfx::Rect(0, 0, 100, 10));
1296 Textfield* dialog_textfield = new Textfield;
1297 dialog_textfield->SetBounds(0, 0, 50, 5);
1298 modal_dialog_widget->GetRootView()->AddChildView(dialog_textfield);
1299 // Dialog widget doesn't need a ShowSync as it gains active status
1300 // synchronously.
1301 modal_dialog_widget->Show();
1302 dialog_textfield->RequestFocus();
1303 EXPECT_TRUE(dialog_textfield->HasFocus());
1304 EXPECT_FALSE(textfield->HasFocus());
1305
1306 DeactivateSync(top_level);
1307 EXPECT_FALSE(dialog_textfield->HasFocus());
1308 EXPECT_FALSE(textfield->HasFocus());
1309
1310 // After deactivation and activation of top level widget, only modal dialog
1311 // should restore focused view.
1312 ActivateSync(top_level);
1313 EXPECT_TRUE(dialog_textfield->HasFocus());
1314 EXPECT_FALSE(textfield->HasFocus());
1315
1316 top_level->CloseNow();
1317 }
1318 #endif // defined(USE_AURA) && !defined(OS_CHROMEOS)
1319
1320 namespace { 1274 namespace {
1321 1275
1322 // Helper class for CaptureLostTrackingWidget to store whether 1276 // Helper class for CaptureLostTrackingWidget to store whether
1323 // OnMouseCaptureLost has been invoked for a widget. 1277 // OnMouseCaptureLost has been invoked for a widget.
1324 class CaptureLostState { 1278 class CaptureLostState {
1325 public: 1279 public:
1326 CaptureLostState() : got_capture_lost_(false) {} 1280 CaptureLostState() : got_capture_lost_(false) {}
1327 1281
1328 bool GetAndClearGotCaptureLost() { 1282 bool GetAndClearGotCaptureLost() {
1329 bool value = got_capture_lost_; 1283 bool value = got_capture_lost_;
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after
1909 1863
1910 ui::KeyEvent key_event2(key_event); 1864 ui::KeyEvent key_event2(key_event);
1911 widget->OnKeyEvent(&key_event2); 1865 widget->OnKeyEvent(&key_event2);
1912 EXPECT_FALSE(key_event2.stopped_propagation()); 1866 EXPECT_FALSE(key_event2.stopped_propagation());
1913 1867
1914 widget->CloseNow(); 1868 widget->CloseNow();
1915 } 1869 }
1916 1870
1917 } // namespace test 1871 } // namespace test
1918 } // namespace views 1872 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/widget/desktop_aura/desktop_native_widget_aura.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698