add new testCases. prepare the test to have them into categories
[pub/Android/ownCloud.git] / automationTest / src / test / java / androidtest / tests / MoveFileTestSuite.java
index ca8a4ec..3d57ee0 100644 (file)
@@ -1,12 +1,20 @@
 package androidtest.tests;
 
+import static org.junit.Assert.*;
+import io.appium.java_client.android.AndroidDriver;
+
 import org.junit.After;
 import org.junit.Before;
 import org.junit.FixMethodOrder;
+import org.junit.Rule;
 import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.rules.TestName;
 import org.junit.runners.MethodSorters;
 
 import androidtest.actions.Actions;
+import androidtest.groups.NoIgnoreTestCategory;
+import androidtest.groups.SmokeTestCategory;
 import androidtest.models.ElementMenuOptions;
 import androidtest.models.MainView;
 import androidtest.models.MoveView;
@@ -15,23 +23,28 @@ import androidtest.models.WaitAMomentPopUp;
 
 
 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class MoveFileTestSuite extends Common{
+public class MoveFileTestSuite{
+       AndroidDriver driver;
+       Common common;
        private String FOLDER_WHERE_MOVE = "folderWhereMove";
        private String FILE_NAME = "test";
-
+       @Rule public TestName name = new TestName();
+       
        @Before
        public void setUp() throws Exception {
-               setUpCommonDriver();
+               common=new Common();
+               driver=common.setUpCommonDriver();
        }
 
        @Test
+       @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class})
        public void testMoveFile () throws Exception {
                WaitAMomentPopUp waitAMomentPopUp;
 
                MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver);
-               assertTrue(waitForTextPresent("ownCloud", mainView.getTitleTextElement()));
+               common.assertIsInMainView();
 
-               waitTillElementIsNotPresent(mainView.getProgressCircular(), 1000);
+               Common.waitTillElementIsNotPresent(mainView.getProgressCircular(), 1000);
 
                //check if the folder already exists and if true, delete them
                Actions.deleteElement(FOLDER_WHERE_MOVE, mainView, driver);
@@ -39,7 +52,7 @@ public class MoveFileTestSuite extends Common{
 
                //Create the folder where the other is gone to be moved
                waitAMomentPopUp = Actions.createFolder(FOLDER_WHERE_MOVE, mainView);
-               waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100);
+               Common.waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100);
                mainView.scrollTillFindElement(FOLDER_WHERE_MOVE);
                assertTrue(mainView.getFileElement().isDisplayed());
 
@@ -54,11 +67,11 @@ public class MoveFileTestSuite extends Common{
                //to move to a folder
                moveView.scrollTillFindElement(FOLDER_WHERE_MOVE).tap(1,1);
                waitAMomentPopUp = moveView.clickOnChoose();
-               waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100);
+               Common.waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100);
 
                //check that the folder moved is inside the other
                mainView.scrollTillFindElement(FOLDER_WHERE_MOVE).tap(1,1);
-               waitTillElementIsNotPresent(mainView.getProgressCircular(), 1000);
+               Common.waitTillElementIsNotPresent(mainView.getProgressCircular(), 1000);
                Thread.sleep(1000);
                mainView.scrollTillFindElement(FILE_NAME);
                assertEquals(FILE_NAME , mainView.getFileElement().getText());
@@ -67,6 +80,7 @@ public class MoveFileTestSuite extends Common{
 
        @After
        public void tearDown() throws Exception {
+               common.takeScreenShotOnFailed(name.getMethodName());
                MainView mainView = new MainView(driver);
                driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_BACK);
                Actions.deleteElement(FOLDER_WHERE_MOVE, mainView, driver);