diff options
author | John Reck <jreck@google.com> | 2017-11-03 10:12:19 -0700 |
---|---|---|
committer | John Reck <jreck@google.com> | 2017-11-03 10:57:44 -0700 |
commit | 1bcacfdcab0eaa0cee92bd7f5a1b5e271dd68e52 (patch) | |
tree | 4a1366cf2d1cf50b5ec4ed1a8cf0f437053cd0d7 /libs/hwui/tests/unit/VectorDrawableTests.cpp | |
parent | 30ec71c0fe194a551d2e4abaff2159e0730488e0 (diff) |
Format the world (or just HWUI)
Test: No code changes, just ran through clang-format
Change-Id: Id23aa4ec7eebc0446fe3a30260f33e7fd455bb8c
Diffstat (limited to 'libs/hwui/tests/unit/VectorDrawableTests.cpp')
-rw-r--r-- | libs/hwui/tests/unit/VectorDrawableTests.cpp | 474 |
1 files changed, 258 insertions, 216 deletions
diff --git a/libs/hwui/tests/unit/VectorDrawableTests.cpp b/libs/hwui/tests/unit/VectorDrawableTests.cpp index 1c2156765fe6..a92cbfdf6757 100644 --- a/libs/hwui/tests/unit/VectorDrawableTests.cpp +++ b/libs/hwui/tests/unit/VectorDrawableTests.cpp @@ -33,195 +33,239 @@ struct TestData { }; const static TestData sTestDataSet[] = { - // TestData with scientific notation -2e3 etc. - { - // Path - "M2.000000,22.000000l20.000000,0.000000 1e0-2e3z", - { - // Verbs - {'M', 'l', 'z'}, - // Verb sizes - {2, 4, 0}, - // Points - {2, 22, 20, 0, 1, -2000}, - }, - [](SkPath* outPath) { - outPath->moveTo(2, 22); - outPath->rLineTo(20, 0); - outPath->rLineTo(1, -2000); - outPath->close(); - outPath->moveTo(2, 22); - } - }, - - // Comprehensive data, containing all the verbs possible. - { - // Path - "M 1 1 m 2 2, l 3 3 L 3 3 H 4 h4 V5 v5, Q6 6 6 6 q 6 6 6 6t 7 7 T 7 7 C 8 8 8 8 8 8 c 8 8 8 8 8 8 S 9 9 9 9 s 9 9 9 9 A 10 10 0 1 1 10 10 a 10 10 0 1 1 10 10", - { - // Verbs - {'M', 'm', 'l', 'L', 'H', 'h', 'V', 'v', 'Q', 'q', 't', 'T', 'C', 'c', 'S', 's', 'A', 'a'}, - // VerbSizes - {2, 2, 2, 2, 1, 1, 1, 1, 4, 4, 2, 2, 6, 6, 4, 4, 7, 7}, - // Points - {1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0, 7.0, 7.0, 7.0, 7.0, 8.0, 8.0, 8.0, 8.0, 8.0, 8.0, 8.0, 8.0, 8.0, 8.0, 8.0, 8.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 10.0, 10.0, 0.0, 1.0, 1.0, 10.0, 10.0, 10.0, 10.0, 0.0, 1.0, 1.0, 10.0, 10.0, } - }, - [](SkPath* outPath) { - outPath->moveTo(1.0, 1.0); - outPath->rMoveTo(2.0, 2.0); - outPath->rLineTo(3.0, 3.0); - outPath->lineTo(3.0, 3.0); - outPath->lineTo(4.0, 3.0); - outPath->rLineTo(4.0, 0); - outPath->lineTo(8.0, 5.0); - outPath->rLineTo(0, 5.0); - outPath->quadTo(6.0, 6.0, 6.0, 6.0); - outPath->rQuadTo(6.0, 6.0, 6.0, 6.0); - outPath->rQuadTo(0.0, 0.0, 7.0, 7.0); - outPath->quadTo(26.0, 26.0, 7.0, 7.0); - outPath->cubicTo(8.0, 8.0, 8.0, 8.0, 8.0, 8.0); - outPath->rCubicTo(8.0, 8.0, 8.0, 8.0, 8.0, 8.0); - outPath->cubicTo(16.0, 16.0, 9.0, 9.0, 9.0, 9.0); - outPath->rCubicTo(0.0, 0.0, 9.0, 9.0, 9.0, 9.0); - outPath->cubicTo(18.447775037328352, 20.404243860300607, 17.998389141249767, 22.8911717921705, 16.737515350332117, 24.986664170401575); - outPath->cubicTo(15.476641559414468, 27.08215654863265, 13.489843598291483, 28.644011882390082, 11.155893964798905, 29.37447073281729); - outPath->cubicTo(8.821944331306327, 30.1049295832445, 6.299226382436471, 29.954422532383525, 4.0686829203897235, 28.951642951534332); - outPath->cubicTo(1.838139458342976, 27.94886337068514, 0.05113662931485696, 26.161860541657013, -0.9516429515343354, 23.931317079610267); - outPath->cubicTo(-1.9544225323835278, 21.70077361756352, -2.1049295832444987, 19.178055668693663, -1.37447073281729, 16.844106035201087); - outPath->cubicTo(-0.6440118823900814, 14.51015640170851, 0.9178434513673546, 12.523358440585524, 3.0133358295984305, 11.262484649667876); - outPath->cubicTo(5.108828207829506, 10.001610858750228, 7.5957561396993984, 9.552224962671648, 10.000000000000005, 10.0); - outPath->cubicTo(10.0, 7.348852265086975, 11.054287646850167, 4.803576729418881, 12.928932188134523, 2.9289321881345254); - outPath->cubicTo(14.803576729418879, 1.0542876468501696, 17.348852265086972, 4.870079381441987E-16, 19.999999999999996, 0.0); - outPath->cubicTo(22.65114773491302, -4.870079381441987E-16, 25.19642327058112, 1.0542876468501678, 27.071067811865476, 2.9289321881345227); - outPath->cubicTo(28.94571235314983, 4.803576729418878, 30.0, 7.348852265086974, 30.0, 9.999999999999998); - outPath->cubicTo(30.0, 12.651147734913023, 28.94571235314983, 15.19642327058112, 27.071067811865476, 17.071067811865476); - outPath->cubicTo(25.19642327058112, 18.94571235314983, 22.651147734913028, 20.0, 20.000000000000004, 20.0); - } - }, - - // Check box VectorDrawable path data - { - // Path - "M 0.0,-1.0 l 0.0,0.0 c 0.5522847498,0.0 1.0,0.4477152502 1.0,1.0 l 0.0,0.0 c 0.0,0.5522847498 -0.4477152502,1.0 -1.0,1.0 l 0.0,0.0 c -0.5522847498,0.0 -1.0,-0.4477152502 -1.0,-1.0 l 0.0,0.0 c 0.0,-0.5522847498 0.4477152502,-1.0 1.0,-1.0 Z M 7.0,-9.0 c 0.0,0.0 -14.0,0.0 -14.0,0.0 c -1.1044921875,0.0 -2.0,0.8955078125 -2.0,2.0 c 0.0,0.0 0.0,14.0 0.0,14.0 c 0.0,1.1044921875 0.8955078125,2.0 2.0,2.0 c 0.0,0.0 14.0,0.0 14.0,0.0 c 1.1044921875,0.0 2.0,-0.8955078125 2.0,-2.0 c 0.0,0.0 0.0,-14.0 0.0,-14.0 c 0.0,-1.1044921875 -0.8955078125,-2.0 -2.0,-2.0 c 0.0,0.0 0.0,0.0 0.0,0.0 Z", - { - {'M', 'l', 'c', 'l', 'c', 'l', 'c', 'l', 'c', 'Z', 'M', 'c', 'c', 'c', 'c', 'c', 'c', 'c', 'c', 'c', 'Z'}, - {2, 2, 6, 2, 6, 2, 6, 2, 6, 0, 2, 6, 6, 6, 6, 6, 6, 6, 6, 6, 0}, - {0.0, -1.0, 0.0, 0.0, 0.5522848, 0.0, 1.0, 0.44771525, 1.0, 1.0, 0.0, 0.0, 0.0, 0.5522848, -0.44771525, 1.0, -1.0, 1.0, 0.0, 0.0, -0.5522848, 0.0, -1.0, -0.44771525, -1.0, -1.0, 0.0, 0.0, 0.0, -0.5522848, 0.44771525, -1.0, 1.0, -1.0, 7.0, -9.0, 0.0, 0.0, -14.0, 0.0, -14.0, 0.0, -1.1044922, 0.0, -2.0, 0.8955078, -2.0, 2.0, 0.0, 0.0, 0.0, 14.0, 0.0, 14.0, 0.0, 1.1044922, 0.8955078, 2.0, 2.0, 2.0, 0.0, 0.0, 14.0, 0.0, 14.0, 0.0, 1.1044922, 0.0, 2.0, -0.8955078, 2.0, -2.0, 0.0, 0.0, 0.0, -14.0, 0.0, -14.0, 0.0, -1.1044922, -0.8955078, -2.0, -2.0, -2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, - }, - [](SkPath* outPath) { - outPath->moveTo(0.0, -1.0); - outPath->rLineTo(0.0, 0.0); - outPath->rCubicTo(0.5522848, 0.0, 1.0, 0.44771525, 1.0, 1.0); - outPath->rLineTo(0.0, 0.0); - outPath->rCubicTo(0.0, 0.5522848, -0.44771525, 1.0, -1.0, 1.0); - outPath->rLineTo(0.0, 0.0); - outPath->rCubicTo(-0.5522848, 0.0, -1.0, -0.44771525, -1.0, -1.0); - outPath->rLineTo(0.0, 0.0); - outPath->rCubicTo(0.0, -0.5522848, 0.44771525, -1.0, 1.0, -1.0); - outPath->close(); - outPath->moveTo(0.0, -1.0); - outPath->moveTo(7.0, -9.0); - outPath->rCubicTo(0.0, 0.0, -14.0, 0.0, -14.0, 0.0); - outPath->rCubicTo(-1.1044922, 0.0, -2.0, 0.8955078, -2.0, 2.0); - outPath->rCubicTo(0.0, 0.0, 0.0, 14.0, 0.0, 14.0); - outPath->rCubicTo(0.0, 1.1044922, 0.8955078, 2.0, 2.0, 2.0); - outPath->rCubicTo(0.0, 0.0, 14.0, 0.0, 14.0, 0.0); - outPath->rCubicTo(1.1044922, 0.0, 2.0, -0.8955078, 2.0, -2.0); - outPath->rCubicTo(0.0, 0.0, 0.0, -14.0, 0.0, -14.0); - outPath->rCubicTo(0.0, -1.1044922, -0.8955078, -2.0, -2.0, -2.0); - outPath->rCubicTo(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); - outPath->close(); - outPath->moveTo(7.0, -9.0); - } - }, - - // pie1 in progress bar - { - "M300,70 a230,230 0 1,0 1,0 z", - { - {'M', 'a', 'z', }, - {2, 7, 0, }, - {300.0, 70.0, 230.0, 230.0, 0.0, 1.0, 0.0, 1.0, 0.0, }, - }, - [](SkPath* outPath) { - outPath->moveTo(300.0, 70.0); - outPath->cubicTo(239.06697794203706, 70.13246340443499, 180.6164396449267, 94.47383115953485, 137.6004913602211, 137.6302781499585); - outPath->cubicTo(94.58454307551551, 180.78672514038215, 70.43390412842275, 239.3163266242308, 70.50013586976587, 300.2494566687817); - outPath->cubicTo(70.56636761110899, 361.1825867133326, 94.84418775550249, 419.65954850554147, 137.9538527586204, 462.72238058830936); - outPath->cubicTo(181.06351776173827, 505.7852126710772, 239.5668339599056, 529.999456521097, 300.49999999999994, 529.999456521097); - outPath->cubicTo(361.43316604009436, 529.999456521097, 419.93648223826176, 505.78521267107726, 463.0461472413797, 462.7223805883093); - outPath->cubicTo(506.1558122444976, 419.65954850554135, 530.433632388891, 361.1825867133324, 530.4998641302341, 300.2494566687815); - outPath->cubicTo(530.5660958715771, 239.31632662423056, 506.4154569244844, 180.7867251403819, 463.3995086397787, 137.6302781499583); - outPath->cubicTo(420.383560355073, 94.47383115953468, 361.93302205796255, 70.13246340443492, 300.9999999999996, 70.00000000000003); - outPath->close(); - outPath->moveTo(300.0, 70.0); - } - }, - - // Random long data - { - // Path - "M5.3,13.2c-0.1,0.0 -0.3,0.0 -0.4,-0.1c-0.3,-0.2 -0.4,-0.7 -0.2,-1.0c1.3,-1.9 2.9,-3.4 4.9,-4.5c4.1,-2.2 9.3,-2.2 13.4,0.0c1.9,1.1 3.6,2.5 4.9,4.4c0.2,0.3 0.1,0.8 -0.2,1.0c-0.3,0.2 -0.8,0.1 -1.0,-0.2c-1.2,-1.7 -2.6,-3.0 -4.3,-4.0c-3.7,-2.0 -8.3,-2.0 -12.0,0.0c-1.7,0.9 -3.2,2.3 -4.3,4.0C5.7,13.1 5.5,13.2 5.3,13.2z", - { - // Verbs - {'M', 'c', 'c', 'c', 'c', 'c', 'c', 'c', 'c', 'c', 'c', 'C', 'z'}, - // Verb sizes - {2, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 0}, - // Points - {5.3, 13.2, -0.1, 0, -0.3, 0, -0.4, -0.1, -0.3, -0.2, -0.4, -0.7, -0.2, -1, 1.3, -1.9, 2.9, -3.4, 4.9, -4.5, 4.1, -2.2, 9.3, -2.2, 13.4, 0, 1.9, 1.1, 3.6, 2.5, 4.9, 4.4, 0.2, 0.3, 0.1, 0.8, -0.2, 1, -0.3, 0.2, -0.8, 0.1, -1, -0.2, -1.2, -1.7, -2.6, -3, -4.3, -4, -3.7, -2, -8.3, -2, -12, 0, -1.7, 0.9, -3.2, 2.3, -4.3, 4, 5.7, 13.1, 5.5, 13.2, 5.3, 13.2}, - }, - [](SkPath* outPath) { - outPath->moveTo(5.3, 13.2); - outPath->rCubicTo(-0.1, 0.0, -0.3, 0.0, -0.4, -0.1); - outPath->rCubicTo(-0.3, -0.2, -0.4, -0.7, -0.2, -1.0); - outPath->rCubicTo(1.3, -1.9, 2.9, -3.4, 4.9, -4.5); - outPath->rCubicTo(4.1, -2.2, 9.3, -2.2, 13.4, 0.0); - outPath->rCubicTo(1.9, 1.1, 3.6, 2.5, 4.9, 4.4); - outPath->rCubicTo(0.2, 0.3, 0.1, 0.8, -0.2, 1.0); - outPath->rCubicTo(-0.3, 0.2, -0.8, 0.1, -1.0, -0.2); - outPath->rCubicTo(-1.2, -1.7, -2.6, -3.0, -4.3, -4.0); - outPath->rCubicTo(-3.7, -2.0, -8.3, -2.0, -12.0, 0.0); - outPath->rCubicTo(-1.7, 0.9, -3.2, 2.3, -4.3, 4.0); - outPath->cubicTo(5.7, 13.1, 5.5, 13.2, 5.3, 13.2); - outPath->close(); - outPath->moveTo(5.3, 13.2); - } - }, - - // Extreme case with numbers and decimal points crunched together - { - // Path - "l0.0.0.5.0.0.5-0.5.0.0-.5z", - { - // Verbs - {'l', 'z'}, - // Verb sizes - {10, 0}, - // Points - {0, 0, 0.5, 0, 0, 0.5, -0.5, 0, 0, -0.5}, - }, - [](SkPath* outPath) { - outPath->rLineTo(0.0, 0.0); - outPath->rLineTo(0.5, 0.0); - outPath->rLineTo(0.0, 0.5); - outPath->rLineTo(-0.5, 0.0); - outPath->rLineTo(0.0, -0.5); - outPath->close(); - outPath->moveTo(0.0, 0.0); - } - }, - - // Empty test data - { - "", - { - // Verbs - {}, - {}, - {}, - }, - [](SkPath* outPath) {} - } + // TestData with scientific notation -2e3 etc. + {// Path + "M2.000000,22.000000l20.000000,0.000000 1e0-2e3z", + { + // Verbs + {'M', 'l', 'z'}, + // Verb sizes + {2, 4, 0}, + // Points + {2, 22, 20, 0, 1, -2000}, + }, + [](SkPath* outPath) { + outPath->moveTo(2, 22); + outPath->rLineTo(20, 0); + outPath->rLineTo(1, -2000); + outPath->close(); + outPath->moveTo(2, 22); + }}, + + // Comprehensive data, containing all the verbs possible. + {// Path + "M 1 1 m 2 2, l 3 3 L 3 3 H 4 h4 V5 v5, Q6 6 6 6 q 6 6 6 6t 7 7 T 7 7 C 8 8 8 8 8 8 c 8 8 " + "8 8 8 8 S 9 9 9 9 s 9 9 9 9 A 10 10 0 1 1 10 10 a 10 10 0 1 1 10 10", + {// Verbs + {'M', 'm', 'l', 'L', 'H', 'h', 'V', 'v', 'Q', 'q', 't', 'T', 'C', 'c', 'S', 's', 'A', + 'a'}, + // VerbSizes + {2, 2, 2, 2, 1, 1, 1, 1, 4, 4, 2, 2, 6, 6, 4, 4, 7, 7}, + // Points + { + 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0, 6.0, + 6.0, 6.0, 6.0, 6.0, 6.0, 7.0, 7.0, 7.0, 7.0, 8.0, 8.0, 8.0, 8.0, 8.0, 8.0, + 8.0, 8.0, 8.0, 8.0, 8.0, 8.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 10.0, + 10.0, 0.0, 1.0, 1.0, 10.0, 10.0, 10.0, 10.0, 0.0, 1.0, 1.0, 10.0, 10.0, + }}, + [](SkPath* outPath) { + outPath->moveTo(1.0, 1.0); + outPath->rMoveTo(2.0, 2.0); + outPath->rLineTo(3.0, 3.0); + outPath->lineTo(3.0, 3.0); + outPath->lineTo(4.0, 3.0); + outPath->rLineTo(4.0, 0); + outPath->lineTo(8.0, 5.0); + outPath->rLineTo(0, 5.0); + outPath->quadTo(6.0, 6.0, 6.0, 6.0); + outPath->rQuadTo(6.0, 6.0, 6.0, 6.0); + outPath->rQuadTo(0.0, 0.0, 7.0, 7.0); + outPath->quadTo(26.0, 26.0, 7.0, 7.0); + outPath->cubicTo(8.0, 8.0, 8.0, 8.0, 8.0, 8.0); + outPath->rCubicTo(8.0, 8.0, 8.0, 8.0, 8.0, 8.0); + outPath->cubicTo(16.0, 16.0, 9.0, 9.0, 9.0, 9.0); + outPath->rCubicTo(0.0, 0.0, 9.0, 9.0, 9.0, 9.0); + outPath->cubicTo(18.447775037328352, 20.404243860300607, 17.998389141249767, + 22.8911717921705, 16.737515350332117, 24.986664170401575); + outPath->cubicTo(15.476641559414468, 27.08215654863265, 13.489843598291483, + 28.644011882390082, 11.155893964798905, 29.37447073281729); + outPath->cubicTo(8.821944331306327, 30.1049295832445, 6.299226382436471, + 29.954422532383525, 4.0686829203897235, 28.951642951534332); + outPath->cubicTo(1.838139458342976, 27.94886337068514, 0.05113662931485696, + 26.161860541657013, -0.9516429515343354, 23.931317079610267); + outPath->cubicTo(-1.9544225323835278, 21.70077361756352, -2.1049295832444987, + 19.178055668693663, -1.37447073281729, 16.844106035201087); + outPath->cubicTo(-0.6440118823900814, 14.51015640170851, 0.9178434513673546, + 12.523358440585524, 3.0133358295984305, 11.262484649667876); + outPath->cubicTo(5.108828207829506, 10.001610858750228, 7.5957561396993984, + 9.552224962671648, 10.000000000000005, 10.0); + outPath->cubicTo(10.0, 7.348852265086975, 11.054287646850167, 4.803576729418881, + 12.928932188134523, 2.9289321881345254); + outPath->cubicTo(14.803576729418879, 1.0542876468501696, 17.348852265086972, + 4.870079381441987E-16, 19.999999999999996, 0.0); + outPath->cubicTo(22.65114773491302, -4.870079381441987E-16, 25.19642327058112, + 1.0542876468501678, 27.071067811865476, 2.9289321881345227); + outPath->cubicTo(28.94571235314983, 4.803576729418878, 30.0, 7.348852265086974, 30.0, + 9.999999999999998); + outPath->cubicTo(30.0, 12.651147734913023, 28.94571235314983, 15.19642327058112, + 27.071067811865476, 17.071067811865476); + outPath->cubicTo(25.19642327058112, 18.94571235314983, 22.651147734913028, 20.0, + 20.000000000000004, 20.0); + }}, + + // Check box VectorDrawable path data + {// Path + "M 0.0,-1.0 l 0.0,0.0 c 0.5522847498,0.0 1.0,0.4477152502 1.0,1.0 l 0.0,0.0 c " + "0.0,0.5522847498 -0.4477152502,1.0 -1.0,1.0 l 0.0,0.0 c -0.5522847498,0.0 " + "-1.0,-0.4477152502 -1.0,-1.0 l 0.0,0.0 c 0.0,-0.5522847498 0.4477152502,-1.0 1.0,-1.0 Z " + "M 7.0,-9.0 c 0.0,0.0 -14.0,0.0 -14.0,0.0 c -1.1044921875,0.0 -2.0,0.8955078125 -2.0,2.0 " + "c 0.0,0.0 0.0,14.0 0.0,14.0 c 0.0,1.1044921875 0.8955078125,2.0 2.0,2.0 c 0.0,0.0 " + "14.0,0.0 14.0,0.0 c 1.1044921875,0.0 2.0,-0.8955078125 2.0,-2.0 c 0.0,0.0 0.0,-14.0 " + "0.0,-14.0 c 0.0,-1.1044921875 -0.8955078125,-2.0 -2.0,-2.0 c 0.0,0.0 0.0,0.0 0.0,0.0 Z", + { + {'M', 'l', 'c', 'l', 'c', 'l', 'c', 'l', 'c', 'Z', 'M', + 'c', 'c', 'c', 'c', 'c', 'c', 'c', 'c', 'c', 'Z'}, + {2, 2, 6, 2, 6, 2, 6, 2, 6, 0, 2, 6, 6, 6, 6, 6, 6, 6, 6, 6, 0}, + {0.0, -1.0, 0.0, 0.0, 0.5522848, 0.0, 1.0, + 0.44771525, 1.0, 1.0, 0.0, 0.0, 0.0, 0.5522848, + -0.44771525, 1.0, -1.0, 1.0, 0.0, 0.0, -0.5522848, + 0.0, -1.0, -0.44771525, -1.0, -1.0, 0.0, 0.0, + 0.0, -0.5522848, 0.44771525, -1.0, 1.0, -1.0, 7.0, + -9.0, 0.0, 0.0, -14.0, 0.0, -14.0, 0.0, + -1.1044922, 0.0, -2.0, 0.8955078, -2.0, 2.0, 0.0, + 0.0, 0.0, 14.0, 0.0, 14.0, 0.0, 1.1044922, + 0.8955078, 2.0, 2.0, 2.0, 0.0, 0.0, 14.0, + 0.0, 14.0, 0.0, 1.1044922, 0.0, 2.0, -0.8955078, + 2.0, -2.0, 0.0, 0.0, 0.0, -14.0, 0.0, + -14.0, 0.0, -1.1044922, -0.8955078, -2.0, -2.0, -2.0, + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, + }, + [](SkPath* outPath) { + outPath->moveTo(0.0, -1.0); + outPath->rLineTo(0.0, 0.0); + outPath->rCubicTo(0.5522848, 0.0, 1.0, 0.44771525, 1.0, 1.0); + outPath->rLineTo(0.0, 0.0); + outPath->rCubicTo(0.0, 0.5522848, -0.44771525, 1.0, -1.0, 1.0); + outPath->rLineTo(0.0, 0.0); + outPath->rCubicTo(-0.5522848, 0.0, -1.0, -0.44771525, -1.0, -1.0); + outPath->rLineTo(0.0, 0.0); + outPath->rCubicTo(0.0, -0.5522848, 0.44771525, -1.0, 1.0, -1.0); + outPath->close(); + outPath->moveTo(0.0, -1.0); + outPath->moveTo(7.0, -9.0); + outPath->rCubicTo(0.0, 0.0, -14.0, 0.0, -14.0, 0.0); + outPath->rCubicTo(-1.1044922, 0.0, -2.0, 0.8955078, -2.0, 2.0); + outPath->rCubicTo(0.0, 0.0, 0.0, 14.0, 0.0, 14.0); + outPath->rCubicTo(0.0, 1.1044922, 0.8955078, 2.0, 2.0, 2.0); + outPath->rCubicTo(0.0, 0.0, 14.0, 0.0, 14.0, 0.0); + outPath->rCubicTo(1.1044922, 0.0, 2.0, -0.8955078, 2.0, -2.0); + outPath->rCubicTo(0.0, 0.0, 0.0, -14.0, 0.0, -14.0); + outPath->rCubicTo(0.0, -1.1044922, -0.8955078, -2.0, -2.0, -2.0); + outPath->rCubicTo(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); + outPath->close(); + outPath->moveTo(7.0, -9.0); + }}, + + // pie1 in progress bar + {"M300,70 a230,230 0 1,0 1,0 z", + { + { + 'M', 'a', 'z', + }, + { + 2, 7, 0, + }, + { + 300.0, 70.0, 230.0, 230.0, 0.0, 1.0, 0.0, 1.0, 0.0, + }, + }, + [](SkPath* outPath) { + outPath->moveTo(300.0, 70.0); + outPath->cubicTo(239.06697794203706, 70.13246340443499, 180.6164396449267, + 94.47383115953485, 137.6004913602211, 137.6302781499585); + outPath->cubicTo(94.58454307551551, 180.78672514038215, 70.43390412842275, + 239.3163266242308, 70.50013586976587, 300.2494566687817); + outPath->cubicTo(70.56636761110899, 361.1825867133326, 94.84418775550249, + 419.65954850554147, 137.9538527586204, 462.72238058830936); + outPath->cubicTo(181.06351776173827, 505.7852126710772, 239.5668339599056, + 529.999456521097, 300.49999999999994, 529.999456521097); + outPath->cubicTo(361.43316604009436, 529.999456521097, 419.93648223826176, + 505.78521267107726, 463.0461472413797, 462.7223805883093); + outPath->cubicTo(506.1558122444976, 419.65954850554135, 530.433632388891, + 361.1825867133324, 530.4998641302341, 300.2494566687815); + outPath->cubicTo(530.5660958715771, 239.31632662423056, 506.4154569244844, + 180.7867251403819, 463.3995086397787, 137.6302781499583); + outPath->cubicTo(420.383560355073, 94.47383115953468, 361.93302205796255, + 70.13246340443492, 300.9999999999996, 70.00000000000003); + outPath->close(); + outPath->moveTo(300.0, 70.0); + }}, + + // Random long data + {// Path + "M5.3,13.2c-0.1,0.0 -0.3,0.0 -0.4,-0.1c-0.3,-0.2 -0.4,-0.7 -0.2,-1.0c1.3,-1.9 2.9,-3.4 " + "4.9,-4.5c4.1,-2.2 9.3,-2.2 13.4,0.0c1.9,1.1 3.6,2.5 4.9,4.4c0.2,0.3 0.1,0.8 " + "-0.2,1.0c-0.3,0.2 -0.8,0.1 -1.0,-0.2c-1.2,-1.7 -2.6,-3.0 -4.3,-4.0c-3.7,-2.0 -8.3,-2.0 " + "-12.0,0.0c-1.7,0.9 -3.2,2.3 -4.3,4.0C5.7,13.1 5.5,13.2 5.3,13.2z", + { + // Verbs + {'M', 'c', 'c', 'c', 'c', 'c', 'c', 'c', 'c', 'c', 'c', 'C', 'z'}, + // Verb sizes + {2, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 0}, + // Points + {5.3, 13.2, -0.1, 0, -0.3, 0, -0.4, -0.1, -0.3, -0.2, -0.4, -0.7, -0.2, -1, + 1.3, -1.9, 2.9, -3.4, 4.9, -4.5, 4.1, -2.2, 9.3, -2.2, 13.4, 0, 1.9, 1.1, + 3.6, 2.5, 4.9, 4.4, 0.2, 0.3, 0.1, 0.8, -0.2, 1, -0.3, 0.2, -0.8, 0.1, + -1, -0.2, -1.2, -1.7, -2.6, -3, -4.3, -4, -3.7, -2, -8.3, -2, -12, 0, + -1.7, 0.9, -3.2, 2.3, -4.3, 4, 5.7, 13.1, 5.5, 13.2, 5.3, 13.2}, + }, + [](SkPath* outPath) { + outPath->moveTo(5.3, 13.2); + outPath->rCubicTo(-0.1, 0.0, -0.3, 0.0, -0.4, -0.1); + outPath->rCubicTo(-0.3, -0.2, -0.4, -0.7, -0.2, -1.0); + outPath->rCubicTo(1.3, -1.9, 2.9, -3.4, 4.9, -4.5); + outPath->rCubicTo(4.1, -2.2, 9.3, -2.2, 13.4, 0.0); + outPath->rCubicTo(1.9, 1.1, 3.6, 2.5, 4.9, 4.4); + outPath->rCubicTo(0.2, 0.3, 0.1, 0.8, -0.2, 1.0); + outPath->rCubicTo(-0.3, 0.2, -0.8, 0.1, -1.0, -0.2); + outPath->rCubicTo(-1.2, -1.7, -2.6, -3.0, -4.3, -4.0); + outPath->rCubicTo(-3.7, -2.0, -8.3, -2.0, -12.0, 0.0); + outPath->rCubicTo(-1.7, 0.9, -3.2, 2.3, -4.3, 4.0); + outPath->cubicTo(5.7, 13.1, 5.5, 13.2, 5.3, 13.2); + outPath->close(); + outPath->moveTo(5.3, 13.2); + }}, + + // Extreme case with numbers and decimal points crunched together + {// Path + "l0.0.0.5.0.0.5-0.5.0.0-.5z", + { + // Verbs + {'l', 'z'}, + // Verb sizes + {10, 0}, + // Points + {0, 0, 0.5, 0, 0, 0.5, -0.5, 0, 0, -0.5}, + }, + [](SkPath* outPath) { + outPath->rLineTo(0.0, 0.0); + outPath->rLineTo(0.5, 0.0); + outPath->rLineTo(0.0, 0.5); + outPath->rLineTo(-0.5, 0.0); + outPath->rLineTo(0.0, -0.5); + outPath->close(); + outPath->moveTo(0.0, 0.0); + }}, + + // Empty test data + {"", + { + // Verbs + {}, + {}, + {}, + }, + [](SkPath* outPath) {}} }; @@ -231,22 +275,21 @@ struct StringPath { }; const StringPath sStringPaths[] = { - {"3e...3", false}, // Not starting with a verb and ill-formatted float - {"L.M.F.A.O", false}, // No floats following verbs - {"m 1 1", true}, // Valid path data - {"\n \t z", true}, // Valid path data with leading spaces - {"1-2e34567", false}, // Not starting with a verb and ill-formatted float - {"f 4 5", false}, // Invalid verb - {"\r ", false} // Empty string + {"3e...3", false}, // Not starting with a verb and ill-formatted float + {"L.M.F.A.O", false}, // No floats following verbs + {"m 1 1", true}, // Valid path data + {"\n \t z", true}, // Valid path data with leading spaces + {"1-2e34567", false}, // Not starting with a verb and ill-formatted float + {"f 4 5", false}, // Invalid verb + {"\r ", false} // Empty string }; - static bool hasSameVerbs(const PathData& from, const PathData& to) { return from.verbs == to.verbs && from.verbSizes == to.verbSizes; } TEST(PathParser, parseStringForData) { - for (TestData testData: sTestDataSet) { + for (TestData testData : sTestDataSet) { PathParser::ParseResult result; // Test generated path data against the given data. PathData pathData; @@ -259,14 +302,14 @@ TEST(PathParser, parseStringForData) { PathParser::ParseResult result; PathData pathData; SkPath skPath; - PathParser::getPathDataFromAsciiString(&pathData, &result, - stringPath.stringPath, strlen(stringPath.stringPath)); + PathParser::getPathDataFromAsciiString(&pathData, &result, stringPath.stringPath, + strlen(stringPath.stringPath)); EXPECT_EQ(stringPath.isValid, !result.failureOccurred); } } TEST(VectorDrawableUtils, createSkPathFromPathData) { - for (TestData testData: sTestDataSet) { + for (TestData testData : sTestDataSet) { SkPath expectedPath; testData.skPathLamda(&expectedPath); SkPath actualPath; @@ -276,7 +319,7 @@ TEST(VectorDrawableUtils, createSkPathFromPathData) { } TEST(PathParser, parseAsciiStringForSkPath) { - for (TestData testData: sTestDataSet) { + for (TestData testData : sTestDataSet) { PathParser::ParseResult result; size_t length = strlen(testData.pathString); // Check the return value as well as the SkPath generated. @@ -293,14 +336,14 @@ TEST(PathParser, parseAsciiStringForSkPath) { PathParser::ParseResult result; SkPath skPath; PathParser::parseAsciiStringForSkPath(&skPath, &result, stringPath.stringPath, - strlen(stringPath.stringPath)); + strlen(stringPath.stringPath)); EXPECT_EQ(stringPath.isValid, !result.failureOccurred); } } TEST(VectorDrawableUtils, morphPathData) { - for (TestData fromData: sTestDataSet) { - for (TestData toData: sTestDataSet) { + for (TestData fromData : sTestDataSet) { + for (TestData toData : sTestDataSet) { bool canMorph = VectorDrawableUtils::canMorph(fromData.pathData, toData.pathData); if (fromData.pathData == toData.pathData) { EXPECT_TRUE(canMorph); @@ -314,11 +357,11 @@ TEST(VectorDrawableUtils, morphPathData) { TEST(VectorDrawableUtils, interpolatePathData) { // Interpolate path data with itself and every other path data - for (TestData fromData: sTestDataSet) { - for (TestData toData: sTestDataSet) { + for (TestData fromData : sTestDataSet) { + for (TestData toData : sTestDataSet) { PathData outData; bool success = VectorDrawableUtils::interpolatePathData(&outData, fromData.pathData, - toData.pathData, 0.5); + toData.pathData, 0.5); bool expectedToMorph = hasSameVerbs(fromData.pathData, toData.pathData); EXPECT_EQ(expectedToMorph, success); } @@ -335,12 +378,12 @@ TEST(VectorDrawableUtils, interpolatePathData) { PathData outData; // Interpolate the two path data with different fractions for (float fraction : fractions) { - bool success = VectorDrawableUtils::interpolatePathData( - &outData, fromPathData, toPathData, fraction); + bool success = VectorDrawableUtils::interpolatePathData(&outData, fromPathData, + toPathData, fraction); EXPECT_TRUE(success); for (size_t i = 0; i < outData.points.size(); i++) { - float expectedResult = fromPathData.points[i] * (1.0 - fraction) + - toPathData.points[i] * fraction; + float expectedResult = + fromPathData.points[i] * (1.0 - fraction) + toPathData.points[i] * fraction; EXPECT_TRUE(MathUtils::areEqual(expectedResult, outData.points[i])); } } @@ -348,7 +391,7 @@ TEST(VectorDrawableUtils, interpolatePathData) { } TEST(VectorDrawable, groupProperties) { - //TODO: Also need to test property sync and dirty flag when properties change. + // TODO: Also need to test property sync and dirty flag when properties change. VectorDrawable::Group group; VectorDrawable::Group::GroupProperties* properties = group.mutateProperties(); // Test default values, change values through setters and verify the change through getters. @@ -379,7 +422,6 @@ TEST(VectorDrawable, groupProperties) { EXPECT_EQ(0.0f, properties->getPivotY()); properties->setPivotY(1.0f); EXPECT_EQ(1.0f, properties->getPivotY()); - } TEST(VectorDrawable, drawPathWithoutIncrementingShaderRefCount) { @@ -402,5 +444,5 @@ TEST(VectorDrawable, drawPathWithoutIncrementingShaderRefCount) { EXPECT_TRUE(shader->unique()); } -}; // namespace uirenderer -}; // namespace android +}; // namespace uirenderer +}; // namespace android |