3d57ee07b49605d53777a3494391ca3e2dda4413
[pub/Android/ownCloud.git] / automationTest / src / test / java / androidtest / tests / MoveFileTestSuite.java
1 package androidtest.tests;
2
3 import static org.junit.Assert.*;
4 import io.appium.java_client.android.AndroidDriver;
5
6 import org.junit.After;
7 import org.junit.Before;
8 import org.junit.FixMethodOrder;
9 import org.junit.Rule;
10 import org.junit.Test;
11 import org.junit.experimental.categories.Category;
12 import org.junit.rules.TestName;
13 import org.junit.runners.MethodSorters;
14
15 import androidtest.actions.Actions;
16 import androidtest.groups.NoIgnoreTestCategory;
17 import androidtest.groups.SmokeTestCategory;
18 import androidtest.models.ElementMenuOptions;
19 import androidtest.models.MainView;
20 import androidtest.models.MoveView;
21 import androidtest.models.WaitAMomentPopUp;
22
23
24
25 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
26 public class MoveFileTestSuite{
27 AndroidDriver driver;
28 Common common;
29 private String FOLDER_WHERE_MOVE = "folderWhereMove";
30 private String FILE_NAME = "test";
31 @Rule public TestName name = new TestName();
32
33 @Before
34 public void setUp() throws Exception {
35 common=new Common();
36 driver=common.setUpCommonDriver();
37 }
38
39 @Test
40 @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class})
41 public void testMoveFile () throws Exception {
42 WaitAMomentPopUp waitAMomentPopUp;
43
44 MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver);
45 common.assertIsInMainView();
46
47 Common.waitTillElementIsNotPresent(mainView.getProgressCircular(), 1000);
48
49 //check if the folder already exists and if true, delete them
50 Actions.deleteElement(FOLDER_WHERE_MOVE, mainView, driver);
51 Actions.deleteElement(FILE_NAME, mainView, driver);
52
53 //Create the folder where the other is gone to be moved
54 waitAMomentPopUp = Actions.createFolder(FOLDER_WHERE_MOVE, mainView);
55 Common.waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100);
56 mainView.scrollTillFindElement(FOLDER_WHERE_MOVE);
57 assertTrue(mainView.getFileElement().isDisplayed());
58
59 MainView mainViewAfterUploadFile = Actions.uploadFile(FILE_NAME, mainView);
60 mainViewAfterUploadFile.scrollTillFindElement(FILE_NAME);
61 assertTrue(mainViewAfterUploadFile.getFileElement().isDisplayed());
62
63 //select to move the file
64 ElementMenuOptions menuOptions = mainView.longPressOnElement(FILE_NAME);
65 MoveView moveView = menuOptions.clickOnMove();
66
67 //to move to a folder
68 moveView.scrollTillFindElement(FOLDER_WHERE_MOVE).tap(1,1);
69 waitAMomentPopUp = moveView.clickOnChoose();
70 Common.waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100);
71
72 //check that the folder moved is inside the other
73 mainView.scrollTillFindElement(FOLDER_WHERE_MOVE).tap(1,1);
74 Common.waitTillElementIsNotPresent(mainView.getProgressCircular(), 1000);
75 Thread.sleep(1000);
76 mainView.scrollTillFindElement(FILE_NAME);
77 assertEquals(FILE_NAME , mainView.getFileElement().getText());
78
79 }
80
81 @After
82 public void tearDown() throws Exception {
83 common.takeScreenShotOnFailed(name.getMethodName());
84 MainView mainView = new MainView(driver);
85 driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_BACK);
86 Actions.deleteElement(FOLDER_WHERE_MOVE, mainView, driver);
87 Actions.deleteElement(FILE_NAME, mainView, driver);
88 driver.removeApp("com.owncloud.android");
89 driver.quit();
90 }
91
92 }