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

Unified Diff: pkg/analysis_server/test/physical_resource_provider_test.dart

Issue 355453005: Add a Resource.parent getter, which gets the parent directory. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 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: pkg/analysis_server/test/physical_resource_provider_test.dart
diff --git a/pkg/analysis_server/test/physical_resource_provider_test.dart b/pkg/analysis_server/test/physical_resource_provider_test.dart
index 63f0a0d484941cdc82e10ff5d2a083f93b74d52d..e16fb82fe4c39994dd6aded9d1690c56993ba402 100644
--- a/pkg/analysis_server/test/physical_resource_provider_test.dart
+++ b/pkg/analysis_server/test/physical_resource_provider_test.dart
@@ -160,6 +160,12 @@ main() {
test('toString', () {
expect(file.toString(), path);
});
+
+ test('parent', () {
+ Resource parent = file.parent;
+ expect(parent, new isInstanceOf<Folder>());
+ expect(parent.path, equals(tempPath));
+ });
});
group('Folder', () {
@@ -216,6 +222,26 @@ main() {
expect(children[1], _isFolder);
expect(children[2], _isFile);
});
+
+ test('parent', () {
+ Resource parent = folder.parent;
+ expect(parent, new isInstanceOf<Folder>());
+ expect(parent.path, equals(tempPath));
+
+ // Since the OS is in control of where tempPath is, we don't know how
+ // far it should be from the root. So just verify that each call to
+ // parent results in a a folder with a shorter path, and that we
+ // reach the root eventually.
+ while (true) {
+ Resource grandParent = parent.parent;
+ if (grandParent == null) {
+ break;
+ }
+ expect(grandParent, new isInstanceOf<Folder>());
+ expect(grandParent.path.length, lessThan(parent.path.length));
+ parent = grandParent;
+ }
+ });
});
});
}

Powered by Google App Engine
This is Rietveld 408576698