#include "components/safe_browsing/content/browser/client_side_phishing_model.h"
#include <string>
#include <utility>
#include "base/containers/span.h"
#include "base/files/file.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/functional/bind.h"
#include "base/logging.h"
#include "base/memory/read_only_shared_memory_region.h"
#include "base/memory/scoped_refptr.h"
#include "base/memory/shared_memory_mapping.h"
#include "base/path_service.h"
#include "base/run_loop.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/task_traits.h"
#include "base/task/thread_pool.h"
#include "base/test/gtest_util.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_command_line.h"
#include "base/test/scoped_feature_list.h"
#include "build/build_config.h"
#include "components/optimization_guide/core/model_util.h"
#include "components/optimization_guide/core/test_model_info_builder.h"
#include "components/optimization_guide/core/test_optimization_guide_model_provider.h"
#include "components/optimization_guide/proto/client_side_phishing_model_metadata.pb.h"
#include "components/optimization_guide/proto/models.pb.h"
#include "components/safe_browsing/core/common/fbs/client_model_generated.h"
#include "components/safe_browsing/core/common/features.h"
#include "components/safe_browsing/core/common/proto/client_model.pb.h"
#include "content/public/test/browser_task_environment.h"
#include "content/public/test/test_renderer_host.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace safe_browsing {
class ClientSidePhishingModelObserverTracker
: public optimization_guide::TestOptimizationGuideModelProvider { … };
class ClientSidePhishingModelTest : public content::RenderViewHostTestHarness { … };
namespace {
std::string CreateFlatBufferString() { … }
void GetFlatBufferStringFromMappedMemory(
base::ReadOnlySharedMemoryRegion region,
std::string* output) { … }
}
TEST_F(ClientSidePhishingModelTest, ValidModel) { … }
TEST_F(ClientSidePhishingModelTest, InvalidModelDueToInvalidPath) { … }
TEST_F(ClientSidePhishingModelTest, InvalidModelDueToNonexistentPath) { … }
TEST_F(ClientSidePhishingModelTest,
InvalidModelDueToValidPathButMultipleAdditionalFilesPath) { … }
TEST_F(ClientSidePhishingModelTest,
InvalidImageEmbeddingModelDueToNonexistentPath) { … }
TEST_F(ClientSidePhishingModelTest,
EmptyOptimizationGuideModelInfoDisablesService) { … }
TEST_F(ClientSidePhishingModelTest, RejectsInvalidFlatbuffer) { … }
TEST_F(ClientSidePhishingModelTest, NotifiesForFile) { … }
TEST_F(ClientSidePhishingModelTest, DoesNotNotifyOnBadInitialUpdate) { … }
TEST_F(ClientSidePhishingModelTest, DoesNotNotifyOnBadFollowingUpdate) { … }
TEST_F(ClientSidePhishingModelTest, CanOverrideFlatBufferWithFlag) { … }
TEST_F(ClientSidePhishingModelTest, AcceptsValidFlatbuffer) { … }
TEST_F(ClientSidePhishingModelTest, FlatbufferOnFollowingUpdate) { … }
}