@@ -42,6 +42,7 @@ var PlayFabApiTests = {
42
42
QUnit . module ( "PlayFab Api Test" ) ;
43
43
QUnit . test ( "InvalidLogin" , PlayFabApiTests . InvalidLogin ) ;
44
44
QUnit . test ( "LoginOrRegister" , PlayFabApiTests . LoginOrRegister ) ;
45
+ QUnit . test ( "LoginWithAdvertisingId" , PlayFabApiTests . LoginWithAdvertisingId ) ;
45
46
46
47
setTimeout ( function ( ) { PlayFabApiTests . PostLoginTests ( 0 ) ; } , 200 ) ;
47
48
setTimeout ( function ( ) { PlayFabApiTests . PostCharacterTests ( 0 ) ; } , 200 ) ;
@@ -96,7 +97,7 @@ var PlayFabApiTests = {
96
97
97
98
return titleDataValid ;
98
99
} ,
99
-
100
+
100
101
CallbackWrapper : function ( callbackName , Callback , assert ) {
101
102
return function ( result , error ) {
102
103
try {
@@ -107,6 +108,17 @@ var PlayFabApiTests = {
107
108
}
108
109
} ;
109
110
} ,
111
+
112
+ SimpleCallbackWrapper : function ( callbackName , Callback , assert ) {
113
+ return function ( ) {
114
+ try {
115
+ Callback ( ) ;
116
+ } catch ( e ) {
117
+ window . console . error ( "Exception thrown during " + callbackName + " callback: " + e . toString ( ) + "\n" + e . stack ) ; // Very irritatingly, qunit doesn't report failure results until all async callbacks return, which doesn't always happen when there's an exception
118
+ assert . ok ( false , "Exception thrown during " + callbackName + " callback: " + e . toString ( ) + "\n" + e . stack ) ;
119
+ }
120
+ } ;
121
+ } ,
110
122
111
123
VerifyNullError : function ( result , error , assert , message ) {
112
124
var success = ( result != null && error == null )
@@ -116,6 +128,11 @@ var PlayFabApiTests = {
116
128
assert . ok ( false , "PlayFab error message: " + error . errorMessage ) ;
117
129
} ,
118
130
131
+ /// <summary>
132
+ /// CLIENT API
133
+ /// Try to deliberately log in with an inappropriate password,
134
+ /// and verify that the error displays as expected.
135
+ /// </summary>
119
136
InvalidLogin : function ( assert ) {
120
137
var invalidRequest = {
121
138
TitleId : PlayFab . settings . titleId ,
@@ -134,6 +151,10 @@ var PlayFabApiTests = {
134
151
PlayFabClientSDK . LoginWithEmailAddress ( invalidRequest , PlayFabApiTests . CallbackWrapper ( "InvalidLoginCallback" , InvalidLoginCallback , assert ) ) ;
135
152
} ,
136
153
154
+ /// <summary>
155
+ /// CLIENT API
156
+ /// Log in or create a user, track their PlayFabId
157
+ /// </summary>
137
158
LoginOrRegister : function ( assert ) {
138
159
var loginRequest = {
139
160
// Currently, you need to look up the correct format for this object in the API-docs:
@@ -188,6 +209,44 @@ var PlayFabApiTests = {
188
209
PlayFabClientSDK . LoginWithEmailAddress ( loginRequest , PlayFabApiTests . CallbackWrapper ( "OptionalLoginCallback" , OptionalLoginCallback , assert ) ) ;
189
210
} ,
190
211
212
+ /// <summary>
213
+ /// CLIENT API
214
+ /// Test that the login call sequence sends the AdvertisingId when set
215
+ /// </summary>
216
+ LoginWithAdvertisingId : function ( assert ) {
217
+ PlayFab . settings . advertisingIdType = PlayFab . settings . AD_TYPE_ANDROID_ID ;
218
+ PlayFab . settings . advertisingIdValue = "PlayFabTestId" ;
219
+
220
+ assert . expect ( 0 ) ;
221
+ var loginDone = assert . async ( ) ;
222
+ var count = - 1 ;
223
+ var FinishAdvertId = function ( ) {
224
+ count += 1 ;
225
+ if ( count > 10 )
226
+ assert . ok ( false , "The advertisingId was not submitted properly" ) ;
227
+ else if ( PlayFab . settings . advertisingIdType === PlayFab . settings . AD_TYPE_ANDROID_ID + "_Successful" )
228
+ loginDone ( ) ;
229
+ else
230
+ setTimeout ( PlayFabApiTests . SimpleCallbackWrapper ( "FinishAdvertId" , FinishAdvertId , assert ) , 200 ) ;
231
+ } ;
232
+ var AdvertLoginCallback = function ( result , error ) {
233
+ setTimeout ( PlayFabApiTests . SimpleCallbackWrapper ( "FinishAdvertId" , FinishAdvertId , assert ) , 200 ) ;
234
+ } ;
235
+ var loginRequest = {
236
+ TitleId : PlayFab . settings . titleId ,
237
+ Email : PlayFabApiTests . titleData . userEmail ,
238
+ Password : PlayFabApiTests . titleData . userPassword ,
239
+ } ;
240
+ PlayFabClientSDK . LoginWithEmailAddress ( loginRequest , PlayFabApiTests . CallbackWrapper ( "AdvertLoginCallback" , AdvertLoginCallback , assert ) ) ;
241
+ } ,
242
+
243
+ /// <summary>
244
+ /// CLIENT API
245
+ /// Test a sequence of calls that modifies saved data,
246
+ /// and verifies that the next sequential API call contains updated data.
247
+ /// Verify that the data is correctly modified on the next call.
248
+ /// Parameter types tested: string, Dictionary<string, string>, DateTime
249
+ /// </summary>
191
250
UserDataApi : function ( assert ) {
192
251
var getDataRequest = { } ; // null also works
193
252
@@ -236,6 +295,13 @@ var PlayFabApiTests = {
236
295
PlayFabClientSDK . GetUserData ( getDataRequest , PlayFabApiTests . CallbackWrapper ( "GetDataCallback1" , GetDataCallback1 , assert ) ) ;
237
296
} ,
238
297
298
+ /// <summary>
299
+ /// CLIENT API
300
+ /// Test a sequence of calls that modifies saved data,
301
+ /// and verifies that the next sequential API call contains updated data.
302
+ /// Verify that the data is saved correctly, and that specific types are tested
303
+ /// Parameter types tested: Dictionary<string, int>
304
+ /// </summary>
239
305
UserStatisticsApi : function ( assert ) {
240
306
var getStatsRequest = { } ; // null also works
241
307
@@ -278,6 +344,11 @@ var PlayFabApiTests = {
278
344
PlayFabClientSDK . GetUserStatistics ( getStatsRequest , PlayFabApiTests . CallbackWrapper ( "GetStatsCallback1" , GetStatsCallback1 , assert ) ) ;
279
345
} ,
280
346
347
+ /// <summary>
348
+ /// SERVER API
349
+ /// Get or create the given test character for the given user
350
+ /// Parameter types tested: Contained-Classes, string
351
+ /// </summary>
281
352
UserCharacter : function ( assert ) {
282
353
var getCharsRequest = { } ;
283
354
var grantCharRequest = {
@@ -328,6 +399,11 @@ var PlayFabApiTests = {
328
399
PlayFabClientSDK . GetAllUsersCharacters ( getCharsRequest , PlayFabApiTests . CallbackWrapper ( "OptionalGetCharsCallback" , OptionalGetCharsCallback , assert ) ) ;
329
400
} ,
330
401
402
+ /// <summary>
403
+ /// CLIENT AND SERVER API
404
+ /// Test that leaderboard results can be requested
405
+ /// Parameter types tested: List of contained-classes
406
+ /// </summary>
331
407
LeaderBoard : function ( assert ) {
332
408
var clientRequest = {
333
409
MaxResultsCount : 3 ,
@@ -365,6 +441,11 @@ var PlayFabApiTests = {
365
441
PlayFabServerSDK . GetLeaderboardAroundCharacter ( serverRequest , PlayFabApiTests . CallbackWrapper ( "GetLeaderboardCallback_S" , GetLeaderboardCallback_S , assert ) ) ;
366
442
} ,
367
443
444
+ /// <summary>
445
+ /// CLIENT API
446
+ /// Test that AccountInfo can be requested
447
+ /// Parameter types tested: List of enum-as-strings converted to list of enums
448
+ /// </summary>
368
449
AccountInfo : function ( assert ) {
369
450
var GetAccountInfoCallback = function ( result , error ) {
370
451
PlayFabApiTests . VerifyNullError ( result , error , assert , "Testing GetAccountInfo result" ) ;
@@ -379,6 +460,10 @@ var PlayFabApiTests = {
379
460
PlayFabClientSDK . GetAccountInfo ( { } , PlayFabApiTests . CallbackWrapper ( "GetAccountInfoCallback" , GetAccountInfoCallback , assert ) ) ;
380
461
} ,
381
462
463
+ /// <summary>
464
+ /// CLIENT API
465
+ /// Test that CloudScript can be properly set up and invoked
466
+ /// </summary>
382
467
CloudScript : function ( assert ) {
383
468
var urlDone = null ;
384
469
var hwDone = null ;
0 commit comments