Commit 0383ff94 authored by Giovanni Ortuño Urquidi's avatar Giovanni Ortuño Urquidi Committed by Commit Bot

desktop-pwas: Minor PendingBookmarkAppManager unittest cleanup

Adds a helper method to initialize a PendingBookmarkAppManager with
test factories.

Bug: 864904
Change-Id: Ibdaaa1d43455f19979db3cd29429844b8c661598
Reviewed-on: https://chromium-review.googlesource.com/1176881Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Commit-Queue: Giovanni Ortuño Urquidi <ortuno@chromium.org>
Cr-Commit-Position: refs/heads/master@{#583509}
parent 90dea8d4
......@@ -140,6 +140,14 @@ class PendingBookmarkAppManagerTest : public ChromeRenderViewHostTestHarness {
return failing_installation_task_creator_;
}
std::unique_ptr<PendingBookmarkAppManager>
GetPendingBookmarkAppManagerWithTestFactories() {
auto manager = std::make_unique<PendingBookmarkAppManager>(profile());
manager->SetFactoriesForTesting(test_web_contents_creator(),
successful_installation_task_creator());
return manager;
}
content::WebContentsTester* web_contents_tester() {
return web_contents_tester_;
}
......@@ -161,11 +169,8 @@ class PendingBookmarkAppManagerTest : public ChromeRenderViewHostTestHarness {
};
TEST_F(PendingBookmarkAppManagerTest, Install_Succeeds) {
PendingBookmarkAppManager pending_app_manager(profile());
pending_app_manager.SetFactoriesForTesting(
test_web_contents_creator(), successful_installation_task_creator());
pending_app_manager.Install(
auto pending_app_manager = GetPendingBookmarkAppManagerWithTestFactories();
pending_app_manager->Install(
GetFooAppInfo(),
base::BindOnce(&PendingBookmarkAppManagerTest::InstallCallback,
base::Unretained(this)));
......@@ -178,11 +183,8 @@ TEST_F(PendingBookmarkAppManagerTest, Install_Succeeds) {
}
TEST_F(PendingBookmarkAppManagerTest, Install_SucceedsTwice) {
PendingBookmarkAppManager pending_app_manager(profile());
pending_app_manager.SetFactoriesForTesting(
test_web_contents_creator(), successful_installation_task_creator());
pending_app_manager.Install(
auto pending_app_manager = GetPendingBookmarkAppManagerWithTestFactories();
pending_app_manager->Install(
GetFooAppInfo(),
base::BindOnce(&PendingBookmarkAppManagerTest::InstallCallback,
base::Unretained(this)));
......@@ -194,7 +196,7 @@ TEST_F(PendingBookmarkAppManagerTest, Install_SucceedsTwice) {
EXPECT_EQ(GURL(kFooWebAppUrl), install_callback_url());
ResetResults();
pending_app_manager.Install(
pending_app_manager->Install(
GetBarAppInfo(),
base::BindOnce(&PendingBookmarkAppManagerTest::InstallCallback,
base::Unretained(this)));
......@@ -207,15 +209,12 @@ TEST_F(PendingBookmarkAppManagerTest, Install_SucceedsTwice) {
}
TEST_F(PendingBookmarkAppManagerTest, Install_PendingSuccessfulTask) {
PendingBookmarkAppManager pending_app_manager(profile());
pending_app_manager.SetFactoriesForTesting(
test_web_contents_creator(), successful_installation_task_creator());
pending_app_manager.Install(
auto pending_app_manager = GetPendingBookmarkAppManagerWithTestFactories();
pending_app_manager->Install(
GetFooAppInfo(),
base::BindOnce(&PendingBookmarkAppManagerTest::InstallCallback,
base::Unretained(this)));
pending_app_manager.Install(
pending_app_manager->Install(
GetBarAppInfo(),
base::BindOnce(&PendingBookmarkAppManagerTest::InstallCallback,
base::Unretained(this)));
......@@ -237,15 +236,12 @@ TEST_F(PendingBookmarkAppManagerTest, Install_PendingSuccessfulTask) {
}
TEST_F(PendingBookmarkAppManagerTest, Install_PendingFailingTask) {
PendingBookmarkAppManager pending_app_manager(profile());
pending_app_manager.SetFactoriesForTesting(
test_web_contents_creator(), successful_installation_task_creator());
pending_app_manager.Install(
auto pending_app_manager = GetPendingBookmarkAppManagerWithTestFactories();
pending_app_manager->Install(
GetFooAppInfo(),
base::BindOnce(&PendingBookmarkAppManagerTest::InstallCallback,
base::Unretained(this)));
pending_app_manager.Install(
pending_app_manager->Install(
GetBarAppInfo(),
base::BindOnce(&PendingBookmarkAppManagerTest::InstallCallback,
base::Unretained(this)));
......@@ -267,17 +263,14 @@ TEST_F(PendingBookmarkAppManagerTest, Install_PendingFailingTask) {
}
TEST_F(PendingBookmarkAppManagerTest, Install_ReentrantCallback) {
PendingBookmarkAppManager pending_app_manager(profile());
pending_app_manager.SetFactoriesForTesting(
test_web_contents_creator(), successful_installation_task_creator());
auto pending_app_manager = GetPendingBookmarkAppManagerWithTestFactories();
// Call install with a callback that tries to install another app.
pending_app_manager.Install(
pending_app_manager->Install(
GetFooAppInfo(),
base::BindLambdaForTesting([&](const GURL& provided_url,
const std::string& app_id) {
base::BindLambdaForTesting(
[&](const GURL& provided_url, const std::string& app_id) {
InstallCallback(provided_url, app_id);
pending_app_manager.Install(
pending_app_manager->Install(
GetBarAppInfo(),
base::BindOnce(&PendingBookmarkAppManagerTest::InstallCallback,
base::Unretained(this)));
......@@ -298,16 +291,13 @@ TEST_F(PendingBookmarkAppManagerTest, Install_ReentrantCallback) {
}
TEST_F(PendingBookmarkAppManagerTest, Install_FailsSameInstallPending) {
PendingBookmarkAppManager pending_app_manager(profile());
pending_app_manager.SetFactoriesForTesting(
test_web_contents_creator(), successful_installation_task_creator());
pending_app_manager.Install(
auto pending_app_manager = GetPendingBookmarkAppManagerWithTestFactories();
pending_app_manager->Install(
GetFooAppInfo(),
base::BindOnce(&PendingBookmarkAppManagerTest::InstallCallback,
base::Unretained(this)));
pending_app_manager.Install(
pending_app_manager->Install(
GetFooAppInfo(),
base::BindOnce(&PendingBookmarkAppManagerTest::InstallCallback,
base::Unretained(this)));
......@@ -326,11 +316,8 @@ TEST_F(PendingBookmarkAppManagerTest, Install_FailsSameInstallPending) {
}
TEST_F(PendingBookmarkAppManagerTest, Install_FailsLoadIncorrectURL) {
PendingBookmarkAppManager pending_app_manager(profile());
pending_app_manager.SetFactoriesForTesting(
test_web_contents_creator(), successful_installation_task_creator());
pending_app_manager.Install(
auto pending_app_manager = GetPendingBookmarkAppManagerWithTestFactories();
pending_app_manager->Install(
GetFooAppInfo(),
base::BindOnce(&PendingBookmarkAppManagerTest::InstallCallback,
base::Unretained(this)));
......
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