Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1010)

Unified Diff: samples/third_party/dromaeo/web/tests/RunnerSuite.dart

Issue 1576153002: Remove the Dromaeo and TodoMVC samples. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: samples/third_party/dromaeo/web/tests/RunnerSuite.dart
diff --git a/samples/third_party/dromaeo/web/tests/RunnerSuite.dart b/samples/third_party/dromaeo/web/tests/RunnerSuite.dart
deleted file mode 100644
index e1e0945e3cadc9a07c0eb2d5365f359ba1e26ec4..0000000000000000000000000000000000000000
--- a/samples/third_party/dromaeo/web/tests/RunnerSuite.dart
+++ /dev/null
@@ -1,132 +0,0 @@
-part of dromaeo;
-
-typedef void Test();
-typedef void Operation();
-typedef void Reporter(Map<String, Result> results);
-
-class Suite {
- /**
- * Ctor.
- * [:_window:] The window of the suite.
- * [:_name:] The name of the suite.
- */
- Suite(this._window, this._name) :
- _operations = new List<Operation>(),
- _nTests = 0, _nRanTests = 0 {
- starter(MessageEvent event) {
- String command = event.data;
- switch (command) {
- case 'start':
- _run();
- return;
- default:
- _window.alert('[${_name}]: unknown command ${command}');
- }
- };
- _window.onMessage.listen(starter);
- }
-
- /**
- * Adds a preparation step to the suite.
- * [:operation:] The operation to be performed.
- */
- Suite prep(Operation operation){
- return _addOperation(operation);
- }
-
- // How many times each individual test should be ran.
- static const int _N_RUNS = 5;
-
- /**
- * Adds another test to the suite.
- * [:name:] The unique name of the test
- * [:test:] A function holding the test to run
- */
- Suite test(String name, Test test_) {
- _nTests++;
- // Don't execute the test immediately.
- return _addOperation(() {
- // List of number of runs in seconds.
- List<double> runsPerSecond = new List<double>();
-
- // Run the test several times.
- try {
- // TODO(antonm): use timer to schedule next run as JS
- // version does. That allows to report the intermidiate results
- // more smoothly as well.
- for (int i = 0; i < _N_RUNS; i++) {
- int runs = 0;
- final int start = new DateTime.now().millisecondsSinceEpoch;
-
- int cur = new DateTime.now().millisecondsSinceEpoch;
- while ((cur - start) < 1000) {
- test_();
- cur = new DateTime.now().millisecondsSinceEpoch;
- runs++;
- }
-
- runsPerSecond.add((runs * 1000.0) / (cur - start));
- }
- } catch (exception, stacktrace) {
- _window.alert('Exception ${exception}: ${stacktrace}');
- return;
- }
- _reportTestResults(name, new Result(runsPerSecond));
- });
- }
-
- /**
- * Finalizes the suite.
- * It might either run the tests immediately or schedule them to be ran later.
- */
- void end() {
- _postMessage('inited', { 'nTests': _nTests });
-
- }
-
- _run() {
- int currentOperation = 0;
- handler() {
- if (currentOperation < _operations.length) {
- _operations[currentOperation]();
- currentOperation++;
- new Timer(const Duration(milliseconds: 1), handler);
- } else {
- _postMessage('over');
- }
- }
- Timer.run(handler);
- }
-
- _reportTestResults(String name, Result result) {
- _nRanTests++;
- _postMessage('result', {
- 'testName': name,
- 'mean': result.mean,
- 'error': result.error,
- 'percent': (100.0 * _nRanTests / _nTests)
- });
- }
-
- _postMessage(String command, [var data = null]) {
- final payload = { 'command': command };
- if (data != null) {
- payload['data'] = data;
- }
- _window.parent.postMessage(JSON.encode(payload), '*');
- }
-
- // Implementation.
-
- final Window _window;
- final String _name;
-
- List<Operation> _operations;
- int _nTests;
- int _nRanTests;
-
- Suite _addOperation(Operation operation) {
- _operations.add(operation);
- return this;
- }
-}
« no previous file with comments | « samples/third_party/dromaeo/web/tests/Common.dart ('k') | samples/third_party/dromaeo/web/tests/dom-attr.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698