| 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 size_t items_updated_; | 61 size_t items_updated_; |
| 62 | 62 |
| 63 DISALLOW_COPY_AND_ASSIGN(TestObserver); | 63 DISALLOW_COPY_AND_ASSIGN(TestObserver); |
| 64 }; | 64 }; |
| 65 | 65 |
| 66 } // namespace | 66 } // namespace |
| 67 | 67 |
| 68 class AppListModelTest : public testing::Test { | 68 class AppListModelTest : public testing::Test { |
| 69 public: | 69 public: |
| 70 AppListModelTest() {} | 70 AppListModelTest() {} |
| 71 virtual ~AppListModelTest() {} | 71 ~AppListModelTest() override {} |
| 72 | 72 |
| 73 // testing::Test overrides: | 73 // testing::Test overrides: |
| 74 virtual void SetUp() override { | 74 void SetUp() override { model_.AddObserver(&observer_); } |
| 75 model_.AddObserver(&observer_); | 75 void TearDown() override { model_.RemoveObserver(&observer_); } |
| 76 } | |
| 77 virtual void TearDown() override { | |
| 78 model_.RemoveObserver(&observer_); | |
| 79 } | |
| 80 | 76 |
| 81 protected: | 77 protected: |
| 82 bool ItemObservedByFolder(AppListFolderItem* folder, | 78 bool ItemObservedByFolder(AppListFolderItem* folder, |
| 83 AppListItem* item) { | 79 AppListItem* item) { |
| 84 return item->observers_.HasObserver(folder); | 80 return item->observers_.HasObserver(folder); |
| 85 } | 81 } |
| 86 | 82 |
| 87 std::string GetItemListContents(AppListItemList* item_list) { | 83 std::string GetItemListContents(AppListItemList* item_list) { |
| 88 std::string s; | 84 std::string s; |
| 89 for (size_t i = 0; i < item_list->item_count(); ++i) { | 85 for (size_t i = 0; i < item_list->item_count(); ++i) { |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 model_.top_level_item_list()->item_at(i)->position().GreaterThan( | 216 model_.top_level_item_list()->item_at(i)->position().GreaterThan( |
| 221 model_.top_level_item_list()->item_at(i - 1)->position())); | 217 model_.top_level_item_list()->item_at(i - 1)->position())); |
| 222 } | 218 } |
| 223 } | 219 } |
| 224 | 220 |
| 225 class AppListModelFolderTest : public AppListModelTest { | 221 class AppListModelFolderTest : public AppListModelTest { |
| 226 public: | 222 public: |
| 227 AppListModelFolderTest() { | 223 AppListModelFolderTest() { |
| 228 model_.SetFoldersEnabled(true); | 224 model_.SetFoldersEnabled(true); |
| 229 } | 225 } |
| 230 virtual ~AppListModelFolderTest() {} | 226 ~AppListModelFolderTest() override {} |
| 231 | 227 |
| 232 // testing::Test overrides: | 228 // testing::Test overrides: |
| 233 virtual void SetUp() override { | 229 void SetUp() override { AppListModelTest::SetUp(); } |
| 234 AppListModelTest::SetUp(); | 230 void TearDown() override { AppListModelTest::TearDown(); } |
| 235 } | |
| 236 virtual void TearDown() override { | |
| 237 AppListModelTest::TearDown(); | |
| 238 } | |
| 239 | 231 |
| 240 private: | 232 private: |
| 241 DISALLOW_COPY_AND_ASSIGN(AppListModelFolderTest); | 233 DISALLOW_COPY_AND_ASSIGN(AppListModelFolderTest); |
| 242 }; | 234 }; |
| 243 | 235 |
| 244 TEST_F(AppListModelFolderTest, FolderItem) { | 236 TEST_F(AppListModelFolderTest, FolderItem) { |
| 245 AppListFolderItem* folder = | 237 AppListFolderItem* folder = |
| 246 new AppListFolderItem("folder1", AppListFolderItem::FOLDER_TYPE_NORMAL); | 238 new AppListFolderItem("folder1", AppListFolderItem::FOLDER_TYPE_NORMAL); |
| 247 const size_t num_folder_apps = 8; | 239 const size_t num_folder_apps = 8; |
| 248 const size_t num_observed_apps = 4; | 240 const size_t num_observed_apps = 4; |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 508 model_.SetFoldersEnabled(false); | 500 model_.SetFoldersEnabled(false); |
| 509 ASSERT_FALSE(model_.FindFolderItem(folder_id)); | 501 ASSERT_FALSE(model_.FindFolderItem(folder_id)); |
| 510 ASSERT_TRUE(model_.FindFolderItem(oem_folder_id)); | 502 ASSERT_TRUE(model_.FindFolderItem(oem_folder_id)); |
| 511 EXPECT_EQ("Item 0,Item 1,oem_folder", GetModelContents()); | 503 EXPECT_EQ("Item 0,Item 1,oem_folder", GetModelContents()); |
| 512 | 504 |
| 513 // Ensure folder creation fails. | 505 // Ensure folder creation fails. |
| 514 EXPECT_EQ(std::string(), model_.MergeItems(item0->id(), item1->id())); | 506 EXPECT_EQ(std::string(), model_.MergeItems(item0->id(), item1->id())); |
| 515 } | 507 } |
| 516 | 508 |
| 517 } // namespace app_list | 509 } // namespace app_list |
| OLD | NEW |