@Test public void twoInstancesOfSameSubcomponent() { // Two instances of the same subcomponent. ChildAsserts child2Asserts = parentAsserts.newChildAsserts(); childAsserts.assertBindingCallCounts(); child2Asserts.assertBindingCallCounts(); component.childReleasableScope1Manager().releaseStrongReferences(); // release scope 3 childAsserts.assertBindingCallCounts(); // no change to scoped bindings in child 1 child2Asserts.assertBindingCallCounts(); // no change to scoped bindings in child 2 gcAndWaitUntilWeakReferencesCleared( ParentModule.class, ChildModule.class, ChildReleasableScope1.class); // GC childAsserts.expectedCallsForChildReleasableScope1Thing++; // expect scope 3 bindings again childAsserts.assertBindingCallCounts(); // when calling child.things() child2Asserts.expectedCallsForChildReleasableScope1Thing++; // expect scope 3 bindings yet again child2Asserts.assertBindingCallCounts(); // when calling child2.things() }
private void assertBindingCallCounts() { parentAsserts.assertBindingCallCounts(); childAsserts.assertBindingCallCounts(); }