add new test cases
[pub/Android/ownCloud.git] / automationTest / src / test / java / androidtest / tests / RenameFolderTestSuite.java
1 package androidtest.tests;
2
3 import org.junit.After;
4 import org.junit.Before;
5 import org.junit.runners.MethodSorters;
6 import org.junit.FixMethodOrder;
7 import org.junit.Test;
8 import androidtest.actions.Actions;
9 import androidtest.models.ElementMenuOptions;
10 import androidtest.models.MainView;
11 import androidtest.models.NewFolderPopUp;
12 import androidtest.models.WaitAMomentPopUp;
13
14
15 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
16 public class RenameFolderTestSuite extends Common{
17
18 private Boolean folderHasBeenCreated = false;
19 private final String OLD_FOLDER_NAME = "beforeRemoving";
20 private final String FOLDER_NAME = "testCreateFolder";
21 private String CurrentCreatedFolder = "";
22
23
24 @Before
25 public void setUp() throws Exception {
26 setUpCommonDriver();
27 }
28
29 @Test
30 public void testRenameFolder () throws Exception {
31 MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver);
32 waitForTextPresent("ownCloud", mainView.getTitleTextElement());
33
34 //TODO. if the folder already exists, do no created
35 //create the folder to rename
36 WaitAMomentPopUp waitAMomentPopUp = Actions.createFolder(OLD_FOLDER_NAME, mainView);
37 waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100);
38 mainView.scrollTillFindElement(OLD_FOLDER_NAME);
39
40 assertTrue(folderHasBeenCreated = mainView.getFileElement().isDisplayed());
41
42 //check if the folder with the new name already exists and if true, delete them
43 Actions.deleteElement(FOLDER_NAME, mainView, driver);
44
45 CurrentCreatedFolder = OLD_FOLDER_NAME;
46 ElementMenuOptions menuOptions = mainView.longPressOnElement(OLD_FOLDER_NAME);
47 NewFolderPopUp FolderPopUp = menuOptions.clickOnRename();
48 FolderPopUp.typeNewFolderName(FOLDER_NAME);
49 FolderPopUp.clickOnNewFolderOkButton();
50 CurrentCreatedFolder = FOLDER_NAME;
51 waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100);
52 mainView.scrollTillFindElement(FOLDER_NAME);
53 assertNotNull(mainView.getFileElement());
54 assertTrue(folderHasBeenCreated = mainView.getFileElement().isDisplayed());
55 assertEquals(FOLDER_NAME , mainView.getFileElement().getText());
56 }
57
58 @After
59 public void tearDown() throws Exception {
60 if(folderHasBeenCreated){
61 MainView mainView = new MainView(driver);
62 Actions.deleteElement(CurrentCreatedFolder, mainView, driver);
63 }
64 driver.removeApp("com.owncloud.android");
65 driver.quit();
66 }
67
68 }