Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SERXIONE-6655: Xumo Content Store - Age Ratings #5957

Merged
merged 4 commits into from
Jan 7, 2025
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
107 changes: 57 additions & 50 deletions Tests/L2Tests/L2TestsPlugin/tests/UserSettings_L2Test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,14 @@ class AsyncHandlerMock_UserSetting
MOCK_METHOD(void, onPreferredCaptionsLanguagesChanged, (const string preferredLanguages));
MOCK_METHOD(void, onPreferredClosedCaptionServiceChanged, (const string service));
MOCK_METHOD(void, onPrivacyModeChanged, (const string privacyMode));
MOCK_METHOD(void, onPinControlChanged, (const bool enabled));
MOCK_METHOD(void, onPinControlChanged, (const bool pinControl));
MOCK_METHOD(void, onViewingRestrictionsChanged, (const string viewingRestrictions));
MOCK_METHOD(void, onViewingRestrictionsWindowChanged, (const string viewingRestrictionsWindow));
MOCK_METHOD(void, onLiveWatershedChanged, (const bool enabled));
MOCK_METHOD(void, onPlaybackWatershedChanged, (const bool enabled));
MOCK_METHOD(void, onBlockNotRatedContentChanged, (const bool enabled));
MOCK_METHOD(void, onPinOnPurchaseChanged, (const bool enabled));
MOCK_METHOD(void, onLiveWatershedChanged, (const bool liveWatershed));
MOCK_METHOD(void, onPlaybackWatershedChanged, (const bool playbackWatershed));
MOCK_METHOD(void, onBlockNotRatedContentChanged, (const bool blockNotRatedContent));
MOCK_METHOD(void, onPinOnPurchaseChanged, (const bool pinOnPurchase));

};

