chromium/chrome/browser/policy/messaging_layer/util/test_response_payload.h

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

// Test support library for response payloads.

#ifndef CHROME_BROWSER_POLICY_MESSAGING_LAYER_UTIL_TEST_RESPONSE_PAYLOAD_H_
#define CHROME_BROWSER_POLICY_MESSAGING_LAYER_UTIL_TEST_RESPONSE_PAYLOAD_H_

#include <optional>

#include "base/values.h"
#include "chrome/browser/policy/messaging_layer/util/reporting_server_connector.h"
#include "components/reporting/util/statusor.h"

namespace reporting {

// Class to build response based on an input request.
// Example:
//
//   auto simple_successful_response = ResponseBuilder(std::move(request))
//                                       .Build();
//   auto failed_response = ResponseBuilder(std::move(request))
//                                       .SetSuccess(false)
//                                       .SetForceConfirm(true)
//                                       .Build();
//
// For the document of what response payload should look like, search for
// "{{{Note}}} ERP Response Payload Overview" in the codebase.
class ResponseBuilder {};

// Helper functor to be used with EXPECT_CALL and |UploadEncryptedReport|. It
// takes a |ResponseBuilder| object, and builds the response dict based on it
// and the input request from |UploadEncryptedReport|. Example:
//
//
//   EXPECT_CALL(*client_,
//               UploadEncryptedReport(IsDataUploadRequestValid(), _, _))
//     .WillOnce(MakeUploadEncryptedReportAction(
//        std::move(ResponseBuilder()
//                    .SetForceConfirm(force_confirm_by_server))));
//
// This class should be able to handle the majority of cases for defining mocked
// |UploadEncryptedReport| actions. In other circumstances, consider feeding a
// lambda function that uses |ResponseBuilder| to .WillOnce()/.WillRepeatedly().
//
// We don't define |MakeUploadEncryptedReportAction| a lambda function here
// because the mutable nature and the size of the argument list makes it far
// less readable.
class MakeUploadEncryptedReportAction {};

}  // namespace reporting

#endif  // CHROME_BROWSER_POLICY_MESSAGING_LAYER_UTIL_TEST_RESPONSE_PAYLOAD_H_