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

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

Issue 1782773002: MacViews: Fix ViewTest.HandleAccelerator by faking window activation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Faked activations for everyone! Created 4 years, 9 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/native_widget_mac_interactive_uitest.mm ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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/macros.h" 7 #include "base/macros.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "ui/base/hit_test.h" 9 #include "ui/base/hit_test.h"
10 #include "ui/events/event_processor.h" 10 #include "ui/events/event_processor.h"
11 #include "ui/views/bubble/bubble_border.h" 11 #include "ui/views/bubble/bubble_border.h"
12 #include "ui/views/bubble/bubble_frame_view.h" 12 #include "ui/views/bubble/bubble_frame_view.h"
13 #include "ui/views/controls/button/checkbox.h" 13 #include "ui/views/controls/button/checkbox.h"
14 #include "ui/views/controls/button/label_button.h" 14 #include "ui/views/controls/button/label_button.h"
15 #include "ui/views/controls/textfield/textfield.h" 15 #include "ui/views/controls/textfield/textfield.h"
16 #include "ui/views/test/views_test_base.h" 16 #include "ui/views/test/views_test_base.h"
17 #include "ui/views/widget/widget.h" 17 #include "ui/views/widget/widget.h"
18 #include "ui/views/window/dialog_client_view.h" 18 #include "ui/views/window/dialog_client_view.h"
19 #include "ui/views/window/dialog_delegate.h" 19 #include "ui/views/window/dialog_delegate.h"
20 20
21 #if defined(OS_MACOSX)
22 #include "ui/base/test/scoped_fake_nswindow_focus.h"
23 #endif
24
25 namespace views { 21 namespace views {
26 22
27 namespace { 23 namespace {
28 24
29 class TestDialog : public DialogDelegateView, public ButtonListener { 25 class TestDialog : public DialogDelegateView, public ButtonListener {
30 public: 26 public:
31 TestDialog() 27 TestDialog()
32 : input_(new views::Textfield()), 28 : input_(new views::Textfield()),
33 canceled_(false), 29 canceled_(false),
34 accepted_(false), 30 accepted_(false),
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 ui::KeyEvent event_copy = event; 129 ui::KeyEvent event_copy = event;
134 if (dialog()->GetFocusManager()->OnKeyEvent(event_copy)) 130 if (dialog()->GetFocusManager()->OnKeyEvent(event_copy))
135 dialog()->GetWidget()->OnKeyEvent(&event_copy); 131 dialog()->GetWidget()->OnKeyEvent(&event_copy);
136 } 132 }
137 133
138 TestDialog* dialog() const { return dialog_; } 134 TestDialog* dialog() const { return dialog_; }
139 135
140 private: 136 private:
141 TestDialog* dialog_; 137 TestDialog* dialog_;
142 138
143 #if defined(OS_MACOSX)
144 // Causes Widget::Show() to transfer focus synchronously and become immune to
145 // losing focus to processes running in parallel.
146 ui::test::ScopedFakeNSWindowFocus fake_focus;
147 #endif
148
149 DISALLOW_COPY_AND_ASSIGN(DialogTest); 139 DISALLOW_COPY_AND_ASSIGN(DialogTest);
150 }; 140 };
151 141
152 } // namespace 142 } // namespace
153 143
154 TEST_F(DialogTest, AcceptAndCancel) { 144 TEST_F(DialogTest, AcceptAndCancel) {
155 DialogClientView* client_view = dialog()->GetDialogClientView(); 145 DialogClientView* client_view = dialog()->GetDialogClientView();
156 LabelButton* ok_button = client_view->ok_button(); 146 LabelButton* ok_button = client_view->ok_button();
157 LabelButton* cancel_button = client_view->cancel_button(); 147 LabelButton* cancel_button = client_view->cancel_button();
158 148
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 dialog2->TearDown(); 253 dialog2->TearDown();
264 } 254 }
265 255
266 // Tests default focus is assigned correctly when showing a new dialog. 256 // Tests default focus is assigned correctly when showing a new dialog.
267 TEST_F(DialogTest, InitialFocus) { 257 TEST_F(DialogTest, InitialFocus) {
268 EXPECT_TRUE(dialog()->input()->HasFocus()); 258 EXPECT_TRUE(dialog()->input()->HasFocus());
269 EXPECT_EQ(dialog()->input(), dialog()->GetFocusManager()->GetFocusedView()); 259 EXPECT_EQ(dialog()->input(), dialog()->GetFocusManager()->GetFocusedView());
270 } 260 }
271 261
272 } // namespace views 262 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/widget/native_widget_mac_interactive_uitest.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698