131 lines
No EOL
6 KiB
C++
131 lines
No EOL
6 KiB
C++
////////////////////////////////////////////////////////////////////////////////
|
|
// (c) Copyright, Ubisoft Entertainment Inc. || Created by Harbour //
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
#include "tests/config.h"
|
|
#if defined(US_SDK_LIGHT_MOBILE)
|
|
#error This file shall not be part of the solution
|
|
#endif
|
|
|
|
#include "tests/fixture/authenticationFixture.h"
|
|
#include "tests/mock/MockHttpClientImpl.h"
|
|
#include "tests/mock/mockResultHelper.h"
|
|
#include <ubiservices/core/types/string.h>
|
|
#include <ubiservices/services/friend/friendClient.h>
|
|
#include <ubiservices/services/friend/friendInfoClub.h>
|
|
#include <ubiservices/services/http/request/httpRequest.h>
|
|
|
|
namespace US_NS {;
|
|
US_DEFINE_TEST(TestFriendsClub);
|
|
typedef AuthenticationFixture<1> FRIENDS_CLUB;
|
|
|
|
#if defined(US_CHINA_ACCOUNTS_SETUP_NOT_DONE) || defined(US_TARGET_GGP)
|
|
// China: 0 friends in china
|
|
// GGP: Unfortunately this tests needs an specifcig setup for ussdk002-006.
|
|
// The tests uses first party api to recover first party information for the user above.
|
|
// Those users, however do not have ggp valid accounts.
|
|
TEST_F(FRIENDS_CLUB, DISABLED_US_RequestFriendsWithFirstPartyInfo)
|
|
#else
|
|
TEST_F(FRIENDS_CLUB, US_RequestFriendsWithFirstPartyInfo)
|
|
#endif
|
|
{
|
|
struct Local
|
|
{
|
|
static const FriendInfo* GetUplayProfile(const Vector<FriendInfo>& friends, const String& friendProfileId)
|
|
{
|
|
for (const auto& it : friends)
|
|
{
|
|
const FriendInfoClub* uplayInfo = it.getInfoClub();
|
|
|
|
if (uplayInfo != nullptr && uplayInfo->m_profileInfo.m_profileId == ProfileId(friendProfileId))
|
|
{
|
|
return ⁢
|
|
}
|
|
}
|
|
|
|
return nullptr;
|
|
}
|
|
|
|
static ::testing::AssertionResult validateUplayInfo(const Vector<FriendInfo>& friends, const String& friendProfileId)
|
|
{
|
|
const FriendInfo* profile = GetUplayProfile(friends, friendProfileId);
|
|
|
|
if (profile == nullptr)
|
|
{
|
|
return ::testing::AssertionFailure() << "Friend with profileId: '" << friendProfileId << "' not found";
|
|
}
|
|
|
|
const FriendInfoClub* uplayInfo = profile->getInfoClub();
|
|
if (uplayInfo == nullptr)
|
|
{
|
|
return ::testing::AssertionFailure() << "Profile Info Club is NULL";
|
|
}
|
|
else if (!uplayInfo->m_profileInfo.m_userId.isSpecified())
|
|
{
|
|
return ::testing::AssertionFailure() << "Friend with profileId: '" << friendProfileId << "'' does not have a m_userId";
|
|
}
|
|
else if (!uplayInfo->m_profileInfo.m_userId.value().isValid())
|
|
{
|
|
return ::testing::AssertionFailure() << "Friend with profileId: '" << friendProfileId << "' has invalid m_userId: " << uplayInfo->m_profileInfo.m_userId.value();
|
|
}
|
|
else if (uplayInfo->m_profileInfo.m_nameOnPlatform.isEmpty())
|
|
{
|
|
return ::testing::AssertionFailure() << "Friend with profileId: '" << friendProfileId << "' does not have a m_nameOnPlatform";
|
|
}
|
|
else if (uplayInfo->m_profileInfo.m_profileType.isEmpty())
|
|
{
|
|
return ::testing::AssertionFailure() << "Friend with profileId: '" << friendProfileId << "' does not have a m_profileType";
|
|
}
|
|
|
|
return ::testing::AssertionSuccess();
|
|
}
|
|
};
|
|
|
|
const AsyncResult<Vector<FriendInfo> > result = getFacade().getFriendClient().requestFriends(FriendClient::ClubWithConsoleInfo);
|
|
ASSERT_TRUE(AsyncHelper::waitSuccess(result));
|
|
|
|
const Vector<FriendInfo>& friends = result.getResult();
|
|
|
|
// If the current user is ussdk001, he should not be a friend of himself
|
|
if (getFacade().getAuthenticationClient().getSessionInfo().getNameOnPlatform() != "ussdk001")
|
|
{
|
|
EXPECT_TRUE(Local::validateUplayInfo(friends, "4d9061de-7c20-4cc9-9f55-b8d6228da6ae")); // ussdk001
|
|
}
|
|
|
|
EXPECT_TRUE(Local::validateUplayInfo(friends, "b2cfc7a1-a08e-4bd8-adf3-73cb1c19faf1")); // ussdk002
|
|
EXPECT_TRUE(Local::validateUplayInfo(friends, "a701a60d-1fd9-4c4f-98a2-b33fa8beb00f")); // ussdk003
|
|
EXPECT_FALSE(Local::validateUplayInfo(friends, "327f0a1e-afe3-46b2-a631-c3e3308247cf")); // ussdk004
|
|
EXPECT_FALSE(Local::validateUplayInfo(friends, "89bca67a-0b27-48f1-9510-b74f205304b9")); // ussdk005
|
|
#if !defined(US_ENABLE_UPLAY_LOGIN)
|
|
EXPECT_FALSE(Local::validateUplayInfo(friends, "70e8ed8e-90f0-44cf-b472-c15ac1411b13")); // ussdk006
|
|
#else
|
|
EXPECT_TRUE(Local::validateUplayInfo(friends, "70e8ed8e-90f0-44cf-b472-c15ac1411b13")); // ussdk006
|
|
#endif //
|
|
|
|
const FriendInfo* profile = Local::GetUplayProfile(friends, "b2cfc7a1-a08e-4bd8-adf3-73cb1c19faf1"); // ussdk002
|
|
ASSERT_TRUE(profile != NULL);
|
|
|
|
// ussdk002 (Uplay) shall have the following accounts linked (minimum)
|
|
|
|
#if defined(US_TARGET_WINDOWS)
|
|
const FriendInfoConsole* infoPSN = profile->getInfoConsole(FriendPlatform::PSN);
|
|
ASSERT_TRUE(infoPSN != NULL); // Both the same (PSN) account
|
|
ASSERT_EQ("5364348020907620316", infoPSN->m_profileInfo.m_idOnPlatform);
|
|
ASSERT_EQ("ussdk002", infoPSN->m_profileInfo.m_nameOnPlatform);
|
|
|
|
const FriendInfoConsole* infoXBL = profile->getInfoConsole(FriendPlatform::XBL);
|
|
ASSERT_TRUE(infoXBL != NULL); // Both the same (XBL) account
|
|
ASSERT_EQ("2814675809618166", infoXBL->m_profileInfo.m_idOnPlatform);
|
|
ASSERT_EQ("2 Dev 820734878", infoXBL->m_profileInfo.m_nameOnPlatform);
|
|
|
|
const FriendInfoConsole* infoWiiU = profile->getInfoConsole(FriendPlatform::WiiU);
|
|
ASSERT_TRUE(infoWiiU != NULL);
|
|
ASSERT_EQ("1799895224", infoWiiU->m_profileInfo.m_idOnPlatform);
|
|
ASSERT_EQ("ussdk002", infoWiiU->m_profileInfo.m_nameOnPlatform);
|
|
|
|
const FriendInfoConsole* infoNNX = profile->getInfoConsole(FriendPlatform::Switch);
|
|
ASSERT_TRUE(infoNNX != NULL);
|
|
ASSERT_EQ("c8a60a98f3d3aac5", infoNNX->m_profileInfo.m_idOnPlatform);
|
|
ASSERT_EQ("ussdk002", infoNNX->m_profileInfo.m_nameOnPlatform);
|
|
#endif
|
|
}
|
|
}; |