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

Side by Side Diff: chrome/browser/ui/app_list/model_pref_updater_unittest.cc

Issue 1865213004: Convert //chrome/browser/ui from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/ui/app_list/model_pref_updater.h"
6
7 #include <memory>
8
5 #include "base/macros.h" 9 #include "base/macros.h"
6 #include "base/memory/scoped_ptr.h"
7 #include "chrome/browser/ui/app_list/app_list_prefs.h" 10 #include "chrome/browser/ui/app_list/app_list_prefs.h"
8 #include "chrome/browser/ui/app_list/extension_app_item.h" 11 #include "chrome/browser/ui/app_list/extension_app_item.h"
9 #include "chrome/browser/ui/app_list/model_pref_updater.h"
10 #include "components/pref_registry/testing_pref_service_syncable.h" 12 #include "components/pref_registry/testing_pref_service_syncable.h"
11 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
12 #include "ui/app_list/app_list_folder_item.h" 14 #include "ui/app_list/app_list_folder_item.h"
13 #include "ui/app_list/app_list_item.h" 15 #include "ui/app_list/app_list_item.h"
14 #include "ui/app_list/test/app_list_test_model.h" 16 #include "ui/app_list/test/app_list_test_model.h"
15 17
16 namespace app_list { 18 namespace app_list {
17 namespace test { 19 namespace test {
18 20
19 class TestExtensionAppItem : public AppListItem { 21 class TestExtensionAppItem : public AppListItem {
(...skipping 19 matching lines...) Expand all
39 prefs_.reset(AppListPrefs::Create(&pref_service_)); 41 prefs_.reset(AppListPrefs::Create(&pref_service_));
40 model_.reset(new AppListTestModel()); 42 model_.reset(new AppListTestModel());
41 pref_updater_.reset(new ModelPrefUpdater(prefs_.get(), model_.get())); 43 pref_updater_.reset(new ModelPrefUpdater(prefs_.get(), model_.get()));
42 } 44 }
43 45
44 AppListTestModel* model() { return model_.get(); } 46 AppListTestModel* model() { return model_.get(); }
45 47
46 AppListPrefs* prefs() { return prefs_.get(); } 48 AppListPrefs* prefs() { return prefs_.get(); }
47 49
48 bool AppListItemMatchesPrefs(AppListItem* item) { 50 bool AppListItemMatchesPrefs(AppListItem* item) {
49 scoped_ptr<AppListPrefs::AppListInfo> info = 51 std::unique_ptr<AppListPrefs::AppListInfo> info =
50 prefs_->GetAppListInfo(item->id()); 52 prefs_->GetAppListInfo(item->id());
51 AppListPrefs::AppListInfo::ItemType expected_type = 53 AppListPrefs::AppListInfo::ItemType expected_type =
52 AppListPrefs::AppListInfo::ITEM_TYPE_INVALID; 54 AppListPrefs::AppListInfo::ITEM_TYPE_INVALID;
53 if (item->GetItemType() == ExtensionAppItem::kItemType) 55 if (item->GetItemType() == ExtensionAppItem::kItemType)
54 expected_type = AppListPrefs::AppListInfo::APP_ITEM; 56 expected_type = AppListPrefs::AppListInfo::APP_ITEM;
55 else if (item->GetItemType() == AppListFolderItem::kItemType) 57 else if (item->GetItemType() == AppListFolderItem::kItemType)
56 expected_type = AppListPrefs::AppListInfo::FOLDER_ITEM; 58 expected_type = AppListPrefs::AppListInfo::FOLDER_ITEM;
57 59
58 return info && info->position.Equals(item->position()) && 60 return info && info->position.Equals(item->position()) &&
59 info->name == item->name() && info->parent_id == item->folder_id() && 61 info->name == item->name() && info->parent_id == item->folder_id() &&
60 info->item_type == expected_type; 62 info->item_type == expected_type;
61 } 63 }
62 64
63 private: 65 private:
64 user_prefs::TestingPrefServiceSyncable pref_service_; 66 user_prefs::TestingPrefServiceSyncable pref_service_;
65 scoped_ptr<AppListTestModel> model_; 67 std::unique_ptr<AppListTestModel> model_;
66 scoped_ptr<AppListPrefs> prefs_; 68 std::unique_ptr<AppListPrefs> prefs_;
67 scoped_ptr<ModelPrefUpdater> pref_updater_; 69 std::unique_ptr<ModelPrefUpdater> pref_updater_;
68 70
69 DISALLOW_COPY_AND_ASSIGN(ModelPrefUpdaterTest); 71 DISALLOW_COPY_AND_ASSIGN(ModelPrefUpdaterTest);
70 }; 72 };
71 73
72 TEST_F(ModelPrefUpdaterTest, ModelChange) { 74 TEST_F(ModelPrefUpdaterTest, ModelChange) {
73 AppListPrefs::AppListInfoMap infos; 75 AppListPrefs::AppListInfoMap infos;
74 prefs()->GetAllAppListInfos(&infos); 76 prefs()->GetAllAppListInfos(&infos);
75 EXPECT_EQ(0u, infos.size()); 77 EXPECT_EQ(0u, infos.size());
76 78
77 AppListFolderItem* folder = 79 AppListFolderItem* folder =
(...skipping 16 matching lines...) Expand all
94 EXPECT_EQ(folder->id(), item->folder_id()); 96 EXPECT_EQ(folder->id(), item->folder_id());
95 97
96 prefs()->GetAllAppListInfos(&infos); 98 prefs()->GetAllAppListInfos(&infos);
97 EXPECT_EQ(2u, infos.size()); 99 EXPECT_EQ(2u, infos.size());
98 EXPECT_TRUE(AppListItemMatchesPrefs(folder)); 100 EXPECT_TRUE(AppListItemMatchesPrefs(folder));
99 EXPECT_TRUE(AppListItemMatchesPrefs(item)); 101 EXPECT_TRUE(AppListItemMatchesPrefs(item));
100 } 102 }
101 103
102 } // namespace test 104 } // namespace test
103 } // namespace app_list 105 } // namespace app_list
OLDNEW
« no previous file with comments | « chrome/browser/ui/app_list/launcher_page_event_dispatcher.cc ('k') | chrome/browser/ui/app_list/profile_loader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698