chromium/components/services/storage/service_worker/service_worker_storage_control_impl_unittest.cc

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

#include "components/services/storage/service_worker/service_worker_storage_control_impl.h"

#include <cstdint>
#include <string>
#include <vector>

#include "base/containers/flat_map.h"
#include "base/containers/span.h"
#include "base/files/scoped_temp_dir.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/bind.h"
#include "base/test/task_environment.h"
#include "base/time/time.h"
#include "components/services/storage/service_worker/service_worker_storage_test_utils.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "mojo/public/cpp/system/data_pipe_utils.h"
#include "net/disk_cache/disk_cache.h"
#include "net/http/http_util.h"
#include "net/test/cert_test_util.h"
#include "net/test/test_data_directory.h"
#include "services/network/public/mojom/url_response_head.mojom.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/storage_key/storage_key.h"
#include "third_party/blink/public/mojom/service_worker/navigation_preload_state.mojom.h"
#include "url/gurl.h"
#include "url/origin.h"

namespace storage {

DatabaseStatus;
RegistrationData;
ResourceRecord;

namespace {

struct FindRegistrationResult {};

struct ReadResponseHeadResult {};

struct ReadDataResult {};

struct GetRegistrationsForOriginResult {};

struct DeleteRegistrationResult {};

struct GetNewVersionIdResult {};

struct GetUserDataResult {};

struct GetUserDataByKeyPrefixResult {};

struct GetUserKeysAndDataByKeyPrefixResult {};

struct GetUserDataForAllRegistrationsResult {};

struct GetUsageForStorageKeyResult {};

ReadResponseHeadResult ReadResponseHead(
    mojom::ServiceWorkerResourceReader* reader) {}

ReadDataResult ReadResponseData(mojom::ServiceWorkerResourceReader* reader,
                                int data_size) {}

int WriteResponseHead(mojom::ServiceWorkerResourceWriter* writer,
                      network::mojom::URLResponseHeadPtr response_head) {}

int WriteResponseData(mojom::ServiceWorkerResourceWriter* writer,
                      mojo_base::BigBuffer data) {}

int WriteResponseMetadata(mojom::ServiceWorkerResourceMetadataWriter* writer,
                          mojo_base::BigBuffer metadata) {}

}  // namespace

class ServiceWorkerStorageControlImplTest : public testing::Test {};

// Tests that FindRegistration methods don't find anything without having stored
// anything.
TEST_F(ServiceWorkerStorageControlImplTest, FindRegistration_NoRegistration) {}

// Tests that storing/finding/deleting a registration works.
TEST_F(ServiceWorkerStorageControlImplTest, StoreAndDeleteRegistration) {}

TEST_F(ServiceWorkerStorageControlImplTest, UpdateToActiveState) {}

TEST_F(ServiceWorkerStorageControlImplTest, UpdateLastUpdateCheckTime) {}

TEST_F(ServiceWorkerStorageControlImplTest, UpdateFetchHandlerType) {}

TEST_F(ServiceWorkerStorageControlImplTest, UpdateResourceSha256Checksums) {}

TEST_F(ServiceWorkerStorageControlImplTest, Update) {}

// Tests that getting registrations works.
TEST_F(ServiceWorkerStorageControlImplTest, GetRegistrationsForStorageKey) {}

// Tests that writing/reading a service worker script succeed.
TEST_F(ServiceWorkerStorageControlImplTest, WriteAndReadResource) {}

// Tests that uncommitted resources can be listed on storage and these resources
// will be committed when a registration is stored with these resources.
TEST_F(ServiceWorkerStorageControlImplTest, UncommittedResources) {}

// Tests that uncommitted resource ids are purged by DoomUncommittedResources.
TEST_F(ServiceWorkerStorageControlImplTest, DoomUncommittedResources) {}

// Tests that storing/getting user data for a registration works.
TEST_F(ServiceWorkerStorageControlImplTest, StoreAndGetUserData) {}

// Tests that storing/getting user data by key prefix works.
TEST_F(ServiceWorkerStorageControlImplTest, StoreAndGetUserDataByKeyPrefix) {}

// Tests that storing/getting user data for multiple registrations work.
TEST_F(ServiceWorkerStorageControlImplTest,
       StoreAndGetUserDataForAllRegistrations) {}

// Tests that getting usage for a storage key works at different stages of
// registration resource update.
TEST_F(ServiceWorkerStorageControlImplTest, GetUsageForStorageKey) {}

// Tests that apply policy updates work.
TEST_F(ServiceWorkerStorageControlImplTest, ApplyPolicyUpdates) {}

TEST_F(ServiceWorkerStorageControlImplTest, TrackRunningVersion) {}

}  // namespace storage