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

Unified Diff: chrome/browser/ui/app_list/arc/arc_app_unittest.cc

Issue 2751913004: arc: Fix race conditon when Play Store is started too early. (Closed)
Patch Set: nits Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
« 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.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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(,
« 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.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698