JD2022-TU1/main/extern/UbiServices/custom/testsIntegration/testXPlay.cpp

1431 lines
51 KiB
C++

////////////////////////////////////////////////////////////////////////////////
// (c) Copyright, Ubisoft Entertainment Inc. || Created by Technology Group //
////////////////////////////////////////////////////////////////////////////////
#include "tests/config.h"
#if defined(US_SDK_FULL)
#include "tests/common/configs.h"
#include "tests/common/helpers.h"
#include "tests/fixture/authenticationFixture.h"
#include "tests/fixture/loginMockFixture.h"
#include "tests/fixture/paramFixture.h"
#include "tests/mock/mockLogDevice.h"
#include "tests/mock/mockResultHelper.h"
#include "tests/mock/parametersMockHelper.h"
#include <../private/ubiservices/core/configs/platformName.h>
#include <ubiservices/core/errors/errorCodes.h>
#include <ubiservices/platformHelper.h>
#include <ubiservices/services/club/actionsGroup.h>
#include <ubiservices/services/club/clubClient.h>
#include <ubiservices/services/entity/entityClient.h>
#include <ubiservices/services/entity/entityCreation.h>
#include <ubiservices/services/entity/entityProfile.h>
#include <ubiservices/services/event/eventClient.h>
#include <ubiservices/services/event/types/eventInfoCustom.h>
#include <ubiservices/services/friend/friendClient.h>
#include <ubiservices/services/leaderboard/leaderboardClient.h>
#include <ubiservices/services/news/newsClient.h>
#include <ubiservices/services/news/newsInfo.h>
#include <ubiservices/services/parameters/parametersClient.h>
#include <ubiservices/services/populations/populationClient.h>
#include <ubiservices/services/populations/populationInfo.h>
#include <ubiservices/services/primaryStore/primaryStoreClient.h>
#include <ubiservices/services/primaryStore/primaryStoreInventoryItem.h>
#include <ubiservices/services/primaryStore/primaryStoreItem.h>
#include <ubiservices/services/profile/applicationUsedInfo.h>
#include <ubiservices/services/profile/profileClient.h>
#include <ubiservices/services/remoteLog/remoteLog.h>
#include <ubiservices/services/remoteLog/remoteLogClient.h>
#include <ubiservices/services/secondaryStore/offerSpace.h>
#include <ubiservices/services/secondaryStore/secondaryStoreClient.h>
#include <ubiservices/services/secondaryStore/storeItemsMapping.h>
#include <ubiservices/services/stats/statsClient.h>
#include <ubiservices/services/user/userClient.h>
#include <usCommon/authenticationHelper.h>
#include <usCommon/firstPartyInit.h>
#if defined(US_TARGET_SWITCH)
#include <nn/nn_Common.h>
#include <nn/ec.h>
#endif
namespace US_NS{;
US_DEFINE_TEST(TestXPlay);
const char* HARBOUR_XPLAY_PC_APP_ID = "356d98ee-ae23-4f3e-b42f-b4fdd5f983de";
const char* HARBOUR_XPLAY_PS4_APP_ID = "006a2b6d-a99c-448e-8ad1-08c92ec4aaa5";
const char* HARBOUR_XPLAY_XONE_APP_ID = "f60c227c-1dcc-49de-ab29-6c5b694be2a6";
const char* HARBOUR_XPLAY_SWITCH_APP_ID = "97096763-da1a-46e0-b567-eef446200490";
const char* HARBOUR_XPLAY_KILI_APP_ID = "356d98ee-ae23-4f3e-b42f-b4fdd5f983de"; //to change
const char* HARBOUR_XPLAY_STADIA_APP_ID = "60380075-da3a-4b9c-8c46-0836bd4633ce";
#if defined(US_TARGET_WINDOWS)
//const char* HARBOUR_XPLAY_APP_ID = "356d98ee-ae23-4f3e-b42f-b4fdd5f983de";
#define HARBOUR_XPLAY_APP_ID HARBOUR_XPLAY_PC_APP_ID
#elif defined(US_TARGET_PS4)
//const char* HARBOUR_XPLAY_APP_ID = "006a2b6d-a99c-448e-8ad1-08c92ec4aaa5";
#define HARBOUR_XPLAY_APP_ID HARBOUR_XPLAY_PS4_APP_ID
#elif defined(US_TARGET_XONE)
//const char* HARBOUR_XPLAY_APP_ID = "f60c227c-1dcc-49de-ab29-6c5b694be2a6";
#define HARBOUR_XPLAY_APP_ID HARBOUR_XPLAY_XONE_APP_ID
#elif defined(US_TARGET_SWITCH)
//const char* HARBOUR_XPLAY_SWITCH_APP_ID = "97096763-da1a-46e0-b567-eef446200490";
#define HARBOUR_XPLAY_APP_ID HARBOUR_XPLAY_SWITCH_APP_ID
#elif defined(US_TARGET_KILI)
//const char* HARBOUR_XPLAY_APP_ID = "006a2b6d-a99c-448e-8ad1-08c92ec4aaa5";
#define HARBOUR_XPLAY_APP_ID HARBOUR_XPLAY_KILI_APP_ID
#elif defined(US_TARGET_GGP)
//const char* HARBOUR_XPLAY_APP_ID = "60380075-da3a-4b9c-8c46-0836bd4633ce";
#define HARBOUR_XPLAY_APP_ID HARBOUR_XPLAY_STADIA_APP_ID
#else
//Using PC App Id for other platforms in the meantime
#define HARBOUR_XPLAY_APP_ID HARBOUR_XPLAY_PC_APP_ID
#endif
const char* HARBOUR_XPLAY_BUILD_ID = "HARBOUR_XPLAY_BUILD";
const char* HARBOUR_XPLAY_SPACE_ID = "65b080dc-d03d-4190-b911-c90e03c4592d";
const char* HARBOUR_XPLAY_PC_SPACE_ID = "105c5af5-9d12-4943-88a5-17494b4f64ab";
const char* HARBOUR_XPLAY_PS4_SPACE_ID = "889260fa-f2aa-45e5-8479-7de78d6f4bb7";
const char* HARBOUR_XPLAY_XONE_SPACE_ID = "6d7af669-7fe7-4af4-9b9a-cf3a303115dd";
const char* HARBOUR_XPLAY_SWITCH_SPACE_ID = "0c59847d-10a4-4517-a999-ed1e00957880";
const char* HARBOUR_XPLAY_KILI_SPACE_ID = "889260fa-f2aa-45e5-8479-7de78d6f4bb7";
const char* HARBOUR_XPLAY_STADIA_SPACE_ID = "0d31ff36-fa09-4af5-b525-da176b7581f2";
class LeakCheckerXplay : public LeakChecker
{
protected:
void initDefaultSDK() override
{
{
initializeSdk();
if (m_type != InitNoScheduler)
{
const GameConfigEvent gameConfigEvent(US_SDK_VERSION_CONST_CHAR, US_TEST_NS::US_SDK_DUMMY_GAME_SKU, Vector<EventTypeInfo>());
const GameConfig gameConfig(ApplicationId(HARBOUR_XPLAY_APP_ID), HARBOUR_XPLAY_BUILD_ID, OnlineAccessContext::Standard, gameConfigEvent,
#if defined(US_TARGET_PS4) || defined(US_TARGET_SWITCH) || defined(US_TARGET_XONE) || defined(US_TARGET_GGP) || defined(US_TARGET_KILI)
GameConfigConsole(NS_COMMON::FIRSTPARTY_APP_ID),
#else
GameConfigConsole(),
#endif
CrossPlayState::On);
ASSERT_EQ(configureSdk(gameConfig), ConfigureResult::Success);
}
};
}
};
class LoginMockFixtureXplay : public LoginMockFixture<false>
{
protected:
void initDefaultSDK() override
{
{
initializeSdk();
if (m_type != InitNoScheduler)
{
const GameConfigEvent gameConfigEvent(US_SDK_VERSION_CONST_CHAR, US_TEST_NS::US_SDK_DUMMY_GAME_SKU, Vector<EventTypeInfo>());
const GameConfig gameConfig(ApplicationId(HARBOUR_XPLAY_APP_ID), HARBOUR_XPLAY_BUILD_ID, OnlineAccessContext::Standard, gameConfigEvent,
#if defined(US_TARGET_PS4) || defined(US_TARGET_SWITCH) || defined(US_TARGET_XONE) || defined(US_TARGET_GGP) || defined(US_TARGET_KILI)
GameConfigConsole(NS_COMMON::FIRSTPARTY_APP_ID),
#else
GameConfigConsole(),
#endif
CrossPlayState::On);
ASSERT_EQ(configureSdk(gameConfig), ConfigureResult::Success);
}
};
}
};
typedef LoginMockFixtureXplay XPLAY_MOCK_NO_LOGIN;
typedef LeakCheckerXplay XPLAY;
typedef AuthenticationFixture<1, true> XPLAY_LOGIN;
namespace Xplay_BF
{
PlayerCredentials getPlayerCredentials(unsigned int playerId = 1)
{
#if defined(US_TARGET_WINDOWS)
const String email = String::formatText("harbourxplay_0%u@ubisoft.com", playerId);
const String password = "a1234567";
return PlayerCredentials(email, password);
#else
US_UNUSED(playerId);
return *NS_COMMON::AuthenticationHelper::createCredentials();
#endif
}
struct XplayFeatureSwitchesParams
{
FeatureSwitchState applicationSwitchState;
FeatureSwitchState spaceSwitchSwitchState;
bool isFeatureSwitchEnabled;
};
void setupMocksForDynamicPopulation(US_TEST_NS::MockLogDevice* logDevice)
{
// Make sure our GET parameters works
EXPECT_CALL(*logDevice, output(US_TEST_NS::US_MOCK_STRING_FINDNOCASE("\"parameters\":{\"us-staging\":{\"fields\":{\"spaceId\":\"65b080dc-d03d-4190-b911-c90e03c4592d\"}"),
LogLevel::Debug, ::testing::_, ::testing::_)).Times(testing::AtLeast(1));
String putRequest = String::formatText("\"US_SDK_APPLICATION_BUILD_ID\":\"HARBOUR_XPLAY_BUILD\",\"US_SDK_PLATFORM_NAME\":\"%s\"", US_PLATFORM_NAME);
#if defined(US_TARGET_ANDROID)
String putResponse = "{\"populations\":[{\"name\":\"Android\",\"obj\":{},\"subject\":\"ManufacturedBy\",\"spaceId\":\"65b080dc-d03d-4190-b911-c90e03c4592d\"";
String spaceParamTestSettings = "\"manufacturerName\":\"Google\"";
#elif defined(US_TARGET_GGP)
String putResponse = "{\"populations\":[{\"name\":\"GGP\",\"obj\":{},\"subject\":\"ManufacturedBy\",\"spaceId\":\"65b080dc-d03d-4190-b911-c90e03c4592d\"";
String spaceParamTestSettings = "\"manufacturerName\":\"Google\"";
#elif defined(US_TARGET_IOS)
String putResponse = "{\"populations\":[{\"name\":\"IOS\",\"obj\":{},\"subject\":\"ManufacturedBy\",\"spaceId\":\"65b080dc-d03d-4190-b911-c90e03c4592d\"";
String spaceParamTestSettings = "\"manufacturerName\":\"Apple\"";
#elif defined(US_TARGET_LINUX)
String putResponse = "{\"populations\":[{\"name\":\"Linux\",\"obj\":{},\"subject\":\"ManufacturedBy\",\"spaceId\":\"65b080dc-d03d-4190-b911-c90e03c4592d\"";
String spaceParamTestSettings = "\"manufacturerName\":\"Linux\"";
#elif defined(US_TARGET_OSX)
String putResponse = "{\"populations\":[{\"name\":\"Mac\",\"obj\":{},\"subject\":\"ManufacturedBy\",\"spaceId\":\"65b080dc-d03d-4190-b911-c90e03c4592d\"";
String spaceParamTestSettings = "\"manufacturerName\":\"Apple\"";
#elif defined(US_TARGET_PS4)
String putResponse = "{\"populations\":[{\"name\":\"PS4\",\"obj\":{},\"subject\":\"ManufacturedBy\",\"spaceId\":\"65b080dc-d03d-4190-b911-c90e03c4592d\"";
String spaceParamTestSettings = "\"manufacturerName\":\"Sony\"";
#elif defined(US_TARGET_SWITCH)
String putResponse = "{\"populations\":[{\"name\":\"Switch\",\"obj\":{},\"subject\":\"ManufacturedBy\",\"spaceId\":\"65b080dc-d03d-4190-b911-c90e03c4592d\"";
String spaceParamTestSettings = "\"manufacturerName\":\"Nintendo\"";
#elif defined(US_TARGET_WINDOWS)
String putResponse = "{\"populations\":[{\"name\":\"PC\",\"obj\":{},\"subject\":\"ManufacturedBy\",\"spaceId\":\"65b080dc-d03d-4190-b911-c90e03c4592d\"";
String spaceParamTestSettings = "\"manufacturerName\":\"HP\"";
#elif defined(US_TARGET_XONE)
String putResponse = "{\"populations\":[{\"name\":\"Xone\",\"obj\":{},\"subject\":\"ManufacturedBy\",\"spaceId\":\"65b080dc-d03d-4190-b911-c90e03c4592d\"";
String spaceParamTestSettings = "\"manufacturerName\":\"Microsoft\"";
#elif defined(US_TARGET_KILI)
String putResponse = "{\"populations\":[{\"name\":\"Kili\",\"obj\":{},\"subject\":\"ManufacturedBy\",\"spaceId\":\"65b080dc-d03d-4190-b911-c90e03c4592d\"";
String spaceParamTestSettings = "\"manufacturerName\":\"Sony\"";
#else
String putResponse = "{\"populations\":[{\"name\":\"Unknown\",\"obj\":{},\"subject\":\"ManufacturedBy\",\"spaceId\":\"65b080dc-d03d-4190-b911-c90e03c4592d\"";
String spaceParamTestSettings = "\"manufacturerName\":\"Unknown\"";
#endif
// Make sure our population updates works
EXPECT_CALL(*logDevice, output(US_TEST_NS::US_MOCK_STRING_FINDNOCASE(putRequest),
LogLevel::Debug, ::testing::_, ::testing::_)).Times(testing::AtLeast(1));
EXPECT_CALL(*logDevice, output(US_TEST_NS::US_MOCK_STRING_FINDNOCASE(putResponse),
LogLevel::Debug, ::testing::_, ::testing::_)).Times(testing::AtLeast(1));
EXPECT_CALL(*logDevice, output(US_TEST_NS::US_MOCK_STRING_FINDNOCASE(spaceParamTestSettings),
LogLevel::Debug, ::testing::_, ::testing::_)).Times(testing::AtLeast(1));
}
}
namespace TestSuspendedMode_BF
{
AsyncResultBatch<Facade*, Empty> changeState(PlatformHelper::State toState);
};
TEST_F(XPLAY, DISABLED_MANUAL_XplayLoginSameUserMultiplePlatform)
{
//setupDebugLogging();
Facade facade;
const unsigned int playerId = 1;
const String nameOnPlatform = String::formatText("HarbourXplay0%u", playerId);
ASSERT_TRUE(AsyncHelper::waitSuccess(facade.createSession(Xplay_BF::getPlayerCredentials(playerId), {}, {})));
EXPECT_EQ(SpaceId(HARBOUR_XPLAY_SPACE_ID), SpaceId(facade.getWorkingSpaceId()));
EXPECT_TRUE(facade.getAuthenticationClient().getSessionInfo().hasUserAccountLinked());
EXPECT_EQ(String("uplay"), facade.getAuthenticationClient().getSessionInfo().getProfileType());
EXPECT_EQ(nameOnPlatform, facade.getAuthenticationClient().getSessionInfo().getNameOnPlatform());
ASSERT_TRUE(AsyncHelper::waitSuccess(facade.deleteSession()));
}
TEST_F(XPLAY, DISABLED_MANUAL_XplayLoginFailWithNoAccountLinked)
{
//setupDebugLogging();
Facade facade;
ASSERT_TRUE(AsyncHelper::waitFailure(facade.createSession(Xplay_BF::getPlayerCredentials(), {}, {}), Errors::AUTH_PLAYER_HAS_NO_UPLAY_ACCOUNT));
}
TEST_F(XPLAY, DISABLED_MANUAL_XplaySecondaryStoreGetOffers)
{
//setupDebugLogging();
Facade facade;
ASSERT_TRUE(AsyncHelper::waitSuccess(facade.createSession(Xplay_BF::getPlayerCredentials(), {}, {})));
SecondaryStoreClient& client = facade.getSecondaryStoreClient();
SecondaryStoreClient::SearchFilterOfferSpace offerFilter;
offerFilter.m_type = "currency";
auto result = client.searchOffersSpace(offerFilter);
ASSERT_TRUE(AsyncHelper::waitSuccess(result));
const auto& offers = result.getResult();
ASSERT_GE(offers.size(), 1u);
ASSERT_TRUE(AsyncHelper::waitSuccess(facade.deleteSession()));
}
TEST_F(XPLAY, DISABLED_MANUAL_XplaySecondaryStoryApplyOffer)
{
//setupDebugLogging();
Facade facade;
ASSERT_TRUE(AsyncHelper::waitSuccess(facade.createSession(Xplay_BF::getPlayerCredentials(), {}, {})));
SecondaryStoreClient& client = facade.getSecondaryStoreClient();
SecondaryStoreClient::SearchFilterOfferSpace offerFilter;
offerFilter.m_type = "currency";
auto result = client.searchOffersSpace(offerFilter);
ASSERT_TRUE(AsyncHelper::waitSuccess(result));
const auto& offers = result.getResult();
ASSERT_GE(offers.size(), 1u);
auto applyOffer = client.applyOffer(offers[0]);
ASSERT_TRUE(AsyncHelper::waitSuccess(applyOffer));
const auto& transactionInfo = applyOffer.getResult();
ASSERT_GE(transactionInfo.m_itemList.size(), 1u);
ASSERT_TRUE(AsyncHelper::waitSuccess(facade.deleteSession()));
}
TEST_F(XPLAY, DISABLED_MANUAL_XplaySecondaryStoreInventory)
{
//setupDebugLogging();
Facade facade;
ASSERT_TRUE(AsyncHelper::waitSuccess(facade.createSession(Xplay_BF::getPlayerCredentials(), {}, {})));
SecondaryStoreClient& client = facade.getSecondaryStoreClient();
auto inventoryAsync = client.requestInventoryAll();
ASSERT_TRUE(AsyncHelper::waitSuccess(inventoryAsync));
const auto& inventory = inventoryAsync.getResult();
EXPECT_GE(inventory.size(), 1u);
ASSERT_TRUE(AsyncHelper::waitSuccess(facade.deleteSession()));
}
//Test that a notification sent from Portal from XPLAY Space is received
TEST_F(XPLAY, DISABLED_MANUAL_XplayOnlineNotificationsFromSpaceNotApplication)
{
//setupDebugLogging();
Facade facade;
const String xplayOnlineNotification = "XplayTestOnlineNotification";
ASSERT_TRUE(AsyncHelper::waitSuccess(facade.createSession(Xplay_BF::getPlayerCredentials(), {}, {})));
ASSERT_TRUE(US_TEST_NS::Helper::waitForWebsocketInit(facade));
NotificationClient& client = facade.getNotificationClient();
auto listener = client.createNotificationListenerCustom();
while (!listener.isNotificationAvailable())
{
US_TEST_NS::Helper::sleep(100);
}
const auto notification = listener.popNotification();
ASSERT_EQ(xplayOnlineNotification, notification.m_type);
ASSERT_EQ(SpaceId(HARBOUR_XPLAY_SPACE_ID), notification.m_spaceId);
ASSERT_TRUE(AsyncHelper::waitSuccess(facade.deleteSession()));
}
//Test that an offline notification sent from Portal from XPLAY Space is received
//This need to be sent before starting the test
TEST_F(XPLAY, DISABLED_MANUAL_XplayOfflineNotificationsFromSpaceNotApplication)
{
//setupDebugLogging();
Facade facade;
const String xplayOfflineNotification = "XplayTestOfflineNotification";
ASSERT_TRUE(AsyncHelper::waitSuccess(facade.createSession(Xplay_BF::getPlayerCredentials(), {}, {})));
ASSERT_TRUE(US_TEST_NS::Helper::waitForWebsocketInit(facade));
NotificationClient& client = facade.getNotificationClient();
auto listener = client.createNotificationListenerCustom();
while (!listener.isNotificationAvailable())
{
US_TEST_NS::Helper::sleep(100);
}
const auto notification = listener.popNotification();
ASSERT_EQ(xplayOfflineNotification, notification.m_type);
ASSERT_EQ(SpaceId(HARBOUR_XPLAY_SPACE_ID), notification.m_spaceId);
ASSERT_TRUE(AsyncHelper::waitSuccess(facade.deleteSession()));
}
//This test retrieving from the Space the Spaces Entities.
//The PC App, PS4 App and Xone App all have their own space entities, but they should NOT be retrieved
TEST_F(XPLAY, DISABLED_MANUAL_XplayGetSpaceEntity)
{
//setupDebugLogging();
Facade facade;
ASSERT_TRUE(AsyncHelper::waitSuccess(facade.createSession(Xplay_BF::getPlayerCredentials(), {}, {})));
EntityClient& client = facade.getEntityClient();
auto result = client.searchEntitiesSpace();
ASSERT_TRUE(AsyncHelper::waitSuccess(result));
const auto entities = result.getResult();
//Only ONE entity exist (the one in the Harbour Xplay Space)
ASSERT_EQ(1u, entities.size());
const auto entity = entities[0];
EXPECT_EQ("XplaySpaceEntity", entity.getName());
EXPECT_EQ("XplayTest", entity.getType());
EXPECT_EQ(1u, entity.getTags().size());
EXPECT_EQ("Xplay", entity.getTags()[0]);
ASSERT_TRUE(AsyncHelper::waitSuccess(facade.deleteSession()));
}
//To be used with XplaySearchEntityAllPlatform
//Create an entity that should be fetched on XplaySearchEntityAllPlatform
//This must be run on all 3 platforms before running XplaySearchEntityAllPlatform
TEST_F(XPLAY, DISABLED_MANUAL_XplayCreateEntityOnSinglePlatform)
{
//setupDebugLogging();
Facade facade;
ASSERT_TRUE(AsyncHelper::waitSuccess(facade.createSession(Xplay_BF::getPlayerCredentials(), {}, {})));
EntityClient& client = facade.getEntityClient();
#if defined(US_TARGET_WINDOWS)
EntityCreation entityCreation("XplayTest", "Xplay_Windows", "{}", {"Xplay"});
#elif defined(US_TARGET_PS4)
EntityCreation entityCreation("XplayTest", "Xplay_PS4", "{}", {"Xplay"});
#else
EntityCreation entityCreation("XplayTest", "Xplay_XOne", "{}", {"Xplay"});
#endif
auto result = client.createEntityProfile(entityCreation);
ASSERT_TRUE(AsyncHelper::waitSuccess(result));
auto entity = result.getResult();
EXPECT_EQ("XplayTest", entity.getType());
EXPECT_EQ(1u, entity.getTags().size());
EXPECT_EQ("Xplay", entity.getTags()[0]);
#if defined(US_TARGET_WINDOWS)
EXPECT_EQ("Xplay_Windows", entity.getName());
#elif defined(US_TARGET_PS4)
EXPECT_EQ("Xplay_PS4", entity.getName());
#elif defined(US_TARGET_KILI)
EXPECT_EQ("Xplay_Kili", entity.getName());
#else
EXPECT_EQ("Xplay_XOne", entity.getName());
#endif
ASSERT_TRUE(AsyncHelper::waitSuccess(facade.deleteSession()));
}
TEST_F(XPLAY, DISABLED_MANUAL_XplaySearchEntityAllPlatform)
{
//setupDebugLogging();
Facade facade;
ASSERT_TRUE(AsyncHelper::waitSuccess(facade.createSession(Xplay_BF::getPlayerCredentials(), {}, {})));
EntityClient& client = facade.getEntityClient();
auto result = client.searchEntitiesProfile();
ASSERT_TRUE(AsyncHelper::waitSuccess(result));
auto entities = result.getResult();
ASSERT_EQ(3u, entities.size());
int pcIndex = -1;
int ps4Index = -1;
int xoneIndex = -1;
for (size_t i = 0; i < entities.size(); ++i)
{
if (entities[i].getName() == "Xplay_Windows")
{
pcIndex = static_cast<int>(i);
}
else if (entities[i].getName() == "Xplay_PS4")
{
ps4Index = static_cast<int>(i);
}
else if (entities[i].getName() == "Xplay_XOne")
{
xoneIndex = static_cast<int>(i);
}
EXPECT_EQ("XplayTest", entities[i].getType());
EXPECT_EQ(1u, entities[i].getTags().size());
EXPECT_EQ("Xplay", entities[i].getTags()[0]);
}
ASSERT_TRUE(pcIndex >= 0 && ps4Index >= 0 && xoneIndex >= 0);
ASSERT_TRUE(AsyncHelper::waitSuccess(facade.deleteSession()));
}
TEST_F(XPLAY, DISABLED_MANUAL_XplayUpdateEntityAllPlatform)
{
//setupDebugLogging();
Facade facade;
ASSERT_TRUE(AsyncHelper::waitSuccess(facade.createSession(Xplay_BF::getPlayerCredentials(), {}, {})));
EntityClient& client = facade.getEntityClient();
auto result = client.searchEntitiesProfile();
ASSERT_TRUE(AsyncHelper::waitSuccess(result));
auto entities = result.getResult();
ASSERT_EQ(3u, entities.size());
int pcIndex = -1;
int ps4Index = -1;
int xoneIndex = -1;
int kiliIndex = -1;
for (size_t i = 0; i < entities.size(); ++i)
{
if (entities[i].getName() == "Xplay_Windows")
{
pcIndex = static_cast<int>(i);
}
else if (entities[i].getName() == "Xplay_PS4")
{
ps4Index = static_cast<int>(i);
}
else if (entities[i].getName() == "Xplay_XOne")
{
xoneIndex = static_cast<int>(i);
}
else if (entities[i].getName() == "Xplay_Kili")
{
kiliIndex = static_cast<int>(i);
}
}
#if defined(US_TARGET_WINDOWS)
ASSERT_TRUE(pcIndex >= 0);
#elif defined(US_TARGET_PS4)
ASSERT_TRUE(ps4Index >= 0);
#elif defined(US_TARGET_KILI)
ASSERT_TRUE(kiliIndex >= 0);
#else
ASSERT_TRUE(xoneIndex >= 0);
#endif
#if defined(US_TARGET_WINDOWS)
EntityProfile& entity = entities[pcIndex];
#elif defined(US_TARGET_PS4)
EntityProfile& entity = entities[ps4Index];
#elif defined(US_TARGET_KILI)
EntityProfile& entity = entities[kiliIndex];
#else
EntityProfile& entity = entities[xoneIndex];
#endif
entity.setName(entity.getName() + "_Update");
EXPECT_TRUE(AsyncHelper::waitSuccess(client.updateEntityProfile(entity)));
ASSERT_TRUE(AsyncHelper::waitSuccess(facade.deleteSession()));
}
TEST_F(XPLAY, DISABLED_MANUAL_XplayDeleteEntityAllPlatform)
{
//setupDebugLogging();
Facade facade;
ASSERT_TRUE(AsyncHelper::waitSuccess(facade.createSession(Xplay_BF::getPlayerCredentials(), {}, {})));
EntityClient& client = facade.getEntityClient();
auto result = client.searchEntitiesProfile();
ASSERT_TRUE(AsyncHelper::waitSuccess(result));
auto entities = result.getResult();
ASSERT_EQ(3u, entities.size());
EntityId pcId("000");
EntityId ps4Id("000");
EntityId xoneId("000");
for (const auto& entity : entities)
{
if (entity.getName() == "Xplay_Windows" || entity.getName() == "Xplay_Windows_Update")
{
pcId = entity.getEntityId();
}
else if (entity.getName() == "Xplay_PS4" || entity.getName() == "Xplay_PS4_Update")
{
ps4Id = entity.getEntityId();
}
else if (entity.getName() == "Xplay_XOne" || entity.getName() == "Xplay_XOne_Update")
{
xoneId = entity.getEntityId();
}
EXPECT_EQ("XplayTest", entity.getType());
EXPECT_EQ(1u, entity.getTags().size());
EXPECT_EQ("Xplay", entity.getTags()[0]);
}
EXPECT_TRUE(pcId.isValid() && ps4Id.isValid() && xoneId.isValid());
EXPECT_TRUE(AsyncHelper::waitSuccess(client.deleteEntityProfile(pcId)));
EXPECT_TRUE(AsyncHelper::waitSuccess(client.deleteEntityProfile(ps4Id)));
EXPECT_TRUE(AsyncHelper::waitSuccess(client.deleteEntityProfile(xoneId)));
result = client.searchEntitiesProfile();
ASSERT_TRUE(AsyncHelper::waitSuccess(result));
entities = result.getResult();
ASSERT_EQ(0u, entities.size());
ASSERT_TRUE(AsyncHelper::waitSuccess(facade.deleteSession()));
}
TEST_F(XPLAY, DISABLED_MANUAL_XplayRemoteLog)
{
//setupDebugLogging();
Facade facade;
ASSERT_TRUE(AsyncHelper::waitSuccess(facade.createSession(Xplay_BF::getPlayerCredentials(), {}, {})));
RemoteLogClient& client = facade.getRemoteLogClient();
const RemoteLog debugLog("Debug Log Xplay");
const RemoteLog infoLog("Info Log Xplay");
const RemoteLog warningLog("Warning Log Xplay");
const RemoteLog errorLog("Error Log Xplay");
client.sendRemoteLog(RemoteLogClient::Debug, "Xplay", debugLog);
client.sendRemoteLog(RemoteLogClient::Info, "Xplay", infoLog);
client.sendRemoteLog(RemoteLogClient::Warning, "Xplay", warningLog);
client.sendRemoteLog(RemoteLogClient::Error, "Xplay", errorLog);
US_TEST_NS::Helper::sleep(5000);
ASSERT_TRUE(AsyncHelper::waitSuccess(facade.deleteSession()));
}
TEST_F(XPLAY, DISABLED_MANUAL_XplayProfileApplicationsUsed)
{
//setupDebugLogging();
Facade facade;
ASSERT_TRUE(AsyncHelper::waitSuccess(facade.createSession(Xplay_BF::getPlayerCredentials(), {}, {})));
ProfileClient& client = facade.getProfileClient();
auto result = client.requestApplicationsUsed();
ASSERT_TRUE(AsyncHelper::waitSuccess(result));
auto applications = result.getResult();
ASSERT_EQ(1u, applications.size());
ASSERT_EQ(ApplicationId(HARBOUR_XPLAY_APP_ID), applications[0].m_applicationId);
ASSERT_TRUE(AsyncHelper::waitSuccess(facade.deleteSession()));
}
TEST_F(XPLAY, DISABLED_MANUAL_XplayProfileAllApplicationsUsed)
{
//setupDebugLogging();
Facade facade;
ASSERT_TRUE(AsyncHelper::waitSuccess(facade.createSession(Xplay_BF::getPlayerCredentials(), {}, {})));
ProfileClient& client = facade.getProfileClient();
auto result = client.requestApplicationsUsedForAllApplications();
ASSERT_TRUE(AsyncHelper::waitSuccess(result));
const auto& applications = result.getResult();
ASSERT_EQ(3u, applications.size());
bool pcFound = false;
bool ps4Found = false;
bool xoneFound = false;
for (const auto& applicationUsed : applications)
{
if (applicationUsed.m_applicationId == ApplicationId(HARBOUR_XPLAY_PC_APP_ID))
{
pcFound = true;
}
else if (applicationUsed.m_applicationId == ApplicationId(HARBOUR_XPLAY_PS4_APP_ID))
{
ps4Found = true;
}
else if (applicationUsed.m_applicationId == ApplicationId(HARBOUR_XPLAY_XONE_APP_ID))
{
xoneFound = true;
}
}
ASSERT_TRUE(pcFound);
ASSERT_TRUE(ps4Found);
ASSERT_TRUE(xoneFound);
ASSERT_TRUE(AsyncHelper::waitSuccess(facade.deleteSession()));
}
TEST_F(XPLAY, DISABLED_MANUAL_XplayUserRequestUserInfo)
{
//setupDebugLogging();
Facade facade;
ASSERT_TRUE(AsyncHelper::waitSuccess(facade.createSession(Xplay_BF::getPlayerCredentials(), {}, {})));
UserClient& client = facade.getUserClient();
const UserId userId("85281591-aaf1-45ef-9559-feb8725325d4");
auto result = client.requestUserInfo({ userId });
ASSERT_TRUE(AsyncHelper::waitSuccess(result));
const auto& userInfos = result.getResult();
ASSERT_EQ(1u, userInfos.size());
const auto& userInfo = userInfos.at(userId);
ASSERT_EQ(3u, userInfo.m_linkedProfiles.size());
bool isUplayFound = false;
bool isPS4Found = false;
bool isXoneFound = false;
for (const auto& linkedProfile : userInfo.m_linkedProfiles)
{
if (linkedProfile.m_profileType == "uplay")
{
isUplayFound = true;
}
else if (linkedProfile.m_profileType == "psn")
{
isPS4Found = true;
}
else if (linkedProfile.m_profileType == "xbl")
{
isXoneFound = true;
}
}
ASSERT_TRUE(isUplayFound);
ASSERT_TRUE(isPS4Found);
ASSERT_TRUE(isXoneFound);
ASSERT_TRUE(AsyncHelper::waitSuccess(facade.deleteSession()));
}
TEST_F(XPLAY, DISABLED_MANUAL_XplayRequestNewsXplaySpace)
{
//setupDebugLogging();
Facade facade;
ASSERT_TRUE(AsyncHelper::waitSuccess(facade.createSession(Xplay_BF::getPlayerCredentials(), {}, {})));
NewsClient& client = facade.getNewsClient();
auto result = client.requestSpaceNews();
ASSERT_TRUE(AsyncHelper::waitSuccess(result));
const auto& newsList = result.getResult();
ASSERT_EQ(1u, newsList.size());
const auto& news = newsList[0];
EXPECT_EQ("test", news.m_type);
EXPECT_EQ("Harbour Xplay Space News 2", news.m_title);
ASSERT_EQ(1u, news.m_links.size());
EXPECT_EQ("http://dummylink/", news.m_links[0].m_param);
ASSERT_TRUE(AsyncHelper::waitSuccess(facade.deleteSession()));
}
TEST_F(XPLAY, DISABLED_MANUAL_XplayRequestNewsXplaySpacePlatform)
{
//setupDebugLogging();
Facade facade;
ASSERT_TRUE(AsyncHelper::waitSuccess(facade.createSession(Xplay_BF::getPlayerCredentials(), {}, {})));
NewsClient& client = facade.getNewsClient();
#if defined(US_TARGET_WINDOWS)
auto result = client.requestSpaceNews(SpaceId(HARBOUR_XPLAY_PC_SPACE_ID));
#elif defined(US_TARGET_PS4)
auto result = client.requestSpaceNews(SpaceId(HARBOUR_XPLAY_PS4_SPACE_ID));
#elif defined(US_TARGET_KILI)
auto result = client.requestSpaceNews(SpaceId(HARBOUR_XPLAY_KILI_SPACE_ID));
#else
auto result = client.requestSpaceNews(SpaceId(HARBOUR_XPLAY_XONE_SPACE_ID));
#endif
ASSERT_TRUE(AsyncHelper::waitSuccess(result));
const auto& newsList = result.getResult();
ASSERT_EQ(1u, newsList.size());
const auto& news = newsList[0];
EXPECT_EQ("test", news.m_type);
#if defined(US_TARGET_WINDOWS)
EXPECT_EQ("Harbour Xplay PC Space News", news.m_title);
#elif defined(US_TARGET_PS4)
EXPECT_EQ("Harbour Xplay PS4 Space News", news.m_title);
#elif defined(US_TARGET_KILI)
EXPECT_EQ("Harbour Xplay KILI Space News", news.m_title);
#else
EXPECT_EQ("Harbour Xplay XOne Space News", news.m_title);
#endif
ASSERT_EQ(1u, news.m_links.size());
EXPECT_EQ("http://dummylink/", news.m_links[0].m_param);
ASSERT_TRUE(AsyncHelper::waitSuccess(facade.deleteSession()));
}
TEST_F(XPLAY, DISABLED_MANUAL_XplaySendCustomEvents)
{
//setupDebugLogging();
Facade facade;
ASSERT_TRUE(AsyncHelper::waitSuccess(facade.createSession(Xplay_BF::getPlayerCredentials(1), {}, {})));
EventClient& client = facade.getEventClient();
unsigned int c = 5;
while (c > 0)
{
auto result = client.pushEvent(EventInfoCustom("harbourscore", "{\"value\": 1}"));
ASSERT_EQ(PushEventResult::Success, result);
result = client.pushEvent(EventInfoCustom("xplay"));
ASSERT_EQ(PushEventResult::Success, result);
US_TEST_NS::Helper::sleep(28000);
--c;
}
US_TEST_NS::Helper::sleep(35000);
ASSERT_TRUE(AsyncHelper::waitSuccess(facade.deleteSession()));
}
TEST_F(XPLAY, DISABLED_MANUAL_XplayStats)
{
//setupDebugLogging();
Facade facade;
ASSERT_TRUE(AsyncHelper::waitSuccess(facade.createSession(Xplay_BF::getPlayerCredentials(), {}, {})));
StatsClient& client = facade.getStatsClient();
auto result = client.requestStatsProfiles();
ASSERT_TRUE(AsyncHelper::waitSuccess(result));
const auto& stats = result.getResult();
ASSERT_EQ(1u, stats.m_stats.size());
for (const auto& stat : stats.m_stats)
{
ASSERT_EQ(facade.getAuthenticationClient().getSessionInfo().getProfileId(), stat.first);
ASSERT_GE(stat.second.m_stats.size(), 1u);
}
ASSERT_TRUE(AsyncHelper::waitSuccess(facade.deleteSession()));
}
TEST_F(XPLAY, DISABLED_MANUAL_XplayStatsOtherPlayer)
{
//setupDebugLogging();
Facade facade;
ASSERT_TRUE(AsyncHelper::waitSuccess(facade.createSession(Xplay_BF::getPlayerCredentials(), {}, {})));
StatsClient& client = facade.getStatsClient();
auto result = client.requestStatsProfiles({ "XplayCount" }, { ProfileId("85281591-aaf1-45ef-9559-feb8725325d4") });
ASSERT_TRUE(AsyncHelper::waitSuccess(result));
const auto& stats = result.getResult();
ASSERT_EQ(1u, stats.m_stats.size());
for (const auto& stat : stats.m_stats)
{
ASSERT_EQ(ProfileId("85281591-aaf1-45ef-9559-feb8725325d4"), stat.first);
ASSERT_GE(stat.second.m_stats.size(), 1u);
}
ASSERT_TRUE(AsyncHelper::waitSuccess(facade.deleteSession()));
}
TEST_F(XPLAY, DISABLED_MANUAL_XplayLeaderboard)
{
//setupDebugLogging();
Facade facade;
ASSERT_TRUE(AsyncHelper::waitSuccess(facade.createSession(Xplay_BF::getPlayerCredentials(), {}, {})));
LeaderboardClient& client = facade.getLeaderboardClient();
auto result = client.requestLeaderboard("XplayCount");
ASSERT_TRUE(AsyncHelper::waitSuccess(result));
const auto& leaderboard = result.getResult();
const auto& standings = leaderboard.m_standings;
ASSERT_GE(standings.size(), 1u);
ASSERT_TRUE(AsyncHelper::waitSuccess(facade.deleteSession()));
}
TEST_F(XPLAY, DISABLED_MANUAL_XplayClubRequestRewards)
{
//setupDebugLogging();
Facade facade;
ASSERT_TRUE(AsyncHelper::waitSuccess(facade.createSession(Xplay_BF::getPlayerCredentials(), {}, {})));
ClubClient& client = facade.getClubClient();
auto result = client.requestRewards();
ASSERT_TRUE(AsyncHelper::waitSuccess(result));
const auto& rewards = result.getResult();
US_UNUSED(rewards);
ASSERT_GE(rewards.size(), 1u);
for (const auto& reward : rewards)
{
EXPECT_EQ("clubtestxplay", reward.m_name);
EXPECT_EQ(0, reward.m_value);
}
ASSERT_TRUE(AsyncHelper::waitSuccess(facade.deleteSession()));
}
TEST_F(XPLAY, DISABLED_MANUAL_XplayClubPurchaseRewards)
{
//setupDebugLogging();
Facade facade;
ASSERT_TRUE(AsyncHelper::waitSuccess(facade.createSession(Xplay_BF::getPlayerCredentials(), {}, {})));
ClubClient& client = facade.getClubClient();
auto result = client.purchaseReward("CLUBTESTXPLAY01");
ASSERT_TRUE(AsyncHelper::waitSuccess(result));
ASSERT_TRUE(AsyncHelper::waitSuccess(facade.deleteSession()));
}
TEST_F(XPLAY, DISABLED_MANUAL_XplayClubActions)
{
//setupDebugLogging();
Facade facade;
ASSERT_TRUE(AsyncHelper::waitSuccess(facade.createSession(Xplay_BF::getPlayerCredentials(), {}, {})));
ClubClient& client = facade.getClubClient();
auto result = client.requestActionsAll();
ASSERT_TRUE(AsyncHelper::waitSuccess(result));
const auto& actions = result.getResult();
EXPECT_EQ(3u, actions.m_units.size());
ASSERT_TRUE(AsyncHelper::waitSuccess(facade.deleteSession()));
}
TEST_F(XPLAY, DISABLED_MANUAL_XplayCompleteActions)
{
//setupDebugLogging();
Facade facade;
ASSERT_TRUE(AsyncHelper::waitSuccess(facade.createSession(Xplay_BF::getPlayerCredentials(), {}, {})));
ClubClient& client = facade.getClubClient();
auto result = client.completeActions({"2"});
ASSERT_TRUE(AsyncHelper::waitSuccess(result));
ASSERT_TRUE(AsyncHelper::waitSuccess(facade.deleteSession()));
}
TEST_F(XPLAY, DISABLED_MANUAL_XplayPrimaryStoreSync)
{
//setupDebugLogging();
Facade facade;
ASSERT_TRUE(AsyncHelper::waitSuccess(facade.createSession(Xplay_BF::getPlayerCredentials(), {}, {})));
SecondaryStoreClient& client = facade.getSecondaryStoreClient();
auto inventoryAsync = client.requestInventoryAll();
ASSERT_TRUE(AsyncHelper::waitSuccess(inventoryAsync));
const auto& inventory = inventoryAsync.getResult();
EXPECT_GE(inventory.size(), 1u);
ASSERT_TRUE(AsyncHelper::waitSuccess(facade.deleteSession()));
}
#if !defined(US_DLL)
TEST_F(XPLAY, DISABLED_MANUAL_XplayPrimaryStoreSyncOnReturntoForeground)
{
static const char* const PROFILE_UPLAY = "da8e9a75-f692-4592-96a7-f92ffd7befdb"; // Uplay: HarbourXplay01
static const char* const ITEM_CONSU2 = "0702276f-e6bc-4328-af87-0a3108f57fac"; // consumable 2
#if !defined(US_TARGET_XONE)
static uint32 ITEM_COUNT_BEFORE_SYNC = 5000 * 7;
static uint32 ITEM_COUNT_AFTER_SYNC = 5000 * 8;
#endif
#if defined(US_TARGET_WINDOWS)
static uint32 SLEEP_TIME_TO_BUY = 20 * 1000; // 20 seconds
#elif defined(US_TARGET_PS4) || defined(US_TARGET_KILI)
static uint32 SLEEP_TIME_TO_BUY = 60 * 1000; // 60 seconds
#elif defined(US_TARGET_XONE)
static uint32 ITEM_COUNT_BEFORE_SYNC = 2000 * 3;
static uint32 ITEM_COUNT_AFTER_SYNC = 2000 * 4;
static uint32 SLEEP_TIME_TO_BUY = 2 * 1000; // xone takes too long, its better to put a break point
#endif
struct Local
{
static void checkInventoryResult(Facade& facade, uint32 expectedItemCount)
{
AsyncResult<Vector<InventoryElement> > resultInventoryUplay = facade.getSecondaryStoreClient().requestInventoryItems(
Vector<StoreItemId>{StoreItemId(ITEM_CONSU2)}, ProfileId(PROFILE_UPLAY), SpaceId(HARBOUR_XPLAY_SPACE_ID));
ASSERT_TRUE(AsyncHelper::waitSuccess(resultInventoryUplay));
const Vector<InventoryElement> inventoryUplay = resultInventoryUplay.getResult();
ASSERT_EQ(1, inventoryUplay.size());
Vector<InventoryElement>::const_iterator itUplay = inventoryUplay.begin();
ASSERT_EQ(StoreItemId(ITEM_CONSU2), itUplay->m_itemId);
ASSERT_EQ(expectedItemCount, itUplay->m_quantity);
}
};
Facade facade;
#if defined(US_TARGET_WINDOWS)
PrimaryStoreInventoryItem itemConsu2Before("9514", PrimaryStoreInventoryItem::InventoryItemState::ReadyToUse, ITEM_COUNT_BEFORE_SYNC);
ASSERT_TRUE(AsyncHelper::waitSuccess(facade.createSession(Xplay_BF::getPlayerCredentials(), {}, {}, EventsParams(),
String(), DynamicPopulationCustomParams(), PrimaryStoreParams(Vector<PrimaryStoreInventoryItem>{ itemConsu2Before }))));
#elif defined(US_TARGET_SWITCH)
SmartPtr<PlayerCredentials> credentials = NS_COMMON::AuthenticationHelper::createPlayerCredentials(2);
ASSERT_TRUE(AsyncHelper::waitSuccess(facade.createSession(*credentials, {}, {})));
#else
ASSERT_TRUE(AsyncHelper::waitSuccess(facade.createSession(Xplay_BF::getPlayerCredentials(), {}, {})));
#endif
ASSERT_TRUE(TestHelpers_BF::waitForPostLoginCompletion(facade, 10000));
#if defined(US_TARGET_XONE) || defined(US_TARGET_PS4) || defined(US_TARGET_KILI)
AsyncResult<Vector<PrimaryStoreInventoryItem> > resultInventory = facade.getPrimaryStoreClient().requestItemsInventory();
ASSERT_TRUE(AsyncHelper::waitSuccess(resultInventory));
Vector<PrimaryStoreInventoryItem> inventory = resultInventory.getResult();
Vector<PrimaryStoreInventoryItem>::const_iterator item = std::find_if(inventory.begin(), inventory.end(), [&](PrimaryStoreInventoryItem& item)
{
#if defined(US_TARGET_XONE)
return item.m_id == "e3ba8fd5-b4f1-40d5-9ec4-40cf935595aa"; // Consumable2
#elif defined(US_TARGET_PS4) || defined(US_TARGET_KILI)
return item.m_id == "CONSU2"; // Consumable2
#endif
});
ASSERT_TRUE(item != inventory.end());
#endif
AsyncResult<Vector<StoreItemsMapping>> resultMap =
facade.getSecondaryStoreClient().requestPrimaryStoreMapping(SpaceId(HARBOUR_XPLAY_SPACE_ID));
ASSERT_TRUE(AsyncHelper::waitSuccess(resultMap));
Vector<StoreItemsMapping> map = resultMap.getResult();
ASSERT_EQ(1, map.size());
Local::checkInventoryResult(facade, ITEM_COUNT_BEFORE_SYNC);
#if defined(US_TARGET_WINDOWS)
US_TEST_NS::Helper::sleep(SLEEP_TIME_TO_BUY); // sleep to add balance to item (consumable 2) on uplay portal
PrimaryStoreInventoryItem itemConsu2After("9514", PrimaryStoreInventoryItem::InventoryItemState::ReadyToUse, ITEM_COUNT_AFTER_SYNC);
//itemConsu2After.m_obtainedDate = DateTime(2019, 03, 19, 13, 55, 0);
AsyncResult<Empty> resultUpdateStore = facade.getPrimaryStoreClient().updatePrimaryStoreProducts(Vector<PrimaryStoreInventoryItem> { itemConsu2After });
ASSERT_TRUE(AsyncHelper::waitSuccess(resultUpdateStore));
#elif defined(US_TARGET_PS4) || defined(US_TARGET_XONE) || defined(US_TARGET_KILI)
ASSERT_TRUE(AsyncHelper::waitSuccess(TestSuspendedMode_BF::changeState(PlatformHelper::Background)));
US_TEST_NS::Helper::sleep(SLEEP_TIME_TO_BUY); // sleep to buy item (consumable 2) on primary store.
ASSERT_TRUE(AsyncHelper::waitSuccess(TestSuspendedMode_BF::changeState(PlatformHelper::Foreground)));
#elif defined(US_TARGET_SWITCH)
ASSERT_TRUE(AsyncHelper::waitSuccess(TestSuspendedMode_BF::changeState(PlatformHelper::Background)));
nn::ApplicationId appId;
appId.value = 0x01009d800a1d0000;
nn::ec::ShowShopConsumableItemList(appId, credentials->getHandle()); // buy 1xConsItem2 on primary store
ASSERT_TRUE(AsyncHelper::waitSuccess(TestSuspendedMode_BF::changeState(PlatformHelper::Foreground)));
#endif
Local::checkInventoryResult(facade, ITEM_COUNT_AFTER_SYNC);
}
#endif
#if defined(US_TARGET_WINDOWS)
TEST_F(XPLAY, DISABLED_MANUAL_XplayAddFriend)
{
//setupDebugLogging();
Facade facade;
ASSERT_TRUE(AsyncHelper::waitSuccess(facade.createSession(Xplay_BF::getPlayerCredentials(1), {}, {})));
FriendClient& client = facade.getFriendClient();
//*
auto result = client.sendFriendsClubInvite({ProfileId("6fc7874d-f7e9-40ed-8913-dc27acbb54c1")});
/*/
auto result = client.acceptFriendClubInvite(ProfileId("da8e9a75-f692-4592-96a7-f92ffd7befdb"));
//*/
ASSERT_TRUE(AsyncHelper::waitSuccess(result));
ASSERT_TRUE(AsyncHelper::waitSuccess(facade.deleteSession()));
}
#endif
TEST_F(XPLAY, DISABLED_MANUAL_XplayFriends)
{
//setupDebugLogging();
Facade facade;
ASSERT_TRUE(AsyncHelper::waitSuccess(facade.createSession(Xplay_BF::getPlayerCredentials(), {}, {})));
FriendClient& client = facade.getFriendClient();
auto result = client.requestFriends(FriendClient::Mode::Consolidated);
ASSERT_TRUE(AsyncHelper::waitSuccess(result));
ASSERT_EQ(3u, result.getResult().size());
ASSERT_TRUE(AsyncHelper::waitSuccess(facade.deleteSession()));
}
// (From testNotificatiion.cpp)This test never ends.
// use it for testing an update on the parameters service.
TEST_F(XPLAY_LOGIN, DISABLED_MANUAL_XplayWaitForAndLogNotifications)
{
//setupDebugLogging();
Facade facade;
NotificationSource<NotificationUbiServices>::ListenerHandler handlerNotificationClient = facade.getNotificationClient().createNotificationListenerUbiServices();
NotificationSource<ParametersNotification>::ListenerHandler handlerParametersClient = facade.getParametersClient().createNotificationListener();
ASSERT_TRUE(AsyncHelper::waitSuccess(facade.createSession(Xplay_BF::getPlayerCredentials(), {}, {})));
bool continueLoop = true;
while (continueLoop)
{
US_TEST_NS::Helper::sleep(500);
while (handlerNotificationClient.isNotificationAvailable())
{
const NotificationUbiServices result = handlerNotificationClient.popNotification();
US_NS::String messageStr(result.m_content.getUtf8());
messageStr = messageStr.truncateTo(100);
messageStr += " ...";
if (result.m_type == US_NS::NotificationUbiServicesType::NotificationMaintenancePending)
{
PRINT_STREAM("Incoming MESSAGING_MAINTENANCE_PENDING: " + messageStr);
}
else if (result.m_type == US_NS::NotificationUbiServicesType::NotificationMaintenanceStart)
{
PRINT_STREAM("Incoming MESSAGING_MAINTENANCE_START: " + messageStr);
}
else if (result.m_type == US_NS::NotificationUbiServicesType::NotificationMaintenanceEnd)
{
PRINT_STREAM("Incoming MESSAGING_MAINTENANCE_END: " + messageStr);
}
{
PRINT_STREAM("Incoming Application Configuration Update: " + messageStr);
}
PRINT_STREAM(result.m_content);
}
while (handlerParametersClient.isNotificationAvailable())
{
const ParametersNotification result = handlerParametersClient.popNotification();
if (result.m_type == US_NS::ParametersNotificationType::ApplicationParametersUpdated ||
result.m_type == US_NS::ParametersNotificationType::ApplicationParametersUpdatedPartially ||
result.m_type == US_NS::ParametersNotificationType::SpaceParametersUpdated)
{
PRINT_STREAM("Incoming Parameters Update Notification");
}
}
}
}
typedef ParamFixture<XPLAY_MOCK_NO_LOGIN, Xplay_BF::XplayFeatureSwitchesParams> XPLAY_MOCK_NO_LOGIN_SWITCHES_FIXTURE;
INSTANTIATE_TEST_CASE_P(XplayFeatureSwitchesParams, XPLAY_MOCK_NO_LOGIN_SWITCHES_FIXTURE, ::testing::Values(
Xplay_BF::XplayFeatureSwitchesParams{ FeatureSwitchState::Enabled, FeatureSwitchState::Enabled, true }, // USNOT_XplayFeatureSwitchClub/ApplicationSwitch_OnSpaceSwitchOn
Xplay_BF::XplayFeatureSwitchesParams{ FeatureSwitchState::Enabled, FeatureSwitchState::Disabled, false }, // USNOT_XplayFeatureSwitchClub/ApplicationSwitch_OnSpaceSwitchOff
Xplay_BF::XplayFeatureSwitchesParams{ FeatureSwitchState::Disabled, FeatureSwitchState::Enabled, false }, // USNOT_XplayFeatureSwitchClub/ApplicationSwitchOffSpaceSwitchOn
Xplay_BF::XplayFeatureSwitchesParams{ FeatureSwitchState::Disabled, FeatureSwitchState::Disabled, false }, // USNOT_XplayFeatureSwitchClub/ApplicationSwitchOffSpaceSwitchOff
Xplay_BF::XplayFeatureSwitchesParams{ FeatureSwitchState::Enabled, FeatureSwitchState::Removed, true }, // USNOT_XplayFeatureSwitchClub/ApplicationSwitchOnSpaceSwitchRemoved
Xplay_BF::XplayFeatureSwitchesParams{ FeatureSwitchState::Disabled, FeatureSwitchState::Removed, false }, // USNOT_XplayFeatureSwitchClub/ApplicationSwitchOffSpaceSwitchRemoved
Xplay_BF::XplayFeatureSwitchesParams{ FeatureSwitchState::Removed, FeatureSwitchState::Enabled, true }, // USNOT_XplayFeatureSwitchClub/ApplicationSwitchRemovedSpaceSwitchOn
Xplay_BF::XplayFeatureSwitchesParams{ FeatureSwitchState::Removed, FeatureSwitchState::Disabled, false }, // USNOT_XplayFeatureSwitchClub/ApplicationSwitchRemovedSpaceSwitchOff
Xplay_BF::XplayFeatureSwitchesParams{ FeatureSwitchState::Removed, FeatureSwitchState::Removed, true } // USNOT_XplayFeatureSwitchClub/ApplicationSwitchRemovedSpaceSwitchRemoved
));
TEST_P(XPLAY_MOCK_NO_LOGIN_SWITCHES_FIXTURE, USNOT_XplayFeatureSwitchClub)
{
const auto param = this->getParam();
{
const auto ParamatersApplicationMock = MockResultHelper::createSuccessResult(
ParametersApplicationMockHelper().changeFeatureSwitch(FeatureSwitchId::ClubService,
param.applicationSwitchState).getParameters().renderContent());
const auto ParamatersSpaceMock = MockResultHelper::createSuccessResult(
ParametersSpaceMockHelper().changeFeatureSwitch(FeatureSwitchId::ClubService,
param.spaceSwitchSwitchState).getParameters().renderContent());
mockFullLogin(nullptr, &ParamatersApplicationMock, &ParamatersSpaceMock);
}
ASSERT_TRUE(AsyncHelper::waitSuccess(getFacade().createSession(Xplay_BF::getPlayerCredentials(), {}, {})));
ASSERT_EQ(param.isFeatureSwitchEnabled, getFacade().getParametersClient().isUsFeatureSwitchEnabled(FeatureSwitchId::ClubService));
}
/// Tests that when a feature switch is missing in both space and application parameters the default
/// value of the SDK should be then applied.
/// Note: Using SessionTicket since it's disabled by default on the SDK(other feature switch are enabled by default).
TEST_F(XPLAY_MOCK_NO_LOGIN, USNOT_XplayFeatureSwitchSessionTicketSdkDefaultValue)
{
{
const auto ParamatersApplicationMock = MockResultHelper::createSuccessResult(
ParametersApplicationMockHelper().changeFeatureSwitch(FeatureSwitchId::SessionTicket,
FeatureSwitchState::Removed).getParameters().renderContent());
const auto ParamatersSpaceMock = MockResultHelper::createSuccessResult(
ParametersSpaceMockHelper().changeFeatureSwitch(FeatureSwitchId::SessionTicket,
FeatureSwitchState::Removed).getParameters().renderContent());
mockFullLogin(nullptr, &ParamatersApplicationMock, &ParamatersSpaceMock);
}
ASSERT_TRUE(AsyncHelper::waitSuccess(getFacade().createSession(Xplay_BF::getPlayerCredentials(), {}, {})));
ASSERT_FALSE(getFacade().getParametersClient().isUsFeatureSwitchEnabled(FeatureSwitchId::SessionTicket));
}
#if defined(US_ENABLE_CLUB_LAUNCHAPP) || defined(US_ENABLE_JOTUN)
#if !defined(US_DLL)
TEST_F(XPLAY, DISABLED_MANUAL_LaunchClubApplication)
{
Facade facade;
ASSERT_TRUE(AsyncHelper::waitSuccess(facade.createSession(Xplay_BF::getPlayerCredentials(), {}, {})));
ASSERT_TRUE(TestHelpers_BF::waitForPostLoginCompletion(facade, 10000));
ClubClient& client = facade.getClubClient();
const AsyncResult<Empty> result = client.launchClubApplication("", ClubDisplayContext::InGame);
EXPECT_TRUE(result.wait());
US_EXPECT_SUCCESS(result);
#if defined(US_TARGET_XONE) || defined(US_TARGET_PS4) || defined(US_TARGET_KILI) || defined(US_TARGET_GGP)
US_TEST_NS::Helper::sleep(2000 * 1000); // 20 sec sleep to check club app is launched correctly
#endif
}
#endif //US_DLL
// Must use a user with no uplay-linked profile
TEST_F(XPLAY, DISABLED_MANUAL_LaunchClubApplicationNoLinkedProfile)
{
Facade facade;
#if defined(US_TARGET_SWITCH)
SmartPtr<PlayerCredentials> credentials = NS_COMMON::AuthenticationHelper::createPlayerCredentials(3);
ASSERT_TRUE(AsyncHelper::waitFailure(facade.createSession(*credentials, {}, {}),
Errors::ErrorCode::AUTH_PLAYER_HAS_NO_UPLAY_ACCOUNT));
#else
ASSERT_TRUE(AsyncHelper::waitFailure(facade.createSession(Xplay_BF::getPlayerCredentials(), {}, {}),
Errors::ErrorCode::AUTH_PLAYER_HAS_NO_UPLAY_ACCOUNT));
#endif
ClubClient& client = facade.getClubClient();
const AsyncResult<Empty> result = client.launchClubApplication("auth", ClubDisplayContext::InGame);
EXPECT_TRUE(result.wait());
US_EXPECT_SUCCESS(result);
#if defined(US_TARGET_XONE) || defined(US_TARGET_PS4) || defined(US_TARGET_KILI) || defined(US_TARGET_GGP)
US_TEST_NS::Helper::sleep(2000 * 1000); // 20 sec sleep to check club app is launched correctly
#endif
}
#endif // defined(US_ENABLE_CLUB_LAUNCHAPP)
#if defined(US_SDK_FULL) // We add the Platform Name in US_SDK_FULL only
/// Test that make sure we change population based on the current platform
TEST_F(XPLAY, US_XplayPopulationUpdatedBasedOnPlatformName)
{
#if defined(US_LOG_ENABLED)
LoggingHelper::enableVerbose();
US_TEST_NS::MockLogDevice* logDevice = US_NEW(US_TEST_NS::MockLogDevice);
InstancesManager::getInstance()->getEventLog().setLogDevice(logDevice);
Xplay_BF::setupMocksForDynamicPopulation(logDevice);
#endif
Facade facade;
// Adding "automaticTestSettings" as a custom space parameters group so that we retrieve the "manufacturerName" value from the
// Harbor Xplay Crossplay space parameters. "manufacturerName" value is based on the platform name we add in our update population
ASSERT_TRUE(AsyncHelper::waitSuccess(facade.createSession(Xplay_BF::getPlayerCredentials(), {}, { "automaticTestSettings" })));
PopulationClient& client = facade.getPopulationsClient();
auto result = client.requestPopulations();
ASSERT_TRUE(AsyncHelper::waitSuccess(result));
const auto& populations = result.getResult();
ASSERT_GT(populations.size(), 0);
// Make sure our population have been correctly updated
#if defined(US_TARGET_ANDROID)
EXPECT_EQ(populations[0].m_name, "Android");
#elif defined(US_TARGET_GGP)
EXPECT_EQ(populations[0].m_name, "GGP");
#elif defined(US_TARGET_IOS)
EXPECT_EQ(populations[0].m_name, "IOS");
#elif defined(US_TARGET_LINUX)
EXPECT_EQ(populations[0].m_name, "Linux");
#elif defined(US_TARGET_OSX)
EXPECT_EQ(populations[0].m_name, "Mac");
#elif defined(US_TARGET_PS4)
EXPECT_EQ(populations[0].m_name, "PS4");
#elif defined(US_TARGET_SWITCH)
EXPECT_EQ(populations[0].m_name, "Switch");
#elif defined(US_TARGET_WINDOWS)
EXPECT_EQ(populations[0].m_name, "PC");
#elif defined(US_TARGET_XONE)
EXPECT_EQ(populations[0].m_name, "Xone");
#elif defined(US_TARGET_KILI)
EXPECT_EQ(populations[0].m_name, "Kili");
#else
EXPECT_EQ(populations[0].m_name, "Unknown");
#endif
// Make sure our working space id is the crossplay one
EXPECT_EQ(facade.getWorkingSpaceId(), SpaceId("65b080dc-d03d-4190-b911-c90e03c4592d"));
ASSERT_TRUE(AsyncHelper::waitSuccess(facade.deleteSession()));
}
#endif
};
#endif //US_SDK_FULL