Commit 1658c432 authored by Lorne Mitchell's avatar Lorne Mitchell Committed by Commit Bot

dpwa: Added TestPendingAppManagerImpl

TestPendingAppManagerImpl caches the install and uninstall requests, which is needed by the system_web_app_manager_unittests.cc.

There is a follow up CL that is in work that will consume this class (https://chromium-review.googlesource.com/c/chromium/src/+/2223978).

Bug: 1088399
Change-Id: Ide90f3be50109b4f7d5794b27b98042e6c23b649
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2251101
Commit-Queue: Lorne Mitchell <lomitch@microsoft.com>
Reviewed-by: default avatarAlexey Baskakov <loyso@chromium.org>
Cr-Commit-Position: refs/heads/master@{#779896}
parent 41ac535d
......@@ -139,6 +139,8 @@ source_set("web_applications_test_support") {
"test/test_install_finalizer.h",
"test/test_pending_app_manager.cc",
"test/test_pending_app_manager.h",
"test/test_pending_app_manager_impl.cc",
"test/test_pending_app_manager_impl.h",
"test/test_system_web_app_manager.cc",
"test/test_system_web_app_manager.h",
"test/test_system_web_app_url_data_source.cc",
......
......@@ -19,6 +19,7 @@ class Time;
namespace web_app {
// Deprecated. Please use TestWebAppRegistryController instead.
class TestAppRegistrar : public AppRegistrar {
public:
struct AppInfo {
......
......@@ -18,6 +18,7 @@ namespace web_app {
class TestAppRegistrar;
// Deprecated. Please use TestPendingAppManagerImpl instead.
class TestPendingAppManager : public PendingAppManager {
public:
explicit TestPendingAppManager(TestAppRegistrar* registrar);
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/web_applications/test/test_pending_app_manager_impl.h"
#include <algorithm>
namespace web_app {
TestPendingAppManagerImpl::TestPendingAppManagerImpl(Profile* profile)
: PendingAppManagerImpl(profile) {}
TestPendingAppManagerImpl::~TestPendingAppManagerImpl() = default;
void TestPendingAppManagerImpl::Install(ExternalInstallOptions install_options,
OnceInstallCallback callback) {
install_requests_.push_back(install_options);
PendingAppManagerImpl::Install(install_options, std::move(callback));
}
void TestPendingAppManagerImpl::InstallApps(
std::vector<ExternalInstallOptions> install_options_list,
const RepeatingInstallCallback& callback) {
std::copy(install_options_list.begin(), install_options_list.end(),
std::back_inserter(install_requests_));
PendingAppManagerImpl::InstallApps(install_options_list, std::move(callback));
}
void TestPendingAppManagerImpl::UninstallApps(
std::vector<GURL> uninstall_urls,
ExternalInstallSource install_source,
const UninstallCallback& callback) {
std::copy(uninstall_urls.begin(), uninstall_urls.end(),
std::back_inserter(uninstall_requests_));
PendingAppManagerImpl::UninstallApps(uninstall_urls, install_source,
std::move(callback));
}
} // namespace web_app
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_WEB_APPLICATIONS_TEST_TEST_PENDING_APP_MANAGER_IMPL_H_
#define CHROME_BROWSER_WEB_APPLICATIONS_TEST_TEST_PENDING_APP_MANAGER_IMPL_H_
#include <vector>
#include "chrome/browser/web_applications/pending_app_manager_impl.h"
namespace web_app {
class TestPendingAppManagerImpl : public PendingAppManagerImpl {
public:
explicit TestPendingAppManagerImpl(Profile* profile);
~TestPendingAppManagerImpl() override;
void Install(ExternalInstallOptions install_options,
OnceInstallCallback callback) override;
void InstallApps(std::vector<ExternalInstallOptions> install_options_list,
const RepeatingInstallCallback& callback) override;
void UninstallApps(std::vector<GURL> uninstall_urls,
ExternalInstallSource install_source,
const UninstallCallback& callback) override;
const std::vector<ExternalInstallOptions>& install_requests() const {
return install_requests_;
}
const std::vector<GURL>& uninstall_requests() const {
return uninstall_requests_;
}
private:
std::vector<ExternalInstallOptions> install_requests_;
std::vector<GURL> uninstall_requests_;
};
} // namespace web_app
#endif // CHROME_BROWSER_WEB_APPLICATIONS_TEST_TEST_PENDING_APP_MANAGER_IMPL_H_
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