fix qmltest bugs
[profile/ivi/qtdeclarative.git] / src / imports / testlib / main.cpp
index 0f27102..5781b3d 100644 (file)
@@ -79,6 +79,48 @@ public:
     }
 
 public Q_SLOTS:
+
+    QDeclarativeV8Handle typeName(const QVariant& v) const
+    {
+        QString name(v.typeName());
+        //qDebug() << "type:" << name  << " string value:" << v.toString() << " value:" << v;
+        if (v.canConvert<QObject*>()) {
+            QDeclarativeType *type = 0;
+            const QMetaObject *mo = v.value<QObject*>()->metaObject();
+            while (!type && mo) {
+                type = QDeclarativeMetaType::qmlType(mo);
+                mo = mo->superClass();
+            }
+            if (type) {
+                name = type->qmlTypeName();
+            }
+        }
+
+        return QDeclarativeV8Handle::fromHandle(v8::String::New(name.toUtf8()));
+    }
+
+    bool compare(const QVariant& act, const QVariant& exp) const {
+        return act == exp;
+    }
+//    QDeclarativeV8Handle toString(const QVariant& v) const
+//    {
+//        QString name(v.typeName());
+
+//        if (v.canConvert<QObject*>()) {
+//            QDeclarativeType *type = 0;
+//            const QMetaObject *mo = v.value<QObject*>()->metaObject();
+//            while (!type && mo) {
+//                type = QDeclarativeMetaType::qmlType(mo);
+//                mo = mo->superClass();
+//            }
+//            if (type) {
+//                name = type->qmlTypeName();
+//            }
+//        }
+
+//        return QDeclarativeV8Handle::fromHandle(v8::String::New(name.toUtf8()));
+//    }
+
     QDeclarativeV8Handle callerFile(int frameIndex = 0) const
     {
         v8::HandleScope scope;