#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 { … };
}
class BackgroundSyncLauncherTest : public testing::Test { … };
TEST_F(BackgroundSyncLauncherTest, CorrectSoonestWakeupDeltaIsPicked) { … }
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
}