From 357f7a8acdc4c1fbfaab8c238c62db11a041d0d8 Mon Sep 17 00:00:00 2001 From: Robert Konigsberg Date: Wed, 28 Dec 2011 20:17:44 -0500 Subject: [PATCH] Add local test selector. SOO MUCH BETTER. --- auto_tests/misc/fake-jstestdriver.js | 35 +++++++++++++++++------- auto_tests/misc/local.html | 50 ++++++++++++++++++++++++++++++++++- auto_tests/tests/interaction_model.js | 3 +++ 3 files changed, 77 insertions(+), 11 deletions(-) diff --git a/auto_tests/misc/fake-jstestdriver.js b/auto_tests/misc/fake-jstestdriver.js index 4a9b0ea..92147ca 100644 --- a/auto_tests/misc/fake-jstestdriver.js +++ b/auto_tests/misc/fake-jstestdriver.js @@ -39,12 +39,12 @@ var jstd = { var testCaseList = []; function TestCase(name) { - this.name = name; - this.toString = function() { + var testCase = function() { return this; }; + testCase.name = name; + testCase.toString = function() { return "Fake test case " + name; }; - var testCase = function() { return this; }; testCase.prototype.setUp = function() { }; testCase.prototype.tearDown = function() { }; /** @@ -87,17 +87,28 @@ function TestCase(name) { testCase.prototype.runAllTests = function() { // what's better than for ... in for non-array objects? var tests = {}; + var names = this.getTestNames(); + for (var idx in names) { + var name = names[idx]; + console.log("Running " + name); + var result = this.runTest(name); + tests[name] = result; + } + console.log(prettyPrintEntity_(tests)); + }; + + testCase.prototype.getTestNames = function() { + // what's better than for ... in for non-array objects? + var tests = []; for (var name in this) { if (name.indexOf('test') == 0 && typeof(this[name]) == 'function') { - console.log("Running " + name); - var result = this.runTest(name); - tests[name] = result; + tests.push(name); } } - console.log(prettyPrintEntity_(tests)); - }; + return tests; + } - testCaseList.push(testCase); + testCaseList.push({name : name, testCase : testCase}); return testCase; }; @@ -107,7 +118,7 @@ function addGlobalTestSymbols() { var num_tests = 0; for (var i = 0; i < testCaseList.length; i++) { - var tc_class = testCaseList[i]; + var tc_class = testCaseList[i].testCase; for (var name in tc_class.prototype) { if (name.indexOf('test') == 0 && typeof(tc_class.prototype[name]) == 'function') { if (globalTestDb.hasOwnProperty(name)) { @@ -128,3 +139,7 @@ function addGlobalTestSymbols() { console.log('Loaded ' + num_tests + ' tests in ' + testCaseList.length + ' test cases'); } + +function getAllTestCases() { + return testCaseList; +} diff --git a/auto_tests/misc/local.html b/auto_tests/misc/local.html index 243e513..05b6cf2 100644 --- a/auto_tests/misc/local.html +++ b/auto_tests/misc/local.html @@ -58,8 +58,20 @@ var test = args.test; var command = args.command; - if (args.testCase) { + if (args.testCaseName) { + var testCases = getAllTestCases(); + for (var idx in testCases) { + var entry = testCases[idx]; + if (entry.name == args.testCaseName) { + var prototype = entry.testCase; + tc = new entry.testCase(); + break; + } + } + } else if (args.testCase) { eval("tc = new " + args.testCase + "()"); + } + if (tc != null) { if (args.command) { if (args.command == "runAllTests") { console.log("Running all tests for " + args.testCase); @@ -87,9 +99,45 @@
  • command - either runTest or runAllTests. Example: local.html?testCase=ScrollingDivTestCase&test=testNestedDiv_Scrolled&command=runTest +

    +

    diff --git a/auto_tests/tests/interaction_model.js b/auto_tests/tests/interaction_model.js index a363f55..b68825a 100644 --- a/auto_tests/tests/interaction_model.js +++ b/auto_tests/tests/interaction_model.js @@ -242,3 +242,6 @@ InteractionModelTestCase.prototype.testClickCallback_clickOnPoint = function() { assertEquals(1, clicked); }; +InteractionModelTestCase.prototype.testIsZoomed_1 = function() { +}; + -- 2.7.4