Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,6 @@
"name",
"version"
],
"additionalProperties": false,
"if": {
"anyOf": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,6 @@
},
"tenConfiguration": {
"type": "object",
"additionalProperties": false,
"properties": {
"uri": {
"$ref": "#/$defs/non_empty_non_localhost_uri"
Expand Down
1 change: 1 addition & 0 deletions tests/ten_runtime/integration/cpp/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ group("cpp") {
"hello_world",
"large_result",
"long_running",
"metadata_additional_field",
"restful",
]

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#
# Copyright © 2025 Agora
# This file is part of TEN Framework, an open source project.
# Licensed under the Apache License, Version 2.0, with certain conditions.
# Refer to the "LICENSE" file in the root directory for more information.
#
import("//build/ten_runtime/feature/test.gni")
import("//build/ten_runtime/ten.gni")

ten_package_test_prepare_app("metadata_additional_field_app") {
src_app = "default_app_cpp"
src_app_language = "cpp"
generated_app_src_root_dir_name = "metadata_additional_field_app"

replace_paths_after_install_app = [
"metadata_additional_field_app/manifest.json",
"metadata_additional_field_app/property.json",
]

replace_paths_after_install_all = [
"metadata_additional_field_app/ten_packages/extension/default_extension_cpp/manifest.json",
"metadata_additional_field_app/ten_packages/extension/default_extension_cpp/property.json",
"metadata_additional_field_app/ten_packages/extension/default_extension_cpp/src/main.cc",
"metadata_additional_field_app/ten_packages/extension/default_extension_cpp/BUILD.gn",
]

if (ten_enable_ten_manager) {
deps = [
"//core/src/ten_manager",
"//core/src/ten_runtime:upload_ten_runtime_system_package_to_server",
"//packages/core_apps/default_app_cpp:upload_default_app_cpp_to_server",
"//packages/core_extensions/default_extension_cpp:upload_default_extension_cpp_to_server",
"//packages/core_protocols/msgpack:upload_protocol_msgpack_to_server",
]
}
}

ten_package_test_prepare_client("metadata_additional_field_app_client") {
sources = [ "client/client.cc" ]
include_dirs = [
"//core/src",
"//core",
"//packages",
"//tests",
]
deps = [
"//core/src/ten_runtime",
"//packages/core_protocols/msgpack:msgpack_files",
"//tests/common/client:msgpack_client",
"//third_party/msgpack:msgpackc",
"//third_party/nlohmann_json",
]
}

ten_package_test_prepare_auxiliary_resources(
"metadata_additional_field_app_test_files") {
resources = [
"__init__.py",
"test_case.py",
]

utils_files = exec_script("//.gnfiles/build/scripts/glob_file.py",
[
"--dir",
rebase_path("//tests/utils/**/*"),
"--dir-base",
rebase_path("//tests/utils"),
"--recursive",
"--only-output-file",
],
"json")

foreach(utils_file, utils_files) {
utils_file_rel_path = utils_file.relative_path
resources +=
[ "//tests/utils/${utils_file_rel_path}=>utils/${utils_file_rel_path}" ]
}
}

group("metadata_additional_field") {
deps = [
":metadata_additional_field_app",
":metadata_additional_field_app_client",
":metadata_additional_field_app_test_files",
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//
// Copyright © 2025 Agora
// This file is part of TEN Framework, an open source project.
// Licensed under the Apache License, Version 2.0, with certain conditions.
// Refer to the "LICENSE" file in the root directory for more information.
//
#include <nlohmann/json.hpp>

#include "tests/common/client/cpp/msgpack_tcp.h"

int main(int argc, char **argv) {
// Create a client and connect to the app.
auto *client = new ten::msgpack_tcp_client_t("msgpack://127.0.0.1:8001/");

// Send graph.
auto start_graph_cmd = ten::cmd_start_graph_t::create();
start_graph_cmd->set_graph_from_json(R"({
"nodes": [{
"type": "extension",
"name": "test_extension",
"addon": "default_extension_cpp",
"app": "msgpack://127.0.0.1:8001/",
"extension_group": "test_extension_group"
}]
})");
auto cmd_result =
client->send_cmd_and_recv_result(std::move(start_graph_cmd));
TEN_ASSERT(TEN_STATUS_CODE_OK == cmd_result->get_status_code(),
"Should not happen.");

// Send a user-defined 'hello world' command.
auto hello_world_cmd = ten::cmd_t::create("hello_world");
hello_world_cmd->set_dest("msgpack://127.0.0.1:8001/", nullptr,
"test_extension");
cmd_result = client->send_cmd_and_recv_result(std::move(hello_world_cmd));
TEN_ASSERT(TEN_STATUS_CODE_OK == cmd_result->get_status_code(),
"Should not happen.");
TEN_ASSERT(static_cast<std::string>("hello world, too") ==
cmd_result->get_property_string("detail"),
"Should not happen.");

delete client;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"type": "app",
"name": "default_app_cpp",
"version": "0.10.2",
"dependencies": [
{
"type": "system",
"name": "ten_runtime",
"version": "0.10.2"
},
{
"type": "extension",
"name": "default_extension_cpp",
"version": "0.10.2"
},
{
"type": "protocol",
"name": "msgpack",
"version": "0.10.2"
}
],
"api": {
"property": {
"hello": {
"type": "string"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"ten": {
"uri": "msgpack://127.0.0.1:8001/",
"predefined_graphs": [
{
"name": "default",
"auto_start": false,
"nodes": [
{
"type": "extension",
"name": "default_extension_cpp",
"addon": "default_extension_cpp",
"extension_group": "default_extension_group"
}
]
}
]
},
"hello": "world"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#
# Copyright © 2025 Agora
# This file is part of TEN Framework, an open source project.
# Licensed under the Apache License, Version 2.0, with certain conditions.
# Refer to the "LICENSE" file in the root directory for more information.
#
import("//build/feature/ten_package.gni")

ten_package("default_extension_cpp") {
package_kind = "extension"
enable_build = true

resources = [
"manifest.json",
"property.json",
]

sources = [ "src/main.cc" ]
include_dirs = [ "//core/include" ]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"type": "extension",
"name": "default_extension_cpp",
"version": "0.10.2",
"dependencies": [
{
"type": "system",
"name": "ten_runtime",
"version": "0.10.2"
}
],
"package": {
"include": [
"**"
]
},
"api": {
"cmd_in": [
{
"name": "hello_world"
}
],
"cmd_out": [],
"data_in": [],
"data_out": [],
"video_frame_in": [],
"video_frame_out": [],
"audio_frame_in": [],
"audio_frame_out": []
},
"unknown_field": "unknown_value"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"hello": "world",
"ten": {
"unknown_field": "unknown_value"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//
// Copyright © 2025 Agora
// This file is part of TEN Framework, an open source project.
// Licensed under the Apache License, Version 2.0, with certain conditions.
// Refer to the "LICENSE" file in the root directory for more information.
//
#include <cassert>
#include <cstdlib>

#include "ten_runtime/binding/cpp/ten.h"

class test_extension : public ten::extension_t {
public:
explicit test_extension(const char *name) : ten::extension_t(name) {}

void on_init(ten::ten_env_t &ten_env) override { ten_env.on_init_done(); }

void on_start(ten::ten_env_t &ten_env) override {
// The property.json will be loaded by default during `on_init` phase, so
// the property `hello` should be available here.
auto prop = ten_env.get_property_string("hello");
if (prop != "world") {
assert(0 && "Should not happen.");
}

ten_env.on_start_done();
}

void on_cmd(ten::ten_env_t &ten_env,
std::unique_ptr<ten::cmd_t> cmd) override {
if (cmd->get_name() == "hello_world") {
auto cmd_result = ten::cmd_result_t::create(TEN_STATUS_CODE_OK, *cmd);
cmd_result->set_property("detail", "hello world, too");
ten_env.return_result(std::move(cmd_result));
}
}
};

TEN_CPP_REGISTER_ADDON_AS_EXTENSION(default_extension_cpp, test_extension);
Loading
Loading