add new testCases. prepare the test to have them into categories
[pub/Android/ownCloud.git] / automationTest / src / test / java / androidtest / tests / RenameFolderTestSuite.java
1 package androidtest.tests;
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 androidtest.actions.Actions;
16 import androidtest.groups.NoIgnoreTestCategory;
17 import androidtest.groups.SmokeTestCategory;
18 import androidtest.models.ElementMenuOptions;
19 import androidtest.models.MainView;
20 import androidtest.models.NewFolderPopUp;
21 import androidtest.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 MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver);
47 common.assertIsInMainView();
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, mainView);
52 Common.waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100);
53 mainView.scrollTillFindElement(OLD_FOLDER_NAME);
54
55 assertTrue(folderHasBeenCreated = mainView.getFileElement().isDisplayed());
56
57 //check if the folder with the new name already exists and if true, delete them
58 Actions.deleteElement(FOLDER_NAME, mainView, driver);
59
60 CurrentCreatedFolder = OLD_FOLDER_NAME;
61 ElementMenuOptions menuOptions = mainView.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 mainView.scrollTillFindElement(FOLDER_NAME);
68 assertNotNull(mainView.getFileElement());
69 assertTrue(folderHasBeenCreated = mainView.getFileElement().isDisplayed());
70 assertEquals(FOLDER_NAME , mainView.getFileElement().getText());
71 }
72
73 @After
74 public void tearDown() throws Exception {
75 common.takeScreenShotOnFailed(name.getMethodName());
76 if(folderHasBeenCreated){
77 MainView mainView = new MainView(driver);
78 Actions.deleteElement(CurrentCreatedFolder, mainView, driver);
79 }
80 driver.removeApp("com.owncloud.android");
81 driver.quit();
82 }
83
84 }