Skip to content

Commit ddc46dc

Browse files
committed
Merge branch 'feature/gateway-end-to-end' into feature/gateway-layer-part-2
2 parents 0843782 + a0a3d13 commit ddc46dc

File tree

10 files changed

+3050
-1712
lines changed

10 files changed

+3050
-1712
lines changed

package-lock.json

Lines changed: 1996 additions & 1656 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/sdks/core/src/cpp/sdk/cpptest/CoreSDKTest.cpp

Lines changed: 324 additions & 13 deletions
Large diffs are not rendered by default.

src/sdks/core/src/cpp/sdk/cpptest/CoreSDKTest.h

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#pragma once
2020

2121
#include <iostream>
22+
#include <nlohmann/json.hpp>
2223
#include "firebolt.h"
2324

2425
class CoreSDKTest {
@@ -178,14 +179,21 @@ class CoreSDKTest {
178179
static void DiscoveryWatched();
179180
static void DiscoveryWatchedReduced();
180181
#endif
181-
static void SubscribeDiscoveryOnNavigateToLaunchNotification();
182-
static void UnsubscribeDiscoveryOnNavigateToLaunchNotification();
182+
static void SubscribeDiscoveryOnNavigateToLaunchHomeIntentNotification();
183+
static void SubscribeDiscoveryOnNavigateToLaunchEntityIntentNotification();
184+
static void SubscribeDiscoveryOnNavigateToLaunchTuneIntentNotification();
185+
static void UnsubscribeDiscoveryOnNavigateToLaunchHomeIntentNotification();
186+
static void UnsubscribeDiscoveryOnNavigateToLaunchEntityIntentNotification();
187+
static void UnsubscribeDiscoveryOnNavigateToLaunchTuneIntentNotification();
183188
static void DiscoveryWatchNext();
184189
static void DiscoveryUserInterest();
185190

186191
static void ParametersInitialization();
187192

188193
static bool WaitOnConnectionReady();
194+
195+
static void event_trigger(nlohmann::json event);
196+
static void provider_trigger(nlohmann::json provider);
189197

190198
private:
191199
static void ConnectionChanged(const bool, const Firebolt::Error);
@@ -206,4 +214,19 @@ class CoreSDKTest {
206214
static KeyboardEmailAsyncResponse _keyboardEmailAsyncResponse;
207215
static KeyboardPasswordAsyncResponse _keyboardPasswordAsyncResponse;
208216
static KeyboardStandardAsyncResponse _keyboardStandardAsyncResponse;
217+
218+
public:
219+
static const nlohmann::json adPolicy;
220+
static const nlohmann::json deviceName;
221+
static const nlohmann::json audioChanged;
222+
static const nlohmann::json deviceScreenResolutionChanged;
223+
static const nlohmann::json preferredAudioLanguagesChanged;
224+
static const nlohmann::json closedCaptionsSettingsChanged;
225+
static const nlohmann::json backgroundNotification;
226+
static const nlohmann::json foregroundNotification;
227+
static const nlohmann::json friendlyNameChanged;
228+
static const nlohmann::json navigateTo;
229+
static const nlohmann::json keyboardStandard;
230+
static const nlohmann::json keyboardEmail;
231+
static const nlohmann::json keyboardPassword;
209232
};

src/sdks/core/src/cpp/sdk/cpptest/Main.cpp

Lines changed: 257 additions & 11 deletions
Large diffs are not rendered by default.

src/sdks/discovery/src/cpp/sdk/cpptest/DiscoverySDKTest.cpp

Lines changed: 129 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,98 @@
1919
#include <unistd.h>
2020
#include <cstring>
2121
#include <string>
22+
#include <cassert>
2223
#include "DiscoverySDKTest.h"
2324

2425
using namespace std;
2526
bool DiscoverySDKTest::_connected;
2627
DiscoverySDKTest::OnUserInterestNotification DiscoverySDKTest::_userInterestNotification;
2728

29+
#ifdef GATEWAY_BIDIRECTIONAL
30+
31+
const nlohmann::json DiscoverySDKTest::userInterestEvent = {
32+
{"method", "content.onUserInterest"},
33+
{"payload", {
34+
{"name", "interest"},
35+
{"appId", "cool-app"},
36+
{"type", "interest"},
37+
{"reason", "playlist"},
38+
{"entity", {
39+
{"identifiers", {
40+
{"entityId", "345"},
41+
{"entityType", "program"},
42+
{"programType", "movie"}
43+
}},
44+
{"info", {
45+
{"title", "Cool Runnings"},
46+
{"synopsis", "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Pulvinar sapien et ligula ullamcorper malesuada proin libero nunc."},
47+
{"releaseDate", "1993-01-01T00:00:00.000Z"},
48+
{"contentRatings", {
49+
{
50+
{"scheme", "US-Movie"},
51+
{"rating", "PG"}
52+
},
53+
{
54+
{"scheme", "CA-Movie"},
55+
{"rating", "G"}
56+
}
57+
}}
58+
}}
59+
}}
60+
}}
61+
};
62+
63+
64+
void DiscoverySDKTest::event_trigger(nlohmann::json event)
65+
{
66+
std::cout << "Event triggered: " << event["method"].dump() << std::endl;
67+
std::string trigger_cmd = "curl --location --request POST http://localhost:3333/api/v1/bidirectionalEventPayload --header 'Content-Type: application/json' --data-raw '{ \"method\": " + event["method"].dump() + ", \"params\": " + event["payload"].dump() + "}'";
68+
system(trigger_cmd.c_str());
69+
std::cout << std::endl;
70+
std::cout << "[ADITYA] trigger_cmd: " << trigger_cmd << std::endl;
71+
}
72+
73+
void DiscoverySDKTest::provider_trigger(nlohmann::json provider)
74+
{
75+
std::cout << "Provider triggered: " << provider["method"].dump() << std::endl;
76+
std::string trigger_cmd = "curl --location --request POST http://localhost:3333/api/v1/bidirectionalPayload --header 'Content-Type: application/json' --data-raw '{ \"method\": " + provider["method"].dump() + ", \"params\": " + provider["payload"].dump() + "}'";
77+
system(trigger_cmd.c_str());
78+
std::cout << std::endl;
79+
}
80+
81+
std::string InterestTypeToString(Firebolt::Discovery::InterestType interestType) {
82+
switch (interestType) {
83+
case Firebolt::Discovery::InterestType::INTEREST:
84+
return "interest";
85+
case Firebolt::Discovery::InterestType::DISINTEREST:
86+
return "disinterest";
87+
default:
88+
return "unknown";
89+
}
90+
}
91+
92+
std::string InterestReasonToString(Firebolt::Discovery::InterestReason interestReason) {
93+
switch (interestReason) {
94+
case Firebolt::Discovery::InterestReason::PLAYLIST:
95+
return "playlist";
96+
case Firebolt::Discovery::InterestReason::REACTION:
97+
return "reaction";
98+
case Firebolt::Discovery::InterestReason::RECORDING:
99+
return "recording";
100+
default:
101+
return "unknown";
102+
}
103+
}
104+
105+
106+
#endif
107+
28108
void DiscoverySDKTest::ConnectionChanged(const bool connected, const Firebolt::Error error)
29109
{
30-
cout << "Change in connection: connected: " << connected << " error: " << static_cast<int>(error) << endl;
31-
_connected = connected;
110+
if (!_connected) {
111+
cout << "Change in connection: connected: " << connected << " error: " << static_cast<int>(error) << endl;
112+
_connected = connected;
113+
}
32114
}
33115

34116
void DiscoverySDKTest::CreateFireboltInstance(const std::string& url)
@@ -67,6 +149,7 @@ bool DiscoverySDKTest::WaitOnConnectionReady()
67149
usleep(sleepSlot);
68150
waiting -= sleepSlot;
69151
}
152+
usleep(5000);
70153
return _connected;
71154
}
72155

