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

Unified Diff: tools/dom/docs/test/docs_test.dart

Issue 13000005: Added tests for docs.dart (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 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: tools/dom/docs/test/docs_test.dart
diff --git a/tools/dom/docs/test/docs_test.dart b/tools/dom/docs/test/docs_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..5d8c283fe25771e5a9c61bd512a833375c163e6f
--- /dev/null
+++ b/tools/dom/docs/test/docs_test.dart
@@ -0,0 +1,57 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library docs_test;
+
+import 'dart:io';
+
+import '../../../../pkg/unittest/lib/unittest.dart';
+
+import '../bin/docs.dart';
+import '../lib/docs.dart';
+
+final Path test_json_path = scriptDir.append('test.json').canonicalize();
Bob Nystrom 2013/03/28 14:18:40 Camel-case "testJsonPath" and others. This isn't p
Andrei Mouravski 2013/03/28 17:01:14 Done.
+
+main() {
+ test('Ensure that docs.json is up to date', () {
+ var oldJson = new File.fromPath(json_path);
+ var testJson = new File.fromPath(test_json_path);
+
+ // We should find a json file where we expect it.
+ expect(oldJson.existsSync(), isTrue);
+
+ // Save the last modified time to check it at the end.
+ var oldJsonModified = oldJson.lastModifiedSync();
+
+ // There should be no test file yet.
+ if (testJson.existsSync()) {
+ testJson.deleteSync();
+ }
Bob Nystrom 2013/03/28 14:18:40 You can make this a one-line if if you want.
Andrei Mouravski 2013/03/28 17:01:14 Done.
+ expect(testJson.existsSync(), isFalse);
+
+ expect(
+ convert(lib_path, test_json_path)
+ .then((bool anyErrors) {
Bob Nystrom 2013/03/28 14:18:40 We still don't have an ideal style for code like t
Andrei Mouravski 2013/03/28 17:01:14 Will defer because I'm not that concerned about th
+ expect(anyErrors, isFalse);
+ oldJson = new File.fromPath(json_path);
+ testJson = new File.fromPath(test_json_path);
Bob Nystrom 2013/03/28 14:18:40 Are these needed?
Andrei Mouravski 2013/03/28 17:01:14 Done.
+
+ // We should have a file now.
+ expect(testJson.existsSync(), isTrue);
+
+ // Ensure that there's nothing different between the new JSON and old.
+ expect(testJson.readAsLinesSync(), equals(oldJson.readAsLinesSync()));
Bob Nystrom 2013/03/28 14:18:40 Nit, but I would probably do readAsStringSync().
Andrei Mouravski 2013/03/28 17:01:14 Done.
+
+ // Ensure that the old JSON file didn't actually change.
+ expect(oldJsonModified, equals(oldJson.lastModifiedSync()));
+
+ // Clean up.
+ if (testJson.existsSync()) {
+ testJson.deleteSync();
+ }
+ expect(testJson.existsSync(), isFalse);
+ return false;
Bob Nystrom 2013/03/28 14:18:40 You don't use the completion value, so just remove
Andrei Mouravski 2013/03/28 17:01:14 Done.
+ }), completes);
+ });
+}

Powered by Google App Engine
This is Rietveld 408576698