tests/auto/qeasingcurve/tst_qeasingcurve.cpp
changeset 30 5dc02b23752f
parent 18 2f34d5167611
equal deleted inserted replaced
29:b72c6db6890b 30:5dc02b23752f
    67     void propertyDefaults();
    67     void propertyDefaults();
    68     void valueForProgress_data();
    68     void valueForProgress_data();
    69     void valueForProgress();
    69     void valueForProgress();
    70     void setCustomType();
    70     void setCustomType();
    71     void operators();
    71     void operators();
       
    72     void properties();
       
    73     void metaTypes();
    72 
    74 
    73 protected:
    75 protected:
    74 };
    76 };
    75 
    77 
    76 tst_QEasingCurve::tst_QEasingCurve()
    78 tst_QEasingCurve::tst_QEasingCurve()
   191     // automatically generated.
   193     // automatically generated.
   192     // note that values are scaled from range [0,1] to range [0, 100] in order to store them as
   194     // note that values are scaled from range [0,1] to range [0, 100] in order to store them as
   193     // integer values and avoid fp inaccuracies
   195     // integer values and avoid fp inaccuracies
   194     QTest::newRow("Linear") << int(QEasingCurve::Linear)
   196     QTest::newRow("Linear") << int(QEasingCurve::Linear)
   195          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   197          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   196          << (RealList() << 0 << 0.1 << 0.2 << 0.3 << 0.4 << 0.5 << 0.6 << 0.7 << 0.8 << 0.9 << 1);
   198          << (RealList() << 0.0000 << 0.1000 << 0.2000 << 0.3000 << 0.4000 << 0.5000 << 0.6000 << 0.7000 << 0.8000 << 0.9000 << 1.0000);
   197 
   199 
   198     QTest::newRow("InQuad") << int(QEasingCurve::InQuad)
   200     QTest::newRow("InQuad") << int(QEasingCurve::InQuad)
   199          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   201          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   200          << (RealList() << 0 << 0.01 << 0.04 << 0.09 << 0.16 << 0.25 << 0.36 << 0.49 << 0.64 << 0.81 << 1);
   202          << (RealList() << 0.0000 << 0.0100 << 0.0400 << 0.0900 << 0.1600 << 0.2500 << 0.3600 << 0.4900 << 0.6400 << 0.8100 << 1.0000);
   201 
   203 
   202     QTest::newRow("OutQuad") << int(QEasingCurve::OutQuad)
   204     QTest::newRow("OutQuad") << int(QEasingCurve::OutQuad)
   203          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   205          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   204          << (RealList() << 0 << 0.19 << 0.36 << 0.51 << 0.64 << 0.75 << 0.84 << 0.91 << 0.96 << 0.99 << 1);
   206          << (RealList() << 0.0000 << 0.1900 << 0.3600 << 0.5100 << 0.6400 << 0.7500 << 0.8400 << 0.9100 << 0.9600 << 0.9900 << 1.0000);
   205 
   207 
   206     QTest::newRow("InOutQuad") << int(QEasingCurve::InOutQuad)
   208     QTest::newRow("InOutQuad") << int(QEasingCurve::InOutQuad)
   207          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   209          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   208          << (RealList() << 0 << 0.02 << 0.08 << 0.18 << 0.32 << 0.5 << 0.68 << 0.82 << 0.92 << 0.98 << 1);
   210          << (RealList() << 0.0000 << 0.0200 << 0.0800 << 0.1800 << 0.3200 << 0.5000 << 0.6800 << 0.8200 << 0.9200 << 0.9800 << 1.0000);
   209 
   211 
   210     QTest::newRow("OutInQuad") << int(QEasingCurve::OutInQuad)
   212     QTest::newRow("OutInQuad") << int(QEasingCurve::OutInQuad)
   211          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   213          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   212          << (RealList() << 0 << 0.18 << 0.32 << 0.42 << 0.48 << 0.5 << 0.52 << 0.58 << 0.68 << 0.82 << 1);
   214          << (RealList() << 0.0000 << 0.1800 << 0.3200 << 0.4200 << 0.4800 << 0.5000 << 0.5200 << 0.5800 << 0.6800 << 0.8200 << 1.0000);
   213 
   215 
   214     QTest::newRow("InCubic") << int(QEasingCurve::InCubic)
   216     QTest::newRow("InCubic") << int(QEasingCurve::InCubic)
   215          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   217          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   216          << (RealList() << 0 << 0.001 << 0.008 << 0.027 << 0.064 << 0.125 << 0.216 << 0.343 << 0.512 << 0.729 << 1);
   218          << (RealList() << 0.0000 << 0.0010 << 0.0080 << 0.0270 << 0.0640 << 0.1250 << 0.2160 << 0.3430 << 0.5120 << 0.7290 << 1.0000);
   217 
   219 
   218     QTest::newRow("OutCubic") << int(QEasingCurve::OutCubic)
   220     QTest::newRow("OutCubic") << int(QEasingCurve::OutCubic)
   219          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   221          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   220          << (RealList() << 0 << 0.271 << 0.488 << 0.657 << 0.784 << 0.875 << 0.936 << 0.973 << 0.992 << 0.999 << 1);
   222          << (RealList() << 0.0000 << 0.2710 << 0.4880 << 0.6570 << 0.7840 << 0.8750 << 0.9360 << 0.9730 << 0.9920 << 0.9990 << 1.0000);
   221 
   223 
   222     QTest::newRow("InOutCubic") << int(QEasingCurve::InOutCubic)
   224     QTest::newRow("InOutCubic") << int(QEasingCurve::InOutCubic)
   223          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   225          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   224          << (RealList() << 0 << 0.004 << 0.032 << 0.108 << 0.256 << 0.5 << 0.744 << 0.892 << 0.968 << 0.996 << 1);
   226          << (RealList() << 0.0000 << 0.0040 << 0.0320 << 0.1080 << 0.2560 << 0.5000 << 0.7440 << 0.8920 << 0.9680 << 0.9960 << 1.0000);
   225 
   227 
   226     QTest::newRow("OutInCubic") << int(QEasingCurve::OutInCubic)
   228     QTest::newRow("OutInCubic") << int(QEasingCurve::OutInCubic)
   227          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   229          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   228          << (RealList() << 0 << 0.244 << 0.392 << 0.468 << 0.496 << 0.5 << 0.504 << 0.532 << 0.608 << 0.756 << 1);
   230          << (RealList() << 0.0000 << 0.2440 << 0.3920 << 0.4680 << 0.4960 << 0.5000 << 0.5040 << 0.5320 << 0.6080 << 0.7560 << 1.0000);
   229 
   231 
   230     QTest::newRow("InQuart") << int(QEasingCurve::InQuart)
   232     QTest::newRow("InQuart") << int(QEasingCurve::InQuart)
   231          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   233          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   232          << (RealList() << 0 << 0.0001 << 0.0016 << 0.0081 << 0.0256 << 0.0625 << 0.1296 << 0.2401 << 0.4096 << 0.6561 << 1);
   234          << (RealList() << 0.0000 << 0.0001 << 0.0016 << 0.0081 << 0.0256 << 0.0625 << 0.1296 << 0.2401 << 0.4096 << 0.6561 << 1.0000);
   233 
   235 
   234     QTest::newRow("OutQuart") << int(QEasingCurve::OutQuart)
   236     QTest::newRow("OutQuart") << int(QEasingCurve::OutQuart)
   235          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   237          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   236          << (RealList() << 0 << 0.3439 << 0.5904 << 0.7599 << 0.8704 << 0.9375 << 0.9744 << 0.9919 << 0.9984 << 0.9999 << 1);
   238          << (RealList() << 0.0000 << 0.3439 << 0.5904 << 0.7599 << 0.8704 << 0.9375 << 0.9744 << 0.9919 << 0.9984 << 0.9999 << 1.0000);
   237 
   239 
   238     QTest::newRow("InOutQuart") << int(QEasingCurve::InOutQuart)
   240     QTest::newRow("InOutQuart") << int(QEasingCurve::InOutQuart)
   239          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   241          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   240          << (RealList() << 0 << 0.0008 << 0.0128 << 0.0648 << 0.2048 << 0.5 << 0.7952 << 0.9352 << 0.9872 << 0.9992 << 1);
   242          << (RealList() << 0.0000 << 0.0008 << 0.0128 << 0.0648 << 0.2048 << 0.5000 << 0.7952 << 0.9352 << 0.9872 << 0.9992 << 1.0000);
   241 
   243 
   242     QTest::newRow("OutInQuart") << int(QEasingCurve::OutInQuart)
   244     QTest::newRow("OutInQuart") << int(QEasingCurve::OutInQuart)
   243          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   245          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   244          << (RealList() << 0 << 0.2952 << 0.4352 << 0.4872 << 0.4992 << 0.5 << 0.5008 << 0.5128 << 0.5648 << 0.7048 << 1);
   246          << (RealList() << 0.0000 << 0.2952 << 0.4352 << 0.4872 << 0.4992 << 0.5000 << 0.5008 << 0.5128 << 0.5648 << 0.7048 << 1.0000);
   245 
   247 
   246     QTest::newRow("InQuint") << int(QEasingCurve::InQuint)
   248     QTest::newRow("InQuint") << int(QEasingCurve::InQuint)
   247          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   249          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   248          << (RealList() << 0 << 1e-05 << 0.00032 << 0.00243 << 0.01024 << 0.03125 << 0.07776 << 0.1681 << 0.3277 << 0.5905 << 1);
   250          << (RealList() << 0.0000 << 0.0000 << 0.0003 << 0.0024 << 0.0102 << 0.0313 << 0.0778 << 0.1681 << 0.3277 << 0.5905 << 1.0000);
   249 
   251 
   250     QTest::newRow("OutQuint") << int(QEasingCurve::OutQuint)
   252     QTest::newRow("OutQuint") << int(QEasingCurve::OutQuint)
   251          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   253          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   252          << (RealList() << 0 << 0.4095 << 0.6723 << 0.8319 << 0.9222 << 0.9688 << 0.9898 << 0.9976 << 0.9997 << 1 << 1);
   254          << (RealList() << 0.0000 << 0.4095 << 0.6723 << 0.8319 << 0.9222 << 0.9688 << 0.9898 << 0.9976 << 0.9997 << 1.0000 << 1.0000);
   253 
   255 
   254     QTest::newRow("InOutQuint") << int(QEasingCurve::InOutQuint)
   256     QTest::newRow("InOutQuint") << int(QEasingCurve::InOutQuint)
   255          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   257          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   256          << (RealList() << 0 << 0.00016 << 0.00512 << 0.03888 << 0.1638 << 0.5 << 0.8362 << 0.9611 << 0.9949 << 0.9998 << 1);
   258          << (RealList() << 0.0000 << 0.0002 << 0.0051 << 0.0389 << 0.1638 << 0.5000 << 0.8362 << 0.9611 << 0.9949 << 0.9998 << 1.0000);
   257 
   259 
   258     QTest::newRow("OutInQuint") << int(QEasingCurve::OutInQuint)
   260     QTest::newRow("OutInQuint") << int(QEasingCurve::OutInQuint)
   259          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   261          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   260          << (RealList() << 0 << 0.3362 << 0.4611 << 0.4949 << 0.4998 << 0.5 << 0.5002 << 0.5051 << 0.5389 << 0.6638 << 1);
   262          << (RealList() << 0.0000 << 0.3362 << 0.4611 << 0.4949 << 0.4998 << 0.5000 << 0.5002 << 0.5051 << 0.5389 << 0.6638 << 1.0000);
   261 
   263 
   262     QTest::newRow("InSine") << int(QEasingCurve::InSine)
   264     QTest::newRow("InSine") << int(QEasingCurve::InSine)
   263          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   265          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   264          << (RealList() << 0 << 0.01231 << 0.04894 << 0.109 << 0.191 << 0.2929 << 0.4122 << 0.546 << 0.691 << 0.8436 << 1);
   266          << (RealList() << 0.0000 << 0.0123 << 0.0489 << 0.1090 << 0.1910 << 0.2929 << 0.4122 << 0.5460 << 0.6910 << 0.8436 << 1.0000);
   265 
   267 
   266     QTest::newRow("OutSine") << int(QEasingCurve::OutSine)
   268     QTest::newRow("OutSine") << int(QEasingCurve::OutSine)
   267          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   269          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   268          << (RealList() << 0 << 0.1564 << 0.309 << 0.454 << 0.5878 << 0.7071 << 0.809 << 0.891 << 0.9511 << 0.9877 << 1);
   270          << (RealList() << 0.0000 << 0.1564 << 0.3090 << 0.4540 << 0.5878 << 0.7071 << 0.8090 << 0.8910 << 0.9511 << 0.9877 << 1.0000);
   269 
   271 
   270     QTest::newRow("InOutSine") << int(QEasingCurve::InOutSine)
   272     QTest::newRow("InOutSine") << int(QEasingCurve::InOutSine)
   271          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   273          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   272          << (RealList() << 0 << 0.02447 << 0.09549 << 0.2061 << 0.3455 << 0.5 << 0.6545 << 0.7939 << 0.9045 << 0.9755 << 1);
   274          << (RealList() << 0.0000 << 0.0245 << 0.0955 << 0.2061 << 0.3455 << 0.5000 << 0.6545 << 0.7939 << 0.9045 << 0.9755 << 1.0000);
   273 
   275 
   274     QTest::newRow("OutInSine") << int(QEasingCurve::OutInSine)
   276     QTest::newRow("OutInSine") << int(QEasingCurve::OutInSine)
   275          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   277          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   276          << (RealList() << 0 << 0.1545 << 0.2939 << 0.4045 << 0.4755 << 0.5 << 0.5245 << 0.5955 << 0.7061 << 0.8455 << 1);
   278          << (RealList() << 0.0000 << 0.1545 << 0.2939 << 0.4045 << 0.4755 << 0.5000 << 0.5245 << 0.5955 << 0.7061 << 0.8455 << 1.0000);
   277 
   279 
   278     QTest::newRow("InExpo") << int(QEasingCurve::InExpo)
   280     QTest::newRow("InExpo") << int(QEasingCurve::InExpo)
   279          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   281          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   280          << (RealList() << 0 << 0.0009531 << 0.002906 << 0.006812 << 0.01462 << 0.03025 << 0.0615 << 0.124 << 0.249 << 0.499 << 1);
   282          << (RealList() << 0.0000 << 0.0010 << 0.0029 << 0.0068 << 0.0146 << 0.0303 << 0.0615 << 0.1240 << 0.2490 << 0.4990 << 1.0000);
   281 
   283 
   282     QTest::newRow("OutExpo") << int(QEasingCurve::OutExpo)
   284     QTest::newRow("OutExpo") << int(QEasingCurve::OutExpo)
   283          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   285          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   284          << (RealList() << 0 << 0.5005 << 0.7507 << 0.8759 << 0.9384 << 0.9697 << 0.9854 << 0.9932 << 0.9971 << 0.999 << 1);
   286          << (RealList() << 0.0000 << 0.5005 << 0.7507 << 0.8759 << 0.9384 << 0.9697 << 0.9854 << 0.9932 << 0.9971 << 0.9990 << 1.0000);
   285 
   287 
   286     QTest::newRow("InOutExpo") << int(QEasingCurve::InOutExpo)
   288     QTest::newRow("InOutExpo") << int(QEasingCurve::InOutExpo)
   287          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   289          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   288          << (RealList() << 0 << 0.001453 << 0.007312 << 0.03075 << 0.1245 << 0.5002 << 0.8754 << 0.9692 << 0.9927 << 0.9985 << 1);
   290          << (RealList() << 0.0000 << 0.0015 << 0.0073 << 0.0308 << 0.1245 << 0.5003 << 0.8754 << 0.9692 << 0.9927 << 0.9985 << 1.0000);
   289 
   291 
   290     QTest::newRow("OutInExpo") << int(QEasingCurve::OutInExpo)
   292     QTest::newRow("OutInExpo") << int(QEasingCurve::OutInExpo)
   291          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   293          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   292          << (RealList() << 0 << 0.3754 << 0.4692 << 0.4927 << 0.4985 << 0.5 << 0.5015 << 0.5073 << 0.5308 << 0.6245 << 1);
   294          << (RealList() << 0.0000 << 0.3754 << 0.4692 << 0.4927 << 0.4985 << 0.5000 << 0.5015 << 0.5073 << 0.5308 << 0.6245 << 1.0000);
   293 
   295 
   294     QTest::newRow("InCirc") << int(QEasingCurve::InCirc)
   296     QTest::newRow("InCirc") << int(QEasingCurve::InCirc)
   295          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   297          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   296          << (RealList() << 0 << 0.005013 << 0.0202 << 0.04606 << 0.08348 << 0.134 << 0.2 << 0.2859 << 0.4 << 0.5641 << 1);
   298          << (RealList() << 0.0000 << 0.0050 << 0.0202 << 0.0461 << 0.0835 << 0.1340 << 0.2000 << 0.2859 << 0.4000 << 0.5641 << 1.0000);
   297 
   299 
   298     QTest::newRow("OutCirc") << int(QEasingCurve::OutCirc)
   300     QTest::newRow("OutCirc") << int(QEasingCurve::OutCirc)
   299          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   301          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   300          << (RealList() << 0 << 0.4359 << 0.6 << 0.7141 << 0.8 << 0.866 << 0.9165 << 0.9539 << 0.9798 << 0.995 << 1);
   302          << (RealList() << 0.0000 << 0.4359 << 0.6000 << 0.7141 << 0.8000 << 0.8660 << 0.9165 << 0.9539 << 0.9798 << 0.9950 << 1.0000);
   301 
   303 
   302     QTest::newRow("InOutCirc") << int(QEasingCurve::InOutCirc)
   304     QTest::newRow("InOutCirc") << int(QEasingCurve::InOutCirc)
   303          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   305          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   304          << (RealList() << 0 << 0.0101 << 0.04174 << 0.1 << 0.2 << 0.5 << 0.8 << 0.9 << 0.9583 << 0.9899 << 1);
   306          << (RealList() << 0.0000 << 0.0101 << 0.0417 << 0.1000 << 0.2000 << 0.5000 << 0.8000 << 0.9000 << 0.9583 << 0.9899 << 1.0000);
   305 
   307 
   306     QTest::newRow("OutInCirc") << int(QEasingCurve::OutInCirc)
   308     QTest::newRow("OutInCirc") << int(QEasingCurve::OutInCirc)
   307          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   309          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   308          << (RealList() << 0 << 0.3 << 0.4 << 0.4583 << 0.4899 << 0.5 << 0.5101 << 0.5417 << 0.6 << 0.7 << 1);
   310          << (RealList() << 0.0000 << 0.3000 << 0.4000 << 0.4583 << 0.4899 << 0.5000 << 0.5101 << 0.5417 << 0.6000 << 0.7000 << 1.0000);
   309 
   311 
   310     QTest::newRow("InElastic") << int(QEasingCurve::InElastic)
   312     QTest::newRow("InElastic") << int(QEasingCurve::InElastic)
   311          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   313          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   312          << (RealList() << 0 << 0.001953 << -0.001953 << -0.003906 << 0.01562 << -0.01562 << -0.03125 << 0.125 << -0.125 << -0.25 << 1);
   314          << (RealList() << 0.0000 << 0.0020 << -0.0020 << -0.0039 << 0.0156 << -0.0156 << -0.0313 << 0.1250 << -0.1250 << -0.2500 << 1.0000);
   313 
   315 
   314     QTest::newRow("OutElastic") << int(QEasingCurve::OutElastic)
   316     QTest::newRow("OutElastic") << int(QEasingCurve::OutElastic)
   315          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   317          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   316          << (RealList() << 0 << 1.25 << 1.125 << 0.875 << 1.031 << 1.016 << 0.9844 << 1.004 << 1.002 << 0.998 << 1);
   318          << (RealList() << 0.0000 << 1.2500 << 1.1250 << 0.8750 << 1.0313 << 1.0156 << 0.9844 << 1.0039 << 1.0020 << 0.9980 << 1.0000);
   317 
   319 
   318     QTest::newRow("InOutElastic") << int(QEasingCurve::InOutElastic)
   320     QTest::newRow("InOutElastic") << int(QEasingCurve::InOutElastic)
   319          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   321          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   320          << (RealList() << 0 << -0.0009766 << 0.007812 << -0.01563 << -0.0625 << 0.5 << 1.062 << 1.016 << 0.9922 << 1.001 << 1);
   322          << (RealList() << 0.0000 << -0.0010 << 0.0078 << -0.0156 << -0.0625 << 0.5000 << 1.0625 << 1.0156 << 0.9922 << 1.0010 << 1.0000);
   321 
   323 
   322     QTest::newRow("OutInElastic") << int(QEasingCurve::OutInElastic)
   324     QTest::newRow("OutInElastic") << int(QEasingCurve::OutInElastic)
   323          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   325          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   324          << (RealList() << 0 << 0.375 << 0.5625 << 0.4922 << 0.498 << 0.5 << 0.4961 << 0.5078 << 0.5313 << 0.25 << 1);
   326          << (RealList() << 0.0000 << 0.3750 << 0.5625 << 0.4922 << 0.4980 << 0.5000 << 0.4961 << 0.5078 << 0.5313 << 0.2500 << 1.0000);
   325 
   327 
   326     QTest::newRow("InBack") << int(QEasingCurve::InBack)
   328     QTest::newRow("InBack") << int(QEasingCurve::InBack)
   327          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   329          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   328          << (RealList() << 0 << -0.01431 << -0.04645 << -0.0802 << -0.09935 << -0.0877 << -0.02903 << 0.09287 << 0.2942 << 0.5912 << 1);
   330          << (RealList() << 0.0000 << -0.0143 << -0.0465 << -0.0802 << -0.0994 << -0.0877 << -0.0290 << 0.0929 << 0.2942 << 0.5912 << 1.0000);
   329 
   331 
   330     QTest::newRow("OutBack") << int(QEasingCurve::OutBack)
   332     QTest::newRow("OutBack") << int(QEasingCurve::OutBack)
   331          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   333          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   332          << (RealList() << 0 << 0.4088 << 0.7058 << 0.9071 << 1.029 << 1.088 << 1.099 << 1.08 << 1.046 << 1.014 << 1);
   334          << (RealList() << 0.0000 << 0.4088 << 0.7058 << 0.9071 << 1.0290 << 1.0877 << 1.0994 << 1.0802 << 1.0465 << 1.0143 << 1.0000);
   333 
   335 
   334     QTest::newRow("InOutBack") << int(QEasingCurve::InOutBack)
   336     QTest::newRow("InOutBack") << int(QEasingCurve::InOutBack)
   335          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   337          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   336          << (RealList() << 0 << -0.03752 << -0.09256 << -0.07883 << 0.08993 << 0.5 << 0.9101 << 1.079 << 1.093 << 1.038 << 1);
   338          << (RealList() << 0.0000 << -0.0375 << -0.0926 << -0.0788 << 0.0899 << 0.5000 << 0.9101 << 1.0788 << 1.0926 << 1.0375 << 1.0000);
   337 
   339 
   338     QTest::newRow("OutInBack") << int(QEasingCurve::OutInBack)
   340     QTest::newRow("OutInBack") << int(QEasingCurve::OutInBack)
   339          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   341          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   340          << (RealList() << 0 << 0.3529 << 0.5145 << 0.5497 << 0.5232 << 0.5 << 0.4768 << 0.4503 << 0.4855 << 0.6471 << 1);
   342          << (RealList() << 0.0000 << 0.3529 << 0.5145 << 0.5497 << 0.5232 << 0.5000 << 0.4768 << 0.4503 << 0.4855 << 0.6471 << 1.0000);
   341 
   343 
   342     QTest::newRow("InBounce") << int(QEasingCurve::InBounce)
   344     QTest::newRow("InBounce") << int(QEasingCurve::InBounce)
   343          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   345          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   344          << (RealList() << 0 << 0.01188 << 0.06 << 0.06937 << 0.2275 << 0.2344 << 0.09 << 0.3194 << 0.6975 << 0.9244 << 1);
   346          << (RealList() << 0.0000 << 0.0119 << 0.0600 << 0.0694 << 0.2275 << 0.2344 << 0.0900 << 0.3194 << 0.6975 << 0.9244 << 1.0000);
   345 
   347 
   346     QTest::newRow("OutBounce") << int(QEasingCurve::OutBounce)
   348     QTest::newRow("OutBounce") << int(QEasingCurve::OutBounce)
   347          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   349          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   348          << (RealList() << 0 << 0.07563 << 0.3025 << 0.6806 << 0.91 << 0.7656 << 0.7725 << 0.9306 << 0.94 << 0.9881 << 1);
   350          << (RealList() << 0.0000 << 0.0756 << 0.3025 << 0.6806 << 0.9100 << 0.7656 << 0.7725 << 0.9306 << 0.9400 << 0.9881 << 1.0000);
   349 
   351 
   350     QTest::newRow("InOutBounce") << int(QEasingCurve::InOutBounce)
   352     QTest::newRow("InOutBounce") << int(QEasingCurve::InOutBounce)
   351          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   353          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   352          << (RealList() << 0 << 0.03 << 0.1138 << 0.045 << 0.3488 << 0.5 << 0.6512 << 0.955 << 0.8862 << 0.97 << 1);
   354          << (RealList() << 0.0000 << 0.0300 << 0.1138 << 0.0450 << 0.3488 << 0.5000 << 0.6512 << 0.9550 << 0.8863 << 0.9700 << 1.0000);
   353 
   355 
   354     QTest::newRow("OutInBounce") << int(QEasingCurve::OutInBounce)
   356     QTest::newRow("OutInBounce") << int(QEasingCurve::OutInBounce)
   355          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   357          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   356          << (RealList() << 0 << 0.1513 << 0.41 << 0.2725 << 0.44 << 0.5 << 0.56 << 0.7275 << 0.59 << 0.8488 << 1);
   358          << (RealList() << 0.0000 << 0.1513 << 0.4100 << 0.2725 << 0.4400 << 0.5000 << 0.5600 << 0.7275 << 0.5900 << 0.8488 << 1.0000);
   357 
   359 
   358     QTest::newRow("InCurve") << int(QEasingCurve::InCurve)
   360     QTest::newRow("InCurve") << int(QEasingCurve::InCurve)
   359          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   361          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   360          << (RealList() << 0 << 0.02447 << 0.1059 << 0.2343 << 0.3727 << 0.5 << 0.6055 << 0.7 << 0.8 << 0.9 << 1);
   362          << (RealList() << 0.0000 << 0.0245 << 0.1059 << 0.2343 << 0.3727 << 0.5000 << 0.6055 << 0.7000 << 0.8000 << 0.9000 << 1.0000);
   361 
   363 
   362     QTest::newRow("OutCurve") << int(QEasingCurve::OutCurve)
   364     QTest::newRow("OutCurve") << int(QEasingCurve::OutCurve)
   363          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   365          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   364          << (RealList() << 0 << 0.1 << 0.2 << 0.3 << 0.3945 << 0.5 << 0.6273 << 0.7657 << 0.8941 << 0.9755 << 1);
   366          << (RealList() << 0.0000 << 0.1000 << 0.2000 << 0.3000 << 0.3945 << 0.5000 << 0.6273 << 0.7657 << 0.8941 << 0.9755 << 1.0000);
   365 
   367 
   366     QTest::newRow("SineCurve") << int(QEasingCurve::SineCurve)
   368     QTest::newRow("SineCurve") << int(QEasingCurve::SineCurve)
   367          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   369          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   368          << (RealList() << 0 << 0.09549 << 0.3455 << 0.6545 << 0.9045 << 1 << 0.9045 << 0.6545 << 0.3455 << 0.09549 << 0);
   370          << (RealList() << 0.0000 << 0.0955 << 0.3455 << 0.6545 << 0.9045 << 1.0000 << 0.9045 << 0.6545 << 0.3455 << 0.0955 << 0.0000);
   369 
   371 
   370     QTest::newRow("CosineCurve") << int(QEasingCurve::CosineCurve)
   372     QTest::newRow("CosineCurve") << int(QEasingCurve::CosineCurve)
   371          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   373          << (IntList()  << 0 << 10 << 20 << 30 << 40 << 50 << 60 << 70 << 80 << 90 << 100)
   372          << (RealList() << 0.5 << 0.7939 << 0.9755 << 0.9755 << 0.7939 << 0.5 << 0.2061 << 0.02447 << 0.02447 << 0.2061 << 0.5);
   374          << (RealList() << 0.5000 << 0.7939 << 0.9755 << 0.9755 << 0.7939 << 0.5000 << 0.2061 << 0.0245 << 0.0245 << 0.2061 << 0.5000);
   373 
   375 
   374 }
   376 }
   375 
   377 
       
   378 /*
       
   379   "fixedpoint" number that is scaled up by 10000.
       
   380   This is to work around two bugs (precision and rounding error) in QString::setNum().
       
   381   It does not trim off trailing zeros. This is good, just to emphasize the precision.
       
   382 */
       
   383 QString fixedToString(int value)
       
   384 {
       
   385     QString str;
       
   386     if (value < 0) {
       
   387         str+= QLatin1Char('-');
       
   388         value = -value;
       
   389     }
       
   390 
       
   391     QString digitArg(QLatin1String("%1."));
       
   392     for (int i = 10000; i >= 1; i/=10) {
       
   393         int digit = value/i;
       
   394         value -= digit*i;
       
   395         str.append(digitArg.arg(digit));
       
   396         digitArg = QLatin1String("%1");
       
   397     }
       
   398     return str;
       
   399 }
   376 
   400 
   377 void tst_QEasingCurve::valueForProgress()
   401 void tst_QEasingCurve::valueForProgress()
   378 {
   402 {
   379 #if 0
   403 #if 0
   380     // used to generate data tables...
   404     // used to generate data tables...
   388         QString strOutputs;
   412         QString strOutputs;
   389 
   413 
   390         for (int t = 0; t <= 100; t+= 10) {
   414         for (int t = 0; t <= 100; t+= 10) {
   391             qreal ease = curve.valueForProgress(t/qreal(100));
   415             qreal ease = curve.valueForProgress(t/qreal(100));
   392             strInputs += QString::fromAscii(" << %1").arg(t);
   416             strInputs += QString::fromAscii(" << %1").arg(t);
   393             strOutputs += " << " + QString().setNum(ease, 'g', 4);
   417             strOutputs += " << " + fixedToString(qRound(ease*10000));
   394         }
   418         }
   395         QString str = QString::fromAscii("    QTest::newRow(\"%1\") << int(QEasingCurve::%2)\n"
   419         QString str = QString::fromAscii("    QTest::newRow(\"%1\") << int(QEasingCurve::%2)\n"
   396                                                 "         << (IntList() %3)\n"
   420                                                 "         << (IntList() %3)\n"
   397                                                 "         << (RealList()%4);\n\n")
   421                                                 "         << (RealList()%4);\n\n")
   398                                       .arg(strCurve)
   422                                       .arg(strCurve)
   407     QFETCH(int, type);
   431     QFETCH(int, type);
   408     QFETCH(IntList, at);
   432     QFETCH(IntList, at);
   409     QFETCH(RealList, expected);
   433     QFETCH(RealList, expected);
   410 
   434 
   411     QEasingCurve curve((QEasingCurve::Type)type);
   435     QEasingCurve curve((QEasingCurve::Type)type);
       
   436     // in theory the baseline should't have an error of more than 0.00005 due to how its rounded,
       
   437     // but due to FP imprecision, we have to adjust the error a bit more.
       
   438     const qreal errorBound = 0.00006;
   412     for (int i = 0; i < at.count(); ++i) {
   439     for (int i = 0; i < at.count(); ++i) {
   413         qreal ease = curve.valueForProgress(at.at(i)/qreal(100));
   440         const qreal ex = expected.at(i);
   414         // converting ease to 4 precision qreal to match the generated samples
   441         const qreal error = qAbs(ex - curve.valueForProgress(at.at(i)/qreal(100)));
   415         qreal easeConv = qreal(QString().setNum(ease, 'g', 4).toDouble());
   442         QVERIFY(error <= errorBound);
   416         qreal ex = expected.at(i);
       
   417 
       
   418         // the least significant digit it is still subject to rounding errors
       
   419         qreal error = easeConv - ex;
       
   420         qreal errorbound = 0.00001;                
       
   421 #if defined( Q_OS_WINCE ) || defined( Q_OS_SYMBIAN )
       
   422         // exception values for WINCE(this test should be rewritten, as it only freezes the status quo of QEasingCurve
       
   423         // The failing (2) values are explicitly excepted here:
       
   424         // The source values for the comparison table should remain untruncated double and the
       
   425         // error bound checking function dynamic. Also the source values should come from a "trusted" source and not
       
   426         // from QEasingCurve itself.        
       
   427         if ((type == int(QEasingCurve::InOutBounce) && (i == 8 || i == 6) ) || (type == int(QEasingCurve::OutExpo) && i == 2))
       
   428             errorbound = 0.0002;         
       
   429 #endif 
       
   430         // accept the potential rounding error in the least significant digit
       
   431         QVERIFY(error <= errorbound );          
       
   432     }
   443     }
   433 #endif
   444 #endif
   434 }
   445 }
   435 
   446 
   436 static qreal discreteEase(qreal progress)
   447 static qreal discreteEase(qreal progress)
   494     curve2.setType(QEasingCurve::InBack);
   505     curve2.setType(QEasingCurve::InBack);
   495     QCOMPARE(curve.overshoot(), curve2.overshoot());
   506     QCOMPARE(curve.overshoot(), curve2.overshoot());
   496     QVERIFY(curve2 == curve);
   507     QVERIFY(curve2 == curve);
   497 }
   508 }
   498 
   509 
       
   510 class tst_QEasingProperties : public QObject
       
   511 {
       
   512     Q_OBJECT
       
   513     Q_PROPERTY(QEasingCurve easing READ easing WRITE setEasing)
       
   514 public:
       
   515     tst_QEasingProperties(QObject *parent = 0) : QObject(parent) {}
       
   516 
       
   517     QEasingCurve easing() const { return e; }
       
   518     void setEasing(const QEasingCurve& value) { e = value; }
       
   519 
       
   520 private:
       
   521     QEasingCurve e;
       
   522 };
       
   523 
       
   524 // Test getting and setting easing properties via the metaobject system.
       
   525 void tst_QEasingCurve::properties()
       
   526 {
       
   527     tst_QEasingProperties obj;
       
   528 
       
   529     QEasingCurve inOutBack(QEasingCurve::InOutBack);
       
   530     qreal overshoot = 1.5f;
       
   531     inOutBack.setOvershoot(overshoot);
       
   532     qreal amplitude = inOutBack.amplitude();
       
   533     qreal period = inOutBack.period();
       
   534 
       
   535     obj.setEasing(inOutBack);
       
   536 
       
   537     QEasingCurve easing = qVariantValue<QEasingCurve>(obj.property("easing"));
       
   538     QCOMPARE(easing.type(), QEasingCurve::InOutBack);
       
   539     QCOMPARE(easing.overshoot(), overshoot);
       
   540     QCOMPARE(easing.amplitude(), amplitude);
       
   541     QCOMPARE(easing.period(), period);
       
   542 
       
   543     QEasingCurve linear(QEasingCurve::Linear);
       
   544     overshoot = linear.overshoot();
       
   545     amplitude = linear.amplitude();
       
   546     period = linear.period();
       
   547 
       
   548     obj.setProperty("easing",
       
   549                     qVariantFromValue(QEasingCurve(QEasingCurve::Linear)));
       
   550 
       
   551     easing = qVariantValue<QEasingCurve>(obj.property("easing"));
       
   552     QCOMPARE(easing.type(), QEasingCurve::Linear);
       
   553     QCOMPARE(easing.overshoot(), overshoot);
       
   554     QCOMPARE(easing.amplitude(), amplitude);
       
   555     QCOMPARE(easing.period(), period);
       
   556 }
       
   557 
       
   558 void tst_QEasingCurve::metaTypes()
       
   559 {
       
   560     QVERIFY(QMetaType::type("QEasingCurve") == QMetaType::QEasingCurve);
       
   561 
       
   562     QCOMPARE(QByteArray(QMetaType::typeName(QMetaType::QEasingCurve)),
       
   563              QByteArray("QEasingCurve"));
       
   564 
       
   565     QVERIFY(QMetaType::isRegistered(QMetaType::QEasingCurve));
       
   566 
       
   567     QVERIFY(qMetaTypeId<QEasingCurve>() == QMetaType::QEasingCurve);
       
   568 }
   499 
   569 
   500 QTEST_MAIN(tst_QEasingCurve)
   570 QTEST_MAIN(tst_QEasingCurve)
   501 #include "tst_qeasingcurve.moc"
   571 #include "tst_qeasingcurve.moc"
   502 
   572 
   503 #endif //QT_VERSION
   573 #endif //QT_VERSION