Revert "Make public getFragments() and getLayoutInflater() methods"
This reverts commit 1bf0fc643dadd23d47b9ad667b36d8c0d443c1a8.
The change is being reverted because it broke git_master build.
Change-Id: I902e33114e53ea78f2c556e760131d99ad734b5b
diff --git a/tests/fragment/src/android/fragment/cts/FragmentTestUtil.java b/tests/fragment/src/android/fragment/cts/FragmentTestUtil.java
index e3d97ac..ed79bc2 100644
--- a/tests/fragment/src/android/fragment/cts/FragmentTestUtil.java
+++ b/tests/fragment/src/android/fragment/cts/FragmentTestUtil.java
@@ -76,11 +76,11 @@
return ret[0];
}
- public static boolean popBackStackImmediate(final ActivityTestRule<? extends Activity> rule) {
+ public static boolean popBackStackImmediate(final ActivityTestRule<FragmentTestActivity> rule) {
return popBackStackImmediate(rule, rule.getActivity().getFragmentManager());
}
- public static boolean popBackStackImmediate(final ActivityTestRule<? extends Activity> rule,
+ public static boolean popBackStackImmediate(final ActivityTestRule<FragmentTestActivity> rule,
final FragmentManager fm) {
final boolean[] ret = new boolean[1];
runOnUiThreadRethrow(rule, new Runnable() {
diff --git a/tests/fragment/src/android/fragment/cts/FragmentTransactionTest.java b/tests/fragment/src/android/fragment/cts/FragmentTransactionTest.java
index 19a068a..a25ceb9 100644
--- a/tests/fragment/src/android/fragment/cts/FragmentTransactionTest.java
+++ b/tests/fragment/src/android/fragment/cts/FragmentTransactionTest.java
@@ -14,32 +14,26 @@
* limitations under the License.
*/
+
package android.fragment.cts;
-import static junit.framework.TestCase.assertEquals;
+
import static junit.framework.TestCase.assertFalse;
import static junit.framework.TestCase.assertTrue;
import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
-import android.os.Bundle;
-import android.os.SystemClock;
import android.support.test.InstrumentationRegistry;
import android.support.test.filters.MediumTest;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
-import java.util.List;
-
/**
* Tests usage of the {@link FragmentTransaction} class.
*/
@@ -211,82 +205,6 @@
});
}
- // Ensure that getFragments() works during transactions, even if it is run off thread
- @Test
- public void getFragmentsOffThread() throws Throwable {
- final FragmentManager fm = mActivity.getFragmentManager();
-
- // Make sure that adding a fragment works
- Fragment fragment = new FragmentWithView();
- fm.beginTransaction()
- .add(android.R.id.content, fragment)
- .addToBackStack(null)
- .commit();
-
- FragmentTestUtil.executePendingTransactions(mActivityRule);
- List<Fragment> fragments = fm.getFragments();
- assertEquals(1, fragments.size());
- assertEquals(fragment, fragments.get(0));
-
- // Removed fragments shouldn't show
- fm.beginTransaction()
- .remove(fragment)
- .addToBackStack(null)
- .commit();
- FragmentTestUtil.executePendingTransactions(mActivityRule);
- assertTrue(fm.getFragments().isEmpty());
-
- // Now try detached fragments
- FragmentTestUtil.popBackStackImmediate(mActivityRule);
- fm.beginTransaction()
- .detach(fragment)
- .addToBackStack(null)
- .commit();
- FragmentTestUtil.executePendingTransactions(mActivityRule);
- assertTrue(fm.getFragments().isEmpty());
-
- // Now try hidden fragments
- FragmentTestUtil.popBackStackImmediate(mActivityRule);
- fm.beginTransaction()
- .hide(fragment)
- .addToBackStack(null)
- .commit();
- FragmentTestUtil.executePendingTransactions(mActivityRule);
- fragments = fm.getFragments();
- assertEquals(1, fragments.size());
- assertEquals(fragment, fragments.get(0));
-
- // And showing it again shouldn't change anything:
- FragmentTestUtil.popBackStackImmediate(mActivityRule);
- fragments = fm.getFragments();
- assertEquals(1, fragments.size());
- assertEquals(fragment, fragments.get(0));
-
- // Now pop back to the start state
- FragmentTestUtil.popBackStackImmediate(mActivityRule);
-
- // We can't force concurrency, but we can do it lots of times and hope that
- // we hit it.
- for (int i = 0; i < 100; i++) {
- fm.beginTransaction()
- .add(android.R.id.content, fragment)
- .addToBackStack(null)
- .commit();
- getFragmentsUntilSize(1);
-
- fm.popBackStack();
- getFragmentsUntilSize(0);
- }
- }
-
- private void getFragmentsUntilSize(int expectedSize) {
- final long endTime = SystemClock.uptimeMillis() + 3000;
-
- do {
- assertTrue(SystemClock.uptimeMillis() < endTime);
- } while (mActivity.getFragmentManager().getFragments().size() != expectedSize);
- }
-
public static class CorrectFragment extends Fragment {}
private static class PrivateFragment extends Fragment {}
@@ -294,12 +212,4 @@
static class PackagePrivateFragment extends Fragment {}
private class NonStaticFragment extends Fragment {}
-
- public static class FragmentWithView extends Fragment {
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- return inflater.inflate(R.layout.text_a, container, false);
- }
- }
}