| Index: chrome/browser/ui/app_list/arc/arc_app_unittest.cc
|
| diff --git a/chrome/browser/ui/app_list/arc/arc_app_unittest.cc b/chrome/browser/ui/app_list/arc/arc_app_unittest.cc
|
| index 2f660845023e3af37d9342674a6b4a1335e20c52..464f81069778aa9327f11b8e0e460ac437372cca 100644
|
| --- a/chrome/browser/ui/app_list/arc/arc_app_unittest.cc
|
| +++ b/chrome/browser/ui/app_list/arc/arc_app_unittest.cc
|
| @@ -425,14 +425,31 @@ class ArcDefaulAppTest : public ArcAppModelBuilderTest {
|
| // ArcAppModelBuilderTest:
|
| void OnBeforeArcTestSetup() override {
|
| ArcDefaultAppList::UseTestAppsDirectory();
|
| + arc_test()->set_wait_default_apps(IsWaitDefaultAppsNeeded());
|
| arc::ArcPackageSyncableServiceFactory::GetInstance()->SetTestingFactory(
|
| profile_.get(), nullptr);
|
| }
|
|
|
| + // Returns true if test needs to wait for default apps on setup.
|
| + virtual bool IsWaitDefaultAppsNeeded() const { return true; }
|
| +
|
| private:
|
| DISALLOW_COPY_AND_ASSIGN(ArcDefaulAppTest);
|
| };
|
|
|
| +class ArcAppLauncherForDefaulAppTest : public ArcDefaulAppTest {
|
| + public:
|
| + ArcAppLauncherForDefaulAppTest() = default;
|
| + ~ArcAppLauncherForDefaulAppTest() override = default;
|
| +
|
| + protected:
|
| + // ArcDefaulAppTest:
|
| + bool IsWaitDefaultAppsNeeded() const override { return false; }
|
| +
|
| + private:
|
| + DISALLOW_COPY_AND_ASSIGN(ArcAppLauncherForDefaulAppTest);
|
| +};
|
| +
|
| class ArcPlayStoreAppTest : public ArcDefaulAppTest {
|
| public:
|
| ArcPlayStoreAppTest() = default;
|
| @@ -1202,11 +1219,11 @@ TEST_P(ArcAppModelBuilderTest, AppLauncher) {
|
| const std::string id2 = ArcAppTest::GetAppId(app2);
|
| const std::string id3 = ArcAppTest::GetAppId(app3);
|
|
|
| - ArcAppLauncher launcher1(profile(), id1, true);
|
| + ArcAppLauncher launcher1(profile(), id1, true, false);
|
| EXPECT_FALSE(launcher1.app_launched());
|
| EXPECT_TRUE(prefs->HasObserver(&launcher1));
|
|
|
| - ArcAppLauncher launcher3(profile(), id3, true);
|
| + ArcAppLauncher launcher3(profile(), id3, true, false);
|
| EXPECT_FALSE(launcher1.app_launched());
|
| EXPECT_TRUE(prefs->HasObserver(&launcher1));
|
| EXPECT_FALSE(launcher3.app_launched());
|
| @@ -1225,7 +1242,7 @@ TEST_P(ArcAppModelBuilderTest, AppLauncher) {
|
| EXPECT_FALSE(prefs->HasObserver(&launcher1));
|
| EXPECT_TRUE(prefs->HasObserver(&launcher3));
|
|
|
| - ArcAppLauncher launcher2(profile(), id2, true);
|
| + ArcAppLauncher launcher2(profile(), id2, true, false);
|
| EXPECT_TRUE(launcher2.app_launched());
|
| EXPECT_FALSE(prefs->HasObserver(&launcher2));
|
| ASSERT_EQ(2u, app_instance()->launch_requests().size());
|
| @@ -1370,6 +1387,37 @@ TEST_P(ArcDefaulAppTest, DefaultApps) {
|
| }
|
| }
|
|
|
| +TEST_P(ArcAppLauncherForDefaulAppTest, AppLauncherForDefaultApps) {
|
| + ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get());
|
| + ASSERT_NE(nullptr, prefs);
|
| +
|
| + ASSERT_GE(fake_default_apps().size(), 2U);
|
| + const arc::mojom::AppInfo& app1 = fake_default_apps()[0];
|
| + const arc::mojom::AppInfo& app2 = fake_default_apps()[1];
|
| + const std::string id1 = ArcAppTest::GetAppId(app1);
|
| + const std::string id2 = ArcAppTest::GetAppId(app2);
|
| +
|
| + // Launch when app is registered and ready.
|
| + ArcAppLauncher launcher1(profile(), id1, true, false);
|
| + // Launch when app is registered.
|
| + ArcAppLauncher launcher2(profile(), id2, true, true);
|
| +
|
| + EXPECT_FALSE(launcher1.app_launched());
|
| + EXPECT_FALSE(launcher2.app_launched());
|
| +
|
| + arc_test()->WaitForDefaultApps();
|
| +
|
| + // Only second app is expected to be launched.
|
| + EXPECT_FALSE(launcher1.app_launched());
|
| + EXPECT_TRUE(launcher2.app_launched());
|
| +
|
| + app_instance()->RefreshAppList();
|
| + app_instance()->SendRefreshAppList(fake_default_apps());
|
| + // Default apps are ready now and it is expected that first app was launched
|
| + // now.
|
| + EXPECT_TRUE(launcher1.app_launched());
|
| +}
|
| +
|
| TEST_P(ArcDefaulAppTest, DefaultAppsNotAvailable) {
|
| ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get());
|
| ASSERT_NE(nullptr, prefs);
|
| @@ -1459,6 +1507,9 @@ INSTANTIATE_TEST_CASE_P(,
|
| ArcDefaulAppTest,
|
| ::testing::ValuesIn(kUnmanagedArcStates));
|
| INSTANTIATE_TEST_CASE_P(,
|
| + ArcAppLauncherForDefaulAppTest,
|
| + ::testing::ValuesIn(kUnmanagedArcStates));
|
| +INSTANTIATE_TEST_CASE_P(,
|
| ArcDefaulAppForManagedUserTest,
|
| ::testing::ValuesIn(kManagedArcStates));
|
| INSTANTIATE_TEST_CASE_P(,
|
|
|