class NotificationHandler : public Exchange::IUserSettings::INotification {
Expand Down Expand Up @@ -162,11 +163,11 @@ class NotificationHandler : public Exchange::IUserSettings::INotification {
m_condition_variable.notify_one();
}

void OnPinControlChanged(const bool enabled) override
void OnPinControlChanged(const bool pinControl) override
{
TEST_LOG("OnPinControlChanged event triggered ***\n");
std::unique_lock<std::mutex> lock(m_mutex);
std::string str = enabled ? "true" : "false";
std::string str = pinControl ? "true" : "false";

TEST_LOG("OnPinControlChanged received: %s\n", str.c_str());
/* Notify the requester thread. */
Expand Down Expand Up @@ -198,47 +199,47 @@ class NotificationHandler : public Exchange::IUserSettings::INotification {

}

void OnLiveWatershedChanged(const bool enabled) override
void OnLiveWatershedChanged(const bool liveWatershed) override
{
TEST_LOG("OnLiveWatershedChanged event triggered ***\n");
std::unique_lock<std::mutex> lock(m_mutex);
std::string str = enabled ? "true" : "false";
std::string str = liveWatershed ? "true" : "false";

TEST_LOG("OnLiveWatershedChanged received: %s\n", str.c_str());
/* Notify the requester thread. */
m_event_signalled |= UserSettings_onLiveWatershedChanged;
m_condition_variable.notify_one();
}

void OnPlaybackWatershedChanged(const bool enabled) override
void OnPlaybackWatershedChanged(const bool playbackWatershed) override
{
TEST_LOG("OnPlaybackWatershedChanged event triggered ***\n");
std::unique_lock<std::mutex> lock(m_mutex);
std::string str = enabled ? "true" : "false";
std::string str = playbackWatershed ? "true" : "false";

TEST_LOG("OnPlaybackWatershedChanged received: %s\n", str.c_str());
/* Notify the requester thread. */
m_event_signalled |= UserSettings_onPlaybackWatershedChanged;
m_condition_variable.notify_one();
}

void OnBlockNotRatedContentChanged(const bool enabled) override
void OnBlockNotRatedContentChanged(const bool blockNotRatedContent) override
{
TEST_LOG("OnBlockNotRatedContentChanged event triggered ***\n");
std::unique_lock<std::mutex> lock(m_mutex);
std::string str = enabled ? "true" : "false";
std::string str = blockNotRatedContent ? "true" : "false";

TEST_LOG("OnBlockNotRatedContentChanged received: %s\n", str.c_str());
/* Notify the requester thread. */
m_event_signalled |= UserSettings_onBlockNotRatedContentChanged;
m_condition_variable.notify_one();
}

void OnPinOnPurchaseChanged(const bool enabled) override
void OnPinOnPurchaseChanged(const bool pinOnPurchase) override
{
TEST_LOG("OnPinOnPurchaseChanged event triggered ***\n");
std::unique_lock<std::mutex> lock(m_mutex);
std::string str = enabled ? "true" : "false";
std::string str = pinOnPurchase ? "true" : "false";

TEST_LOG("OnPinOnPurchaseChanged received: %s\n", str.c_str());
/* Notify the requester thread. */
Expand Down Expand Up @@ -280,13 +281,13 @@ class UserSettingTest : public L2TestMocks {
void onCaptionsChanged(bool enabled);
void onPreferredCaptionsLanguagesChanged(const string preferredLanguages);
void onPreferredClosedCaptionServiceChanged(const string service);
void onPinControlChanged(const bool enabled);
void onPinControlChanged(const bool pinControl);
void onViewingRestrictionsChanged(const string viewingRestrictions);
void onViewingRestrictionsWindowChanged(const string viewingRestrictionsWindow);
void onLiveWatershedChanged(const bool enabled);
void onPlaybackWatershedChanged(const bool enabled);
void onBlockNotRatedContentChanged(const bool enabled);
void onPinOnPurchaseChanged(const bool enabled);
void onLiveWatershedChanged(const bool liveWatershed);
void onPlaybackWatershedChanged(const bool playbackWatershed);
void onBlockNotRatedContentChanged(const bool blockNotRatedContent);
void onPinOnPurchaseChanged(const bool pinOnPurchase);

uint32_t WaitForRequestStatus(uint32_t timeout_ms,UserSettingsL2test_async_events_t expected_status);
uint32_t CreateUserSettingInterfaceObjectUsingComRPCConnection();
Expand Down Expand Up @@ -476,11 +477,11 @@ void UserSettingTest::onPreferredClosedCaptionServiceChanged(const string servic
m_condition_variable.notify_one();
}

void UserSettingTest::onPinControlChanged(bool enabled)
void UserSettingTest::onPinControlChanged(bool pinControl)
{
TEST_LOG("OnPinControlChanged event triggered ***\n");
std::unique_lock<std::mutex> lock(m_mutex);
std::string str = enabled ? "true" : "false";
std::string str = pinControl ? "true" : "false";

TEST_LOG("OnPinControlChanged received: %s\n", str.c_str());
/* Notify the requester thread. */
Expand Down Expand Up @@ -512,47 +513,47 @@ void UserSettingTest::onViewingRestrictionsWindowChanged(const string viewingRes

}

void UserSettingTest::onLiveWatershedChanged(const bool enabled)
void UserSettingTest::onLiveWatershedChanged(const bool liveWatershed)
{
TEST_LOG("OnLiveWatershedChanged event triggered ***\n");
std::unique_lock<std::mutex> lock(m_mutex);
std::string str = enabled ? "true" : "false";
std::string str = liveWatershed ? "true" : "false";

TEST_LOG("OnLiveWatershedChanged received: %s\n", str.c_str());
/* Notify the requester thread. */
m_event_signalled |= UserSettings_onLiveWatershedChanged;
m_condition_variable.notify_one();
}

void UserSettingTest::onPlaybackWatershedChanged(const bool enabled)
void UserSettingTest::onPlaybackWatershedChanged(const bool playbackWatershed)
{
TEST_LOG("OnPlaybackWatershedChanged event triggered ***\n");
std::unique_lock<std::mutex> lock(m_mutex);
std::string str = enabled ? "true" : "false";
std::string str = playbackWatershed ? "true" : "false";

TEST_LOG("OnPlaybackWatershedChanged received: %s\n", str.c_str());
/* Notify the requester thread. */
m_event_signalled |= UserSettings_onPlaybackWatershedChanged;
m_condition_variable.notify_one();
}

void UserSettingTest::onBlockNotRatedContentChanged(const bool enabled)
void UserSettingTest::onBlockNotRatedContentChanged(const bool blockNotRatedContent)
{
TEST_LOG("OnBlockNotRatedContentChanged event triggered ***\n");
std::unique_lock<std::mutex> lock(m_mutex);
std::string str = enabled ? "true" : "false";
std::string str = blockNotRatedContent ? "true" : "false";

TEST_LOG("OnBlockNotRatedContentChanged received: %s\n", str.c_str());
/* Notify the requester thread. */
m_event_signalled |= UserSettings_onBlockNotRatedContentChanged;
m_condition_variable.notify_one();
}

void UserSettingTest::onPinOnPurchaseChanged(const bool enabled)
void UserSettingTest::onPinOnPurchaseChanged(const bool pinOnPurchase)
{
TEST_LOG("OnPinOnPurchaseChanged event triggered ***\n");
std::unique_lock<std::mutex> lock(m_mutex);
std::string str = enabled ? "true" : "false";
std::string str = pinOnPurchase ? "true" : "false";

TEST_LOG("OnPinOnPurchaseChanged received: %s\n", str.c_str());
/* Notify the requester thread. */
Expand Down Expand Up @@ -906,6 +907,12 @@ TEST_F(UserSettingTest, SetAndGetMethodsUsingJsonRpcConnectionSuccessCase)
uint32_t signalled = UserSettings_StateInvalid;

bool enabled = true;
bool pinControl = true;
bool liveWatershed = true;
bool playbackWatershed = true;
bool blockNotRatedContent = true;
bool pinOnPurchase = true;

string preferredLanguages = "en";
string presentationLanguage = "fra";
string preferredCaptionsLanguages = "en,es";
Expand Down Expand Up @@ -1072,16 +1079,16 @@ TEST_F(UserSettingTest, SetAndGetMethodsUsingJsonRpcConnectionSuccessCase)
status = jsonrpc.Subscribe<JsonObject>(JSON_TIMEOUT,
_T("onPinControlChanged"),
[this, &async_handler](const JsonObject& parameters) {
bool enabled = parameters["enabled"].Boolean();
async_handler.onPinControlChanged(enabled);
bool pinControl = parameters["pinControl"].Boolean();
async_handler.onPinControlChanged(pinControl);
});
EXPECT_EQ(Core::ERROR_NONE, status);

EXPECT_CALL(async_handler, onPinControlChanged(MatchRequestStatusBool(enabled)))
EXPECT_CALL(async_handler, onPinControlChanged(MatchRequestStatusBool(pinControl)))
.WillOnce(Invoke(this, &UserSettingTest::onPinControlChanged));

JsonObject paramsPinControl;
paramsPinControl["enabled"] = true;
paramsPinControl["pinControl"] = true;
status = InvokeServiceMethod("org.rdk.UserSettings", "setPinControl", paramsPinControl, result_json);
EXPECT_EQ(status,Core::ERROR_NONE);

Expand Down Expand Up @@ -1152,16 +1159,16 @@ TEST_F(UserSettingTest, SetAndGetMethodsUsingJsonRpcConnectionSuccessCase)
status = jsonrpc.Subscribe<JsonObject>(JSON_TIMEOUT,
_T("onLiveWatershedChanged"),
[this, &async_handler](const JsonObject& parameters) {
bool enabled = parameters["enabled"].Boolean();
async_handler.onLiveWatershedChanged(enabled);
bool liveWatershed = parameters["liveWatershed"].Boolean();
async_handler.onLiveWatershedChanged(liveWatershed);
});
EXPECT_EQ(Core::ERROR_NONE, status);

EXPECT_CALL(async_handler, onLiveWatershedChanged(MatchRequestStatusBool(enabled)))
EXPECT_CALL(async_handler, onLiveWatershedChanged(MatchRequestStatusBool(liveWatershed)))
.WillOnce(Invoke(this, &UserSettingTest::onLiveWatershedChanged));

JsonObject paramsLiveWatershed;
paramsLiveWatershed["enabled"] = true;
paramsLiveWatershed["liveWatershed"] = true;
status = InvokeServiceMethod("org.rdk.UserSettings", "setLiveWatershed", paramsLiveWatershed, result_json);
EXPECT_EQ(status,Core::ERROR_NONE);

Expand All @@ -1180,16 +1187,16 @@ TEST_F(UserSettingTest, SetAndGetMethodsUsingJsonRpcConnectionSuccessCase)
status = jsonrpc.Subscribe<JsonObject>(JSON_TIMEOUT,
_T("onPlaybackWatershedChanged"),
[this, &async_handler](const JsonObject& parameters) {
bool enabled = parameters["enabled"].Boolean();
async_handler.onPlaybackWatershedChanged(enabled);
bool playbackWatershed = parameters["playbackWatershed"].Boolean();
async_handler.onPlaybackWatershedChanged(playbackWatershed);
});
EXPECT_EQ(Core::ERROR_NONE, status);

EXPECT_CALL(async_handler, onPlaybackWatershedChanged(MatchRequestStatusBool(enabled)))
EXPECT_CALL(async_handler, onPlaybackWatershedChanged(MatchRequestStatusBool(playbackWatershed)))
.WillOnce(Invoke(this, &UserSettingTest::onPlaybackWatershedChanged));

JsonObject paramsPlaybackWatershed;
paramsPlaybackWatershed["enabled"] = true;
paramsPlaybackWatershed["playbackWatershed"] = true;
status = InvokeServiceMethod("org.rdk.UserSettings", "setPlaybackWatershed", paramsPlaybackWatershed, result_json);
EXPECT_EQ(status,Core::ERROR_NONE);

Expand All @@ -1208,16 +1215,16 @@ TEST_F(UserSettingTest, SetAndGetMethodsUsingJsonRpcConnectionSuccessCase)
status = jsonrpc.Subscribe<JsonObject>(JSON_TIMEOUT,
_T("onBlockNotRatedContentChanged"),
[this, &async_handler](const JsonObject& parameters) {
bool enabled = parameters["enabled"].Boolean();
async_handler.onBlockNotRatedContentChanged(enabled);
bool blockNotRatedContent = parameters["blockNotRatedContent"].Boolean();
async_handler.onBlockNotRatedContentChanged(blockNotRatedContent);
});
EXPECT_EQ(Core::ERROR_NONE, status);

EXPECT_CALL(async_handler, onBlockNotRatedContentChanged(MatchRequestStatusBool(enabled)))
EXPECT_CALL(async_handler, onBlockNotRatedContentChanged(MatchRequestStatusBool(blockNotRatedContent)))
.WillOnce(Invoke(this, &UserSettingTest::onBlockNotRatedContentChanged));

JsonObject paramsBlockNotRatedContent;
paramsBlockNotRatedContent["enabled"] = true;
paramsBlockNotRatedContent["blockNotRatedContent"] = true;
status = InvokeServiceMethod("org.rdk.UserSettings", "setBlockNotRatedContent", paramsBlockNotRatedContent, result_json);
EXPECT_EQ(status,Core::ERROR_NONE);

Expand All @@ -1236,16 +1243,16 @@ TEST_F(UserSettingTest, SetAndGetMethodsUsingJsonRpcConnectionSuccessCase)
status = jsonrpc.Subscribe<JsonObject>(JSON_TIMEOUT,
_T("onPinOnPurchaseChanged"),
[this, &async_handler](const JsonObject& parameters) {
bool enabled = parameters["enabled"].Boolean();
async_handler.onPinOnPurchaseChanged(enabled);
bool pinOnPurchase = parameters["pinOnPurchase"].Boolean();
async_handler.onPinOnPurchaseChanged(pinOnPurchase);
});
EXPECT_EQ(Core::ERROR_NONE, status);

EXPECT_CALL(async_handler, onPinOnPurchaseChanged(MatchRequestStatusBool(enabled)))
EXPECT_CALL(async_handler, onPinOnPurchaseChanged(MatchRequestStatusBool(pinOnPurchase)))
.WillOnce(Invoke(this, &UserSettingTest::onPinOnPurchaseChanged));

JsonObject paramsPinOnPurchase;
paramsPinOnPurchase["enabled"] = true;
paramsPinOnPurchase["pinOnPurchase"] = true;
status = InvokeServiceMethod("org.rdk.UserSettings", "setPinOnPurchase", paramsPinOnPurchase, result_json);
EXPECT_EQ(status,Core::ERROR_NONE);

Expand Down
Loading
Loading