@Test public void testLayoutOutputForRootWithNullLayout() { final Component componentWithNullLayout = new InlineLayoutSpec() { @Override protected Component onCreateLayout(ComponentContext c) { return null; } }; LayoutState layoutState = calculateLayoutState( application, componentWithNullLayout, -1, makeSizeSpec(350, EXACTLY), makeSizeSpec(200, EXACTLY)); assertThat(layoutState.getVisibilityOutputCount()).isEqualTo(0); }
@Test public void testLayoutComponentForNestedTreeChildWithNullLayout() { final Component component = new InlineLayoutSpec() { @Override protected Component onCreateLayout(ComponentContext c) { return create(c) .paddingPx(ALL, 2) .child(new TestNullLayoutComponent()) .invisibleHandler(c.newEventHandler(2)) .build(); } }; LayoutState layoutState = calculateLayoutState( application, component, -1, makeSizeSpec(350, EXACTLY), makeSizeSpec(200, EXACTLY)); assertThat(layoutState.getVisibilityOutputCount()).isEqualTo(1); }
assertThat(layoutState.getVisibilityOutputCount()).isEqualTo(4); for (int i = 0; i < layoutState.getVisibilityOutputCount(); i++) { if (layoutState.getVisibilityOutputAt(i).getVisibleEventHandler() != null) { visibleHandlerCount += 1;
@Test public void testVisibilityOutputsForDelegateComponents() { final boolean isDelegate = true; final Component component = new InlineLayoutSpec() { @Override protected Component onCreateLayout(ComponentContext c) { return create(c) .child( TestLayoutComponent.create(c, 0, 0, true, true, false, isDelegate) .visibleHandler(c.newEventHandler(1))) .wrapInView() .build(); } }; LayoutState layoutState = calculateLayoutState( application, component, -1, makeSizeSpec(100, EXACTLY), makeSizeSpec(100, EXACTLY)); assertThat(layoutState.getVisibilityOutputCount()).isEqualTo(1); }
@Test public void testLayoutOutputsForForceWrappedComponent() { final Component component = new InlineLayoutSpec() { @Override protected Component onCreateLayout(ComponentContext c) { return create(c) .child( TestDrawableComponent.create(c) .visibleHandler(c.newEventHandler(1)) .wrapInView()) .build(); } }; final LayoutState layoutState = calculateLayoutState( application, component, -1, makeSizeSpec(100, EXACTLY), makeSizeSpec(100, EXACTLY)); assertThat(layoutState.getVisibilityOutputCount()).isEqualTo(1); }
@Test public void testNoUnnecessaryVisibilityOutputs() { final Component component = new InlineLayoutSpec() { @Override protected Component onCreateLayout(ComponentContext c) { return create(c) .child( create(c) .child( TestDrawableComponent.create(c).visibleHandler(c.newEventHandler(1)))) .child(TestDrawableComponent.create(c).invisibleHandler(c.newEventHandler(2))) .child(TestDrawableComponent.create(c)) .build(); } }; LayoutState layoutState = calculateLayoutState( application, component, -1, makeSizeSpec(100, EXACTLY), makeSizeSpec(100, EXACTLY)); assertThat(layoutState.getVisibilityOutputCount()).isEqualTo(2); }
@Test public void testNoUnnecessaryVisibilityOutputsWithFocused() { final Component component = new InlineLayoutSpec() { @Override protected Component onCreateLayout(ComponentContext c) { return create(c) .child( create(c) .child( TestDrawableComponent.create(c).visibleHandler(c.newEventHandler(1)))) .child(TestDrawableComponent.create(c).focusedHandler(c.newEventHandler(4))) .child(TestDrawableComponent.create(c)) .build(); } }; LayoutState layoutState = calculateLayoutState( application, component, -1, makeSizeSpec(100, EXACTLY), makeSizeSpec(100, EXACTLY)); assertThat(layoutState.getVisibilityOutputCount()).isEqualTo(2); }
@Test public void testNoUnnecessaryVisibilityOutputsWithFullImpression() { final Component component = new InlineLayoutSpec() { @Override protected Component onCreateLayout(ComponentContext c) { return create(c) .child( create(c) .child( TestDrawableComponent.create(c).visibleHandler(c.newEventHandler(1)))) .child(TestDrawableComponent.create(c).fullImpressionHandler(c.newEventHandler(3))) .child(TestDrawableComponent.create(c)) .build(); } }; LayoutState layoutState = calculateLayoutState( application, component, -1, makeSizeSpec(100, EXACTLY), makeSizeSpec(100, EXACTLY)); assertThat(layoutState.getVisibilityOutputCount()).isEqualTo(2); }
final boolean isTracing = ComponentsSystrace.isTracing(); final long totalStartTime = isDoingPerfLog ? System.nanoTime() : 0L; for (int j = 0, size = layoutState.getVisibilityOutputCount(); j < size; j++) { final VisibilityOutput visibilityOutput = layoutState.getVisibilityOutputAt(j); if (isTracing) {