#ifndef EXTENSIONS_RENDERER_BINDINGS_API_BINDING_TEST_UTIL_H_
#define EXTENSIONS_RENDERER_BINDINGS_API_BINDING_TEST_UTIL_H_
#include <memory>
#include <string>
#include <string_view>
#include "base/values.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "v8/include/v8.h"
namespace extensions {
std::string ReplaceSingleQuotes(std::string_view str);
base::Value ValueFromString(std::string_view str);
base::Value::List ListValueFromString(std::string_view str);
base::Value::Dict DictValueFromString(std::string_view str);
std::string ValueToString(const base::ValueView&);
std::string V8ToString(v8::Local<v8::Value> value,
v8::Local<v8::Context> context);
v8::Local<v8::Value> V8ValueFromScriptSource(v8::Local<v8::Context> context,
std::string_view source);
v8::Local<v8::Function> FunctionFromString(v8::Local<v8::Context> context,
std::string_view source);
std::unique_ptr<base::Value> V8ToBaseValue(v8::Local<v8::Value> value,
v8::Local<v8::Context> context);
v8::Local<v8::Value> RunFunction(v8::Local<v8::Function> function,
v8::Local<v8::Context> context,
v8::Local<v8::Value> receiver,
int argc,
v8::Local<v8::Value> argv[]);
v8::Local<v8::Value> RunFunction(v8::Local<v8::Function> function,
v8::Local<v8::Context> context,
int argc,
v8::Local<v8::Value> argv[]);
v8::Local<v8::Value> RunFunctionOnGlobal(v8::Local<v8::Function> function,
v8::Local<v8::Context> context,
int argc,
v8::Local<v8::Value> argv[]);
void RunFunctionOnGlobalAndIgnoreResult(v8::Local<v8::Function> function,
v8::Local<v8::Context> context,
int argc,
v8::Local<v8::Value> argv[]);
v8::Global<v8::Value> RunFunctionOnGlobalAndReturnHandle(
v8::Local<v8::Function> function,
v8::Local<v8::Context> context,
int argc,
v8::Local<v8::Value> argv[]);
void RunFunctionAndExpectError(v8::Local<v8::Function> function,
v8::Local<v8::Context> context,
v8::Local<v8::Value> receiver,
int argc,
v8::Local<v8::Value> argv[],
const std::string& expected_error);
void RunFunctionAndExpectError(v8::Local<v8::Function> function,
v8::Local<v8::Context> context,
int argc,
v8::Local<v8::Value> argv[],
const std::string& expected_error);
v8::Local<v8::Value> GetPropertyFromObject(v8::Local<v8::Object> object,
v8::Local<v8::Context> context,
std::string_view key);
std::unique_ptr<base::Value> GetBaseValuePropertyFromObject(
v8::Local<v8::Object> object,
v8::Local<v8::Context> context,
std::string_view key);
std::string GetStringPropertyFromObject(v8::Local<v8::Object> object,
v8::Local<v8::Context> context,
std::string_view key);
template <typename T>
struct ValueTypeChecker { … };
template <>
struct ValueTypeChecker<v8::Function> { … };
template <>
struct ValueTypeChecker<v8::Object> { … };
template <>
struct ValueTypeChecker<v8::Promise> { … };
template <>
struct ValueTypeChecker<v8::Array> { … };
template <typename T>
bool GetValueAs(v8::Local<v8::Value> value, v8::Local<T>* out) { … }
template <typename T>
bool V8ValueIs(v8::Local<v8::Value> value) { … }
template <typename T>
bool GetPropertyFromObjectAs(v8::Local<v8::Object> object,
v8::Local<v8::Context> context,
std::string_view key,
v8::Local<T>* out) { … }
}
#endif