chromium/content/browser/background_sync/background_sync_launcher_unittest.cc

// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "content/browser/background_sync/background_sync_launcher.h"

#include <map>
#include <vector>

#include "base/functional/bind.h"
#include "base/memory/raw_ptr.h"
#include "base/strings/string_number_conversions.h"
#include "base/test/bind.h"
#include "base/test/task_environment.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "content/browser/storage_partition_impl.h"
#include "content/common/content_export.h"
#include "content/public/browser/background_sync_context.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/common/content_client.h"
#include "content/public/test/browser_task_environment.h"
#include "content/public/test/test_browser_context.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
#if BUILDFLAG(IS_ANDROID)
#include "base/run_loop.h"
#endif

namespace content {

namespace {

const char kUrl_1[] =;
const char kUrl_2[] =;

class TestBrowserClient : public ContentBrowserClient {};

}  // namespace

class BackgroundSyncLauncherTest : public testing::Test {};

// Tests that we pick the correct wake up delta for the one-shot Background
// Sync wake up task, across all storage partitions.
TEST_F(BackgroundSyncLauncherTest, CorrectSoonestWakeupDeltaIsPicked) {}

// Tests that we pick the correct wake up delta for the correct Background Sync
// wake up task, across all storage partitions.
TEST_F(BackgroundSyncLauncherTest, SoonestWakeupDeltaIsPickedForTheRightTask) {}

#if BUILDFLAG(IS_ANDROID)
TEST_F(BackgroundSyncLauncherTest, FireBackgroundSyncEvents) {
  std::vector<GURL> urls = {GURL(kUrl_1), GURL(kUrl_2)};
  SetUpBrowserContext(urls, blink::mojom::BackgroundSyncType::ONE_SHOT);

  ASSERT_NO_FATAL_FAILURE(FireBackgroundSyncEventsForAllPartitions());
  EXPECT_EQ(NumInvocationsOfFireBackgroundSyncEvents(), 2);
}
#endif

}  // namespace content