OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
8 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; | 8 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; |
9 import 'package:analyzer/dart/element/element.dart'; | 9 import 'package:analyzer/dart/element/element.dart'; |
10 import 'package:analyzer/dart/element/type.dart'; | 10 import 'package:analyzer/dart/element/type.dart'; |
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
555 | 555 |
556 test_cachedPriorityResults() async { | 556 test_cachedPriorityResults() async { |
557 var a = _p('/test/bin/a.dart'); | 557 var a = _p('/test/bin/a.dart'); |
558 provider.newFile(a, 'var a = 1;'); | 558 provider.newFile(a, 'var a = 1;'); |
559 | 559 |
560 driver.priorityFiles = [a]; | 560 driver.priorityFiles = [a]; |
561 | 561 |
562 AnalysisResult result1 = await driver.getResult(a); | 562 AnalysisResult result1 = await driver.getResult(a); |
563 expect(driver.test.priorityResults, containsPair(a, result1)); | 563 expect(driver.test.priorityResults, containsPair(a, result1)); |
564 | 564 |
565 AnalysisResult result2 = await driver.getResult(a); | 565 await scheduler.waitForIdle(); |
566 expect(result2, same(result1)); | 566 allResults.clear(); |
| 567 |
| 568 // Get the (cached) result, not reported to the stream. |
| 569 { |
| 570 AnalysisResult result2 = await driver.getResult(a); |
| 571 expect(result2, same(result1)); |
| 572 expect(allResults, isEmpty); |
| 573 } |
| 574 |
| 575 // Get the (cached) result, reported to the stream. |
| 576 { |
| 577 AnalysisResult result2 = |
| 578 await driver.getResult(a, sendCachedToStream: true); |
| 579 expect(result2, same(result1)); |
| 580 |
| 581 expect(allResults, hasLength(1)); |
| 582 expect(allResults.single, same(result1)); |
| 583 } |
567 } | 584 } |
568 | 585 |
569 test_cachedPriorityResults_flush_onAnyFileChange() async { | 586 test_cachedPriorityResults_flush_onAnyFileChange() async { |
570 var a = _p('/test/bin/a.dart'); | 587 var a = _p('/test/bin/a.dart'); |
571 var b = _p('/test/bin/b.dart'); | 588 var b = _p('/test/bin/b.dart'); |
572 provider.newFile(a, 'var a = 1;'); | 589 provider.newFile(a, 'var a = 1;'); |
573 provider.newFile(a, 'var b = 2;'); | 590 provider.newFile(a, 'var b = 2;'); |
574 | 591 |
575 driver.priorityFiles = [a]; | 592 driver.priorityFiles = [a]; |
576 | 593 |
(...skipping 2148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2725 var path = _p('/test.dart'); | 2742 var path = _p('/test.dart'); |
2726 expect(() { | 2743 expect(() { |
2727 driver.removeFile(path); | 2744 driver.removeFile(path); |
2728 }, throwsStateError); | 2745 }, throwsStateError); |
2729 } | 2746 } |
2730 | 2747 |
2731 String _p(String path) => provider.convertPath(path); | 2748 String _p(String path) => provider.convertPath(path); |
2732 } | 2749 } |
2733 | 2750 |
2734 class _SourceMock extends TypedMock implements Source {} | 2751 class _SourceMock extends TypedMock implements Source {} |
OLD | NEW |