@@ -90,9 +173,51 @@ inline const T ConvertToEnum(EnumMap<T> enumMap, const string& str)
90173
return value;
91174
}
92175

93-
void DiscoverySDKTest::OnUserInterestNotification::onUserInterest( const Firebolt::Content::InterestEvent& interest)
176+
std::string ContentRatingSchemeToString(Firebolt::Entertainment::ContentRatingScheme scheme)
177+
{
178+
switch (scheme)
179+
{
180+
case Firebolt::Entertainment::ContentRatingScheme::CA_MOVIE:
181+
return "CA-Movie";
182+
case Firebolt::Entertainment::ContentRatingScheme::CA_TV:
183+
return "CA-TV";
184+
case Firebolt::Entertainment::ContentRatingScheme::CA_MOVIE_FR:
185+
return "CA-Movie_Fr";
186+
case Firebolt::Entertainment::ContentRatingScheme::CA_TV_FR:
187+
return "CA-TV_Fr";
188+
case Firebolt::Entertainment::ContentRatingScheme::US_MOVIE:
189+
return "US-Movie";
190+
case Firebolt::Entertainment::ContentRatingScheme::US_TV:
191+
return "US-TV";
192+
default:
193+
return "UNKNOWN";
194+
}
195+
}
196+
197+
void DiscoverySDKTest::OnUserInterestNotification::onUserInterest(const Firebolt::Content::InterestEvent &interest)
94198
{
95-
cout << "User Interest changed notification" << endl;
199+
cout << "onUserInterest() notification \n";
200+
201+
#ifdef GATEWAY_BIDIRECTIONAL
202+
assert(interest.appId == userInterestEvent["payload"]["appId"]);
203+
assert(InterestTypeToString(interest.type) == userInterestEvent["payload"]["type"]);
204+
assert(InterestReasonToString(interest.reason) == userInterestEvent["payload"]["reason"]);
205+
assert(interest.entity.info->title.value() == userInterestEvent["payload"]["entity"]["info"]["title"]);
206+
assert(interest.entity.info->synopsis.value() == userInterestEvent["payload"]["entity"]["info"]["synopsis"]);
207+
assert(interest.entity.info->releaseDate.value() == userInterestEvent["payload"]["entity"]["info"]["releaseDate"]);
208+
size_t i = 0;
209+
for (const auto &rating : interest.entity.info->contentRatings.value())
210+
{
211+
assert(ContentRatingSchemeToString(rating.scheme) == userInterestEvent["payload"]["entity"]["info"]["contentRatings"][i]["scheme"]);
212+
i++;
213+
}
214+
size_t j = 0;
215+
for (const auto &ratings : interest.entity.info->contentRatings.value())
216+
{
217+
assert(ratings.rating == userInterestEvent["payload"]["entity"]["info"]["contentRatings"][j]["rating"]);
218+
j++;
219+
}
220+
#endif
96221
}
97222

