2 * ownCloud Android client application
5 * Copyright (C) 2015 ownCloud Inc.
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.
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.
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/>.
21 package com
.owncloud
.android
.test
.ui
.testSuites
;
23 import static org
.junit
.Assert
.*;
24 import io
.appium
.java_client
.android
.AndroidDriver
;
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 import org
.openqa
.selenium
.By
;
35 import org
.openqa
.selenium
.support
.ui
.ExpectedConditions
;
37 import com
.owncloud
.android
.test
.ui
.actions
.Actions
;
38 import com
.owncloud
.android
.test
.ui
.groups
.NoIgnoreTestCategory
;
39 import com
.owncloud
.android
.test
.ui
.groups
.SmokeTestCategory
;
40 import com
.owncloud
.android
.test
.ui
.models
.ElementMenuOptions
;
41 import com
.owncloud
.android
.test
.ui
.models
.FileListView
;
42 import com
.owncloud
.android
.test
.ui
.models
.NewFolderPopUp
;
43 import com
.owncloud
.android
.test
.ui
.models
.WaitAMomentPopUp
;
46 @FixMethodOrder(MethodSorters
.NAME_ASCENDING
)
47 public class RenameFileTestSuite
{
51 private Boolean fileHasBeenCreated
= false
;
52 private final String OLD_FILE_NAME
= Config
.fileToTestName
;
53 private final String FILE_NAME
= "newNameFile";
54 private String CurrentCreatedFile
= "";
56 @Rule public TestName name
= new TestName();
59 public void setUp() throws Exception
{
61 driver
=common
.setUpCommonDriver();
65 @Category({NoIgnoreTestCategory
.class, SmokeTestCategory
.class})
66 public void testRenameFile () throws Exception
{
67 FileListView fileListView
= Actions
.login(Config
.URL
, Config
.user
,
68 Config
.password
, Config
.isTrusted
, driver
);
69 common
.assertIsInFileListView();
71 //TODO. if the file already exists, do not upload
72 FileListView fileListViewAfterUploadFile
= Actions
73 .uploadFile(OLD_FILE_NAME
, fileListView
);
75 //check if the file with the new name already exists, if true delete it
76 Actions
.deleteElement(FILE_NAME
, fileListView
, driver
);
78 fileListViewAfterUploadFile
.scrollTillFindElement(OLD_FILE_NAME
);
79 assertTrue(fileHasBeenCreated
= fileListViewAfterUploadFile
80 .getFileElement().isDisplayed());
81 CurrentCreatedFile
= OLD_FILE_NAME
;
82 Common
.waitTillElementIsNotPresent(fileListViewAfterUploadFile
83 .getProgressCircular(), 1000);
84 common
.wait
.until(ExpectedConditions
.visibilityOf(
85 fileListViewAfterUploadFile
.getFileElementLayout()
86 .findElement(By
.id(FileListView
.getLocalFileIndicator()))));
87 ElementMenuOptions menuOptions
= fileListViewAfterUploadFile
88 .longPressOnElement(OLD_FILE_NAME
);
89 NewFolderPopUp newFolderPopUp
= menuOptions
.clickOnRename();
90 newFolderPopUp
.typeNewFolderName(FILE_NAME
);
91 WaitAMomentPopUp waitAMomentPopUp
= newFolderPopUp
92 .clickOnNewFolderOkButton();
93 Common
.waitTillElementIsNotPresent(waitAMomentPopUp
94 .getWaitAMomentTextElement(), 100);
95 fileListViewAfterUploadFile
.scrollTillFindElement(FILE_NAME
);
96 assertNotNull(fileListViewAfterUploadFile
.getFileElement());
97 assertTrue(fileListViewAfterUploadFile
.getFileElement().isDisplayed());
98 assertEquals(FILE_NAME
, fileListViewAfterUploadFile
.getFileElement()
100 CurrentCreatedFile
= FILE_NAME
;
104 public void tearDown() throws Exception
{
105 common
.takeScreenShotOnFailed(name
.getMethodName());
106 if (fileHasBeenCreated
) {
107 FileListView fileListView
= new FileListView(driver
);
108 Actions
.deleteElement(CurrentCreatedFile
,fileListView
, driver
);
110 driver
.removeApp("com.owncloud.android");