207 lines
8.8 KiB
C++
207 lines
8.8 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/memoryCheckFixture.h"
|
|
#include <ubiservices/services/friend/friendInfoConsole.h>
|
|
#include <ubiservices/services/friend/friendInfoClub.h>
|
|
#include <ubiservices/core/JSON/jsonWriter.h>
|
|
|
|
namespace US_NS {;
|
|
US_DEFINE_TEST(TestFriends);
|
|
|
|
#if !defined(US_DLL)
|
|
|
|
typedef LeakChecker UNIT_FRIEND;
|
|
|
|
namespace FriendInfoClubPrivate
|
|
{
|
|
bool extractData(const Json& source, FriendInfoClub& target);
|
|
|
|
bool extractData(const Json& source)
|
|
{
|
|
FriendInfoClub dummy;
|
|
return extractData(source, dummy);
|
|
}
|
|
}
|
|
|
|
TEST_F(UNIT_FRIEND, LOCAL_FriendInfoClubParsing)
|
|
{
|
|
JsonWriter writer;
|
|
writer["pid"] = "1111aaaa-2222-bbbb-3333-cccc4444dddd";
|
|
EXPECT_FALSE(FriendInfoClubPrivate::extractData(writer.getJson()));
|
|
|
|
writer["state"] = "Friends";
|
|
EXPECT_TRUE(FriendInfoClubPrivate::extractData(writer.getJson()));
|
|
|
|
writer["extraField"] = 42;
|
|
EXPECT_TRUE(FriendInfoClubPrivate::extractData(writer.getJson()));
|
|
}
|
|
|
|
#if defined(US_TARGET_PS4)
|
|
|
|
TEST_F(UNIT_FRIEND, LOCAL_FriendInfoConstructorWithoutPS4UserInfo)
|
|
{
|
|
std::unique_ptr<FriendInfoConsole> friendConsole(US_NEW(FriendInfoConsole, String("aaa"), "bbb"));
|
|
EXPECT_FALSE(friendConsole->m_presence.isSpecified());
|
|
}
|
|
|
|
TEST_F(UNIT_FRIEND, LOCAL_FriendInfoConstructorWithPS4UserInfoWithoutPresence)
|
|
{
|
|
const uint32 PLATFORM_PRESENCE_COUNT = 0;
|
|
|
|
sce::Toolkit::NP::V2::UserProfile::NpProfile userInfo;
|
|
sce::Toolkit::NP::V2::Presence::Presence presence;
|
|
|
|
presence.numPlatforms = PLATFORM_PRESENCE_COUNT;
|
|
presence.platforms = NULL;
|
|
{
|
|
std::unique_ptr<FriendInfoConsole> friendConsole(US_NEW(FriendInfoConsole, String("OnlineId"), "Username", userInfo, presence));
|
|
|
|
// Validate some fields to make sure data was copied correctly
|
|
EXPECT_TRUE(friendConsole->m_presence.isSpecified());
|
|
EXPECT_EQ(friendConsole->m_presence.value().numPlatforms, PLATFORM_PRESENCE_COUNT);
|
|
}
|
|
}
|
|
|
|
TEST_F(UNIT_FRIEND, LOCAL_FriendInfoConstructorWithPS4UserInfoWithPresence)
|
|
{
|
|
const uint32 PLATFORM_PRESENCE_COUNT = 2;
|
|
|
|
sce::Toolkit::NP::V2::UserProfile::NpProfile userInfo;
|
|
sce::Toolkit::NP::V2::Presence::Presence presence;
|
|
sce::Toolkit::NP::V2::Presence::PlatformPresence* platformPresence = US_NEW_ARRAY(sce::Toolkit::NP::V2::Presence::PlatformPresence, PLATFORM_PRESENCE_COUNT);
|
|
|
|
int presenceIndex = 0;
|
|
{
|
|
strcpy(platformPresence[presenceIndex].binaryGameData, "GameData1");
|
|
platformPresence[presenceIndex].binaryGameDataSize = 10;
|
|
strcpy(platformPresence[presenceIndex].gameStatus, "Running1");
|
|
SceNpTitleId titleId;
|
|
strcpy(titleId.id, "TitleId1");
|
|
platformPresence[presenceIndex].npTitleId = titleId;
|
|
strcpy(platformPresence[presenceIndex].npTitleName, "TitleName1");
|
|
platformPresence[presenceIndex].onlineStatusOnPlatform = sce::Toolkit::NP::V2::Presence::OnlineStatus::online;
|
|
platformPresence[presenceIndex].platform = sce::Toolkit::NP::V2::Presence::PlatformPresenceType::ps4;
|
|
}
|
|
|
|
presenceIndex++;
|
|
{
|
|
strcpy(platformPresence[presenceIndex].binaryGameData, "GameData2");
|
|
platformPresence[presenceIndex].binaryGameDataSize = 10;
|
|
strcpy(platformPresence[presenceIndex].gameStatus, "Running2");
|
|
SceNpTitleId titleId;
|
|
strcpy(titleId.id, "TitleId2");
|
|
platformPresence[presenceIndex].npTitleId = titleId;
|
|
strcpy(platformPresence[presenceIndex].npTitleName, "TitleName2");
|
|
platformPresence[presenceIndex].onlineStatusOnPlatform = sce::Toolkit::NP::V2::Presence::OnlineStatus::standBy;
|
|
platformPresence[presenceIndex].platform = sce::Toolkit::NP::V2::Presence::PlatformPresenceType::ps3;
|
|
}
|
|
|
|
presence.numPlatforms = PLATFORM_PRESENCE_COUNT;
|
|
presence.platforms = platformPresence;
|
|
{
|
|
std::unique_ptr<FriendInfoConsole> friendConsole(US_NEW(FriendInfoConsole, String("OnlineId"), "Username", userInfo, presence));
|
|
|
|
// Validate some fields to make sure data was copied correctly
|
|
EXPECT_TRUE(friendConsole->m_presence.isSpecified());
|
|
EXPECT_EQ(friendConsole->m_presence.value().numPlatforms, PLATFORM_PRESENCE_COUNT);
|
|
|
|
EXPECT_STREQ(friendConsole->m_presence.value().platforms[0].npTitleName, "TitleName1");
|
|
EXPECT_EQ(friendConsole->m_presence.value().platforms[0].platform, sce::Toolkit::NP::V2::Presence::PlatformPresenceType::ps4);
|
|
|
|
EXPECT_STREQ(friendConsole->m_presence.value().platforms[1].npTitleName, "TitleName2");
|
|
EXPECT_EQ(friendConsole->m_presence.value().platforms[1].platform, sce::Toolkit::NP::V2::Presence::PlatformPresenceType::ps3);
|
|
}
|
|
|
|
presence.platforms = NULL;
|
|
US_DELETE_ARRAY(platformPresence);
|
|
}
|
|
#endif // US_TARGET_PS4
|
|
|
|
#if defined(US_TARGET_KILI)
|
|
//
|
|
//TEST_F(UNIT_FRIEND, LOCAL_FriendInfoConstructorWithoutKILIUserInfo)
|
|
//{
|
|
// std::unique_ptr<FriendInfoConsole> friendConsole(US_NEW(FriendInfoConsole, String("aaa"), "bbb"));
|
|
// EXPECT_FALSE(friendConsole->m_presence.isSpecified());
|
|
//}
|
|
//
|
|
//TEST_F(UNIT_FRIEND, LOCAL_FriendInfoConstructorWithKILIUserInfoWithoutPresence)
|
|
//{
|
|
// const uint32 PLATFORM_PRESENCE_COUNT = 0;
|
|
//
|
|
// sce::Toolkit::NP::V2::UserProfile::NpProfile userInfo;
|
|
// sce::Toolkit::NP::V2::Presence::Presence presence;
|
|
//
|
|
// presence.numPlatforms = PLATFORM_PRESENCE_COUNT;
|
|
// presence.platforms = NULL;
|
|
// {
|
|
// std::unique_ptr<FriendInfoConsole> friendConsole(US_NEW(FriendInfoConsole, String("OnlineId"), "Username", userInfo, presence));
|
|
//
|
|
// // Validate some fields to make sure data was copied correctly
|
|
// EXPECT_TRUE(friendConsole->m_presence.isSpecified());
|
|
// EXPECT_EQ(friendConsole->m_presence.value().numPlatforms, PLATFORM_PRESENCE_COUNT);
|
|
// }
|
|
//}
|
|
//
|
|
//TEST_F(UNIT_FRIEND, LOCAL_FriendInfoConstructorWithKILIUserInfoWithPresence)
|
|
//{
|
|
// const uint32 PLATFORM_PRESENCE_COUNT = 2;
|
|
//
|
|
// sce::Toolkit::NP::V2::UserProfile::NpProfile userInfo;
|
|
// sce::Toolkit::NP::V2::Presence::Presence presence;
|
|
// sce::Toolkit::NP::V2::Presence::PlatformPresence* platformPresence = US_NEW_ARRAY(sce::Toolkit::NP::V2::Presence::PlatformPresence, PLATFORM_PRESENCE_COUNT);
|
|
//
|
|
// int presenceIndex = 0;
|
|
// {
|
|
// strcpy(platformPresence[presenceIndex].binaryGameData, "GameData1");
|
|
// platformPresence[presenceIndex].binaryGameDataSize = 10;
|
|
// strcpy(platformPresence[presenceIndex].gameStatus, "Running1");
|
|
// SceNpTitleId titleId;
|
|
// strcpy(titleId.id, "TitleId1");
|
|
// platformPresence[presenceIndex].npTitleId = titleId;
|
|
// strcpy(platformPresence[presenceIndex].npTitleName, "TitleName1");
|
|
// platformPresence[presenceIndex].onlineStatusOnPlatform = sce::Toolkit::NP::V2::Presence::OnlineStatus::online;
|
|
// platformPresence[presenceIndex].platform = sce::Toolkit::NP::V2::Presence::PlatformPresenceType::kili;
|
|
// }
|
|
//
|
|
// presenceIndex++;
|
|
// {
|
|
// strcpy(platformPresence[presenceIndex].binaryGameData, "GameData2");
|
|
// platformPresence[presenceIndex].binaryGameDataSize = 10;
|
|
// strcpy(platformPresence[presenceIndex].gameStatus, "Running2");
|
|
// SceNpTitleId titleId;
|
|
// strcpy(titleId.id, "TitleId2");
|
|
// platformPresence[presenceIndex].npTitleId = titleId;
|
|
// strcpy(platformPresence[presenceIndex].npTitleName, "TitleName2");
|
|
// platformPresence[presenceIndex].onlineStatusOnPlatform = sce::Toolkit::NP::V2::Presence::OnlineStatus::standBy;
|
|
// platformPresence[presenceIndex].platform = sce::Toolkit::NP::V2::Presence::PlatformPresenceType::ps3;
|
|
// }
|
|
//
|
|
// presence.numPlatforms = PLATFORM_PRESENCE_COUNT;
|
|
// presence.platforms = platformPresence;
|
|
// {
|
|
// std::unique_ptr<FriendInfoConsole> friendConsole(US_NEW(FriendInfoConsole, String("OnlineId"), "Username", userInfo, presence));
|
|
//
|
|
// // Validate some fields to make sure data was copied correctly
|
|
// EXPECT_TRUE(friendConsole->m_presence.isSpecified());
|
|
// EXPECT_EQ(friendConsole->m_presence.value().numPlatforms, PLATFORM_PRESENCE_COUNT);
|
|
//
|
|
// EXPECT_STREQ(friendConsole->m_presence.value().platforms[0].npTitleName, "TitleName1");
|
|
// EXPECT_EQ(friendConsole->m_presence.value().platforms[0].platform, sce::Toolkit::NP::V2::Presence::PlatformPresenceType::kili);
|
|
//
|
|
// EXPECT_STREQ(friendConsole->m_presence.value().platforms[1].npTitleName, "TitleName2");
|
|
// EXPECT_EQ(friendConsole->m_presence.value().platforms[1].platform, sce::Toolkit::NP::V2::Presence::PlatformPresenceType::ps3);
|
|
// }
|
|
//
|
|
// presence.platforms = NULL;
|
|
// US_DELETE_ARRAY(platformPresence);
|
|
//}
|
|
#endif // US_TARGET_KILI
|
|
#endif
|
|
|
|
};
|