chromium/extensions/renderer/bindings/api_request_handler_unittest.cc

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

#include "extensions/renderer/bindings/api_request_handler.h"

#include <optional>

#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/strings/strcat.h"
#include "base/test/bind.h"
#include "base/values.h"
#include "extensions/renderer/bindings/api_binding_test.h"
#include "extensions/renderer/bindings/api_binding_test_util.h"
#include "extensions/renderer/bindings/exception_handler.h"
#include "extensions/renderer/bindings/test_interaction_provider.h"
#include "extensions/renderer/bindings/test_js_runner.h"
#include "extensions/renderer/v8_helpers.h"
#include "gin/converter.h"
#include "gin/function_template.h"
#include "gin/public/context_holder.h"
#include "gin/public/isolate_holder.h"
#include "testing/gmock/include/gmock/gmock.h"

namespace extensions {

namespace {

const char kEchoArgs[] =;

const char kMethod[] =;

// TODO(devlin): We should probably hoist this up to e.g. api_binding_types.h.
ArgumentList;

// TODO(devlin): Should we move some parts of api_binding_unittest.cc to here?

}  // namespace

class APIRequestHandlerTest : public APIBindingTest {};

// Tests adding a request to the request handler, and then triggering the
// response.
TEST_F(APIRequestHandlerTest, AddRequestAndCompleteRequestTest) {}

// Tests that trying to run non-existent or invalided requests is a no-op.
TEST_F(APIRequestHandlerTest, InvalidRequestsTest) {}

TEST_F(APIRequestHandlerTest, MultipleRequestsAndContexts) {}

TEST_F(APIRequestHandlerTest, CustomCallbackArguments) {}

TEST_F(APIRequestHandlerTest, CustomCallbackWithErrorInExtensionCallback) {}

TEST_F(APIRequestHandlerTest, CustomCallbackPromiseBased) {}

// Test that having a custom callback without an extension-provided callback
// doesn't crash.
TEST_F(APIRequestHandlerTest, CustomCallbackArgumentsWithEmptyCallback) {}

TEST_F(APIRequestHandlerTest, ResultModifier) {}

// Test user gestures being curried around for API requests.
TEST_F(APIRequestHandlerTest, UserGestureTest) {}

TEST_F(APIRequestHandlerTest, SettingLastError) {}

TEST_F(APIRequestHandlerTest, AddPendingRequestCallback) {}

TEST_F(APIRequestHandlerTest, AddPendingRequestPromise) {}

TEST_F(APIRequestHandlerTest, AddPendingRequestWithResultModifier) {}

// Tests that throwing an exception in a callback is properly handled.
TEST_F(APIRequestHandlerTest, ThrowExceptionInCallback) {}

// Tests promise-based requests with the promise being fulfilled.
TEST_F(APIRequestHandlerTest, PromiseBasedRequests_Fulfilled) {}

// Tests promise-based requests with the promise being rejected.
TEST_F(APIRequestHandlerTest, PromiseBasedRequests_Rejected) {}

}  // namespace extensions