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

Side by Side Diff: pkg/analyzer/test/src/task/dart_work_manager_test.dart

Issue 1405643002: Issue 24566. Main AnalysisContext.getLibrariesContaining() should work also for SDK sources. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 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
« no previous file with comments | « pkg/analyzer/test/src/context/context_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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.src.task.dart_work_manager_test; 5 library test.src.task.dart_work_manager_test;
6 6
7 import 'package:analyzer/src/context/cache.dart'; 7 import 'package:analyzer/src/context/cache.dart';
8 import 'package:analyzer/src/generated/ast.dart'; 8 import 'package:analyzer/src/generated/ast.dart';
9 import 'package:analyzer/src/generated/engine.dart' 9 import 'package:analyzer/src/generated/engine.dart'
10 show 10 show
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 manager.libraryPartsMap[library1] = [part1]; 325 manager.libraryPartsMap[library1] = [part1];
326 manager.libraryPartsMap[library2] = [part1, part2]; 326 manager.libraryPartsMap[library2] = [part1, part2];
327 // getLibrariesContainingPart 327 // getLibrariesContainingPart
328 expect(manager.getLibrariesContainingPart(part1), 328 expect(manager.getLibrariesContainingPart(part1),
329 unorderedEquals([library1, library2])); 329 unorderedEquals([library1, library2]));
330 expect( 330 expect(
331 manager.getLibrariesContainingPart(part2), unorderedEquals([library2])); 331 manager.getLibrariesContainingPart(part2), unorderedEquals([library2]));
332 expect(manager.getLibrariesContainingPart(part3), isEmpty); 332 expect(manager.getLibrariesContainingPart(part3), isEmpty);
333 } 333 }
334 334
335 void test_getLibrariesContainingPart_inSDK() {
336 Source part = new _SourceMock('part.dart');
337 when(part.isInSystemLibrary).thenReturn(true);
338 // SDK work manager
339 DartWorkManager sdkDartWorkManagerMock = new _DartWorkManagerMock();
340 when(sdkDartWorkManagerMock.getLibrariesContainingPart(part))
341 .thenReturn([source2, source3]);
342 // SDK context mock
343 InternalAnalysisContext sdkContextMock = new _InternalAnalysisContextMock();
344 when(sdkContextMock.workManagers).thenReturn([sdkDartWorkManagerMock]);
345 // SDK mock
346 DartSdk sdkMock = new _DartSdkMock();
347 when(sdkMock.context).thenReturn(sdkContextMock);
348 // SourceFactory mock
349 SourceFactory sourceFactory = new _SourceFactoryMock();
350 when(sourceFactory.dartSdk).thenReturn(sdkMock);
351 when(context.sourceFactory).thenReturn(sourceFactory);
352 // SDK source mock
353 Source source = new _SourceMock('test.dart');
354 when(source.source).thenReturn(source);
355 when(source.isInSystemLibrary).thenReturn(true);
356 // validate
357 expect(manager.getLibrariesContainingPart(part),
358 unorderedEquals([source2, source3]));
359 }
360
335 void test_getNextResult_hasLibraries_firstIsError() { 361 void test_getNextResult_hasLibraries_firstIsError() {
336 entry1.setErrorState(caughtException, [LIBRARY_ERRORS_READY]); 362 entry1.setErrorState(caughtException, [LIBRARY_ERRORS_READY]);
337 manager.librarySourceQueue.addAll([source1, source2]); 363 manager.librarySourceQueue.addAll([source1, source2]);
338 TargetedResult request = manager.getNextResult(); 364 TargetedResult request = manager.getNextResult();
339 expect(request.target, source2); 365 expect(request.target, source2);
340 expect(request.result, LIBRARY_ERRORS_READY); 366 expect(request.result, LIBRARY_ERRORS_READY);
341 // source1 is out, source2 is waiting 367 // source1 is out, source2 is waiting
342 expect_librarySourceQueue([source2]); 368 expect_librarySourceQueue([source2]);
343 } 369 }
344 370
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 803
778 class _SourceMock extends TypedMock implements Source { 804 class _SourceMock extends TypedMock implements Source {
779 final String shortName; 805 final String shortName;
780 _SourceMock(this.shortName); 806 _SourceMock(this.shortName);
781 @override 807 @override
782 String get fullName => '/' + shortName; 808 String get fullName => '/' + shortName;
783 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); 809 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
784 @override 810 @override
785 String toString() => fullName; 811 String toString() => fullName;
786 } 812 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/src/context/context_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698