#include <map>
#include <memory>
#include <utility>
#include "base/auto_reset.h"
#include "base/functional/bind.h"
#include "base/ranges/algorithm.h"
#include "base/run_loop.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "content/browser/background_fetch/background_fetch_context.h"
#include "content/browser/background_fetch/background_fetch_data_manager_observer.h"
#include "content/browser/background_fetch/background_fetch_job_controller.h"
#include "content/browser/background_fetch/background_fetch_registration_id.h"
#include "content/browser/background_fetch/background_fetch_service_impl.h"
#include "content/browser/background_fetch/background_fetch_test_base.h"
#include "content/browser/background_fetch/background_fetch_test_data_manager.h"
#include "content/browser/background_fetch/background_fetch_test_service_worker.h"
#include "content/browser/renderer_host/render_frame_host_impl.h"
#include "content/browser/service_worker/service_worker_context_wrapper.h"
#include "content/browser/storage_partition_impl.h"
#include "content/common/background_fetch/background_fetch_types.h"
#include "content/public/test/browser_task_environment.h"
#include "content/public/test/mock_permission_manager.h"
#include "content/public/test/test_browser_context.h"
#include "content/public/test/test_renderer_host.h"
#include "content/public/test/web_contents_tester.h"
#include "mojo/core/embedder/embedder.h"
#include "mojo/public/cpp/bindings/message.h"
#include "mojo/public/cpp/test_support/fake_message_dispatch_context.h"
#include "mojo/public/cpp/test_support/test_utils.h"
#include "services/network/public/mojom/fetch_api.mojom.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "third_party/blink/public/common/manifest/manifest.h"
#include "third_party/blink/public/common/permissions/permission_utils.h"
#include "third_party/blink/public/common/storage_key/storage_key.h"
#include "third_party/blink/public/mojom/fetch/fetch_api_request.mojom.h"
#include "ui/gfx/geometry/size.h"
#include "url/origin.h"
namespace content {
namespace {
_;
const char kExampleUniqueId[] = …;
const char kExampleDeveloperId[] = …;
const char kAlternativeDeveloperId[] = …;
blink::Manifest::ImageResource CreateIcon(const std::string& src,
std::vector<gfx::Size> sizes,
const std::string& type) { … }
bool ContainsHeader(const base::flat_map<std::string, std::string>& headers,
const std::string& target) { … }
std::vector<blink::mojom::FetchAPIRequestPtr> CloneRequestVector(
const std::vector<blink::mojom::FetchAPIRequestPtr>& requests) { … }
}
class BackgroundFetchServiceTest
: public BackgroundFetchTestBase,
public BackgroundFetchDataManagerObserver,
public ServiceWorkerContextCoreObserver,
public DevToolsBackgroundServicesContextImpl::EventObserver { … };
TEST_F(BackgroundFetchServiceTest, FetchInvalidArguments) { … }
TEST_F(BackgroundFetchServiceTest, FetchRegistrationProperties) { … }
TEST_F(BackgroundFetchServiceTest, FetchDuplicatedRegistrationFailure) { … }
TEST_F(BackgroundFetchServiceTest, FetchSuccessEventDispatch) { … }
TEST_F(BackgroundFetchServiceTest, FetchFailEventDispatch) { … }
TEST_F(BackgroundFetchServiceTest, UpdateUI) { … }
TEST_F(BackgroundFetchServiceTest, Abort) { … }
TEST_F(BackgroundFetchServiceTest, AbortEventDispatch) { … }
TEST_F(BackgroundFetchServiceTest, UniqueId) { … }
TEST_F(BackgroundFetchServiceTest, GetDeveloperIds) { … }
TEST_F(BackgroundFetchServiceTest, UnregisterServiceWorker) { … }
TEST_F(BackgroundFetchServiceTest, JobsInitializedOnBrowserRestart) { … }
TEST_F(BackgroundFetchServiceTest,
DevToolsContextReceivesBackgroundFetchEvents) { … }
}