Adrien BĂ©raud | 04d822c | 2015-04-02 17:44:36 -0400 | [diff] [blame] | 1 | package cx.ring.client; |
| 2 | |
| 3 | import android.test.ActivityInstrumentationTestCase2; |
| 4 | import com.robotium.solo.Solo; |
| 5 | import junit.framework.Assert; |
| 6 | import cx.ring.fragments.AboutFragment; |
| 7 | import cx.ring.fragments.AccountsManagementFragment; |
| 8 | import cx.ring.fragments.HomeFragment; |
| 9 | |
| 10 | /** |
| 11 | * This is a simple framework for a test of an Application. See |
| 12 | * {@link android.test.ApplicationTestCase ApplicationTestCase} for more information on |
| 13 | * how to write and extend Application tests. |
| 14 | * <p/> |
| 15 | * To run this test, you can type: |
| 16 | * adb shell am instrument -w \ |
| 17 | * -e class org.sflphone.client.HomeActivityTest \ |
| 18 | * org.sflphone.tests/android.test.InstrumentationTestRunner |
| 19 | */ |
| 20 | public class HomeActivityTest extends ActivityInstrumentationTestCase2<HomeActivity> { |
| 21 | |
| 22 | HomeActivity mActivity; |
| 23 | Solo mSolo; |
| 24 | |
| 25 | public HomeActivityTest() { |
| 26 | super(HomeActivity.class); |
| 27 | } |
| 28 | |
| 29 | @Override |
| 30 | protected void setUp() throws Exception { |
| 31 | super.setUp(); |
| 32 | mActivity = getActivity(); |
| 33 | mSolo = new Solo(getInstrumentation(), getActivity()); |
| 34 | } |
| 35 | |
| 36 | public void testService() throws Exception { |
| 37 | Assert.assertTrue(mActivity.getService() != null); |
| 38 | Assert.assertTrue(mActivity.getService().getRecordPath() != null); |
| 39 | } |
| 40 | |
| 41 | public void testSections() throws Exception { |
| 42 | mActivity.onSectionSelected(0); |
| 43 | Assert.assertTrue(mActivity.fContent instanceof HomeFragment); |
| 44 | String homeScreenTitle = String.format("%s.%s", getClass().getSimpleName(), getName()); |
| 45 | mSolo.takeScreenshot(homeScreenTitle); |
| 46 | mActivity.onSectionSelected(1); |
| 47 | Assert.assertTrue(mActivity.fContent instanceof AccountsManagementFragment); |
| 48 | mSolo.sleep(500); |
| 49 | String accountsScreenTitle = String.format("%s.%s", ((Object)mActivity.fContent).getClass().getSimpleName(), getName()); |
| 50 | mSolo.takeScreenshot(accountsScreenTitle); |
| 51 | mActivity.onSectionSelected(2); |
| 52 | Assert.assertTrue(mActivity.fContent instanceof AboutFragment); |
| 53 | mSolo.sleep(500); |
| 54 | String aboutScreenTitle = String.format("%s.%s", ((Object)mActivity.fContent).getClass().getSimpleName(), getName()); |
| 55 | mSolo.takeScreenshot(aboutScreenTitle); |
| 56 | } |
| 57 | |
| 58 | } |