OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/table/table_view.h" | 5 #include "ui/views/controls/table/table_view.h" |
6 | 6 |
7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 #include "ui/views/controls/table/table_grouper.h" | 10 #include "ui/views/controls/table/table_grouper.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 void AddRow(int row, int c1_value, int c2_value); | 60 void AddRow(int row, int c1_value, int c2_value); |
61 | 61 |
62 // Removes the row at index |row|. | 62 // Removes the row at index |row|. |
63 void RemoveRow(int row); | 63 void RemoveRow(int row); |
64 | 64 |
65 // Changes the values of the row at |row|. | 65 // Changes the values of the row at |row|. |
66 void ChangeRow(int row, int c1_value, int c2_value); | 66 void ChangeRow(int row, int c1_value, int c2_value); |
67 | 67 |
68 // ui::TableModel: | 68 // ui::TableModel: |
69 virtual int RowCount() OVERRIDE; | 69 virtual int RowCount() OVERRIDE; |
70 virtual string16 GetText(int row, int column_id) OVERRIDE; | 70 virtual base::string16 GetText(int row, int column_id) OVERRIDE; |
71 virtual void SetObserver(ui::TableModelObserver* observer) OVERRIDE; | 71 virtual void SetObserver(ui::TableModelObserver* observer) OVERRIDE; |
72 virtual int CompareValues(int row1, int row2, int column_id) OVERRIDE; | 72 virtual int CompareValues(int row1, int row2, int column_id) OVERRIDE; |
73 | 73 |
74 private: | 74 private: |
75 ui::TableModelObserver* observer_; | 75 ui::TableModelObserver* observer_; |
76 | 76 |
77 // The data. | 77 // The data. |
78 std::vector<std::vector<int> > rows_; | 78 std::vector<std::vector<int> > rows_; |
79 | 79 |
80 DISALLOW_COPY_AND_ASSIGN(TestTableModel2); | 80 DISALLOW_COPY_AND_ASSIGN(TestTableModel2); |
(...skipping 27 matching lines...) Expand all Loading... |
108 rows_[row][0] = c1_value; | 108 rows_[row][0] = c1_value; |
109 rows_[row][1] = c2_value; | 109 rows_[row][1] = c2_value; |
110 if (observer_) | 110 if (observer_) |
111 observer_->OnItemsChanged(row, 1); | 111 observer_->OnItemsChanged(row, 1); |
112 } | 112 } |
113 | 113 |
114 int TestTableModel2::RowCount() { | 114 int TestTableModel2::RowCount() { |
115 return static_cast<int>(rows_.size()); | 115 return static_cast<int>(rows_.size()); |
116 } | 116 } |
117 | 117 |
118 string16 TestTableModel2::GetText(int row, int column_id) { | 118 base::string16 TestTableModel2::GetText(int row, int column_id) { |
119 return base::IntToString16(rows_[row][column_id]); | 119 return base::IntToString16(rows_[row][column_id]); |
120 } | 120 } |
121 | 121 |
122 void TestTableModel2::SetObserver(ui::TableModelObserver* observer) { | 122 void TestTableModel2::SetObserver(ui::TableModelObserver* observer) { |
123 observer_ = observer; | 123 observer_ = observer; |
124 } | 124 } |
125 | 125 |
126 int TestTableModel2::CompareValues(int row1, int row2, int column_id) { | 126 int TestTableModel2::CompareValues(int row1, int row2, int column_id) { |
127 return rows_[row1][column_id] - rows_[row2][column_id]; | 127 return rows_[row1][column_id] - rows_[row2][column_id]; |
128 } | 128 } |
(...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
832 | 832 |
833 // Extend selection to first row. | 833 // Extend selection to first row. |
834 ClickOnRow(0, ui::EF_SHIFT_DOWN); | 834 ClickOnRow(0, ui::EF_SHIFT_DOWN); |
835 EXPECT_EQ(1, observer.GetChangedCountAndClear()); | 835 EXPECT_EQ(1, observer.GetChangedCountAndClear()); |
836 EXPECT_EQ("active=2 anchor=4 selection=2 3 4", SelectionStateAsString()); | 836 EXPECT_EQ("active=2 anchor=4 selection=2 3 4", SelectionStateAsString()); |
837 | 837 |
838 table_->SetObserver(NULL); | 838 table_->SetObserver(NULL); |
839 } | 839 } |
840 | 840 |
841 } // namespace views | 841 } // namespace views |
OLD | NEW |