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.index.split_store; | 5 library test.engine.src.index.split_store; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 import 'package:analysis_server/src/index/store/codec.dart'; | |
10 import 'package:analysis_server/src/index/store/split_store.dart'; | |
11 import 'package:analyzer/src/generated/element.dart'; | 9 import 'package:analyzer/src/generated/element.dart'; |
12 import 'package:analyzer/src/generated/engine.dart'; | 10 import 'package:analyzer/src/generated/engine.dart'; |
13 import 'package:analyzer/src/generated/index.dart'; | |
14 import 'package:analyzer/src/generated/source.dart'; | 11 import 'package:analyzer/src/generated/source.dart'; |
15 import 'package:typed_mock/typed_mock.dart'; | 12 import 'package:typed_mock/typed_mock.dart'; |
16 import 'package:unittest/unittest.dart'; | 13 import 'package:unittest/unittest.dart'; |
17 | 14 |
18 import '../../reflective_tests.dart'; | 15 import '../../reflective_tests.dart'; |
19 import 'memory_node_manager.dart'; | |
20 import 'single_source_container.dart'; | 16 import 'single_source_container.dart'; |
21 import 'typed_mocks.dart'; | 17 import 'typed_mocks.dart'; |
| 18 import 'package:analyzer/src/index/store/split_store.dart'; |
| 19 import 'package:analyzer/index/index.dart'; |
| 20 import 'package:analyzer/src/index/store/codec.dart'; |
| 21 import 'package:analyzer/src/index/store/memory_node_manager.dart'; |
22 | 22 |
23 | 23 |
24 main() { | 24 main() { |
25 groupSep = ' | '; | 25 groupSep = ' | '; |
26 group('FileNodeManager', () { | 26 group('FileNodeManager', () { |
27 runReflectiveTests(_FileNodeManagerTest); | 27 runReflectiveTests(_FileNodeManagerTest); |
28 }); | 28 }); |
29 group('IndexNode', () { | 29 group('IndexNode', () { |
30 runReflectiveTests(_IndexNodeTest); | 30 runReflectiveTests(_IndexNodeTest); |
31 }); | 31 }); |
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
553 } | 553 } |
554 | 554 |
555 void test_aboutToIndexDart_disposedContext_wrapped() { | 555 void test_aboutToIndexDart_disposedContext_wrapped() { |
556 when(contextA.isDisposed).thenReturn(true); | 556 when(contextA.isDisposed).thenReturn(true); |
557 InstrumentedAnalysisContextImpl instrumentedContext = | 557 InstrumentedAnalysisContextImpl instrumentedContext = |
558 new MockInstrumentedAnalysisContextImpl(); | 558 new MockInstrumentedAnalysisContextImpl(); |
559 when(instrumentedContext.basis).thenReturn(contextA); | 559 when(instrumentedContext.basis).thenReturn(contextA); |
560 expect(store.aboutToIndexDart(instrumentedContext, unitElementA), isFalse); | 560 expect(store.aboutToIndexDart(instrumentedContext, unitElementA), isFalse); |
561 } | 561 } |
562 | 562 |
563 void test_aboutToIndexDart_library_first() { | 563 Future test_aboutToIndexDart_library_first() { |
564 when(libraryElement.parts).thenReturn(<CompilationUnitElement>[unitElementA, | 564 when(libraryElement.parts).thenReturn(<CompilationUnitElement>[unitElementA, |
565 unitElementB]); | 565 unitElementB]); |
566 { | 566 { |
567 store.aboutToIndexDart(contextA, libraryUnitElement); | 567 store.aboutToIndexDart(contextA, libraryUnitElement); |
568 store.doneIndex(); | 568 store.doneIndex(); |
569 } | 569 } |
570 { | 570 return store.getRelationships(elementA, relationship).then( |
571 List<Location> locations = store.getRelationships(elementA, relationship); | 571 (List<Location> locations) { |
572 assertLocations(locations, []); | 572 assertLocations(locations, []); |
573 } | 573 }); |
574 } | 574 } |
575 | 575 |
576 test_aboutToIndexDart_library_secondWithoutOneUnit() { | 576 test_aboutToIndexDart_library_secondWithoutOneUnit() { |
577 Location locationA = mockLocation(elementA); | 577 Location locationA = mockLocation(elementA); |
578 Location locationB = mockLocation(elementB); | 578 Location locationB = mockLocation(elementB); |
579 { | 579 { |
580 store.aboutToIndexDart(contextA, unitElementA); | 580 store.aboutToIndexDart(contextA, unitElementA); |
581 store.recordRelationship(elementA, relationship, locationA); | 581 store.recordRelationship(elementA, relationship, locationA); |
582 store.doneIndex(); | 582 store.doneIndex(); |
583 } | 583 } |
584 { | 584 { |
585 store.aboutToIndexDart(contextA, unitElementB); | 585 store.aboutToIndexDart(contextA, unitElementB); |
586 store.recordRelationship(elementA, relationship, locationB); | 586 store.recordRelationship(elementA, relationship, locationB); |
587 store.doneIndex(); | 587 store.doneIndex(); |
588 } | 588 } |
589 // "A" and "B" locations | 589 // "A" and "B" locations |
590 return store.getRelationshipsAsync(elementA, relationship).then( | 590 return store.getRelationships(elementA, relationship).then( |
591 (List<Location> locations) { | 591 (List<Location> locations) { |
592 assertLocations(locations, [locationA, locationB]); | 592 assertLocations(locations, [locationA, locationB]); |
593 }).then((_) { | |
594 // apply "libraryUnitElement", only with "B" | 593 // apply "libraryUnitElement", only with "B" |
595 when(libraryElement.parts).thenReturn([unitElementB]); | 594 when(libraryElement.parts).thenReturn([unitElementB]); |
596 { | 595 { |
597 store.aboutToIndexDart(contextA, libraryUnitElement); | 596 store.aboutToIndexDart(contextA, libraryUnitElement); |
598 store.doneIndex(); | 597 store.doneIndex(); |
599 } | 598 } |
600 return store.getRelationshipsAsync(elementA, relationship).then( | 599 }).then((_) { |
| 600 return store.getRelationships(elementA, relationship).then( |
601 (List<Location> locations) { | 601 (List<Location> locations) { |
602 assertLocations(locations, [locationB]); | 602 assertLocations(locations, [locationB]); |
603 }); | 603 }); |
604 }); | 604 }); |
605 } | 605 } |
606 | 606 |
607 void test_aboutToIndexDart_nullLibraryElement() { | 607 void test_aboutToIndexDart_nullLibraryElement() { |
608 when(unitElementA.library).thenReturn(null); | 608 when(unitElementA.library).thenReturn(null); |
609 expect(store.aboutToIndexDart(contextA, unitElementA), isFalse); | 609 expect(store.aboutToIndexDart(contextA, unitElementA), isFalse); |
610 } | 610 } |
(...skipping 14 matching lines...) Expand all Loading... |
625 store.aboutToIndexHtml(contextA, htmlElementA); | 625 store.aboutToIndexHtml(contextA, htmlElementA); |
626 store.recordRelationship(elementA, relationship, locationA); | 626 store.recordRelationship(elementA, relationship, locationA); |
627 store.doneIndex(); | 627 store.doneIndex(); |
628 } | 628 } |
629 { | 629 { |
630 store.aboutToIndexHtml(contextA, htmlElementB); | 630 store.aboutToIndexHtml(contextA, htmlElementB); |
631 store.recordRelationship(elementA, relationship, locationB); | 631 store.recordRelationship(elementA, relationship, locationB); |
632 store.doneIndex(); | 632 store.doneIndex(); |
633 } | 633 } |
634 // "A" and "B" locations | 634 // "A" and "B" locations |
635 return store.getRelationshipsAsync(elementA, relationship).then( | 635 return store.getRelationships(elementA, relationship).then( |
636 (List<Location> locations) { | 636 (List<Location> locations) { |
637 assertLocations(locations, [locationA, locationB]); | 637 assertLocations(locations, [locationA, locationB]); |
638 }); | 638 }); |
639 } | 639 } |
640 | 640 |
641 void test_aboutToIndexHtml_disposedContext() { | 641 void test_aboutToIndexHtml_disposedContext() { |
642 when(contextA.isDisposed).thenReturn(true); | 642 when(contextA.isDisposed).thenReturn(true); |
643 expect(store.aboutToIndexHtml(contextA, htmlElementA), isFalse); | 643 expect(store.aboutToIndexHtml(contextA, htmlElementA), isFalse); |
644 } | 644 } |
645 | 645 |
646 void test_clear() { | 646 void test_clear() { |
647 Location locationA = mockLocation(elementA); | 647 Location locationA = mockLocation(elementA); |
648 store.aboutToIndexDart(contextA, unitElementA); | 648 store.aboutToIndexDart(contextA, unitElementA); |
649 store.recordRelationship(elementA, relationship, locationA); | 649 store.recordRelationship(elementA, relationship, locationA); |
650 store.doneIndex(); | 650 store.doneIndex(); |
651 expect(nodeManager.isEmpty(), isFalse); | 651 expect(nodeManager.isEmpty(), isFalse); |
652 // clear | 652 // clear |
653 store.clear(); | 653 store.clear(); |
654 expect(nodeManager.isEmpty(), isTrue); | 654 expect(nodeManager.isEmpty(), isTrue); |
655 } | 655 } |
656 | 656 |
657 test_getRelationships_empty() { | 657 test_getRelationships_empty() { |
658 return store.getRelationshipsAsync(elementA, relationship).then( | 658 return store.getRelationships(elementA, relationship).then( |
659 (List<Location> locations) { | 659 (List<Location> locations) { |
660 expect(locations, isEmpty); | 660 expect(locations, isEmpty); |
661 }); | 661 }); |
662 } | 662 } |
663 | 663 |
664 void test_getStatistics() { | 664 void test_getStatistics() { |
665 // empty initially | 665 // empty initially |
666 { | 666 { |
667 String statistics = store.statistics; | 667 String statistics = store.statistics; |
668 expect(statistics, contains('0 locations')); | 668 expect(statistics, contains('0 locations')); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
707 { | 707 { |
708 store.aboutToIndexDart(contextA, unitElementA); | 708 store.aboutToIndexDart(contextA, unitElementA); |
709 store.recordRelationship(elementA, relationship, locationA); | 709 store.recordRelationship(elementA, relationship, locationA); |
710 store.doneIndex(); | 710 store.doneIndex(); |
711 } | 711 } |
712 { | 712 { |
713 store.aboutToIndexDart(contextA, unitElementB); | 713 store.aboutToIndexDart(contextA, unitElementB); |
714 store.recordRelationship(elementA, relationship, locationB); | 714 store.recordRelationship(elementA, relationship, locationB); |
715 store.doneIndex(); | 715 store.doneIndex(); |
716 } | 716 } |
717 return store.getRelationshipsAsync(elementA, relationship).then( | 717 return store.getRelationships(elementA, relationship).then( |
718 (List<Location> locations) { | 718 (List<Location> locations) { |
719 assertLocations(locations, [locationA, locationB]); | 719 assertLocations(locations, [locationA, locationB]); |
720 }); | 720 }); |
721 } | 721 } |
722 | 722 |
723 test_recordRelationship_oneLocation() { | 723 test_recordRelationship_oneLocation() { |
724 Location locationA = mockLocation(elementA); | 724 Location locationA = mockLocation(elementA); |
725 store.aboutToIndexDart(contextA, unitElementA); | 725 store.aboutToIndexDart(contextA, unitElementA); |
726 store.recordRelationship(elementA, relationship, locationA); | 726 store.recordRelationship(elementA, relationship, locationA); |
727 store.doneIndex(); | 727 store.doneIndex(); |
728 return store.getRelationshipsAsync(elementA, relationship).then( | 728 return store.getRelationships(elementA, relationship).then( |
729 (List<Location> locations) { | 729 (List<Location> locations) { |
730 assertLocations(locations, [locationA]); | 730 assertLocations(locations, [locationA]); |
731 }); | 731 }); |
732 } | 732 } |
733 | 733 |
734 test_recordRelationship_twoLocations() { | 734 test_recordRelationship_twoLocations() { |
735 Location locationA = mockLocation(elementA); | 735 Location locationA = mockLocation(elementA); |
736 Location locationB = mockLocation(elementA); | 736 Location locationB = mockLocation(elementA); |
737 store.aboutToIndexDart(contextA, unitElementA); | 737 store.aboutToIndexDart(contextA, unitElementA); |
738 store.recordRelationship(elementA, relationship, locationA); | 738 store.recordRelationship(elementA, relationship, locationA); |
739 store.recordRelationship(elementA, relationship, locationB); | 739 store.recordRelationship(elementA, relationship, locationB); |
740 store.doneIndex(); | 740 store.doneIndex(); |
741 return store.getRelationshipsAsync(elementA, relationship).then( | 741 return store.getRelationships(elementA, relationship).then( |
742 (List<Location> locations) { | 742 (List<Location> locations) { |
743 assertLocations(locations, [locationA, locationB]); | 743 assertLocations(locations, [locationA, locationB]); |
744 }); | 744 }); |
745 } | 745 } |
746 | 746 |
747 test_removeContext() { | 747 test_removeContext() { |
748 Location locationA = mockLocation(elementA); | 748 Location locationA = mockLocation(elementA); |
749 Location locationB = mockLocation(elementB); | 749 Location locationB = mockLocation(elementB); |
750 { | 750 { |
751 store.aboutToIndexDart(contextA, unitElementA); | 751 store.aboutToIndexDart(contextA, unitElementA); |
752 store.recordRelationship(elementA, relationship, locationA); | 752 store.recordRelationship(elementA, relationship, locationA); |
753 store.doneIndex(); | 753 store.doneIndex(); |
754 } | 754 } |
755 { | 755 { |
756 store.aboutToIndexDart(contextA, unitElementB); | 756 store.aboutToIndexDart(contextA, unitElementB); |
757 store.recordRelationship(elementA, relationship, locationB); | 757 store.recordRelationship(elementA, relationship, locationB); |
758 store.doneIndex(); | 758 store.doneIndex(); |
759 } | 759 } |
760 // "A" and "B" locations | 760 // "A" and "B" locations |
761 return store.getRelationshipsAsync(elementA, relationship).then( | 761 return store.getRelationships(elementA, relationship).then( |
762 (List<Location> locations) { | 762 (List<Location> locations) { |
763 assertLocations(locations, [locationA, locationB]); | 763 assertLocations(locations, [locationA, locationB]); |
764 }).then((_) { | |
765 // remove "A" context | 764 // remove "A" context |
766 store.removeContext(contextA); | 765 store.removeContext(contextA); |
767 return store.getRelationshipsAsync(elementA, relationship).then( | 766 }).then((_) { |
| 767 return store.getRelationships(elementA, relationship).then( |
768 (List<Location> locations) { | 768 (List<Location> locations) { |
769 assertLocations(locations, []); | 769 assertLocations(locations, []); |
770 }); | 770 }); |
771 }); | 771 }); |
772 } | 772 } |
773 | 773 |
774 void test_removeContext_nullContext() { | 774 void test_removeContext_nullContext() { |
775 store.removeContext(null); | 775 store.removeContext(null); |
776 } | 776 } |
777 | 777 |
(...skipping 10 matching lines...) Expand all Loading... |
788 store.aboutToIndexDart(contextA, unitElementB); | 788 store.aboutToIndexDart(contextA, unitElementB); |
789 store.recordRelationship(elementA, relationship, locationB); | 789 store.recordRelationship(elementA, relationship, locationB); |
790 store.doneIndex(); | 790 store.doneIndex(); |
791 } | 791 } |
792 { | 792 { |
793 store.aboutToIndexDart(contextA, unitElementC); | 793 store.aboutToIndexDart(contextA, unitElementC); |
794 store.recordRelationship(elementA, relationship, locationC); | 794 store.recordRelationship(elementA, relationship, locationC); |
795 store.doneIndex(); | 795 store.doneIndex(); |
796 } | 796 } |
797 // "A", "B" and "C" locations | 797 // "A", "B" and "C" locations |
798 return store.getRelationshipsAsync(elementA, relationship).then( | 798 return store.getRelationships(elementA, relationship).then( |
799 (List<Location> locations) { | 799 (List<Location> locations) { |
800 assertLocations(locations, [locationA, locationB, locationC]); | 800 assertLocations(locations, [locationA, locationB, locationC]); |
801 }).then((_) { | 801 }).then((_) { |
802 // remove "librarySource" | 802 // remove "librarySource" |
803 store.removeSource(contextA, librarySource); | 803 store.removeSource(contextA, librarySource); |
804 return store.getRelationshipsAsync(elementA, relationship).then( | 804 return store.getRelationships(elementA, relationship).then( |
805 (List<Location> locations) { | 805 (List<Location> locations) { |
806 assertLocations(locations, []); | 806 assertLocations(locations, []); |
807 }); | 807 }); |
808 }); | 808 }); |
809 } | 809 } |
810 | 810 |
811 void test_removeSource_nullContext() { | 811 void test_removeSource_nullContext() { |
812 store.removeSource(null, sourceA); | 812 store.removeSource(null, sourceA); |
813 } | 813 } |
814 | 814 |
(...skipping 10 matching lines...) Expand all Loading... |
825 store.aboutToIndexDart(contextA, unitElementB); | 825 store.aboutToIndexDart(contextA, unitElementB); |
826 store.recordRelationship(elementA, relationship, locationB); | 826 store.recordRelationship(elementA, relationship, locationB); |
827 store.doneIndex(); | 827 store.doneIndex(); |
828 } | 828 } |
829 { | 829 { |
830 store.aboutToIndexDart(contextA, unitElementC); | 830 store.aboutToIndexDart(contextA, unitElementC); |
831 store.recordRelationship(elementA, relationship, locationC); | 831 store.recordRelationship(elementA, relationship, locationC); |
832 store.doneIndex(); | 832 store.doneIndex(); |
833 } | 833 } |
834 // "A", "B" and "C" locations | 834 // "A", "B" and "C" locations |
835 return store.getRelationshipsAsync(elementA, relationship).then( | 835 return store.getRelationships(elementA, relationship).then( |
836 (List<Location> locations) { | 836 (List<Location> locations) { |
837 assertLocations(locations, [locationA, locationB, locationC]); | 837 assertLocations(locations, [locationA, locationB, locationC]); |
838 }).then((_) { | 838 }).then((_) { |
839 // remove "A" source | 839 // remove "A" source |
840 store.removeSource(contextA, sourceA); | 840 store.removeSource(contextA, sourceA); |
841 return store.getRelationshipsAsync(elementA, relationship).then( | 841 return store.getRelationships(elementA, relationship).then( |
842 (List<Location> locations) { | 842 (List<Location> locations) { |
843 assertLocations(locations, [locationB, locationC]); | 843 assertLocations(locations, [locationB, locationC]); |
844 }); | 844 }); |
845 }); | 845 }); |
846 } | 846 } |
847 | 847 |
848 test_removeSources_library() { | 848 test_removeSources_library() { |
849 Location locationA = mockLocation(elementA); | 849 Location locationA = mockLocation(elementA); |
850 Location locationB = mockLocation(elementB); | 850 Location locationB = mockLocation(elementB); |
851 { | 851 { |
852 store.aboutToIndexDart(contextA, unitElementA); | 852 store.aboutToIndexDart(contextA, unitElementA); |
853 store.recordRelationship(elementA, relationship, locationA); | 853 store.recordRelationship(elementA, relationship, locationA); |
854 store.doneIndex(); | 854 store.doneIndex(); |
855 } | 855 } |
856 { | 856 { |
857 store.aboutToIndexDart(contextA, unitElementB); | 857 store.aboutToIndexDart(contextA, unitElementB); |
858 store.recordRelationship(elementA, relationship, locationB); | 858 store.recordRelationship(elementA, relationship, locationB); |
859 store.doneIndex(); | 859 store.doneIndex(); |
860 } | 860 } |
861 // "A" and "B" locations | 861 // "A" and "B" locations |
862 return store.getRelationshipsAsync(elementA, relationship).then( | 862 return store.getRelationships(elementA, relationship).then( |
863 (List<Location> locations) { | 863 (List<Location> locations) { |
864 assertLocations(locations, [locationA, locationB]); | 864 assertLocations(locations, [locationA, locationB]); |
865 }).then((_) { | 865 }).then((_) { |
866 // remove "librarySource" | 866 // remove "librarySource" |
867 store.removeSources(contextA, new SingleSourceContainer(librarySource)); | 867 store.removeSources(contextA, new SingleSourceContainer(librarySource)); |
868 return store.getRelationshipsAsync(elementA, relationship).then( | 868 return store.getRelationships(elementA, relationship).then( |
869 (List<Location> locations) { | 869 (List<Location> locations) { |
870 assertLocations(locations, []); | 870 assertLocations(locations, []); |
871 }); | 871 }); |
872 }); | 872 }); |
873 } | 873 } |
874 | 874 |
875 void test_removeSources_nullContext() { | 875 void test_removeSources_nullContext() { |
876 store.removeSources(null, null); | 876 store.removeSources(null, null); |
877 } | 877 } |
878 | 878 |
(...skipping 10 matching lines...) Expand all Loading... |
889 store.aboutToIndexDart(contextA, unitElementB); | 889 store.aboutToIndexDart(contextA, unitElementB); |
890 store.recordRelationship(elementA, relationship, locationB); | 890 store.recordRelationship(elementA, relationship, locationB); |
891 store.doneIndex(); | 891 store.doneIndex(); |
892 } | 892 } |
893 { | 893 { |
894 store.aboutToIndexDart(contextA, unitElementC); | 894 store.aboutToIndexDart(contextA, unitElementC); |
895 store.recordRelationship(elementA, relationship, locationC); | 895 store.recordRelationship(elementA, relationship, locationC); |
896 store.doneIndex(); | 896 store.doneIndex(); |
897 } | 897 } |
898 // "A", "B" and "C" locations | 898 // "A", "B" and "C" locations |
899 return store.getRelationshipsAsync(elementA, relationship).then( | 899 return store.getRelationships(elementA, relationship).then( |
900 (List<Location> locations) { | 900 (List<Location> locations) { |
901 assertLocations(locations, [locationA, locationB, locationC]); | 901 assertLocations(locations, [locationA, locationB, locationC]); |
902 }).then((_) { | 902 }).then((_) { |
903 // remove "A" source | 903 // remove "A" source |
904 store.removeSources(contextA, new SingleSourceContainer(sourceA)); | 904 store.removeSources(contextA, new SingleSourceContainer(sourceA)); |
905 store.removeSource(contextA, sourceA); | 905 store.removeSource(contextA, sourceA); |
906 return store.getRelationshipsAsync(elementA, relationship).then( | 906 return store.getRelationships(elementA, relationship).then( |
907 (List<Location> locations) { | 907 (List<Location> locations) { |
908 assertLocations(locations, [locationB, locationC]); | 908 assertLocations(locations, [locationB, locationC]); |
909 }); | 909 }); |
910 }); | 910 }); |
911 } | 911 } |
912 | 912 |
913 test_universe_aboutToIndex() { | 913 test_universe_aboutToIndex() { |
914 when(contextA.getElement(elementLocationA)).thenReturn(elementA); | 914 when(contextA.getElement(elementLocationA)).thenReturn(elementA); |
915 when(contextB.getElement(elementLocationB)).thenReturn(elementB); | 915 when(contextB.getElement(elementLocationB)).thenReturn(elementB); |
916 Location locationA = mockLocation(elementA); | 916 Location locationA = mockLocation(elementA); |
917 Location locationB = mockLocation(elementB); | 917 Location locationB = mockLocation(elementB); |
918 { | 918 { |
919 store.aboutToIndexDart(contextA, unitElementA); | 919 store.aboutToIndexDart(contextA, unitElementA); |
920 store.recordRelationship(UniverseElement.INSTANCE, relationship, | 920 store.recordRelationship(UniverseElement.INSTANCE, relationship, |
921 locationA); | 921 locationA); |
922 store.doneIndex(); | 922 store.doneIndex(); |
923 } | 923 } |
924 { | 924 { |
925 store.aboutToIndexDart(contextB, unitElementB); | 925 store.aboutToIndexDart(contextB, unitElementB); |
926 store.recordRelationship(UniverseElement.INSTANCE, relationship, | 926 store.recordRelationship(UniverseElement.INSTANCE, relationship, |
927 locationB); | 927 locationB); |
928 store.doneIndex(); | 928 store.doneIndex(); |
929 } | 929 } |
930 // get relationships | 930 // get relationships |
931 return store.getRelationshipsAsync(UniverseElement.INSTANCE, | 931 return store.getRelationships(UniverseElement.INSTANCE, relationship).then( |
932 relationship).then((List<Location> locations) { | 932 (List<Location> locations) { |
933 assertLocations(locations, [locationA, locationB]); | 933 assertLocations(locations, [locationA, locationB]); |
934 }).then((_) { | 934 }).then((_) { |
935 // re-index "unitElementA" | 935 // re-index "unitElementA" |
936 store.aboutToIndexDart(contextA, unitElementA); | 936 store.aboutToIndexDart(contextA, unitElementA); |
937 store.doneIndex(); | 937 store.doneIndex(); |
938 return store.getRelationshipsAsync(UniverseElement.INSTANCE, | 938 return store.getRelationships(UniverseElement.INSTANCE, |
939 relationship).then((List<Location> locations) { | 939 relationship).then((List<Location> locations) { |
940 assertLocations(locations, [locationB]); | 940 assertLocations(locations, [locationB]); |
941 }); | 941 }); |
942 }); | 942 }); |
943 } | 943 } |
944 | 944 |
945 test_universe_clear() { | 945 test_universe_clear() { |
946 when(contextA.getElement(elementLocationA)).thenReturn(elementA); | 946 when(contextA.getElement(elementLocationA)).thenReturn(elementA); |
947 when(contextB.getElement(elementLocationB)).thenReturn(elementB); | 947 when(contextB.getElement(elementLocationB)).thenReturn(elementB); |
948 Location locationA = mockLocation(elementA); | 948 Location locationA = mockLocation(elementA); |
949 Location locationB = mockLocation(elementB); | 949 Location locationB = mockLocation(elementB); |
950 { | 950 { |
951 store.aboutToIndexDart(contextA, unitElementA); | 951 store.aboutToIndexDart(contextA, unitElementA); |
952 store.recordRelationship(UniverseElement.INSTANCE, relationship, | 952 store.recordRelationship(UniverseElement.INSTANCE, relationship, |
953 locationA); | 953 locationA); |
954 store.doneIndex(); | 954 store.doneIndex(); |
955 } | 955 } |
956 { | 956 { |
957 store.aboutToIndexDart(contextA, unitElementB); | 957 store.aboutToIndexDart(contextA, unitElementB); |
958 store.recordRelationship(UniverseElement.INSTANCE, relationship, | 958 store.recordRelationship(UniverseElement.INSTANCE, relationship, |
959 locationB); | 959 locationB); |
960 store.doneIndex(); | 960 store.doneIndex(); |
961 } | 961 } |
962 return store.getRelationshipsAsync(UniverseElement.INSTANCE, | 962 return store.getRelationships(UniverseElement.INSTANCE, relationship).then( |
963 relationship).then((List<Location> locations) { | 963 (List<Location> locations) { |
964 assertLocations(locations, [locationA, locationB]); | 964 assertLocations(locations, [locationA, locationB]); |
965 }).then((_) { | 965 }).then((_) { |
966 // clear | 966 // clear |
967 store.clear(); | 967 store.clear(); |
968 return store.getRelationshipsAsync(UniverseElement.INSTANCE, | 968 return store.getRelationships(UniverseElement.INSTANCE, |
969 relationship).then((List<Location> locations) { | 969 relationship).then((List<Location> locations) { |
970 expect(locations, isEmpty); | 970 expect(locations, isEmpty); |
971 }); | 971 }); |
972 }); | 972 }); |
973 } | 973 } |
974 | 974 |
975 test_universe_removeContext() { | 975 test_universe_removeContext() { |
976 when(contextA.getElement(elementLocationA)).thenReturn(elementA); | 976 when(contextA.getElement(elementLocationA)).thenReturn(elementA); |
977 when(contextB.getElement(elementLocationB)).thenReturn(elementB); | 977 when(contextB.getElement(elementLocationB)).thenReturn(elementB); |
978 Location locationA = mockLocation(elementA); | 978 Location locationA = mockLocation(elementA); |
979 Location locationB = mockLocation(elementB); | 979 Location locationB = mockLocation(elementB); |
980 { | 980 { |
981 store.aboutToIndexDart(contextA, unitElementA); | 981 store.aboutToIndexDart(contextA, unitElementA); |
982 store.recordRelationship(UniverseElement.INSTANCE, relationship, | 982 store.recordRelationship(UniverseElement.INSTANCE, relationship, |
983 locationA); | 983 locationA); |
984 store.doneIndex(); | 984 store.doneIndex(); |
985 } | 985 } |
986 { | 986 { |
987 store.aboutToIndexDart(contextB, unitElementB); | 987 store.aboutToIndexDart(contextB, unitElementB); |
988 store.recordRelationship(UniverseElement.INSTANCE, relationship, | 988 store.recordRelationship(UniverseElement.INSTANCE, relationship, |
989 locationB); | 989 locationB); |
990 store.doneIndex(); | 990 store.doneIndex(); |
991 } | 991 } |
992 return store.getRelationshipsAsync(UniverseElement.INSTANCE, | 992 return store.getRelationships(UniverseElement.INSTANCE, relationship).then( |
993 relationship).then((List<Location> locations) { | 993 (List<Location> locations) { |
994 assertLocations(locations, [locationA, locationB]); | 994 assertLocations(locations, [locationA, locationB]); |
995 }).then((_) { | 995 }).then((_) { |
996 // remove "contextA" | 996 // remove "contextA" |
997 store.removeContext(contextA); | 997 store.removeContext(contextA); |
998 return store.getRelationshipsAsync(UniverseElement.INSTANCE, | 998 return store.getRelationships(UniverseElement.INSTANCE, |
999 relationship).then((List<Location> locations) { | 999 relationship).then((List<Location> locations) { |
1000 assertLocations(locations, [locationB]); | 1000 assertLocations(locations, [locationB]); |
1001 }); | 1001 }); |
1002 }); | 1002 }); |
1003 } | 1003 } |
1004 | 1004 |
1005 test_universe_removeSource() { | 1005 test_universe_removeSource() { |
1006 when(contextA.getElement(elementLocationA)).thenReturn(elementA); | 1006 when(contextA.getElement(elementLocationA)).thenReturn(elementA); |
1007 when(contextB.getElement(elementLocationB)).thenReturn(elementB); | 1007 when(contextB.getElement(elementLocationB)).thenReturn(elementB); |
1008 Location locationA = mockLocation(elementA); | 1008 Location locationA = mockLocation(elementA); |
1009 Location locationB = mockLocation(elementB); | 1009 Location locationB = mockLocation(elementB); |
1010 { | 1010 { |
1011 store.aboutToIndexDart(contextA, unitElementA); | 1011 store.aboutToIndexDart(contextA, unitElementA); |
1012 store.recordRelationship(UniverseElement.INSTANCE, relationship, | 1012 store.recordRelationship(UniverseElement.INSTANCE, relationship, |
1013 locationA); | 1013 locationA); |
1014 store.doneIndex(); | 1014 store.doneIndex(); |
1015 } | 1015 } |
1016 { | 1016 { |
1017 store.aboutToIndexDart(contextA, unitElementB); | 1017 store.aboutToIndexDart(contextA, unitElementB); |
1018 store.recordRelationship(UniverseElement.INSTANCE, relationship, | 1018 store.recordRelationship(UniverseElement.INSTANCE, relationship, |
1019 locationB); | 1019 locationB); |
1020 store.doneIndex(); | 1020 store.doneIndex(); |
1021 } | 1021 } |
1022 return store.getRelationshipsAsync(UniverseElement.INSTANCE, | 1022 return store.getRelationships(UniverseElement.INSTANCE, relationship).then( |
1023 relationship).then((List<Location> locations) { | 1023 (List<Location> locations) { |
1024 assertLocations(locations, [locationA, locationB]); | 1024 assertLocations(locations, [locationA, locationB]); |
1025 }).then((_) { | 1025 }).then((_) { |
1026 // remove "sourceA" | 1026 // remove "sourceA" |
1027 store.removeSource(contextA, sourceA); | 1027 store.removeSource(contextA, sourceA); |
1028 return store.getRelationshipsAsync(UniverseElement.INSTANCE, | 1028 return store.getRelationships(UniverseElement.INSTANCE, |
1029 relationship).then((List<Location> locations) { | 1029 relationship).then((List<Location> locations) { |
1030 assertLocations(locations, [locationB]); | 1030 assertLocations(locations, [locationB]); |
1031 }); | 1031 }); |
1032 }); | 1032 }); |
1033 } | 1033 } |
1034 | 1034 |
1035 /** | 1035 /** |
1036 * Asserts that the [actual] locations have all the [expected] locations and | 1036 * Asserts that the [actual] locations have all the [expected] locations and |
1037 * only them. | 1037 * only them. |
1038 */ | 1038 */ |
(...skipping 18 matching lines...) Expand all Loading... |
1057 * Wraps the given locations into [LocationEqualsWrapper]. | 1057 * Wraps the given locations into [LocationEqualsWrapper]. |
1058 */ | 1058 */ |
1059 static List<_LocationEqualsWrapper> wrapLocations(List<Location> locations) { | 1059 static List<_LocationEqualsWrapper> wrapLocations(List<Location> locations) { |
1060 List<_LocationEqualsWrapper> wrappers = <_LocationEqualsWrapper>[]; | 1060 List<_LocationEqualsWrapper> wrappers = <_LocationEqualsWrapper>[]; |
1061 for (Location location in locations) { | 1061 for (Location location in locations) { |
1062 wrappers.add(new _LocationEqualsWrapper(location)); | 1062 wrappers.add(new _LocationEqualsWrapper(location)); |
1063 } | 1063 } |
1064 return wrappers; | 1064 return wrappers; |
1065 } | 1065 } |
1066 } | 1066 } |
OLD | NEW |