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

Side by Side Diff: ash/shelf/shelf_model_unittest.cc

Issue 684643002: Standardize usage of virtual/override/final specifiers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase 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 | « ash/shelf/shelf_layout_manager_unittest.cc ('k') | ash/shelf/shelf_navigator_unittest.cc » ('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 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 "ash/shelf/shelf_model.h" 5 #include "ash/shelf/shelf_model.h"
6 6
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 9
10 #include "ash/ash_switches.h" 10 #include "ash/ash_switches.h"
(...skipping 22 matching lines...) Expand all
33 std::string result; 33 std::string result;
34 AddToResult("added=%d", added_count_, &result); 34 AddToResult("added=%d", added_count_, &result);
35 AddToResult("removed=%d", removed_count_, &result); 35 AddToResult("removed=%d", removed_count_, &result);
36 AddToResult("changed=%d", changed_count_, &result); 36 AddToResult("changed=%d", changed_count_, &result);
37 AddToResult("moved=%d", moved_count_, &result); 37 AddToResult("moved=%d", moved_count_, &result);
38 added_count_ = removed_count_ = changed_count_ = moved_count_ = 0; 38 added_count_ = removed_count_ = changed_count_ = moved_count_ = 0;
39 return result; 39 return result;
40 } 40 }
41 41
42 // ShelfModelObserver overrides: 42 // ShelfModelObserver overrides:
43 virtual void ShelfItemAdded(int index) override { 43 void ShelfItemAdded(int index) override { added_count_++; }
44 added_count_++; 44 void ShelfItemRemoved(int index, ShelfID id) override { removed_count_++; }
45 } 45 void ShelfItemChanged(int index, const ShelfItem& old_item) override {
46 virtual void ShelfItemRemoved(int index, ShelfID id) override {
47 removed_count_++;
48 }
49 virtual void ShelfItemChanged(int index,
50 const ShelfItem& old_item) override {
51 changed_count_++; 46 changed_count_++;
52 } 47 }
53 virtual void ShelfItemMoved(int start_index, int target_index) override { 48 void ShelfItemMoved(int start_index, int target_index) override {
54 moved_count_++; 49 moved_count_++;
55 } 50 }
56 virtual void ShelfStatusChanged() override { 51 void ShelfStatusChanged() override {}
57 }
58 52
59 private: 53 private:
60 void AddToResult(const std::string& format, int count, std::string* result) { 54 void AddToResult(const std::string& format, int count, std::string* result) {
61 if (!count) 55 if (!count)
62 return; 56 return;
63 if (!result->empty()) 57 if (!result->empty())
64 *result += " "; 58 *result += " ";
65 *result += base::StringPrintf(format.c_str(), count); 59 *result += base::StringPrintf(format.c_str(), count);
66 } 60 }
67 61
68 int added_count_; 62 int added_count_;
69 int removed_count_; 63 int removed_count_;
70 int changed_count_; 64 int changed_count_;
71 int moved_count_; 65 int moved_count_;
72 66
73 DISALLOW_COPY_AND_ASSIGN(TestShelfModelObserver); 67 DISALLOW_COPY_AND_ASSIGN(TestShelfModelObserver);
74 }; 68 };
75 69
76 } // namespace 70 } // namespace
77 71
78 class ShelfModelTest : public testing::Test { 72 class ShelfModelTest : public testing::Test {
79 public: 73 public:
80 ShelfModelTest() {} 74 ShelfModelTest() {}
81 virtual ~ShelfModelTest() {} 75 ~ShelfModelTest() override {}
82 76
83 virtual void SetUp() { 77 void SetUp() override {
84 model_.reset(new ShelfModel); 78 model_.reset(new ShelfModel);
85 observer_.reset(new TestShelfModelObserver); 79 observer_.reset(new TestShelfModelObserver);
86 EXPECT_EQ(0, model_->item_count()); 80 EXPECT_EQ(0, model_->item_count());
87 81
88 ShelfItem item; 82 ShelfItem item;
89 item.type = TYPE_APP_LIST; 83 item.type = TYPE_APP_LIST;
90 model_->Add(item); 84 model_->Add(item);
91 EXPECT_EQ(1, model_->item_count()); 85 EXPECT_EQ(1, model_->item_count());
92 86
93 model_->AddObserver(observer_.get()); 87 model_->AddObserver(observer_.get());
94 } 88 }
95 89
96 virtual void TearDown() { 90 void TearDown() override {
97 observer_.reset(); 91 observer_.reset();
98 model_.reset(); 92 model_.reset();
99 } 93 }
100 94
101 scoped_ptr<ShelfModel> model_; 95 scoped_ptr<ShelfModel> model_;
102 scoped_ptr<TestShelfModelObserver> observer_; 96 scoped_ptr<TestShelfModelObserver> observer_;
103 97
104 private: 98 private:
105 DISALLOW_COPY_AND_ASSIGN(ShelfModelTest); 99 DISALLOW_COPY_AND_ASSIGN(ShelfModelTest);
106 }; 100 };
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 // Now change the type of the second item and make sure that it is moving 343 // Now change the type of the second item and make sure that it is moving
350 // behind the shortcuts. 344 // behind the shortcuts.
351 item.type = TYPE_PLATFORM_APP; 345 item.type = TYPE_PLATFORM_APP;
352 model_->Set(app2_index, item); 346 model_->Set(app2_index, item);
353 347
354 // The item should have moved in front of the app launcher. 348 // The item should have moved in front of the app launcher.
355 EXPECT_EQ(TYPE_PLATFORM_APP, model_->items()[4].type); 349 EXPECT_EQ(TYPE_PLATFORM_APP, model_->items()[4].type);
356 } 350 }
357 351
358 } // namespace ash 352 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shelf/shelf_layout_manager_unittest.cc ('k') | ash/shelf/shelf_navigator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698