a2bdab33f034953dc7adc292e14c353591599631
[pub/Android/ownCloud.git] / automationTest / src / test / java / com / owncloud / android / test / ui / testSuites / CreateFolderTestSuite.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.FileListView;
19 import com.owncloud.android.test.ui.models.WaitAMomentPopUp;
20
21
22 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
23 public class CreateFolderTestSuite{
24
25 AndroidDriver driver;
26 Common common;
27 private Boolean folderHasBeenCreated = false;
28 private final String FOLDER_NAME = "testCreateFolder";
29 private String CurrentCreatedFolder = "";
30
31 @Rule public TestName name = new TestName();
32
33 @Before
34 public void setUp() throws Exception {
35 common=new Common();
36 driver=common.setUpCommonDriver();
37 }
38
39 @Test
40 @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class})
41 public void testCreateNewFolder () throws Exception {
42 String NEW_FOLDER_NAME = "testCreateFolder";
43
44 FileListView fileListView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver);
45 common.assertIsInFileListView();
46
47 //check if the folder already exists and if true, delete them
48 Actions.deleteElement(NEW_FOLDER_NAME, fileListView, driver);
49
50 WaitAMomentPopUp waitAMomentPopUp = Actions.createFolder(NEW_FOLDER_NAME, fileListView);
51 Common.waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100);
52 fileListView.scrollTillFindElement(FOLDER_NAME);
53 assertNotNull(fileListView.getFileElement());
54 assertTrue(folderHasBeenCreated=fileListView.getFileElement().isDisplayed());
55 CurrentCreatedFolder = FOLDER_NAME;
56 assertEquals(FOLDER_NAME , fileListView.getFileElement().getText());
57 }
58
59 @After
60 public void tearDown() throws Exception {
61 common.takeScreenShotOnFailed(name.getMethodName());
62 if (folderHasBeenCreated) {
63 FileListView fileListView = new FileListView(driver);
64 Actions.deleteElement(CurrentCreatedFolder, fileListView, driver);
65 }
66 driver.removeApp("com.owncloud.android");
67 driver.quit();
68 }
69
70 }