OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 <map> | 5 #include <map> |
6 | 6 |
7 #include "app/gfx/canvas.h" | 7 #include "app/gfx/canvas.h" |
8 #include "app/gfx/path.h" | 8 #include "app/gfx/path.h" |
9 #include "base/clipboard.h" | 9 #include "base/clipboard.h" |
| 10 #include "base/keyboard_codes.h" |
10 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
12 #include "views/background.h" | 13 #include "views/background.h" |
13 #include "views/controls/button/checkbox.h" | 14 #include "views/controls/button/checkbox.h" |
14 #if defined(OS_WIN) | 15 #if defined(OS_WIN) |
15 #include "views/controls/button/native_button_win.h" | 16 #include "views/controls/button/native_button_win.h" |
16 #endif | 17 #endif |
17 #include "views/controls/scroll_view.h" | 18 #include "views/controls/scroll_view.h" |
18 #include "views/controls/textfield/textfield.h" | 19 #include "views/controls/textfield/textfield.h" |
19 #include "views/event.h" | 20 #include "views/event.h" |
(...skipping 1031 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1051 native_window_ = window->GetNativeWindow(); | 1052 native_window_ = window->GetNativeWindow(); |
1052 focus_manager_ = FocusManager::GetFocusManagerForNativeView(native_window_); | 1053 focus_manager_ = FocusManager::GetFocusManagerForNativeView(native_window_); |
1053 client_view_ = | 1054 client_view_ = |
1054 static_cast<views::DialogClientView*>(window->GetClientView()); | 1055 static_cast<views::DialogClientView*>(window->GetClientView()); |
1055 ok_button_ = client_view_->ok_button(); | 1056 ok_button_ = client_view_->ok_button(); |
1056 cancel_button_ = client_view_->cancel_button(); | 1057 cancel_button_ = client_view_->cancel_button(); |
1057 } | 1058 } |
1058 | 1059 |
1059 void SimularePressingEnterAndCheckDefaultButton(ButtonID button_id) { | 1060 void SimularePressingEnterAndCheckDefaultButton(ButtonID button_id) { |
1060 #if defined(OS_WIN) | 1061 #if defined(OS_WIN) |
1061 focus_manager_->OnKeyDown(native_window_, WM_KEYDOWN, VK_RETURN, 0); | 1062 KeyEvent event(Event::ET_KEY_PRESSED, VK_RETURN, 0, 0); |
| 1063 focus_manager_->OnKeyEvent(event); |
1062 #else | 1064 #else |
1063 // TODO(platform) | 1065 // TODO(platform) |
1064 return; | 1066 return; |
1065 #endif | 1067 #endif |
1066 switch (button_id) { | 1068 switch (button_id) { |
1067 case OK: | 1069 case OK: |
1068 EXPECT_TRUE(dialog_view_->oked_); | 1070 EXPECT_TRUE(dialog_view_->oked_); |
1069 EXPECT_FALSE(dialog_view_->canceled_); | 1071 EXPECT_FALSE(dialog_view_->canceled_); |
1070 EXPECT_FALSE(dialog_view_->last_pressed_button_); | 1072 EXPECT_FALSE(dialog_view_->last_pressed_button_); |
1071 break; | 1073 break; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1138 | 1140 |
1139 // Focus the cancel button. | 1141 // Focus the cancel button. |
1140 client_view_->FocusWillChange(NULL, cancel_button_); | 1142 client_view_->FocusWillChange(NULL, cancel_button_); |
1141 EXPECT_FALSE(ok_button_->is_default()); | 1143 EXPECT_FALSE(ok_button_->is_default()); |
1142 EXPECT_TRUE(cancel_button_->is_default()); | 1144 EXPECT_TRUE(cancel_button_->is_default()); |
1143 EXPECT_FALSE(dialog_view_->button1_->is_default()); | 1145 EXPECT_FALSE(dialog_view_->button1_->is_default()); |
1144 EXPECT_FALSE(dialog_view_->button2_->is_default()); | 1146 EXPECT_FALSE(dialog_view_->button2_->is_default()); |
1145 SimularePressingEnterAndCheckDefaultButton(CANCEL); | 1147 SimularePressingEnterAndCheckDefaultButton(CANCEL); |
1146 } | 1148 } |
1147 #endif | 1149 #endif |
OLD | NEW |