chromium/chrome/browser/ai/ai_writer_unittest.cc

// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/ai/ai_writer.h"

#include <memory>

#include "base/run_loop.h"
#include "base/test/bind.h"
#include "base/test/mock_callback.h"
#include "chrome/browser/ai/ai_manager_keyed_service_factory.h"
#include "chrome/browser/optimization_guide/mock_optimization_guide_keyed_service.h"
#include "chrome/browser/optimization_guide/optimization_guide_keyed_service_factory.h"
#include "chrome/test/base/chrome_render_view_host_test_harness.h"
#include "components/optimization_guide/core/mock_optimization_guide_model_executor.h"
#include "components/optimization_guide/core/optimization_guide_switches.h"
#include "components/optimization_guide/core/optimization_guide_util.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/mojom/ai/ai_manager.mojom.h"
#include "third_party/blink/public/mojom/ai/model_streaming_responder.mojom.h"

_;
AtMost;
NiceMock;

namespace {

constexpr char kSharedContextString[] =;
constexpr char kContextString[] =;
constexpr char kConcatenatedContextString[] =;
constexpr char kInputString[] =;

class MockCreateWriterClient
    : public blink::mojom::AIManagerCreateWriterClient {};

// TODO(crbug.com/357967382): Move MockResponder to a common utils file.
class MockResponder : public blink::mojom::ModelStreamingResponder {};

class MockSupportsUserData : public base::SupportsUserData {};

optimization_guide::OptimizationGuideModelStreamingExecutionResult
CreateExecutionResult(const std::string_view outpt, bool is_complete) {}

optimization_guide::OptimizationGuideModelStreamingExecutionResult
CreateExecutionErrorResult(
    optimization_guide::OptimizationGuideModelExecutionError error) {}

void CheckComposeRequestContext(
    const google::protobuf::MessageLite& request_metadata,
    const std::string& expected_context_string) {}
void CheckComposeRequestUserInput(
    const google::protobuf::MessageLite& request_metadata,
    const std::string& expected_user_input) {}

}  // namespace

class AIWriterTest : public ChromeRenderViewHostTestHarness {};

TEST_F(AIWriterTest, CreateWriterNoService) {}

TEST_F(AIWriterTest, CreateWriterModelNotAvailable) {}

TEST_F(AIWriterTest, CreateWriterRetryAfterConfigNotAvailableForFeature) {}

TEST_F(AIWriterTest, CreateWriterAbortAfterConfigNotAvailableForFeature) {}

TEST_F(AIWriterTest, ContextDestroyed) {}

TEST_F(AIWriterTest, SimpleWrite) {}

TEST_F(AIWriterTest, WriteError) {}

TEST_F(AIWriterTest, WriteMultipleResponse) {}

TEST_F(AIWriterTest, MultipleWrite) {}

TEST_F(AIWriterTest, ResponderDisconnected) {}

TEST_F(AIWriterTest, WriterDisconnected) {}