class NestedScrollView extends FrameLayout implements NestedScrollingParent2,
        NestedScrollingChild2, ScrollingView {

    @Override
    protected float getBottomFadingEdgeStrength() {
        if (getChildCount() == 0) {
            return 0.0f;
        }

        View child = getChildAt(0);
        final NestedScrollView.LayoutParams lp = (LayoutParams) child.getLayoutParams();
        final int length = getVerticalFadingEdgeLength();
        final int bottomEdge = getHeight() - getPaddingBottom();
        final int span = child.getBottom() + lp.bottomMargin - getScrollY() - bottomEdge;
        if (span < length) {
            return span / (float) length;
        }

        return 1.0f;
    }

}

class NestedScrollViewTest extends FrameLayout {

    private NestedScrollView mNestedScrollView;
    private View mChild;

    @Test
    public void getBottomFadingEdgeStrength_childBottomIsAboveParentAndNoMargin_isZero() {

        setup(100);
        mNestedScrollView.setVerticalFadingEdgeEnabled(true);
        measureAndLayout(100);

        float expected = mNestedScrollView.getBottomFadingEdgeStrength();

        assertThat(expected, is(0f));
    }

}