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

Side by Side Diff: pkg/analysis_server/test/resource_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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 library test.resource; 5 library test.resource;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/src/resource.dart'; 9 import 'package:analysis_server/src/resource.dart';
10 import 'package:analyzer/src/generated/engine.dart' show TimestampedData; 10 import 'package:analyzer/src/generated/engine.dart' show TimestampedData;
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 252
253 test('shortName', () { 253 test('shortName', () {
254 File file = provider.getResource('/foo/bar/file.txt'); 254 File file = provider.getResource('/foo/bar/file.txt');
255 expect(file.shortName, 'file.txt'); 255 expect(file.shortName, 'file.txt');
256 }); 256 });
257 257
258 test('toString', () { 258 test('toString', () {
259 File file = provider.getResource('/foo/bar/file.txt'); 259 File file = provider.getResource('/foo/bar/file.txt');
260 expect(file.toString(), '/foo/bar/file.txt'); 260 expect(file.toString(), '/foo/bar/file.txt');
261 }); 261 });
262
263 test('parent', () {
264 provider.newFile('/foo/bar/file.txt', 'content');
265 File file = provider.getResource('/foo/bar/file.txt');
266 Resource parent = file.parent;
267 expect(parent, new isInstanceOf<Folder>());
268 expect(parent.path, equals('/foo/bar'));
269 });
262 }); 270 });
263 271
264 group('Folder', () { 272 group('Folder', () {
265 Folder folder; 273 Folder folder;
266 274
267 setUp(() { 275 setUp(() {
268 folder = provider.newFolder('/foo/bar'); 276 folder = provider.newFolder('/foo/bar');
269 }); 277 });
270 278
271 group('getChild', () { 279 group('getChild', () {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 }); 312 });
305 // check names 313 // check names
306 expect(children[0].shortName, 'a.txt'); 314 expect(children[0].shortName, 'a.txt');
307 expect(children[1].shortName, 'bFolder'); 315 expect(children[1].shortName, 'bFolder');
308 expect(children[2].shortName, 'c.txt'); 316 expect(children[2].shortName, 'c.txt');
309 // check types 317 // check types
310 expect(children[0], _isFile); 318 expect(children[0], _isFile);
311 expect(children[1], _isFolder); 319 expect(children[1], _isFolder);
312 expect(children[2], _isFile); 320 expect(children[2], _isFile);
313 }); 321 });
322
323 test('parent', () {
324 Resource parent1 = folder.parent;
325 expect(parent1, new isInstanceOf<Folder>());
326 expect(parent1.path, equals('/foo'));
327 Resource parent2 = parent1.parent;
328 expect(parent2, new isInstanceOf<Folder>());
329 expect(parent2.path, equals('/'));
330 expect(parent2.parent, isNull);
331 });
314 }); 332 });
315 333
316 group('_MemoryFileSource', () { 334 group('_MemoryFileSource', () {
317 Source source; 335 Source source;
318 336
319 group('existent', () { 337 group('existent', () {
320 setUp(() { 338 setUp(() {
321 File file = provider.newFile('/foo/test.dart', 'library test;'); 339 File file = provider.newFile('/foo/test.dart', 'library test;');
322 source = file.createSource(UriKind.FILE_URI); 340 source = file.createSource(UriKind.FILE_URI);
323 }); 341 });
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 expect(source, isNull); 486 expect(source, isNull);
469 }); 487 });
470 488
471 test('not a file URI', () { 489 test('not a file URI', () {
472 var uri = new Uri(scheme: 'https', path: '127.0.0.1/test.dart'); 490 var uri = new Uri(scheme: 'https', path: '127.0.0.1/test.dart');
473 Source source = resolver.resolveAbsolute(uri); 491 Source source = resolver.resolveAbsolute(uri);
474 expect(source, isNull); 492 expect(source, isNull);
475 }); 493 });
476 }); 494 });
477 } 495 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698