5e0e2cd1b9a6946f7072e1a8eb0c69689a60b27a
[pub/Android/ownCloud.git] / automationTest / src / test / java / com / owncloud / android / test / ui / testSuites / DeleteFolderTestSuite.java
1 /**
2 * ownCloud Android client application
3 *
4 * @author purigarcia
5 * Copyright (C) 2015 ownCloud Inc.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2,
9 * as published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 *
19 */
20
21 package com.owncloud.android.test.ui.testSuites;
22
23 import static org.junit.Assert.*;
24 import io.appium.java_client.android.AndroidDriver;
25
26 import org.junit.After;
27 import org.junit.Before;
28 import org.junit.Rule;
29 import org.junit.experimental.categories.Category;
30 import org.junit.rules.TestName;
31 import org.junit.runners.MethodSorters;
32 import org.junit.FixMethodOrder;
33 import org.junit.Test;
34
35 import com.owncloud.android.test.ui.actions.Actions;
36 import com.owncloud.android.test.ui.groups.NoIgnoreTestCategory;
37 import com.owncloud.android.test.ui.groups.SmokeTestCategory;
38 import com.owncloud.android.test.ui.models.FileListView;
39 import com.owncloud.android.test.ui.models.WaitAMomentPopUp;
40
41
42 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
43 public class DeleteFolderTestSuite{
44 AndroidDriver driver;
45 Common common;
46 private Boolean folderHasBeenCreated = false;
47 private final String FOLDER_NAME = "testCreateFolder";
48
49 @Rule public TestName name = new TestName();
50
51
52 @Before
53 public void setUp() throws Exception {
54 common=new Common();
55 driver=common.setUpCommonDriver();
56 }
57
58 @Test
59 @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class})
60 public void testDeleteFolder () throws Exception {
61 FileListView fileListView = Actions.login(Config.URL, Config.user,
62 Config.password, Config.isTrusted, driver);
63 common.assertIsInFileListView();
64
65 //TODO. if the folder already exists, do no created
66 //create the folder
67 WaitAMomentPopUp waitAMomentPopUp = Actions
68 .createFolder(FOLDER_NAME, fileListView);
69 Common.waitTillElementIsNotPresent(
70 waitAMomentPopUp.getWaitAMomentTextElement(), 100);
71 fileListView.scrollTillFindElement(FOLDER_NAME);
72 assertTrue(
73 folderHasBeenCreated = fileListView.getFileElement().isDisplayed());
74
75 //delete the folder
76 Actions.deleteElement(FOLDER_NAME, fileListView, driver);
77 assertFalse(
78 folderHasBeenCreated =fileListView.getFileElement().isDisplayed());
79 }
80
81 @After
82 public void tearDown() throws Exception {
83 common.takeScreenShotOnFailed(name.getMethodName());
84 if(folderHasBeenCreated){
85 FileListView fileListView = new FileListView(driver);
86 Actions.deleteElement(FOLDER_NAME, fileListView, driver);
87 }
88 driver.removeApp("com.owncloud.android");
89 driver.quit();
90 }
91
92 }