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/table/table_view_unittest.cc

Issue 6044007: Remove wstring from TableModel.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years, 12 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 <vector> 5 #include <vector>
6 6
7 #include "app/table_model.h" 7 #include "app/table_model.h"
8 #include "app/table_model_observer.h" 8 #include "app/table_model_observer.h"
9 #include "base/compiler_specific.h"
9 #include "base/message_loop.h" 10 #include "base/message_loop.h"
10 #include "base/string_number_conversions.h" 11 #include "base/string_number_conversions.h"
11 #include "base/utf_string_conversions.h" 12 #include "base/utf_string_conversions.h"
12 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
13 #include "views/controls/table/table_view.h" 14 #include "views/controls/table/table_view.h"
14 #include "views/controls/table/table_view2.h" 15 #include "views/controls/table/table_view2.h"
15 #include "views/window/window_delegate.h" 16 #include "views/window/window_delegate.h"
16 #if defined(OS_WIN) 17 #if defined(OS_WIN)
17 #include "views/window/window_win.h" 18 #include "views/window/window_win.h"
18 #else 19 #else
(...skipping 21 matching lines...) Expand all
40 // Adds a new row at index |row| with values |c1_value| and |c2_value|. 41 // Adds a new row at index |row| with values |c1_value| and |c2_value|.
41 void AddRow(int row, int c1_value, int c2_value); 42 void AddRow(int row, int c1_value, int c2_value);
42 43
43 // Removes the row at index |row|. 44 // Removes the row at index |row|.
44 void RemoveRow(int row); 45 void RemoveRow(int row);
45 46
46 // Changes the values of the row at |row|. 47 // Changes the values of the row at |row|.
47 void ChangeRow(int row, int c1_value, int c2_value); 48 void ChangeRow(int row, int c1_value, int c2_value);
48 49
49 // TableModel 50 // TableModel
50 virtual int RowCount(); 51 virtual int RowCount() OVERRIDE;
51 virtual std::wstring GetText(int row, int column_id); 52 virtual string16 GetText(int row, int column_id) OVERRIDE;
52 virtual void SetObserver(TableModelObserver* observer); 53 virtual void SetObserver(TableModelObserver* observer) OVERRIDE;
53 virtual int CompareValues(int row1, int row2, int column_id); 54 virtual int CompareValues(int row1, int row2, int column_id) OVERRIDE;
54 55
55 private: 56 private:
56 TableModelObserver* observer_; 57 TableModelObserver* observer_;
57 58
58 // The data. 59 // The data.
59 std::vector<std::vector<int> > rows_; 60 std::vector<std::vector<int> > rows_;
60 61
61 DISALLOW_COPY_AND_ASSIGN(TestTableModel); 62 DISALLOW_COPY_AND_ASSIGN(TestTableModel);
62 }; 63 };
63 64
64 // Same behavior as TestTableModel, except even items are in one group, while 65 // Same behavior as TestTableModel, except even items are in one group, while
65 // odd items are put in a different group. 66 // odd items are put in a different group.
66 class GroupTestTableModel : public TestTableModel { 67 class GroupTestTableModel : public TestTableModel {
67 virtual bool HasGroups() { return true; } 68 virtual bool HasGroups() { return true; }
68 69
69 virtual Groups GetGroups() { 70 virtual Groups GetGroups() {
70 Groups groups; 71 Groups groups;
71 Group group1, group2; 72 Group group1, group2;
72 group1.title = L"Group 1"; 73 group1.title = ASCIIToUTF16("Group 1");
73 group1.id = 0; 74 group1.id = 0;
74 group2.title = L"Group 2"; 75 group2.title = ASCIIToUTF16("Group 2");
75 group2.id = 0; 76 group2.id = 0;
76 groups.push_back(group1); 77 groups.push_back(group1);
77 groups.push_back(group2); 78 groups.push_back(group2);
78 return groups; 79 return groups;
79 } 80 }
80 81
81 // Return group = 0 if row is even, otherwise group = 1. 82 // Return group = 0 if row is even, otherwise group = 1.
82 virtual int GetGroupID(int row) { return row % 2; } 83 virtual int GetGroupID(int row) { return row % 2; }
83 }; 84 };
84 85
(...skipping 24 matching lines...) Expand all
109 rows_[row][0] = c1_value; 110 rows_[row][0] = c1_value;
110 rows_[row][1] = c2_value; 111 rows_[row][1] = c2_value;
111 if (observer_) 112 if (observer_)
112 observer_->OnItemsChanged(row, 1); 113 observer_->OnItemsChanged(row, 1);
113 } 114 }
114 115
115 int TestTableModel::RowCount() { 116 int TestTableModel::RowCount() {
116 return static_cast<int>(rows_.size()); 117 return static_cast<int>(rows_.size());
117 } 118 }
118 119
119 std::wstring TestTableModel::GetText(int row, int column_id) { 120 string16 TestTableModel::GetText(int row, int column_id) {
120 return UTF8ToWide(base::IntToString(rows_[row][column_id])); 121 return UTF8ToUTF16(base::IntToString(rows_[row][column_id]));
121 } 122 }
122 123
123 void TestTableModel::SetObserver(TableModelObserver* observer) { 124 void TestTableModel::SetObserver(TableModelObserver* observer) {
124 observer_ = observer; 125 observer_ = observer;
125 } 126 }
126 127
127 int TestTableModel::CompareValues(int row1, int row2, int column_id) { 128 int TestTableModel::CompareValues(int row1, int row2, int column_id) {
128 return rows_[row1][column_id] - rows_[row2][column_id]; 129 return rows_[row1][column_id] - rows_[row2][column_id];
129 } 130 }
130 131
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 621
621 table_->FocusRow(2); 622 table_->FocusRow(2);
622 EXPECT_EQ(2, table_->GetFirstFocusedRow()); 623 EXPECT_EQ(2, table_->GetFirstFocusedRow());
623 624
624 table_->ClearRowFocus(); 625 table_->ClearRowFocus();
625 EXPECT_EQ(-1, table_->GetFirstSelectedRow()); 626 EXPECT_EQ(-1, table_->GetFirstSelectedRow());
626 } 627 }
627 #endif 628 #endif
628 629
629 } // namespace views 630 } // namespace views
OLDNEW
« chrome/common/content_settings_helper_unittest.cc ('K') | « views/controls/table/native_table_gtk.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698