tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
changeset 37 758a864f9613
parent 33 3e2da88830cd
equal deleted inserted replaced
36:ef0373b55136 37:758a864f9613
   116     void dynamicObjects();
   116     void dynamicObjects();
   117     void customVariantTypes();
   117     void customVariantTypes();
   118     void valueTypes();
   118     void valueTypes();
   119     void cppnamespace();
   119     void cppnamespace();
   120     void aliasProperties();
   120     void aliasProperties();
       
   121     void aliasPropertiesAndSignals();
   121     void componentCompositeType();
   122     void componentCompositeType();
   122     void i18n();
   123     void i18n();
   123     void i18n_data();
   124     void i18n_data();
   124     void onCompleted();
   125     void onCompleted();
   125     void onDestruction();
   126     void onDestruction();
   126     void scriptString();
   127     void scriptString();
   127     void defaultPropertyListOrder();
   128     void defaultPropertyListOrder();
   128     void declaredPropertyValues();
   129     void declaredPropertyValues();
       
   130     void dontDoubleCallClassBegin();
   129 
   131 
   130     void basicRemote_data();
   132     void basicRemote_data();
   131     void basicRemote();
   133     void basicRemote();
   132     void importsBuiltin_data();
   134     void importsBuiltin_data();
   133     void importsBuiltin();
   135     void importsBuiltin();
   139     void importsInstalled();
   141     void importsInstalled();
   140     void importsOrder_data();
   142     void importsOrder_data();
   141     void importsOrder();
   143     void importsOrder();
   142 
   144 
   143     void qmlAttachedPropertiesObjectMethod();
   145     void qmlAttachedPropertiesObjectMethod();
   144 
       
   145     void customOnProperty();
   146     void customOnProperty();
       
   147     void variantNotify();
   146 
   148 
   147     // regression tests for crashes
   149     // regression tests for crashes
   148     void crash1();
   150     void crash1();
   149     void crash2();
   151     void crash2();
   150 
   152 
   340     QTest::newRow("invalidAlias.2") << "invalidAlias.2.qml" << "invalidAlias.2.errors.txt" << false;
   342     QTest::newRow("invalidAlias.2") << "invalidAlias.2.qml" << "invalidAlias.2.errors.txt" << false;
   341     QTest::newRow("invalidAlias.3") << "invalidAlias.3.qml" << "invalidAlias.3.errors.txt" << false;
   343     QTest::newRow("invalidAlias.3") << "invalidAlias.3.qml" << "invalidAlias.3.errors.txt" << false;
   342     QTest::newRow("invalidAlias.4") << "invalidAlias.4.qml" << "invalidAlias.4.errors.txt" << false;
   344     QTest::newRow("invalidAlias.4") << "invalidAlias.4.qml" << "invalidAlias.4.errors.txt" << false;
   343     QTest::newRow("invalidAlias.5") << "invalidAlias.5.qml" << "invalidAlias.5.errors.txt" << false;
   345     QTest::newRow("invalidAlias.5") << "invalidAlias.5.qml" << "invalidAlias.5.errors.txt" << false;
   344     QTest::newRow("invalidAlias.6") << "invalidAlias.6.qml" << "invalidAlias.6.errors.txt" << false;
   346     QTest::newRow("invalidAlias.6") << "invalidAlias.6.qml" << "invalidAlias.6.errors.txt" << false;
       
   347     QTest::newRow("invalidAlias.7") << "invalidAlias.7.qml" << "invalidAlias.7.errors.txt" << false;
   345 
   348 
   346     QTest::newRow("invalidAttachedProperty.1") << "invalidAttachedProperty.1.qml" << "invalidAttachedProperty.1.errors.txt" << false;
   349     QTest::newRow("invalidAttachedProperty.1") << "invalidAttachedProperty.1.qml" << "invalidAttachedProperty.1.errors.txt" << false;
   347     QTest::newRow("invalidAttachedProperty.2") << "invalidAttachedProperty.2.qml" << "invalidAttachedProperty.2.errors.txt" << false;
   350     QTest::newRow("invalidAttachedProperty.2") << "invalidAttachedProperty.2.qml" << "invalidAttachedProperty.2.errors.txt" << false;
   348     QTest::newRow("invalidAttachedProperty.3") << "invalidAttachedProperty.3.qml" << "invalidAttachedProperty.3.errors.txt" << false;
   351     QTest::newRow("invalidAttachedProperty.3") << "invalidAttachedProperty.3.qml" << "invalidAttachedProperty.3.errors.txt" << false;
   349     QTest::newRow("invalidAttachedProperty.4") << "invalidAttachedProperty.4.qml" << "invalidAttachedProperty.4.errors.txt" << false;
   352     QTest::newRow("invalidAttachedProperty.4") << "invalidAttachedProperty.4.qml" << "invalidAttachedProperty.4.errors.txt" << false;
   370     QTest::newRow("noCreation") << "noCreation.qml" << "noCreation.errors.txt" << false;
   373     QTest::newRow("noCreation") << "noCreation.qml" << "noCreation.errors.txt" << false;
   371     QTest::newRow("destroyedSignal") << "destroyedSignal.qml" << "destroyedSignal.errors.txt" << false;
   374     QTest::newRow("destroyedSignal") << "destroyedSignal.qml" << "destroyedSignal.errors.txt" << false;
   372     QTest::newRow("assignToNamespace") << "assignToNamespace.qml" << "assignToNamespace.errors.txt" << false;
   375     QTest::newRow("assignToNamespace") << "assignToNamespace.qml" << "assignToNamespace.errors.txt" << false;
   373     QTest::newRow("invalidOn") << "invalidOn.qml" << "invalidOn.errors.txt" << false;
   376     QTest::newRow("invalidOn") << "invalidOn.qml" << "invalidOn.errors.txt" << false;
   374     QTest::newRow("invalidProperty") << "invalidProperty.qml" << "invalidProperty.errors.txt" << false;
   377     QTest::newRow("invalidProperty") << "invalidProperty.qml" << "invalidProperty.errors.txt" << false;
       
   378     QTest::newRow("nonScriptableProperty") << "nonScriptableProperty.qml" << "nonScriptableProperty.errors.txt" << false;
   375 }
   379 }
   376 
   380 
   377 
   381 
   378 void tst_qdeclarativelanguage::errors()
   382 void tst_qdeclarativelanguage::errors()
   379 {
   383 {
  1046 
  1050 
  1047         delete object;
  1051         delete object;
  1048     }
  1052     }
  1049 }
  1053 }
  1050 
  1054 
       
  1055 // QTBUG-13374 Test that alias properties and signals can coexist
       
  1056 void tst_qdeclarativelanguage::aliasPropertiesAndSignals()
       
  1057 {
       
  1058     QDeclarativeComponent component(&engine, TEST_FILE("aliasPropertiesAndSignals.qml"));
       
  1059     VERIFY_ERRORS(0);
       
  1060     QObject *o = component.create();
       
  1061     QVERIFY(o);
       
  1062     QCOMPARE(o->property("test").toBool(), true);
       
  1063     delete o;
       
  1064 }
       
  1065 
  1051 // Test that the root element in a composite type can be a Component
  1066 // Test that the root element in a composite type can be a Component
  1052 void tst_qdeclarativelanguage::componentCompositeType()
  1067 void tst_qdeclarativelanguage::componentCompositeType()
  1053 {
  1068 {
  1054     QDeclarativeComponent component(&engine, TEST_FILE("componentCompositeType.qml"));
  1069     QDeclarativeComponent component(&engine, TEST_FILE("componentCompositeType.qml"));
  1055     VERIFY_ERRORS(0);
  1070     VERIFY_ERRORS(0);
  1188 
  1203 
  1189 void tst_qdeclarativelanguage::declaredPropertyValues()
  1204 void tst_qdeclarativelanguage::declaredPropertyValues()
  1190 {
  1205 {
  1191     QDeclarativeComponent component(&engine, TEST_FILE("declaredPropertyValues.qml"));
  1206     QDeclarativeComponent component(&engine, TEST_FILE("declaredPropertyValues.qml"));
  1192     VERIFY_ERRORS(0);
  1207     VERIFY_ERRORS(0);
       
  1208 }
       
  1209 
       
  1210 void tst_qdeclarativelanguage::dontDoubleCallClassBegin()
       
  1211 {
       
  1212     QDeclarativeComponent component(&engine, TEST_FILE("dontDoubleCallClassBegin.qml"));
       
  1213     QObject *o = component.create();
       
  1214     QVERIFY(o);
       
  1215 
       
  1216     MyParserStatus *o2 = qobject_cast<MyParserStatus *>(qvariant_cast<QObject *>(o->property("object")));
       
  1217     QVERIFY(o2);
       
  1218     QCOMPARE(o2->classBeginCount(), 1);
       
  1219     QCOMPARE(o2->componentCompleteCount(), 1);
       
  1220 
       
  1221     delete o;
  1193 }
  1222 }
  1194 
  1223 
  1195 // Check that first child of qml is of given type. Empty type insists on error.
  1224 // Check that first child of qml is of given type. Empty type insists on error.
  1196 void tst_qdeclarativelanguage::testType(const QString& qml, const QString& type, const QString& expectederror)
  1225 void tst_qdeclarativelanguage::testType(const QString& qml, const QString& type, const QString& expectederror)
  1197 {
  1226 {
  1666     QCOMPARE(object->property("on").toInt(), 10);
  1695     QCOMPARE(object->property("on").toInt(), 10);
  1667 
  1696 
  1668     delete object;
  1697     delete object;
  1669 }
  1698 }
  1670 
  1699 
       
  1700 // QTBUG-12601
       
  1701 void tst_qdeclarativelanguage::variantNotify()
       
  1702 {
       
  1703     QDeclarativeComponent component(&engine, TEST_FILE("variantNotify.qml"));
       
  1704 
       
  1705     VERIFY_ERRORS(0);
       
  1706     QObject *object = component.create();
       
  1707     QVERIFY(object != 0);
       
  1708 
       
  1709     QCOMPARE(object->property("notifyCount").toInt(), 1);
       
  1710 
       
  1711     delete object;
       
  1712 }
       
  1713 
  1671 void tst_qdeclarativelanguage::initTestCase()
  1714 void tst_qdeclarativelanguage::initTestCase()
  1672 {
  1715 {
  1673     registerTypes();
  1716     registerTypes();
  1674 
  1717 
  1675     qmlRegisterType<TestType>("com.nokia.Test", 0, 0, "TestTP");
  1718     qmlRegisterType<TestType>("com.nokia.Test", 0, 0, "TestTP");