ClickGuard { public static OnClickListener retrieveOnClickListener(View view) { if (view == null) { throw new NullPointerException("Given view is null!"); } return ListenerGetter.get(view); } private  ClickGuard(); static ClickGuard newGuard(); static ClickGuard newGuard(long watchPeriodMillis); static GuardedOnClickListener wrap(OnClickListener onClickListener); static GuardedOnClickListener wrap(long watchPeriodMillis, OnClickListener onClickListener); static GuardedOnClickListener wrap(ClickGuard guard, OnClickListener onClickListener); static ClickGuard guard(View view, View... others); static ClickGuard guard(long watchPeriodMillis, View view, View... others); static ClickGuard guard(ClickGuard guard, View view, View... others); static ClickGuard guardAll(Iterable<View> views); static ClickGuard guardAll(long watchPeriodMillis, Iterable<View> views); static ClickGuard guardAll(ClickGuard guard, Iterable<View> views); static ClickGuard get(View view); static OnClickListener retrieveOnClickListener(View view); ClickGuard add(View view); ClickGuard addAll(View view, View... others); ClickGuard addAll(Iterable<View> views); GuardedOnClickListener wrapOnClickListener(OnClickListener onClickListener); abstract void watch(); abstract void rest(); abstract boolean isWatching(); static final long DEFAULT_WATCH_PERIOD_MILLIS; }
@Test public void retrieveTheRightOnClickListener() { View view = new View(Robolectric.application); View.OnClickListener listener = new CountClickListener(); view.setOnClickListener(listener); assertEquals(listener, ClickGuard.retrieveOnClickListener(view)); }