d950d4130b386e1313958c2bbc3b28ea5bb70c91
[pub/Android/ownCloud.git] / automationTest / src / test / java / com / owncloud / android / test / ui / testSuites / MoveFileTestSuite.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.FixMethodOrder;
29 import org.junit.Rule;
30 import org.junit.Test;
31 import org.junit.experimental.categories.Category;
32 import org.junit.rules.TestName;
33 import org.junit.runners.MethodSorters;
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.MoveView;
41 import com.owncloud.android.test.ui.models.WaitAMomentPopUp;
42
43
44
45 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
46 public class MoveFileTestSuite{
47 AndroidDriver driver;
48 Common common;
49 private String FOLDER_WHERE_MOVE = "folderWhereMove";
50 private String FILE_NAME = Config.fileToTestName;
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 testMoveFile () throws Exception {
62 WaitAMomentPopUp waitAMomentPopUp;
63
64 FileListView fileListView = Actions.login(Config.URL, Config.user,
65 Config.password, Config.isTrusted, driver);
66 common.assertIsInFileListView();
67
68 //Common.waitTillElementIsNotPresent(
69 //fileListView.getProgressCircular(), 1000);
70
71 //check if the folder already exists and if true, delete them
72 Actions.deleteElement(FOLDER_WHERE_MOVE, fileListView, driver);
73 Actions.deleteElement(FILE_NAME, fileListView, driver);
74
75 //Create the folder where the other is gone to be moved
76 waitAMomentPopUp = Actions
77 .createFolder(FOLDER_WHERE_MOVE, fileListView);
78 Common.waitTillElementIsNotPresent(
79 waitAMomentPopUp.getWaitAMomentTextElement(), 100);
80 fileListView.scrollTillFindElement(FOLDER_WHERE_MOVE);
81 assertTrue(fileListView.getFileElement().isDisplayed());
82
83 FileListView fileListViewAfterUploadFile = Actions
84 .uploadFile(FILE_NAME, fileListView);
85 fileListViewAfterUploadFile.scrollTillFindElement(FILE_NAME);
86 assertTrue(fileListViewAfterUploadFile.getFileElement().isDisplayed());
87
88 //select to move the file
89 ElementMenuOptions menuOptions = fileListView
90 .longPressOnElement(FILE_NAME);
91 MoveView moveView = menuOptions.clickOnMove();
92
93 //to move to a folder
94 moveView.scrollTillFindElement(FOLDER_WHERE_MOVE).tap(1,1);
95 waitAMomentPopUp = moveView.clickOnChoose();
96 Common.waitTillElementIsNotPresent(
97 waitAMomentPopUp.getWaitAMomentTextElement(), 100);
98
99 //check that the folder moved is inside the other
100 fileListView.scrollTillFindElement(FOLDER_WHERE_MOVE).tap(1,1);
101 Common.waitTillElementIsNotPresent(fileListView.getProgressCircular(),
102 1000);
103 Thread.sleep(1000);
104 fileListView.scrollTillFindElement(FILE_NAME);
105 assertEquals(FILE_NAME , fileListView.getFileElement().getText());
106
107 }
108
109 @After
110 public void tearDown() throws Exception {
111 common.takeScreenShotOnFailed(name.getMethodName());
112 FileListView fileListView = new FileListView(driver);
113 driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_BACK);
114 Actions.deleteElement(FOLDER_WHERE_MOVE, fileListView, driver);
115 Actions.deleteElement(FILE_NAME, fileListView, driver);
116 driver.removeApp("com.owncloud.android");
117 driver.quit();
118 }
119
120 }