Chromium Code Reviews| 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..88bc90197c6891ff7e1b6ac7c6d4cbd57799f9eb 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(IsNeedWaitDefaultApps()); |
| arc::ArcPackageSyncableServiceFactory::GetInstance()->SetTestingFactory( |
| profile_.get(), nullptr); |
| } |
| + // Returns true if test needs to wait for default apps on setup. |
| + virtual bool IsNeedWaitDefaultApps() const { return true; } |
|
hidehiko
2017/03/16 16:23:19
nit: IsWaitDefaultAppsNeeded() looks more common p
khmel
2017/03/16 16:38:47
Done.
|
| + |
| private: |
| DISALLOW_COPY_AND_ASSIGN(ArcDefaulAppTest); |
| }; |
| +class ArcAppLauncherForDefaulAppTest : public ArcDefaulAppTest { |
| + public: |
| + ArcAppLauncherForDefaulAppTest() = default; |
| + ~ArcAppLauncherForDefaulAppTest() override = default; |
| + |
| + protected: |
| + // ArcDefaulAppTest: |
| + bool IsNeedWaitDefaultApps() 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()); |
| @@ -1366,10 +1383,43 @@ TEST_P(ArcDefaulAppTest, DefaultApps) { |
| // Validate that OEM state is preserved. |
| for (const auto& default_app : fake_default_apps()) { |
| const std::string app_id = ArcAppTest::GetAppId(default_app); |
| + printf("#### %s %d %d\n", app_id.c_str(), oem_states[app_id], |
|
hidehiko
2017/03/16 16:23:19
Looks debugging purpose? Could you remove?
khmel
2017/03/16 16:38:47
Hmm, why git cl upload did not catch this? Done
|
| + prefs->IsOem(app_id)); |
| EXPECT_EQ(oem_states[app_id], prefs->IsOem(app_id)); |
| } |
| } |
| +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 +1509,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(, |