PageRenderTime 49ms CodeModel.GetById 16ms RepoModel.GetById 0ms 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
Possible License(s): GPL-3.0
  1. package cz.romario.opensudoku.test;
  2. import android.test.ActivityInstrumentationTestCase2;
  3. import com.jayway.android.robotium.solo.Solo;
  4. import cz.romario.opensudoku.gui.FolderListActivity;
  5. import cz.romario.opensudoku.gui.SudokuExportActivity;
  6. import cz.romario.opensudoku.gui.SudokuListActivity;
  7. import cz.romario.opensudoku.R;
  8. public class FolderListActivityTest extends
  9. ActivityInstrumentationTestCase2<FolderListActivity> {
  10. static final String NEW_FOLDER_NAME = "Robotest";
  11. static final String RENAMED_FOLDER_NAME = "RenamedTest";
  12. private Solo solo;
  13. public FolderListActivityTest() {
  14. super("cz.romario.opensudoku", FolderListActivity.class);
  15. }
  16. @Override
  17. protected void setUp() throws Exception {
  18. solo = new Solo(getInstrumentation(), getActivity());
  19. }
  20. public void testListItemSelect() {
  21. solo.clickInList(2);
  22. solo.assertCurrentActivity("SudokuListActivity", SudokuListActivity.class);
  23. String medium = getString(R.string.difficulty_medium);
  24. assertTrue(solo.getCurrentActivity().getTitle().toString().contains(medium));
  25. }
  26. public void testListItemExport() {
  27. String medium = getString(R.string.difficulty_medium);
  28. solo.clickLongOnText(medium);
  29. solo.clickOnText(getString(R.string.export_folder));
  30. solo.assertCurrentActivity("SudokuExportActivity", SudokuExportActivity.class);
  31. assertTrue(solo.searchText(medium));
  32. }
  33. public void testMenuExportAllFolders() {
  34. solo.clickOnMenuItem(getString(R.string.export_all_folders));
  35. solo.assertCurrentActivity("SudokuExportActivity", SudokuExportActivity.class);
  36. }
  37. public void testMenuAbout() {
  38. solo.clickOnMenuItem(getString(R.string.about));
  39. assertTrue(solo.searchText("Version:"));
  40. solo.clickOnButton(getString(android.R.string.ok));
  41. }
  42. public void testGetPuzzlesOnline() {
  43. solo.clickOnButton(getString(R.string.get_more_puzzles_online));
  44. solo.waitForText("opensudoku-android");
  45. }
  46. public void test01MenuAddFolder() throws InterruptedException {
  47. // create test folder
  48. solo.clickOnMenuItem(getString(R.string.add_folder));
  49. solo.enterText(0, NEW_FOLDER_NAME);
  50. solo.clickOnButton(getString(R.string.save));
  51. solo.searchText(NEW_FOLDER_NAME);
  52. // click on our newly created folder
  53. solo.clickInList(getActivity().getListView().getCount());
  54. solo.assertCurrentActivity("SudokuListActivity", SudokuListActivity.class);
  55. assertTrue(solo.getCurrentActivity().getTitle().toString().contains(NEW_FOLDER_NAME));
  56. }
  57. public void test02ListItemRenameFolder() {
  58. solo.clickLongOnText(NEW_FOLDER_NAME);
  59. solo.clickOnText(getString(R.string.rename_folder));
  60. solo.clearEditText(0);
  61. solo.enterText(0, RENAMED_FOLDER_NAME);
  62. solo.clickOnButton(getString(R.string.save));
  63. assertTrue(solo.searchText(RENAMED_FOLDER_NAME));
  64. assertFalse(solo.searchText(NEW_FOLDER_NAME));
  65. }
  66. public void test03ListItemDeleteFolder() throws InterruptedException {
  67. // select folder created in testMenuAddFolder and delete it
  68. solo.clickLongOnText(RENAMED_FOLDER_NAME);
  69. solo.clickOnText(getString(R.string.delete_folder));
  70. solo.clickOnButton(getString(android.R.string.ok));
  71. assertFalse(solo.searchText(RENAMED_FOLDER_NAME));
  72. }
  73. @Override
  74. protected void tearDown() throws Exception {
  75. try {
  76. solo.finalize();
  77. } catch (Throwable e) {
  78. e.printStackTrace();
  79. }
  80. getActivity().finish();
  81. super.tearDown();
  82. }
  83. private void addFolder(String folderName) {
  84. }
  85. private String getString(int resId) {
  86. return getActivity().getString(resId);
  87. }
  88. }