547 lines
25 KiB
C++
547 lines
25 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/common/helpers.h"
|
|
#include "tests/fixture/authenticationFixture.h"
|
|
#include "tests/fixture/loginMockFixture.h"
|
|
#include "tests/fixture/paramFixture.h"
|
|
#include "tests/mock/mockProfileHelper.h"
|
|
#include "tests/mock/mockResultHelper.h"
|
|
#include <ubiservices/facade.h>
|
|
#include <ubiservices/loggingHelper.h>
|
|
#include <ubiservices/core/errors/errorCodes.h>
|
|
#include <ubiservices/services/friend/friendClient.h>
|
|
#include <ubiservices/services/friend/friendInfoConsole.h>
|
|
#include <ubiservices/services/friend/friendInfoClub.h>
|
|
#include <ubiservices/services/http/request/httpRequest.h>
|
|
#include <ubiservices/services/parameters/parametersClient.h>
|
|
#include <../private/ubiservices/services/parameters/parametersClientProxy.h>
|
|
|
|
namespace US_NS {;
|
|
US_DEFINE_TEST(TestFriendsConsole);
|
|
typedef AuthenticationFixture<1> FRIENDS_CONSOLE_LOGIN;
|
|
typedef LoginMockFixture<true> FRIENDS_CONSOLE_MOCK_LOGIN_CACHE;
|
|
typedef LoginMockFixtureNoInit FRIENDS_CONSOLE_MOCK_NOINIT;
|
|
|
|
namespace TestFriendsConsole_BF
|
|
{
|
|
String getConsoleUsername(uint32 i)
|
|
{
|
|
#if defined(US_TARGET_XONE) || defined(US_TARGET_WINDOWS) || defined(US_TARGET_LINUX) || defined(US_TARGET_GGP) || defined(US_TARGET_OSX)
|
|
switch (i)
|
|
{
|
|
case 1: return "2 Dev 876026320"; // ussdk001
|
|
break;
|
|
case 2: return "2 Dev 820734878"; // ussdk002
|
|
break;
|
|
case 3: return "2 Dev 582379320"; // ussdk003
|
|
break;
|
|
case 4: return "2 Dev 538703112"; // ussdk004
|
|
break;
|
|
case 5: return "2 Dev 958831192"; // ussdk005
|
|
break;
|
|
case 6:
|
|
#if defined(US_TARGET_GGP)
|
|
return "6262246098701102834"; // ussdkTristan
|
|
#else
|
|
return "2 Dev 660299965"; // This xbox live profile is currently unlinked
|
|
#endif
|
|
break;
|
|
default:
|
|
return "";
|
|
}
|
|
#else
|
|
return (i == 6) ? String() : String::formatText("ussdk00%d", i);
|
|
#endif
|
|
}
|
|
|
|
uint32 getExpectedFriendsCount(FriendClient::Mode mode, bool isFriendsUplayProfileFeatureSwitchOn)
|
|
{
|
|
#if defined(US_ENABLE_UPLAY_LOGIN) && !defined(US_TARGET_IOS) || defined(US_UPLAY_LOGIN_FOR_IOS)
|
|
// On these platforms, the current player is ussdk001;
|
|
US_UNUSED(mode);
|
|
US_UNUSED(isFriendsUplayProfileFeatureSwitchOn);
|
|
return 3; // The current player is ussdk001;
|
|
#else
|
|
// On console, friends without profile linked on the current platform are discarded
|
|
// Unless the cross friends feature is on
|
|
switch(mode)
|
|
{
|
|
case FriendClient::Consolidated:
|
|
#if defined(US_TARGET_IOS)
|
|
return 4; // Hit
|
|
#else
|
|
if (isFriendsUplayProfileFeatureSwitchOn)
|
|
{
|
|
return 6;
|
|
}
|
|
return 5;
|
|
#endif
|
|
case FriendClient::ConsoleOnly:
|
|
#if defined(US_TARGET_IOS)
|
|
return 0;
|
|
#elif defined(US_TARGET_GGP) // only testing one friend for now.
|
|
return 1;
|
|
#endif
|
|
case FriendClient::ConsoleWithClubInfo:
|
|
#if defined(US_TARGET_IOS)
|
|
return 0;
|
|
#else
|
|
return 4;
|
|
#endif
|
|
case FriendClient::ClubWithConsoleInfo:
|
|
#if defined(US_TARGET_IOS)
|
|
return 0; // Hit
|
|
#else
|
|
return 3;
|
|
#endif
|
|
case FriendClient::ClubOnly:// No friend is returned without console data and cross friends is off.
|
|
#if defined(US_TARGET_IOS)
|
|
return 4; // Hit
|
|
#else
|
|
if (isFriendsUplayProfileFeatureSwitchOn)
|
|
{
|
|
return 4;
|
|
}
|
|
#endif
|
|
default:
|
|
return 0;
|
|
}
|
|
#endif
|
|
}
|
|
|
|
// Here is the test Setup
|
|
// | Club username | PS3 username | Xbox username | WiiU Username | Switch Username | Is Club friend | Is console friend |
|
|
// | ussdk001 | usskd001 | usskd001 | ussdk001 | ussdk001 | no |
|
|
// | ussdk002 | ussdk002 | ussdk002 | ussdk002 | ussdk002 | yes |
|
|
// | ussdk003 | ussdk003 | ussdk003 | ussdk003 | ussdk003 | yes |
|
|
// | ussdk004 | ussdk004 | ussdk004 | ussdk004 | ussdk004 | yes |
|
|
// | ussdk005 | ussdk005 | ussdk005 | ussdk005 | ussdk005 | yes |
|
|
// | ussdk006 | (none) | (none) | (none) | (none) | no |
|
|
|
|
uint32 validateSingleFriendClub(const FriendInfo& friendInfo, FriendClient::Mode mode)
|
|
{
|
|
struct Local
|
|
{
|
|
static String getClubUsername(uint32 i)
|
|
{
|
|
return String::formatText("ussdk00%d", i);
|
|
}
|
|
};
|
|
|
|
const FriendInfoClub* info = friendInfo.getInfoClub();
|
|
uint32 count = 0;
|
|
if(mode == FriendClient::ConsoleOnly)
|
|
{
|
|
EXPECT_TRUE(info == NULL);
|
|
return count;
|
|
}
|
|
|
|
// For these modes no FriendInfo should have a null FriendInfoClub
|
|
if(mode == FriendClient::ClubOnly || mode == FriendClient::ClubWithConsoleInfo)
|
|
{
|
|
EXPECT_TRUE(info != NULL);
|
|
}
|
|
|
|
if(info != NULL)
|
|
{
|
|
const String& username = info->m_profileInfo.m_nameOnPlatform;
|
|
if(mode == FriendClient::ConsoleWithClubInfo)
|
|
{
|
|
EXPECT_TRUE(username != Local::getClubUsername(1));
|
|
EXPECT_TRUE(username != Local::getClubUsername(6));
|
|
}
|
|
if( mode == FriendClient::ClubOnly || mode == FriendClient::ClubWithConsoleInfo)
|
|
{
|
|
EXPECT_TRUE(username != Local::getClubUsername(4));
|
|
EXPECT_TRUE(username != Local::getClubUsername(5));
|
|
}
|
|
|
|
for(uint32 i = 1; i < 7; ++i)
|
|
{
|
|
if(username == Local::getClubUsername(i))
|
|
{
|
|
count++;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
return count;
|
|
}
|
|
|
|
uint32 validateSingleFriendConsole(const FriendInfo& friendInfo, FriendClient::Mode mode)
|
|
{
|
|
#if defined(US_ENABLE_UPLAY_LOGIN) && !defined(US_TARGET_IOS) || defined(US_UPLAY_LOGIN_FOR_IOS)
|
|
// Using XBL on Uplay platforms is arbitrary
|
|
const FriendInfoConsole* info = friendInfo.getInfoConsole(FriendPlatform::XBL);
|
|
#else
|
|
const FriendInfoConsole* info = friendInfo.getInfoConsole();
|
|
#endif
|
|
if(mode == FriendClient::ClubOnly)
|
|
{
|
|
EXPECT_TRUE(info == NULL);
|
|
return 0;
|
|
}
|
|
|
|
uint32 count = 0;
|
|
|
|
// For these mode no FriendInfo should have a null FriendInfoConsole
|
|
if(mode == FriendClient::ConsoleOnly || mode == FriendClient::ConsoleWithClubInfo)
|
|
{
|
|
EXPECT_TRUE(info != NULL);
|
|
}
|
|
|
|
if(info != NULL)
|
|
{
|
|
const String& username = info->m_profileInfo.m_nameOnPlatform;
|
|
if(mode == FriendClient::ClubWithConsoleInfo)
|
|
{
|
|
EXPECT_TRUE(info->m_profileInfo.m_nameOnPlatform != getConsoleUsername(4));
|
|
EXPECT_TRUE(info->m_profileInfo.m_nameOnPlatform != getConsoleUsername(5));
|
|
}
|
|
if(mode == FriendClient::ConsoleOnly || mode == FriendClient::ConsoleWithClubInfo)
|
|
{
|
|
#if !defined(US_TARGET_GGP)
|
|
EXPECT_TRUE(info->m_profileInfo.m_nameOnPlatform != getConsoleUsername(1));
|
|
#endif
|
|
EXPECT_TRUE(info->m_profileInfo.m_nameOnPlatform != getConsoleUsername(6));
|
|
}
|
|
for(uint32 i = 1; i < 7; ++i)
|
|
{
|
|
if(username == getConsoleUsername(i))
|
|
{
|
|
count++;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
return count;
|
|
}
|
|
|
|
void validateFriends(const Vector<FriendInfo>& friends, FriendClient::Mode mode, bool isFriendsUplayProfileFeatureSwitchOn)
|
|
{
|
|
const uint32 expectedCount = getExpectedFriendsCount(mode, isFriendsUplayProfileFeatureSwitchOn);
|
|
EXPECT_GE(friends.size(), expectedCount);
|
|
uint32 foundCountConsole = 0;
|
|
uint32 foundCountClub = 0;
|
|
|
|
for(const auto& it : friends)
|
|
{
|
|
foundCountConsole += validateSingleFriendConsole(it, mode);
|
|
foundCountClub += validateSingleFriendClub(it, mode);
|
|
}
|
|
|
|
#if !defined(US_TARGET_KILI) //TODO_KILI temporary until friend set up is done
|
|
switch(mode)
|
|
{
|
|
case FriendClient::ConsoleOnly: // We do not fetch the club info
|
|
EXPECT_EQ(0u, foundCountClub);
|
|
EXPECT_EQ(expectedCount, foundCountConsole);
|
|
break;
|
|
case FriendClient::ClubOnly: // We do not fetch the Console info
|
|
EXPECT_EQ(expectedCount, foundCountClub);
|
|
EXPECT_EQ(0u, foundCountConsole);
|
|
break;
|
|
case FriendClient::ConsoleWithClubInfo: // We fetch both Club & Console Info
|
|
EXPECT_EQ(expectedCount, foundCountClub);
|
|
EXPECT_EQ(expectedCount, foundCountConsole);
|
|
break;
|
|
case FriendClient::ClubWithConsoleInfo:
|
|
case FriendClient::Consolidated: // We fetch both Club & Console Info
|
|
#if defined(US_TARGET_IOS) && !defined(US_UPLAY_LOGIN_FOR_IOS)
|
|
EXPECT_EQ(4, foundCountClub);
|
|
#else
|
|
EXPECT_EQ(expectedCount, foundCountClub);
|
|
#endif
|
|
#if (defined(US_ENABLE_UPLAY_LOGIN) && !defined(US_TARGET_IOS) && !defined(US_TARGET_ANDROID)) || defined(US_UPLAY_LOGIN_FOR_IOS)
|
|
EXPECT_EQ(expectedCount - 1, foundCountConsole); // ussdk006 has no linked account
|
|
#else
|
|
#if defined(US_TARGET_IOS) || defined(US_TARGET_ANDROID)
|
|
EXPECT_EQ(0, foundCountConsole);
|
|
#else
|
|
//When the FriendsUplayProfile feature switch is activated, we have one additionnal friend coming from Uplay
|
|
//We need to not take that friend into account when comparing with the console count friends.
|
|
if (isFriendsUplayProfileFeatureSwitchOn && mode == FriendClient::Consolidated)
|
|
{
|
|
EXPECT_EQ(expectedCount-1, foundCountConsole);
|
|
}
|
|
else
|
|
{
|
|
EXPECT_EQ(expectedCount, foundCountConsole);
|
|
}
|
|
#endif
|
|
#endif
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
#endif
|
|
}
|
|
}
|
|
|
|
namespace TestParametersFriendsConsoleRequest_BF
|
|
{
|
|
struct ParamsFriendsConsoleRequest
|
|
{
|
|
FriendClient::Mode mode;
|
|
bool friendsUplayProfileFeatureSwitchActive;
|
|
};
|
|
}
|
|
|
|
#if !defined(US_ENABLE_UPLAY_LOGIN) && !defined(US_DLL)
|
|
/// @test Requests friends in Consolidated mode twice in a row to confirm that the
|
|
/// second call returns the cached result from the first call.
|
|
#if defined(US_TARGET_GGP)
|
|
// Unfortunately this tests even though is mocked needs an specific setup for ussdk002 and ussdk003.
|
|
// 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_CONSOLE_MOCK_LOGIN_CACHE, DISABLED_USNOT_RequestFriendsConsolidatedCache)
|
|
#else
|
|
TEST_F(FRIENDS_CONSOLE_MOCK_LOGIN_CACHE, USNOT_RequestFriendsConsolidatedCache)
|
|
#endif
|
|
{
|
|
waitForPostLoginCompletion(); // Avoid impacting the time taken by friend request (could trigger time to live expiration)
|
|
|
|
const Vector<uint32> indices = Vector<uint32>({2u, 3u});
|
|
::testing::InSequence s;
|
|
{
|
|
const String json = MockProfileHelper::buildRequestFriendsResponse(indices).renderContent();
|
|
const MockAsyncResult mockResult = MockResultHelper::createSuccessResult(json);
|
|
US_EXPECT_CALL_HTTP_SIMPLE(getMockHttpClientImpl(), HttpMethod::HTTP_GET, "mock-friendsClub", mockResult);
|
|
}
|
|
{
|
|
const String json = MockProfileHelper::buildRequestProfilesResponse(indices).renderContent();
|
|
const MockAsyncResult mockResult = MockResultHelper::createSuccessResult(json);
|
|
US_EXPECT_CALL_HTTP_SIMPLE(getMockHttpClientImpl(), HttpMethod::HTTP_GET, "mock-profiles?userId", mockResult);
|
|
}
|
|
{
|
|
const String json = MockProfileHelper::buildRequestProfilesResponse(indices).renderContent();
|
|
const MockAsyncResult mockResult = MockResultHelper::createSuccessResult(json);
|
|
US_EXPECT_CALL_HTTP_SIMPLE(getMockHttpClientImpl(), HttpMethod::HTTP_GET, "mock-profiles?idOnPlatform", mockResult);
|
|
}
|
|
{
|
|
const String json = MockProfileHelper::buildRequestProfilesResponse(indices).renderContent();
|
|
const MockAsyncResult mockResult = MockResultHelper::createSuccessResult(json);
|
|
US_EXPECT_CALL_HTTP_SIMPLE(getMockHttpClientImpl(), HttpMethod::HTTP_GET, "mock-profiles?userId", mockResult);
|
|
}
|
|
|
|
// First call should make HTTP request
|
|
const AsyncResult<Vector<FriendInfo> > resultHttp = getFacade().getFriendClient().requestFriends(FriendClient::Consolidated);
|
|
ASSERT_TRUE(AsyncHelper::waitSuccess(resultHttp));
|
|
|
|
|
|
// Second call should return cache without making any HTTP request
|
|
const AsyncResult<Vector<FriendInfo> > resultCache = getFacade().getFriendClient().requestFriends(FriendClient::Consolidated);
|
|
ASSERT_TRUE(resultCache.hasSucceeded());
|
|
|
|
// Validate second result is from cache
|
|
ASSERT_TRUE(resultHttp == resultCache);
|
|
}
|
|
|
|
/// @test Requests friends in ConsoleOnly mode twice in a row to confirm that the
|
|
/// second call returns the cached result from the first call.
|
|
TEST_F(FRIENDS_CONSOLE_MOCK_LOGIN_CACHE, USNOT_RequestFriendsConsoleOnlyCache)
|
|
{
|
|
waitForPostLoginCompletion();
|
|
const Vector<uint32> indices = Vector<uint32>({2u, 3u});
|
|
{
|
|
const String json = MockProfileHelper::buildRequestProfilesResponse(indices).renderContent();
|
|
const MockAsyncResult mockResult = MockResultHelper::createSuccessResult(json);
|
|
US_EXPECT_CALL_HTTP_SIMPLE(getMockHttpClientImpl(), HttpMethod::HTTP_GET, "mock-profiles?idOnPlatform", mockResult);
|
|
}
|
|
|
|
// First call should make HTTP request
|
|
const AsyncResult<Vector<FriendInfo> > resultHttp = getFacade().getFriendClient().requestFriends(FriendClient::ConsoleOnly);
|
|
ASSERT_TRUE(AsyncHelper::waitSuccess(resultHttp));
|
|
|
|
// Second call should return cache without making any HTTP request
|
|
const AsyncResult<Vector<FriendInfo> > resultCache = getFacade().getFriendClient().requestFriends(FriendClient::ConsoleOnly);
|
|
ASSERT_TRUE(resultCache.hasSucceeded());
|
|
|
|
// Validate second result is from cache
|
|
ASSERT_TRUE(resultHttp == resultCache);
|
|
}
|
|
|
|
/// @test Requests friends in ConsoleWithClubInfo mode twice in a row to confirm that the
|
|
/// second call returns the cached result from the first call.
|
|
#if defined(US_TARGET_GGP)
|
|
// Unfortunately this tests even though is mocked needs an specific setup for ussdk002 and ussdk003.
|
|
// 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_CONSOLE_MOCK_LOGIN_CACHE, DISABLED_USNOT_RequestFriendsConsoleWithClubInfoCache)
|
|
#else
|
|
TEST_F(FRIENDS_CONSOLE_MOCK_LOGIN_CACHE, USNOT_RequestFriendsConsoleWithClubInfoCache)
|
|
#endif
|
|
{
|
|
waitForPostLoginCompletion();
|
|
|
|
const Vector<uint32> indices = Vector<uint32>({2u, 3u});
|
|
{
|
|
const String json = MockProfileHelper::buildRequestProfilesResponse(indices).renderContent();
|
|
const MockAsyncResult mockResult = MockResultHelper::createSuccessResult(json);
|
|
US_EXPECT_CALL_HTTP_SIMPLE(getMockHttpClientImpl(), HttpMethod::HTTP_GET, "mock-profiles?idOnPlatform", mockResult);
|
|
}
|
|
{
|
|
const String json = MockProfileHelper::buildRequestProfilesResponse(indices).renderContent();
|
|
const MockAsyncResult mockResult = MockResultHelper::createSuccessResult(json);
|
|
US_EXPECT_CALL_HTTP_SIMPLE(getMockHttpClientImpl(), HttpMethod::HTTP_GET, "mock-profiles?userId", mockResult);
|
|
}
|
|
|
|
// First call should make HTTP request
|
|
const AsyncResult<Vector<FriendInfo> > resultHttp = getFacade().getFriendClient().requestFriends(FriendClient::ConsoleWithClubInfo);
|
|
ASSERT_TRUE(AsyncHelper::waitSuccess(resultHttp));
|
|
|
|
// Second call should return cache without making any HTTP request
|
|
const AsyncResult<Vector<FriendInfo> > resultCache = getFacade().getFriendClient().requestFriends(FriendClient::ConsoleWithClubInfo);
|
|
ASSERT_TRUE(resultCache.hasSucceeded());
|
|
|
|
// Validate second result is from cache
|
|
ASSERT_TRUE(resultHttp == resultCache);
|
|
}
|
|
|
|
/// @test Requests friends in ClubWithConsoleInfo mode twice in a row to confirm that the
|
|
/// second call returns the cached result from the first call.
|
|
TEST_F(FRIENDS_CONSOLE_MOCK_LOGIN_CACHE, USNOT_RequestFriendsClubWithConsoleInfoCache)
|
|
{
|
|
const Vector<uint32> indices = Vector<uint32>({2u, 3u});
|
|
::testing::InSequence s;
|
|
{
|
|
const String json = MockProfileHelper::buildRequestFriendsResponse(indices).renderContent();
|
|
const MockAsyncResult mockResult = MockResultHelper::createSuccessResult(json);
|
|
US_EXPECT_CALL_HTTP_SIMPLE(getMockHttpClientImpl(), HttpMethod::HTTP_GET, "mock-friendsClub", mockResult);
|
|
}
|
|
{
|
|
const String json = MockProfileHelper::buildRequestProfilesResponse(indices).renderContent();
|
|
const MockAsyncResult mockResult = MockResultHelper::createSuccessResult(json);
|
|
US_EXPECT_CALL_HTTP_SIMPLE(getMockHttpClientImpl(), HttpMethod::HTTP_GET, "mock-profiles?userId", mockResult);
|
|
}
|
|
|
|
// First call should make HTTP request
|
|
const AsyncResult<Vector<FriendInfo> > resultHttp = getFacade().getFriendClient().requestFriends(FriendClient::ClubWithConsoleInfo);
|
|
ASSERT_TRUE(AsyncHelper::waitSuccess(resultHttp));
|
|
|
|
// Second call should return cache without making any HTTP request
|
|
const AsyncResult<Vector<FriendInfo> > resultCache = getFacade().getFriendClient().requestFriends(FriendClient::ClubWithConsoleInfo);
|
|
ASSERT_TRUE(resultCache.hasSucceeded());
|
|
|
|
// Validate second result is from cache
|
|
ASSERT_TRUE(resultHttp == resultCache);
|
|
}
|
|
|
|
/// @test Alternates calls of requestFriends between ConsoleWithClubInfo and ClubWithConsoleInfo modes
|
|
/// as to confirm that any given mode preserves its cache regardless of calls to other modes.
|
|
#if defined(US_TARGET_GGP)
|
|
// Unfortunately this tests even though is mocked needs an specific setup for ussdk002 and ussdk003.
|
|
// 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_CONSOLE_MOCK_LOGIN_CACHE, DISABLED_USNOT_RequestFriendsAlternatingModesCache)
|
|
#else
|
|
TEST_F(FRIENDS_CONSOLE_MOCK_LOGIN_CACHE, USNOT_RequestFriendsAlternatingModesCache)
|
|
#endif
|
|
{
|
|
waitForPostLoginCompletion();
|
|
|
|
// First call with ConsoleWithClubInfo mode should make HTTP request
|
|
const Vector<uint32> indices = Vector<uint32>({2u, 3u});
|
|
::testing::InSequence s;
|
|
{
|
|
const String json = MockProfileHelper::buildRequestProfilesResponse(indices).renderContent();
|
|
const MockAsyncResult mockResult = MockResultHelper::createSuccessResult(json);
|
|
US_EXPECT_CALL_HTTP_SIMPLE(getMockHttpClientImpl(), HttpMethod::HTTP_GET, "mock-profiles?idOnPlatform", mockResult);
|
|
}
|
|
{
|
|
const String json = MockProfileHelper::buildRequestProfilesResponse(indices).renderContent();
|
|
const MockAsyncResult mockResult = MockResultHelper::createSuccessResult(json);
|
|
US_EXPECT_CALL_HTTP_SIMPLE(getMockHttpClientImpl(), HttpMethod::HTTP_GET, "mock-profiles?userId", mockResult);
|
|
}
|
|
const AsyncResult<Vector<FriendInfo> > firstModeResultHttp = getFacade().getFriendClient().requestFriends(FriendClient::ConsoleWithClubInfo);
|
|
ASSERT_TRUE(AsyncHelper::waitSuccess(firstModeResultHttp));
|
|
|
|
// First call with ClubWithConsoleInfo mode should make HTTP request
|
|
{
|
|
const String json = MockProfileHelper::buildRequestFriendsResponse(indices).renderContent();
|
|
const MockAsyncResult mockResult = MockResultHelper::createSuccessResult(json);
|
|
US_EXPECT_CALL_HTTP_SIMPLE(getMockHttpClientImpl(), HttpMethod::HTTP_GET, "mock-friendsClub", mockResult);
|
|
}
|
|
{
|
|
const String json = MockProfileHelper::buildRequestProfilesResponse(indices).renderContent();
|
|
const MockAsyncResult mockResult = MockResultHelper::createSuccessResult(json);
|
|
US_EXPECT_CALL_HTTP_SIMPLE(getMockHttpClientImpl(), HttpMethod::HTTP_GET, "mock-profiles?userId", mockResult);
|
|
}
|
|
const AsyncResult<Vector<FriendInfo> > secondModeResultHttp = getFacade().getFriendClient().requestFriends(FriendClient::ClubWithConsoleInfo);
|
|
ASSERT_TRUE(AsyncHelper::waitSuccess(secondModeResultHttp));
|
|
|
|
// Second call with ConsoleWithClubInfo mode should return cache without making any HTTP request
|
|
const AsyncResult<Vector<FriendInfo> > firstModeResultCache = getFacade().getFriendClient().requestFriends(FriendClient::ConsoleWithClubInfo);
|
|
ASSERT_TRUE(firstModeResultCache.hasSucceeded());
|
|
|
|
// Second call with ClubWithConsoleInfo mode should return cache without making any HTTP request
|
|
const AsyncResult<Vector<FriendInfo> > secondModeResultCache = getFacade().getFriendClient().requestFriends(FriendClient::ClubWithConsoleInfo);
|
|
ASSERT_TRUE(secondModeResultCache.hasSucceeded());
|
|
|
|
// Confirming both results from caches are different caches
|
|
ASSERT_TRUE(firstModeResultCache != secondModeResultCache);
|
|
}
|
|
|
|
#if !defined(US_TARGET_GGP)
|
|
// On ggp this test is set to manual since TestFriendsConsole_BF::validateFriends needs to be modified
|
|
// to accomodate the temporary setup of a developer runnning this test.
|
|
|
|
typedef ParamFixture<FRIENDS_CONSOLE_LOGIN, TestParametersFriendsConsoleRequest_BF::ParamsFriendsConsoleRequest> PARAMETERS_FRIENDS_CONSOLE_REQUEST_FIXTURE;
|
|
INSTANTIATE_TEST_CASE_P(ParamsFriendsConsoleRequest, PARAMETERS_FRIENDS_CONSOLE_REQUEST_FIXTURE, ::testing::Values(
|
|
TestParametersFriendsConsoleRequest_BF::ParamsFriendsConsoleRequest{ FriendClient::ConsoleOnly, true},
|
|
TestParametersFriendsConsoleRequest_BF::ParamsFriendsConsoleRequest{ FriendClient::ConsoleOnly, false},
|
|
TestParametersFriendsConsoleRequest_BF::ParamsFriendsConsoleRequest{ FriendClient::ConsoleWithClubInfo, true },
|
|
TestParametersFriendsConsoleRequest_BF::ParamsFriendsConsoleRequest{ FriendClient::ConsoleWithClubInfo, false },
|
|
TestParametersFriendsConsoleRequest_BF::ParamsFriendsConsoleRequest{ FriendClient::ClubOnly, true },
|
|
TestParametersFriendsConsoleRequest_BF::ParamsFriendsConsoleRequest{ FriendClient::ClubOnly, false },
|
|
TestParametersFriendsConsoleRequest_BF::ParamsFriendsConsoleRequest{ FriendClient::ClubWithConsoleInfo, true },
|
|
TestParametersFriendsConsoleRequest_BF::ParamsFriendsConsoleRequest{ FriendClient::ClubWithConsoleInfo, false },
|
|
TestParametersFriendsConsoleRequest_BF::ParamsFriendsConsoleRequest{ FriendClient::Consolidated, true },
|
|
TestParametersFriendsConsoleRequest_BF::ParamsFriendsConsoleRequest{ FriendClient::Consolidated, false }
|
|
));
|
|
|
|
#if defined(US_CHINA_ACCOUNTS_SETUP_NOT_DONE) // 0 friends in china
|
|
TEST_P(PARAMETERS_FRIENDS_CONSOLE_REQUEST_FIXTURE, DISABLED_US_RequestFriendsConsole)
|
|
#else
|
|
/// @test Performs Friends Request for all mode on console, with and without cross friends
|
|
TEST_P(PARAMETERS_FRIENDS_CONSOLE_REQUEST_FIXTURE, US_RequestFriendsConsole)
|
|
#endif
|
|
{
|
|
const auto param = this->getParam();
|
|
ParametersClientProxy::enableSwitch(getFacade(), FeatureSwitchId::FriendsUplayProfile, param.friendsUplayProfileFeatureSwitchActive);
|
|
AsyncResult<Vector<FriendInfo> > result = getFacade().getFriendClient().requestFriends(param.mode);
|
|
ASSERT_TRUE(AsyncHelper::waitSuccess(result));
|
|
TestFriendsConsole_BF::validateFriends(result.getResult(), param.mode, getFacade().getParametersClient().isUsFeatureSwitchEnabled(FeatureSwitchId::FriendsUplayProfile));
|
|
}
|
|
#endif
|
|
|
|
#if defined(US_CHINA_ACCOUNTS_SETUP_NOT_DONE) // 0 friends in china
|
|
TEST_F(FRIENDS_CONSOLE_LOGIN, DISABLED_US_RequestFriendsClubWithConsoleInfo)
|
|
#else
|
|
TEST_F(FRIENDS_CONSOLE_LOGIN, US_MINRUN_RequestFriendsClubWithConsoleInfo)
|
|
#endif
|
|
{
|
|
const FriendClient::Mode MODE = FriendClient::ClubWithConsoleInfo;
|
|
AsyncResult<Vector<FriendInfo> > result = getFacade().getFriendClient().requestFriends(MODE);
|
|
ASSERT_TRUE(AsyncHelper::waitSuccess(result));
|
|
TestFriendsConsole_BF::validateFriends(result.getResult(), MODE, getFacade().getParametersClient().isUsFeatureSwitchEnabled(FeatureSwitchId::FriendsUplayProfile));
|
|
}
|
|
|
|
#if defined(US_CHINA_ACCOUNTS_SETUP_NOT_DONE) // 0 friends in china
|
|
TEST_F(FRIENDS_CONSOLE_LOGIN, DISABLED_US_RequestFriendsConsolidated)
|
|
#else
|
|
TEST_F(FRIENDS_CONSOLE_LOGIN, US_RequestFriendsConsolidated)
|
|
#endif
|
|
{
|
|
const FriendClient::Mode MODE = FriendClient::Consolidated;
|
|
AsyncResult<Vector<FriendInfo> > result = getFacade().getFriendClient().requestFriends(MODE);
|
|
ASSERT_TRUE(AsyncHelper::waitSuccess(result));
|
|
TestFriendsConsole_BF::validateFriends(result.getResult(), MODE, getFacade().getParametersClient().isUsFeatureSwitchEnabled(FeatureSwitchId::FriendsUplayProfile));
|
|
}
|
|
#endif // !US_ENABLE_UPLAY_LOGIN
|
|
};
|