| 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 test.analysis.notification.analyzedDirectories; | |
| 6 | |
| 7 import 'dart:async'; | 5 import 'dart:async'; |
| 8 | 6 |
| 9 import 'package:analysis_server/protocol/protocol.dart'; | 7 import 'package:analysis_server/protocol/protocol.dart'; |
| 10 import 'package:analysis_server/protocol/protocol_generated.dart'; | 8 import 'package:analysis_server/protocol/protocol_generated.dart'; |
| 11 import 'package:analysis_server/src/constants.dart'; | 9 import 'package:analysis_server/src/constants.dart'; |
| 12 import 'package:test/test.dart'; | 10 import 'package:test/test.dart'; |
| 13 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 11 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| 14 | 12 |
| 15 import '../analysis_abstract.dart'; | 13 import '../analysis_abstract.dart'; |
| 16 import '../mocks.dart'; | 14 import '../mocks.dart'; |
| 17 | 15 |
| 18 main() { | 16 main() { |
| 19 defineReflectiveSuite(() { | 17 defineReflectiveSuite(() { |
| 20 defineReflectiveTests(AnalysisNotificationAnalyzedFilesTest); | 18 defineReflectiveTests(AnalysisNotificationAnalyzedFilesTest); |
| 21 defineReflectiveTests(AnalysisNotificationAnalyzedFilesTest_Driver); | |
| 22 }); | 19 }); |
| 23 } | 20 } |
| 24 | 21 |
| 25 @reflectiveTest | 22 @reflectiveTest |
| 26 class AnalysisNotificationAnalyzedFilesTest extends AbstractAnalysisTest { | 23 class AnalysisNotificationAnalyzedFilesTest extends AbstractAnalysisTest { |
| 27 List<String> analyzedFiles; | 24 List<String> analyzedFiles; |
| 28 bool analyzedFilesReceived = false; | 25 bool analyzedFilesReceived = false; |
| 29 | 26 |
| 30 void assertHasFile(String filePath) { | 27 void assertHasFile(String filePath) { |
| 31 expect(analyzedFilesReceived, isTrue); | 28 expect(analyzedFilesReceived, isTrue); |
| 32 expect(analyzedFiles, contains(filePath)); | 29 expect(analyzedFiles, contains(filePath)); |
| 33 } | 30 } |
| 34 | 31 |
| 35 Future<Null> prepareAnalyzedFiles() async { | 32 Future<Null> prepareAnalyzedFiles() async { |
| 36 addGeneralAnalysisSubscription(GeneralAnalysisService.ANALYZED_FILES); | 33 addGeneralAnalysisSubscription(GeneralAnalysisService.ANALYZED_FILES); |
| 37 await pumpEventQueue(); | 34 await pumpEventQueue(); |
| 38 } | 35 } |
| 39 | 36 |
| 40 void processNotification(Notification notification) { | 37 void processNotification(Notification notification) { |
| 41 if (notification.event == ANALYSIS_ANALYZED_FILES) { | 38 if (notification.event == ANALYSIS_ANALYZED_FILES) { |
| 42 AnalysisAnalyzedFilesParams params = | 39 AnalysisAnalyzedFilesParams params = |
| 43 new AnalysisAnalyzedFilesParams.fromNotification(notification); | 40 new AnalysisAnalyzedFilesParams.fromNotification(notification); |
| 44 analyzedFilesReceived = true; | 41 analyzedFilesReceived = true; |
| 45 analyzedFiles = params.directories; | 42 analyzedFiles = params.directories; |
| 46 } | 43 } |
| 47 } | 44 } |
| 48 | 45 |
| 49 void setUp() { | 46 void setUp() { |
| 47 enableNewAnalysisDriver = true; |
| 48 generateSummaryFiles = true; |
| 50 super.setUp(); | 49 super.setUp(); |
| 51 createProject(); | 50 createProject(); |
| 52 } | 51 } |
| 53 | 52 |
| 54 test_afterAnalysis() async { | 53 test_afterAnalysis() async { |
| 55 addTestFile(''' | 54 addTestFile(''' |
| 56 class A {} | 55 class A {} |
| 57 '''); | 56 '''); |
| 58 await waitForTasksFinished(); | 57 await waitForTasksFinished(); |
| 59 await prepareAnalyzedFiles(); | 58 await prepareAnalyzedFiles(); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 analyzedFilesReceived = false; | 106 analyzedFilesReceived = false; |
| 108 modifyTestFile('import "/foo.dart";'); | 107 modifyTestFile('import "/foo.dart";'); |
| 109 await prepareAnalyzedFiles(); | 108 await prepareAnalyzedFiles(); |
| 110 assertHasFile('/foo.dart'); | 109 assertHasFile('/foo.dart'); |
| 111 } | 110 } |
| 112 | 111 |
| 113 void unsubscribeAnalyzedFiles() { | 112 void unsubscribeAnalyzedFiles() { |
| 114 removeGeneralAnalysisSubscription(GeneralAnalysisService.ANALYZED_FILES); | 113 removeGeneralAnalysisSubscription(GeneralAnalysisService.ANALYZED_FILES); |
| 115 } | 114 } |
| 116 } | 115 } |
| 117 | |
| 118 @reflectiveTest | |
| 119 class AnalysisNotificationAnalyzedFilesTest_Driver | |
| 120 extends AnalysisNotificationAnalyzedFilesTest { | |
| 121 @override | |
| 122 void setUp() { | |
| 123 enableNewAnalysisDriver = true; | |
| 124 generateSummaryFiles = true; | |
| 125 super.setUp(); | |
| 126 } | |
| 127 } | |
| OLD | NEW |