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

Side by Side Diff: chrome/browser/ui/app_list/arc/arc_app_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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <algorithm> 8 #include <algorithm>
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 // Validate that prefs and model have right content. 141 // Validate that prefs and model have right content.
142 void ValidateHaveApps(const std::vector<arc::AppInfo> apps) { 142 void ValidateHaveApps(const std::vector<arc::AppInfo> apps) {
143 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); 143 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get());
144 const std::vector<std::string> ids = prefs->GetAppIds(); 144 const std::vector<std::string> ids = prefs->GetAppIds();
145 ASSERT_EQ(apps.size(), ids.size()); 145 ASSERT_EQ(apps.size(), ids.size());
146 ASSERT_EQ(apps.size(), GetArcItemCount()); 146 ASSERT_EQ(apps.size(), GetArcItemCount());
147 // In principle, order of items is not defined. 147 // In principle, order of items is not defined.
148 for (auto& app : apps) { 148 for (auto& app : apps) {
149 const std::string id = ArcAppTest::GetAppId(app); 149 const std::string id = ArcAppTest::GetAppId(app);
150 EXPECT_NE(std::find(ids.begin(), ids.end(), id), ids.end()); 150 EXPECT_NE(std::find(ids.begin(), ids.end(), id), ids.end());
151 scoped_ptr<ArcAppListPrefs::AppInfo> app_info = prefs->GetApp(id); 151 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = prefs->GetApp(id);
152 ASSERT_NE(nullptr, app_info.get()); 152 ASSERT_NE(nullptr, app_info.get());
153 EXPECT_EQ(app.name, app_info->name); 153 EXPECT_EQ(app.name, app_info->name);
154 EXPECT_EQ(app.package_name, app_info->package_name); 154 EXPECT_EQ(app.package_name, app_info->package_name);
155 EXPECT_EQ(app.activity, app_info->activity); 155 EXPECT_EQ(app.activity, app_info->activity);
156 156
157 const ArcAppItem* app_item = FindArcItem(id); 157 const ArcAppItem* app_item = FindArcItem(id);
158 ASSERT_NE(nullptr, app_item); 158 ASSERT_NE(nullptr, app_item);
159 EXPECT_EQ(app.name, app_item->GetDisplayName()); 159 EXPECT_EQ(app.name, app_item->GetDisplayName());
160 } 160 }
161 } 161 }
162 162
163 // Validate that requested apps have required ready state and other apps have 163 // Validate that requested apps have required ready state and other apps have
164 // opposite state. 164 // opposite state.
165 void ValidateAppReadyState(const std::vector<arc::AppInfo> apps, bool ready) { 165 void ValidateAppReadyState(const std::vector<arc::AppInfo> apps, bool ready) {
166 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); 166 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get());
167 ASSERT_NE(nullptr, prefs); 167 ASSERT_NE(nullptr, prefs);
168 168
169 std::vector<std::string> ids = prefs->GetAppIds(); 169 std::vector<std::string> ids = prefs->GetAppIds();
170 EXPECT_EQ(ids.size(), GetArcItemCount()); 170 EXPECT_EQ(ids.size(), GetArcItemCount());
171 171
172 // Process requested apps. 172 // Process requested apps.
173 for (auto& app : apps) { 173 for (auto& app : apps) {
174 const std::string id = ArcAppTest::GetAppId(app); 174 const std::string id = ArcAppTest::GetAppId(app);
175 std::vector<std::string>::iterator it_id = std::find(ids.begin(), 175 std::vector<std::string>::iterator it_id = std::find(ids.begin(),
176 ids.end(), 176 ids.end(),
177 id); 177 id);
178 ASSERT_NE(it_id, ids.end()); 178 ASSERT_NE(it_id, ids.end());
179 ids.erase(it_id); 179 ids.erase(it_id);
180 180
181 scoped_ptr<ArcAppListPrefs::AppInfo> app_info = prefs->GetApp(id); 181 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = prefs->GetApp(id);
182 ASSERT_NE(nullptr, app_info.get()); 182 ASSERT_NE(nullptr, app_info.get());
183 EXPECT_EQ(ready, app_info->ready); 183 EXPECT_EQ(ready, app_info->ready);
184 const ArcAppItem* app_item = FindArcItem(id); 184 const ArcAppItem* app_item = FindArcItem(id);
185 ASSERT_NE(nullptr, app_item); 185 ASSERT_NE(nullptr, app_item);
186 EXPECT_EQ(ready, app_item->ready()); 186 EXPECT_EQ(ready, app_item->ready());
187 } 187 }
188 188
189 // Process the rest of the apps. 189 // Process the rest of the apps.
190 for (auto& id : ids) { 190 for (auto& id : ids) {
191 scoped_ptr<ArcAppListPrefs::AppInfo> app_info = prefs->GetApp(id); 191 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = prefs->GetApp(id);
192 ASSERT_NE(nullptr, app_info.get()); 192 ASSERT_NE(nullptr, app_info.get());
193 EXPECT_NE(ready, app_info->ready); 193 EXPECT_NE(ready, app_info->ready);
194 const ArcAppItem* app_item = FindArcItem(id); 194 const ArcAppItem* app_item = FindArcItem(id);
195 ASSERT_NE(nullptr, app_item); 195 ASSERT_NE(nullptr, app_item);
196 EXPECT_NE(ready, app_item->ready()); 196 EXPECT_NE(ready, app_item->ready());
197 } 197 }
198 } 198 }
199 199
200 // Validates that provided image is acceptable as Arc app icon. 200 // Validates that provided image is acceptable as Arc app icon.
201 void ValidateIcon(const gfx::ImageSkia& image) { 201 void ValidateIcon(const gfx::ImageSkia& image) {
(...skipping 25 matching lines...) Expand all
227 arc::FakeArcBridgeService* bridge_service() { 227 arc::FakeArcBridgeService* bridge_service() {
228 return arc_test_.bridge_service(); 228 return arc_test_.bridge_service();
229 } 229 }
230 230
231 arc::FakeAppInstance* app_instance() { 231 arc::FakeAppInstance* app_instance() {
232 return arc_test_.app_instance(); 232 return arc_test_.app_instance();
233 } 233 }
234 234
235 private: 235 private:
236 ArcAppTest arc_test_; 236 ArcAppTest arc_test_;
237 scoped_ptr<app_list::AppListModel> model_; 237 std::unique_ptr<app_list::AppListModel> model_;
238 scoped_ptr<test::TestAppListControllerDelegate> controller_; 238 std::unique_ptr<test::TestAppListControllerDelegate> controller_;
239 scoped_ptr<ArcAppModelBuilder> builder_; 239 std::unique_ptr<ArcAppModelBuilder> builder_;
240 240
241 DISALLOW_COPY_AND_ASSIGN(ArcAppModelBuilderTest); 241 DISALLOW_COPY_AND_ASSIGN(ArcAppModelBuilderTest);
242 }; 242 };
243 243
244 TEST_F(ArcAppModelBuilderTest, RefreshAllOnReady) { 244 TEST_F(ArcAppModelBuilderTest, RefreshAllOnReady) {
245 // There should already have been one call, when the interface was 245 // There should already have been one call, when the interface was
246 // registered. 246 // registered.
247 EXPECT_EQ(1, app_instance()->refresh_app_list_count()); 247 EXPECT_EQ(1, app_instance()->refresh_app_list_count());
248 bridge_service()->SetReady(); 248 bridge_service()->SetReady();
249 app_instance()->RefreshAppList(); 249 app_instance()->RefreshAppList();
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 app_instance()->SendRefreshAppList( 537 app_instance()->SendRefreshAppList(
538 std::vector<arc::AppInfo>(fake_apps().begin(), fake_apps().begin() + 2)); 538 std::vector<arc::AppInfo>(fake_apps().begin(), fake_apps().begin() + 2));
539 const arc::AppInfo& app1 = fake_apps()[0]; 539 const arc::AppInfo& app1 = fake_apps()[0];
540 const arc::AppInfo& app2 = fake_apps()[1]; 540 const arc::AppInfo& app2 = fake_apps()[1];
541 const std::string id1 = ArcAppTest::GetAppId(app1); 541 const std::string id1 = ArcAppTest::GetAppId(app1);
542 const std::string id2 = ArcAppTest::GetAppId(app2); 542 const std::string id2 = ArcAppTest::GetAppId(app2);
543 543
544 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); 544 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get());
545 ASSERT_NE(nullptr, prefs); 545 ASSERT_NE(nullptr, prefs);
546 546
547 scoped_ptr<ArcAppListPrefs::AppInfo> app_info = prefs->GetApp(id1); 547 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = prefs->GetApp(id1);
548 ASSERT_NE(nullptr, app_info.get()); 548 ASSERT_NE(nullptr, app_info.get());
549 549
550 EXPECT_EQ(base::Time(), app_info->last_launch_time); 550 EXPECT_EQ(base::Time(), app_info->last_launch_time);
551 551
552 // Test direct setting last launch time. 552 // Test direct setting last launch time.
553 base::Time now_time = base::Time::Now(); 553 base::Time now_time = base::Time::Now();
554 prefs->SetLastLaunchTime(id1, now_time); 554 prefs->SetLastLaunchTime(id1, now_time);
555 555
556 app_info = prefs->GetApp(id1); 556 app_info = prefs->GetApp(id1);
557 ASSERT_NE(nullptr, app_info.get()); 557 ASSERT_NE(nullptr, app_info.get());
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 609
610 // Allow one more circle to read and decode installed icons. 610 // Allow one more circle to read and decode installed icons.
611 content::BrowserThread::GetBlockingPool()->FlushForTesting(); 611 content::BrowserThread::GetBlockingPool()->FlushForTesting();
612 base::RunLoop().RunUntilIdle(); 612 base::RunLoop().RunUntilIdle();
613 613
614 // Validate loaded image. 614 // Validate loaded image.
615 EXPECT_EQ(1 + scale_factors.size(), delegate.update_image_cnt()); 615 EXPECT_EQ(1 + scale_factors.size(), delegate.update_image_cnt());
616 EXPECT_EQ(app_id, delegate.app_id()); 616 EXPECT_EQ(app_id, delegate.app_id());
617 ValidateIcon(delegate.image()); 617 ValidateIcon(delegate.image());
618 } 618 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/app_list/arc/arc_app_test.h ('k') | chrome/browser/ui/app_list/arc/arc_app_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698