0298bd469f0dd1d5e3165ca834416c7f184fcdce
[pub/Android/ownCloud.git] / automationTest / src / test / java / com / owncloud / android / test / ui / testSuites / RenameFolderTestSuite.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.ElementMenuOptions;
39 import com.owncloud.android.test.ui.models.FileListView;
40 import com.owncloud.android.test.ui.models.NewFolderPopUp;
41 import com.owncloud.android.test.ui.models.WaitAMomentPopUp;
42
43
44 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
45 public class RenameFolderTestSuite{
46
47 AndroidDriver driver;
48 Common common;
49 private Boolean folderHasBeenCreated = false;
50 private final String OLD_FOLDER_NAME = "beforeRemoving";
51 private final String FOLDER_NAME = "testCreateFolder";
52 private String CurrentCreatedFolder = "";
53
54 @Rule public TestName name = new TestName();
55
56
57 @Before
58 public void setUp() throws Exception {
59 common=new Common();
60 driver=common.setUpCommonDriver();
61 }
62
63 @Test
64 @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class})
65 public void testRenameFolder () throws Exception {
66 FileListView fileListView = Actions.login(Config.URL, Config.user,
67 Config.password, Config.isTrusted, driver);
68 common.assertIsInFileListView();
69
70 //TODO. if the folder already exists, do no created
71 //create the folder to rename
72 WaitAMomentPopUp waitAMomentPopUp = Actions
73 .createFolder(OLD_FOLDER_NAME, fileListView);
74 Common.waitTillElementIsNotPresent(
75 waitAMomentPopUp.getWaitAMomentTextElement(), 100);
76 fileListView.scrollTillFindElement(OLD_FOLDER_NAME);
77
78 assertTrue(
79 folderHasBeenCreated = fileListView.getFileElement().isDisplayed());
80
81 //check if the folder with the new name already exists
82 //and if true, delete them
83 Actions.deleteElement(FOLDER_NAME, fileListView, driver);
84
85 CurrentCreatedFolder = OLD_FOLDER_NAME;
86 ElementMenuOptions menuOptions = fileListView
87 .longPressOnElement(OLD_FOLDER_NAME);
88 NewFolderPopUp FolderPopUp = menuOptions.clickOnRename();
89 FolderPopUp.typeNewFolderName(FOLDER_NAME);
90 FolderPopUp.clickOnNewFolderOkButton();
91 CurrentCreatedFolder = FOLDER_NAME;
92 Common.waitTillElementIsNotPresent(waitAMomentPopUp
93 .getWaitAMomentTextElement(), 100);
94 fileListView.scrollTillFindElement(FOLDER_NAME);
95 assertNotNull(fileListView.getFileElement());
96 assertTrue(
97 folderHasBeenCreated = fileListView.getFileElement().isDisplayed());
98 assertEquals(FOLDER_NAME , fileListView.getFileElement().getText());
99 }
100
101 @After
102 public void tearDown() throws Exception {
103 common.takeScreenShotOnFailed(name.getMethodName());
104 if(folderHasBeenCreated){
105 FileListView fileListView = new FileListView(driver);
106 Actions.deleteElement(CurrentCreatedFolder, fileListView, driver);
107 }
108 driver.removeApp("com.owncloud.android");
109 driver.quit();
110 }
111
112 }