98223
void DiscoverySDKTest::SubscribeUserInterest()

src/sdks/discovery/src/cpp/sdk/cpptest/DiscoverySDKTest.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#pragma once
2020

2121
#include <iostream>
22+
#include <nlohmann/json.hpp>
2223
#include "firebolt.h"
2324

2425
class DiscoverySDKTest {
@@ -41,9 +42,19 @@ class DiscoverySDKTest {
4142

4243
static bool WaitOnConnectionReady();
4344

45+
#ifdef GATEWAY_BIDIRECTIONAL
46+
static void event_trigger(nlohmann::json event);
47+
static void provider_trigger(nlohmann::json provider);
48+
#endif
49+
4450
private:
4551
static void ConnectionChanged(const bool, const Firebolt::Error);
4652
static bool _connected;
4753
static OnUserInterestNotification _userInterestNotification;
4854

55+
#ifdef GATEWAY_BIDIRECTIONAL
56+
public:
57+
static const nlohmann::json userInterestEvent;
58+
#endif
59+
4960
};

src/sdks/discovery/src/cpp/sdk/cpptest/Main.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <string>
2222
#include <iostream>
2323
#include <stdexcept>
24+
#include <unistd.h>
2425
#include "DiscoverySDKTest.h"
2526

2627
using namespace std;
@@ -42,8 +43,11 @@ void RunAllTests() {
4243

4344
// Ensure the connection is ready before running tests
4445
if (DiscoverySDKTest::WaitOnConnectionReady()) {
46+
47+
sleep(2);
4548

4649
runTest(DiscoverySDKTest::SubscribeUserInterest, "SubscribeUserInterest");
50+
DiscoverySDKTest::event_trigger(DiscoverySDKTest::userInterestEvent);
4751
runTest(DiscoverySDKTest::UnsubscribeUserInterest, "UnsubscribeUserInterest");
4852
runTest(DiscoverySDKTest::RequestUserInterest, "RequestUserInterest");
4953

src/sdks/manage/src/cpp/sdk/cpptest/Main.cpp

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <string>
2222
#include <iostream>
2323
#include <stdexcept>
24+
#include <unistd.h>
2425
#include "ManageSDKTest.h"
2526

2627
using namespace std;
@@ -54,29 +55,34 @@ void RunAllTests() {
5455
runTest(ManageSDKTest::GetAudioDescriptionsEnabled, "GetAudioDescriptionsEnabled");
5556
runTest(ManageSDKTest::SetAudioDescriptionsEnabled, "SetAudioDescriptionsEnabled");
5657
runTest(ManageSDKTest::SubscribeAudioDescriptionsEnabledChanged, "SubscribeAudioDescriptionsEnabledChanged");
58+
ManageSDKTest::event_trigger(ManageSDKTest::audioDescriptionsEnabledChanged);
5759
runTest(ManageSDKTest::UnsubscribeAudioDescriptionsEnabledChanged, "UnsubscribeAudioDescriptionsEnabledChanged");
5860

5961
// Device methods
6062
runTest(ManageSDKTest::GetDeviceName, "GetDeviceName");
6163
runTest(ManageSDKTest::SetDeviceName, "SetDeviceName");
6264
runTest(ManageSDKTest::SubscribeDeviceNameChanged, "SubscribeDeviceNameChanged");
65+
ManageSDKTest::event_trigger(ManageSDKTest::deviceNameChanged);
6366
runTest(ManageSDKTest::UnsubscribeDeviceNameChanged, "UnsubscribeDeviceNameChanged");
6467

6568
// ClosedCaptions methods
6669
runTest(ManageSDKTest::GetClosedCaptionsBackgroundOpacity, "GetClosedCaptionsBackgroundOpacity");
6770
runTest(ManageSDKTest::SetClosedCaptionsBackgroundOpacity, "SetClosedCaptionsBackgroundOpacity");
6871
runTest(ManageSDKTest::SubscribeClosedCaptionsBackgroundOpacityChanged, "SubscribeClosedCaptionsBackgroundOpacityChanged");
72+
ManageSDKTest::event_trigger(ManageSDKTest::backgroundOpacityChanged);
6973
runTest(ManageSDKTest::UnsubscribeClosedCaptionsBackgroundOpacityChanged, "UnsubscribeClosedCaptionsBackgroundOpacityChanged");
7074

7175
runTest(ManageSDKTest::GetClosedCaptionsFontFamily, "GetClosedCaptionsFontFamily");
7276
runTest(ManageSDKTest::SetClosedCaptionsFontFamily, "SetClosedCaptionsFontFamily");
7377
runTest(ManageSDKTest::SubscribeClosedCaptionsFontFamilyChanged, "SubscribeClosedCaptionsFontFamilyChanged");
78+
ManageSDKTest::event_trigger(ManageSDKTest::fontFamilyChanged);
7479
runTest(ManageSDKTest::UnsubscribeClosedCaptionsFontFamilyChanged, "UnsubscribeClosedCaptionsFontFamilyChanged");
7580

7681
// Localization methods
7782
runTest(ManageSDKTest::GetLocalizationPreferredAudioLanguages, "GetLocalizationPreferredAudioLanguages");
7883
runTest(ManageSDKTest::SetLocalizationPreferredAudioLanguages, "SetLocalizationPreferredAudioLanguages");
7984
runTest(ManageSDKTest::SubscribeLocalizationPreferredAudioLanguagesChanged, "SubscribeLocalizationPreferredAudioLanguagesChanged");
85+
ManageSDKTest::event_trigger(ManageSDKTest::preferredAudioLanguagesChanged);
8086
runTest(ManageSDKTest::UnsubscribeLocalizationPreferredAudioLanguagesChanged, "UnsubscribeLocalizationPreferredAudioLanguagesChanged");
8187

8288
runTest(ManageSDKTest::GetLocalizationAdditionalInfo, "GetLocalizationAdditionalInfo");
@@ -87,14 +93,17 @@ void RunAllTests() {
8793
runTest(ManageSDKTest::GetPrivacyAllowACRCollection, "GetPrivacyAllowACRCollection");
8894
runTest(ManageSDKTest::SetPrivacyAllowACRCollection, "SetPrivacyAllowACRCollection");
8995
runTest(ManageSDKTest::SubscribePrivacyAllowACRCollectionChanged, "SubscribePrivacyAllowACRCollectionChanged");
96+
ManageSDKTest::event_trigger(ManageSDKTest::allowACRCollectionChanged);
9097
runTest(ManageSDKTest::UnsubscribePrivacyAllowACRCollectionChanged, "UnsubscribePrivacyAllowACRCollectionChanged");
9198

9299
runTest(ManageSDKTest::GetPrivacySettings, "GetPrivacySettings");
93100

94101
// Discovery methods
95102
runTest(ManageSDKTest::SubscribeDiscoverySignInNotification, "SubscribeDiscoverySignInNotification");
103+
ManageSDKTest::event_trigger(ManageSDKTest::signInEvent);
96104
runTest(ManageSDKTest::UnsubscribeDiscoverySignInNotification, "UnsubscribeDiscoverySignInNotification");
97105
runTest(ManageSDKTest::SubscribeDiscoverySignOutNotification, "SubscribeDiscoverySignOutNotification");
106+
ManageSDKTest::event_trigger(ManageSDKTest::signOutEvent);
98107
runTest(ManageSDKTest::UnsubscribeDiscoverySignOutNotification, "UnsubscribeDiscoverySignOutNotification");
99108

100109
// UserGrants methods
@@ -103,25 +112,30 @@ void RunAllTests() {
103112
runTest(ManageSDKTest::DenyUserGrantsPermission, "DenyUserGrantsPermission");
104113
runTest(ManageSDKTest::ClearUserGrantsPermission, "ClearUserGrantsPermission");
105114

106-
// Wifi methods
107-
// runTest(ManageSDKTest::WifiScan, "WifiScan");
108-
// runTest(ManageSDKTest::WifiConnect, "WifiConnect");
109-
// runTest(ManageSDKTest::WifiDisconnect, "WifiDisconnect");
110-
111115
// Provider registration
112116
runTest(ManageSDKTest::RegisterKeyboardProvider, "RegisterKeyboardProvider");
117+
ManageSDKTest::provider_trigger(ManageSDKTest::requestStandard);
118+
runTest(ManageSDKTest::SendResponseMessageToKeyboardProvider, "SendResponseMessageToKeyboardProvider");
119+
120+
runTest(ManageSDKTest::RegisterKeyboardProvider, "RegisterKeyboardProvider");
121+
ManageSDKTest::provider_trigger(ManageSDKTest::requestEmail);
113122
runTest(ManageSDKTest::SendResponseMessageToKeyboardProvider, "SendResponseMessageToKeyboardProvider");
114-
runTest(ManageSDKTest::SendErrorMessageToKeyboardProvider, "SendErrorMessageToKeyboardProvider");
115123

116-
runTest(ManageSDKTest::RegisterAcknowledgeChallengeProvider, "RegisterAcknowledgeChallengeProvider");
117-
runTest(ManageSDKTest::SendResponseMessageToAcknowledgeChallengeProvider, "SendResponseMessageToAcknowledgeChallengeProvider");
118-
runTest(ManageSDKTest::SendErrorMessageToAcknowledgeChallengeProvider, "SendErrorMessageToAcknowledgeChallengeProvider");
124+
runTest(ManageSDKTest::RegisterKeyboardProvider, "RegisterKeyboardProvider");
125+
ManageSDKTest::provider_trigger(ManageSDKTest::requestPassword);
126+
runTest(ManageSDKTest::SendResponseMessageToKeyboardProvider, "SendResponseMessageToKeyboardProvider");
127+
128+
// runTest(ManageSDKTest::RegisterAcknowledgeChallengeProvider, "RegisterAcknowledgeChallengeProvider");
129+
// ManageSDKTest::provider_trigger(ManageSDKTest::ackRequestChallenge);
130+
// runTest(ManageSDKTest::SendResponseMessageToAcknowledgeChallengeProvider, "SendResponseMessageToAcknowledgeChallengeProvider");
131+
132+
// runTest(ManageSDKTest::RegisterPinChallengeProvider, "RegisterPinChallengeProvider");
133+
// ManageSDKTest::provider_trigger(ManageSDKTest::pinRequestChallenge);
134+
// runTest(ManageSDKTest::SendResponseMessageToPinChallengeProvider, "SendResponseMessageToPinChallengeProvider");
119135

120-
runTest(ManageSDKTest::RegisterPinChallengeProvider, "RegisterPinChallengeProvider");
121-
runTest(ManageSDKTest::SendResponseMessageToPinChallengeProvider, "SendResponseMessageToPinChallengeProvider");
122-
runTest(ManageSDKTest::SendErrorMessageToPinChallengeProvider, "SendErrorMessageToPinChallengeProvider");
123136

124137
runTest(ManageSDKTest::GlobalSubscribeHdmiAutoLowLatencyModeCapableChanged, "GlobalSubscribeHdmiAutoLowLatencyModeCapableChanged");
138+
ManageSDKTest::event_trigger(ManageSDKTest::autoLowLatencyModeCapableChanged);
125139
runTest(ManageSDKTest::GlobalUnsubscribeHdmiAutoLowLatencyModeCapableChanged, "GlobalUnsubscribeHdmiAutoLowLatencyModeCapableChanged");
126140

127141
runTest(ManageSDKTest::GetAutoLowLatencyModeCapable, "GetAutoLowLatencyModeCapable");

0 commit comments

Comments
 (0)