### Question:
CustomViewTarget implements Target<Z> { @Override public final void onLoadCleared(@Nullable Drawable placeholder) { sizeDeterminer.clearCallbacksAndListener(); onResourceCleared(placeholder); if (!isClearedByUs) { maybeRemoveAttachStateListener(); } } CustomViewTarget(@NonNull T view); @Override void onStart(); @Override void onStop(); @Override void onDestroy(); @SuppressWarnings("WeakerAccess") // Public API @NonNull final CustomViewTarget<T, Z> waitForLayout(); @NonNull @SuppressWarnings({"UnusedReturnValue", "WeakerAccess"}) final CustomViewTarget<T, Z> clearOnDetach(); @SuppressWarnings({"UnusedReturnValue", "WeakerAccess"}) final CustomViewTarget<T, Z> useTagId(@IdRes int tagId); @NonNull final T getView(); @Override final void getSize(@NonNull SizeReadyCallback cb); @Override final void removeCallback(@NonNull SizeReadyCallback cb); @Override final void onLoadStarted(@Nullable Drawable placeholder); @Override final void onLoadCleared(@Nullable Drawable placeholder); @Override final void setRequest(@Nullable Request request); @Override @Nullable final Request getRequest(); @Override String toString();  }### Answer:
@Test public void onLoadCleared_withoutClearOnDetach_doesNotRemoveListeners() { final AtomicInteger count = new AtomicInteger(); OnAttachStateChangeListener expected = new OnAttachStateChangeListener() { @Override public void onViewAttachedToWindow(View v) { count.incrementAndGet(); } @Override public void onViewDetachedFromWindow(View v) { } }; view.addOnAttachStateChangeListener(expected); attachStateTarget.onLoadCleared( null); activity.visible(); Truth.assertThat(count.get()).isEqualTo(1); }