#include "components/safe_browsing/core/browser/tailored_security_service/tailored_security_service.h"
#include <memory>
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/memory/raw_ptr.h"
#include "base/run_loop.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "base/values.h"
#include "components/prefs/pref_registry_simple.h"
#include "components/prefs/testing_pref_service.h"
#include "components/safe_browsing/core/common/features.h"
#include "components/safe_browsing/core/common/safe_browsing_prefs.h"
#include "net/http/http_status_code.h"
#include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "services/network/public/cpp/weak_wrapper_shared_url_loader_factory.h"
#include "services/network/test/test_url_loader_factory.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
IsEmpty;
Not;
namespace safe_browsing {
namespace {
const char kQueryTailoredSecurityServiceUrl[] = …;
class TestingTailoredSecurityService : public TailoredSecurityService { … };
class TestRequest : public TailoredSecurityService::Request { … };
std::unique_ptr<TailoredSecurityService::Request>
TestingTailoredSecurityService::CreateRequest(
const GURL& url,
CompletionCallback callback,
const net::NetworkTrafficAnnotationTag& traffic_annotation) { … }
base::Value::Dict TestingTailoredSecurityService::ReadResponse(
Request* request) { … }
void TestingTailoredSecurityService::SetTailoredSecurityServiceCallback(
bool is_enabled,
base::Time previous_update) { … }
void TestingTailoredSecurityService::GetTailoredSecurityServiceCallback(
bool is_enabled,
base::Time previous_update) { … }
void TestingTailoredSecurityService::MultipleRequestsCallback(
bool is_enabled,
base::Time previous_update) { … }
const std::string& TestingTailoredSecurityService::GetExpectedPostData(
Request* request) { … }
std::string
TestingTailoredSecurityService::GetExpectedTailoredSecurityServiceValue() { … }
void TestingTailoredSecurityService::Shutdown() { … }
void TestingTailoredSecurityService::MaybeNotifySyncUser(
bool is_enabled,
base::Time previous_update) { … }
}
class TailoredSecurityServiceTest : public testing::Test { … };
TEST_F(TailoredSecurityServiceTest, GetTailoredSecurityServiceEnabled) { … }
TEST_F(TailoredSecurityServiceTest,
SetTailoredSecurityBitEnabledForTestingTrue) { … }
TEST_F(TailoredSecurityServiceTest, SetTailoredSecurityBitForTestingFalse) { … }
TEST_F(TailoredSecurityServiceTest, MultipleRequests) { … }
TEST_F(TailoredSecurityServiceTest, VerifyReadResponse) { … }
TEST_F(TailoredSecurityServiceTest, TestShutdown) { … }
TEST_F(TailoredSecurityServiceTest, NotifiesSyncForEnabled) { … }
TEST_F(TailoredSecurityServiceTest, NotifiesSyncForDisabled) { … }
TEST_F(TailoredSecurityServiceTest,
RetryEnabledTimestampUpdateCallbackSetsStateToRetryNeeded) { … }
TEST_F(TailoredSecurityServiceTest, RetryDisabledStateRemainsUnset) { … }
TEST_F(TailoredSecurityServiceTest,
RetryEnabledTimestampUpdateCallbackRecordsStartTime) { … }
TEST_F(TailoredSecurityServiceTest,
RetryDisabledTimestampUpdateCallbackDoesNotRecordStartTime) { … }
TEST_F(TailoredSecurityServiceTest,
HistorySyncEnabledForUserReturnsFalseWhenSyncServiceIsNull) { … }
}