Permalink
Browse files

RhoConnect-client-Java: ObjectNotify callback implementation.

  • Loading branch information...
1 parent 58ec2e3 commit 43fb6d3cd202c0567664d32c0cbbcf3108afff17 @lexis-t lexis-t committed Jul 31, 2011
Showing with 431 additions and 150 deletions.
  1. +0 −1 .gitignore
  2. BIN rhoconnect-client/Java/Android/test/libs/armeabi/librhoconnectclient.so
  3. BIN rhoconnect-client/Java/Android/test/rhoimpl.jar
  4. +44 −3 ...nnect-client/Java/Android/test/src/com/rhomobile/rhoconnect_client_test/TestRhoConnectClient.java
  5. +2 −82 rhoconnect-client/Java/RhoConnect/jni/include/RhoConnectJniNotify.h
  6. +47 −15 rhoconnect-client/Java/RhoConnect/jni/include/com_rhomobile_rhoconnect_RhoConnectClient.h
  7. +13 −0 rhoconnect-client/Java/RhoConnect/jni/include/com_rhomobile_rhoconnect_RhoConnectObjectNotify.h
  8. +13 −0 ...ct-client/Java/RhoConnect/jni/include/com_rhomobile_rhoconnect_RhoConnectObjectNotify_IDelegate.h
  9. +1 −1 rhoconnect-client/Java/RhoConnect/jni/include/com_rhomobile_rhoconnect_RhomModel.h
  10. +1 −0 rhoconnect-client/Java/RhoConnect/jni/include/rhojava.inc
  11. +127 −28 rhoconnect-client/Java/RhoConnect/jni/src/RhoConnectJniClient.cpp
  12. +9 −1 rhoconnect-client/Java/RhoConnect/jni/src/RhoConnectJniModel.cpp
  13. +145 −5 rhoconnect-client/Java/RhoConnect/jni/src/RhoConnectJniNotify.cpp
  14. +8 −2 rhoconnect-client/Java/RhoConnect/src/com/rhomobile/rhoconnect/RhoConnectClient.java
  15. +2 −11 rhoconnect-client/Java/RhoConnect/src/com/rhomobile/rhoconnect/RhoConnectNotify.java
  16. +19 −1 rhoconnect-client/Java/RhoConnect/src/com/rhomobile/rhoconnect/RhoConnectObjectNotify.java
  17. BIN rhoconnect-client/Samples/Java/android_store/libs/armeabi/librhoconnectclient.so
  18. BIN rhoconnect-client/Samples/Java/android_store/rhoimpl.jar
