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

Side by Side Diff: ui/views/window/dialog_client_view_unittest.cc

Issue 1645013004: Views - dialog button defaultness shouldn't follow focus. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix win compile Created 4 years, 10 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/window/dialog_client_view.cc ('k') | ui/views/window/dialog_delegate_unittest.cc » ('j') | 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) 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/macros.h" 5 #include "base/macros.h"
6 #include "base/strings/utf_string_conversions.h" 6 #include "base/strings/utf_string_conversions.h"
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 #include "ui/base/ui_base_types.h" 8 #include "ui/base/ui_base_types.h"
9 #include "ui/views/controls/button/label_button.h" 9 #include "ui/views/controls/button/label_button.h"
10 #include "ui/views/test/test_views.h" 10 #include "ui/views/test/test_views.h"
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 gfx::Size no_footnote_size = client_view()->bounds().size(); 249 gfx::Size no_footnote_size = client_view()->bounds().size();
250 250
251 View* footnote_view = new ProportionallySizedView(3); 251 View* footnote_view = new ProportionallySizedView(3);
252 SetFootnoteView(footnote_view); 252 SetFootnoteView(footnote_view);
253 CheckContentsIsSetToPreferredSize(); 253 CheckContentsIsSetToPreferredSize();
254 EXPECT_GT(client_view()->bounds().height(), no_footnote_size.height()); 254 EXPECT_GT(client_view()->bounds().height(), no_footnote_size.height());
255 EXPECT_EQ(footnote_view->bounds().width() * 3, 255 EXPECT_EQ(footnote_view->bounds().width() * 3,
256 footnote_view->bounds().height()); 256 footnote_view->bounds().height());
257 } 257 }
258 258
259 // No ReparentNativeView on Mac. See http://crbug.com/514920.
260 #if defined(OS_MACOSX) && !defined(USE_AURA)
261 #define MAYBE_FocusManager DISABLED_FocusManager
262 #else
263 #define MAYBE_FocusManager FocusManager
264 #endif
265
266 // Test that the DialogClientView's FocusManager is properly updated when the
267 // DialogClientView belongs to a non top level widget and the widget is
268 // reparented. The DialogClientView belongs to a non top level widget in the
269 // case of constrained windows. The constrained window's widget is reparented
270 // when a browser tab is dragged to a different browser window.
271 TEST_F(DialogClientViewTest, MAYBE_FocusManager) {
272 scoped_ptr<Widget> toplevel1(new Widget);
273 Widget::InitParams toplevel1_params =
274 CreateParams(Widget::InitParams::TYPE_WINDOW);
275 toplevel1_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
276 toplevel1->Init(toplevel1_params);
277
278 scoped_ptr<Widget> toplevel2(new Widget);
279 Widget::InitParams toplevel2_params =
280 CreateParams(Widget::InitParams::TYPE_WINDOW);
281 toplevel2_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
282 toplevel2->Init(toplevel2_params);
283
284 Widget* dialog = new Widget;
285 Widget::InitParams dialog_params =
286 CreateParams(Widget::InitParams::TYPE_WINDOW);
287 dialog_params.child = true;
288 dialog_params.delegate = new DialogDelegateView();
289 dialog_params.parent = toplevel1->GetNativeView();
290 dialog->Init(dialog_params);
291
292 // Test that the FocusManager has been properly set when the DialogClientView
293 // was parented to |dialog|.
294 DialogClientView* client_view =
295 static_cast<DialogClientView*>(dialog->client_view());
296 EXPECT_EQ(toplevel1->GetFocusManager(), client_view->focus_manager_);
297
298 // Test that the FocusManager is properly updated when the DialogClientView's
299 // top level widget is changed.
300 Widget::ReparentNativeView(dialog->GetNativeView(), NULL);
301 EXPECT_EQ(NULL, client_view->focus_manager_);
302 Widget::ReparentNativeView(dialog->GetNativeView(),
303 toplevel2->GetNativeView());
304 EXPECT_EQ(toplevel2->GetFocusManager(), client_view->focus_manager_);
305 Widget::ReparentNativeView(dialog->GetNativeView(),
306 toplevel1->GetNativeView());
307 EXPECT_NE(toplevel1->GetFocusManager(), toplevel2->GetFocusManager());
308 EXPECT_EQ(toplevel1->GetFocusManager(), client_view->focus_manager_);
309
310 // Test that the FocusManager is properly cleared when the DialogClientView is
311 // removed from |dialog| during the widget's destruction.
312 client_view->set_owned_by_client();
313 scoped_ptr<DialogClientView> owned_client_view(client_view);
314 toplevel1->CloseNow();
315 toplevel2->CloseNow();
316 EXPECT_EQ(NULL, owned_client_view->focus_manager_);
317 }
318
319 } // namespace views 259 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/window/dialog_client_view.cc ('k') | ui/views/window/dialog_delegate_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698