chromium/chrome/browser/safe_browsing/incident_reporting/state_store_unittest.cc

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

#include "chrome/browser/safe_browsing/incident_reporting/state_store.h"

#include <stdint.h>

#include "base/files/scoped_temp_dir.h"
#include "base/json/json_file_value_serializer.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/test_simple_task_runner.h"
#include "base/values.h"
#include "build/build_config.h"
#include "chrome/browser/prefs/browser_prefs.h"
#include "chrome/browser/safe_browsing/incident_reporting/incident.h"
#include "chrome/browser/safe_browsing/incident_reporting/platform_state_store.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
#include "chrome/test/base/testing_profile_manager.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "components/prefs/in_memory_pref_store.h"
#include "components/safe_browsing/core/common/safe_browsing_prefs.h"
#include "components/sync_preferences/pref_service_syncable.h"
#include "components/sync_preferences/pref_service_syncable_factory.h"
#include "content/public/test/browser_task_environment.h"
#include "extensions/browser/quota_service.h"
#include "testing/gtest/include/gtest/gtest.h"

#if BUILDFLAG(IS_WIN)
#include "base/test/test_reg_util_win.h"
#endif

namespace safe_browsing {

#if BUILDFLAG(IS_WIN)

// A base test fixture that redirects HKCU for testing the platform state store
// backed by the Windows registry to prevent interference with existing Chrome
// installs or other tests.
class PlatformStateStoreTestBase : public ::testing::Test {
 protected:
  PlatformStateStoreTestBase() {}

  PlatformStateStoreTestBase(const PlatformStateStoreTestBase&) = delete;
  PlatformStateStoreTestBase& operator=(const PlatformStateStoreTestBase&) =
      delete;

  void SetUp() override {
    ::testing::Test::SetUp();
    ASSERT_NO_FATAL_FAILURE(
        registry_override_manager_.OverrideRegistry(HKEY_CURRENT_USER));
  }

 private:
  registry_util::RegistryOverrideManager registry_override_manager_;
};

#else  // BUILDFLAG(IS_WIN)

PlatformStateStoreTestBase;

#endif  // BUILDFLAG(IS_WIN)

// A test fixture with a testing profile that writes its user prefs to a json
// file.
class StateStoreTest : public PlatformStateStoreTestBase {};

// static
const char StateStoreTest::kProfileName_[] =;
const StateStoreTest::TestData StateStoreTest::kTestData_[] =;

TEST_F(StateStoreTest, MarkAsAndHasBeenReported) {}

TEST_F(StateStoreTest, ClearForType) {}

TEST_F(StateStoreTest, ClearAll) {}

TEST_F(StateStoreTest, Persistence) {}

TEST_F(StateStoreTest, PersistenceWithStoreDelete) {}

}  // namespace safe_browsing