NativeTestCase.h

00001 /*
00002  * @(#)NativeTestCase.h  0.2.0 / 2007-12-31
00003  *
00004  * Copyright (c) 2007, ETF and contributors. All rights reserved.
00005  *
00006  * This software is licensed under the LGPL, version 2.1, license.
00007  * A copy of the license is included in the file LICENSE-LGPL.txt.
00008  */
00009 #ifndef NATIVETESTCASE_H
00010 #define NATIVETESTCASE_H
00011 
00012 #ifdef JAVAQX_TEST
00013 
00014 #include "JavaQxCore.h"
00015 
00016 /*^**************************************************************************^*/
00017 /*- NativeTestCase Class.                                                    -*/
00018 /*^**************************************************************************^*/
00019 
00026 class JAVAQX_EXPORT NativeTestCase : public QObject
00027 {
00028   Q_OBJECT
00029 public:
00030   NativeTestCase(JNIEnv *env, jobject obj);
00031   virtual ~NativeTestCase();
00032 public:
00033   static void initialize(JNIEnv *env, jclass cls);
00034   static jlong testObject(JNIEnv *env, jobject obj);
00035 protected:
00036   void failCondition(const char *condition = 0, const char *fileName = 0,
00037                      int lineNumber = -1);
00038 protected:
00039   inline JNIEnv *env() const;
00040   inline jweak obj() const;
00041 private:
00042   JNIEnv *m_env;
00043   jweak m_obj;
00044 private:
00045   static jfieldID sm_testObjectFID;
00046   static jmethodID sm_failConditionMID;
00047 };
00048 
00049 /*^**************************************************************************^*/
00050 /*- NativeTestCase :: Public Inline Member Functions.                        -*/
00051 /*^**************************************************************************^*/
00052 
00058 inline JNIEnv *NativeTestCase::env() const
00059 {
00060   return m_env;
00061 }
00062 
00068 inline jweak NativeTestCase::obj() const
00069 {
00070   return m_obj;
00071 }
00072 
00073 /*^**************************************************************************^*/
00074 /*- Macro Definition.                                                        -*/
00075 /*^**************************************************************************^*/
00076 
00077 #define nativeTestCase (reinterpret_cast<NativeTestCase *>(testObject))
00078 
00079 #endif // JAVAQX_TEST
00080 
00081 #endif // NATIVETESTCASE_H
00082 
00083 /*^*****************************************************************************
00084   File History:
00085 
00086  - 2007-12-31 11:15:54 Slobodan
00087    Initial version
00088 
00089 *****************************************************************************^*/

Copyright © 2007 ETF and contributors. All Rights Reserved.