mirror of
https://github.com/logos-co/logos-protocol.git
synced 2026-08-29 13:01:07 +00:00
* Extract the Logos protocol layer from logos-cpp-sdk
Transports (plain TCP/TLS, qt_local, qt_remote/QRO, mock), token manager,
consumer core (LogosAPIClient/LogosAPIConsumer incl. the capability
auto-requestModule flow), ModuleProxy, the abstract LogosProviderObject
interface, and the canonical QVariant<->JSON conversion — now behind the
language-neutral lp_* C ABI (logos_protocol.h) carrying the protocol
semver (LOGOS_PROTOCOL_VERSION_*, lp_protocol_version()).
Bytes crossing the ABI use the lossless {"_bytes": base64url} tagging
(NUL-safe), matching the plain wire encoding.
Provider lp_* surface is compiled groundwork; serving lands with module
authoring.
* consumer: typed requestModule for the capability flow
Port of logos-cpp-sdk master f5a127dd ('use updated capability module',
cpp-sdk#85, Iuri Matias) — the touched files (logos_api_client.cpp,
logos_api_consumer.{h,cpp}) moved into this repo in the P1 extraction.
The capability auto-requestModule path now calls a typed std::string
helper on the consumer (which acquires the capability object directly)
instead of a stringly invokeRemoteMethod round-trip. 111/111 tests.
81 lines
2.4 KiB
C++
81 lines
2.4 KiB
C++
#include <gtest/gtest.h>
|
|
#include "plugin_registry.h"
|
|
|
|
class PluginRegistryTest : public ::testing::Test {
|
|
protected:
|
|
void TearDown() override
|
|
{
|
|
// Clean up any registered plugins
|
|
PluginRegistry::unregisterPlugin("test_plugin");
|
|
PluginRegistry::unregisterPlugin("another_plugin");
|
|
}
|
|
};
|
|
|
|
TEST_F(PluginRegistryTest, RegisterAndHasPlugin)
|
|
{
|
|
QObject obj;
|
|
PluginRegistry::registerPlugin(&obj, "test_plugin");
|
|
EXPECT_TRUE(PluginRegistry::hasPlugin("test_plugin"));
|
|
}
|
|
|
|
TEST_F(PluginRegistryTest, UnregisterPlugin)
|
|
{
|
|
QObject obj;
|
|
PluginRegistry::registerPlugin(&obj, "test_plugin");
|
|
EXPECT_TRUE(PluginRegistry::unregisterPlugin("test_plugin"));
|
|
EXPECT_FALSE(PluginRegistry::hasPlugin("test_plugin"));
|
|
}
|
|
|
|
TEST_F(PluginRegistryTest, GetPluginReturnsCorrectObject)
|
|
{
|
|
QObject obj;
|
|
PluginRegistry::registerPlugin(&obj, "test_plugin");
|
|
QObject* retrieved = PluginRegistry::getPlugin<QObject>("test_plugin");
|
|
EXPECT_EQ(retrieved, &obj);
|
|
}
|
|
|
|
TEST_F(PluginRegistryTest, GetPluginReturnsNullForMissing)
|
|
{
|
|
QObject* retrieved = PluginRegistry::getPlugin<QObject>("nonexistent");
|
|
EXPECT_EQ(retrieved, nullptr);
|
|
}
|
|
|
|
TEST_F(PluginRegistryTest, HasPluginReturnsFalseForMissing)
|
|
{
|
|
EXPECT_FALSE(PluginRegistry::hasPlugin("nonexistent"));
|
|
}
|
|
|
|
TEST_F(PluginRegistryTest, EmptyNameGuards)
|
|
{
|
|
EXPECT_FALSE(PluginRegistry::hasPlugin(""));
|
|
EXPECT_FALSE(PluginRegistry::unregisterPlugin(""));
|
|
EXPECT_EQ(PluginRegistry::getPlugin<QObject>(""), nullptr);
|
|
}
|
|
|
|
TEST_F(PluginRegistryTest, KeyNormalization)
|
|
{
|
|
EXPECT_EQ(PluginRegistry::toPluginKey("My Module"),
|
|
"logos_plugin_my_module");
|
|
EXPECT_EQ(PluginRegistry::toPluginKey("TEST"),
|
|
"logos_plugin_test");
|
|
}
|
|
|
|
TEST_F(PluginRegistryTest, MultiplePlugins)
|
|
{
|
|
QObject obj1, obj2;
|
|
PluginRegistry::registerPlugin(&obj1, "test_plugin");
|
|
PluginRegistry::registerPlugin(&obj2, "another_plugin");
|
|
EXPECT_TRUE(PluginRegistry::hasPlugin("test_plugin"));
|
|
EXPECT_TRUE(PluginRegistry::hasPlugin("another_plugin"));
|
|
EXPECT_NE(PluginRegistry::getPlugin<QObject>("test_plugin"),
|
|
PluginRegistry::getPlugin<QObject>("another_plugin"));
|
|
}
|
|
|
|
TEST_F(PluginRegistryTest, OverwritePlugin)
|
|
{
|
|
QObject obj1, obj2;
|
|
PluginRegistry::registerPlugin(&obj1, "test_plugin");
|
|
PluginRegistry::registerPlugin(&obj2, "test_plugin");
|
|
EXPECT_EQ(PluginRegistry::getPlugin<QObject>("test_plugin"), &obj2);
|
|
}
|