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

Unified Diff: services/dart/dart_apptests/lib/src/file_apptests.dart

Issue 1539843004: Support some file operations in dart:io under mojo (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years 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
« no previous file with comments | « services/dart/dart_apptests/lib/main.dart ('k') | services/files/directory_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/dart/dart_apptests/lib/src/file_apptests.dart
diff --git a/services/dart/dart_apptests/lib/src/file_apptests.dart b/services/dart/dart_apptests/lib/src/file_apptests.dart
new file mode 100644
index 0000000000000000000000000000000000000000..8dd10dad14756365739608e07282873b6a22799a
--- /dev/null
+++ b/services/dart/dart_apptests/lib/src/file_apptests.dart
@@ -0,0 +1,60 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+library file_apptests;
+
+import 'dart:async';
+import 'dart:convert';
+import 'dart:io';
+
+import 'package:mojo_apptest/apptest.dart';
+import 'package:mojo/application.dart';
+import 'package:mojo/bindings.dart';
+import 'package:mojo/core.dart';
+
+tests(Application application, String url) {
+ group('File Apptests', () {
+ test('Absolute path', () async {
+ String current = Directory.current.path;
+ for (String relative in ['abd', '..', '.', 'efg/hij', 'abc/']) {
+ if (current.endsWith('/')) {
+ expect(new File(relative).absolute.path, '$current$relative');
+ } else {
+ expect(new File(relative).absolute.path, '$current/$relative');
+ }
+ expect(new File(relative).absolute.isAbsolute, isTrue);
+ expect(new Directory(relative).absolute.path,
+ new Link(relative).absolute.path);
+ expect(new File(relative).absolute is File, isTrue);
+ expect(new Directory(relative).absolute is Directory, isTrue);
+ expect(new Link(relative).absolute is Link, isTrue);
+ }
+ for (String absolute in ['/abd', '/', '/./..\\', '/efg/hij', '/abc/']) {
+ expect(new File(absolute).absolute.path, absolute);
+ expect(new File(absolute).absolute.isAbsolute, isTrue);
+ }
+ });
+ test('File Constructor', () async {
+ expect(new File('blåbærgrød'), isNotNull);
+ expect(new File('foo.txt'), isNotNull);
+ });
+ test('Directory systemTemp', () async {
+ expect(Directory.systemTemp, isNotNull);
+ });
+ test('Directory create', () async {
+ Directory directory =
+ await Directory.systemTemp.createTemp('dart_directory_test');
+ Directory subDirectory = new Directory("${directory.path}/subdir");
+ expect('$directory'.contains(directory.path), isTrue);
+ expect(await subDirectory.exists(), isFalse);
+ await subDirectory.create();
+ expect(await subDirectory.exists(), isTrue);
+ File f = new File('${subDirectory.path}/file.txt');
+ File fLong = new File('${directory.path}/subdir/../subdir/file.txt');
+ expect(await f.exists(), isFalse);
+ await fLong.create();
+ expect(await f.exists(), isTrue);
+ });
+ });
+}
« no previous file with comments | « services/dart/dart_apptests/lib/main.dart ('k') | services/files/directory_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698