Search in sources :

Example 1 with OnViewChangedNotifier

use of org.androidannotations.api.view.OnViewChangedNotifier in project androidannotations by androidannotations.

the class InheritanceTest method afterViewsMotherCallsFirst.

@Test
public void afterViewsMotherCallsFirst() {
    OnViewChangedNotifier notifier = new OnViewChangedNotifier();
    OnViewChangedNotifier.replaceNotifier(notifier);
    Child_ child = Child_.getInstance_(mock(Activity.class));
    notifier.notifyViewChanged(mock(HasViews.class));
    assertThat(child.motherInitViewsWasCalled).isTrue();
}
Also used : OnViewChangedNotifier(org.androidannotations.api.view.OnViewChangedNotifier) Activity(android.app.Activity) HasViews(org.androidannotations.api.view.HasViews) Test(org.junit.Test)

Example 2 with OnViewChangedNotifier

use of org.androidannotations.api.view.OnViewChangedNotifier in project androidannotations by androidannotations.

the class SomeSingletonTest method viewsAreNotInjected.

@Test
public void viewsAreNotInjected() throws Exception {
    Context context = mock(Context.class);
    OnViewChangedNotifier notifier = new OnViewChangedNotifier();
    OnViewChangedNotifier.replaceNotifier(notifier);
    SomeSingleton singleton = SomeSingleton_.getInstance_(context);
    notifier.notifyViewChanged(new HasViews() {

        @Override
        public View findViewById(int id) {
            return mock(View.class);
        }
    });
    assertThat(singleton.myTextView).isNull();
    assertThat(singleton.beanWithView.myTextView).isNull();
}
Also used : Context(android.content.Context) OnViewChangedNotifier(org.androidannotations.api.view.OnViewChangedNotifier) View(android.view.View) HasViews(org.androidannotations.api.view.HasViews) Test(org.junit.Test)

Aggregations

HasViews (org.androidannotations.api.view.HasViews)2 OnViewChangedNotifier (org.androidannotations.api.view.OnViewChangedNotifier)2 Test (org.junit.Test)2 Activity (android.app.Activity)1 Context (android.content.Context)1 View (android.view.View)1