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

Side by Side Diff: views/controls/combobox/native_combobox_views_unittest.cc

Issue 7761011: views: Fix a couple of trivial TODOS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/utf_string_conversions.h" 5 #include "base/utf_string_conversions.h"
6 #include "ui/base/keycodes/keyboard_codes.h" 6 #include "ui/base/keycodes/keyboard_codes.h"
7 #include "ui/base/models/combobox_model.h" 7 #include "ui/base/models/combobox_model.h"
8 #include "views/controls/combobox/combobox.h" 8 #include "views/controls/combobox/combobox.h"
9 #include "views/controls/combobox/native_combobox_views.h" 9 #include "views/controls/combobox/native_combobox_views.h"
10 #include "views/ime/mock_input_method.h" 10 #include "views/ime/mock_input_method.h"
11 #include "views/test/views_test_base.h" 11 #include "views/test/views_test_base.h"
12 #include "views/widget/native_widget_private.h" 12 #include "views/widget/native_widget_private.h"
13 #include "views/widget/widget.h" 13 #include "views/widget/widget.h"
14 14
15 namespace { 15 namespace {
16 16
17 // A wrapper of Combobox to intercept the result of OnKeyPressed() and 17 // A wrapper of Combobox to intercept the result of OnKeyPressed() and
18 // OnKeyReleased() methods. 18 // OnKeyReleased() methods.
19 class TestCombobox : public views::Combobox { 19 class TestCombobox : public views::Combobox {
20 public: 20 public:
21 TestCombobox(ComboboxModel* model) 21 TestCombobox(ui::ComboboxModel* model)
22 : Combobox(model), 22 : Combobox(model),
23 key_handled_(false), 23 key_handled_(false),
24 key_received_(false) { 24 key_received_(false) {
25 } 25 }
26 26
27 virtual bool OnKeyPressed(const views::KeyEvent& e) OVERRIDE { 27 virtual bool OnKeyPressed(const views::KeyEvent& e) OVERRIDE {
28 key_received_ = true; 28 key_received_ = true;
29 key_handled_ = views::Combobox::OnKeyPressed(e); 29 key_handled_ = views::Combobox::OnKeyPressed(e);
30 return key_handled_; 30 return key_handled_;
31 } 31 }
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 // We need widget to populate wrapper class. 135 // We need widget to populate wrapper class.
136 Widget* widget_; 136 Widget* widget_;
137 137
138 // combobox_ will be allocated InitCombobox() and then owned by widget_. 138 // combobox_ will be allocated InitCombobox() and then owned by widget_.
139 TestCombobox* combobox_; 139 TestCombobox* combobox_;
140 140
141 // combobox_view_ is the pointer to the pure Views interface of combobox_. 141 // combobox_view_ is the pointer to the pure Views interface of combobox_.
142 NativeComboboxViews* combobox_view_; 142 NativeComboboxViews* combobox_view_;
143 143
144 // Combobox does not take ownership of model_, which needs to be scoped. 144 // Combobox does not take ownership of model_, which needs to be scoped.
145 scoped_ptr<ComboboxModel> model_; 145 scoped_ptr<ui::ComboboxModel> model_;
146 146
147 // For testing input method related behaviors. 147 // For testing input method related behaviors.
148 MockInputMethod* input_method_; 148 MockInputMethod* input_method_;
149 }; 149 };
150 150
151 TEST_F(NativeComboboxViewsTest, KeyTest) { 151 TEST_F(NativeComboboxViewsTest, KeyTest) {
152 InitCombobox(); 152 InitCombobox();
153 SendKeyEvent(ui::VKEY_END); 153 SendKeyEvent(ui::VKEY_END);
154 EXPECT_EQ(combobox_->selected_item() + 1, model_->GetItemCount()); 154 EXPECT_EQ(combobox_->selected_item() + 1, model_->GetItemCount());
155 SendKeyEvent(ui::VKEY_HOME); 155 SendKeyEvent(ui::VKEY_HOME);
156 EXPECT_EQ(combobox_->selected_item(), 0); 156 EXPECT_EQ(combobox_->selected_item(), 0);
157 SendKeyEvent(ui::VKEY_DOWN); 157 SendKeyEvent(ui::VKEY_DOWN);
158 SendKeyEvent(ui::VKEY_DOWN); 158 SendKeyEvent(ui::VKEY_DOWN);
159 EXPECT_EQ(combobox_->selected_item(), 2); 159 EXPECT_EQ(combobox_->selected_item(), 2);
160 SendKeyEvent(ui::VKEY_RIGHT); 160 SendKeyEvent(ui::VKEY_RIGHT);
161 EXPECT_EQ(combobox_->selected_item(), 2); 161 EXPECT_EQ(combobox_->selected_item(), 2);
162 SendKeyEvent(ui::VKEY_LEFT); 162 SendKeyEvent(ui::VKEY_LEFT);
163 EXPECT_EQ(combobox_->selected_item(), 2); 163 EXPECT_EQ(combobox_->selected_item(), 2);
164 } 164 }
165 165
166 } // namespace views 166 } // namespace views
OLDNEW
« no previous file with comments | « views/controls/combobox/native_combobox_gtk.cc ('k') | views/controls/combobox/native_combobox_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698