OLD | NEW |
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 import 'dart:async'; | 5 import 'dart:async'; |
6 | 6 |
7 import 'package:analysis_server/protocol/protocol_generated.dart'; | 7 import 'package:analysis_server/protocol/protocol_generated.dart'; |
8 import 'package:analyzer_plugin/protocol/protocol_common.dart'; | 8 import 'package:analyzer_plugin/protocol/protocol_common.dart'; |
9 import 'package:test/test.dart'; | 9 import 'package:test/test.dart'; |
10 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 10 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
(...skipping 21 matching lines...) Expand all Loading... |
32 '''; | 32 '''; |
33 | 33 |
34 /** | 34 /** |
35 * Check that an edit.importElements request with the given list of [elements] | 35 * Check that an edit.importElements request with the given list of [elements] |
36 * produces the [expected] list of edits. | 36 * produces the [expected] list of edits. |
37 */ | 37 */ |
38 checkEdits(List<ImportedElements> elements, List<SourceEdit> expected) async { | 38 checkEdits(List<ImportedElements> elements, List<SourceEdit> expected) async { |
39 EditImportElementsResult result = | 39 EditImportElementsResult result = |
40 await sendEditImportElements(pathname, elements); | 40 await sendEditImportElements(pathname, elements); |
41 | 41 |
42 expect(result.edits, hasLength(expected.length)); | 42 SourceFileEdit edit = result.edit; |
| 43 expect(edit, isNotNull); |
| 44 expect(edit.edits, hasLength(expected.length)); |
43 // TODO(brianwilkerson) Finish implementing this. | 45 // TODO(brianwilkerson) Finish implementing this. |
44 } | 46 } |
45 | 47 |
46 /** | 48 /** |
47 * Check that an edit.importElements request with the given list of [elements] | 49 * Check that an edit.importElements request with the given list of [elements] |
48 * produces no edits. | 50 * produces no edits. |
49 */ | 51 */ |
50 Future<Null> checkNoEdits(List<ImportedElements> elements) async { | 52 Future<Null> checkNoEdits(List<ImportedElements> elements) async { |
51 EditImportElementsResult result = | 53 EditImportElementsResult result = |
52 await sendEditImportElements(pathname, <ImportedElements>[]); | 54 await sendEditImportElements(pathname, <ImportedElements>[]); |
53 | 55 |
54 expect(result.edits, hasLength(0)); | 56 SourceFileEdit edit = result.edit; |
| 57 expect(edit, isNotNull); |
| 58 expect(edit.edits, hasLength(0)); |
55 } | 59 } |
56 | 60 |
57 setUp() { | 61 setUp() { |
58 return super.setUp().then((_) { | 62 return super.setUp().then((_) { |
59 pathname = sourcePath('test.dart'); | 63 pathname = sourcePath('test.dart'); |
60 }); | 64 }); |
61 } | 65 } |
62 | 66 |
63 test_getImportedElements_noEdits() async { | 67 test_getImportedElements_noEdits() async { |
64 writeFile(pathname, text); | 68 writeFile(pathname, text); |
65 standardAnalysisSetup(); | 69 standardAnalysisSetup(); |
66 await analysisFinished; | 70 await analysisFinished; |
67 | 71 |
68 List<Future> tests = []; | 72 List<Future> tests = []; |
69 // Test that an empty list of elements produces no edits. | 73 // Test that an empty list of elements produces no edits. |
70 tests.add(checkNoEdits(<ImportedElements>[])); | 74 tests.add(checkNoEdits(<ImportedElements>[])); |
71 return Future.wait(tests); | 75 return Future.wait(tests); |
72 } | 76 } |
73 } | 77 } |
OLD | NEW |