OLD | NEW |
---|---|
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 <memory> | 10 #include <memory> |
(...skipping 20 matching lines...) Expand all Loading... | |
31 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" | 31 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" |
32 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs_factory.h" | 32 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs_factory.h" |
33 #include "chrome/browser/ui/app_list/arc/arc_app_model_builder.h" | 33 #include "chrome/browser/ui/app_list/arc/arc_app_model_builder.h" |
34 #include "chrome/browser/ui/app_list/arc/arc_app_test.h" | 34 #include "chrome/browser/ui/app_list/arc/arc_app_test.h" |
35 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" | 35 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" |
36 #include "chrome/browser/ui/app_list/arc/arc_default_app_list.h" | 36 #include "chrome/browser/ui/app_list/arc/arc_default_app_list.h" |
37 #include "chrome/browser/ui/app_list/arc/arc_package_syncable_service_factory.h" | 37 #include "chrome/browser/ui/app_list/arc/arc_package_syncable_service_factory.h" |
38 #include "chrome/browser/ui/app_list/test/test_app_list_controller_delegate.h" | 38 #include "chrome/browser/ui/app_list/test/test_app_list_controller_delegate.h" |
39 #include "chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.h" | 39 #include "chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.h" |
40 #include "chrome/test/base/testing_profile.h" | 40 #include "chrome/test/base/testing_profile.h" |
41 #include "components/arc/arc_util.h" | |
41 #include "components/arc/test/fake_app_instance.h" | 42 #include "components/arc/test/fake_app_instance.h" |
42 #include "content/public/browser/browser_thread.h" | 43 #include "content/public/browser/browser_thread.h" |
43 #include "extensions/browser/extension_system.h" | 44 #include "extensions/browser/extension_system.h" |
44 #include "extensions/common/extension.h" | 45 #include "extensions/common/extension.h" |
45 #include "extensions/common/manifest_constants.h" | 46 #include "extensions/common/manifest_constants.h" |
46 #include "testing/gtest/include/gtest/gtest.h" | 47 #include "testing/gtest/include/gtest/gtest.h" |
47 #include "ui/app_list/app_list_constants.h" | 48 #include "ui/app_list/app_list_constants.h" |
48 #include "ui/app_list/app_list_model.h" | 49 #include "ui/app_list/app_list_model.h" |
49 #include "ui/events/event_constants.h" | 50 #include "ui/events/event_constants.h" |
50 #include "ui/gfx/geometry/safe_integer_conversions.h" | 51 #include "ui/gfx/geometry/safe_integer_conversions.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
87 // Process pending tasks. This performs multiple thread hops, so we need | 88 // Process pending tasks. This performs multiple thread hops, so we need |
88 // to run it continuously until it is resolved. | 89 // to run it continuously until it is resolved. |
89 do { | 90 do { |
90 content::BrowserThread::GetBlockingPool()->FlushForTesting(); | 91 content::BrowserThread::GetBlockingPool()->FlushForTesting(); |
91 base::RunLoop().RunUntilIdle(); | 92 base::RunLoop().RunUntilIdle(); |
92 } while (!base::PathExists(icon_path)); | 93 } while (!base::PathExists(icon_path)); |
93 } | 94 } |
94 | 95 |
95 } // namespace | 96 } // namespace |
96 | 97 |
97 class ArcAppModelBuilderTest : public AppListTestBase { | 98 class ArcAppModelBuilderTest : public AppListTestBase, |
99 public ::testing::WithParamInterface<bool> { | |
98 public: | 100 public: |
99 ArcAppModelBuilderTest() = default; | 101 ArcAppModelBuilderTest() = default; |
100 ~ArcAppModelBuilderTest() override { | 102 ~ArcAppModelBuilderTest() override { |
101 // Release profile file in order to keep right sequence. | 103 // Release profile file in order to keep right sequence. |
102 profile_.reset(); | 104 profile_.reset(); |
103 } | 105 } |
104 | 106 |
105 void SetUp() override { | 107 void SetUp() override { |
108 if (GetParam()) | |
109 arc::SetArcAlwaysStartForTesting(); | |
106 AppListTestBase::SetUp(); | 110 AppListTestBase::SetUp(); |
107 OnBeforeArcTestSetup(); | 111 OnBeforeArcTestSetup(); |
108 arc_test_.SetUp(profile_.get()); | 112 arc_test_.SetUp(profile_.get()); |
109 CreateBuilder(); | 113 CreateBuilder(); |
110 | 114 |
111 // Validating decoded content does not fit well for unit tests. | 115 // Validating decoded content does not fit well for unit tests. |
112 ArcAppIcon::DisableSafeDecodingForTesting(); | 116 ArcAppIcon::DisableSafeDecodingForTesting(); |
113 } | 117 } |
114 | 118 |
115 void TearDown() override { | 119 void TearDown() override { |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
446 // ArcAppModelBuilderTest: | 450 // ArcAppModelBuilderTest: |
447 void OnBeforeArcTestSetup() override { | 451 void OnBeforeArcTestSetup() override { |
448 arc::ArcPackageSyncableServiceFactory::GetInstance()->SetTestingFactory( | 452 arc::ArcPackageSyncableServiceFactory::GetInstance()->SetTestingFactory( |
449 profile_.get(), nullptr); | 453 profile_.get(), nullptr); |
450 } | 454 } |
451 | 455 |
452 private: | 456 private: |
453 DISALLOW_COPY_AND_ASSIGN(ArcAppModelBuilderRecreate); | 457 DISALLOW_COPY_AND_ASSIGN(ArcAppModelBuilderRecreate); |
454 }; | 458 }; |
455 | 459 |
456 TEST_F(ArcAppModelBuilderTest, ArcPackagePref) { | 460 TEST_P(ArcAppModelBuilderTest, ArcPackagePref) { |
457 ValidateHavePackages(std::vector<arc::mojom::ArcPackageInfo>()); | 461 ValidateHavePackages(std::vector<arc::mojom::ArcPackageInfo>()); |
458 app_instance()->SendRefreshPackageList(fake_packages()); | 462 app_instance()->SendRefreshPackageList(fake_packages()); |
459 ValidateHavePackages(fake_packages()); | 463 ValidateHavePackages(fake_packages()); |
460 | 464 |
461 arc::mojom::ArcPackageInfo package; | 465 arc::mojom::ArcPackageInfo package; |
462 package.package_name = kTestPackageName; | 466 package.package_name = kTestPackageName; |
463 package.package_version = 2; | 467 package.package_version = 2; |
464 package.last_backup_android_id = 2; | 468 package.last_backup_android_id = 2; |
465 package.last_backup_time = 2; | 469 package.last_backup_time = 2; |
466 package.sync = true; | 470 package.sync = true; |
467 | 471 |
468 RemovePackage(package); | 472 RemovePackage(package); |
469 app_instance()->SendPackageUninstalled(package.package_name); | 473 app_instance()->SendPackageUninstalled(package.package_name); |
470 ValidateHavePackages(fake_packages()); | 474 ValidateHavePackages(fake_packages()); |
471 | 475 |
472 AddPackage(package); | 476 AddPackage(package); |
473 app_instance()->SendPackageAdded(package); | 477 app_instance()->SendPackageAdded(package); |
474 ValidateHavePackages(fake_packages()); | 478 ValidateHavePackages(fake_packages()); |
475 } | 479 } |
476 | 480 |
477 TEST_F(ArcAppModelBuilderTest, RefreshAllOnReady) { | 481 TEST_P(ArcAppModelBuilderTest, RefreshAllOnReady) { |
478 // There should already have been one call, when the interface was | 482 // There should already have been one call, when the interface was |
479 // registered. | 483 // registered. |
480 EXPECT_EQ(1, app_instance()->refresh_app_list_count()); | 484 EXPECT_EQ(1, app_instance()->refresh_app_list_count()); |
481 app_instance()->RefreshAppList(); | 485 app_instance()->RefreshAppList(); |
482 EXPECT_EQ(2, app_instance()->refresh_app_list_count()); | 486 EXPECT_EQ(2, app_instance()->refresh_app_list_count()); |
483 } | 487 } |
484 | 488 |
485 TEST_F(ArcAppModelBuilderTest, RefreshAllFillsContent) { | 489 TEST_P(ArcAppModelBuilderTest, RefreshAllFillsContent) { |
486 ValidateHaveApps(std::vector<arc::mojom::AppInfo>()); | 490 ValidateHaveApps(std::vector<arc::mojom::AppInfo>()); |
487 app_instance()->RefreshAppList(); | 491 app_instance()->RefreshAppList(); |
488 app_instance()->SendRefreshAppList(fake_apps()); | 492 app_instance()->SendRefreshAppList(fake_apps()); |
489 ValidateHaveApps(fake_apps()); | 493 ValidateHaveApps(fake_apps()); |
490 } | 494 } |
491 | 495 |
492 TEST_F(ArcAppModelBuilderTest, InstallShortcut) { | 496 TEST_P(ArcAppModelBuilderTest, InstallShortcut) { |
493 ValidateHaveApps(std::vector<arc::mojom::AppInfo>()); | 497 ValidateHaveApps(std::vector<arc::mojom::AppInfo>()); |
494 | 498 |
495 app_instance()->SendInstallShortcuts(fake_shortcuts()); | 499 app_instance()->SendInstallShortcuts(fake_shortcuts()); |
496 ValidateHaveShortcuts(fake_shortcuts()); | 500 ValidateHaveShortcuts(fake_shortcuts()); |
497 } | 501 } |
498 | 502 |
499 TEST_F(ArcAppModelBuilderTest, RefreshAllPreservesShortcut) { | 503 TEST_P(ArcAppModelBuilderTest, RefreshAllPreservesShortcut) { |
500 ValidateHaveApps(std::vector<arc::mojom::AppInfo>()); | 504 ValidateHaveApps(std::vector<arc::mojom::AppInfo>()); |
501 app_instance()->RefreshAppList(); | 505 app_instance()->RefreshAppList(); |
502 app_instance()->SendRefreshAppList(fake_apps()); | 506 app_instance()->SendRefreshAppList(fake_apps()); |
503 ValidateHaveApps(fake_apps()); | 507 ValidateHaveApps(fake_apps()); |
504 | 508 |
505 app_instance()->SendInstallShortcuts(fake_shortcuts()); | 509 app_instance()->SendInstallShortcuts(fake_shortcuts()); |
506 ValidateHaveAppsAndShortcuts(fake_apps(), fake_shortcuts()); | 510 ValidateHaveAppsAndShortcuts(fake_apps(), fake_shortcuts()); |
507 | 511 |
508 app_instance()->RefreshAppList(); | 512 app_instance()->RefreshAppList(); |
509 app_instance()->SendRefreshAppList(fake_apps()); | 513 app_instance()->SendRefreshAppList(fake_apps()); |
510 ValidateHaveAppsAndShortcuts(fake_apps(), fake_shortcuts()); | 514 ValidateHaveAppsAndShortcuts(fake_apps(), fake_shortcuts()); |
511 } | 515 } |
512 | 516 |
513 TEST_F(ArcAppModelBuilderTest, MultipleRefreshAll) { | 517 TEST_P(ArcAppModelBuilderTest, MultipleRefreshAll) { |
514 ValidateHaveApps(std::vector<arc::mojom::AppInfo>()); | 518 ValidateHaveApps(std::vector<arc::mojom::AppInfo>()); |
515 app_instance()->RefreshAppList(); | 519 app_instance()->RefreshAppList(); |
516 // Send info about all fake apps except last. | 520 // Send info about all fake apps except last. |
517 std::vector<arc::mojom::AppInfo> apps1(fake_apps().begin(), | 521 std::vector<arc::mojom::AppInfo> apps1(fake_apps().begin(), |
518 fake_apps().end() - 1); | 522 fake_apps().end() - 1); |
519 app_instance()->SendRefreshAppList(apps1); | 523 app_instance()->SendRefreshAppList(apps1); |
520 // At this point all apps (except last) should exist and be ready. | 524 // At this point all apps (except last) should exist and be ready. |
521 ValidateHaveApps(apps1); | 525 ValidateHaveApps(apps1); |
522 ValidateAppReadyState(apps1, true); | 526 ValidateAppReadyState(apps1, true); |
523 | 527 |
(...skipping 11 matching lines...) Expand all Loading... | |
535 ValidateHaveApps(fake_apps()); | 539 ValidateHaveApps(fake_apps()); |
536 ValidateAppReadyState(fake_apps(), true); | 540 ValidateAppReadyState(fake_apps(), true); |
537 | 541 |
538 // Send info no app available. | 542 // Send info no app available. |
539 std::vector<arc::mojom::AppInfo> no_apps; | 543 std::vector<arc::mojom::AppInfo> no_apps; |
540 app_instance()->SendRefreshAppList(no_apps); | 544 app_instance()->SendRefreshAppList(no_apps); |
541 // At this point no app should exist. | 545 // At this point no app should exist. |
542 ValidateHaveApps(no_apps); | 546 ValidateHaveApps(no_apps); |
543 } | 547 } |
544 | 548 |
545 TEST_F(ArcAppModelBuilderTest, StopStartServicePreserveApps) { | 549 TEST_P(ArcAppModelBuilderTest, StopStartServicePreserveApps) { |
546 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); | 550 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); |
547 ASSERT_NE(nullptr, prefs); | 551 ASSERT_NE(nullptr, prefs); |
548 | 552 |
549 app_instance()->RefreshAppList(); | 553 app_instance()->RefreshAppList(); |
550 EXPECT_EQ(0u, GetArcItemCount()); | 554 EXPECT_EQ(0u, GetArcItemCount()); |
551 EXPECT_EQ(0u, prefs->GetAppIds().size()); | 555 EXPECT_EQ(0u, prefs->GetAppIds().size()); |
552 | 556 |
553 app_instance()->SendRefreshAppList(fake_apps()); | 557 app_instance()->SendRefreshAppList(fake_apps()); |
554 std::vector<std::string> ids = prefs->GetAppIds(); | 558 std::vector<std::string> ids = prefs->GetAppIds(); |
555 EXPECT_EQ(fake_apps().size(), ids.size()); | 559 EXPECT_EQ(fake_apps().size(), ids.size()); |
556 ValidateAppReadyState(fake_apps(), true); | 560 ValidateAppReadyState(fake_apps(), true); |
557 | 561 |
558 // Stopping service does not delete items. It makes them non-ready. | 562 // Stopping service does not delete items. It makes them non-ready. |
559 arc_test()->StopArcInstance(); | 563 arc_test()->StopArcInstance(); |
560 // Ids should be the same. | 564 // Ids should be the same. |
561 EXPECT_EQ(ids, prefs->GetAppIds()); | 565 EXPECT_EQ(ids, prefs->GetAppIds()); |
562 ValidateAppReadyState(fake_apps(), false); | 566 ValidateAppReadyState(fake_apps(), false); |
563 | 567 |
564 // Ids should be the same. | 568 // Ids should be the same. |
565 EXPECT_EQ(ids, prefs->GetAppIds()); | 569 EXPECT_EQ(ids, prefs->GetAppIds()); |
566 ValidateAppReadyState(fake_apps(), false); | 570 ValidateAppReadyState(fake_apps(), false); |
567 | 571 |
568 // Refreshing app list makes apps available. | 572 // Refreshing app list makes apps available. |
569 app_instance()->SendRefreshAppList(fake_apps()); | 573 app_instance()->SendRefreshAppList(fake_apps()); |
570 EXPECT_EQ(ids, prefs->GetAppIds()); | 574 EXPECT_EQ(ids, prefs->GetAppIds()); |
571 ValidateAppReadyState(fake_apps(), true); | 575 ValidateAppReadyState(fake_apps(), true); |
572 } | 576 } |
573 | 577 |
574 TEST_F(ArcAppModelBuilderTest, StopStartServicePreserveShortcuts) { | 578 TEST_P(ArcAppModelBuilderTest, StopStartServicePreserveShortcuts) { |
575 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); | 579 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); |
576 ASSERT_NE(nullptr, prefs); | 580 ASSERT_NE(nullptr, prefs); |
577 | 581 |
578 app_instance()->RefreshAppList(); | 582 app_instance()->RefreshAppList(); |
579 EXPECT_EQ(0u, GetArcItemCount()); | 583 EXPECT_EQ(0u, GetArcItemCount()); |
580 EXPECT_EQ(0u, prefs->GetAppIds().size()); | 584 EXPECT_EQ(0u, prefs->GetAppIds().size()); |
581 | 585 |
582 app_instance()->SendInstallShortcuts(fake_shortcuts()); | 586 app_instance()->SendInstallShortcuts(fake_shortcuts()); |
583 std::vector<std::string> ids = prefs->GetAppIds(); | 587 std::vector<std::string> ids = prefs->GetAppIds(); |
584 EXPECT_EQ(fake_shortcuts().size(), ids.size()); | 588 EXPECT_EQ(fake_shortcuts().size(), ids.size()); |
585 ValidateShortcutReadyState(fake_shortcuts(), true); | 589 ValidateShortcutReadyState(fake_shortcuts(), true); |
586 | 590 |
587 // Stopping service does not delete items. It makes them non-ready. | 591 // Stopping service does not delete items. It makes them non-ready. |
588 arc_test()->StopArcInstance(); | 592 arc_test()->StopArcInstance(); |
589 // Ids should be the same. | 593 // Ids should be the same. |
590 EXPECT_EQ(ids, prefs->GetAppIds()); | 594 EXPECT_EQ(ids, prefs->GetAppIds()); |
591 ValidateShortcutReadyState(fake_shortcuts(), false); | 595 ValidateShortcutReadyState(fake_shortcuts(), false); |
592 | 596 |
593 // Ids should be the same. | 597 // Ids should be the same. |
594 EXPECT_EQ(ids, prefs->GetAppIds()); | 598 EXPECT_EQ(ids, prefs->GetAppIds()); |
595 ValidateShortcutReadyState(fake_shortcuts(), false); | 599 ValidateShortcutReadyState(fake_shortcuts(), false); |
596 | 600 |
597 // Refreshing app list makes apps available. | 601 // Refreshing app list makes apps available. |
598 app_instance()->RefreshAppList(); | 602 app_instance()->RefreshAppList(); |
599 app_instance()->SendRefreshAppList(std::vector<arc::mojom::AppInfo>()); | 603 app_instance()->SendRefreshAppList(std::vector<arc::mojom::AppInfo>()); |
600 EXPECT_EQ(ids, prefs->GetAppIds()); | 604 EXPECT_EQ(ids, prefs->GetAppIds()); |
601 ValidateShortcutReadyState(fake_shortcuts(), true); | 605 ValidateShortcutReadyState(fake_shortcuts(), true); |
602 } | 606 } |
603 | 607 |
604 TEST_F(ArcAppModelBuilderTest, RestartPreserveApps) { | 608 TEST_P(ArcAppModelBuilderTest, RestartPreserveApps) { |
605 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); | 609 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); |
606 ASSERT_NE(nullptr, prefs); | 610 ASSERT_NE(nullptr, prefs); |
607 | 611 |
608 // Start from scratch and fill with apps. | 612 // Start from scratch and fill with apps. |
609 app_instance()->SendRefreshAppList(fake_apps()); | 613 app_instance()->SendRefreshAppList(fake_apps()); |
610 std::vector<std::string> ids = prefs->GetAppIds(); | 614 std::vector<std::string> ids = prefs->GetAppIds(); |
611 EXPECT_EQ(fake_apps().size(), ids.size()); | 615 EXPECT_EQ(fake_apps().size(), ids.size()); |
612 ValidateAppReadyState(fake_apps(), true); | 616 ValidateAppReadyState(fake_apps(), true); |
613 | 617 |
614 // This recreates model and ARC apps will be read from prefs. | 618 // This recreates model and ARC apps will be read from prefs. |
615 arc_test()->StopArcInstance(); | 619 arc_test()->StopArcInstance(); |
616 CreateBuilder(); | 620 CreateBuilder(); |
617 ValidateAppReadyState(fake_apps(), false); | 621 ValidateAppReadyState(fake_apps(), false); |
618 } | 622 } |
619 | 623 |
620 TEST_F(ArcAppModelBuilderTest, RestartPreserveShortcuts) { | 624 TEST_P(ArcAppModelBuilderTest, RestartPreserveShortcuts) { |
621 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); | 625 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); |
622 ASSERT_NE(nullptr, prefs); | 626 ASSERT_NE(nullptr, prefs); |
623 | 627 |
624 // Start from scratch and install shortcuts. | 628 // Start from scratch and install shortcuts. |
625 app_instance()->SendInstallShortcuts(fake_shortcuts()); | 629 app_instance()->SendInstallShortcuts(fake_shortcuts()); |
626 std::vector<std::string> ids = prefs->GetAppIds(); | 630 std::vector<std::string> ids = prefs->GetAppIds(); |
627 EXPECT_EQ(fake_apps().size(), ids.size()); | 631 EXPECT_EQ(fake_apps().size(), ids.size()); |
628 ValidateShortcutReadyState(fake_shortcuts(), true); | 632 ValidateShortcutReadyState(fake_shortcuts(), true); |
629 | 633 |
630 // This recreates model and ARC apps and shortcuts will be read from prefs. | 634 // This recreates model and ARC apps and shortcuts will be read from prefs. |
631 arc_test()->StopArcInstance(); | 635 arc_test()->StopArcInstance(); |
632 CreateBuilder(); | 636 CreateBuilder(); |
633 ValidateShortcutReadyState(fake_shortcuts(), false); | 637 ValidateShortcutReadyState(fake_shortcuts(), false); |
634 } | 638 } |
635 | 639 |
636 TEST_F(ArcAppModelBuilderTest, LaunchApps) { | 640 TEST_P(ArcAppModelBuilderTest, LaunchApps) { |
637 // Disable attempts to dismiss app launcher view. | 641 // Disable attempts to dismiss app launcher view. |
638 ChromeAppListItem::OverrideAppListControllerDelegateForTesting(controller()); | 642 ChromeAppListItem::OverrideAppListControllerDelegateForTesting(controller()); |
639 | 643 |
640 app_instance()->RefreshAppList(); | 644 app_instance()->RefreshAppList(); |
641 app_instance()->SendRefreshAppList(fake_apps()); | 645 app_instance()->SendRefreshAppList(fake_apps()); |
642 | 646 |
643 // Simulate item activate. | 647 // Simulate item activate. |
644 const arc::mojom::AppInfo& app_first = fake_apps()[0]; | 648 const arc::mojom::AppInfo& app_first = fake_apps()[0]; |
645 const arc::mojom::AppInfo& app_last = fake_apps()[0]; | 649 const arc::mojom::AppInfo& app_last = fake_apps()[0]; |
646 ArcAppItem* item_first = FindArcItem(ArcAppTest::GetAppId(app_first)); | 650 ArcAppItem* item_first = FindArcItem(ArcAppTest::GetAppId(app_first)); |
(...skipping 15 matching lines...) Expand all Loading... | |
662 arc_test()->StopArcInstance(); | 666 arc_test()->StopArcInstance(); |
663 item_first = FindArcItem(ArcAppTest::GetAppId(app_first)); | 667 item_first = FindArcItem(ArcAppTest::GetAppId(app_first)); |
664 ASSERT_NE(nullptr, item_first); | 668 ASSERT_NE(nullptr, item_first); |
665 size_t launch_request_count_before = app_instance()->launch_requests().size(); | 669 size_t launch_request_count_before = app_instance()->launch_requests().size(); |
666 item_first->Activate(0); | 670 item_first->Activate(0); |
667 // Number of launch requests must not change. | 671 // Number of launch requests must not change. |
668 EXPECT_EQ(launch_request_count_before, | 672 EXPECT_EQ(launch_request_count_before, |
669 app_instance()->launch_requests().size()); | 673 app_instance()->launch_requests().size()); |
670 } | 674 } |
671 | 675 |
672 TEST_F(ArcAppModelBuilderTest, LaunchShortcuts) { | 676 TEST_P(ArcAppModelBuilderTest, LaunchShortcuts) { |
673 // Disable attempts to dismiss app launcher view. | 677 // Disable attempts to dismiss app launcher view. |
674 ChromeAppListItem::OverrideAppListControllerDelegateForTesting(controller()); | 678 ChromeAppListItem::OverrideAppListControllerDelegateForTesting(controller()); |
675 | 679 |
676 app_instance()->RefreshAppList(); | 680 app_instance()->RefreshAppList(); |
677 app_instance()->SendInstallShortcuts(fake_shortcuts()); | 681 app_instance()->SendInstallShortcuts(fake_shortcuts()); |
678 | 682 |
679 // Simulate item activate. | 683 // Simulate item activate. |
680 const arc::mojom::ShortcutInfo& app_first = fake_shortcuts()[0]; | 684 const arc::mojom::ShortcutInfo& app_first = fake_shortcuts()[0]; |
681 const arc::mojom::ShortcutInfo& app_last = fake_shortcuts()[0]; | 685 const arc::mojom::ShortcutInfo& app_last = fake_shortcuts()[0]; |
682 ArcAppItem* item_first = FindArcItem(ArcAppTest::GetAppId(app_first)); | 686 ArcAppItem* item_first = FindArcItem(ArcAppTest::GetAppId(app_first)); |
(...skipping 15 matching lines...) Expand all Loading... | |
698 arc_test()->StopArcInstance(); | 702 arc_test()->StopArcInstance(); |
699 item_first = FindArcItem(ArcAppTest::GetAppId(app_first)); | 703 item_first = FindArcItem(ArcAppTest::GetAppId(app_first)); |
700 ASSERT_NE(nullptr, item_first); | 704 ASSERT_NE(nullptr, item_first); |
701 size_t launch_request_count_before = app_instance()->launch_intents().size(); | 705 size_t launch_request_count_before = app_instance()->launch_intents().size(); |
702 item_first->Activate(0); | 706 item_first->Activate(0); |
703 // Number of launch requests must not change. | 707 // Number of launch requests must not change. |
704 EXPECT_EQ(launch_request_count_before, | 708 EXPECT_EQ(launch_request_count_before, |
705 app_instance()->launch_intents().size()); | 709 app_instance()->launch_intents().size()); |
706 } | 710 } |
707 | 711 |
708 TEST_F(ArcAppModelBuilderTest, RequestIcons) { | 712 TEST_P(ArcAppModelBuilderTest, RequestIcons) { |
709 // Make sure we are on UI thread. | 713 // Make sure we are on UI thread. |
710 ASSERT_TRUE(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 714 ASSERT_TRUE(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
711 | 715 |
712 app_instance()->RefreshAppList(); | 716 app_instance()->RefreshAppList(); |
713 app_instance()->SendRefreshAppList(fake_apps()); | 717 app_instance()->SendRefreshAppList(fake_apps()); |
714 | 718 |
715 // Validate that no icon exists at the beginning and request icon for | 719 // Validate that no icon exists at the beginning and request icon for |
716 // each supported scale factor. This will start asynchronous loading. | 720 // each supported scale factor. This will start asynchronous loading. |
717 uint32_t expected_mask = 0; | 721 uint32_t expected_mask = 0; |
718 const std::vector<ui::ScaleFactor>& scale_factors = | 722 const std::vector<ui::ScaleFactor>& scale_factors = |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
753 // Validate that we have a request for each icon for each supported scale | 757 // Validate that we have a request for each icon for each supported scale |
754 // factor. | 758 // factor. |
755 EXPECT_EQ(fake_apps().size(), app_masks.size()); | 759 EXPECT_EQ(fake_apps().size(), app_masks.size()); |
756 for (auto& app : fake_apps()) { | 760 for (auto& app : fake_apps()) { |
757 const std::string id = ArcAppTest::GetAppId(app); | 761 const std::string id = ArcAppTest::GetAppId(app); |
758 ASSERT_NE(app_masks.find(id), app_masks.end()); | 762 ASSERT_NE(app_masks.find(id), app_masks.end()); |
759 EXPECT_EQ(app_masks[id], expected_mask); | 763 EXPECT_EQ(app_masks[id], expected_mask); |
760 } | 764 } |
761 } | 765 } |
762 | 766 |
763 TEST_F(ArcAppModelBuilderTest, RequestShortcutIcons) { | 767 TEST_P(ArcAppModelBuilderTest, RequestShortcutIcons) { |
764 // Make sure we are on UI thread. | 768 // Make sure we are on UI thread. |
765 ASSERT_TRUE(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 769 ASSERT_TRUE(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
766 | 770 |
767 const arc::mojom::ShortcutInfo& shortcut = fake_shortcuts()[0]; | 771 const arc::mojom::ShortcutInfo& shortcut = fake_shortcuts()[0]; |
768 app_instance()->SendInstallShortcut(shortcut); | 772 app_instance()->SendInstallShortcut(shortcut); |
769 | 773 |
770 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); | 774 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); |
771 ASSERT_NE(nullptr, prefs); | 775 ASSERT_NE(nullptr, prefs); |
772 | 776 |
773 // Icons representations loading is done asynchronously and is started once | 777 // Icons representations loading is done asynchronously and is started once |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
806 EXPECT_EQ(app_mask, expected_mask); | 810 EXPECT_EQ(app_mask, expected_mask); |
807 | 811 |
808 // Validate all icon files are installed. | 812 // Validate all icon files are installed. |
809 for (auto& scale_factor : scale_factors) { | 813 for (auto& scale_factor : scale_factors) { |
810 const base::FilePath icon_path = | 814 const base::FilePath icon_path = |
811 prefs->GetIconPath(ArcAppTest::GetAppId(shortcut), scale_factor); | 815 prefs->GetIconPath(ArcAppTest::GetAppId(shortcut), scale_factor); |
812 EXPECT_TRUE(base::PathExists(icon_path)); | 816 EXPECT_TRUE(base::PathExists(icon_path)); |
813 } | 817 } |
814 } | 818 } |
815 | 819 |
816 TEST_F(ArcAppModelBuilderTest, InstallIcon) { | 820 TEST_P(ArcAppModelBuilderTest, InstallIcon) { |
817 // Make sure we are on UI thread. | 821 // Make sure we are on UI thread. |
818 ASSERT_TRUE(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 822 ASSERT_TRUE(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
819 | 823 |
820 app_instance()->RefreshAppList(); | 824 app_instance()->RefreshAppList(); |
821 app_instance()->SendRefreshAppList(std::vector<arc::mojom::AppInfo>( | 825 app_instance()->SendRefreshAppList(std::vector<arc::mojom::AppInfo>( |
822 fake_apps().begin(), fake_apps().begin() + 1)); | 826 fake_apps().begin(), fake_apps().begin() + 1)); |
823 const arc::mojom::AppInfo& app = fake_apps()[0]; | 827 const arc::mojom::AppInfo& app = fake_apps()[0]; |
824 | 828 |
825 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); | 829 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); |
826 ASSERT_NE(nullptr, prefs); | 830 ASSERT_NE(nullptr, prefs); |
(...skipping 18 matching lines...) Expand all Loading... | |
845 // Validate that icons are installed, have right content and icon is | 849 // Validate that icons are installed, have right content and icon is |
846 // refreshed for ARC app item. | 850 // refreshed for ARC app item. |
847 EXPECT_TRUE(base::PathExists(icon_path)); | 851 EXPECT_TRUE(base::PathExists(icon_path)); |
848 | 852 |
849 std::string icon_data; | 853 std::string icon_data; |
850 // Read the file from disk and compare with reference data. | 854 // Read the file from disk and compare with reference data. |
851 EXPECT_TRUE(base::ReadFileToString(icon_path, &icon_data)); | 855 EXPECT_TRUE(base::ReadFileToString(icon_path, &icon_data)); |
852 ASSERT_EQ(icon_data, png_data); | 856 ASSERT_EQ(icon_data, png_data); |
853 } | 857 } |
854 | 858 |
855 TEST_F(ArcAppModelBuilderTest, RemoveAppCleanUpFolder) { | 859 TEST_P(ArcAppModelBuilderTest, RemoveAppCleanUpFolder) { |
856 // Make sure we are on UI thread. | 860 // Make sure we are on UI thread. |
857 ASSERT_TRUE(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 861 ASSERT_TRUE(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
858 | 862 |
859 app_instance()->RefreshAppList(); | 863 app_instance()->RefreshAppList(); |
860 app_instance()->SendRefreshAppList(std::vector<arc::mojom::AppInfo>( | 864 app_instance()->SendRefreshAppList(std::vector<arc::mojom::AppInfo>( |
861 fake_apps().begin(), fake_apps().begin() + 1)); | 865 fake_apps().begin(), fake_apps().begin() + 1)); |
862 const arc::mojom::AppInfo& app = fake_apps()[0]; | 866 const arc::mojom::AppInfo& app = fake_apps()[0]; |
863 | 867 |
864 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); | 868 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); |
865 ASSERT_NE(nullptr, prefs); | 869 ASSERT_NE(nullptr, prefs); |
(...skipping 21 matching lines...) Expand all Loading... | |
887 // removed, not added. | 891 // removed, not added. |
888 // Process pending tasks. This performs multiple thread hops, so we need | 892 // Process pending tasks. This performs multiple thread hops, so we need |
889 // to run it continuously until it is resolved. | 893 // to run it continuously until it is resolved. |
890 do { | 894 do { |
891 content::BrowserThread::GetBlockingPool()->FlushForTesting(); | 895 content::BrowserThread::GetBlockingPool()->FlushForTesting(); |
892 base::RunLoop().RunUntilIdle(); | 896 base::RunLoop().RunUntilIdle(); |
893 } while (base::PathExists(app_path)); | 897 } while (base::PathExists(app_path)); |
894 EXPECT_FALSE(base::PathExists(app_path)); | 898 EXPECT_FALSE(base::PathExists(app_path)); |
895 } | 899 } |
896 | 900 |
897 TEST_F(ArcAppModelBuilderTest, LastLaunchTime) { | 901 TEST_P(ArcAppModelBuilderTest, LastLaunchTime) { |
898 // Make sure we are on UI thread. | 902 // Make sure we are on UI thread. |
899 ASSERT_TRUE(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 903 ASSERT_TRUE(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
900 | 904 |
901 app_instance()->RefreshAppList(); | 905 app_instance()->RefreshAppList(); |
902 app_instance()->SendRefreshAppList(std::vector<arc::mojom::AppInfo>( | 906 app_instance()->SendRefreshAppList(std::vector<arc::mojom::AppInfo>( |
903 fake_apps().begin(), fake_apps().begin() + 2)); | 907 fake_apps().begin(), fake_apps().begin() + 2)); |
904 const arc::mojom::AppInfo& app1 = fake_apps()[0]; | 908 const arc::mojom::AppInfo& app1 = fake_apps()[0]; |
905 const arc::mojom::AppInfo& app2 = fake_apps()[1]; | 909 const arc::mojom::AppInfo& app2 = fake_apps()[1]; |
906 const std::string id1 = ArcAppTest::GetAppId(app1); | 910 const std::string id1 = ArcAppTest::GetAppId(app1); |
907 const std::string id2 = ArcAppTest::GetAppId(app2); | 911 const std::string id2 = ArcAppTest::GetAppId(app2); |
(...skipping 23 matching lines...) Expand all Loading... | |
931 arc::LaunchApp(profile(), id2, ui::EF_NONE); | 935 arc::LaunchApp(profile(), id2, ui::EF_NONE); |
932 base::Time time_after = base::Time::Now(); | 936 base::Time time_after = base::Time::Now(); |
933 | 937 |
934 app_info = prefs->GetApp(id2); | 938 app_info = prefs->GetApp(id2); |
935 ASSERT_NE(nullptr, app_info.get()); | 939 ASSERT_NE(nullptr, app_info.get()); |
936 ASSERT_LE(time_before, app_info->last_launch_time); | 940 ASSERT_LE(time_before, app_info->last_launch_time); |
937 ASSERT_GE(time_after, app_info->last_launch_time); | 941 ASSERT_GE(time_after, app_info->last_launch_time); |
938 } | 942 } |
939 | 943 |
940 // Validate that arc model contains expected elements on restart. | 944 // Validate that arc model contains expected elements on restart. |
941 TEST_F(ArcAppModelBuilderRecreate, AppModelRestart) { | 945 TEST_P(ArcAppModelBuilderRecreate, AppModelRestart) { |
942 // No apps on initial start. | 946 // No apps on initial start. |
943 ValidateHaveApps(std::vector<arc::mojom::AppInfo>()); | 947 ValidateHaveApps(std::vector<arc::mojom::AppInfo>()); |
944 | 948 |
945 // Send info about all fake apps except last. | 949 // Send info about all fake apps except last. |
946 std::vector<arc::mojom::AppInfo> apps1(fake_apps().begin(), | 950 std::vector<arc::mojom::AppInfo> apps1(fake_apps().begin(), |
947 fake_apps().end() - 1); | 951 fake_apps().end() - 1); |
948 app_instance()->RefreshAppList(); | 952 app_instance()->RefreshAppList(); |
949 app_instance()->SendRefreshAppList(apps1); | 953 app_instance()->SendRefreshAppList(apps1); |
950 // Model has refreshed apps. | 954 // Model has refreshed apps. |
951 ValidateHaveApps(apps1); | 955 ValidateHaveApps(apps1); |
(...skipping 12 matching lines...) Expand all Loading... | |
964 ValidateHaveApps(apps1); | 968 ValidateHaveApps(apps1); |
965 EXPECT_EQ(apps1.size(), GetArcItemCount()); | 969 EXPECT_EQ(apps1.size(), GetArcItemCount()); |
966 | 970 |
967 // Now refresh old apps with new one. | 971 // Now refresh old apps with new one. |
968 app_instance()->RefreshAppList(); | 972 app_instance()->RefreshAppList(); |
969 app_instance()->SendRefreshAppList(fake_apps()); | 973 app_instance()->SendRefreshAppList(fake_apps()); |
970 ValidateHaveApps(fake_apps()); | 974 ValidateHaveApps(fake_apps()); |
971 EXPECT_EQ(fake_apps().size(), GetArcItemCount()); | 975 EXPECT_EQ(fake_apps().size(), GetArcItemCount()); |
972 } | 976 } |
973 | 977 |
974 TEST_F(ArcPlayStoreAppTest, PlayStore) { | 978 TEST_P(ArcPlayStoreAppTest, PlayStore) { |
975 // Make sure PlayStore is available. | 979 // Make sure PlayStore is available. |
976 ASSERT_TRUE(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 980 ASSERT_TRUE(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
977 | 981 |
978 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); | 982 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); |
979 ASSERT_TRUE(prefs); | 983 ASSERT_TRUE(prefs); |
980 | 984 |
981 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = prefs->GetApp( | 985 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = prefs->GetApp( |
982 arc::kPlayStoreAppId); | 986 arc::kPlayStoreAppId); |
983 ASSERT_TRUE(app_info); | 987 ASSERT_TRUE(app_info); |
984 EXPECT_FALSE(app_info->ready); | 988 EXPECT_FALSE(app_info->ready); |
985 | 989 |
986 arc::mojom::AppInfo app; | 990 arc::mojom::AppInfo app; |
987 std::vector<arc::mojom::AppInfo> apps; | 991 std::vector<arc::mojom::AppInfo> apps; |
988 app.name = "Play Store"; | 992 app.name = "Play Store"; |
989 app.package_name = arc::kPlayStorePackage; | 993 app.package_name = arc::kPlayStorePackage; |
990 app.activity = arc::kPlayStoreActivity; | 994 app.activity = arc::kPlayStoreActivity; |
991 app.sticky = false; | 995 app.sticky = false; |
992 apps.push_back(app); | 996 apps.push_back(app); |
993 | 997 |
994 app_instance()->RefreshAppList(); | 998 app_instance()->RefreshAppList(); |
995 app_instance()->SendRefreshAppList(apps); | 999 app_instance()->SendRefreshAppList(apps); |
996 | 1000 |
997 app_info = prefs->GetApp(arc::kPlayStoreAppId); | 1001 app_info = prefs->GetApp(arc::kPlayStoreAppId); |
998 ASSERT_TRUE(app_info); | 1002 ASSERT_TRUE(app_info); |
999 EXPECT_TRUE(app_info->ready); | 1003 EXPECT_TRUE(app_info->ready); |
1000 | 1004 |
1005 // TODO(victorhsieh): Opt-out on Persistent ARC is special. Skip until | |
1006 // implemented. | |
1007 if (arc::ShouldArcAlwaysStart()) | |
1008 return; | |
1001 arc::SetArcPlayStoreEnabledForProfile(profile(), false); | 1009 arc::SetArcPlayStoreEnabledForProfile(profile(), false); |
1002 | 1010 |
1003 app_info = prefs->GetApp(arc::kPlayStoreAppId); | 1011 app_info = prefs->GetApp(arc::kPlayStoreAppId); |
1004 ASSERT_TRUE(app_info); | 1012 ASSERT_TRUE(app_info); |
1005 EXPECT_FALSE(app_info->ready); | 1013 EXPECT_FALSE(app_info->ready); |
1006 | 1014 |
1007 arc::LaunchApp(profile(), arc::kPlayStoreAppId, ui::EF_NONE); | 1015 arc::LaunchApp(profile(), arc::kPlayStoreAppId, ui::EF_NONE); |
1008 EXPECT_TRUE(arc::IsArcPlayStoreEnabledForProfile(profile())); | 1016 EXPECT_TRUE(arc::IsArcPlayStoreEnabledForProfile(profile())); |
1009 } | 1017 } |
1010 | 1018 |
1011 // Test that icon is correctly extracted for shelf group. | 1019 // Test that icon is correctly extracted for shelf group. |
1012 TEST_F(ArcAppModelBuilderTest, IconLoaderForShelfGroup) { | 1020 TEST_P(ArcAppModelBuilderTest, IconLoaderForShelfGroup) { |
1013 const arc::mojom::AppInfo& app = fake_apps()[0]; | 1021 const arc::mojom::AppInfo& app = fake_apps()[0]; |
1014 const std::string app_id = ArcAppTest::GetAppId(app); | 1022 const std::string app_id = ArcAppTest::GetAppId(app); |
1015 | 1023 |
1016 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); | 1024 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); |
1017 ASSERT_NE(nullptr, prefs); | 1025 ASSERT_NE(nullptr, prefs); |
1018 | 1026 |
1019 app_instance()->RefreshAppList(); | 1027 app_instance()->RefreshAppList(); |
1020 app_instance()->SendRefreshAppList(std::vector<arc::mojom::AppInfo>( | 1028 app_instance()->SendRefreshAppList(std::vector<arc::mojom::AppInfo>( |
1021 fake_apps().begin(), fake_apps().begin() + 1)); | 1029 fake_apps().begin(), fake_apps().begin() + 1)); |
1022 content::BrowserThread::GetBlockingPool()->FlushForTesting(); | 1030 content::BrowserThread::GetBlockingPool()->FlushForTesting(); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1069 EXPECT_EQ(shortcut_request_cnt, | 1077 EXPECT_EQ(shortcut_request_cnt, |
1070 app_instance()->shortcut_icon_requests().size()); | 1078 app_instance()->shortcut_icon_requests().size()); |
1071 for (size_t i = initial_icon_request_count; | 1079 for (size_t i = initial_icon_request_count; |
1072 i < app_instance()->icon_requests().size(); ++i) { | 1080 i < app_instance()->icon_requests().size(); ++i) { |
1073 const auto& request = app_instance()->icon_requests()[i]; | 1081 const auto& request = app_instance()->icon_requests()[i]; |
1074 EXPECT_TRUE(request->IsForApp(app)); | 1082 EXPECT_TRUE(request->IsForApp(app)); |
1075 } | 1083 } |
1076 } | 1084 } |
1077 | 1085 |
1078 // TODO(crbug.com/628425) -- reenable once this test is less flaky. | 1086 // TODO(crbug.com/628425) -- reenable once this test is less flaky. |
1079 TEST_F(ArcAppModelBuilderTest, DISABLED_IconLoader) { | 1087 TEST_P(ArcAppModelBuilderTest, DISABLED_IconLoader) { |
1080 const arc::mojom::AppInfo& app = fake_apps()[0]; | 1088 const arc::mojom::AppInfo& app = fake_apps()[0]; |
1081 const std::string app_id = ArcAppTest::GetAppId(app); | 1089 const std::string app_id = ArcAppTest::GetAppId(app); |
1082 | 1090 |
1083 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); | 1091 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); |
1084 ASSERT_NE(nullptr, prefs); | 1092 ASSERT_NE(nullptr, prefs); |
1085 | 1093 |
1086 app_instance()->RefreshAppList(); | 1094 app_instance()->RefreshAppList(); |
1087 app_instance()->SendRefreshAppList(std::vector<arc::mojom::AppInfo>( | 1095 app_instance()->SendRefreshAppList(std::vector<arc::mojom::AppInfo>( |
1088 fake_apps().begin(), fake_apps().begin() + 1)); | 1096 fake_apps().begin(), fake_apps().begin() + 1)); |
1089 | 1097 |
(...skipping 21 matching lines...) Expand all Loading... | |
1111 app_item->icon().GetRepresentation(scale); | 1119 app_item->icon().GetRepresentation(scale); |
1112 WaitForIconReady(prefs, app_id, scale_factor); | 1120 WaitForIconReady(prefs, app_id, scale_factor); |
1113 } | 1121 } |
1114 | 1122 |
1115 // Validate loaded image. | 1123 // Validate loaded image. |
1116 EXPECT_EQ(1 + scale_factors.size(), delegate.update_image_cnt()); | 1124 EXPECT_EQ(1 + scale_factors.size(), delegate.update_image_cnt()); |
1117 EXPECT_EQ(app_id, delegate.app_id()); | 1125 EXPECT_EQ(app_id, delegate.app_id()); |
1118 ValidateIcon(delegate.image()); | 1126 ValidateIcon(delegate.image()); |
1119 } | 1127 } |
1120 | 1128 |
1121 TEST_F(ArcAppModelBuilderTest, AppLauncher) { | 1129 TEST_P(ArcAppModelBuilderTest, AppLauncher) { |
1122 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile()); | 1130 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile()); |
1123 ASSERT_NE(nullptr, prefs); | 1131 ASSERT_NE(nullptr, prefs); |
1124 | 1132 |
1125 // App1 is called in deferred mode, after refreshing apps. | 1133 // App1 is called in deferred mode, after refreshing apps. |
1126 // App2 is never called since app is not avaialble. | 1134 // App2 is never called since app is not avaialble. |
1127 // App3 is never called immediately because app is available already. | 1135 // App3 is never called immediately because app is available already. |
1128 const arc::mojom::AppInfo& app1 = fake_apps()[0]; | 1136 const arc::mojom::AppInfo& app1 = fake_apps()[0]; |
1129 const arc::mojom::AppInfo& app2 = fake_apps()[1]; | 1137 const arc::mojom::AppInfo& app2 = fake_apps()[1]; |
1130 const arc::mojom::AppInfo& app3 = fake_apps()[2]; | 1138 const arc::mojom::AppInfo& app3 = fake_apps()[2]; |
1131 const std::string id1 = ArcAppTest::GetAppId(app1); | 1139 const std::string id1 = ArcAppTest::GetAppId(app1); |
(...skipping 24 matching lines...) Expand all Loading... | |
1156 EXPECT_TRUE(prefs->HasObserver(&launcher3)); | 1164 EXPECT_TRUE(prefs->HasObserver(&launcher3)); |
1157 | 1165 |
1158 ArcAppLauncher launcher2(profile(), id2, true); | 1166 ArcAppLauncher launcher2(profile(), id2, true); |
1159 EXPECT_TRUE(launcher2.app_launched()); | 1167 EXPECT_TRUE(launcher2.app_launched()); |
1160 EXPECT_FALSE(prefs->HasObserver(&launcher2)); | 1168 EXPECT_FALSE(prefs->HasObserver(&launcher2)); |
1161 ASSERT_EQ(2u, app_instance()->launch_requests().size()); | 1169 ASSERT_EQ(2u, app_instance()->launch_requests().size()); |
1162 EXPECT_TRUE(app_instance()->launch_requests()[1]->IsForApp(app2)); | 1170 EXPECT_TRUE(app_instance()->launch_requests()[1]->IsForApp(app2)); |
1163 } | 1171 } |
1164 | 1172 |
1165 // Validates an app that have no launchable flag. | 1173 // Validates an app that have no launchable flag. |
1166 TEST_F(ArcAppModelBuilderTest, NonLaunchableApp) { | 1174 TEST_P(ArcAppModelBuilderTest, NonLaunchableApp) { |
1167 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); | 1175 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); |
1168 ASSERT_NE(nullptr, prefs); | 1176 ASSERT_NE(nullptr, prefs); |
1169 | 1177 |
1170 ValidateHaveApps(std::vector<arc::mojom::AppInfo>()); | 1178 ValidateHaveApps(std::vector<arc::mojom::AppInfo>()); |
1171 app_instance()->RefreshAppList(); | 1179 app_instance()->RefreshAppList(); |
1172 // Send all except first. | 1180 // Send all except first. |
1173 std::vector<arc::mojom::AppInfo> apps(fake_apps().begin() + 1, | 1181 std::vector<arc::mojom::AppInfo> apps(fake_apps().begin() + 1, |
1174 fake_apps().end()); | 1182 fake_apps().end()); |
1175 app_instance()->SendRefreshAppList(apps); | 1183 app_instance()->SendRefreshAppList(apps); |
1176 ValidateHaveApps(apps); | 1184 ValidateHaveApps(apps); |
1177 | 1185 |
1178 const std::string app_id = ArcAppTest::GetAppId(fake_apps()[0]); | 1186 const std::string app_id = ArcAppTest::GetAppId(fake_apps()[0]); |
1179 | 1187 |
1180 EXPECT_FALSE(prefs->IsRegistered(app_id)); | 1188 EXPECT_FALSE(prefs->IsRegistered(app_id)); |
1181 EXPECT_FALSE(FindArcItem(app_id)); | 1189 EXPECT_FALSE(FindArcItem(app_id)); |
1182 app_instance()->SendTaskCreated(0, fake_apps()[0], std::string()); | 1190 app_instance()->SendTaskCreated(0, fake_apps()[0], std::string()); |
1183 // App should not appear now in the model but should be registered. | 1191 // App should not appear now in the model but should be registered. |
1184 EXPECT_FALSE(FindArcItem(app_id)); | 1192 EXPECT_FALSE(FindArcItem(app_id)); |
1185 EXPECT_TRUE(prefs->IsRegistered(app_id)); | 1193 EXPECT_TRUE(prefs->IsRegistered(app_id)); |
1186 } | 1194 } |
1187 | 1195 |
1188 TEST_F(ArcAppModelBuilderTest, ArcAppsOnPackageUpdated) { | 1196 TEST_P(ArcAppModelBuilderTest, ArcAppsOnPackageUpdated) { |
1189 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); | 1197 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); |
1190 ASSERT_NE(nullptr, prefs); | 1198 ASSERT_NE(nullptr, prefs); |
1191 | 1199 |
1192 std::vector<arc::mojom::AppInfo> apps = fake_apps(); | 1200 std::vector<arc::mojom::AppInfo> apps = fake_apps(); |
1193 ASSERT_GE(3u, apps.size()); | 1201 ASSERT_GE(3u, apps.size()); |
1194 apps[0].package_name = apps[2].package_name; | 1202 apps[0].package_name = apps[2].package_name; |
1195 apps[1].package_name = apps[2].package_name; | 1203 apps[1].package_name = apps[2].package_name; |
1196 // Second app should be preserved after update. | 1204 // Second app should be preserved after update. |
1197 std::vector<arc::mojom::AppInfo> apps1(apps.begin(), apps.begin() + 2); | 1205 std::vector<arc::mojom::AppInfo> apps1(apps.begin(), apps.begin() + 2); |
1198 std::vector<arc::mojom::AppInfo> apps2(apps.begin() + 1, apps.begin() + 3); | 1206 std::vector<arc::mojom::AppInfo> apps2(apps.begin() + 1, apps.begin() + 3); |
(...skipping 12 matching lines...) Expand all Loading... | |
1211 | 1219 |
1212 app_instance()->SendPackageAppListRefreshed(apps[0].package_name, apps2); | 1220 app_instance()->SendPackageAppListRefreshed(apps[0].package_name, apps2); |
1213 ValidateHaveApps(apps2); | 1221 ValidateHaveApps(apps2); |
1214 | 1222 |
1215 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info_after = | 1223 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info_after = |
1216 prefs->GetApp(app_id); | 1224 prefs->GetApp(app_id); |
1217 ASSERT_TRUE(app_info_after); | 1225 ASSERT_TRUE(app_info_after); |
1218 EXPECT_EQ(now_time, app_info_after->last_launch_time); | 1226 EXPECT_EQ(now_time, app_info_after->last_launch_time); |
1219 } | 1227 } |
1220 | 1228 |
1221 TEST_F(ArcDefaulAppTest, DefaultApps) { | 1229 TEST_P(ArcDefaulAppTest, DefaultApps) { |
1222 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); | 1230 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); |
1223 ASSERT_NE(nullptr, prefs); | 1231 ASSERT_NE(nullptr, prefs); |
1224 | 1232 |
1225 ValidateHaveApps(fake_default_apps()); | 1233 ValidateHaveApps(fake_default_apps()); |
1226 | 1234 |
1227 // Start normal apps. We should have apps from 2 subsets. | 1235 // Start normal apps. We should have apps from 2 subsets. |
1228 app_instance()->RefreshAppList(); | 1236 app_instance()->RefreshAppList(); |
1229 app_instance()->SendRefreshAppList(fake_apps()); | 1237 app_instance()->SendRefreshAppList(fake_apps()); |
1230 | 1238 |
1231 std::vector<arc::mojom::AppInfo> all_apps = fake_default_apps(); | 1239 std::vector<arc::mojom::AppInfo> all_apps = fake_default_apps(); |
(...skipping 25 matching lines...) Expand all Loading... | |
1257 EXPECT_TRUE(app_info->ready); | 1265 EXPECT_TRUE(app_info->ready); |
1258 oem_states[app_id] = prefs->IsOem(app_id); | 1266 oem_states[app_id] = prefs->IsOem(app_id); |
1259 } | 1267 } |
1260 | 1268 |
1261 // Uninstall first default package. Default app should go away. | 1269 // Uninstall first default package. Default app should go away. |
1262 app_instance()->SendPackageUninstalled(all_apps[0].package_name); | 1270 app_instance()->SendPackageUninstalled(all_apps[0].package_name); |
1263 all_apps.erase(all_apps.begin()); | 1271 all_apps.erase(all_apps.begin()); |
1264 ValidateHaveApps(all_apps); | 1272 ValidateHaveApps(all_apps); |
1265 | 1273 |
1266 // OptOut and default apps should exist minus first. | 1274 // OptOut and default apps should exist minus first. |
1275 // TODO(victorhsieh): Opt-out on Persistent ARC is special. Skip until | |
1276 // implemented. | |
1277 if (arc::ShouldArcAlwaysStart()) | |
1278 return; | |
1267 arc::SetArcPlayStoreEnabledForProfile(profile(), false); | 1279 arc::SetArcPlayStoreEnabledForProfile(profile(), false); |
1268 all_apps = fake_default_apps(); | 1280 all_apps = fake_default_apps(); |
1269 all_apps.erase(all_apps.begin()); | 1281 all_apps.erase(all_apps.begin()); |
1270 ValidateHaveApps(all_apps); | 1282 ValidateHaveApps(all_apps); |
1271 | 1283 |
1272 // Sign-out and sign-in again. Removed default app should not appear. | 1284 // Sign-out and sign-in again. Removed default app should not appear. |
1273 arc_test()->TearDown(); | 1285 arc_test()->TearDown(); |
1274 ResetBuilder(); | 1286 ResetBuilder(); |
1275 ArcAppListPrefsFactory::GetInstance()->RecreateServiceInstanceForTesting( | 1287 ArcAppListPrefsFactory::GetInstance()->RecreateServiceInstanceForTesting( |
1276 profile_.get()); | 1288 profile_.get()); |
1277 arc_test()->SetUp(profile_.get()); | 1289 arc_test()->SetUp(profile_.get()); |
1278 CreateBuilder(); | 1290 CreateBuilder(); |
1279 | 1291 |
1280 // Prefs are changed. | 1292 // Prefs are changed. |
1281 prefs = ArcAppListPrefs::Get(profile_.get()); | 1293 prefs = ArcAppListPrefs::Get(profile_.get()); |
1282 ASSERT_NE(nullptr, prefs); | 1294 ASSERT_NE(nullptr, prefs); |
1283 | |
1284 ValidateHaveApps(all_apps); | 1295 ValidateHaveApps(all_apps); |
1285 | 1296 |
1286 // Install deleted default app again. | 1297 // Install deleted default app again. |
1287 std::vector<arc::mojom::AppInfo> package_apps; | 1298 std::vector<arc::mojom::AppInfo> package_apps; |
1288 package_apps.push_back(fake_default_apps()[0]); | 1299 package_apps.push_back(fake_default_apps()[0]); |
1289 app_instance()->SendPackageAppListRefreshed( | 1300 app_instance()->SendPackageAppListRefreshed( |
1290 fake_default_apps()[0].package_name, package_apps); | 1301 fake_default_apps()[0].package_name, package_apps); |
1291 ValidateHaveApps(fake_default_apps()); | 1302 ValidateHaveApps(fake_default_apps()); |
1292 | 1303 |
1293 // Validate that OEM state is preserved. | 1304 // Validate that OEM state is preserved. |
1294 for (const auto& default_app : fake_default_apps()) { | 1305 for (const auto& default_app : fake_default_apps()) { |
1295 const std::string app_id = ArcAppTest::GetAppId(default_app); | 1306 const std::string app_id = ArcAppTest::GetAppId(default_app); |
1296 EXPECT_EQ(oem_states[app_id], prefs->IsOem(app_id)); | 1307 EXPECT_EQ(oem_states[app_id], prefs->IsOem(app_id)); |
1297 } | 1308 } |
1298 } | 1309 } |
1299 | 1310 |
1300 TEST_F(ArcDefaulAppTest, DefaultAppsNotAvailable) { | 1311 TEST_P(ArcDefaulAppTest, DefaultAppsNotAvailable) { |
1301 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); | 1312 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); |
1302 ASSERT_NE(nullptr, prefs); | 1313 ASSERT_NE(nullptr, prefs); |
1303 | 1314 |
1304 ValidateHaveApps(fake_default_apps()); | 1315 ValidateHaveApps(fake_default_apps()); |
1305 | 1316 |
1306 const std::vector<arc::mojom::AppInfo> empty_app_list; | 1317 const std::vector<arc::mojom::AppInfo> empty_app_list; |
1307 | 1318 |
1308 app_instance()->RefreshAppList(); | 1319 app_instance()->RefreshAppList(); |
1309 app_instance()->SendRefreshAppList(empty_app_list); | 1320 app_instance()->SendRefreshAppList(empty_app_list); |
1310 | 1321 |
1311 ValidateHaveApps(fake_default_apps()); | 1322 ValidateHaveApps(fake_default_apps()); |
1312 | 1323 |
1313 prefs->SimulateDefaultAppAvailabilityTimeoutForTesting(); | 1324 prefs->SimulateDefaultAppAvailabilityTimeoutForTesting(); |
1314 | 1325 |
1315 // No default app installation and already installed packages. | 1326 // No default app installation and already installed packages. |
1316 ValidateHaveApps(empty_app_list); | 1327 ValidateHaveApps(empty_app_list); |
1317 } | 1328 } |
1318 | 1329 |
1319 TEST_F(ArcDefaulAppTest, DefaultAppsInstallation) { | 1330 TEST_P(ArcDefaulAppTest, DefaultAppsInstallation) { |
1320 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); | 1331 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get()); |
1321 ASSERT_NE(nullptr, prefs); | 1332 ASSERT_NE(nullptr, prefs); |
1322 | 1333 |
1323 const std::vector<arc::mojom::AppInfo> empty_app_list; | 1334 const std::vector<arc::mojom::AppInfo> empty_app_list; |
1324 | 1335 |
1325 ValidateHaveApps(fake_default_apps()); | 1336 ValidateHaveApps(fake_default_apps()); |
1326 | 1337 |
1327 app_instance()->RefreshAppList(); | 1338 app_instance()->RefreshAppList(); |
1328 app_instance()->SendRefreshAppList(empty_app_list); | 1339 app_instance()->SendRefreshAppList(empty_app_list); |
1329 | 1340 |
(...skipping 19 matching lines...) Expand all Loading... | |
1349 // completed. | 1360 // completed. |
1350 ValidateHaveApps(fake_default_apps()); | 1361 ValidateHaveApps(fake_default_apps()); |
1351 | 1362 |
1352 // Last default app installation failed. | 1363 // Last default app installation failed. |
1353 app_instance()->SendInstallationFinished(app_last.package_name, false); | 1364 app_instance()->SendInstallationFinished(app_last.package_name, false); |
1354 | 1365 |
1355 // We should have all default apps except last. | 1366 // We should have all default apps except last. |
1356 ValidateHaveApps(available_apps); | 1367 ValidateHaveApps(available_apps); |
1357 } | 1368 } |
1358 | 1369 |
1359 TEST_F(ArcDefaulAppForManagedUserTest, DefaultAppsForManagedUser) { | 1370 TEST_P(ArcDefaulAppForManagedUserTest, DefaultAppsForManagedUser) { |
1360 const ArcAppListPrefs* const prefs = ArcAppListPrefs::Get(profile_.get()); | 1371 const ArcAppListPrefs* const prefs = ArcAppListPrefs::Get(profile_.get()); |
1361 ASSERT_TRUE(prefs); | 1372 ASSERT_TRUE(prefs); |
1362 | 1373 |
1363 // There is no default app for managed users except Play Store | 1374 // There is no default app for managed users except Play Store |
1364 for (const auto& app : fake_default_apps()) { | 1375 for (const auto& app : fake_default_apps()) { |
1365 const std::string app_id = ArcAppTest::GetAppId(app); | 1376 const std::string app_id = ArcAppTest::GetAppId(app); |
1366 EXPECT_FALSE(prefs->IsRegistered(app_id)); | 1377 EXPECT_FALSE(prefs->IsRegistered(app_id)); |
1367 EXPECT_FALSE(prefs->GetApp(app_id)); | 1378 EXPECT_FALSE(prefs->GetApp(app_id)); |
1368 } | 1379 } |
1369 } | 1380 } |
1381 | |
1382 INSTANTIATE_TEST_CASE_P(, | |
Luis Héctor Chávez
2017/03/01 22:25:38
Given that you're not exhaustively going through a
victorhsieh
2017/03/02 00:28:12
Actually this is just one switch. Change to ::tes
Luis Héctor Chávez
2017/03/02 04:34:22
Ah! Misread that as those being the cases.
re: su
victorhsieh
2017/03/02 18:49:52
Ok, I also misread your comments :P Done.
| |
1383 ArcAppModelBuilderTest, | |
1384 ::testing::Values(false, true)); | |
1385 INSTANTIATE_TEST_CASE_P(, ArcDefaulAppTest, ::testing::Values(false, true)); | |
1386 INSTANTIATE_TEST_CASE_P(, | |
1387 ArcDefaulAppForManagedUserTest, | |
1388 ::testing::Values(false, true)); | |
1389 INSTANTIATE_TEST_CASE_P(, ArcPlayStoreAppTest, ::testing::Values(false, true)); | |
1390 INSTANTIATE_TEST_CASE_P(, | |
1391 ArcAppModelBuilderRecreate, | |
1392 ::testing::Values(false, true)); | |
OLD | NEW |