|
| 1 | +/** |
| 2 | + * Copyright (C) 2010-2014 eBusiness Information, Excilys Group |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); you may not |
| 5 | + * use this file except in compliance with the License. You may obtain a copy of |
| 6 | + * the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed To in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 12 | + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 13 | + * License for the specific language governing permissions and limitations under |
| 14 | + * the License. |
| 15 | + */ |
| 16 | +package org.androidannotations.test15; |
| 17 | + |
| 18 | +import static org.fest.assertions.api.Assertions.assertThat; |
| 19 | + |
| 20 | +import org.androidannotations.test15.instancestate.SaveInstanceStateActivityParameterizedTest; |
| 21 | +import org.junit.Test; |
| 22 | +import org.junit.runner.RunWith; |
| 23 | +import org.robolectric.RobolectricTestRunner; |
| 24 | + |
| 25 | +import android.os.Bundle; |
| 26 | + |
| 27 | +@RunWith(RobolectricTestRunner.class) |
| 28 | +public class FragmentArgsTest { |
| 29 | + |
| 30 | + private static final int TEST_INT = 42; |
| 31 | + |
| 32 | + /** |
| 33 | + * This test verifies the Fragment argument gets injected. It does not check |
| 34 | + * for different types, because we use the same code for every |
| 35 | + * Bundle-related operation and types are already tested in |
| 36 | + * {@link SaveInstanceStateActivityParameterizedTest}. |
| 37 | + * |
| 38 | + */ |
| 39 | + @Test |
| 40 | + public void testFragmentArgInjected() { |
| 41 | + Bundle bundle = new Bundle(); |
| 42 | + bundle.putInt("myInt", TEST_INT); |
| 43 | + |
| 44 | + FragmentArguments fragment = new FragmentArguments_(); |
| 45 | + fragment.setArguments(bundle); |
| 46 | + |
| 47 | + assertThat(fragment.myInt).isZero(); |
| 48 | + |
| 49 | + fragment.onCreate(null); |
| 50 | + |
| 51 | + assertThat(fragment.myInt).isEqualTo(TEST_INT); |
| 52 | + } |
| 53 | +} |
0 commit comments