1 package androidtest
.tests
;
3 import org
.junit
.After
;
4 import org
.junit
.Before
;
5 import org
.junit
.runners
.MethodSorters
;
6 import org
.junit
.FixMethodOrder
;
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
;
15 @FixMethodOrder(MethodSorters
.NAME_ASCENDING
)
16 public class RenameFolderTestSuite
extends Common
{
18 private Boolean folderHasBeenCreated
= false
;
19 private final String OLD_FOLDER_NAME
= "beforeRemoving";
20 private final String FOLDER_NAME
= "testCreateFolder";
21 private String CurrentCreatedFolder
= "";
25 public void setUp() throws Exception
{
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());
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
);
40 assertTrue(folderHasBeenCreated
= mainView
.getFileElement().isDisplayed());
42 //check if the folder with the new name already exists and if true, delete them
43 Actions
.deleteElement(FOLDER_NAME
, mainView
, driver
);
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());
59 public void tearDown() throws Exception
{
60 if(folderHasBeenCreated
){
61 MainView mainView
= new MainView(driver
);
62 Actions
.deleteElement(CurrentCreatedFolder
, mainView
, driver
);
64 driver
.removeApp("com.owncloud.android");