| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * A simple unit test library for running tests inside the DARTest In-App test | 6 * A simple unit test library for running tests inside the DARTest In-App test |
| 7 * runner along side the application under test in a browser. | 7 * runner along side the application under test in a browser. |
| 8 */ | 8 */ |
| 9 #library("unittest"); | 9 #library("unittest"); |
| 10 | 10 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 Function updateUI = null; | 24 Function updateUI = null; |
| 25 | 25 |
| 26 Function dartestLogger = null; | 26 Function dartestLogger = null; |
| 27 | 27 |
| 28 _platformDefer(void callback()) { | 28 _platformDefer(void callback()) { |
| 29 _testRunner = runDartests; | 29 _testRunner = runDartests; |
| 30 // DARTest ignores the callback. Tests are launched from UI. | 30 // DARTest ignores the callback. Tests are launched from UI. |
| 31 } | 31 } |
| 32 | 32 |
| 33 // Update test results | 33 // Update test results |
| 34 updateTestStats(TestCase test) { | 34 updateTestStats(TestCase test_) { |
| 35 assert(test.result != null); | 35 assert(test_.result != null); |
| 36 if(test.startTime != null) { | 36 if(test_.startTime != null) { |
| 37 test.runningTime = (new Date.now()).difference(test.startTime); | 37 test_.runningTime = (new Date.now()).difference(test_.startTime); |
| 38 } | 38 } |
| 39 testsRun++; | 39 testsRun++; |
| 40 switch (test.result) { | 40 switch (test_.result) { |
| 41 case 'fail': testsFailed++; break; | 41 case 'fail': testsFailed++; break; |
| 42 case 'error': testsErrors++; break; | 42 case 'error': testsErrors++; break; |
| 43 } | 43 } |
| 44 updateUI(test); | 44 updateUI(test_); |
| 45 } | 45 } |
| 46 | 46 |
| 47 // Run tests sequentially | 47 // Run tests sequentially |
| 48 runDartests() { | 48 runDartests() { |
| 49 if(previousAsyncTest) { | 49 if(previousAsyncTest) { |
| 50 updateTestStats(_tests[_currentTest - 1]); | 50 updateTestStats(_tests[_currentTest - 1]); |
| 51 previousAsyncTest = false; | 51 previousAsyncTest = false; |
| 52 } | 52 } |
| 53 if(_currentTest < _tests.length) { | 53 if(_currentTest < _tests.length) { |
| 54 final testCase = _tests[_currentTest]; | 54 final testCase = _tests[_currentTest]; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 67 | 67 |
| 68 _platformStartTests() { | 68 _platformStartTests() { |
| 69 // TODO(shauvik): Support for VM and command line coming soon! | 69 // TODO(shauvik): Support for VM and command line coming soon! |
| 70 window.console.log("Warning: Running DARTest from VM or Command-line."); | 70 window.console.log("Warning: Running DARTest from VM or Command-line."); |
| 71 } | 71 } |
| 72 | 72 |
| 73 _platformInitialize() { | 73 _platformInitialize() { |
| 74 // Do nothing | 74 // Do nothing |
| 75 } | 75 } |
| 76 | 76 |
| 77 _platformCompleteTests(int testsPassed, int testsFailed, int testsErrors) { | 77 _platformCompleteTests(int testsPassed_, int testsFailed_, int testsErrors_) { |
| 78 // Do nothing | 78 // Do nothing |
| 79 } | 79 } |
| 80 | 80 |
| 81 String getTestResultsCsv() { | 81 String getTestResultsCsv() { |
| 82 StringBuffer out = new StringBuffer(); | 82 StringBuffer out = new StringBuffer(); |
| 83 _tests.forEach((final test) { | 83 _tests.forEach((final test_) { |
| 84 String result = 'none'; | 84 String result = 'none'; |
| 85 if(test.result != null) { | 85 if(test_.result != null) { |
| 86 result = test.result.toUpperCase(); | 86 result = test_.result.toUpperCase(); |
| 87 } | 87 } |
| 88 out.add('${test.id}, "${test.description}", $result\n'); | 88 out.add('${test_.id}, "${test_.description}", $result\n'); |
| 89 }); | 89 }); |
| 90 return out.toString(); | 90 return out.toString(); |
| 91 } | 91 } |
| OLD | NEW |