@@ -550,6 +550,177 @@ suggestions
550
550
kind: setter
551
551
f02
552
552
kind: setter
553
+ ''' );
554
+ }
555
+
556
+ Future <void > test_isVisibleForTesting_method_otherPackage () async {
557
+ var otherRoot = getFolder ('$packagesRootPath /other' );
558
+ newFile ('${otherRoot .path }/lib/a.dart' , r'''
559
+ import 'package:meta/meta.dart';
560
+
561
+ class A {
562
+ void f01() {}
563
+
564
+ @visibleForTesting
565
+ void f02() {}
566
+ }
567
+ ''' );
568
+
569
+ writeTestPackageConfig (
570
+ config: PackageConfigFileBuilder ()
571
+ ..add (
572
+ name: 'other' ,
573
+ rootPath: otherRoot.path,
574
+ ),
575
+ meta: true ,
576
+ );
577
+
578
+ await computeSuggestions ('''
579
+ import 'package:other/a.dart''
580
+
581
+ void f() {
582
+ A().^
583
+ }
584
+ ''' );
585
+
586
+ assertResponse (r'''
587
+ suggestions
588
+ f01
589
+ kind: methodInvocation
590
+ ''' );
591
+ }
592
+
593
+ Future <void > test_isVisibleForTesting_method_otherPackage_test () async {
594
+ var otherRoot = getFolder ('$packagesRootPath /other' );
595
+ newFile ('${otherRoot .path }/lib/a.dart' , r'''
596
+ import 'package:meta/meta.dart';
597
+
598
+ class A {
599
+ void f01() {}
600
+
601
+ @visibleForTesting
602
+ void f02() {}
603
+ }
604
+ ''' );
605
+
606
+ writeTestPackageConfig (
607
+ config: PackageConfigFileBuilder ()
608
+ ..add (
609
+ name: 'other' ,
610
+ rootPath: otherRoot.path,
611
+ ),
612
+ meta: true ,
613
+ );
614
+
615
+ testFilePath = '$testPackageTestPath /test.dart' ;
616
+ await computeSuggestions ('''
617
+ import 'package:other/a.dart''
618
+
619
+ void f() {
620
+ A().^
621
+ }
622
+ ''' );
623
+
624
+ assertResponse (r'''
625
+ suggestions
626
+ f01
627
+ kind: methodInvocation
628
+ ''' );
629
+ }
630
+
631
+ Future <void > test_isVisibleForTesting_method_sameLibrary () async {
632
+ writeTestPackageConfig (
633
+ meta: true ,
634
+ );
635
+
636
+ await computeSuggestions ('''
637
+ import 'package:meta/meta.dart';
638
+
639
+ class A {
640
+ void f01() {}
641
+
642
+ @visibleForTesting
643
+ void f02() {}
644
+ }
645
+
646
+ void f(A a) {
647
+ a.^
648
+ }
649
+ ''' );
650
+
651
+ assertResponse (r'''
652
+ suggestions
653
+ f01
654
+ kind: methodInvocation
655
+ f02
656
+ kind: methodInvocation
657
+ ''' );
658
+ }
659
+
660
+ Future <void >
661
+ test_isVisibleForTesting_method_samePackage_otherLibrary () async {
662
+ writeTestPackageConfig (
663
+ meta: true ,
664
+ );
665
+
666
+ newFile ('$testPackageLibPath /a.dart' , r'''
667
+ import 'package:meta/meta.dart';
668
+
669
+ class A {
670
+ void f01() {}
671
+
672
+ @visibleForTesting
673
+ void f02() {}
674
+ }
675
+ ''' );
676
+
677
+ await computeSuggestions ('''
678
+ import 'a.dart';
679
+
680
+ void f(A a) {
681
+ a.^
682
+ }
683
+ ''' );
684
+
685
+ assertResponse (r'''
686
+ suggestions
687
+ f01
688
+ kind: methodInvocation
689
+ ''' );
690
+ }
691
+
692
+ Future <void >
693
+ test_isVisibleForTesting_method_samePackage_otherLibrary_test () async {
694
+ writeTestPackageConfig (
695
+ meta: true ,
696
+ );
697
+
698
+ newFile ('$testPackageLibPath /a.dart' , r'''
699
+ import 'package:meta/meta.dart';
700
+
701
+ class A {
702
+ void f01() {}
703
+
704
+ @visibleForTesting
705
+ void f02() {}
706
+ }
707
+ ''' );
708
+
709
+ testFilePath = '$testPackageTestPath /test.dart' ;
710
+ await computeSuggestions ('''
711
+ import 'package:test/a.dart';
712
+
713
+ void f(A a) {
714
+ a.^
715
+ }
716
+ ''' );
717
+
718
+ assertResponse (r'''
719
+ suggestions
720
+ f01
721
+ kind: methodInvocation
722
+ f02
723
+ kind: methodInvocation
553
724
''' );
554
725
}
555
726
}
0 commit comments