OLD | NEW |
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/app_list/app_list_model.h" | 5 #include "ui/app_list/app_list_model.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 TestObserver() | 26 TestObserver() |
27 : status_changed_count_(0), | 27 : status_changed_count_(0), |
28 items_added_(0), | 28 items_added_(0), |
29 items_removed_(0), | 29 items_removed_(0), |
30 items_updated_(0) { | 30 items_updated_(0) { |
31 } | 31 } |
32 virtual ~TestObserver() { | 32 virtual ~TestObserver() { |
33 } | 33 } |
34 | 34 |
35 // AppListModelObserver | 35 // AppListModelObserver |
36 virtual void OnAppListModelStatusChanged() OVERRIDE { | 36 virtual void OnAppListModelStatusChanged() override { |
37 ++status_changed_count_; | 37 ++status_changed_count_; |
38 } | 38 } |
39 | 39 |
40 virtual void OnAppListItemAdded(AppListItem* item) OVERRIDE { | 40 virtual void OnAppListItemAdded(AppListItem* item) override { |
41 items_added_++; | 41 items_added_++; |
42 } | 42 } |
43 | 43 |
44 virtual void OnAppListItemWillBeDeleted(AppListItem* item) OVERRIDE { | 44 virtual void OnAppListItemWillBeDeleted(AppListItem* item) override { |
45 items_removed_++; | 45 items_removed_++; |
46 } | 46 } |
47 | 47 |
48 virtual void OnAppListItemUpdated(AppListItem* item) OVERRIDE { | 48 virtual void OnAppListItemUpdated(AppListItem* item) override { |
49 items_updated_++; | 49 items_updated_++; |
50 } | 50 } |
51 | 51 |
52 int status_changed_count() const { return status_changed_count_; } | 52 int status_changed_count() const { return status_changed_count_; } |
53 size_t items_added() { return items_added_; } | 53 size_t items_added() { return items_added_; } |
54 size_t items_removed() { return items_removed_; } | 54 size_t items_removed() { return items_removed_; } |
55 size_t items_updated() { return items_updated_; } | 55 size_t items_updated() { return items_updated_; } |
56 | 56 |
57 void ResetCounts() { | 57 void ResetCounts() { |
58 status_changed_count_ = 0; | 58 status_changed_count_ = 0; |
(...skipping 12 matching lines...) Expand all Loading... |
71 }; | 71 }; |
72 | 72 |
73 } // namespace | 73 } // namespace |
74 | 74 |
75 class AppListModelTest : public testing::Test { | 75 class AppListModelTest : public testing::Test { |
76 public: | 76 public: |
77 AppListModelTest() {} | 77 AppListModelTest() {} |
78 virtual ~AppListModelTest() {} | 78 virtual ~AppListModelTest() {} |
79 | 79 |
80 // testing::Test overrides: | 80 // testing::Test overrides: |
81 virtual void SetUp() OVERRIDE { | 81 virtual void SetUp() override { |
82 model_.AddObserver(&observer_); | 82 model_.AddObserver(&observer_); |
83 } | 83 } |
84 virtual void TearDown() OVERRIDE { | 84 virtual void TearDown() override { |
85 model_.RemoveObserver(&observer_); | 85 model_.RemoveObserver(&observer_); |
86 } | 86 } |
87 | 87 |
88 protected: | 88 protected: |
89 bool ItemObservedByFolder(AppListFolderItem* folder, | 89 bool ItemObservedByFolder(AppListFolderItem* folder, |
90 AppListItem* item) { | 90 AppListItem* item) { |
91 return item->observers_.HasObserver(folder); | 91 return item->observers_.HasObserver(folder); |
92 } | 92 } |
93 | 93 |
94 std::string GetItemListContents(AppListItemList* item_list) { | 94 std::string GetItemListContents(AppListItemList* item_list) { |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 } | 230 } |
231 | 231 |
232 class AppListModelFolderTest : public AppListModelTest { | 232 class AppListModelFolderTest : public AppListModelTest { |
233 public: | 233 public: |
234 AppListModelFolderTest() { | 234 AppListModelFolderTest() { |
235 model_.SetFoldersEnabled(true); | 235 model_.SetFoldersEnabled(true); |
236 } | 236 } |
237 virtual ~AppListModelFolderTest() {} | 237 virtual ~AppListModelFolderTest() {} |
238 | 238 |
239 // testing::Test overrides: | 239 // testing::Test overrides: |
240 virtual void SetUp() OVERRIDE { | 240 virtual void SetUp() override { |
241 AppListModelTest::SetUp(); | 241 AppListModelTest::SetUp(); |
242 } | 242 } |
243 virtual void TearDown() OVERRIDE { | 243 virtual void TearDown() override { |
244 AppListModelTest::TearDown(); | 244 AppListModelTest::TearDown(); |
245 } | 245 } |
246 | 246 |
247 private: | 247 private: |
248 DISALLOW_COPY_AND_ASSIGN(AppListModelFolderTest); | 248 DISALLOW_COPY_AND_ASSIGN(AppListModelFolderTest); |
249 }; | 249 }; |
250 | 250 |
251 TEST_F(AppListModelFolderTest, FolderItem) { | 251 TEST_F(AppListModelFolderTest, FolderItem) { |
252 AppListFolderItem* folder = | 252 AppListFolderItem* folder = |
253 new AppListFolderItem("folder1", AppListFolderItem::FOLDER_TYPE_NORMAL); | 253 new AppListFolderItem("folder1", AppListFolderItem::FOLDER_TYPE_NORMAL); |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 model_.SetFoldersEnabled(false); | 515 model_.SetFoldersEnabled(false); |
516 ASSERT_FALSE(model_.FindFolderItem(folder_id)); | 516 ASSERT_FALSE(model_.FindFolderItem(folder_id)); |
517 ASSERT_TRUE(model_.FindFolderItem(oem_folder_id)); | 517 ASSERT_TRUE(model_.FindFolderItem(oem_folder_id)); |
518 EXPECT_EQ("Item 0,Item 1,oem_folder", GetModelContents()); | 518 EXPECT_EQ("Item 0,Item 1,oem_folder", GetModelContents()); |
519 | 519 |
520 // Ensure folder creation fails. | 520 // Ensure folder creation fails. |
521 EXPECT_EQ(std::string(), model_.MergeItems(item0->id(), item1->id())); | 521 EXPECT_EQ(std::string(), model_.MergeItems(item0->id(), item1->id())); |
522 } | 522 } |
523 | 523 |
524 } // namespace app_list | 524 } // namespace app_list |
OLD | NEW |