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

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

Issue 404203003: Distinguish between keystroke and character events. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: IsCharFromNative() for Mac build Created 6 years, 4 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/win/hwnd_message_handler.cc ('k') | ui/wm/core/compound_event_filter_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 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 "base/strings/utf_string_conversions.h" 5 #include "base/strings/utf_string_conversions.h"
6 #include "ui/base/hit_test.h" 6 #include "ui/base/hit_test.h"
7 #include "ui/views/bubble/bubble_border.h" 7 #include "ui/views/bubble/bubble_border.h"
8 #include "ui/views/bubble/bubble_frame_view.h" 8 #include "ui/views/bubble/bubble_frame_view.h"
9 #include "ui/views/controls/button/checkbox.h" 9 #include "ui/views/controls/button/checkbox.h"
10 #include "ui/views/controls/button/label_button.h" 10 #include "ui/views/controls/button/label_button.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 virtual bool UseNewStyleForThisDialog() const OVERRIDE { return true; } 44 virtual bool UseNewStyleForThisDialog() const OVERRIDE { return true; }
45 45
46 // ButtonListener override: 46 // ButtonListener override:
47 virtual void ButtonPressed(Button* sender, const ui::Event& event) OVERRIDE { 47 virtual void ButtonPressed(Button* sender, const ui::Event& event) OVERRIDE {
48 last_pressed_button_ = sender; 48 last_pressed_button_ = sender;
49 } 49 }
50 50
51 Button* last_pressed_button() const { return last_pressed_button_; } 51 Button* last_pressed_button() const { return last_pressed_button_; }
52 52
53 void PressEnterAndCheckStates(Button* button) { 53 void PressEnterAndCheckStates(Button* button) {
54 ui::KeyEvent key_event(ui::ET_KEY_PRESSED, ui::VKEY_RETURN, 0, false); 54 ui::KeyEvent key_event(ui::ET_KEY_PRESSED, ui::VKEY_RETURN, ui::EF_NONE);
55 GetFocusManager()->OnKeyEvent(key_event); 55 GetFocusManager()->OnKeyEvent(key_event);
56 const DialogClientView* client_view = GetDialogClientView(); 56 const DialogClientView* client_view = GetDialogClientView();
57 EXPECT_EQ(canceled_, client_view->cancel_button()->is_default()); 57 EXPECT_EQ(canceled_, client_view->cancel_button()->is_default());
58 EXPECT_EQ(accepted_, client_view->ok_button()->is_default()); 58 EXPECT_EQ(accepted_, client_view->ok_button()->is_default());
59 // This view does not listen for ok or cancel clicks, DialogClientView does. 59 // This view does not listen for ok or cancel clicks, DialogClientView does.
60 CheckAndResetStates(button == client_view->cancel_button(), 60 CheckAndResetStates(button == client_view->cancel_button(),
61 button == client_view->ok_button(), 61 button == client_view->ok_button(),
62 (canceled_ || accepted_ ) ? NULL : button); 62 (canceled_ || accepted_ ) ? NULL : button);
63 } 63 }
64 64
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 EXPECT_FALSE(button_2->is_default()); 151 EXPECT_FALSE(button_2->is_default());
152 dialog()->PressEnterAndCheckStates(ok_button); 152 dialog()->PressEnterAndCheckStates(ok_button);
153 } 153 }
154 154
155 TEST_F(DialogTest, AcceptAndCancel) { 155 TEST_F(DialogTest, AcceptAndCancel) {
156 DialogClientView* client_view = dialog()->GetDialogClientView(); 156 DialogClientView* client_view = dialog()->GetDialogClientView();
157 LabelButton* ok_button = client_view->ok_button(); 157 LabelButton* ok_button = client_view->ok_button();
158 LabelButton* cancel_button = client_view->cancel_button(); 158 LabelButton* cancel_button = client_view->cancel_button();
159 159
160 // Check that return/escape accelerators accept/cancel dialogs. 160 // Check that return/escape accelerators accept/cancel dialogs.
161 const ui::KeyEvent return_key(ui::ET_KEY_PRESSED, ui::VKEY_RETURN, 0, false); 161 const ui::KeyEvent return_key(
162 ui::ET_KEY_PRESSED, ui::VKEY_RETURN, ui::EF_NONE);
162 dialog()->GetFocusManager()->OnKeyEvent(return_key); 163 dialog()->GetFocusManager()->OnKeyEvent(return_key);
163 dialog()->CheckAndResetStates(false, true, NULL); 164 dialog()->CheckAndResetStates(false, true, NULL);
164 const ui::KeyEvent escape_key(ui::ET_KEY_PRESSED, ui::VKEY_ESCAPE, 0, false); 165 const ui::KeyEvent escape_key(
166 ui::ET_KEY_PRESSED, ui::VKEY_ESCAPE, ui::EF_NONE);
165 dialog()->GetFocusManager()->OnKeyEvent(escape_key); 167 dialog()->GetFocusManager()->OnKeyEvent(escape_key);
166 dialog()->CheckAndResetStates(true, false, NULL); 168 dialog()->CheckAndResetStates(true, false, NULL);
167 169
168 // Check ok and cancel button behavior on a directed return key events. 170 // Check ok and cancel button behavior on a directed return key events.
169 ok_button->OnKeyPressed(return_key); 171 ok_button->OnKeyPressed(return_key);
170 dialog()->CheckAndResetStates(false, true, NULL); 172 dialog()->CheckAndResetStates(false, true, NULL);
171 cancel_button->OnKeyPressed(return_key); 173 cancel_button->OnKeyPressed(return_key);
172 dialog()->CheckAndResetStates(true, false, NULL); 174 dialog()->CheckAndResetStates(true, false, NULL);
173 175
174 // Check that return accelerators cancel dialogs if cancel is focused. 176 // Check that return accelerators cancel dialogs if cancel is focused.
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 frame2->GetPreferredSize().height()); 222 frame2->GetPreferredSize().height());
221 223
222 // Giving the default test dialog a title will yield the same bounds. 224 // Giving the default test dialog a title will yield the same bounds.
223 dialog()->set_title(base::ASCIIToUTF16("Title")); 225 dialog()->set_title(base::ASCIIToUTF16("Title"));
224 dialog()->GetWidget()->UpdateWindowTitle(); 226 dialog()->GetWidget()->UpdateWindowTitle();
225 EXPECT_EQ(frame1->GetPreferredSize().height(), 227 EXPECT_EQ(frame1->GetPreferredSize().height(),
226 frame2->GetPreferredSize().height()); 228 frame2->GetPreferredSize().height());
227 } 229 }
228 230
229 } // namespace views 231 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/win/hwnd_message_handler.cc ('k') | ui/wm/core/compound_event_filter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698