PageRenderTime 32ms CodeModel.GetById 21ms app.highlight 9ms RepoModel.GetById 1ms app.codeStats 0ms

/OpenSudokuFuncTest/src/cz/romario/opensudoku/test/FolderListActivityTest.java

http://opensudoku-android.googlecode.com/
Java | 119 lines | 85 code | 31 blank | 3 comment | 0 complexity | a533ac4db1ed40fd6e8fbb15dd115afa MD5 | raw file
  1package cz.romario.opensudoku.test;
  2
  3import android.test.ActivityInstrumentationTestCase2;
  4
  5import com.jayway.android.robotium.solo.Solo;
  6
  7import cz.romario.opensudoku.gui.FolderListActivity;
  8import cz.romario.opensudoku.gui.SudokuExportActivity;
  9import cz.romario.opensudoku.gui.SudokuListActivity;
 10import cz.romario.opensudoku.R;
 11
 12
 13public class FolderListActivityTest extends
 14		ActivityInstrumentationTestCase2<FolderListActivity> {
 15
 16	static final String NEW_FOLDER_NAME = "Robotest";
 17	static final String RENAMED_FOLDER_NAME = "RenamedTest";	
 18	
 19	private Solo solo;
 20
 21	public FolderListActivityTest() {
 22		super("cz.romario.opensudoku", FolderListActivity.class);
 23	}
 24
 25	@Override
 26	protected void setUp() throws Exception {
 27		solo = new Solo(getInstrumentation(), getActivity());
 28	}
 29	
 30	public void testListItemSelect() {
 31		solo.clickInList(2);
 32		solo.assertCurrentActivity("SudokuListActivity", SudokuListActivity.class);
 33		String medium = getString(R.string.difficulty_medium);
 34		assertTrue(solo.getCurrentActivity().getTitle().toString().contains(medium));
 35	}
 36	
 37	public void testListItemExport() {
 38		String medium = getString(R.string.difficulty_medium);
 39		solo.clickLongOnText(medium);
 40		solo.clickOnText(getString(R.string.export_folder));
 41		solo.assertCurrentActivity("SudokuExportActivity", SudokuExportActivity.class);
 42		assertTrue(solo.searchText(medium));
 43	}
 44	
 45	public void testMenuExportAllFolders() {
 46		solo.clickOnMenuItem(getString(R.string.export_all_folders));
 47		solo.assertCurrentActivity("SudokuExportActivity", SudokuExportActivity.class);
 48	}
 49	
 50	public void testMenuAbout() {
 51		solo.clickOnMenuItem(getString(R.string.about));
 52		assertTrue(solo.searchText("Version:"));
 53		solo.clickOnButton(getString(android.R.string.ok));
 54	}
 55
 56	public void testGetPuzzlesOnline() {
 57		solo.clickOnButton(getString(R.string.get_more_puzzles_online));
 58		solo.waitForText("opensudoku-android");
 59	}
 60	
 61	
 62	
 63	public void test01MenuAddFolder() throws InterruptedException {
 64		// create test folder
 65		solo.clickOnMenuItem(getString(R.string.add_folder));
 66		solo.enterText(0, NEW_FOLDER_NAME);
 67		solo.clickOnButton(getString(R.string.save));
 68		solo.searchText(NEW_FOLDER_NAME);
 69		
 70		// click on our newly created folder
 71		solo.clickInList(getActivity().getListView().getCount());
 72		solo.assertCurrentActivity("SudokuListActivity", SudokuListActivity.class);
 73		assertTrue(solo.getCurrentActivity().getTitle().toString().contains(NEW_FOLDER_NAME));
 74	}
 75	
 76	public void test02ListItemRenameFolder() {
 77		solo.clickLongOnText(NEW_FOLDER_NAME);
 78		solo.clickOnText(getString(R.string.rename_folder));
 79		solo.clearEditText(0);
 80		solo.enterText(0, RENAMED_FOLDER_NAME);
 81		solo.clickOnButton(getString(R.string.save));
 82		
 83		assertTrue(solo.searchText(RENAMED_FOLDER_NAME));
 84		assertFalse(solo.searchText(NEW_FOLDER_NAME));
 85	}
 86	
 87	public void test03ListItemDeleteFolder() throws InterruptedException {
 88		// select folder created in testMenuAddFolder and delete it
 89		solo.clickLongOnText(RENAMED_FOLDER_NAME);
 90		solo.clickOnText(getString(R.string.delete_folder));
 91		solo.clickOnButton(getString(android.R.string.ok));
 92		
 93		assertFalse(solo.searchText(RENAMED_FOLDER_NAME));
 94	}
 95	
 96
 97	@Override
 98	protected void tearDown() throws Exception {
 99		try {
100			solo.finalize();
101		} catch (Throwable e) {
102
103			e.printStackTrace();
104		}
105		getActivity().finish();
106		super.tearDown();
107
108	}
109	
110	private void addFolder(String folderName) {
111		
112	}
113	
114	private String getString(int resId) {
115		return getActivity().getString(resId);
116	}
117	
118
119}