#include "components/optimization_guide/core/model_execution/model_execution_manager.h"
#include <memory>
#include "base/files/file_path.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "base/test/test.pb.h"
#include "components/optimization_guide/core/model_execution/model_execution_features.h"
#include "components/optimization_guide/core/model_execution/model_execution_prefs.h"
#include "components/optimization_guide/core/model_execution/on_device_model_access_controller.h"
#include "components/optimization_guide/core/model_execution/on_device_model_service_controller.h"
#include "components/optimization_guide/core/optimization_guide_constants.h"
#include "components/optimization_guide/core/optimization_guide_logger.h"
#include "components/optimization_guide/core/optimization_guide_model_executor.h"
#include "components/optimization_guide/core/optimization_guide_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/prefs/pref_service.h"
#include "components/signin/public/identity_manager/identity_test_environment.h"
#include "components/sync_preferences/testing_pref_service_syncable.h"
#include "components/variations/scoped_variations_ids_provider.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"
namespace optimization_guide {
namespace {
TestMessage;
HasSubstr;
proto::ExecuteResponse BuildComposeResponse(const std::string& output) { … }
class FakeServiceController : public OnDeviceModelServiceController { … };
class FakeModelProvider : public TestOptimizationGuideModelProvider { … };
class ModelExecutionManagerTest : public testing::Test { … };
TEST_F(ModelExecutionManagerTest, ExecuteModelEmptyAccessToken) { … }
TEST_F(ModelExecutionManagerTest, ExecuteModelWithUserSignIn) { … }
TEST_F(ModelExecutionManagerTest, ExecuteModelWithServerError) { … }
TEST_F(ModelExecutionManagerTest,
ExecuteModelWithServerErrorAllowedForLogging) { … }
TEST_F(ModelExecutionManagerTest, ExecuteModelDisableFallback) { … }
TEST_F(ModelExecutionManagerTest,
ExecuteModelDisableFallbackExplicitlySetToFalse) { … }
TEST_F(ModelExecutionManagerTest, ExecuteModelWithPassthroughSession) { … }
TEST_F(ModelExecutionManagerTest, LogsContextToExecutionTimeHistogram) { … }
TEST_F(ModelExecutionManagerTest,
ExecuteModelWithPassthroughSessionAddContext) { … }
TEST_F(ModelExecutionManagerTest,
ExecuteModelWithPassthroughSessionMultipleAddContext) { … }
TEST_F(ModelExecutionManagerTest,
ExecuteModelWithPassthroughSessionExecuteOverridesAddContext) { … }
TEST_F(ModelExecutionManagerTest, TestMultipleParallelRequests) { … }
TEST_F(ModelExecutionManagerTest, DoesNotRegisterTextSafetyIfNotEnabled) { … }
class ModelExecutionManagerSafetyEnabledTest
: public ModelExecutionManagerTest { … };
TEST_F(ModelExecutionManagerSafetyEnabledTest,
RegistersTextSafetyModelIfEnabled) { … }
TEST_F(ModelExecutionManagerSafetyEnabledTest,
DoesNotNotifyServiceControllerWrongTarget) { … }
TEST_F(ModelExecutionManagerSafetyEnabledTest, NotifiesServiceController) { … }
TEST_F(ModelExecutionManagerSafetyEnabledTest, UpdateLanguageDetection) { … }
TEST_F(ModelExecutionManagerSafetyEnabledTest,
NotRegisteredWhenDisabledByEnterprisePolicy) { … }
}
}