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

Side by Side Diff: ui/views/controls/table/table_view_unittest.cc

Issue 681883002: Standardize usage of virtual/override/final specifiers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « ui/views/controls/table/table_view.h ('k') | ui/views/controls/table/test_table_model.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 // Adds a new row at index |row| with values |c1_value| and |c2_value|. 59 // Adds a new row at index |row| with values |c1_value| and |c2_value|.
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 int RowCount() override;
70 virtual base::string16 GetText(int row, int column_id) override; 70 base::string16 GetText(int row, int column_id) override;
71 virtual void SetObserver(ui::TableModelObserver* observer) override; 71 void SetObserver(ui::TableModelObserver* observer) override;
72 virtual int CompareValues(int row1, int row2, int column_id) override; 72 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);
81 }; 81 };
82 82
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 } 150 }
151 151
152 class TestTableView : public TableView { 152 class TestTableView : public TableView {
153 public: 153 public:
154 TestTableView(ui::TableModel* model, 154 TestTableView(ui::TableModel* model,
155 const std::vector<ui::TableColumn>& columns) 155 const std::vector<ui::TableColumn>& columns)
156 : TableView(model, columns, TEXT_ONLY, false) { 156 : TableView(model, columns, TEXT_ONLY, false) {
157 } 157 }
158 158
159 // View overrides: 159 // View overrides:
160 virtual bool HasFocus() const override { 160 bool HasFocus() const override {
161 // Overriden so key processing works. 161 // Overriden so key processing works.
162 return true; 162 return true;
163 } 163 }
164 164
165 private: 165 private:
166 DISALLOW_COPY_AND_ASSIGN(TestTableView); 166 DISALLOW_COPY_AND_ASSIGN(TestTableView);
167 }; 167 };
168 168
169 } // namespace 169 } // namespace
170 170
171 class TableViewTest : public testing::Test { 171 class TableViewTest : public testing::Test {
172 public: 172 public:
173 TableViewTest() : table_(NULL) {} 173 TableViewTest() : table_(NULL) {}
174 174
175 virtual void SetUp() override { 175 void SetUp() override {
176 model_.reset(new TestTableModel2); 176 model_.reset(new TestTableModel2);
177 std::vector<ui::TableColumn> columns(2); 177 std::vector<ui::TableColumn> columns(2);
178 columns[0].title = base::ASCIIToUTF16("Title Column 0"); 178 columns[0].title = base::ASCIIToUTF16("Title Column 0");
179 columns[0].sortable = true; 179 columns[0].sortable = true;
180 columns[1].title = base::ASCIIToUTF16("Title Column 1"); 180 columns[1].title = base::ASCIIToUTF16("Title Column 1");
181 columns[1].id = 1; 181 columns[1].id = 1;
182 columns[1].sortable = true; 182 columns[1].sortable = true;
183 table_ = new TestTableView(model_.get(), columns); 183 table_ = new TestTableView(model_.get(), columns);
184 parent_.reset(table_->CreateParentIfNecessary()); 184 parent_.reset(table_->CreateParentIfNecessary());
185 parent_->SetBounds(0, 0, 10000, 10000); 185 parent_->SetBounds(0, 0, 10000, 10000);
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 403
404 class TableGrouperImpl : public TableGrouper { 404 class TableGrouperImpl : public TableGrouper {
405 public: 405 public:
406 TableGrouperImpl() {} 406 TableGrouperImpl() {}
407 407
408 void SetRanges(const std::vector<int>& ranges) { 408 void SetRanges(const std::vector<int>& ranges) {
409 ranges_ = ranges; 409 ranges_ = ranges;
410 } 410 }
411 411
412 // TableGrouper overrides: 412 // TableGrouper overrides:
413 virtual void GetGroupRange(int model_index, GroupRange* range) override { 413 void GetGroupRange(int model_index, GroupRange* range) override {
414 int offset = 0; 414 int offset = 0;
415 size_t range_index = 0; 415 size_t range_index = 0;
416 for (; range_index < ranges_.size() && offset < model_index; ++range_index) 416 for (; range_index < ranges_.size() && offset < model_index; ++range_index)
417 offset += ranges_[range_index]; 417 offset += ranges_[range_index];
418 418
419 if (offset == model_index) { 419 if (offset == model_index) {
420 range->start = model_index; 420 range->start = model_index;
421 range->length = ranges_[range_index]; 421 range->length = ranges_[range_index];
422 } else { 422 } else {
423 range->start = offset - ranges_[range_index - 1]; 423 range->start = offset - ranges_[range_index - 1];
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 public: 507 public:
508 TableViewObserverImpl() : selection_changed_count_(0) {} 508 TableViewObserverImpl() : selection_changed_count_(0) {}
509 509
510 int GetChangedCountAndClear() { 510 int GetChangedCountAndClear() {
511 const int count = selection_changed_count_; 511 const int count = selection_changed_count_;
512 selection_changed_count_ = 0; 512 selection_changed_count_ = 0;
513 return count; 513 return count;
514 } 514 }
515 515
516 // TableViewObserver overrides: 516 // TableViewObserver overrides:
517 virtual void OnSelectionChanged() override { 517 void OnSelectionChanged() override { selection_changed_count_++; }
518 selection_changed_count_++;
519 }
520 518
521 private: 519 private:
522 int selection_changed_count_; 520 int selection_changed_count_;
523 521
524 DISALLOW_COPY_AND_ASSIGN(TableViewObserverImpl); 522 DISALLOW_COPY_AND_ASSIGN(TableViewObserverImpl);
525 }; 523 };
526 524
527 } // namespace 525 } // namespace
528 526
529 // Assertions around changing the selection. 527 // Assertions around changing the selection.
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 834
837 // Extend selection to first row. 835 // Extend selection to first row.
838 ClickOnRow(0, ui::EF_SHIFT_DOWN); 836 ClickOnRow(0, ui::EF_SHIFT_DOWN);
839 EXPECT_EQ(1, observer.GetChangedCountAndClear()); 837 EXPECT_EQ(1, observer.GetChangedCountAndClear());
840 EXPECT_EQ("active=2 anchor=4 selection=2 3 4", SelectionStateAsString()); 838 EXPECT_EQ("active=2 anchor=4 selection=2 3 4", SelectionStateAsString());
841 839
842 table_->SetObserver(NULL); 840 table_->SetObserver(NULL);
843 } 841 }
844 842
845 } // namespace views 843 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/table/table_view.h ('k') | ui/views/controls/table/test_table_model.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698