d9d5b272f2fe74c033b7e292477a9dfafdcc9ead
[pub/Android/ownCloud.git] / automationTest / src / test / java / com / owncloud / android / test / ui / testSuites / CreateFolderTestSuite.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 CreateFolderTestSuite{
44
45 AndroidDriver driver;
46 Common common;
47 private Boolean folderHasBeenCreated = false;
48 private final String FOLDER_NAME = "testCreateFolder";
49 private String CurrentCreatedFolder = "";
50
51 @Rule public TestName name = new TestName();
52
53 @Before
54 public void setUp() throws Exception {
55 common=new Common();
56 driver=common.setUpCommonDriver();
57 }
58
59 @Test
60 @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class})
61 public void testCreateNewFolder () throws Exception {
62 String NEW_FOLDER_NAME = "testCreateFolder";
63
64 FileListView fileListView = Actions.login(Config.URL,
65 Config.user,Config.password, Config.isTrusted, driver);
66 common.assertIsInFileListView();
67
68 //check if the folder already exists and if true, delete them
69 Actions.deleteElement(NEW_FOLDER_NAME, fileListView, driver);
70
71 WaitAMomentPopUp waitAMomentPopUp = Actions
72 .createFolder(NEW_FOLDER_NAME, fileListView);
73 Common.waitTillElementIsNotPresent(waitAMomentPopUp
74 .getWaitAMomentTextElement(), 100);
75 fileListView.scrollTillFindElement(FOLDER_NAME);
76 assertNotNull(fileListView.getFileElement());
77 assertTrue(
78 folderHasBeenCreated=fileListView.getFileElement().isDisplayed());
79 CurrentCreatedFolder = FOLDER_NAME;
80 assertEquals(FOLDER_NAME , fileListView.getFileElement().getText());
81 }
82
83 @After
84 public void tearDown() throws Exception {
85 common.takeScreenShotOnFailed(name.getMethodName());
86 if (folderHasBeenCreated) {
87 FileListView fileListView = new FileListView(driver);
88 Actions.deleteElement(CurrentCreatedFolder, fileListView, driver);
89 }
90 driver.removeApp("com.owncloud.android");
91 driver.quit();
92 }
93
94 }