MoveFolderTestSuite.java 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. package androidtest.tests;
  2. import static org.junit.Assert.*;
  3. import io.appium.java_client.android.AndroidDriver;
  4. import org.junit.After;
  5. import org.junit.Before;
  6. import org.junit.Rule;
  7. import org.junit.experimental.categories.Category;
  8. import org.junit.rules.TestName;
  9. import org.junit.runners.MethodSorters;
  10. import org.junit.FixMethodOrder;
  11. import org.junit.Test;
  12. import androidtest.actions.Actions;
  13. import androidtest.groups.NoIgnoreTestCategory;
  14. import androidtest.groups.SmokeTestCategory;
  15. import androidtest.models.ElementMenuOptions;
  16. import androidtest.models.MainView;
  17. import androidtest.models.MoveView;
  18. import androidtest.models.WaitAMomentPopUp;
  19. @FixMethodOrder(MethodSorters.NAME_ASCENDING)
  20. public class MoveFolderTestSuite{
  21. AndroidDriver driver;
  22. Common common;
  23. private String FOLDER_TO_MOVE = "folderToMove";
  24. private String FOLDER_WHERE_MOVE = "folderWhereMove";
  25. @Rule public TestName name = new TestName();
  26. @Before
  27. public void setUp() throws Exception {
  28. common=new Common();
  29. driver=common.setUpCommonDriver();
  30. }
  31. @Test
  32. @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class})
  33. public void testMoveFolder () throws Exception {
  34. WaitAMomentPopUp waitAMomentPopUp;
  35. MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver);
  36. common.assertIsInMainView();
  37. Common.waitTillElementIsNotPresent(mainView.getProgressCircular(), 1000);
  38. //check if the folder already exists and if true, delete them
  39. Actions.deleteElement(FOLDER_WHERE_MOVE, mainView, driver);
  40. Actions.deleteElement(FOLDER_TO_MOVE, mainView, driver);
  41. //Create the folder where the other is gone to be moved
  42. waitAMomentPopUp = Actions.createFolder(FOLDER_WHERE_MOVE, mainView);
  43. Common.waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100);
  44. mainView.scrollTillFindElement(FOLDER_WHERE_MOVE);
  45. assertTrue(mainView.getFileElement().isDisplayed());
  46. //Create the folder which is going to be moved
  47. waitAMomentPopUp = Actions.createFolder(FOLDER_TO_MOVE, mainView);
  48. Common.waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100);
  49. mainView.scrollTillFindElement(FOLDER_TO_MOVE);
  50. assertTrue(mainView.getFileElement().isDisplayed());
  51. //select to move the folder
  52. ElementMenuOptions menuOptions = mainView.longPressOnElement(FOLDER_TO_MOVE);
  53. MoveView moveView = menuOptions.clickOnMove();
  54. //to move to a folder
  55. moveView.scrollTillFindElement(FOLDER_WHERE_MOVE).tap(1,1);
  56. waitAMomentPopUp = moveView.clickOnChoose();
  57. Common.waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100);
  58. //check that the folder moved is inside the other
  59. mainView.scrollTillFindElement(FOLDER_WHERE_MOVE).tap(1,1);
  60. Common.waitTillElementIsNotPresent(mainView.getProgressCircular(), 1000);
  61. Thread.sleep(1000);
  62. mainView.scrollTillFindElement(FOLDER_TO_MOVE);
  63. assertEquals(FOLDER_TO_MOVE , mainView.getFileElement().getText());
  64. }
  65. @After
  66. public void tearDown() throws Exception {
  67. common.takeScreenShotOnFailed(name.getMethodName());
  68. MainView mainView = new MainView(driver);
  69. driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_BACK);
  70. Actions.deleteElement(FOLDER_WHERE_MOVE, mainView, driver);
  71. Actions.deleteElement(FOLDER_TO_MOVE, mainView, driver);
  72. driver.removeApp("com.owncloud.android");
  73. driver.quit();
  74. }
  75. }