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

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

Issue 2781623005: [Merge M58] arg: Enable Play Store item in App Launcher for managed case. (Closed)
Patch Set: fix merge conflicts / unit tests passed / manually tested on device 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
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 902018e89c06ae999b8478e0d260142a4b7d99eb..c3ecc2377ac367dee3f158d3cc2e749a881ebb42 100644
--- a/chrome/browser/ui/app_list/arc/arc_app_unittest.cc
+++ b/chrome/browser/ui/app_list/arc/arc_app_unittest.cc
@@ -21,9 +21,9 @@
#include "chrome/browser/chromeos/arc/arc_support_host.h"
#include "chrome/browser/chromeos/arc/arc_util.h"
#include "chrome/browser/extensions/extension_service.h"
+#include "chrome/browser/extensions/extension_service_test_base.h"
#include "chrome/browser/policy/profile_policy_connector.h"
#include "chrome/browser/policy/profile_policy_connector_factory.h"
-#include "chrome/browser/ui/app_list/app_list_test_util.h"
#include "chrome/browser/ui/app_list/arc/arc_app_icon.h"
#include "chrome/browser/ui/app_list/arc/arc_app_icon_loader.h"
#include "chrome/browser/ui/app_list/arc/arc_app_item.h"
@@ -37,8 +37,10 @@
#include "chrome/browser/ui/app_list/arc/arc_package_syncable_service_factory.h"
#include "chrome/browser/ui/app_list/test/test_app_list_controller_delegate.h"
#include "chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.h"
+#include "chrome/common/pref_names.h"
#include "chrome/test/base/testing_profile.h"
#include "components/arc/test/fake_app_instance.h"
+#include "components/sync_preferences/testing_pref_service_syncable.h"
#include "content/public/browser/browser_thread.h"
#include "extensions/browser/extension_system.h"
#include "extensions/common/extension.h"
@@ -92,9 +94,28 @@ void WaitForIconReady(ArcAppListPrefs* prefs,
} while (!base::PathExists(icon_path));
}
+enum class ArcState {
+ // By default, ARC is non-persistent and Play Store is unmanaged.
+ ARC_PLAY_STORE_UNMANAGED,
+ // ARC is non-persistent and Play Store is managed and enabled.
+ ARC_PLAY_STORE_MANAGED_AND_ENABLED,
+ // ARC is non-persistent and Play Store is managed and disabled.
+ ARC_PLAY_STORE_MANAGED_AND_DISABLED,
+};
+
+constexpr ArcState kManagedArcStates[] = {
+ ArcState::ARC_PLAY_STORE_MANAGED_AND_ENABLED,
+ ArcState::ARC_PLAY_STORE_MANAGED_AND_DISABLED,
+};
+
+constexpr ArcState kUnmanagedArcStates[] = {
+ ArcState::ARC_PLAY_STORE_UNMANAGED,
+};
+
} // namespace
-class ArcAppModelBuilderTest : public AppListTestBase {
+class ArcAppModelBuilderTest : public extensions::ExtensionServiceTestBase,
+ public ::testing::WithParamInterface<ArcState> {
public:
ArcAppModelBuilderTest() = default;
~ArcAppModelBuilderTest() override {
@@ -103,7 +124,17 @@ class ArcAppModelBuilderTest : public AppListTestBase {
}
void SetUp() override {
- AppListTestBase::SetUp();
+ extensions::ExtensionServiceTestBase::SetUp();
+ InitializeExtensionService(ExtensionServiceInitParams());
+ service_->Init();
+ // ExtensionService needs a real I/O thread.
+ service_->SetFileTaskRunnerForTesting(
+ content::BrowserThread::GetBlockingPool()
+ ->GetSequencedTaskRunnerWithShutdownBehavior(
+ content::BrowserThread::GetBlockingPool()
+ ->GetNamedSequenceToken("ext_install-"),
+ base::SequencedWorkerPool::SKIP_ON_SHUTDOWN));
+
OnBeforeArcTestSetup();
arc_test_.SetUp(profile_.get());
CreateBuilder();
@@ -340,7 +371,7 @@ class ArcAppModelBuilderTest : public AppListTestBase {
AppListControllerDelegate* controller() { return controller_.get(); }
- Profile* profile() { return profile_.get(); }
+ TestingProfile* profile() { return profile_.get(); }
ArcAppTest* arc_test() { return &arc_test_; }
@@ -390,26 +421,6 @@ class ArcDefaulAppTest : public ArcAppModelBuilderTest {
DISALLOW_COPY_AND_ASSIGN(ArcDefaulAppTest);
};
-class ArcDefaulAppForManagedUserTest : public ArcDefaulAppTest {
- public:
- ArcDefaulAppForManagedUserTest() = default;
- ~ArcDefaulAppForManagedUserTest() override = default;
-
- protected:
- // ArcAppModelBuilderTest:
- void OnBeforeArcTestSetup() override {
- ArcDefaulAppTest::OnBeforeArcTestSetup();
-
- policy::ProfilePolicyConnector* const connector =
- policy::ProfilePolicyConnectorFactory::GetForBrowserContext(
- profile());
- connector->OverrideIsManagedForTesting(true);
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(ArcDefaulAppForManagedUserTest);
-};
-
class ArcPlayStoreAppTest : public ArcDefaulAppTest {
public:
ArcPlayStoreAppTest() = default;
@@ -445,6 +456,39 @@ class ArcPlayStoreAppTest : public ArcDefaulAppTest {
DISALLOW_COPY_AND_ASSIGN(ArcPlayStoreAppTest);
};
+class ArcDefaulAppForManagedUserTest : public ArcPlayStoreAppTest {
+ public:
+ ArcDefaulAppForManagedUserTest() = default;
+ ~ArcDefaulAppForManagedUserTest() override = default;
+
+ protected:
+ bool IsEnabledByPolicy() const {
+ switch (GetParam()) {
+ case ArcState::ARC_PLAY_STORE_MANAGED_AND_ENABLED:
+ return true;
+ case ArcState::ARC_PLAY_STORE_MANAGED_AND_DISABLED:
+ return false;
+ default:
+ NOTREACHED();
+ return false;
+ }
+ }
+
+ // ArcPlayStoreAppTest:
+ void OnBeforeArcTestSetup() override {
+ policy::ProfilePolicyConnector* const connector =
+ policy::ProfilePolicyConnectorFactory::GetForBrowserContext(profile());
+ connector->OverrideIsManagedForTesting(true);
+ profile()->GetTestingPrefService()->SetManagedPref(
+ prefs::kArcEnabled, new base::Value(IsEnabledByPolicy()));
+
+ ArcPlayStoreAppTest::OnBeforeArcTestSetup();
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ArcDefaulAppForManagedUserTest);
+};
+
class ArcAppModelBuilderRecreate : public ArcAppModelBuilderTest {
public:
ArcAppModelBuilderRecreate() = default;
@@ -461,7 +505,7 @@ class ArcAppModelBuilderRecreate : public ArcAppModelBuilderTest {
DISALLOW_COPY_AND_ASSIGN(ArcAppModelBuilderRecreate);
};
-TEST_F(ArcAppModelBuilderTest, ArcPackagePref) {
+TEST_P(ArcAppModelBuilderTest, ArcPackagePref) {
ValidateHavePackages(std::vector<arc::mojom::ArcPackageInfo>());
app_instance()->SendRefreshPackageList(fake_packages());
ValidateHavePackages(fake_packages());
@@ -482,7 +526,7 @@ TEST_F(ArcAppModelBuilderTest, ArcPackagePref) {
ValidateHavePackages(fake_packages());
}
-TEST_F(ArcAppModelBuilderTest, RefreshAllOnReady) {
+TEST_P(ArcAppModelBuilderTest, RefreshAllOnReady) {
// There should already have been one call, when the interface was
// registered.
EXPECT_EQ(1, app_instance()->refresh_app_list_count());
@@ -490,21 +534,21 @@ TEST_F(ArcAppModelBuilderTest, RefreshAllOnReady) {
EXPECT_EQ(2, app_instance()->refresh_app_list_count());
}
-TEST_F(ArcAppModelBuilderTest, RefreshAllFillsContent) {
+TEST_P(ArcAppModelBuilderTest, RefreshAllFillsContent) {
ValidateHaveApps(std::vector<arc::mojom::AppInfo>());
app_instance()->RefreshAppList();
app_instance()->SendRefreshAppList(fake_apps());
ValidateHaveApps(fake_apps());
}
-TEST_F(ArcAppModelBuilderTest, InstallShortcut) {
+TEST_P(ArcAppModelBuilderTest, InstallShortcut) {
ValidateHaveApps(std::vector<arc::mojom::AppInfo>());
app_instance()->SendInstallShortcuts(fake_shortcuts());
ValidateHaveShortcuts(fake_shortcuts());
}
-TEST_F(ArcAppModelBuilderTest, RefreshAllPreservesShortcut) {
+TEST_P(ArcAppModelBuilderTest, RefreshAllPreservesShortcut) {
ValidateHaveApps(std::vector<arc::mojom::AppInfo>());
app_instance()->RefreshAppList();
app_instance()->SendRefreshAppList(fake_apps());
@@ -518,7 +562,7 @@ TEST_F(ArcAppModelBuilderTest, RefreshAllPreservesShortcut) {
ValidateHaveAppsAndShortcuts(fake_apps(), fake_shortcuts());
}
-TEST_F(ArcAppModelBuilderTest, MultipleRefreshAll) {
+TEST_P(ArcAppModelBuilderTest, MultipleRefreshAll) {
ValidateHaveApps(std::vector<arc::mojom::AppInfo>());
app_instance()->RefreshAppList();
// Send info about all fake apps except last.
@@ -550,7 +594,7 @@ TEST_F(ArcAppModelBuilderTest, MultipleRefreshAll) {
ValidateHaveApps(no_apps);
}
-TEST_F(ArcAppModelBuilderTest, StopStartServicePreserveApps) {
+TEST_P(ArcAppModelBuilderTest, StopStartServicePreserveApps) {
ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get());
ASSERT_NE(nullptr, prefs);
@@ -579,7 +623,7 @@ TEST_F(ArcAppModelBuilderTest, StopStartServicePreserveApps) {
ValidateAppReadyState(fake_apps(), true);
}
-TEST_F(ArcAppModelBuilderTest, StopStartServicePreserveShortcuts) {
+TEST_P(ArcAppModelBuilderTest, StopStartServicePreserveShortcuts) {
ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get());
ASSERT_NE(nullptr, prefs);
@@ -609,7 +653,7 @@ TEST_F(ArcAppModelBuilderTest, StopStartServicePreserveShortcuts) {
ValidateShortcutReadyState(fake_shortcuts(), true);
}
-TEST_F(ArcAppModelBuilderTest, RestartPreserveApps) {
+TEST_P(ArcAppModelBuilderTest, RestartPreserveApps) {
ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get());
ASSERT_NE(nullptr, prefs);
@@ -625,7 +669,7 @@ TEST_F(ArcAppModelBuilderTest, RestartPreserveApps) {
ValidateAppReadyState(fake_apps(), false);
}
-TEST_F(ArcAppModelBuilderTest, RestartPreserveShortcuts) {
+TEST_P(ArcAppModelBuilderTest, RestartPreserveShortcuts) {
ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get());
ASSERT_NE(nullptr, prefs);
@@ -641,7 +685,7 @@ TEST_F(ArcAppModelBuilderTest, RestartPreserveShortcuts) {
ValidateShortcutReadyState(fake_shortcuts(), false);
}
-TEST_F(ArcAppModelBuilderTest, LaunchApps) {
+TEST_P(ArcAppModelBuilderTest, LaunchApps) {
// Disable attempts to dismiss app launcher view.
ChromeAppListItem::OverrideAppListControllerDelegateForTesting(controller());
@@ -677,7 +721,7 @@ TEST_F(ArcAppModelBuilderTest, LaunchApps) {
app_instance()->launch_requests().size());
}
-TEST_F(ArcAppModelBuilderTest, LaunchShortcuts) {
+TEST_P(ArcAppModelBuilderTest, LaunchShortcuts) {
// Disable attempts to dismiss app launcher view.
ChromeAppListItem::OverrideAppListControllerDelegateForTesting(controller());
@@ -713,7 +757,7 @@ TEST_F(ArcAppModelBuilderTest, LaunchShortcuts) {
app_instance()->launch_intents().size());
}
-TEST_F(ArcAppModelBuilderTest, RequestIcons) {
+TEST_P(ArcAppModelBuilderTest, RequestIcons) {
// Make sure we are on UI thread.
ASSERT_TRUE(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
@@ -768,7 +812,7 @@ TEST_F(ArcAppModelBuilderTest, RequestIcons) {
}
}
-TEST_F(ArcAppModelBuilderTest, RequestShortcutIcons) {
+TEST_P(ArcAppModelBuilderTest, RequestShortcutIcons) {
// Make sure we are on UI thread.
ASSERT_TRUE(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
@@ -821,7 +865,7 @@ TEST_F(ArcAppModelBuilderTest, RequestShortcutIcons) {
}
}
-TEST_F(ArcAppModelBuilderTest, InstallIcon) {
+TEST_P(ArcAppModelBuilderTest, InstallIcon) {
// Make sure we are on UI thread.
ASSERT_TRUE(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
@@ -860,7 +904,7 @@ TEST_F(ArcAppModelBuilderTest, InstallIcon) {
ASSERT_EQ(icon_data, png_data);
}
-TEST_F(ArcAppModelBuilderTest, RemoveAppCleanUpFolder) {
+TEST_P(ArcAppModelBuilderTest, RemoveAppCleanUpFolder) {
// Make sure we are on UI thread.
ASSERT_TRUE(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
@@ -900,7 +944,7 @@ TEST_F(ArcAppModelBuilderTest, RemoveAppCleanUpFolder) {
EXPECT_FALSE(base::PathExists(app_path));
}
-TEST_F(ArcAppModelBuilderTest, LastLaunchTime) {
+TEST_P(ArcAppModelBuilderTest, LastLaunchTime) {
// Make sure we are on UI thread.
ASSERT_TRUE(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
@@ -944,7 +988,7 @@ TEST_F(ArcAppModelBuilderTest, LastLaunchTime) {
}
// Validate that arc model contains expected elements on restart.
-TEST_F(ArcAppModelBuilderRecreate, AppModelRestart) {
+TEST_P(ArcAppModelBuilderRecreate, AppModelRestart) {
// No apps on initial start.
ValidateHaveApps(std::vector<arc::mojom::AppInfo>());
@@ -977,7 +1021,7 @@ TEST_F(ArcAppModelBuilderRecreate, AppModelRestart) {
EXPECT_EQ(fake_apps().size(), GetArcItemCount());
}
-TEST_F(ArcPlayStoreAppTest, PlayStore) {
+TEST_P(ArcPlayStoreAppTest, PlayStore) {
// Make sure PlayStore is available.
ASSERT_TRUE(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
@@ -1015,7 +1059,7 @@ TEST_F(ArcPlayStoreAppTest, PlayStore) {
}
// Test that icon is correctly extracted for shelf group.
-TEST_F(ArcAppModelBuilderTest, IconLoaderForShelfGroup) {
+TEST_P(ArcAppModelBuilderTest, IconLoaderForShelfGroup) {
const arc::mojom::AppInfo& app = fake_apps()[0];
const std::string app_id = ArcAppTest::GetAppId(app);
@@ -1088,7 +1132,7 @@ TEST_F(ArcAppModelBuilderTest, IconLoaderForShelfGroup) {
// If the cached icon file is corrupted, we expect send request to ARC for a new
// icon.
-TEST_F(ArcAppModelBuilderTest, IconLoaderWithBadIcon) {
+TEST_P(ArcAppModelBuilderTest, IconLoaderWithBadIcon) {
const arc::mojom::AppInfo& app = fake_apps()[0];
const std::string app_id = ArcAppTest::GetAppId(app);
@@ -1145,7 +1189,7 @@ TEST_F(ArcAppModelBuilderTest, IconLoaderWithBadIcon) {
}
// TODO(crbug.com/628425) -- reenable once this test is less flaky.
-TEST_F(ArcAppModelBuilderTest, DISABLED_IconLoader) {
+TEST_P(ArcAppModelBuilderTest, DISABLED_IconLoader) {
const arc::mojom::AppInfo& app = fake_apps()[0];
const std::string app_id = ArcAppTest::GetAppId(app);
@@ -1187,7 +1231,7 @@ TEST_F(ArcAppModelBuilderTest, DISABLED_IconLoader) {
ValidateIcon(delegate.image());
}
-TEST_F(ArcAppModelBuilderTest, AppLauncher) {
+TEST_P(ArcAppModelBuilderTest, AppLauncher) {
ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile());
ASSERT_NE(nullptr, prefs);
@@ -1232,7 +1276,7 @@ TEST_F(ArcAppModelBuilderTest, AppLauncher) {
}
// Validates an app that have no launchable flag.
-TEST_F(ArcAppModelBuilderTest, NonLaunchableApp) {
+TEST_P(ArcAppModelBuilderTest, NonLaunchableApp) {
ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get());
ASSERT_NE(nullptr, prefs);
@@ -1254,7 +1298,7 @@ TEST_F(ArcAppModelBuilderTest, NonLaunchableApp) {
EXPECT_TRUE(prefs->IsRegistered(app_id));
}
-TEST_F(ArcAppModelBuilderTest, ArcAppsOnPackageUpdated) {
+TEST_P(ArcAppModelBuilderTest, ArcAppsOnPackageUpdated) {
ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get());
ASSERT_NE(nullptr, prefs);
@@ -1287,7 +1331,7 @@ TEST_F(ArcAppModelBuilderTest, ArcAppsOnPackageUpdated) {
EXPECT_EQ(now_time, app_info_after->last_launch_time);
}
-TEST_F(ArcDefaulAppTest, DefaultApps) {
+TEST_P(ArcDefaulAppTest, DefaultApps) {
ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get());
ASSERT_NE(nullptr, prefs);
@@ -1366,7 +1410,7 @@ TEST_F(ArcDefaulAppTest, DefaultApps) {
}
}
-TEST_F(ArcDefaulAppTest, DefaultAppsNotAvailable) {
+TEST_P(ArcDefaulAppTest, DefaultAppsNotAvailable) {
ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get());
ASSERT_NE(nullptr, prefs);
@@ -1385,7 +1429,7 @@ TEST_F(ArcDefaulAppTest, DefaultAppsNotAvailable) {
ValidateHaveApps(empty_app_list);
}
-TEST_F(ArcDefaulAppTest, DefaultAppsInstallation) {
+TEST_P(ArcDefaulAppTest, DefaultAppsInstallation) {
ArcAppListPrefs* prefs = ArcAppListPrefs::Get(profile_.get());
ASSERT_NE(nullptr, prefs);
@@ -1425,7 +1469,7 @@ TEST_F(ArcDefaulAppTest, DefaultAppsInstallation) {
ValidateHaveApps(available_apps);
}
-TEST_F(ArcDefaulAppForManagedUserTest, DefaultAppsForManagedUser) {
+TEST_P(ArcDefaulAppForManagedUserTest, DefaultAppsForManagedUser) {
const ArcAppListPrefs* const prefs = ArcAppListPrefs::Get(profile_.get());
ASSERT_TRUE(prefs);
@@ -1435,4 +1479,31 @@ TEST_F(ArcDefaulAppForManagedUserTest, DefaultAppsForManagedUser) {
EXPECT_FALSE(prefs->IsRegistered(app_id));
EXPECT_FALSE(prefs->GetApp(app_id));
}
+
+ // PlayStor exists for managed and enabled state.
+ std::unique_ptr<ArcAppListPrefs::AppInfo> app_info =
+ prefs->GetApp(arc::kPlayStoreAppId);
+ if (IsEnabledByPolicy()) {
+ ASSERT_TRUE(app_info);
+ EXPECT_FALSE(app_info->ready);
+ } else {
+ EXPECT_FALSE(prefs->IsRegistered(arc::kPlayStoreAppId));
+ EXPECT_FALSE(app_info);
+ }
}
+
+INSTANTIATE_TEST_CASE_P(,
+ ArcAppModelBuilderTest,
+ ::testing::ValuesIn(kUnmanagedArcStates));
+INSTANTIATE_TEST_CASE_P(,
+ ArcDefaulAppTest,
+ ::testing::ValuesIn(kUnmanagedArcStates));
+INSTANTIATE_TEST_CASE_P(,
+ ArcDefaulAppForManagedUserTest,
+ ::testing::ValuesIn(kManagedArcStates));
+INSTANTIATE_TEST_CASE_P(,
+ ArcPlayStoreAppTest,
+ ::testing::ValuesIn(kUnmanagedArcStates));
+INSTANTIATE_TEST_CASE_P(,
+ ArcAppModelBuilderRecreate,
+ ::testing::ValuesIn(kUnmanagedArcStates));
« no previous file with comments | « chrome/browser/ui/app_list/arc/arc_app_list_prefs.cc ('k') | chrome/browser/ui/app_list/arc/arc_default_app_list.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698