Skip to content

Commit 4a45a08

Browse files
author
Paul Gilmore
committed
Merge pull request #28 from PlayFab/nightly
Weekly SDK Publish
2 parents d94223f + 7f16a47 commit 4a45a08

File tree

5 files changed

+551
-310
lines changed

5 files changed

+551
-310
lines changed

PlayFabApiTest.js

Lines changed: 86 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ var PlayFabApiTests = {
4242
QUnit.module("PlayFab Api Test");
4343
QUnit.test("InvalidLogin", PlayFabApiTests.InvalidLogin);
4444
QUnit.test("LoginOrRegister", PlayFabApiTests.LoginOrRegister);
45+
QUnit.test("LoginWithAdvertisingId", PlayFabApiTests.LoginWithAdvertisingId);
4546

4647
setTimeout(function () { PlayFabApiTests.PostLoginTests(0); }, 200);
4748
setTimeout(function () { PlayFabApiTests.PostCharacterTests(0); }, 200);
@@ -96,7 +97,7 @@ var PlayFabApiTests = {
9697

9798
return titleDataValid;
9899
},
99-
100+
100101
CallbackWrapper: function (callbackName, Callback, assert) {
101102
return function (result, error) {
102103
try {
@@ -107,6 +108,17 @@ var PlayFabApiTests = {
107108
}
108109
};
109110
},
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+
},
110122

111123
VerifyNullError: function (result, error, assert, message) {
112124
var success = (result != null && error == null)
@@ -116,6 +128,11 @@ var PlayFabApiTests = {
116128
assert.ok(false, "PlayFab error message: " + error.errorMessage);
117129
},
118130

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>
119136
InvalidLogin: function (assert) {
120137
var invalidRequest = {
121138
TitleId: PlayFab.settings.titleId,
@@ -134,6 +151,10 @@ var PlayFabApiTests = {
134151
PlayFabClientSDK.LoginWithEmailAddress(invalidRequest, PlayFabApiTests.CallbackWrapper("InvalidLoginCallback", InvalidLoginCallback, assert));
135152
},
136153

154+
/// <summary>
155+
/// CLIENT API
156+
/// Log in or create a user, track their PlayFabId
157+
/// </summary>
137158
LoginOrRegister: function (assert) {
138159
var loginRequest = {
139160
// Currently, you need to look up the correct format for this object in the API-docs:
@@ -188,6 +209,44 @@ var PlayFabApiTests = {
188209
PlayFabClientSDK.LoginWithEmailAddress(loginRequest, PlayFabApiTests.CallbackWrapper("OptionalLoginCallback", OptionalLoginCallback, assert));
189210
},
190211

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>
191250
UserDataApi: function (assert) {
192251
var getDataRequest = {}; // null also works
193252

@@ -236,6 +295,13 @@ var PlayFabApiTests = {
236295
PlayFabClientSDK.GetUserData(getDataRequest, PlayFabApiTests.CallbackWrapper("GetDataCallback1", GetDataCallback1, assert));
237296
},
238297

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>
239305
UserStatisticsApi: function (assert) {
240306
var getStatsRequest = {}; // null also works
241307

@@ -278,6 +344,11 @@ var PlayFabApiTests = {
278344
PlayFabClientSDK.GetUserStatistics(getStatsRequest, PlayFabApiTests.CallbackWrapper("GetStatsCallback1", GetStatsCallback1, assert));
279345
},
280346

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>
281352
UserCharacter: function (assert) {
282353
var getCharsRequest = {};
283354
var grantCharRequest = {
@@ -328,6 +399,11 @@ var PlayFabApiTests = {
328399
PlayFabClientSDK.GetAllUsersCharacters(getCharsRequest, PlayFabApiTests.CallbackWrapper("OptionalGetCharsCallback", OptionalGetCharsCallback, assert));
329400
},
330401

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>
331407
LeaderBoard: function (assert) {
332408
var clientRequest = {
333409
MaxResultsCount: 3,
@@ -365,6 +441,11 @@ var PlayFabApiTests = {
365441
PlayFabServerSDK.GetLeaderboardAroundCharacter(serverRequest, PlayFabApiTests.CallbackWrapper("GetLeaderboardCallback_S", GetLeaderboardCallback_S, assert));
366442
},
367443

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>
368449
AccountInfo: function (assert) {
369450
var GetAccountInfoCallback = function (result, error) {
370451
PlayFabApiTests.VerifyNullError(result, error, assert, "Testing GetAccountInfo result");
@@ -379,6 +460,10 @@ var PlayFabApiTests = {
379460
PlayFabClientSDK.GetAccountInfo({}, PlayFabApiTests.CallbackWrapper("GetAccountInfoCallback", GetAccountInfoCallback, assert));
380461
},
381462

463+
/// <summary>
464+
/// CLIENT API
465+
/// Test that CloudScript can be properly set up and invoked
466+
/// </summary>
382467
CloudScript: function (assert) {
383468
var urlDone = null;
384469
var hwDone = null;

0 commit comments

Comments
 (0)