00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef NATIVETEST_H
00010 #define NATIVETEST_H
00011
00012 #ifdef JAVAQX_TEST
00013
00014 #include "JavaQxCore.h"
00015
00016
00017
00018
00019
00026 class JAVAQX_EXPORT NativeTest : public QObject
00027 {
00028 Q_OBJECT
00029 public:
00030 jobjectArray getTestMethods(JNIEnv *env);
00031 void setUp(JNIEnv *env);
00032 void tearDown(JNIEnv *env);
00033 bool invokeMethod(JNIEnv *env, jobject obj, jstring methodName);
00034 public:
00035 static void initialize(JNIEnv *env, jclass cls);
00036 protected:
00037 virtual void setUp();
00038 virtual void tearDown();
00039 protected:
00040 jobject createJObject(const char *className);
00041 jobject createJObject(const char *className, const char *ctorSig, ...);
00042 void *nativeObjectPointer(jobject obj);
00043 void *nativeObjectPointer(jobject obj, const char *fieldName);
00044 template<typename T> T nativePointer(jobject obj) {
00045 return reinterpret_cast<T>(nativeObjectPointer(obj));
00046 }
00047 template<typename T> T nativePointer(jobject obj, const char *fieldName) {
00048 return reinterpret_cast<T>(nativeObjectPointer(obj, fieldName));
00049 }
00050 void failCondition(const char *condition = 0, const char *fileName = 0,
00051 int lineNumber = -1);
00052 protected:
00053 inline JNIEnv *env() const;
00054 private:
00055 JNIEnv *m_env;
00056 jweak m_obj;
00057 private:
00058 static jmethodID sm_failConditionMID;
00059 };
00060
00061
00062
00063
00064
00070 inline JNIEnv *NativeTest::env() const
00071 {
00072 return m_env;
00073 }
00074
00075
00076
00077
00078
00079 #define nativeTest (reinterpret_cast<NativeTest *>(testCase))
00080
00081 #endif // JAVAQX_TEST
00082
00083 #endif // NATIVETEST_H
00084
00085
00086
00087
00088
00089
00090
00091