790336c949fd6788e4f39d240d2b2132d135156e
[pub/Android/ownCloud.git] / automationTest / src / test / java / com / owncloud / android / test / ui / testSuites / MoveFolderTestSuite.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.MoveView;
41 import com.owncloud.android.test.ui.models.WaitAMomentPopUp;
42
43
44 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
45 public class MoveFolderTestSuite{
46 AndroidDriver driver;
47 Common common;
48 private String FOLDER_TO_MOVE = "folderToMove";
49 private String FOLDER_WHERE_MOVE = "folderWhereMove";
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 testMoveFolder () 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(FOLDER_TO_MOVE, 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 //Create the folder which is going to be moved
84 waitAMomentPopUp = Actions.createFolder(FOLDER_TO_MOVE, fileListView);
85 Common.waitTillElementIsNotPresent(
86 waitAMomentPopUp.getWaitAMomentTextElement(), 100);
87 fileListView.scrollTillFindElement(FOLDER_TO_MOVE);
88 assertTrue(fileListView.getFileElement().isDisplayed());
89
90 //select to move the folder
91 ElementMenuOptions menuOptions = fileListView
92 .longPressOnElement(FOLDER_TO_MOVE);
93 MoveView moveView = menuOptions.clickOnMove();
94
95 //to move to a folder
96 moveView.scrollTillFindElement(FOLDER_WHERE_MOVE).tap(1,1);
97 waitAMomentPopUp = moveView.clickOnChoose();
98 Common.waitTillElementIsNotPresent(waitAMomentPopUp
99 .getWaitAMomentTextElement(), 100);
100
101 //check that the folder moved is inside the other
102 fileListView.scrollTillFindElement(FOLDER_WHERE_MOVE).tap(1,1);
103 Common.waitTillElementIsNotPresent(fileListView.getProgressCircular(),
104 1000);
105 Thread.sleep(1000);
106 fileListView.scrollTillFindElement(FOLDER_TO_MOVE);
107 assertEquals(FOLDER_TO_MOVE , fileListView.getFileElement().getText());
108 }
109
110 @After
111 public void tearDown() throws Exception {
112 common.takeScreenShotOnFailed(name.getMethodName());
113 FileListView fileListView = new FileListView(driver);
114 driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_BACK);
115 Actions.deleteElement(FOLDER_WHERE_MOVE, fileListView, driver);
116 Actions.deleteElement(FOLDER_TO_MOVE, fileListView, driver);
117 driver.removeApp("com.owncloud.android");
118 driver.quit();
119 }
120
121
122 }