Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Added BBM presence for other users #152

Closed
wants to merge 1 commit into from

3 participants

@pagey

This change adds presence update information for other users on your BBM contact list.

This change is dependant on https://www.github.com/blackberry-webworks/BB10-WebWorks-Framework/pull/148
Currently not supported is getting the display picture of the user

Docs pull request: blackberry-webworks/WebWorks-API-Docs#182
Viewable docs: http://blackberry-webworks.github.com/WebWorks-API-Docs/WebWorks-API-Docs-next-BB10-bbm-users/view/topics.html

@tracyli

tested with http://ci0000003863287:8080/hudson/job/BB10-Webworks-Framework-next-bbm-users/15/: onupdate worked fine and no issue was found.

@nukulb

@rwmtse - code review?

@pagey - I assume this entire API is not implemented, it still has some missing pieces like "other profile pic"
do we have open issues for these?

@pagey

I created issue #222 for the missing API

@nukulb nukulb closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 4, 2012
  1. @pagey

    Added other users for BBM

    pagey authored
This page is out of date. Refresh to see the latest.
View
10 ext/bbm.platform/BBMEvents.js
@@ -20,16 +20,18 @@ module.exports = {
addEventListener: function (event, trigger) {
if (event === "onaccesschanged") {
bbm.startEvents(trigger);
- }
- else {
+ } else if (event === "onupdate") {
+ bbm.startContactEvents(trigger);
+ } else {
console.log("Ignore registration for unknown event: " + event);
}
},
removeEventListener: function (event) {
if (event === "onaccesschanged") {
bbm.stopEvents();
- }
- else {
+ } else if (event === "onupdate") {
+ bbm.stopContactEvents();
+ } else {
console.log("Ignore un-registration for unknown event: " + event);
}
}
View
124 ext/bbm.platform/BBMJNEXT.js
@@ -1,18 +1,18 @@
/*
-* Copyright 2012 Research In Motion Limited.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+ * Copyright 2012 Research In Motion Limited.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
function requireLocal(id) {
return !!require.resolve ? require("../../" + id) : window.require(id);
@@ -20,6 +20,7 @@ function requireLocal(id) {
var bbm,
accesschangedCallback = null,
+ updateCallback = null,
_event = require("../../lib/event");
///////////////////////////////////////////////////////////////////
@@ -28,89 +29,106 @@ var bbm,
JNEXT.BBM = function ()
{
- var self = this;
+ var _self = this;
+ _self.self = {};
+ _self.users = {};
- self.startEvents = function (trigger) {
+ _self.startEvents = function (trigger) {
if (accesschangedCallback === null) {
accesschangedCallback = trigger;
- JNEXT.invoke(self.m_id, "startEvents");
+ JNEXT.invoke(_self.m_id, "startEvents");
}
};
- self.stopEvents = function () {
+ _self.stopEvents = function () {
accesschangedCallback = null;
- JNEXT.invoke(self.m_id, "stopEvents");
+ JNEXT.invoke(_self.m_id, "stopEvents");
};
- self.register = function (options) {
- JNEXT.invoke(self.m_id, "register " + JSON.stringify(options));
+ _self.startContactEvents = function (trigger) {
+ if (updateCallback === null) {
+ updateCallback = trigger;
+ JNEXT.invoke(_self.m_id, "startContactEvents");
+ }
+ };
+
+ _self.stopContactEvents = function () {
+ updateCallback = null;
+ JNEXT.invoke(_self.m_id, "stopContactEvents");
+ };
+
+ _self.register = function (options) {
+ JNEXT.invoke(_self.m_id, "register " + JSON.stringify(options));
+ };
+
+ _self.getgid = function () {
+ return JNEXT.invoke(_self.m_id, "getgid");
};
- self.getProfile = function (field) {
- return JNEXT.invoke(self.m_id, "getProfile " + field);
+ _self.self.getProfile = function (field) {
+ return JNEXT.invoke(_self.m_id, "self.getProfile " + field);
};
- self.getDisplayPicture = function (eventId) {
- self.displayPictureEventId = eventId;
- return JNEXT.invoke(self.m_id, "getDisplayPicture");
+ _self.self.getDisplayPicture = function (eventId) {
+ _self.displayPictureEventId = eventId;
+ return JNEXT.invoke(_self.m_id, "self.getDisplayPicture");
};
- self.setStatus = function (statusArgs) {
- JNEXT.invoke(self.m_id, "setStatus " + JSON.stringify(statusArgs));
+ _self.self.setStatus = function (statusArgs) {
+ JNEXT.invoke(_self.m_id, "self.setStatus " + JSON.stringify(statusArgs));
};
- self.setPersonalMessage = function (personalMessage) {
- JNEXT.invoke(self.m_id, "setPersonalMessage " + personalMessage);
+ _self.self.setPersonalMessage = function (personalMessage) {
+ JNEXT.invoke(_self.m_id, "self.setPersonalMessage " + personalMessage);
};
- self.setDisplayPicture = function (displayPicture) {
- JNEXT.invoke(self.m_id, "setDisplayPicture " + displayPicture);
+ _self.self.setDisplayPicture = function (displayPicture) {
+ JNEXT.invoke(_self.m_id, "self.setDisplayPicture " + displayPicture);
};
- self.getId = function () {
- return self.m_id;
+ _self.getId = function () {
+ return _self.m_id;
};
- self.init = function () {
+ _self.init = function () {
if (!JNEXT.require("bbm")) {
return false;
}
- self.m_id = JNEXT.createObject("bbm.BBM");
-
- if (self.m_id === "") {
+ _self.m_id = JNEXT.createObject("bbm.BBM");
+
+ if (_self.m_id === "") {
return false;
}
- JNEXT.registerEvents(self);
+ JNEXT.registerEvents(_self);
};
-
- self.onEvent = function (strData) {
+
+ _self.onEvent = function (strData) {
var arData = strData.split(" "),
strEventDesc = arData[0],
- allowed;
-
+ allowed,
+ obj;
+
if (strEventDesc === "onaccesschanged") {
if (arData[1] === "allowed") {
allowed = true;
} else {
allowed = false;
}
-
accesschangedCallback(allowed, arData[1]);
+ } else if (strEventDesc === "onupdate") {
+ obj = arData.slice(2, arData.length).join(" ");
+ updateCallback(JSON.parse(obj), arData[1]);
} else if (strEventDesc === "self.getDisplayPicture") {
- _event.trigger(self.displayPictureEventId, arData[1]);
+ _event.trigger(_self.displayPictureEventId, arData[1]);
}
};
+
+ _self.m_id = "";
+ _self.displayPictureEventId = "";
- self.getgid = function () {
- return JNEXT.invoke(self.m_id, "getgid");
- };
-
- self.m_id = "";
- self.displayPictureEventId = "";
-
- self.init();
+ _self.init();
};
bbm = new JNEXT.BBM();
View
31 ext/bbm.platform/index.js
@@ -24,6 +24,13 @@ var bbm = require("./BBMJNEXT").bbm,
trigger: function (allowed, reason) {
_event.trigger("onaccesschanged", allowed, reason);
}
+ },
+ onupdate: {
+ context: require("./BBMEvents"),
+ event: "onupdate",
+ trigger: function (user, event) {
+ _event.trigger("onupdate", user, event);
+ }
}
},
BBM_DISPLAY_NAME = 0,
@@ -62,42 +69,42 @@ module.exports = {
self : {
appVersion : function (success, fail, args, env) {
- success(bbm.getProfile(BBM_APP_VERSION));
+ success(bbm.self.getProfile(BBM_APP_VERSION));
},
bbmsdkVersion : function (success, fail, args, env) {
- success(parseInt(bbm.getProfile(BBM_SDK_VERSION), 10));
+ success(parseInt(bbm.self.getProfile(BBM_SDK_VERSION), 10));
},
displayName : function (success, fail, args, env) {
- success(bbm.getProfile(BBM_DISPLAY_NAME));
+ success(bbm.self.getProfile(BBM_DISPLAY_NAME));
},
handle : function (success, fail, args, env) {
- success(bbm.getProfile(BBM_HANDLE));
+ success(bbm.self.getProfile(BBM_HANDLE));
},
personalMessage : function (success, fail, args, env) {
- success(bbm.getProfile(BBM_PERSONAL_MESSAGE));
+ success(bbm.self.getProfile(BBM_PERSONAL_MESSAGE));
},
ppid : function (success, fail, args, env) {
- success(bbm.getProfile(BBM_PPID));
+ success(bbm.self.getProfile(BBM_PPID));
},
status : function (success, fail, args, env) {
- success(bbm.getProfile(BBM_STATUS));
+ success(bbm.self.getProfile(BBM_STATUS));
},
statusMessage : function (success, fail, args, env) {
- success(bbm.getProfile(BBM_STATUS_MESSAGE));
+ success(bbm.self.getProfile(BBM_STATUS_MESSAGE));
},
getDisplayPicture : function (success, fail, args, env) {
if (args) {
args.eventId = JSON.parse(decodeURIComponent(args.eventId));
- bbm.getDisplayPicture(args.eventId);
+ bbm.self.getDisplayPicture(args.eventId);
success();
}
},
@@ -113,7 +120,7 @@ module.exports = {
}
}
- bbm.setStatus(args);
+ bbm.self.setStatus(args);
success();
},
@@ -127,7 +134,7 @@ module.exports = {
}
}
- bbm.setPersonalMessage(args.personalMessage);
+ bbm.self.setPersonalMessage(args.personalMessage);
success();
},
@@ -141,7 +148,7 @@ module.exports = {
}
}
- bbm.setDisplayPicture(args.displayPicture);
+ bbm.self.setDisplayPicture(args.displayPicture);
success();
}
},
View
192 ext/bbm.platform/native/bbm_bps.cpp
@@ -17,10 +17,12 @@
#include "bbm_bps.hpp"
#include "bbm_js.hpp"
#include <bbmsp/bbmsp.h>
-#include <bbmsp/bbmsp_events.h>
+#include <bbmsp/bbmsp_contactlist.h>
#include <bbmsp/bbmsp_context.h>
+#include <bbmsp/bbmsp_events.h>
#include <bbmsp/bbmsp_userprofile.h>
#include <bbmsp/bbmsp_util.h>
+#include <json/writer.h>
#include <fcntl.h>
#include <resolv.h>
#include <stdio.h>
@@ -29,14 +31,16 @@
#include <string>
#include <vector>
-#define MUTEX_LOCK() pthread_mutex_lock(&m_lock)
+#define MUTEX_LOCK() pthread_mutex_trylock(&m_lock)
#define MUTEX_UNLOCK() pthread_mutex_unlock(&m_lock)
namespace webworks {
+bool BBMBPS::contactEventsEnabled = false;
pthread_mutex_t BBMBPS::m_lock = PTHREAD_MUTEX_INITIALIZER;
int BBMBPS::m_eventChannel = -1;
-int BBMBPS::m_endEventDomain = -1;
+int BBMBPS::m_BBMInternalDomain = -1;
+bbmsp_contact_list_t *BBMBPS::m_pContactList;
BBMBPS::BBMBPS(BBM *parent) : m_pParent(parent)
{
@@ -56,9 +60,9 @@ void BBMBPS::SetActiveChannel(int channel)
int BBMBPS::InitializeEvents()
{
m_eventChannel = bps_channel_get_active();
- m_endEventDomain = bps_register_domain();
+ m_BBMInternalDomain = bps_register_domain();
- return (m_endEventDomain >= 0) ? 0 : 1;
+ return (m_BBMInternalDomain >= 0) ? 0 : 1;
}
void BBMBPS::processAccessCode(int code)
@@ -112,7 +116,52 @@ void BBMBPS::processAccessCode(int code)
accessString.append("unknown");
break;
}
- m_pParent->NotifyEvent(accessString);
+ m_pParent->NotifyEvent(accessString);
+}
+
+void BBMBPS::processContactUpdate(bbmsp_event_t *event)
+{
+ int updateType = -1;
+ bbmsp_contact_t *contact;
+ std::string updateString = "onupdate ";
+ bbmsp_event_contact_changed_get_contact(event, &contact);
+ updateType = bbmsp_event_contact_changed_get_presence_update_type(event);
+
+ switch (updateType)
+ {
+ case BBMSP_DISPLAY_NAME:
+ updateString += "displayname " + getFullContact(contact);
+ break;
+ case BBMSP_DISPLAY_PICTURE:
+ updateString += "displaypicture " + getFullContact(contact);
+ break;
+ case BBMSP_PERSONAL_MESSAGE:
+ updateString += "personalmessage " + getFullContact(contact);
+ break;
+ case BBMSP_STATUS:
+ updateString += "status " + getFullContact(contact);
+ break;
+ default:
+ break;
+ }
+ m_pParent->NotifyEvent(updateString);
+}
+
+std::string BBMBPS::getFullContact(bbmsp_contact_t *contact)
+{
+ Json::FastWriter writer;
+ Json::Value root;
+
+ root["displayName"] = GetContact(contact, BBM_DISPLAY_NAME);
+ root["status"] = GetContact(contact, BBM_STATUS);
+ root["statusMessage"] = GetContact(contact, BBM_STATUS_MESSAGE);
+ root["personalMessage"] = GetContact(contact, BBM_PERSONAL_MESSAGE);
+ root["ppid"] = GetContact(contact, BBM_PPID);
+ root["handle"] = GetContact(contact, BBM_HANDLE);
+ root["appVersion"] = GetContact(contact, BBM_APP_VERSION);
+ root["bbmsdkVersion"] = GetContact(contact, BBM_SDK_VERSION);
+
+ return writer.write(root);
}
int BBMBPS::WaitForEvents()
@@ -135,7 +184,6 @@ int BBMBPS::WaitForEvents()
if (event_domain == bbmsp_get_domain()) {
int eventCategory = 0;
int eventType = 0;
- int code = 0;
bbmsp_event_get(event, &bbmEvent);
@@ -188,11 +236,29 @@ int BBMBPS::WaitForEvents()
}
break;
}
+ case BBMSP_CONTACT_LIST:
+ {
+ if (bbmsp_event_get_type(event, &eventType) == BBMSP_SUCCESS) {
+ switch (eventType) {
+ case BBMSP_SP_EVENT_CONTACT_CHANGED:
+ {
+ processContactUpdate(bbmEvent);
+ }
+ }
+ }
+ }
}
+ MUTEX_UNLOCK();
+ }
+ } else if (event_domain == m_BBMInternalDomain) {
+ int code = bps_event_get_code(event);
+ if (code == INTERNAL_EVENT_STOP) {
+ break;
+ } else if (code == INTERNAL_EVENT_CONTACT_EVENTS) {
+ MUTEX_LOCK();
+ bbmsp_event_contact_list_register_event();
+ contactEventsEnabled = true;
}
- MUTEX_UNLOCK();
- } else if (event_domain == m_endEventDomain) {
- break;
}
}
}
@@ -207,10 +273,29 @@ int BBMBPS::GetActiveChannel()
void BBMBPS::SendEndEvent()
{
bps_event_t *end_event = NULL;
- bps_event_create(&end_event, m_endEventDomain, 0, NULL, NULL);
+ bps_event_create(&end_event, m_BBMInternalDomain, INTERNAL_EVENT_STOP, NULL, NULL);
bps_channel_push_event(m_eventChannel, end_event);
}
+void BBMBPS::StartContactEvents()
+{
+ if (!contactEventsEnabled) {
+ bps_event_t *end_event = NULL;
+ bps_event_create(&end_event, m_BBMInternalDomain, INTERNAL_EVENT_CONTACT_EVENTS, NULL, NULL);
+ bps_channel_push_event(m_eventChannel, end_event);
+ }
+}
+
+void BBMBPS::StopContactEvents()
+{
+ contactEventsEnabled = false;
+}
+
+int BBMBPS::GetGid()
+{
+ return static_cast<int>(getgid());
+}
+
void BBMBPS::Register(const std::string& uuid)
{
MUTEX_LOCK();
@@ -222,11 +307,12 @@ std::string BBMBPS::GetProfile(const BBMField field)
{
MUTEX_LOCK();
bbmsp_profile_t *profile;
- bbmsp_profile_create(&profile);
- bbmsp_get_user_profile(profile);
std::string value;
char buffer[4096];
+ bbmsp_profile_create(&profile);
+ bbmsp_get_user_profile(profile);
+
switch (field)
{
case BBM_DISPLAY_NAME:
@@ -238,8 +324,7 @@ std::string BBMBPS::GetProfile(const BBMField field)
}
case BBM_STATUS:
{
- int val;
- val = bbmsp_profile_get_status(profile);
+ int val = bbmsp_profile_get_status(profile);
if (val == 0) {
value = "available";
}
@@ -285,8 +370,7 @@ std::string BBMBPS::GetProfile(const BBMField field)
}
case BBM_SDK_VERSION:
{
- int val;
- val = bbmsp_profile_get_platform_version(profile);
+ int val = bbmsp_profile_get_platform_version(profile);
std::stringstream ss;
ss << val;
value = ss.str();
@@ -369,9 +453,79 @@ void BBMBPS::SetDisplayPicture(const std::string& imgPath)
MUTEX_UNLOCK();
}
-int BBMBPS::GetGid()
+std::string BBMBPS::GetContact(bbmsp_contact_t *contact, BBMField field)
{
- return static_cast<int>(getgid());
+ MUTEX_LOCK();
+ std::string value;
+ unsigned int size;
+ char *buffer;
+
+ switch (field)
+ {
+ case BBM_DISPLAY_NAME:
+ {
+ if (bbmsp_contact_get_display_name(contact, &buffer, &size) == BBMSP_SUCCESS) {
+ value = buffer;
+ }
+ break;
+ }
+ case BBM_STATUS:
+ {
+ bbmsp_presence_status_t status = bbmsp_contact_get_status(contact);
+ if (status == BBMSP_PRESENCE_STATUS_AVAILABLE) {
+ value = "available";
+ }
+ else if (status == BBMSP_PRESENCE_STATUS_BUSY) {
+ value = "busy";
+ }
+ break;
+ }
+ case BBM_STATUS_MESSAGE:
+ {
+ if (bbmsp_contact_get_status_message(contact, &buffer, &size) == BBMSP_SUCCESS) {
+ value = buffer;
+ }
+ break;
+ }
+ case BBM_PERSONAL_MESSAGE:
+ {
+ if (bbmsp_contact_get_personal_message(contact, &buffer, &size) == BBMSP_SUCCESS) {
+ value = buffer;
+ }
+ break;
+ }
+ case BBM_PPID:
+ {
+ if (bbmsp_contact_get_ppid(contact, &buffer, &size) == BBMSP_SUCCESS) {
+ value = buffer;
+ }
+ break;
+ }
+ case BBM_HANDLE:
+ {
+ if (bbmsp_contact_get_handle(contact, &buffer, &size) == BBMSP_SUCCESS) {
+ value = buffer;
+ }
+ break;
+ }
+ case BBM_APP_VERSION:
+ {
+ if (bbmsp_contact_get_app_version(contact, &buffer, &size) == BBMSP_SUCCESS) {
+ value = buffer;
+ }
+ break;
+ }
+ case BBM_SDK_VERSION:
+ {
+ int val = bbmsp_contact_get_platform_version(contact);
+ std::stringstream ss;
+ ss << val;
+ value = ss.str();
+ break;
+ }
+ }
+ MUTEX_UNLOCK();
+ return value;
}
} // namespace webworks
View
18 ext/bbm.platform/native/bbm_bps.hpp
@@ -17,6 +17,7 @@
#ifndef BBM_BPS_H_
#define BBM_BPS_H_
+#include <bbmsp/bbmsp_contactlist.h>
#include <pthread.h>
#include <string>
@@ -35,30 +36,43 @@ enum BBMField {
BBM_SDK_VERSION,
};
+enum BBMInternalEvents {
+ INTERNAL_EVENT_STOP = 0,
+ INTERNAL_EVENT_CONTACT_EVENTS,
+};
+
class BBMBPS {
public:
explicit BBMBPS(BBM *parent = NULL);
~BBMBPS();
void SetActiveChannel(int channel);
+ // Events related functions
int InitializeEvents();
int WaitForEvents();
static void SendEndEvent();
static int GetActiveChannel();
+ void StartContactEvents();
+ void StopContactEvents();
// BBM related functions
void Register(const std::string& uuid);
+ int GetGid();
std::string GetProfile(BBMField field);
void GetDisplayPicture();
void SetStatus(int status, const std::string& personalMessage);
void SetPersonalMessage(const std::string& personalMessage);
void SetDisplayPicture(const std::string& imgPath);
- int GetGid();
+ std::string GetContact(bbmsp_contact_t *contact, BBMField field);
private:
BBM *m_pParent;
void processAccessCode(int code);
+ void processContactUpdate(bbmsp_event_t *event);
+ std::string getFullContact(bbmsp_contact_t *contact);
+ static bool contactEventsEnabled;
static pthread_mutex_t m_lock;
static int m_eventChannel;
- static int m_endEventDomain;
+ static int m_BBMInternalDomain;
+ static bbmsp_contact_list_t *m_pContactList;
};
} // namespace webworks
View
27 ext/bbm.platform/native/bbm_js.cpp
@@ -76,6 +76,16 @@ std::string BBM::InvokeMethod(const std::string& command)
StartEvents();
} else if (strCommand == "stopEvents") {
StopEvents();
+ } else if (strCommand == "startContactEvents") {
+ StartEvents();
+ m_pBBMController->StartContactEvents();
+ } else if (strCommand == "stopContactEvents") {
+ m_pBBMController->StopContactEvents();
+ } else if (strCommand == "getgid") {
+ int gid = m_pBBMController->GetGid();
+ std::stringstream ss;
+ ss << gid;
+ return ss.str();
} else if (strCommand == "register") {
// parse the JSON
bool parse = reader.parse(strParam, obj);
@@ -88,14 +98,13 @@ std::string BBM::InvokeMethod(const std::string& command)
const std::string uuid = obj["uuid"].asString();
m_pBBMController->Register(uuid);
- } else if (strCommand == "getProfile") {
+ } else if (strCommand == "self.getProfile") {
webworks::BBMField field = static_cast<webworks::BBMField>(atoi(strParam.c_str()));
-
return m_pBBMController->GetProfile(field);
- } else if (strCommand == "getDisplayPicture") {
+ } else if (strCommand == "self.getDisplayPicture") {
m_pBBMController->GetDisplayPicture();
return "";
- } else if (strCommand == "setStatus") {
+ } else if (strCommand == "self.setStatus") {
bool parse = reader.parse(strParam, obj);
if (!parse) {
@@ -114,17 +123,11 @@ std::string BBM::InvokeMethod(const std::string& command)
}
m_pBBMController->SetStatus(status, strStatusMessage);
- } else if (strCommand == "setPersonalMessage") {
+ } else if (strCommand == "self.setPersonalMessage") {
m_pBBMController->SetPersonalMessage(strParam);
- } else if (strCommand == "setDisplayPicture") {
+ } else if (strCommand == "self.setDisplayPicture") {
m_pBBMController->SetDisplayPicture(strParam);
- } else if (strCommand == "getgid") {
- int gid = m_pBBMController->GetGid();
- std::stringstream ss;
- ss << gid;
- return ss.str();
}
-
return "";
}
View
24 test/functional/manual/blackberry.bbm.platform.js
@@ -112,3 +112,27 @@ describe("blackberry.bbm.platform.users", function () {
});
});
+
+describe("blackberry.bbm.platform.users", function () {
+ describe("onupdate", function () {
+ var onUpdate,
+ waitForTimeout = 30000;
+
+ it("can receive updates from other users", function () {
+ runs(function () {
+ onUpdate = jasmine.createSpy();
+ blackberry.event.addEventListener("onupdate", onUpdate);
+ alert("Update the contact on the other device to continue");
+ });
+
+ waitsFor(function () {
+ return onUpdate.callCount;
+ }, "event never fired", waitForTimeout);
+
+ runs(function () {
+ expect(onUpdate.toBeCalled());
+ });
+ });
+ });
+});
+
View
39 test/unit/ext/bbm.platform/BBMEvents.js
@@ -39,19 +39,40 @@ describe("bbm.platform BBMEvents", function () {
expect(JNEXT.createObject).toHaveBeenCalledWith("bbm.BBM");
});
- describe("addEventListener", function () {
- var trigger = function () {};
+ describe("onaccesschanged event", function () {
+ describe("addEventListener", function () {
+ var trigger = function () {};
- it("invokes JNEXT startEvents for 'onaccesschanged' event", function () {
- BBMEvents.addEventListener("onaccesschanged", trigger);
- expect(JNEXT.invoke).toHaveBeenCalledWith(jasmine.any(String), "startEvents");
+ it("invokes JNEXT startEvents for 'onaccesschanged' event", function () {
+ BBMEvents.addEventListener("onaccesschanged", trigger);
+ expect(JNEXT.invoke).toHaveBeenCalledWith(jasmine.any(String), "startEvents");
+ });
+ });
+
+ describe("removeEventListener", function () {
+ it("invokes JNEXT stopEvents for 'onaccesschanged' event", function () {
+ BBMEvents.removeEventListener("onaccesschanged");
+ expect(JNEXT.invoke).toHaveBeenCalledWith(jasmine.any(String), "stopEvents");
+ });
});
});
- describe("removeEventListener", function () {
- it("invokes JNEXT stopEvents for 'onaccesschanged' event", function () {
- BBMEvents.removeEventListener("onaccesschanged");
- expect(JNEXT.invoke).toHaveBeenCalledWith(jasmine.any(String), "stopEvents");
+ describe("onupdate event", function () {
+ describe("addEventListener", function () {
+ var trigger = function () {};
+
+ it("invokes JNEXT startContactEvents for 'onupdate' event", function () {
+ BBMEvents.addEventListener("onupdate", trigger);
+ expect(JNEXT.invoke).toHaveBeenCalledWith(jasmine.any(String), "startContactEvents");
+ });
+ });
+
+ describe("removeEventListener", function () {
+ it("invokes JNEXT stopContactEvents for 'onupdate' event", function () {
+ BBMEvents.removeEventListener("onupdate");
+ expect(JNEXT.invoke).toHaveBeenCalledWith(jasmine.any(String), "stopContactEvents");
+ });
});
});
});
+
View
24 test/unit/ext/bbm.platform/index.js
@@ -83,7 +83,7 @@ describe("bbm.platform index", function () {
index.self.appVersion(success, null, null, null);
- expect(JNEXT.invoke).toHaveBeenCalledWith(jasmine.any(String), "getProfile " + BBM_APP_VERSION);
+ expect(JNEXT.invoke).toHaveBeenCalledWith(jasmine.any(String), "self.getProfile " + BBM_APP_VERSION);
expect(success).toHaveBeenCalled();
});
@@ -92,7 +92,7 @@ describe("bbm.platform index", function () {
index.self.bbmsdkVersion(success, null, null, null);
- expect(JNEXT.invoke).toHaveBeenCalledWith(jasmine.any(String), "getProfile " + BBM_SDK_VERSION);
+ expect(JNEXT.invoke).toHaveBeenCalledWith(jasmine.any(String), "self.getProfile " + BBM_SDK_VERSION);
expect(success).toHaveBeenCalled();
});
@@ -101,7 +101,7 @@ describe("bbm.platform index", function () {
index.self.displayName(success, null, null, null);
- expect(JNEXT.invoke).toHaveBeenCalledWith(jasmine.any(String), "getProfile " + BBM_DISPLAY_NAME);
+ expect(JNEXT.invoke).toHaveBeenCalledWith(jasmine.any(String), "self.getProfile " + BBM_DISPLAY_NAME);
expect(success).toHaveBeenCalled();
});
@@ -110,7 +110,7 @@ describe("bbm.platform index", function () {
index.self.handle(success, null, null, null);
- expect(JNEXT.invoke).toHaveBeenCalledWith(jasmine.any(String), "getProfile " + BBM_HANDLE);
+ expect(JNEXT.invoke).toHaveBeenCalledWith(jasmine.any(String), "self.getProfile " + BBM_HANDLE);
expect(success).toHaveBeenCalled();
});
@@ -119,7 +119,7 @@ describe("bbm.platform index", function () {
index.self.personalMessage(success, null, null, null);
- expect(JNEXT.invoke).toHaveBeenCalledWith(jasmine.any(String), "getProfile " + BBM_PERSONAL_MESSAGE);
+ expect(JNEXT.invoke).toHaveBeenCalledWith(jasmine.any(String), "self.getProfile " + BBM_PERSONAL_MESSAGE);
expect(success).toHaveBeenCalled();
});
@@ -128,7 +128,7 @@ describe("bbm.platform index", function () {
index.self.ppid(success, null, null, null);
- expect(JNEXT.invoke).toHaveBeenCalledWith(jasmine.any(String), "getProfile " + BBM_PPID);
+ expect(JNEXT.invoke).toHaveBeenCalledWith(jasmine.any(String), "self.getProfile " + BBM_PPID);
expect(success).toHaveBeenCalled();
});
@@ -137,7 +137,7 @@ describe("bbm.platform index", function () {
index.self.status(success, null, null, null);
- expect(JNEXT.invoke).toHaveBeenCalledWith(jasmine.any(String), "getProfile " + BBM_STATUS);
+ expect(JNEXT.invoke).toHaveBeenCalledWith(jasmine.any(String), "self.getProfile " + BBM_STATUS);
expect(success).toHaveBeenCalled();
});
@@ -146,7 +146,7 @@ describe("bbm.platform index", function () {
index.self.statusMessage(success, null, null, null);
- expect(JNEXT.invoke).toHaveBeenCalledWith(jasmine.any(String), "getProfile " + BBM_STATUS_MESSAGE);
+ expect(JNEXT.invoke).toHaveBeenCalledWith(jasmine.any(String), "self.getProfile " + BBM_STATUS_MESSAGE);
expect(success).toHaveBeenCalled();
});
});
@@ -162,7 +162,7 @@ describe("bbm.platform index", function () {
index.self.getDisplayPicture(success, null, args, null);
- expect(JNEXT.invoke).toHaveBeenCalledWith(jasmine.any(String), "getDisplayPicture");
+ expect(JNEXT.invoke).toHaveBeenCalledWith(jasmine.any(String), "self.getDisplayPicture");
expect(success).toHaveBeenCalled();
});
@@ -181,7 +181,7 @@ describe("bbm.platform index", function () {
index.self.setStatus(success, null, args, null);
- expect(JNEXT.invoke).toHaveBeenCalledWith(jasmine.any(String), "setStatus " + JSON.stringify(args));
+ expect(JNEXT.invoke).toHaveBeenCalledWith(jasmine.any(String), "self.setStatus " + JSON.stringify(args));
expect(success).toHaveBeenCalled();
});
});
@@ -197,7 +197,7 @@ describe("bbm.platform index", function () {
index.self.setPersonalMessage(success, null, args, null);
- expect(JNEXT.invoke).toHaveBeenCalledWith(jasmine.any(String), "setPersonalMessage " + personalMessage);
+ expect(JNEXT.invoke).toHaveBeenCalledWith(jasmine.any(String), "self.setPersonalMessage " + personalMessage);
expect(success).toHaveBeenCalled();
});
});
@@ -213,7 +213,7 @@ describe("bbm.platform index", function () {
index.self.setDisplayPicture(success, null, args, null);
- expect(JNEXT.invoke).toHaveBeenCalledWith(jasmine.any(String), "setDisplayPicture " + displayPicture);
+ expect(JNEXT.invoke).toHaveBeenCalledWith(jasmine.any(String), "self.setDisplayPicture " + displayPicture);
expect(success).toHaveBeenCalled();
});
});
Something went wrong with that request. Please try again.