Commit 826c05aa authored by Nigel Tao's avatar Nigel Tao Committed by Commit Bot

Clean up SimulatePreviouslyInstalledApp

N SimulateEtc methods were replaced with 1 method.

Change-Id: I0b9b0701959de1cbc0c8b273cd5f59a929766de7
Reviewed-on: https://chromium-review.googlesource.com/1208990Reviewed-by: default avatarGiovanni Ortuño Urquidi <ortuno@chromium.org>
Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Commit-Queue: Nigel Tao <nigeltao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#589429}
parent bed2a3f6
...@@ -92,29 +92,20 @@ class WebAppPolicyManagerTest : public ChromeRenderViewHostTestHarness { ...@@ -92,29 +92,20 @@ class WebAppPolicyManagerTest : public ChromeRenderViewHostTestHarness {
web_app::WebAppProvider::Get(profile())->Reset(); web_app::WebAppProvider::Get(profile())->Reset();
} }
// TODO(nigeltao): replace the N SimulateEtc methods with 1 method, that void SimulatePreviouslyInstalledApp(GURL url,
// derives the extensions::Manifest::Location from app_info.install_source. extensions::Manifest::Location location) {
void SimulatePreviouslyInstalledApp(PendingAppManager::AppInfo app_info,
extensions::Manifest::Location location =
extensions::Manifest::INTERNAL) {
scoped_refptr<extensions::Extension> extension = scoped_refptr<extensions::Extension> extension =
extensions::ExtensionBuilder("Dummy Name") extensions::ExtensionBuilder("Dummy Name")
.SetLocation(location) .SetLocation(location)
.SetID(crx_file::id_util::GenerateId("fake_app_id_for:" + .SetID(
app_info.url.spec())) crx_file::id_util::GenerateId("fake_app_id_for:" + url.spec()))
.Build(); .Build();
extensions::ExtensionRegistry* registry = extensions::ExtensionRegistry* registry =
extensions::ExtensionRegistry::Get(profile()); extensions::ExtensionRegistry::Get(profile());
registry->AddEnabled(extension); registry->AddEnabled(extension);
ExtensionIdsMap extension_ids_map(profile()->GetPrefs()); ExtensionIdsMap extension_ids_map(profile()->GetPrefs());
extension_ids_map.Insert(app_info.url, extension->id()); extension_ids_map.Insert(url, extension->id());
}
void SimulatePreviouslyInstalledPolicyApp(
PendingAppManager::AppInfo app_info) {
SimulatePreviouslyInstalledApp(
std::move(app_info), extensions::Manifest::EXTERNAL_POLICY_DOWNLOAD);
} }
private: private:
...@@ -216,9 +207,12 @@ TEST_F(WebAppPolicyManagerTest, DynamicRefresh) { ...@@ -216,9 +207,12 @@ TEST_F(WebAppPolicyManagerTest, DynamicRefresh) {
TEST_F(WebAppPolicyManagerTest, UninstallAppInstalledInPreviousSession) { TEST_F(WebAppPolicyManagerTest, UninstallAppInstalledInPreviousSession) {
// Simulate two policy apps and a regular app that were installed in the // Simulate two policy apps and a regular app that were installed in the
// previous session. // previous session.
SimulatePreviouslyInstalledPolicyApp(GetWindowedAppInfo()); SimulatePreviouslyInstalledApp(
SimulatePreviouslyInstalledPolicyApp(GetTabbedAppInfo()); GURL(kWindowedUrl), extensions::Manifest::EXTERNAL_POLICY_DOWNLOAD);
SimulatePreviouslyInstalledApp(GetDefaultContainerAppInfo()); SimulatePreviouslyInstalledApp(
GURL(kTabbedUrl), extensions::Manifest::EXTERNAL_POLICY_DOWNLOAD);
SimulatePreviouslyInstalledApp(GURL(kDefaultContainerUrl),
extensions::Manifest::INTERNAL);
// Push a policy with only one of the apps. // Push a policy with only one of the apps.
base::Value first_list(base::Value::Type::LIST); base::Value first_list(base::Value::Type::LIST);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment