diff --git a/AndroidAnnotations/androidannotations-core/androidannotations-test/src/test/java/org/androidannotations/test/efragment/MyListFragmentTest.java b/AndroidAnnotations/androidannotations-core/androidannotations-test/src/test/java/org/androidannotations/test/efragment/MyListFragmentTest.java index 78c55e8274..5818c370ad 100644 --- a/AndroidAnnotations/androidannotations-core/androidannotations-test/src/test/java/org/androidannotations/test/efragment/MyListFragmentTest.java +++ b/AndroidAnnotations/androidannotations-core/androidannotations-test/src/test/java/org/androidannotations/test/efragment/MyListFragmentTest.java @@ -49,11 +49,11 @@ public class MyListFragmentTest { @Before public void setUp() { myListFragment = new MyListFragment_(); - startFragment(myListFragment); } @Test public void isItemClickAvailableFromListFragment() { + startFragment(myListFragment); ListView listView = (ListView) myListFragment.findViewById(android.R.id.list); long itemId = listView.getAdapter().getItemId(TESTED_CLICKED_INDEX); View view = listView.getChildAt(TESTED_CLICKED_INDEX); @@ -65,6 +65,7 @@ public void isItemClickAvailableFromListFragment() { @Test public void notIgnoredMethodIsCalled() { + startFragment(myListFragment); assertFalse(myListFragment.didExecute); myListFragment.notIgnored(); assertTrue(myListFragment.didExecute); @@ -72,6 +73,7 @@ public void notIgnoredMethodIsCalled() { @Test public void uithreadMethodIsCalled() { + startFragment(myListFragment); assertFalse(myListFragment.didExecute); myListFragment.uiThread(); assertTrue(myListFragment.didExecute); @@ -79,6 +81,7 @@ public void uithreadMethodIsCalled() { @Test public void uithreadMethodIsCanceled() { + startFragment(myListFragment); ShadowLooper.pauseMainLooper(); myListFragment.uiThreadWithId(); UiThreadExecutor.cancelAll("id"); @@ -88,6 +91,7 @@ public void uithreadMethodIsCanceled() { @Test public void backgroundMethodIsCalled() { + startFragment(myListFragment); assertFalse(myListFragment.didExecute); runBackgroundsOnSameThread(); myListFragment.backgroundThread(); @@ -96,6 +100,7 @@ public void backgroundMethodIsCalled() { @Test public void ignoredWhenDetachedWorksForUithreadMethod() { + startFragment(myListFragment); popBackStack(); assertFalse(myListFragment.didExecute); @@ -105,6 +110,7 @@ public void ignoredWhenDetachedWorksForUithreadMethod() { @Test public void ignoredWhenDetachedWorksForBackgroundMethod() { + startFragment(myListFragment); popBackStack(); assertFalse(myListFragment.didExecute); @@ -115,6 +121,7 @@ public void ignoredWhenDetachedWorksForBackgroundMethod() { @Test public void ignoredWhenDetachedWorksForIgnoredMethod() { + startFragment(myListFragment); popBackStack(); assertFalse(myListFragment.didExecute); @@ -122,8 +129,16 @@ public void ignoredWhenDetachedWorksForIgnoredMethod() { assertFalse(myListFragment.didExecute); } + @Test + public void ignoredBeforeOnCreateView() { + assertFalse(myListFragment.didExecute); + myListFragment.ignoreWhenViewDestroyed(); + assertFalse(myListFragment.didExecute); + } + @Test public void notIgnoredAfterOnCreateView() { + startFragment(myListFragment); assertFalse(myListFragment.didExecute); myListFragment.onCreateView(null, null, null); assertFalse(myListFragment.didExecute); @@ -133,6 +148,7 @@ public void notIgnoredAfterOnCreateView() { @Test public void ignoredWhenViewDestroyedForIgnoredMethod() { + startFragment(myListFragment); assertFalse(myListFragment.didExecute); myListFragment.onDestroyView(); myListFragment.ignoreWhenViewDestroyed(); @@ -141,6 +157,7 @@ public void ignoredWhenViewDestroyedForIgnoredMethod() { @Test public void notIgnoredAfterFragmentRecreate() { + startFragment(myListFragment); assertFalse(myListFragment.didExecute); myListFragment.onDestroyView(); myListFragment.onCreateView(null, null, null); @@ -150,6 +167,7 @@ public void notIgnoredAfterFragmentRecreate() { @Test public void notIgnoredBeforeDetached() { + startFragment(myListFragment); assertFalse(myListFragment.didExecute); myListFragment.ignored(); assertTrue(myListFragment.didExecute); @@ -157,6 +175,7 @@ public void notIgnoredBeforeDetached() { @Test public void notIgnoredBeforeViewDestroyed() { + startFragment(myListFragment); assertFalse(myListFragment.didExecute); myListFragment.ignoreWhenViewDestroyed(); assertTrue(myListFragment.didExecute); @@ -164,6 +183,7 @@ public void notIgnoredBeforeViewDestroyed() { @Test public void layoutNotInjectedWithoutForce() { + startFragment(myListFragment); View buttonInInjectedLayout = myListFragment.getView().findViewById(R.id.conventionButton); assertThat(buttonInInjectedLayout).isNull(); diff --git a/AndroidAnnotations/androidannotations-core/androidannotations/src/main/java/org/androidannotations/holder/EFragmentHolder.java b/AndroidAnnotations/androidannotations-core/androidannotations/src/main/java/org/androidannotations/holder/EFragmentHolder.java index e6afa6376e..dd8e705d2e 100644 --- a/AndroidAnnotations/androidannotations-core/androidannotations/src/main/java/org/androidannotations/holder/EFragmentHolder.java +++ b/AndroidAnnotations/androidannotations-core/androidannotations/src/main/java/org/androidannotations/holder/EFragmentHolder.java @@ -221,7 +221,7 @@ public JFieldVar getViewDestroyedField() { } private void setViewDestroyedField() { - viewDestroyedField = generatedClass.field(PRIVATE | VOLATILE, getCodeModel().BOOLEAN, "viewDestroyed" + generationSuffix()); + viewDestroyedField = generatedClass.field(PRIVATE | VOLATILE, getCodeModel().BOOLEAN, "viewDestroyed" + generationSuffix(), TRUE); getSetContentViewBlock().assign(viewDestroyedField, FALSE); getOnDestroyViewAfterSuperBlock().assign(viewDestroyedField, TRUE); }