#include "components/assist_ranker/ranker_model_loader_impl.h"
#include <initializer_list>
#include <memory>
#include <vector>
#include "base/containers/circular_deque.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/functional/bind.h"
#include "base/memory/ref_counted.h"
#include "base/test/task_environment.h"
#include "components/assist_ranker/proto/ranker_model.pb.h"
#include "components/assist_ranker/proto/translate_ranker_model.pb.h"
#include "components/assist_ranker/ranker_model.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/public/mojom/url_response_head.mojom.h"
#include "services/network/test/test_url_loader_factory.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
RankerModel;
RankerModelLoaderImpl;
RankerModelStatus;
const char kInvalidModelData[] = …;
class RankerModelLoaderImplTest : public ::testing::Test { … };
RankerModelLoaderImplTest::RankerModelLoaderImplTest() { … }
void RankerModelLoaderImplTest::SetUp() { … }
std::unique_ptr<RankerModel> RankerModelLoaderImplTest::Clone(
const RankerModel& model) { … }
bool RankerModelLoaderImplTest::IsEqual(const RankerModel& m1,
const RankerModel& m2) { … }
bool RankerModelLoaderImplTest::IsEquivalent(const RankerModel& m1,
const RankerModel& m2) { … }
bool RankerModelLoaderImplTest::DoLoaderTest(const base::FilePath& model_path,
const GURL& model_url) { … }
void RankerModelLoaderImplTest::InitRemoteModels() { … }
void RankerModelLoaderImplTest::InitLocalModels() { … }
void RankerModelLoaderImplTest::InitModel(const GURL& model_url,
const base::Time& last_modified,
const base::TimeDelta& cache_duration,
RankerModel* model) { … }
void RankerModelLoaderImplTest::SaveModel(const RankerModel& model,
const base::FilePath& model_path) { … }
RankerModelStatus RankerModelLoaderImplTest::ValidateModel(
const RankerModel& model) { … }
void RankerModelLoaderImplTest::OnModelAvailable(
std::unique_ptr<RankerModel> model) { … }
}
TEST_F(RankerModelLoaderImplTest, NoLocalOrRemoteModel) { … }
TEST_F(RankerModelLoaderImplTest, BadLocalAndRemoteModel) { … }
TEST_F(RankerModelLoaderImplTest, LoadFromFileOnly) { … }
TEST_F(RankerModelLoaderImplTest, LoadFromFileSkipsDownload) { … }
TEST_F(RankerModelLoaderImplTest, LoadFromFileAndBadUrl) { … }
TEST_F(RankerModelLoaderImplTest, LoadFromURLOnly) { … }
TEST_F(RankerModelLoaderImplTest, LoadFromExpiredFileTriggersDownload) { … }
TEST_F(RankerModelLoaderImplTest, LoadFromBadFileTriggersDownload) { … }
TEST_F(RankerModelLoaderImplTest, IncompatibleCachedFileTriggersDownload) { … }
TEST_F(RankerModelLoaderImplTest, IncompatibleDownloadedFileKeepsExpired) { … }