From 952da3de677c212306d712bedee440a24b0069aa Mon Sep 17 00:00:00 2001 From: Val Erastov Date: Tue, 24 Feb 2015 01:03:14 -0800 Subject: [PATCH] testing framework --- web/app/test/fixtures.js | 2 ++ web/app/test/suite.js | 25 +++++++++++++++++++++++++ web/app/test/testCases.js | 5 +++++ web/test.html | 18 ++++++++++++------ 4 files changed, 44 insertions(+), 6 deletions(-) create mode 100644 web/app/test/fixtures.js create mode 100644 web/app/test/suite.js create mode 100644 web/app/test/testCases.js diff --git a/web/app/test/fixtures.js b/web/app/test/fixtures.js new file mode 100644 index 00000000..2958552e --- /dev/null +++ b/web/app/test/fixtures.js @@ -0,0 +1,2 @@ +TCAD.test.fixtures = {}; +TCAD.test.fixtures.RoundRect = {"layers":[{"name":"_dim","data":[]},{"name":"default","data":[{"id":6,"_class":"TCAD.TWO.Segment","points":[[0,[1,266.5634479999531],[2,794.5807272294047]],[3,[4,776.6236240728185],[5,794.5807272294039]]]},{"id":13,"_class":"TCAD.TWO.Segment","points":[[7,[8,927.2879843119589],[9,643.9224734815724]],[10,[11,927.2879843120583],[12,174.51664392112346]]]},{"id":20,"_class":"TCAD.TWO.Segment","points":[[14,[15,266.5475645170609],[16,23.8639268074262]],[17,[18,776.6354356426971],[19,23.863926807460135]]]},{"id":27,"_class":"TCAD.TWO.Segment","points":[[21,[22,115.90857396213624],[23,643.9003106222236]],[24,[25,115.90857396213619],[26,174.4837595347564]]]},{"id":37,"_class":"TCAD.TWO.Arc","points":[[28,[29,927.2879843119588],[30,643.9224734815724]],[31,[32,776.6236240728185],[33,794.5807272294043]],[34,[35,776.6353054124875],[36,643.9280483299306]]]},{"id":48,"_class":"TCAD.TWO.Arc","points":[[39,[40,266.5634479999531],[41,794.5807272294056]],[42,[43,115.90857396213616],[44,643.9003106222236]],[45,[46,266.5612528616091],[47,643.9280483299286]]]},{"id":59,"_class":"TCAD.TWO.Arc","points":[[50,[51,115.90857396213627],[52,174.4837595347564]],[53,[54,266.5475645170609],[55,23.86392680742626]],[56,[57,266.56125286160903],[58,174.5166057068994]]]},{"id":70,"_class":"TCAD.TWO.Arc","points":[[61,[62,776.6354356426971],[63,23.863926807393575]],[64,[65,927.2879843118895],[66,174.51664392112346]],[67,[68,776.635305412442],[69,174.5166057068957]]]}]}],"constraints":[["coi",[0,39]],["coi",[42,21]],["coi",[24,50]],["coi",[53,14]],["coi",[17,61]],["coi",[64,10]],["coi",[28,7]],["coi",[31,3]],["Horizontal",[6]],["Horizontal",[20]],["Vertical",[13]],["Vertical",[27]],["Tangent",[48,6]],["Tangent",[37,6]],["Tangent",[37,13]],["Tangent",[70,13]],["Tangent",[70,20]],["Tangent",[59,20]],["Tangent",[59,27]],["Tangent",[48,27]],["RR",[37,48]],["RR",[48,59]],["RR",[59,70]]]} diff --git a/web/app/test/suite.js b/web/app/test/suite.js new file mode 100644 index 00000000..c4a3b982 --- /dev/null +++ b/web/app/test/suite.js @@ -0,0 +1,25 @@ +TCAD.test = {}; +TCAD.test.cases = {}; + +TCAD.test.runSuite = function() { + for (var p in TCAD.test.cases) { + _log("... Run test " + p); + TCAD.test.cases[p].apply(); + } + _log("DONE."); +}; + +function _log(text) { + $('#testOutput').append("
"+text+"
"); +}; + +_loadFixture = function(name) { + THE_APP.loadSketch(TCAD.test.fixtures[name]); +}; + +_assertEq = function(expected, actual, msg) { + if (expected !== actual) { + _log("* Assertion Error. Expected [" + expected + "], but was [" + actual + "]"); + if (!!msg) _log(msg); + } +}; diff --git a/web/app/test/testCases.js b/web/app/test/testCases.js new file mode 100644 index 00000000..3926d375 --- /dev/null +++ b/web/app/test/testCases.js @@ -0,0 +1,5 @@ + +TCAD.test.cases.roundRect = function() { + _loadFixture("RoundRect"); + _assertEq(31, THE_APP.viewer.parametricManager.system.length); +}; \ No newline at end of file diff --git a/web/test.html b/web/test.html index ae65dc57..87eff207 100644 --- a/web/test.html +++ b/web/test.html @@ -6,15 +6,15 @@ @@ -44,10 +44,15 @@ - + + + + + - -
+ +

TEST RESULTS

+
\ No newline at end of file