#include "components/permissions/prediction_service/prediction_service.h"
#include <memory>
#include <optional>
#include <vector>
#include "base/command_line.h"
#include "base/functional/bind.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/time/time.h"
#include "components/permissions/features.h"
#include "components/permissions/permission_request_enums.h"
#include "components/permissions/prediction_service/prediction_common.h"
#include "components/permissions/prediction_service/prediction_request_features.h"
#include "components/permissions/prediction_service/prediction_service_messages.pb.h"
#include "components/permissions/request_type.h"
#include "google/protobuf/message_lite.h"
#include "net/base/net_errors.h"
#include "net/http/http_response_headers.h"
#include "net/http/http_status_code.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 "third_party/googletest/src/googletest/include/gtest/gtest.h"
namespace {
permissions::PredictionRequestFeatures kFeaturesAllCountsZero = …;
const permissions::PredictionRequestFeatures kFeaturesCountsNeedingRounding = …;
const permissions::PredictionRequestFeatures kFeaturesEvenCountsOver100 = …;
const permissions::PredictionRequestFeatures kFeaturesEvenCountsOver100Alt = …;
const permissions::PredictionRequestFeatures kFeaturesDifferentCounts = …;
permissions::GeneratePredictionsRequest kRequestAllCountsZero;
permissions::GeneratePredictionsRequest kRequestRoundedCounts;
permissions::GeneratePredictionsRequest kRequestEqualCountsTotal20;
permissions::GeneratePredictionsRequest kRequestDifferentCounts;
permissions::GeneratePredictionsResponse kResponseLikely;
permissions::GeneratePredictionsResponse kResponseUnlikely;
void InitializeProtoHelperObjects() { … }
}
namespace permissions {
class PredictionServiceTest : public testing::Test { … };
TEST_F(PredictionServiceTest, BuiltProtoRequestIsCorrect) { … }
TEST_F(PredictionServiceTest, ResponsesAreCorrect) { … }
TEST_F(PredictionServiceTest, FeatureParamAndCommandLineCanOverrideDefaultUrl) { … }
TEST_F(PredictionServiceTest,
FeatureEnabledWithNoFeatureParamFallsBackOnDefault) { … }
TEST_F(PredictionServiceTest, HandleSimultaneousRequests) { … }
TEST_F(PredictionServiceTest, InvalidResponse) { … }
TEST_F(PredictionServiceTest, PromptCountsAreBucketed) { … }
}