View
@@ -52,7 +52,6 @@ rhoconnect-client/build/*
rhoconnect-client/Samples/ObjectiveC/store/build/*
rhoconnect-client/C++/Tests/Win32/bin/*
rhoconnect-client/Java/Android/.metadata/*
-rhoconnect-client/Java/Android/test/*
spec/bin/*
spec/**/bin/*
Binary file not shown.
@@ -9,16 +9,27 @@
import com.rhomobile.rhodes.RhoLogConf;
import com.rhomobile.rhodes.file.RhoFileApi;
import com.rhomobile.rhoconnect.RhoConnectClient;
+import com.rhomobile.rhoconnect.RhoConnectObjectNotify;
import com.rhomobile.rhoconnect.RhomModel;
import com.rhomobile.rhoconnect.RhoConnectNotify;
public class TestRhoConnectClient extends AndroidTestCase {
private static final String TAG = TestRhoConnectClient.class.getSimpleName();
private final String SYNC_URL = "http://rhodes-store-server.heroku.com/application";
+
+ class ObjectNotifyDelegate implements RhoConnectObjectNotify.IDelegate
+ {
+ RhoConnectObjectNotify mNotify;
+ @Override
+ public void call(RhoConnectObjectNotify notify) {
+ mNotify = notify;
+ }
+ }
RhoConnectClient mClient;
RhomModel mModels[];
+ RhomModel mProduct;
@Override
protected void setUp()
@@ -45,6 +56,7 @@ protected void setUp()
new RhomModel("Customer", RhomModel.SYNC_TYPE_INCREMENTAL),
new RhomModel("Product", RhomModel.SYNC_TYPE_INCREMENTAL)
};
+ mProduct = mModels[2];
mClient.initialize(mModels);
mClient.setThreadedMode(false);
@@ -74,7 +86,7 @@ public void testLogin()
public void testSyncProductByName()
{
testLogin();
- RhoConnectNotify notify = mModels[2].sync();
+ RhoConnectNotify notify = mProduct.sync();
assertEquals(notify.getErrorCode(), 0);
}
@@ -90,7 +102,7 @@ public void testCreateNewProduct()
Map<String, String> item = new HashMap<String, String>();
item.put("name", "AndroidTest");
- mModels[2].create(item);
+ mProduct.create(item);
assertTrue(item.containsKey("object"));
assertTrue(item.containsKey("source_id"));
@@ -99,8 +111,37 @@ public void testCreateNewProduct()
assertTrue(item2 != null);
assertEquals(item.get("name"), item2.get("name"));
- //testSyncProductByName();
+ }
+
+ public void testCreateObjectNotify()
+ {
+ Map<String, String> item = new HashMap<String, String>();
+ item.put("name", "AndroidTest2");
+
+ mProduct.create(item);
+
+ assertTrue(item.containsKey("object"));
+ assertTrue(item.containsKey("source_id"));
+
+ Map<String, String> item2 = mModels[2].find(item.get("object"));
+ assertNotNull(item2);
+ assertEquals(item.get("name"), item2.get("name"));
+
+ ObjectNotifyDelegate objectCallback = new ObjectNotifyDelegate();
+ mClient.setObjectNotification(objectCallback);
+ mClient.addObjectNotify(Integer.parseInt(item.get("source_id")), item.get("object"));
+
+ testSyncProductByName();
+
+ assertNotNull(objectCallback.mNotify);
+
+ String[] createdObjects = objectCallback.mNotify.getCreatedObjects();
+ assertNotNull(createdObjects);
+
+ int[] createdSourceIds = objectCallback.mNotify.getCreatedSourceIds();
+ assertNotNull(createdSourceIds);
+ assertEquals(createdObjects[0], item.get("object"));
}
}
@@ -5,88 +5,8 @@
namespace rho { namespace connect_jni {
-//template <class Ret, class P>
-//class Bind1
-//{
-//public:
-// typedef P param_t;
-// typedef Ret return_t;
-// typedef return_t (*callback_t)(param_t);
-//private:
-// callback_t m_callback;
-// param_t m_param;
-//public:
-// Bind1(callback_t fn, param_t param) : m_callback(fn), m_param(param) {}
-// return_t operator()() { return m_callback(m_param); }
-//};
-//
-//template <class Ret, class P0, class P1>
-//class Bind2
-//{
-//public:
-// typedef P0 param0_t;
-// typedef P1 param1_t;
-// typedef Ret return_t;
-// typedef return_t (*callback_t)(param0_t, param1_t);
-//private:
-// callback_t m_callback;
-// param0_t m_param0;
-// param1_t m_param1;
-//public:
-// Bind2(callback_t fn, param0_t param0, param1_t param1) : m_callback(fn), m_param0(param0), m_param1(param1) {}
-// return_t operator()() { return m_callback(m_param0, m_param1); }
-//};
-//
-//template <class Ret, class P0, class P1, class P2>
-//class Bind3
-//{
-//public:
-// typedef P0 param0_t;
-// typedef P1 param1_t;
-// typedef P2 param2_t;
-// typedef Ret return_t;
-// typedef return_t (*callback_t)(param0_t, param1_t, param2_t);
-//private:
-// callback_t m_callback;
-// param0_t m_param0;
-// param1_t m_param1;
-// param2_t m_param2;
-//public:
-// Bind3(callback_t fn, param0_t param0, param1_t param1, param2_t param2)
-// : m_callback(fn), m_param0(param0), m_param1(param1), m_param2(param2) {}
-// return_t operator()() { return m_callback(m_param0, m_param1, m_param2); }
-//};
-//
-//template <class Ret, class P>
-//Bind1<Ret, P> make_bind(typename Bind1<Ret, P>::callback_t fn, typename Bind1<Ret, P>::param_t param)
-//{
-// return Bind1<Ret, P>(fn, param);
-//}
-//
-//template <class Ret, class P0, class P1>
-//Bind2<Ret, P0, P1> make_bind(typename Bind2<Ret, P0, P1>::callback_t fn,
-// typename Bind2<Ret, P0, P1>::param0_t param0,
-// typename Bind2<Ret, P0, P1>::param1_t param1)
-//{
-// return Bind2<Ret, P0, P1>(fn, param0, param1);
-//}
-//
-//template <class Ret, class P0, class P1, class P2>
-//Bind3<Ret, P0, P1, P2> make_bind(typename Bind3<Ret, P0, P1, P2>::callback_t fn,
-// typename Bind3<Ret, P0, P1, P2>::param0_t param0,
-// typename Bind3<Ret, P0, P1, P2>::param1_t param1,
-// typename Bind3<Ret, P0, P1, P2>::param2_t param2)
-//{
-// return Bind3<Ret, P0, P1, P2>(fn, param0, param1, param2);
-//}
-
-jhobject rhoconnect_jni_parsenotify(JNIEnv * env, const char* res);
-
-//template <class functor>
-//jhobject rhoconnect_call(JNIEnv * env, functor fn)
-//{
-// return rhoconnect_jni_parsenotify(env, reinterpret_cast<char*>(fn()));
-//}
+jobject rhoconnect_jni_parsenotify(JNIEnv * env, const char* res);
+jobject rhoconnect_jni_parseobjectnotify(JNIEnv * env, const char* res);
}}

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -23,3 +23,4 @@ RHODES_DEFINE_JAVA_CLASS(RHOCONNECT_JAVA_CLASS_RHOMMODEL, "com/rhomobile/rhoconn
RHODES_DEFINE_JAVA_CLASS(RHOCONNECT_JAVA_CLASS_NOTIFY, "com/rhomobile/rhoconnect/RhoConnectNotify")
RHODES_DEFINE_JAVA_CLASS(RHOCONNECT_JAVA_CLASS_NOTIFY_DELEGATE, "com/rhomobile/rhoconnect/RhoConnectNotify$IDelegate")
RHODES_DEFINE_JAVA_CLASS(RHOCONNECT_JAVA_CLASS_OBJECTNOTIFY, "com/rhomobile/rhoconnect/RhoConnectObjectNotify")
+RHODES_DEFINE_JAVA_CLASS(RHOCONNECT_JAVA_CLASS_OBJECTNOTIFY_DELEGATE, "com/rhomobile/rhoconnect/RhoConnectObjectNotify$IDelegate")
Oops, something went wrong.

0 comments on commit 43fb6d3

Please sign in to comment.