| OLD | NEW |
| 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 analyzer.test.file_system.memory_file_system_test; | 5 library analyzer.test.file_system.memory_file_system_test; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:core'; | 8 import 'dart:core'; |
| 9 | 9 |
| 10 import 'package:analyzer/file_system/file_system.dart'; | 10 import 'package:analyzer/file_system/file_system.dart'; |
| 11 import 'package:analyzer/file_system/memory_file_system.dart'; | 11 import 'package:analyzer/file_system/memory_file_system.dart'; |
| 12 import 'package:analyzer/src/generated/engine.dart' show TimestampedData; | 12 import 'package:analyzer/src/generated/engine.dart' show TimestampedData; |
| 13 import 'package:analyzer/src/generated/source.dart'; | 13 import 'package:analyzer/src/generated/source.dart'; |
| 14 import 'package:analyzer/src/generated/utilities_dart.dart'; | 14 import 'package:analyzer/src/generated/utilities_dart.dart'; |
| 15 import 'package:path/path.dart'; | 15 import 'package:path/path.dart' as pathos; |
| 16 import 'package:test/test.dart'; | 16 import 'package:test/test.dart'; |
| 17 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 17 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| 18 import 'package:watcher/watcher.dart'; | 18 import 'package:watcher/watcher.dart'; |
| 19 | 19 |
| 20 main() { | 20 main() { |
| 21 defineReflectiveSuite(() { | 21 defineReflectiveSuite(() { |
| 22 defineReflectiveTests(FileSystemExceptionTest); | 22 defineReflectiveTests(FileSystemExceptionTest); |
| 23 defineReflectiveTests(FileTest); | 23 defineReflectiveTests(FileTest); |
| 24 defineReflectiveTests(FolderTest); | 24 defineReflectiveTests(FolderTest); |
| 25 defineReflectiveTests(MemoryFileSourceExistingTest); | 25 defineReflectiveTests(MemoryFileSourceExistingTest); |
| (...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 source = file.createSource(); | 457 source = file.createSource(); |
| 458 } | 458 } |
| 459 | 459 |
| 460 void test_contents() { | 460 void test_contents() { |
| 461 TimestampedData<String> contents = source.contents; | 461 TimestampedData<String> contents = source.contents; |
| 462 expect(contents.data, 'library test;'); | 462 expect(contents.data, 'library test;'); |
| 463 } | 463 } |
| 464 | 464 |
| 465 void test_encoding() { | 465 void test_encoding() { |
| 466 String expected = 'file:///foo/test.dart'; | 466 String expected = 'file:///foo/test.dart'; |
| 467 if (provider.pathContext.style == windows.style) { | 467 if (provider.pathContext.style == pathos.windows.style) { |
| 468 expected = 'file:///C:/foo/test.dart'; | 468 expected = 'file:///C:/foo/test.dart'; |
| 469 } | 469 } |
| 470 expect(source.encoding, expected); | 470 expect(source.encoding, expected); |
| 471 } | 471 } |
| 472 | 472 |
| 473 void test_equals_false_differentFile() { | 473 void test_equals_false_differentFile() { |
| 474 File fileA = provider.newFile(provider.convertPath('/foo/a.dart'), ''); | 474 File fileA = provider.newFile(provider.convertPath('/foo/a.dart'), ''); |
| 475 File fileB = provider.newFile(provider.convertPath('/foo/b.dart'), ''); | 475 File fileB = provider.newFile(provider.convertPath('/foo/b.dart'), ''); |
| 476 Source sourceA = fileA.createSource(); | 476 Source sourceA = fileA.createSource(); |
| 477 Source sourceB = fileB.createSource(); | 477 Source sourceB = fileB.createSource(); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 544 } | 544 } |
| 545 | 545 |
| 546 void test_contents() { | 546 void test_contents() { |
| 547 expect(() { | 547 expect(() { |
| 548 source.contents; | 548 source.contents; |
| 549 }, throwsA(_isFileSystemException)); | 549 }, throwsA(_isFileSystemException)); |
| 550 } | 550 } |
| 551 | 551 |
| 552 void test_encoding() { | 552 void test_encoding() { |
| 553 String expected = 'file:///foo/test.dart'; | 553 String expected = 'file:///foo/test.dart'; |
| 554 if (provider.pathContext.style == windows.style) { | 554 if (provider.pathContext.style == pathos.windows.style) { |
| 555 expected = 'file:///C:/foo/test.dart'; | 555 expected = 'file:///C:/foo/test.dart'; |
| 556 } | 556 } |
| 557 expect(source.encoding, expected); | 557 expect(source.encoding, expected); |
| 558 } | 558 } |
| 559 | 559 |
| 560 void test_exists() { | 560 void test_exists() { |
| 561 expect(source.exists(), isFalse); | 561 expect(source.exists(), isFalse); |
| 562 } | 562 } |
| 563 | 563 |
| 564 void test_fullName() { | 564 void test_fullName() { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 609 void test_deleteFile_success() { | 609 void test_deleteFile_success() { |
| 610 String path = provider.convertPath('/my/file'); | 610 String path = provider.convertPath('/my/file'); |
| 611 provider.newFile(path, 'contents'); | 611 provider.newFile(path, 'contents'); |
| 612 Resource file = provider.getResource(path); | 612 Resource file = provider.getResource(path); |
| 613 expect(file, new isInstanceOf<File>()); | 613 expect(file, new isInstanceOf<File>()); |
| 614 expect(file.exists, isTrue); | 614 expect(file.exists, isTrue); |
| 615 provider.deleteFile(path); | 615 provider.deleteFile(path); |
| 616 expect(file.exists, isFalse); | 616 expect(file.exists, isFalse); |
| 617 } | 617 } |
| 618 | 618 |
| 619 test_getModificationTimes() async { | |
| 620 File file = provider.newFile(provider.convertPath('/test.dart'), ''); | |
| 621 Source source = file.createSource(); | |
| 622 List<int> times = await provider.getModificationTimes([source]); | |
| 623 expect(times, [source.modificationStamp]); | |
| 624 } | |
| 625 | |
| 626 test_getFolder_existing() async { | 619 test_getFolder_existing() async { |
| 627 String path = provider.convertPath('/foo/bar'); | 620 String path = provider.convertPath('/foo/bar'); |
| 628 provider.newFolder(path); | 621 provider.newFolder(path); |
| 629 Folder folder = provider.getFolder(path); | 622 Folder folder = provider.getFolder(path); |
| 630 expect(folder, isNotNull); | 623 expect(folder, isNotNull); |
| 631 expect(folder.path, path); | 624 expect(folder.path, path); |
| 632 expect(folder.exists, isTrue); | 625 expect(folder.exists, isTrue); |
| 633 } | 626 } |
| 634 | 627 |
| 635 test_getFolder_notExisting() async { | 628 test_getFolder_notExisting() async { |
| 636 String path = provider.convertPath('/foo/bar'); | 629 String path = provider.convertPath('/foo/bar'); |
| 637 Folder folder = provider.getFolder(path); | 630 Folder folder = provider.getFolder(path); |
| 638 expect(folder, isNotNull); | 631 expect(folder, isNotNull); |
| 639 expect(folder.path, path); | 632 expect(folder.path, path); |
| 640 expect(folder.exists, isFalse); | 633 expect(folder.exists, isFalse); |
| 641 } | 634 } |
| 642 | 635 |
| 636 test_getModificationTimes() async { |
| 637 File file = provider.newFile(provider.convertPath('/test.dart'), ''); |
| 638 Source source = file.createSource(); |
| 639 List<int> times = await provider.getModificationTimes([source]); |
| 640 expect(times, [source.modificationStamp]); |
| 641 } |
| 642 |
| 643 void test_getStateLocation_uniqueness() { | 643 void test_getStateLocation_uniqueness() { |
| 644 String idOne = 'one'; | 644 String idOne = 'one'; |
| 645 Folder folderOne = provider.getStateLocation(idOne); | 645 Folder folderOne = provider.getStateLocation(idOne); |
| 646 expect(folderOne, isNotNull); | 646 expect(folderOne, isNotNull); |
| 647 String idTwo = 'two'; | 647 String idTwo = 'two'; |
| 648 Folder folderTwo = provider.getStateLocation(idTwo); | 648 Folder folderTwo = provider.getStateLocation(idTwo); |
| 649 expect(folderTwo, isNotNull); | 649 expect(folderTwo, isNotNull); |
| 650 expect(folderTwo, isNot(equals(folderOne))); | 650 expect(folderTwo, isNot(equals(folderOne))); |
| 651 expect(provider.getStateLocation(idOne), equals(folderOne)); | 651 expect(provider.getStateLocation(idOne), equals(folderOne)); |
| 652 } | 652 } |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 786 return new Future.delayed(Duration.ZERO, computation); | 786 return new Future.delayed(Duration.ZERO, computation); |
| 787 } | 787 } |
| 788 | 788 |
| 789 _watchingFolder(String path, test(List<WatchEvent> changesReceived)) { | 789 _watchingFolder(String path, test(List<WatchEvent> changesReceived)) { |
| 790 Folder folder = provider.getResource(path); | 790 Folder folder = provider.getResource(path); |
| 791 var changesReceived = <WatchEvent>[]; | 791 var changesReceived = <WatchEvent>[]; |
| 792 folder.changes.listen(changesReceived.add); | 792 folder.changes.listen(changesReceived.add); |
| 793 return test(changesReceived); | 793 return test(changesReceived); |
| 794 } | 794 } |
| 795 } | 795 } |
| OLD | NEW |