Skip to content

Commit

Permalink
test(core): SecondScreen unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ksentak committed Oct 3, 2024
1 parent 518ab64 commit 21bb70c
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions src/sdks/core/src/cpp/sdk/cpptest/unit/secondscreenTest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#include "unit.h"

class SecondScreenTest : public ::testing::Test
{
protected:
JsonEngine *jsonEngine;
Firebolt::Error error = Firebolt::Error::None;

void SetUp() override
{
jsonEngine = new JsonEngine();
}

void TearDown() override
{
delete jsonEngine;
}
};

TEST_F(SecondScreenTest, FriendlyName)
{
nlohmann::json_abi_v3_11_3::json expectedValue = nlohmann::json::parse(jsonEngine->get_value("SecondScreen.friendlyName"));

auto actualValue = Firebolt::IFireboltAccessor::Instance().SecondScreenInterface().friendlyName(&error);

EXPECT_EQ(error, Firebolt::Error::None) << "Failed to retrieve friendlyName from Secondscreen.friendlyName() method";
EXPECT_EQ(actualValue, expectedValue);
}

TEST_F(SecondScreenTest, Device)
{
nlohmann::json_abi_v3_11_3::json expectedValue = nlohmann::json::parse(jsonEngine->get_value("SecondScreen.device"));

auto actualValue = Firebolt::IFireboltAccessor::Instance().SecondScreenInterface().device(std::nullopt, &error);

EXPECT_EQ(error, Firebolt::Error::None) << "Failed to retrieve device from Secondscreen.device() method";
EXPECT_EQ(actualValue, expectedValue);
}

TEST_F(SecondScreenTest, Protocols)
{
std::string jsonString = jsonEngine->get_value("SecondScreen.protocols");

// Check if the JSON string is empty
ASSERT_FALSE(jsonString.empty()) << "JSON string for Secondscreen.protocols is empty";

nlohmann::json expectedValues;
try {
expectedValues = nlohmann::json::parse(jsonString);
} catch (const nlohmann::json::parse_error& e) {
FAIL() << "Failed to parse JSON string: " << e.what();
}

Firebolt::Types::BooleanMap actualValues = Firebolt::IFireboltAccessor::Instance().SecondScreenInterface().protocols(&error);

EXPECT_EQ(error, Firebolt::Error::None) << "Failed to retrieve protocols from Secondscreen.protocols() method";
EXPECT_EQ(actualValues, expectedValues);
}

0 comments on commit 21bb70c

Please sign in to comment.