0983f017f7cd4074d5072e78beab39bdf119be15
[pub/Android/ownCloud.git] / automationTest / src / test / java / com / owncloud / android / test / ui / testSuites / RenameFolderTestSuite.java
1 package com.owncloud.android.test.ui.testSuites;
2
3 import static org.junit.Assert.*;
4 import io.appium.java_client.android.AndroidDriver;
5
6 import org.junit.After;
7 import org.junit.Before;
8 import org.junit.Rule;
9 import org.junit.experimental.categories.Category;
10 import org.junit.rules.TestName;
11 import org.junit.runners.MethodSorters;
12 import org.junit.FixMethodOrder;
13 import org.junit.Test;
14
15 import com.owncloud.android.test.ui.actions.Actions;
16 import com.owncloud.android.test.ui.groups.NoIgnoreTestCategory;
17 import com.owncloud.android.test.ui.groups.SmokeTestCategory;
18 import com.owncloud.android.test.ui.models.ElementMenuOptions;
19 import com.owncloud.android.test.ui.models.FileListView;
20 import com.owncloud.android.test.ui.models.NewFolderPopUp;
21 import com.owncloud.android.test.ui.models.WaitAMomentPopUp;
22
23
24 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
25 public class RenameFolderTestSuite{
26
27 AndroidDriver driver;
28 Common common;
29 private Boolean folderHasBeenCreated = false;
30 private final String OLD_FOLDER_NAME = "beforeRemoving";
31 private final String FOLDER_NAME = "testCreateFolder";
32 private String CurrentCreatedFolder = "";
33
34 @Rule public TestName name = new TestName();
35
36
37 @Before
38 public void setUp() throws Exception {
39 common=new Common();
40 driver=common.setUpCommonDriver();
41 }
42
43 @Test
44 @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class})
45 public void testRenameFolder () throws Exception {
46 FileListView fileListView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver);
47 common.assertIsInFileListView();
48
49 //TODO. if the folder already exists, do no created
50 //create the folder to rename
51 WaitAMomentPopUp waitAMomentPopUp = Actions.createFolder(OLD_FOLDER_NAME, fileListView);
52 Common.waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100);
53 fileListView.scrollTillFindElement(OLD_FOLDER_NAME);
54
55 assertTrue(folderHasBeenCreated = fileListView.getFileElement().isDisplayed());
56
57 //check if the folder with the new name already exists and if true, delete them
58 Actions.deleteElement(FOLDER_NAME, fileListView, driver);
59
60 CurrentCreatedFolder = OLD_FOLDER_NAME;
61 ElementMenuOptions menuOptions = fileListView.longPressOnElement(OLD_FOLDER_NAME);
62 NewFolderPopUp FolderPopUp = menuOptions.clickOnRename();
63 FolderPopUp.typeNewFolderName(FOLDER_NAME);
64 FolderPopUp.clickOnNewFolderOkButton();
65 CurrentCreatedFolder = FOLDER_NAME;
66 Common.waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100);
67 fileListView.scrollTillFindElement(FOLDER_NAME);
68 assertNotNull(fileListView.getFileElement());
69 assertTrue(folderHasBeenCreated = fileListView.getFileElement().isDisplayed());
70 assertEquals(FOLDER_NAME , fileListView.getFileElement().getText());
71 }
72
73 @After
74 public void tearDown() throws Exception {
75 common.takeScreenShotOnFailed(name.getMethodName());
76 if(folderHasBeenCreated){
77 FileListView fileListView = new FileListView(driver);
78 Actions.deleteElement(CurrentCreatedFolder, fileListView, driver);
79 }
80 driver.removeApp("com.owncloud.android");
81 driver.quit();
82 }
83
84 }