add new testCases. prepare the test to have them into categories
[pub/Android/ownCloud.git] / automationTest / src / test / java / androidtest / tests / MoveFolderTestSuite.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.Rule;
9 import org.junit.experimental.categories.Category;
10 import org.junit.rules.TestName;
11 import org.junit.runners.MethodSorters;
12 import org.junit.FixMethodOrder;
13 import org.junit.Test;
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 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
25 public class MoveFolderTestSuite{
26 AndroidDriver driver;
27 Common common;
28 private String FOLDER_TO_MOVE = "folderToMove";
29 private String FOLDER_WHERE_MOVE = "folderWhereMove";
30
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 testMoveFolder () 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(FOLDER_TO_MOVE, 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 //Create the folder which is going to be moved
60 waitAMomentPopUp = Actions.createFolder(FOLDER_TO_MOVE, mainView);
61 Common.waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100);
62 mainView.scrollTillFindElement(FOLDER_TO_MOVE);
63 assertTrue(mainView.getFileElement().isDisplayed());
64
65 //select to move the folder
66 ElementMenuOptions menuOptions = mainView.longPressOnElement(FOLDER_TO_MOVE);
67 MoveView moveView = menuOptions.clickOnMove();
68
69 //to move to a folder
70 moveView.scrollTillFindElement(FOLDER_WHERE_MOVE).tap(1,1);
71 waitAMomentPopUp = moveView.clickOnChoose();
72 Common.waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100);
73
74 //check that the folder moved is inside the other
75 mainView.scrollTillFindElement(FOLDER_WHERE_MOVE).tap(1,1);
76 Common.waitTillElementIsNotPresent(mainView.getProgressCircular(), 1000);
77 Thread.sleep(1000);
78 mainView.scrollTillFindElement(FOLDER_TO_MOVE);
79 assertEquals(FOLDER_TO_MOVE , mainView.getFileElement().getText());
80 }
81
82 @After
83 public void tearDown() throws Exception {
84 common.takeScreenShotOnFailed(name.getMethodName());
85 MainView mainView = new MainView(driver);
86 driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_BACK);
87 Actions.deleteElement(FOLDER_WHERE_MOVE, mainView, driver);
88 Actions.deleteElement(FOLDER_TO_MOVE, mainView, driver);
89 driver.removeApp("com.owncloud.android");
90 driver.quit();
91 }
92
93
94 }