void tst_QAndroidJniObject::getStaticByteField()
{
    QAndroidJniEnvironment env;
    jclass cls = env->FindClass("java/lang/Byte");
    QVERIFY(cls != 0);

    jbyte i = QAndroidJniObject::getStaticField<jbyte>(cls, "MAX_VALUE");
    QCOMPARE(i, jbyte(127));
}
void tst_QAndroidJniObject::callStaticByteMethodClassName()
{
    QString number = QString::number(123);
    QAndroidJniObject parameter = QAndroidJniObject::fromString(number);

    jbyte returnValue = QAndroidJniObject::callStaticMethod<jbyte>("java/lang/Byte",
                                                            "parseByte",
                                                            "(Ljava/lang/String;)B",
                                                            parameter.object<jstring>());
    QCOMPARE(returnValue, jbyte(number.toInt()));
}
void tst_QAndroidJniObject::callStaticByteMethod()
{
    QAndroidJniEnvironment env;
    jclass cls = env->FindClass("java/lang/Byte");
    QVERIFY(cls != 0);

    QString number = QString::number(123);
    QAndroidJniObject parameter = QAndroidJniObject::fromString(number);

    jbyte returnValue = QAndroidJniObject::callStaticMethod<jbyte>(cls,
                                                            "parseByte",
                                                            "(Ljava/lang/String;)B",
                                                            parameter.object<jstring>());
    QCOMPARE(returnValue, jbyte(number.toInt()));
}
Пример #4
0
static jvalue numToJvalue(const T &num)
{
    jvalue value;
    switch (sig) //a good compiler should simplify out the switch
    {
    case 'Z': value.z = jboolean(num); return value;
    case 'C': value.c = jchar(num); return value;
    case 'B': value.b = jbyte(num); return value;
    case 'S': value.s = jshort(num); return value;
    case 'I': value.i = jint(num); return value;
    case 'J': value.j = jlong(num); return value;
    case 'F': value.f = jfloat(num); return value;
    case 'D': value.d = jdouble(num); return value;
    }
    poco_bugcheck_msg(std::string(1, sig).c_str()); throw;
}
void tst_QAndroidJniObject::getStaticByteFieldClassName()
{
    jbyte i = QAndroidJniObject::getStaticField<jbyte>("java/lang/Byte", "MAX_VALUE");
    QCOMPARE(i, jbyte(127));
}
Пример #6
0
static void testProxy0ReturnByte(CuTest* tc) {
    handler = testProxy0ReturnByte_handler;
    jbyte (*f)(jbyte) = (jbyte (*)(jbyte)) _proxy0;
    jbyte result = f(16);
    CuAssertIntEquals(tc, 32, result);
}