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

Side by Side Diff: chrome/browser/ui/app_list/arc/arc_app_unittest.cc

Issue 1885683005: Add module suffix in .mojom files for components/arc (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase only 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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 const size_t count = GetArcItemCount(); 132 const size_t count = GetArcItemCount();
133 for (size_t i = 0; i < count; ++i) { 133 for (size_t i = 0; i < count; ++i) {
134 ArcAppItem* item = GetArcItem(i); 134 ArcAppItem* item = GetArcItem(i);
135 if (item && item->id() == id) 135 if (item && item->id() == id)
136 return item; 136 return item;
137 } 137 }
138 return nullptr; 138 return nullptr;
139 } 139 }
140 140
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::mojom::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 std::unique_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::mojom::AppInfo> apps,
166 bool ready) {
166 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); 167 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get());
167 ASSERT_NE(nullptr, prefs); 168 ASSERT_NE(nullptr, prefs);
168 169
169 std::vector<std::string> ids = prefs->GetAppIds(); 170 std::vector<std::string> ids = prefs->GetAppIds();
170 EXPECT_EQ(ids.size(), GetArcItemCount()); 171 EXPECT_EQ(ids.size(), GetArcItemCount());
171 172
172 // Process requested apps. 173 // Process requested apps.
173 for (auto& app : apps) { 174 for (auto& app : apps) {
174 const std::string id = ArcAppTest::GetAppId(app); 175 const std::string id = ArcAppTest::GetAppId(app);
175 std::vector<std::string>::iterator it_id = std::find(ids.begin(), 176 std::vector<std::string>::iterator it_id = std::find(ids.begin(),
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 representation.pixel_width()); 214 representation.pixel_width());
214 EXPECT_EQ(gfx::ToCeiledInt(app_list::kGridIconDimension * scale), 215 EXPECT_EQ(gfx::ToCeiledInt(app_list::kGridIconDimension * scale),
215 representation.pixel_height()); 216 representation.pixel_height());
216 } 217 }
217 } 218 }
218 219
219 AppListControllerDelegate* controller() { return controller_.get(); } 220 AppListControllerDelegate* controller() { return controller_.get(); }
220 221
221 Profile* profile() { return profile_.get(); } 222 Profile* profile() { return profile_.get(); }
222 223
223 const std::vector<arc::AppInfo>& fake_apps() const { 224 const std::vector<arc::mojom::AppInfo>& fake_apps() const {
224 return arc_test_.fake_apps(); 225 return arc_test_.fake_apps();
225 } 226 }
226 227
227 arc::FakeArcBridgeService* bridge_service() { 228 arc::FakeArcBridgeService* bridge_service() {
228 return arc_test_.bridge_service(); 229 return arc_test_.bridge_service();
229 } 230 }
230 231
231 arc::FakeAppInstance* app_instance() { 232 arc::FakeAppInstance* app_instance() {
232 return arc_test_.app_instance(); 233 return arc_test_.app_instance();
233 } 234 }
(...skipping 10 matching lines...) Expand all
244 TEST_F(ArcAppModelBuilderTest, RefreshAllOnReady) { 245 TEST_F(ArcAppModelBuilderTest, RefreshAllOnReady) {
245 // There should already have been one call, when the interface was 246 // There should already have been one call, when the interface was
246 // registered. 247 // registered.
247 EXPECT_EQ(1, app_instance()->refresh_app_list_count()); 248 EXPECT_EQ(1, app_instance()->refresh_app_list_count());
248 bridge_service()->SetReady(); 249 bridge_service()->SetReady();
249 app_instance()->RefreshAppList(); 250 app_instance()->RefreshAppList();
250 EXPECT_EQ(2, app_instance()->refresh_app_list_count()); 251 EXPECT_EQ(2, app_instance()->refresh_app_list_count());
251 } 252 }
252 253
253 TEST_F(ArcAppModelBuilderTest, RefreshAllFillsContent) { 254 TEST_F(ArcAppModelBuilderTest, RefreshAllFillsContent) {
254 ValidateHaveApps(std::vector<arc::AppInfo>()); 255 ValidateHaveApps(std::vector<arc::mojom::AppInfo>());
255 bridge_service()->SetReady(); 256 bridge_service()->SetReady();
256 app_instance()->RefreshAppList(); 257 app_instance()->RefreshAppList();
257 app_instance()->SendRefreshAppList(fake_apps()); 258 app_instance()->SendRefreshAppList(fake_apps());
258 ValidateHaveApps(fake_apps()); 259 ValidateHaveApps(fake_apps());
259 } 260 }
260 261
261 TEST_F(ArcAppModelBuilderTest, MultipleRefreshAll) { 262 TEST_F(ArcAppModelBuilderTest, MultipleRefreshAll) {
262 ValidateHaveApps(std::vector<arc::AppInfo>()); 263 ValidateHaveApps(std::vector<arc::mojom::AppInfo>());
263 bridge_service()->SetReady(); 264 bridge_service()->SetReady();
264 app_instance()->RefreshAppList(); 265 app_instance()->RefreshAppList();
265 // Send info about all fake apps except last. 266 // Send info about all fake apps except last.
266 std::vector<arc::AppInfo> apps1(fake_apps().begin(), fake_apps().end() - 1); 267 std::vector<arc::mojom::AppInfo> apps1(fake_apps().begin(),
268 fake_apps().end() - 1);
267 app_instance()->SendRefreshAppList(apps1); 269 app_instance()->SendRefreshAppList(apps1);
268 // At this point all apps (except last) should exist and be ready. 270 // At this point all apps (except last) should exist and be ready.
269 ValidateHaveApps(apps1); 271 ValidateHaveApps(apps1);
270 ValidateAppReadyState(apps1, true); 272 ValidateAppReadyState(apps1, true);
271 273
272 // Send info about all fake apps except first. 274 // Send info about all fake apps except first.
273 std::vector<arc::AppInfo> apps2(fake_apps().begin() + 1, fake_apps().end()); 275 std::vector<arc::mojom::AppInfo> apps2(fake_apps().begin() + 1,
276 fake_apps().end());
274 app_instance()->SendRefreshAppList(apps2); 277 app_instance()->SendRefreshAppList(apps2);
275 // At this point all apps should exist but first one should be non-ready. 278 // At this point all apps should exist but first one should be non-ready.
276 ValidateHaveApps(apps2); 279 ValidateHaveApps(apps2);
277 ValidateAppReadyState(apps2, true); 280 ValidateAppReadyState(apps2, true);
278 281
279 // Send info about all fake apps. 282 // Send info about all fake apps.
280 app_instance()->SendRefreshAppList(fake_apps()); 283 app_instance()->SendRefreshAppList(fake_apps());
281 // At this point all apps should exist and be ready. 284 // At this point all apps should exist and be ready.
282 ValidateHaveApps(fake_apps()); 285 ValidateHaveApps(fake_apps());
283 ValidateAppReadyState(fake_apps(), true); 286 ValidateAppReadyState(fake_apps(), true);
284 287
285 // Send info no app available. 288 // Send info no app available.
286 std::vector<arc::AppInfo> no_apps; 289 std::vector<arc::mojom::AppInfo> no_apps;
287 app_instance()->SendRefreshAppList(no_apps); 290 app_instance()->SendRefreshAppList(no_apps);
288 // At this point no app should exist. 291 // At this point no app should exist.
289 ValidateHaveApps(no_apps); 292 ValidateHaveApps(no_apps);
290 } 293 }
291 294
292 TEST_F(ArcAppModelBuilderTest, StopStartServicePreserveApps) { 295 TEST_F(ArcAppModelBuilderTest, StopStartServicePreserveApps) {
293 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); 296 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get());
294 ASSERT_NE(nullptr, prefs); 297 ASSERT_NE(nullptr, prefs);
295 298
296 bridge_service()->SetReady(); 299 bridge_service()->SetReady();
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 344
342 TEST_F(ArcAppModelBuilderTest, LaunchApps) { 345 TEST_F(ArcAppModelBuilderTest, LaunchApps) {
343 // Disable attempts to dismiss app launcher view. 346 // Disable attempts to dismiss app launcher view.
344 ChromeAppListItem::OverrideAppListControllerDelegateForTesting(controller()); 347 ChromeAppListItem::OverrideAppListControllerDelegateForTesting(controller());
345 348
346 bridge_service()->SetReady(); 349 bridge_service()->SetReady();
347 app_instance()->RefreshAppList(); 350 app_instance()->RefreshAppList();
348 app_instance()->SendRefreshAppList(fake_apps()); 351 app_instance()->SendRefreshAppList(fake_apps());
349 352
350 // Simulate item activate. 353 // Simulate item activate.
351 const arc::AppInfo& app_first = fake_apps()[0]; 354 const arc::mojom::AppInfo& app_first = fake_apps()[0];
352 const arc::AppInfo& app_last = fake_apps()[0]; 355 const arc::mojom::AppInfo& app_last = fake_apps()[0];
353 ArcAppItem* item_first = FindArcItem(ArcAppTest::GetAppId(app_first)); 356 ArcAppItem* item_first = FindArcItem(ArcAppTest::GetAppId(app_first));
354 ArcAppItem* item_last = FindArcItem(ArcAppTest::GetAppId(app_last)); 357 ArcAppItem* item_last = FindArcItem(ArcAppTest::GetAppId(app_last));
355 ASSERT_NE(nullptr, item_first); 358 ASSERT_NE(nullptr, item_first);
356 ASSERT_NE(nullptr, item_last); 359 ASSERT_NE(nullptr, item_last);
357 item_first->Activate(0); 360 item_first->Activate(0);
358 app_instance()->WaitForIncomingMethodCall(); 361 app_instance()->WaitForIncomingMethodCall();
359 item_last->Activate(0); 362 item_last->Activate(0);
360 app_instance()->WaitForIncomingMethodCall(); 363 app_instance()->WaitForIncomingMethodCall();
361 item_first->Activate(0); 364 item_first->Activate(0);
362 app_instance()->WaitForIncomingMethodCall(); 365 app_instance()->WaitForIncomingMethodCall();
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 EXPECT_EQ(app_masks[id], expected_mask); 441 EXPECT_EQ(app_masks[id], expected_mask);
439 } 442 }
440 } 443 }
441 444
442 TEST_F(ArcAppModelBuilderTest, InstallIcon) { 445 TEST_F(ArcAppModelBuilderTest, InstallIcon) {
443 // Make sure we are on UI thread. 446 // Make sure we are on UI thread.
444 ASSERT_TRUE(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 447 ASSERT_TRUE(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
445 448
446 bridge_service()->SetReady(); 449 bridge_service()->SetReady();
447 app_instance()->RefreshAppList(); 450 app_instance()->RefreshAppList();
448 app_instance()->SendRefreshAppList( 451 app_instance()->SendRefreshAppList(std::vector<arc::mojom::AppInfo>(
449 std::vector<arc::AppInfo>(fake_apps().begin(), fake_apps().begin() + 1)); 452 fake_apps().begin(), fake_apps().begin() + 1));
450 const arc::AppInfo& app = fake_apps()[0]; 453 const arc::mojom::AppInfo& app = fake_apps()[0];
451 454
452 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); 455 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get());
453 ASSERT_NE(nullptr, prefs); 456 ASSERT_NE(nullptr, prefs);
454 457
455 const ui::ScaleFactor scale_factor = ui::GetSupportedScaleFactors()[0]; 458 const ui::ScaleFactor scale_factor = ui::GetSupportedScaleFactors()[0];
456 const float scale = ui::GetScaleForScaleFactor(scale_factor); 459 const float scale = ui::GetScaleForScaleFactor(scale_factor);
457 const base::FilePath icon_path = prefs->GetIconPath(ArcAppTest::GetAppId(app), 460 const base::FilePath icon_path = prefs->GetIconPath(ArcAppTest::GetAppId(app),
458 scale_factor); 461 scale_factor);
459 EXPECT_EQ(true, !base::PathExists(icon_path)); 462 EXPECT_EQ(true, !base::PathExists(icon_path));
460 463
461 const ArcAppItem* app_item = FindArcItem(ArcAppTest::GetAppId(app)); 464 const ArcAppItem* app_item = FindArcItem(ArcAppTest::GetAppId(app));
462 EXPECT_NE(nullptr, app_item); 465 EXPECT_NE(nullptr, app_item);
463 // This initiates async loading. 466 // This initiates async loading.
464 app_item->icon().GetRepresentation(scale); 467 app_item->icon().GetRepresentation(scale);
465 468
466 // Process pending tasks. 469 // Process pending tasks.
467 content::BrowserThread::GetBlockingPool()->FlushForTesting(); 470 content::BrowserThread::GetBlockingPool()->FlushForTesting();
468 base::RunLoop().RunUntilIdle(); 471 base::RunLoop().RunUntilIdle();
469 472
470 // Validating decoded content does not fit well for unit tests. 473 // Validating decoded content does not fit well for unit tests.
471 ArcAppIcon::DisableSafeDecodingForTesting(); 474 ArcAppIcon::DisableSafeDecodingForTesting();
472 475
473 // Now send generated icon for the app. 476 // Now send generated icon for the app.
474 std::string png_data; 477 std::string png_data;
475 EXPECT_EQ(true, 478 EXPECT_EQ(true, app_instance()->GenerateAndSendIcon(
476 app_instance()->GenerateAndSendIcon( 479 app, static_cast<arc::mojom::ScaleFactor>(scale_factor),
477 app, static_cast<arc::ScaleFactor>(scale_factor), &png_data)); 480 &png_data));
478 481
479 // Process pending tasks. 482 // Process pending tasks.
480 content::BrowserThread::GetBlockingPool()->FlushForTesting(); 483 content::BrowserThread::GetBlockingPool()->FlushForTesting();
481 base::RunLoop().RunUntilIdle(); 484 base::RunLoop().RunUntilIdle();
482 485
483 // Validate that icons are installed, have right content and icon is 486 // Validate that icons are installed, have right content and icon is
484 // refreshed for ARC app item. 487 // refreshed for ARC app item.
485 EXPECT_EQ(true, base::PathExists(icon_path)); 488 EXPECT_EQ(true, base::PathExists(icon_path));
486 489
487 std::string icon_data; 490 std::string icon_data;
488 // Read the file from disk and compare with reference data. 491 // Read the file from disk and compare with reference data.
489 EXPECT_EQ(true, base::ReadFileToString(icon_path, &icon_data)); 492 EXPECT_EQ(true, base::ReadFileToString(icon_path, &icon_data));
490 ASSERT_EQ(icon_data, png_data); 493 ASSERT_EQ(icon_data, png_data);
491 } 494 }
492 495
493 TEST_F(ArcAppModelBuilderTest, RemoveAppCleanUpFolder) { 496 TEST_F(ArcAppModelBuilderTest, RemoveAppCleanUpFolder) {
494 // Make sure we are on UI thread. 497 // Make sure we are on UI thread.
495 ASSERT_TRUE(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 498 ASSERT_TRUE(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
496 499
497 bridge_service()->SetReady(); 500 bridge_service()->SetReady();
498 app_instance()->RefreshAppList(); 501 app_instance()->RefreshAppList();
499 app_instance()->SendRefreshAppList( 502 app_instance()->SendRefreshAppList(std::vector<arc::mojom::AppInfo>(
500 std::vector<arc::AppInfo>(fake_apps().begin(), fake_apps().begin() + 1)); 503 fake_apps().begin(), fake_apps().begin() + 1));
501 const arc::AppInfo& app = fake_apps()[0]; 504 const arc::mojom::AppInfo& app = fake_apps()[0];
502 505
503 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); 506 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get());
504 ASSERT_NE(nullptr, prefs); 507 ASSERT_NE(nullptr, prefs);
505 508
506 const std::string app_id = ArcAppTest::GetAppId(app); 509 const std::string app_id = ArcAppTest::GetAppId(app);
507 const base::FilePath app_path = prefs->GetAppPath(app_id); 510 const base::FilePath app_path = prefs->GetAppPath(app_id);
508 const ui::ScaleFactor scale_factor = ui::GetSupportedScaleFactors()[0]; 511 const ui::ScaleFactor scale_factor = ui::GetSupportedScaleFactors()[0];
509 512
510 // No app folder by default. 513 // No app folder by default.
511 EXPECT_EQ(true, !base::PathExists(app_path)); 514 EXPECT_EQ(true, !base::PathExists(app_path));
512 515
513 // Request icon, this will create app folder. 516 // Request icon, this will create app folder.
514 prefs->RequestIcon(app_id, scale_factor); 517 prefs->RequestIcon(app_id, scale_factor);
515 // Now send generated icon for the app. 518 // Now send generated icon for the app.
516 std::string png_data; 519 std::string png_data;
517 EXPECT_EQ(true, 520 EXPECT_EQ(true, app_instance()->GenerateAndSendIcon(
518 app_instance()->GenerateAndSendIcon( 521 app, static_cast<arc::mojom::ScaleFactor>(scale_factor),
519 app, static_cast<arc::ScaleFactor>(scale_factor), &png_data)); 522 &png_data));
520 content::BrowserThread::GetBlockingPool()->FlushForTesting(); 523 content::BrowserThread::GetBlockingPool()->FlushForTesting();
521 base::RunLoop().RunUntilIdle(); 524 base::RunLoop().RunUntilIdle();
522 EXPECT_EQ(true, base::PathExists(app_path)); 525 EXPECT_EQ(true, base::PathExists(app_path));
523 526
524 // Send empty app list. This will delete app and its folder. 527 // Send empty app list. This will delete app and its folder.
525 app_instance()->SendRefreshAppList(std::vector<arc::AppInfo>()); 528 app_instance()->SendRefreshAppList(std::vector<arc::mojom::AppInfo>());
526 content::BrowserThread::GetBlockingPool()->FlushForTesting(); 529 content::BrowserThread::GetBlockingPool()->FlushForTesting();
527 base::RunLoop().RunUntilIdle(); 530 base::RunLoop().RunUntilIdle();
528 EXPECT_EQ(true, !base::PathExists(app_path)); 531 EXPECT_EQ(true, !base::PathExists(app_path));
529 } 532 }
530 533
531 TEST_F(ArcAppModelBuilderTest, LastLaunchTime) { 534 TEST_F(ArcAppModelBuilderTest, LastLaunchTime) {
532 // Make sure we are on UI thread. 535 // Make sure we are on UI thread.
533 ASSERT_TRUE(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 536 ASSERT_TRUE(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
534 537
535 bridge_service()->SetReady(); 538 bridge_service()->SetReady();
536 app_instance()->RefreshAppList(); 539 app_instance()->RefreshAppList();
537 app_instance()->SendRefreshAppList( 540 app_instance()->SendRefreshAppList(std::vector<arc::mojom::AppInfo>(
538 std::vector<arc::AppInfo>(fake_apps().begin(), fake_apps().begin() + 2)); 541 fake_apps().begin(), fake_apps().begin() + 2));
539 const arc::AppInfo& app1 = fake_apps()[0]; 542 const arc::mojom::AppInfo& app1 = fake_apps()[0];
540 const arc::AppInfo& app2 = fake_apps()[1]; 543 const arc::mojom::AppInfo& app2 = fake_apps()[1];
541 const std::string id1 = ArcAppTest::GetAppId(app1); 544 const std::string id1 = ArcAppTest::GetAppId(app1);
542 const std::string id2 = ArcAppTest::GetAppId(app2); 545 const std::string id2 = ArcAppTest::GetAppId(app2);
543 546
544 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); 547 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get());
545 ASSERT_NE(nullptr, prefs); 548 ASSERT_NE(nullptr, prefs);
546 549
547 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = prefs->GetApp(id1); 550 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = prefs->GetApp(id1);
548 ASSERT_NE(nullptr, app_info.get()); 551 ASSERT_NE(nullptr, app_info.get());
549 552
550 EXPECT_EQ(base::Time(), app_info->last_launch_time); 553 EXPECT_EQ(base::Time(), app_info->last_launch_time);
(...skipping 18 matching lines...) Expand all
569 app_info = prefs->GetApp(id2); 572 app_info = prefs->GetApp(id2);
570 ASSERT_NE(nullptr, app_info.get()); 573 ASSERT_NE(nullptr, app_info.get());
571 ASSERT_LE(time_before, app_info->last_launch_time); 574 ASSERT_LE(time_before, app_info->last_launch_time);
572 ASSERT_GE(time_after, app_info->last_launch_time); 575 ASSERT_GE(time_after, app_info->last_launch_time);
573 } 576 }
574 577
575 TEST_F(ArcAppModelBuilderTest, IconLoader) { 578 TEST_F(ArcAppModelBuilderTest, IconLoader) {
576 // Validating decoded content does not fit well for unit tests. 579 // Validating decoded content does not fit well for unit tests.
577 ArcAppIcon::DisableSafeDecodingForTesting(); 580 ArcAppIcon::DisableSafeDecodingForTesting();
578 581
579 const arc::AppInfo& app = fake_apps()[0]; 582 const arc::mojom::AppInfo& app = fake_apps()[0];
580 const std::string app_id = ArcAppTest::GetAppId(app); 583 const std::string app_id = ArcAppTest::GetAppId(app);
581 584
582 bridge_service()->SetReady(); 585 bridge_service()->SetReady();
583 app_instance()->RefreshAppList(); 586 app_instance()->RefreshAppList();
584 app_instance()->SendRefreshAppList( 587 app_instance()->SendRefreshAppList(std::vector<arc::mojom::AppInfo>(
585 std::vector<arc::AppInfo>(fake_apps().begin(), fake_apps().begin() + 1)); 588 fake_apps().begin(), fake_apps().begin() + 1));
586 589
587 FakeAppIconLoaderDelegate delegate; 590 FakeAppIconLoaderDelegate delegate;
588 ArcAppIconLoader icon_loader(profile(), app_list::kListIconSize, &delegate); 591 ArcAppIconLoader icon_loader(profile(), app_list::kListIconSize, &delegate);
589 EXPECT_EQ(0UL, delegate.update_image_cnt()); 592 EXPECT_EQ(0UL, delegate.update_image_cnt());
590 icon_loader.FetchImage(app_id); 593 icon_loader.FetchImage(app_id);
591 EXPECT_EQ(1UL, delegate.update_image_cnt()); 594 EXPECT_EQ(1UL, delegate.update_image_cnt());
592 EXPECT_EQ(app_id, delegate.app_id()); 595 EXPECT_EQ(app_id, delegate.app_id());
593 596
594 // Validate default image. 597 // Validate default image.
595 ValidateIcon(delegate.image()); 598 ValidateIcon(delegate.image());
596 599
597 const std::vector<ui::ScaleFactor>& scale_factors = 600 const std::vector<ui::ScaleFactor>& scale_factors =
598 ui::GetSupportedScaleFactors(); 601 ui::GetSupportedScaleFactors();
599 for (auto& scale_factor : scale_factors) { 602 for (auto& scale_factor : scale_factors) {
600 std::string png_data; 603 std::string png_data;
601 EXPECT_TRUE(app_instance()->GenerateAndSendIcon( 604 EXPECT_TRUE(app_instance()->GenerateAndSendIcon(
602 app, static_cast<arc::ScaleFactor>(scale_factor), 605 app, static_cast<arc::mojom::ScaleFactor>(scale_factor), &png_data));
603 &png_data));
604 } 606 }
605 607
606 // Process pending tasks, this installs icons. 608 // Process pending tasks, this installs icons.
607 content::BrowserThread::GetBlockingPool()->FlushForTesting(); 609 content::BrowserThread::GetBlockingPool()->FlushForTesting();
608 base::RunLoop().RunUntilIdle(); 610 base::RunLoop().RunUntilIdle();
609 611
610 // Allow one more circle to read and decode installed icons. 612 // Allow one more circle to read and decode installed icons.
611 content::BrowserThread::GetBlockingPool()->FlushForTesting(); 613 content::BrowserThread::GetBlockingPool()->FlushForTesting();
612 base::RunLoop().RunUntilIdle(); 614 base::RunLoop().RunUntilIdle();
613 615
614 // Validate loaded image. 616 // Validate loaded image.
615 EXPECT_EQ(1 + scale_factors.size(), delegate.update_image_cnt()); 617 EXPECT_EQ(1 + scale_factors.size(), delegate.update_image_cnt());
616 EXPECT_EQ(app_id, delegate.app_id()); 618 EXPECT_EQ(app_id, delegate.app_id());
617 ValidateIcon(delegate.image()); 619 ValidateIcon(delegate.image());
618 } 620 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/app_list/arc/arc_app_test.cc ('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