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

Side by Side Diff: ui/views/controls/combobox/combobox_unittest.cc

Issue 26540004: Return blank strings for Views Combobox separator items. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Upload again to kick the CQ. Created 7 years, 2 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
« no previous file with comments | « ui/views/controls/combobox/combobox.cc ('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 "ui/views/controls/combobox/combobox.h" 5 #include "ui/views/controls/combobox/combobox.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "ui/base/models/combobox_model.h" 10 #include "ui/base/models/combobox_model.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 class TestComboboxModel : public ui::ComboboxModel { 56 class TestComboboxModel : public ui::ComboboxModel {
57 public: 57 public:
58 TestComboboxModel() {} 58 TestComboboxModel() {}
59 virtual ~TestComboboxModel() {} 59 virtual ~TestComboboxModel() {}
60 60
61 // ui::ComboboxModel: 61 // ui::ComboboxModel:
62 virtual int GetItemCount() const OVERRIDE { 62 virtual int GetItemCount() const OVERRIDE {
63 return 10; 63 return 10;
64 } 64 }
65 virtual string16 GetItemAt(int index) OVERRIDE { 65 virtual string16 GetItemAt(int index) OVERRIDE {
66 return string16(); 66 DCHECK(!IsItemSeparatorAt(index));
67 return ASCIIToUTF16(IsItemSeparatorAt(index) ? "SEPARATOR" : "ITEM");
67 } 68 }
68 virtual bool IsItemSeparatorAt(int index) OVERRIDE { 69 virtual bool IsItemSeparatorAt(int index) OVERRIDE {
69 return separators_.find(index) != separators_.end(); 70 return separators_.find(index) != separators_.end();
70 } 71 }
71 72
72 void SetSeparators(const std::set<int>& separators) { 73 void SetSeparators(const std::set<int>& separators) {
73 separators_ = separators; 74 separators_ = separators;
74 } 75 }
75 76
76 private: 77 private:
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 SendKeyEvent(ui::VKEY_HOME); 301 SendKeyEvent(ui::VKEY_HOME);
301 EXPECT_EQ(0, combobox_->selected_index()); 302 EXPECT_EQ(0, combobox_->selected_index());
302 SendKeyEvent(ui::VKEY_NEXT); 303 SendKeyEvent(ui::VKEY_NEXT);
303 EXPECT_EQ(6, combobox_->selected_index()); 304 EXPECT_EQ(6, combobox_->selected_index());
304 SendKeyEvent(ui::VKEY_PRIOR); 305 SendKeyEvent(ui::VKEY_PRIOR);
305 EXPECT_EQ(0, combobox_->selected_index()); 306 EXPECT_EQ(0, combobox_->selected_index());
306 SendKeyEvent(ui::VKEY_END); 307 SendKeyEvent(ui::VKEY_END);
307 EXPECT_EQ(6, combobox_->selected_index()); 308 EXPECT_EQ(6, combobox_->selected_index());
308 } 309 }
309 310
311 TEST_F(ComboboxTest, GetTextForRowTest) {
312 InitCombobox();
313 std::set<int> separators;
314 separators.insert(0);
315 separators.insert(1);
316 separators.insert(9);
317 model_->SetSeparators(separators);
318 for (int i = 0; i < combobox_->GetRowCount(); ++i) {
319 if (separators.count(i) != 0)
320 EXPECT_TRUE(combobox_->GetTextForRow(i).empty()) << i;
321 else
322 EXPECT_EQ(ASCIIToUTF16("ITEM"), combobox_->GetTextForRow(i)) << i;
323 }
324 }
325
310 } // namespace views 326 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/combobox/combobox.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698