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

Unified Diff: chrome/browser/ui/app_list/model_pref_updater_unittest.cc

Issue 2430753002: Discard unused AppListPrefs code. (Closed)
Patch Set: update Created 4 years, 2 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/app_list/model_pref_updater.cc ('k') | chrome/test/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/app_list/model_pref_updater_unittest.cc
diff --git a/chrome/browser/ui/app_list/model_pref_updater_unittest.cc b/chrome/browser/ui/app_list/model_pref_updater_unittest.cc
deleted file mode 100644
index a5c4c768a898fa360ce4d094ef8d72d9083a1cbe..0000000000000000000000000000000000000000
--- a/chrome/browser/ui/app_list/model_pref_updater_unittest.cc
+++ /dev/null
@@ -1,105 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ui/app_list/model_pref_updater.h"
-
-#include <memory>
-
-#include "base/macros.h"
-#include "chrome/browser/ui/app_list/app_list_prefs.h"
-#include "chrome/browser/ui/app_list/extension_app_item.h"
-#include "components/pref_registry/testing_pref_service_syncable.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "ui/app_list/app_list_folder_item.h"
-#include "ui/app_list/app_list_item.h"
-#include "ui/app_list/test/app_list_test_model.h"
-
-namespace app_list {
-namespace test {
-
-class TestExtensionAppItem : public AppListItem {
- public:
- explicit TestExtensionAppItem(const std::string& id) : AppListItem(id) {}
- ~TestExtensionAppItem() override {}
-
- const char* GetItemType() const override {
- return ExtensionAppItem::kItemType;
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(TestExtensionAppItem);
-};
-
-class ModelPrefUpdaterTest : public testing::Test {
- public:
- ModelPrefUpdaterTest() {}
- ~ModelPrefUpdaterTest() override {}
-
- void SetUp() override {
- AppListPrefs::RegisterProfilePrefs(pref_service_.registry());
- prefs_.reset(AppListPrefs::Create(&pref_service_));
- model_.reset(new AppListTestModel());
- pref_updater_.reset(new ModelPrefUpdater(prefs_.get(), model_.get()));
- }
-
- AppListTestModel* model() { return model_.get(); }
-
- AppListPrefs* prefs() { return prefs_.get(); }
-
- bool AppListItemMatchesPrefs(AppListItem* item) {
- std::unique_ptr<AppListPrefs::AppListInfo> info =
- prefs_->GetAppListInfo(item->id());
- AppListPrefs::AppListInfo::ItemType expected_type =
- AppListPrefs::AppListInfo::ITEM_TYPE_INVALID;
- if (item->GetItemType() == ExtensionAppItem::kItemType)
- expected_type = AppListPrefs::AppListInfo::APP_ITEM;
- else if (item->GetItemType() == AppListFolderItem::kItemType)
- expected_type = AppListPrefs::AppListInfo::FOLDER_ITEM;
-
- return info && info->position.Equals(item->position()) &&
- info->name == item->name() && info->parent_id == item->folder_id() &&
- info->item_type == expected_type;
- }
-
- private:
- user_prefs::TestingPrefServiceSyncable pref_service_;
- std::unique_ptr<AppListTestModel> model_;
- std::unique_ptr<AppListPrefs> prefs_;
- std::unique_ptr<ModelPrefUpdater> pref_updater_;
-
- DISALLOW_COPY_AND_ASSIGN(ModelPrefUpdaterTest);
-};
-
-TEST_F(ModelPrefUpdaterTest, ModelChange) {
- AppListPrefs::AppListInfoMap infos;
- prefs()->GetAllAppListInfos(&infos);
- EXPECT_EQ(0u, infos.size());
-
- AppListFolderItem* folder =
- new AppListFolderItem("folder1", AppListFolderItem::FOLDER_TYPE_NORMAL);
- model()->AddItem(folder);
-
- prefs()->GetAllAppListInfos(&infos);
- EXPECT_EQ(1u, infos.size());
- EXPECT_TRUE(AppListItemMatchesPrefs(folder));
-
- AppListItem* item = new TestExtensionAppItem("Item 0");
- model()->AddItem(item);
-
- prefs()->GetAllAppListInfos(&infos);
- EXPECT_EQ(2u, infos.size());
- EXPECT_TRUE(AppListItemMatchesPrefs(folder));
- EXPECT_TRUE(AppListItemMatchesPrefs(item));
-
- model()->MoveItemToFolder(item, folder->id());
- EXPECT_EQ(folder->id(), item->folder_id());
-
- prefs()->GetAllAppListInfos(&infos);
- EXPECT_EQ(2u, infos.size());
- EXPECT_TRUE(AppListItemMatchesPrefs(folder));
- EXPECT_TRUE(AppListItemMatchesPrefs(item));
-}
-
-} // namespace test
-} // namespace app_list
« no previous file with comments | « chrome/browser/ui/app_list/model_pref_updater.cc ('k') | chrome/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698