add new test cases
authorpurigarcia <pgarcia@solidgear.es>
Thu, 9 Apr 2015 08:41:42 +0000 (10:41 +0200)
committerpurigarcia <pgarcia@solidgear.es>
Thu, 9 Apr 2015 08:41:42 +0000 (10:41 +0200)
28 files changed:
automationTest/.classpath
automationTest/.gitignore
automationTest/.settings/org.eclipse.jdt.core.prefs
automationTest/src/test/java/androidtest/actions/Actions.java
automationTest/src/test/java/androidtest/models/CertificatePopUp.java [new file with mode: 0644]
automationTest/src/test/java/androidtest/models/ElementMenuOptions.java [new file with mode: 0644]
automationTest/src/test/java/androidtest/models/FilesView.java
automationTest/src/test/java/androidtest/models/LoginForm.java
automationTest/src/test/java/androidtest/models/MainView.java
automationTest/src/test/java/androidtest/models/MenuList.java [new file with mode: 0644]
automationTest/src/test/java/androidtest/models/MoveView.java [new file with mode: 0644]
automationTest/src/test/java/androidtest/models/NewFolderPopUp.java [new file with mode: 0644]
automationTest/src/test/java/androidtest/models/RemoveConfirmationView.java [new file with mode: 0644]
automationTest/src/test/java/androidtest/models/WaitAMomentPopUp.java [new file with mode: 0644]
automationTest/src/test/java/androidtest/tests/.gitignore [new file with mode: 0644]
automationTest/src/test/java/androidtest/tests/Common.java [new file with mode: 0644]
automationTest/src/test/java/androidtest/tests/CommonTest.java [deleted file]
automationTest/src/test/java/androidtest/tests/Config.java
automationTest/src/test/java/androidtest/tests/CreateFolderTestSuite.java
automationTest/src/test/java/androidtest/tests/DeleteFileTestSuite.java [new file with mode: 0644]
automationTest/src/test/java/androidtest/tests/DeleteFolderTestSuite.java [new file with mode: 0644]
automationTest/src/test/java/androidtest/tests/LoginTestSuite.java
automationTest/src/test/java/androidtest/tests/LogoutTestSuite.java [new file with mode: 0644]
automationTest/src/test/java/androidtest/tests/MoveFileTestSuite.java [new file with mode: 0644]
automationTest/src/test/java/androidtest/tests/MoveFolderTestSuite.java [new file with mode: 0644]
automationTest/src/test/java/androidtest/tests/RenameFileTestSuite.java [new file with mode: 0644]
automationTest/src/test/java/androidtest/tests/RenameFolderTestSuite.java [new file with mode: 0644]
automationTest/src/test/java/androidtest/tests/UploadTestSuite.java

index 53c3598..069344d 100644 (file)
@@ -13,7 +13,7 @@
                        <attribute name="maven.pomderived" value="true"/>
                </attributes>
        </classpathentry>
                        <attribute name="maven.pomderived" value="true"/>
                </attributes>
        </classpathentry>
-       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5">
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
                <attributes>
                        <attribute name="maven.pomderived" value="true"/>
                </attributes>
                <attributes>
                        <attribute name="maven.pomderived" value="true"/>
                </attributes>
index 7326dd9..3fe891d 100644 (file)
@@ -1,2 +1,2 @@
 /target/
 /target/
-.DS_Store
\ No newline at end of file
+src/test/java/androidtest/tests/Config.java
index abec6ca..6249222 100644 (file)
@@ -1,5 +1,12 @@
 eclipse.preferences.version=1
 eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
-org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.7
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
 org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
 org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
-org.eclipse.jdt.core.compiler.source=1.5
+org.eclipse.jdt.core.compiler.source=1.7
index 952b01f..a89f5de 100644 (file)
 package androidtest.actions;
 
 package androidtest.actions;
 
+import java.util.HashMap;
+
+import org.openqa.selenium.NoSuchElementException;
+import org.openqa.selenium.remote.RemoteWebElement;
+
 import io.appium.java_client.android.AndroidDriver;
 import io.appium.java_client.android.AndroidDriver;
+import io.appium.java_client.android.AndroidElement;
+
+import org.openqa.selenium.support.ui.ExpectedConditions;
+import org.openqa.selenium.support.ui.WebDriverWait;
+
+import androidtest.models.CertificatePopUp;
+import androidtest.models.ElementMenuOptions;
+import androidtest.models.FilesView;
+import androidtest.models.LoginForm;
 import androidtest.models.MainView;
 import androidtest.models.MainView;
+import androidtest.models.MenuList;
+import androidtest.models.NewFolderPopUp;
+import androidtest.models.RemoveConfirmationView;
 import androidtest.models.SettingsView;
 import androidtest.models.SettingsView;
+import androidtest.models.WaitAMomentPopUp;
+import androidtest.tests.Common;
 
 public class Actions {
 
 public class Actions {
-       
+
+       public static MainView login(String url, String user, String password, Boolean isTrusted, AndroidDriver driver) throws InterruptedException {
+               LoginForm loginForm = new LoginForm(driver);
+               CertificatePopUp certificatePopUp = loginForm.typeHostUrl(url); 
+               if(!isTrusted){
+                       driver.runAppInBackground(3);
+                       WebDriverWait wait = new WebDriverWait(driver, 30);
+                       wait.until(ExpectedConditions.visibilityOf(certificatePopUp.getOkButtonElement()));
+                       certificatePopUp.clickOnOkButton();
+               }
+               loginForm.typeUserName(user);
+               loginForm.typePassword(password);
+               //TODO. Assert related to check the connection?
+               return loginForm.clickOnConnectButton();
+       }
+
+       public static WaitAMomentPopUp createFolder(String folderName, MainView mainView){
+               NewFolderPopUp newFolderPopUp = mainView.clickOnNewFolderButton();
+               newFolderPopUp.typeNewFolderName(folderName);
+               WaitAMomentPopUp waitAMomentPopUp = newFolderPopUp.clickOnNewFolderOkButton();
+               //TODO. assert here
+               return waitAMomentPopUp;
+       }
+
+
+       public static AndroidElement scrollTillFindElement (String elementName, AndroidElement element, AndroidDriver driver) {
+               AndroidElement fileElement;
+
+               if(element.getAttribute("scrollable").equals("true")){
+                       HashMap<String, String> scrollObject = new HashMap<String, String>();
+                       scrollObject.put("text", elementName);
+                       scrollObject.put("element", ( (RemoteWebElement) element).getId());
+                       driver.executeScript("mobile: scrollTo", scrollObject);
+               }
+               try {
+                       fileElement = (AndroidElement) driver.findElementByName(elementName);
+               } catch (NoSuchElementException e) {
+                       fileElement = null;
+               }
+               return fileElement;
+       }
+
+
        public static void deleteAccount (MainView mainView) {  
        public static void deleteAccount (MainView mainView) {  
-               mainView.clickOnMenuButton();
-               SettingsView settingView = mainView.clickOnSettingsButton();
+               MenuList menulist = mainView.clickOnMenuButton();
+               SettingsView settingView = menulist.clickOnSettingsButton();
                deleteAccount(settingView);
                deleteAccount(settingView);
-               
        }
        }
-       
+
        public static void deleteAccount (SettingsView settingsView) {
                settingsView.tapOnAccountElement(1, 1000);
                settingsView.clickOnDeleteAccountElement();
        }
        public static void deleteAccount (SettingsView settingsView) {
                settingsView.tapOnAccountElement(1, 1000);
                settingsView.clickOnDeleteAccountElement();
        }
-       
+
        public static void clickOnMainLayout(AndroidDriver driver){
                driver.tap(1, 0, 0, 1);
        }
        public static void clickOnMainLayout(AndroidDriver driver){
                driver.tap(1, 0, 0, 1);
        }
-       
-       
+
+       //TODO. convert deleteFodler and deleteFile in deleteElement
+       public static AndroidElement deleteElement(String elementName,  MainView mainView, AndroidDriver driver) throws Exception{
+               AndroidElement fileElement;
+               WaitAMomentPopUp waitAMomentPopUp;
+               try{
+                       fileElement = (AndroidElement) driver.findElementByName(elementName);
+                       ElementMenuOptions menuOptions = mainView.longPressOnElement(elementName);
+                       RemoveConfirmationView removeConfirmationView = menuOptions.clickOnRemove();;
+                       waitAMomentPopUp = removeConfirmationView.clickOnRemoteAndLocalButton();
+                       Common.waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100);
+               }catch(NoSuchElementException e){
+                       fileElement=null;
+               }
+               return fileElement;
+       }
+
+       public static MainView uploadFile(String elementName,  MainView mainView) throws InterruptedException{
+               mainView.clickOnUploadButton();
+               FilesView filesView = mainView.clickOnFilesElementUploadFile();
+               filesView.clickOnFileName(elementName);
+               MainView mainViewAfterUploadFile = filesView.clickOnUploadButton();
+               //TO DO. detect when the file is successfully uploaded
+               Thread.sleep(15000);
+               return mainViewAfterUploadFile; 
+       }
+
+
 }
 }
diff --git a/automationTest/src/test/java/androidtest/models/CertificatePopUp.java b/automationTest/src/test/java/androidtest/models/CertificatePopUp.java
new file mode 100644 (file)
index 0000000..dbcffcc
--- /dev/null
@@ -0,0 +1,29 @@
+package androidtest.models;
+
+import io.appium.java_client.android.AndroidDriver;
+import io.appium.java_client.android.AndroidElement;
+import io.appium.java_client.pagefactory.AndroidFindBy;
+import io.appium.java_client.pagefactory.AppiumFieldDecorator;
+
+import org.openqa.selenium.support.PageFactory;
+
+public class CertificatePopUp {
+       final AndroidDriver driver;     
+       
+       @AndroidFindBy(name = "OK")
+       private AndroidElement okButton;
+       
+       public CertificatePopUp (AndroidDriver driver) {
+               this.driver = driver;
+               PageFactory.initElements(new AppiumFieldDecorator(driver), this);
+       }
+       
+       public void clickOnOkButton () {
+               okButton.click();
+       }
+       
+       public AndroidElement getOkButtonElement () {
+               return okButton;
+       }
+
+}
diff --git a/automationTest/src/test/java/androidtest/models/ElementMenuOptions.java b/automationTest/src/test/java/androidtest/models/ElementMenuOptions.java
new file mode 100644 (file)
index 0000000..090e038
--- /dev/null
@@ -0,0 +1,55 @@
+package androidtest.models;
+
+import io.appium.java_client.android.AndroidDriver;
+import io.appium.java_client.android.AndroidElement;
+import io.appium.java_client.pagefactory.AndroidFindBy;
+import io.appium.java_client.pagefactory.AppiumFieldDecorator;
+
+import org.openqa.selenium.support.PageFactory;
+
+public class ElementMenuOptions {
+
+       final AndroidDriver driver;
+       
+       @AndroidFindBy(name = "Details")
+       private AndroidElement detailsFileElement;
+       
+       @AndroidFindBy(name = "Rename")
+       private AndroidElement renameFileElement;
+       
+       @AndroidFindBy(name = "Remove")
+       private AndroidElement removeFileElement;
+       
+       @AndroidFindBy(name = "Move")
+       private AndroidElement moveElement;
+       
+       public ElementMenuOptions (AndroidDriver driver) {
+               this.driver = driver;
+               PageFactory.initElements(new AppiumFieldDecorator(driver), this);
+       }
+       
+       public AppDetailsView clickOnDetails () {
+               detailsFileElement.click();
+               AppDetailsView appDetailsView = new AppDetailsView(driver);
+               return appDetailsView;
+       }
+       
+       public RemoveConfirmationView clickOnRemove () {
+               removeFileElement.click();
+               RemoveConfirmationView removeConfirmationView = new RemoveConfirmationView(driver);
+               return removeConfirmationView;
+       }
+       
+
+       public MoveView clickOnMove () {
+               moveElement.click();
+               MoveView moveView = new MoveView(driver);
+               return moveView;
+       }
+
+       public NewFolderPopUp clickOnRename () {
+               renameFileElement.click();
+               NewFolderPopUp newFolderPopUp = new NewFolderPopUp(driver);
+               return newFolderPopUp;
+       }
+}
index 73fb67f..c913b10 100644 (file)
@@ -1,22 +1,19 @@
 package androidtest.models;
 
 package androidtest.models;
 
-import java.util.HashMap;
-
 import io.appium.java_client.android.AndroidDriver;
 import io.appium.java_client.android.AndroidElement;
 import io.appium.java_client.pagefactory.AndroidFindBy;
 import io.appium.java_client.pagefactory.AppiumFieldDecorator;
 import io.appium.java_client.android.AndroidDriver;
 import io.appium.java_client.android.AndroidElement;
 import io.appium.java_client.pagefactory.AndroidFindBy;
 import io.appium.java_client.pagefactory.AppiumFieldDecorator;
-
-import org.openqa.selenium.remote.RemoteWebElement;
 import org.openqa.selenium.support.CacheLookup;
 import org.openqa.selenium.support.PageFactory;
 import org.openqa.selenium.support.CacheLookup;
 import org.openqa.selenium.support.PageFactory;
+import androidtest.actions.Actions;
 
 
-public class FilesView {
+public class FilesView{
        final AndroidDriver driver;
        
        @CacheLookup
        @AndroidFindBy(id = "com.owncloud.android:id/list_root")
        final AndroidDriver driver;
        
        @CacheLookup
        @AndroidFindBy(id = "com.owncloud.android:id/list_root")
-       private AndroidElement fileLayout;
+       private AndroidElement filesLayout;
        
        @CacheLookup
        @AndroidFindBy(id = "com.owncloud.android:id/upload_files_btn_upload")
        
        @CacheLookup
        @AndroidFindBy(id = "com.owncloud.android:id/upload_files_btn_upload")
@@ -35,12 +32,9 @@ public class FilesView {
                return mainView;
        }
        
                return mainView;
        }
        
+       //change to scrollTillFindElement
        public void scrollTillFindFile (String fileName) {
        public void scrollTillFindFile (String fileName) {
-        HashMap<String, String> scrollObject = new HashMap<String, String>();
-        scrollObject.put("text", fileName);
-        scrollObject.put("element", ( (RemoteWebElement) fileLayout).getId());
-        driver.executeScript("mobile: scrollTo", scrollObject);
-               fileElement = (AndroidElement) driver.findElementByName(fileName);
+               fileElement = Actions.scrollTillFindElement (fileName,filesLayout,driver);
        }
        
        public void clickOnFileName (String fileName) {
        }
        
        public void clickOnFileName (String fileName) {
index 2354269..ea78102 100644 (file)
@@ -2,6 +2,7 @@ package androidtest.models;
 
 import org.openqa.selenium.support.CacheLookup;
 import org.openqa.selenium.support.PageFactory;
 
 import org.openqa.selenium.support.CacheLookup;
 import org.openqa.selenium.support.PageFactory;
+
 import io.appium.java_client.android.AndroidDriver;
 import io.appium.java_client.android.AndroidElement;
 import io.appium.java_client.pagefactory.AndroidFindBy;
 import io.appium.java_client.android.AndroidDriver;
 import io.appium.java_client.android.AndroidElement;
 import io.appium.java_client.pagefactory.AndroidFindBy;
@@ -37,10 +38,11 @@ public class LoginForm {
                PageFactory.initElements(new AppiumFieldDecorator(driver), this);
        }
 
                PageFactory.initElements(new AppiumFieldDecorator(driver), this);
        }
 
-       public void typeHostUrl (String hostUrl) {
+       public CertificatePopUp typeHostUrl (String hostUrl) {
                hostUrlInput.clear();
                hostUrlInput.clear();
-               hostUrlInput.sendKeys(hostUrl);
-               driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_BACK);
+               hostUrlInput.sendKeys(hostUrl + "\n");
+               CertificatePopUp certificatePopUp = new CertificatePopUp(driver);
+               return certificatePopUp;
        }
        
        public void clickOnUserName () {
        }
        
        public void clickOnUserName () {
@@ -50,13 +52,13 @@ public class LoginForm {
        public void typeUserName (String userName) {
                userNameInput.clear();
                userNameInput.sendKeys(userName);
        public void typeUserName (String userName) {
                userNameInput.clear();
                userNameInput.sendKeys(userName);
-               driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_BACK);
+               driver.hideKeyboard();
        }
        
        public void typePassword (String password) {
                passwordInput.clear();
                passwordInput.sendKeys(password);
        }
        
        public void typePassword (String password) {
                passwordInput.clear();
                passwordInput.sendKeys(password);
-               driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_BACK);
+               driver.hideKeyboard();
        }
        
        public MainView clickOnConnectButton () {
        }
        
        public MainView clickOnConnectButton () {
@@ -65,6 +67,19 @@ public class LoginForm {
                return mainView;
        }
        
                return mainView;
        }
        
+       public AndroidElement gethostUrlInput () {
+               return hostUrlInput;
+       }
+       
+       public AndroidElement getUserNameInput () {
+               return userNameInput;
+       }
+       
+       public AndroidElement getPasswordInput () {
+               return passwordInput;
+       }
+       
+       
        public AndroidElement getServerStatusTextElement () {
                return serverStatusText;
        }
        public AndroidElement getServerStatusTextElement () {
                return serverStatusText;
        }
index 66523f9..6228f0e 100644 (file)
@@ -1,6 +1,5 @@
 package androidtest.models;
 
 package androidtest.models;
 
-import java.util.HashMap;
 import java.util.List;
 
 import io.appium.java_client.android.AndroidDriver;
 import java.util.List;
 
 import io.appium.java_client.android.AndroidDriver;
@@ -8,14 +7,15 @@ import io.appium.java_client.android.AndroidElement;
 import io.appium.java_client.pagefactory.AndroidFindBy;
 import io.appium.java_client.pagefactory.AppiumFieldDecorator;
 
 import io.appium.java_client.pagefactory.AndroidFindBy;
 import io.appium.java_client.pagefactory.AppiumFieldDecorator;
 
-import org.openqa.selenium.remote.RemoteWebElement;
+import org.openqa.selenium.NoSuchElementException;
 import org.openqa.selenium.support.CacheLookup;
 import org.openqa.selenium.support.PageFactory;
 
 import org.openqa.selenium.support.CacheLookup;
 import org.openqa.selenium.support.PageFactory;
 
+import androidtest.actions.Actions;
+
 public class MainView {
        final AndroidDriver driver;
        
 public class MainView {
        final AndroidDriver driver;
        
-       @CacheLookup
        @AndroidFindBy(uiAutomator = "new UiSelector().description(\"More options\")")
        private AndroidElement menuButton;
        
        @AndroidFindBy(uiAutomator = "new UiSelector().description(\"More options\")")
        private AndroidElement menuButton;
        
@@ -27,8 +27,8 @@ public class MainView {
        @AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"android:id/action_bar_title\")")
        private AndroidElement titleText;
        
        @AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"android:id/action_bar_title\")")
        private AndroidElement titleText;
        
-       @AndroidFindBy(name = "Settings")
-       private AndroidElement settingsButton;
+       @AndroidFindBy(id = "android:id/progress_circular")
+       private AndroidElement progressCircular;
 
        @CacheLookup
        @AndroidFindBy(uiAutomator = "new UiSelector().description(\"New folder\")")
 
        @CacheLookup
        @AndroidFindBy(uiAutomator = "new UiSelector().description(\"New folder\")")
@@ -38,12 +38,6 @@ public class MainView {
        @AndroidFindBy(uiAutomator = "new UiSelector().description(\"Upload\")")
        private AndroidElement uploadButton;
        
        @AndroidFindBy(uiAutomator = "new UiSelector().description(\"Upload\")")
        private AndroidElement uploadButton;
        
-       @AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"com.owncloud.android:id/user_input\")")
-       private AndroidElement newFolderNameField;
-       
-       @AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"android:id/button1\")")
-       private AndroidElement newFolderOkButton;
-       
        private AndroidElement waitAMomentText;
        
        @AndroidFindBy(id = "com.owncloud.android:id/ListItemLayout")
        private AndroidElement waitAMomentText;
        
        @AndroidFindBy(id = "com.owncloud.android:id/ListItemLayout")
@@ -52,15 +46,6 @@ public class MainView {
        @AndroidFindBy(id = "com.owncloud.android:id/list_root")
        private AndroidElement listRootLayout;
        
        @AndroidFindBy(id = "com.owncloud.android:id/list_root")
        private AndroidElement listRootLayout;
        
-       @AndroidFindBy(name = "Remove")
-       private AndroidElement removeFileElement;
-       
-       @AndroidFindBy(name = "Details")
-       private AndroidElement detailsFileElement;
-       
-       @AndroidFindBy(name = "Remote and local")
-       private AndroidElement remoteAndLocalButton;
-       
        @AndroidFindBy(name = "Files")
        private AndroidElement filesElementUploadFile;
        
        @AndroidFindBy(name = "Files")
        private AndroidElement filesElementUploadFile;
        
@@ -68,27 +53,19 @@ public class MainView {
        
        private AndroidElement fileElementLayout;
        
        
        private AndroidElement fileElementLayout;
        
+       private static String localFileIndicator = "com.owncloud.android:id/localFileIndicator";
+       private static String favoriteFileIndicator = "com.owncloud.android:id/favoriteIcon";
+       
        
        public MainView (AndroidDriver driver) {
                this.driver = driver;
                PageFactory.initElements(new AppiumFieldDecorator(driver), this);
        }
 
        
        public MainView (AndroidDriver driver) {
                this.driver = driver;
                PageFactory.initElements(new AppiumFieldDecorator(driver), this);
        }
 
-       public void clickOnMenuButton () {
-               //TODO. DETECT WHEN HAPPENS WHEN THERE IS NOT BUTTON IN THE TOPBAR
-               //if(menuButton.exists()){
-                       //menuButton.click();
-               //}else{
-                       //Thread.sleep(10000);
-                       //getUiDevice().pressMenu();
-               //}
+       public MenuList clickOnMenuButton () {
                menuButton.click();
                menuButton.click();
-       }
-       
-       public SettingsView clickOnSettingsButton () {
-               settingsButton.click();
-               SettingsView settingsView = new SettingsView(driver);
-               return settingsView;
+               MenuList menuList = new MenuList (driver);
+               return menuList;
        }
        
        public SettingsView getSettingsView () {
        }
        
        public SettingsView getSettingsView () {
@@ -96,34 +73,10 @@ public class MainView {
                return settingsView;
        }
        
                return settingsView;
        }
        
-       public void clickOnNewFolderButton () {
+       public NewFolderPopUp clickOnNewFolderButton () {
                newFolderButton.click();
                newFolderButton.click();
-       }
-       
-       public void clickOnRemoveFileElement () {
-               removeFileElement.click();
-       }
-       
-       public AppDetailsView clickOnDetailsFileElement () {
-               detailsFileElement.click();
-               AppDetailsView appDetailsView = new AppDetailsView(driver);
-               return appDetailsView;
-       }
-       
-       public void typeNewFolderName (String newFolderName) {
-               newFolderNameField.clear();
-               newFolderNameField.sendKeys(newFolderName);
-               driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_BACK);
-       }
-       
-       public void clickOnNewFolderOkButton () {
-               newFolderOkButton.click();
-               waitAMomentText = (AndroidElement) driver.findElementByName("Wait a moment");
-       }
-       
-       public void clickOnRemoteAndLocalButton () {
-               remoteAndLocalButton.click();
-               waitAMomentText = (AndroidElement) driver.findElementByName("Wait a moment");
+               NewFolderPopUp newFolderPopUp = new NewFolderPopUp(driver);
+               return newFolderPopUp;
        }
        
        public void clickOnUploadButton () {
        }
        
        public void clickOnUploadButton () {
@@ -156,24 +109,38 @@ public class MainView {
                return fileElement;
        }
        
                return fileElement;
        }
        
-       public void tapOnFileElement (String fileName) {
-               scrollTillFindElement(fileName);
-               fileElement.tap(1, 1000);
+       public ElementMenuOptions longPressOnElement (String elementName) {
+               scrollTillFindElement(elementName).tap(1, 1000);
+               //fileElement.tap(1, 1000);
+               ElementMenuOptions menuOptions = new ElementMenuOptions(driver);
+               return menuOptions;
        }
        
        }
        
-       public AndroidElement scrollTillFindElement (String fileName) {
-        HashMap<String, String> scrollObject = new HashMap<String, String>();
-        scrollObject.put("text", fileName);
-        scrollObject.put("element", ( (RemoteWebElement) filesLayout).getId());
-        if(filesLayout.getAttribute("scrollable").equals("true")){
-               driver.executeScript("mobile: scrollTo", scrollObject);
+       public AndroidElement scrollTillFindElement (String elementName) {
+        fileElement = Actions.scrollTillFindElement (elementName,filesLayout,driver);
+               try {
+               fileElementLayout = (AndroidElement) driver.findElementByAndroidUIAutomator("new UiSelector().description(\"LinearLayout-"+ elementName +"\")");
+        } catch (NoSuchElementException e) {
+               fileElementLayout = null;
         }
         }
-               fileElement = (AndroidElement) driver.findElementByName(fileName);
-               fileElementLayout = (AndroidElement) driver.findElementByAndroidUIAutomator("new UiSelector().description(\"LinearLayout-"+ fileName +"\")");
                return fileElement;
        }
        
        public AndroidElement getFileElementLayout () {
                return fileElementLayout;
        }
                return fileElement;
        }
        
        public AndroidElement getFileElementLayout () {
                return fileElementLayout;
        }
+       
+       public AndroidElement getProgressCircular () {
+               return progressCircular;
+       }
+       
+       public static String getLocalFileIndicator() {
+               return localFileIndicator;
+       }
+       
+       public static String getFavoriteFileIndicator() {
+               return favoriteFileIndicator;
+       }
+
+
 }
 }
diff --git a/automationTest/src/test/java/androidtest/models/MenuList.java b/automationTest/src/test/java/androidtest/models/MenuList.java
new file mode 100644 (file)
index 0000000..466fa1c
--- /dev/null
@@ -0,0 +1,27 @@
+package androidtest.models;
+
+import org.openqa.selenium.support.PageFactory;
+
+import io.appium.java_client.android.AndroidDriver;
+import io.appium.java_client.android.AndroidElement;
+import io.appium.java_client.pagefactory.AndroidFindBy;
+import io.appium.java_client.pagefactory.AppiumFieldDecorator;
+
+public class MenuList {
+
+       final AndroidDriver driver;
+       
+       @AndroidFindBy(name = "Settings")
+       private AndroidElement settingsButton;
+       
+       public MenuList (AndroidDriver driver) {
+               this.driver = driver;
+               PageFactory.initElements(new AppiumFieldDecorator(driver), this);
+       }
+       
+       public SettingsView clickOnSettingsButton () {
+               settingsButton.click();
+               SettingsView settingsView = new SettingsView(driver);
+               return settingsView;
+       }
+}
diff --git a/automationTest/src/test/java/androidtest/models/MoveView.java b/automationTest/src/test/java/androidtest/models/MoveView.java
new file mode 100644 (file)
index 0000000..f54ba28
--- /dev/null
@@ -0,0 +1,37 @@
+package androidtest.models;
+
+import io.appium.java_client.android.AndroidDriver;
+import io.appium.java_client.android.AndroidElement;
+import io.appium.java_client.pagefactory.AndroidFindBy;
+import io.appium.java_client.pagefactory.AppiumFieldDecorator;
+
+import org.openqa.selenium.support.CacheLookup;
+import org.openqa.selenium.support.PageFactory;
+
+import androidtest.actions.Actions;
+
+public class MoveView {
+       final AndroidDriver driver;
+       
+       @CacheLookup
+       @AndroidFindBy(id = "com.owncloud.android:id/list_root")
+       private AndroidElement filesLayout;
+       
+       @AndroidFindBy(name = "Choose")
+       private AndroidElement chooseButton;
+       
+       public MoveView (AndroidDriver driver) {
+               this.driver = driver;
+               PageFactory.initElements(new AppiumFieldDecorator(driver), this);
+       }
+       
+       public WaitAMomentPopUp clickOnChoose () {
+               chooseButton.click();
+               WaitAMomentPopUp waitAMomentPopUp = new WaitAMomentPopUp(driver);
+               return waitAMomentPopUp;
+       }
+       
+       public  AndroidElement scrollTillFindElement (String elementName) {
+               return Actions.scrollTillFindElement (elementName,filesLayout,driver);
+       }
+}
\ No newline at end of file
diff --git a/automationTest/src/test/java/androidtest/models/NewFolderPopUp.java b/automationTest/src/test/java/androidtest/models/NewFolderPopUp.java
new file mode 100644 (file)
index 0000000..658130d
--- /dev/null
@@ -0,0 +1,36 @@
+package androidtest.models;
+
+import org.openqa.selenium.support.PageFactory;
+
+import io.appium.java_client.android.AndroidDriver;
+import io.appium.java_client.android.AndroidElement;
+import io.appium.java_client.pagefactory.AndroidFindBy;
+import io.appium.java_client.pagefactory.AppiumFieldDecorator;
+
+public class NewFolderPopUp {
+
+       final AndroidDriver driver;
+       
+       @AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"android:id/button1\")")
+       private AndroidElement newFolderOkButton;
+       
+       @AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"com.owncloud.android:id/user_input\")")
+       private AndroidElement newFolderNameField;
+       
+       public NewFolderPopUp (AndroidDriver driver) {
+               this.driver = driver;
+               PageFactory.initElements(new AppiumFieldDecorator(driver), this);
+       }
+               
+       public void typeNewFolderName (String newFolderName) {
+               newFolderNameField.clear();
+               newFolderNameField.sendKeys(newFolderName);
+               driver.hideKeyboard();
+       }
+
+       public WaitAMomentPopUp clickOnNewFolderOkButton () {
+               newFolderOkButton.click();
+               WaitAMomentPopUp waitAMomentPopUp = new WaitAMomentPopUp(driver);
+               return waitAMomentPopUp;
+       }
+}
diff --git a/automationTest/src/test/java/androidtest/models/RemoveConfirmationView.java b/automationTest/src/test/java/androidtest/models/RemoveConfirmationView.java
new file mode 100644 (file)
index 0000000..e9a1ba9
--- /dev/null
@@ -0,0 +1,26 @@
+package androidtest.models;
+
+import io.appium.java_client.android.AndroidDriver;
+import io.appium.java_client.android.AndroidElement;
+import io.appium.java_client.pagefactory.AndroidFindBy;
+import io.appium.java_client.pagefactory.AppiumFieldDecorator;
+
+import org.openqa.selenium.support.PageFactory;
+
+public class RemoveConfirmationView {
+       final AndroidDriver driver;
+       
+       @AndroidFindBy(name = "Remote and local")
+       private AndroidElement remoteAndLocalButton;
+       
+       public RemoveConfirmationView (AndroidDriver driver) {
+               this.driver = driver;
+               PageFactory.initElements(new AppiumFieldDecorator(driver), this);
+       }
+       
+       public WaitAMomentPopUp clickOnRemoteAndLocalButton () {
+               remoteAndLocalButton.click();
+               WaitAMomentPopUp waitAMomentPopUp = new WaitAMomentPopUp(driver);
+               return waitAMomentPopUp;
+       }
+}
diff --git a/automationTest/src/test/java/androidtest/models/WaitAMomentPopUp.java b/automationTest/src/test/java/androidtest/models/WaitAMomentPopUp.java
new file mode 100644 (file)
index 0000000..f566e4a
--- /dev/null
@@ -0,0 +1,24 @@
+package androidtest.models;
+
+import org.openqa.selenium.support.PageFactory;
+
+import io.appium.java_client.android.AndroidDriver;
+import io.appium.java_client.android.AndroidElement;
+import io.appium.java_client.pagefactory.AndroidFindBy;
+import io.appium.java_client.pagefactory.AppiumFieldDecorator;
+
+public class WaitAMomentPopUp {
+       final AndroidDriver driver;
+       
+       @AndroidFindBy(name = "Wait a moment")
+       private AndroidElement waitAMomentText;
+       
+       public WaitAMomentPopUp (AndroidDriver driver) {
+               this.driver = driver;
+               PageFactory.initElements(new AppiumFieldDecorator(driver), this);
+       }
+       
+       public AndroidElement getWaitAMomentTextElement () {
+               return waitAMomentText;
+       }
+}
diff --git a/automationTest/src/test/java/androidtest/tests/.gitignore b/automationTest/src/test/java/androidtest/tests/.gitignore
new file mode 100644 (file)
index 0000000..fa0f66d
--- /dev/null
@@ -0,0 +1 @@
+Config.java
\ No newline at end of file
diff --git a/automationTest/src/test/java/androidtest/tests/Common.java b/automationTest/src/test/java/androidtest/tests/Common.java
new file mode 100644 (file)
index 0000000..7bf21bd
--- /dev/null
@@ -0,0 +1,87 @@
+package androidtest.tests;
+
+import java.io.File;
+import java.net.URL;
+import java.util.concurrent.TimeUnit;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.NoSuchElementException;
+import org.openqa.selenium.TimeoutException;
+import org.openqa.selenium.remote.DesiredCapabilities;
+import org.openqa.selenium.support.ui.WebDriverWait;
+import io.appium.java_client.android.AndroidDriver;
+import io.appium.java_client.android.AndroidElement;
+import junit.framework.TestCase;
+
+public class Common extends TestCase{
+       AndroidDriver driver;
+       static int waitingTime = 30;
+       
+       WebDriverWait wait;
+       
+       protected void setUpCommonDriver () throws Exception {
+               File rootPath = new File(System.getProperty("user.dir"));
+               File appDir = new File(rootPath,"src/test/resources");
+               File app = new File(appDir,"ownCloud.apk");
+               DesiredCapabilities capabilities = new DesiredCapabilities();
+               capabilities.setCapability("platformName", "Android");
+               capabilities.setCapability("deviceName", "Device");
+               capabilities.setCapability("app", app.getAbsolutePath());
+               capabilities.setCapability("app-package", "com.owncloud.android");
+               capabilities.setCapability("app-activity", ".ui.activity.FileDisplayActivity"); 
+               capabilities.setCapability("appWaitActivity", ".authentication.AuthenticatorActivity");
+               driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
+               driver.manage().timeouts().implicitlyWait(waitingTime, TimeUnit.SECONDS);
+               wait = new WebDriverWait(driver, waitingTime, 50);
+
+       }
+       
+       protected boolean waitForTextPresent(String text, AndroidElement element) throws InterruptedException{
+               for (int second = 0;;second++){ 
+                       if (second >= waitingTime)
+                               return false;
+                       try{
+                               if (text.equals(element.getText()))
+                                       break;
+                       } catch (Exception e){
+                               
+                       }
+                       Thread.sleep(1000);
+               }
+               return true;
+       }
+       
+       protected boolean isElementPresent(AndroidElement element, By by) {
+               try {
+                       element.findElement(by);
+                       return true;
+               } catch (NoSuchElementException e) {
+                       return false;
+               }
+       }
+       
+       protected boolean isElementPresent(AndroidElement element) {
+               try{
+                       element.isDisplayed();
+               } catch (NoSuchElementException e){
+                       return false;
+               }
+               return true;
+       }
+       
+       //pollingTime in milliseconds
+       public static void waitTillElementIsNotPresent (AndroidElement element, int pollingTime) throws Exception {
+               for (int time = 0;;time += pollingTime){        
+                       if (time >= waitingTime * 1000) //convert to milliseconds
+                               break;
+                       try{
+                               element.isDisplayed();
+                       } catch (NoSuchElementException e){
+                               return;
+                       }
+                       Thread.sleep(pollingTime);
+               }
+               throw new TimeoutException();
+       }
+       
+}
diff --git a/automationTest/src/test/java/androidtest/tests/CommonTest.java b/automationTest/src/test/java/androidtest/tests/CommonTest.java
deleted file mode 100644 (file)
index b819544..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-package androidtest.tests;
-
-import java.io.File;
-import java.net.URL;
-
-import org.openqa.selenium.By;
-import org.openqa.selenium.NoSuchElementException;
-import org.openqa.selenium.remote.DesiredCapabilities;
-
-import androidtest.models.LoginForm;
-import androidtest.models.MainView;
-import io.appium.java_client.android.AndroidDriver;
-import io.appium.java_client.android.AndroidElement;
-import junit.framework.TestCase;
-
-public class CommonTest extends TestCase{
-       AndroidDriver driver;
-       final int waitingTime = 30;
-       
-       protected void setUpCommonDriver () throws Exception {
-               File rootPath = new File(System.getProperty("user.dir"));
-               File appDir = new File(rootPath,"src/test/resources");
-               File app = new File(appDir,"ownCloud.apk");
-               DesiredCapabilities capabilities = new DesiredCapabilities();
-               capabilities.setCapability("platformName", "Android");
-               capabilities.setCapability("deviceName", "Device");
-               capabilities.setCapability("app", app.getAbsolutePath());
-               capabilities.setCapability("app-package", "com.owncloud.android");
-               capabilities.setCapability("app-activity", ".ui.activity.FileDisplayActivity"); 
-               capabilities.setCapability("appWaitActivity", ".authentication.AuthenticatorActivity");
-               driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
-       }
-       
-       protected boolean waitForTextPresent(String text, AndroidElement element) throws InterruptedException{
-               for (int second = 0;;second++){ 
-                       if (second >= waitingTime)
-                               return false;
-                       try{
-                               if (text.equals(element.getText()))
-                                       break;
-                       } catch (Exception e){
-                               
-                       }
-                       Thread.sleep(1000);
-               }
-               return true;
-       }
-       
-       protected boolean isElementPresent(AndroidElement element, By by) {
-               try {
-                       element.findElement(by);
-                       return true;
-               } catch (NoSuchElementException e) {
-                       return false;
-               }
-       }
-       
-       protected MainView login(String url, String user, String password) throws InterruptedException {
-               LoginForm loginForm = new LoginForm(driver);
-               loginForm.typeHostUrl(url);
-               loginForm.clickOnUserName();
-               waitForTextPresent("Secure connection established", loginForm.getServerStatusTextElement());
-               assertTrue(waitForTextPresent("Secure connection established", loginForm.getServerStatusTextElement()));        
-               loginForm.typeUserName(user);
-               loginForm.typePassword(password);
-               return loginForm.clickOnConnectButton();
-       }
-       
-}
index 4e1b0fe..5f5da2b 100644 (file)
@@ -3,22 +3,27 @@ package androidtest.tests;
 public final class Config {
        
        public static final String server = "owncloudServerVar";
 public final class Config {
        
        public static final String server = "owncloudServerVar";
-       public static final Boolean hasSubdirectory = false;
-       public static String URL = GetURl(hasSubdirectory);
+       public static final Boolean hasResource = false;
+       public static String URL = GetURl(server, hasResource, "resourceServerVar");
+       public static boolean isTrusted = true;
+       
+       public static final String server2 = "owncloudServer2Var";
+       public static final Boolean hasResource2 = false;
+       public static String URL2 = GetURl(server2, hasResource2, "resourceServerVar");
+       public static boolean isTrusted2 = true;
        
        public static final String user = "owncloudUserVar";
        public static final String password = "owncloudPasswordVar";
        public static final String user2 = "owncloudUser2Var";
        public static final String password2 = "owncloudPassword2Var";
        
        public static final String user = "owncloudUserVar";
        public static final String password = "owncloudPasswordVar";
        public static final String user2 = "owncloudUser2Var";
        public static final String password2 = "owncloudPassword2Var";
-       public static final String userAccount = user + "@"+server;
-       public static final String userAccount2 = user2 + "@"+server;
+       public static final String userAccount = user + "@"+ server;
+       public static final String userAccount2 = user2 + "@"+ server2;
        
        
-       public static String GetURl(Boolean hasSubdirectory){
+       public static String GetURl(String server, Boolean hasSubdirectory, String serverResource){
                if(hasSubdirectory){
                if(hasSubdirectory){
-                       return server + "/owncloud";
+                       return server + serverResource;
                }else{
                        return server;
                }
        }
                }else{
                        return server;
                }
        }
-
 }
 }
index 8736384..61294da 100644 (file)
@@ -1,54 +1,55 @@
 package androidtest.tests;
 
 package androidtest.tests;
 
-import io.appium.java_client.android.AndroidElement;
-
 import org.junit.After;
 import org.junit.Before;
 import org.junit.runners.MethodSorters;
 import org.junit.FixMethodOrder;
 import org.junit.Test;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.runners.MethodSorters;
 import org.junit.FixMethodOrder;
 import org.junit.Test;
-
-
 import androidtest.actions.Actions;
 import androidtest.models.MainView;
 import androidtest.actions.Actions;
 import androidtest.models.MainView;
+import androidtest.models.WaitAMomentPopUp;
 
 
 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
 
 
 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class CreateFolderTestSuite extends CommonTest{
+public class CreateFolderTestSuite extends Common{
+       
+       private Boolean folderHasBeenCreated = false;
+       private final String FOLDER_NAME = "testCreateFolder";
+       private String CurrentCreatedFolder = "";
+
 
        @Before
        public void setUp() throws Exception {
                setUpCommonDriver();
        }
 
 
        @Before
        public void setUp() throws Exception {
                setUpCommonDriver();
        }
 
-
        @Test
        @Test
-       public void test6CreateNewFolder () throws Exception {
+       public void testCreateNewFolder () throws Exception {
                String NEW_FOLDER_NAME = "testCreateFolder";
 
                String NEW_FOLDER_NAME = "testCreateFolder";
 
-               MainView mainView = login(Config.URL, Config.user,Config.password);
+               MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver);
                assertTrue(waitForTextPresent("ownCloud", mainView.getTitleTextElement()));
                assertTrue(waitForTextPresent("ownCloud", mainView.getTitleTextElement()));
-               mainView.clickOnNewFolderButton();
-               mainView.typeNewFolderName(NEW_FOLDER_NAME);
-               mainView.clickOnNewFolderOkButton();
-               assertTrue(waitForTextPresent("Wait a moment" , mainView.getWaitAMomentTextElement()));
-               while(mainView.getWaitAMomentTextElement().isDisplayed()){}
-               AndroidElement newFolderElement = mainView.scrollTillFindElement(NEW_FOLDER_NAME);
-               assertTrue(newFolderElement.isDisplayed());
-               newFolderElement.tap(1, 1000);
-               mainView.clickOnRemoveFileElement();
-               mainView.clickOnRemoteAndLocalButton();
-               assertTrue(waitForTextPresent("Wait a moment" , mainView.getWaitAMomentTextElement()));
-               while(mainView.getWaitAMomentTextElement().isDisplayed()){}
-               Actions.deleteAccount(mainView);
-       }
 
 
+               //check if the folder already exists and if true, delete them
+               Actions.deleteElement(NEW_FOLDER_NAME, mainView, driver);
+
+               WaitAMomentPopUp waitAMomentPopUp = Actions.createFolder(NEW_FOLDER_NAME, mainView);
+               waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100);
+               mainView.scrollTillFindElement(FOLDER_NAME);
+               assertNotNull(mainView.getFileElement());
+               assertTrue(folderHasBeenCreated=mainView.getFileElement().isDisplayed());       
+               CurrentCreatedFolder = FOLDER_NAME;
+               assertEquals(FOLDER_NAME , mainView.getFileElement().getText());
+       }
 
        @After
        public void tearDown() throws Exception {
 
        @After
        public void tearDown() throws Exception {
+               if (folderHasBeenCreated) {
+                       MainView mainView = new MainView(driver);
+                       Actions.deleteElement(CurrentCreatedFolder, mainView, driver);
+               }
                driver.removeApp("com.owncloud.android");
                driver.quit();
        }
 
 }
                driver.removeApp("com.owncloud.android");
                driver.quit();
        }
 
 }
-
diff --git a/automationTest/src/test/java/androidtest/tests/DeleteFileTestSuite.java b/automationTest/src/test/java/androidtest/tests/DeleteFileTestSuite.java
new file mode 100644 (file)
index 0000000..2ea23b6
--- /dev/null
@@ -0,0 +1,47 @@
+package androidtest.tests;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.runners.MethodSorters;
+import org.junit.FixMethodOrder;
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.support.ui.ExpectedConditions;
+
+import androidtest.actions.Actions;
+import androidtest.models.MainView;
+
+
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class DeleteFileTestSuite extends Common{
+       
+       private final String FILE_NAME = "test";
+       
+       @Before
+       public void setUp() throws Exception {
+               setUpCommonDriver();
+       }
+
+       @Test
+       public void testDeleteFile () throws Exception {                
+               MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver);
+               waitForTextPresent("ownCloud", mainView.getTitleTextElement());
+               
+               //TODO. if the file already exists, do not upload
+               MainView mainViewAfterUploadFile = Actions.uploadFile(FILE_NAME, mainView);
+               
+               mainViewAfterUploadFile.scrollTillFindElement(FILE_NAME);
+               waitTillElementIsNotPresent(mainViewAfterUploadFile.getProgressCircular(), 1000);
+               wait.until(ExpectedConditions.visibilityOf(mainViewAfterUploadFile.getFileElementLayout().findElement(By.id(MainView.getLocalFileIndicator()))));
+               
+               Actions.deleteElement(FILE_NAME,mainViewAfterUploadFile, driver);
+               assertFalse(mainViewAfterUploadFile.getFileElement().isDisplayed());
+       }
+
+       @After
+       public void tearDown() throws Exception {
+               driver.removeApp("com.owncloud.android");
+               driver.quit();
+       }
+
+}
\ No newline at end of file
diff --git a/automationTest/src/test/java/androidtest/tests/DeleteFolderTestSuite.java b/automationTest/src/test/java/androidtest/tests/DeleteFolderTestSuite.java
new file mode 100644 (file)
index 0000000..d5a8b35
--- /dev/null
@@ -0,0 +1,52 @@
+package androidtest.tests;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.runners.MethodSorters;
+import org.junit.FixMethodOrder;
+import org.junit.Test;
+
+import androidtest.actions.Actions;
+import androidtest.models.MainView;
+import androidtest.models.WaitAMomentPopUp;
+
+
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class DeleteFolderTestSuite extends Common{
+       private Boolean folderHasBeenCreated = false;
+       private final String FOLDER_NAME = "testCreateFolder";
+
+
+       @Before
+       public void setUp() throws Exception {
+               setUpCommonDriver();
+       }
+
+       @Test
+       public void testDeleteFolder () throws Exception {
+               MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver);
+               waitForTextPresent("ownCloud", mainView.getTitleTextElement());
+               
+               //TODO. if the folder already exists, do no created
+               //create the folder
+               WaitAMomentPopUp waitAMomentPopUp = Actions.createFolder(FOLDER_NAME, mainView);
+               waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100);
+               mainView.scrollTillFindElement(FOLDER_NAME);
+               assertTrue(folderHasBeenCreated = mainView.getFileElement().isDisplayed());
+
+               //delete the folder
+               Actions.deleteElement(FOLDER_NAME, mainView, driver);
+               assertFalse(folderHasBeenCreated =mainView.getFileElement().isDisplayed());
+       }
+
+       @After
+       public void tearDown() throws Exception {
+               if(folderHasBeenCreated){
+                       MainView mainView = new MainView(driver);
+                       Actions.deleteElement(FOLDER_NAME, mainView, driver);
+               }
+               driver.removeApp("com.owncloud.android");
+               driver.quit();
+       }
+
+}
index a4cbda6..a37bfa7 100644 (file)
@@ -6,15 +6,14 @@ import org.junit.runners.MethodSorters;
 import org.junit.FixMethodOrder;
 import org.junit.Test;
 import org.openqa.selenium.ScreenOrientation;
 import org.junit.FixMethodOrder;
 import org.junit.Test;
 import org.openqa.selenium.ScreenOrientation;
-
-
 import androidtest.actions.Actions;
 import androidtest.models.LoginForm;
 import androidtest.models.MainView;
 import androidtest.actions.Actions;
 import androidtest.models.LoginForm;
 import androidtest.models.MainView;
+import androidtest.models.MenuList;
 import androidtest.models.SettingsView;
 
 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
 import androidtest.models.SettingsView;
 
 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class LoginTestSuite extends CommonTest{
+public class LoginTestSuite extends Common{
 
        @Before
        public void setUp() throws Exception {
 
        @Before
        public void setUp() throws Exception {
@@ -23,98 +22,67 @@ public class LoginTestSuite extends CommonTest{
        
        @Test
        public void test1LoginPortrait () throws Exception {
        
        @Test
        public void test1LoginPortrait () throws Exception {
-               
-               System.out.println("Hello" + Config.server);
-               String testName = "loginPortrait";
                driver.rotate(ScreenOrientation.PORTRAIT);
                driver.rotate(ScreenOrientation.PORTRAIT);
-
-               MainView mainView = login(Config.URL, Config.user,Config.password);
+               
+               MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver);
                assertTrue(waitForTextPresent("ownCloud", mainView.getTitleTextElement()));
                assertTrue(waitForTextPresent("ownCloud", mainView.getTitleTextElement()));
-               //TO DO. detect in which view is. it can be files view or settings view
-               /*if(mainView.getTitleTextElement().equals("ownCloud") || mainView.getTitleTextElement().equals("Settings")){
-                       if(mainView.getTitleTextElement().getText().equals("ownCloud")){
-                               assertTrue(waitForTextPresent("ownCloud", mainView.getTitleTextElement()));
-                       }else{
-                               assertTrue(waitForTextPresent("Settings", mainView.getTitleTextElement()));
-                       }
-                       fail(testName);
-               }*/
-               Actions.deleteAccount(mainView);
        }
        
        @Test
        public void test2LoginLandscape () throws Exception {
        }
        
        @Test
        public void test2LoginLandscape () throws Exception {
-               
-               String testName = "loginLandscape";
                driver.rotate(ScreenOrientation.LANDSCAPE);
                driver.rotate(ScreenOrientation.LANDSCAPE);
-               MainView mainView = login(Config.URL, Config.user,Config.password);
+               MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver);
                assertTrue(waitForTextPresent("ownCloud", mainView.getTitleTextElement()));
                //TO DO. detect in which view is. it can be files view or settings view
                assertTrue(waitForTextPresent("ownCloud", mainView.getTitleTextElement()));
                //TO DO. detect in which view is. it can be files view or settings view
-               Actions.deleteAccount(mainView);
        }
        
        
        @Test
        public void test3MultiAccountRotate () throws Exception {
        }
        
        
        @Test
        public void test3MultiAccountRotate () throws Exception {
-               
-               String testName = "MultiAccountRotate";
                driver.rotate(ScreenOrientation.LANDSCAPE);
                driver.rotate(ScreenOrientation.LANDSCAPE);
-               MainView mainView = login(Config.URL, Config.user,Config.password);
+               MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver);
                assertTrue(waitForTextPresent("ownCloud", mainView.getTitleTextElement()));
                
                driver.rotate(ScreenOrientation.PORTRAIT);
                assertTrue(waitForTextPresent("ownCloud", mainView.getTitleTextElement()));
                
                driver.rotate(ScreenOrientation.PORTRAIT);
-               mainView.clickOnMenuButton();
-               SettingsView settingsView = mainView.clickOnSettingsButton();
+               MenuList menu = mainView.clickOnMenuButton();
+               SettingsView settingsView = menu.clickOnSettingsButton();
                settingsView.tapOnAddAccount(1, 1000);
                settingsView.tapOnAddAccount(1, 1000);
-               mainView = login(Config.URL, Config.user2,Config.password2);
+               mainView = Actions.login(Config.URL2, Config.user2,Config.password2, Config.isTrusted2, driver);
                
                assertTrue(waitForTextPresent("Settings", mainView.getTitleTextElement()));
                //TO DO. detect in which view is. it can be files view or settings view
                //Actions.deleteAccount(mainView);
                
                assertTrue(waitForTextPresent("Settings", mainView.getTitleTextElement()));
                //TO DO. detect in which view is. it can be files view or settings view
                //Actions.deleteAccount(mainView);
-               Actions.deleteAccount(settingsView);
                //TO DO. Delete the second user
        }
        
        @Test
        public void test4ExistingAccountRotate () throws Exception {
                //TO DO. Delete the second user
        }
        
        @Test
        public void test4ExistingAccountRotate () throws Exception {
-               
-               String testName = "ExistingAccountRotate";
                driver.rotate(ScreenOrientation.PORTRAIT);
                driver.rotate(ScreenOrientation.PORTRAIT);
-               MainView mainView = login(Config.URL, Config.user,Config.password);
+               MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver);
                assertTrue(waitForTextPresent("ownCloud", mainView.getTitleTextElement()));
                
                driver.rotate(ScreenOrientation.LANDSCAPE);
                assertTrue(waitForTextPresent("ownCloud", mainView.getTitleTextElement()));
                
                driver.rotate(ScreenOrientation.LANDSCAPE);
-               mainView.clickOnMenuButton();
-               SettingsView settingsView = mainView.clickOnSettingsButton();
+               MenuList menu = mainView.clickOnMenuButton();
+               SettingsView settingsView = menu.clickOnSettingsButton();
                settingsView.tapOnAddAccount(1, 1000);
                settingsView.tapOnAddAccount(1, 1000);
-               LoginForm loginForm = new LoginForm(driver);
-               loginForm.typeHostUrl(Config.URL);
-               loginForm.clickOnUserName();
-               waitForTextPresent("Secure connection established", loginForm.getServerStatusTextElement());
-               assertTrue(waitForTextPresent("Secure connection established", loginForm.getServerStatusTextElement()));        
-               loginForm.typeUserName(Config.user);
-               loginForm.typePassword(Config.password);
-               mainView = loginForm.clickOnConnectButton();
                
                
+               LoginForm loginForm = new LoginForm(driver);
+               mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver);    
                assertTrue(waitForTextPresent("An account for the same user and server already exists in the device", loginForm.getAuthStatusText()));
                assertTrue(waitForTextPresent("An account for the same user and server already exists in the device", loginForm.getAuthStatusText()));
-               driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_BACK);
-               Actions.deleteAccount(settingsView);
        }
        
 
        public void test5ChangePasswordWrong () throws Exception {
 
        }
        
 
        public void test5ChangePasswordWrong () throws Exception {
 
-               MainView mainView = login(Config.URL, Config.user,Config.password);
+               MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver);
                assertTrue(waitForTextPresent("ownCloud", mainView.getTitleTextElement()));
                assertTrue(waitForTextPresent("ownCloud", mainView.getTitleTextElement()));
-               mainView.clickOnMenuButton();
-               SettingsView settingView = mainView.clickOnSettingsButton();
-               settingView.tapOnAccountElement(1, 1000);
-               LoginForm changePasswordForm = settingView.clickOnChangePasswordElement();
+               MenuList menu = mainView.clickOnMenuButton();
+               SettingsView settingsView = menu.clickOnSettingsButton();
+               settingsView.tapOnAccountElement(1, 1000);
+               LoginForm changePasswordForm = settingsView.clickOnChangePasswordElement();
                changePasswordForm.typePassword("WrongPassword");
                changePasswordForm.clickOnConnectButton();
                assertTrue(waitForTextPresent("Wrong username or password", changePasswordForm.getAuthStatusText()));
                changePasswordForm.typePassword("WrongPassword");
                changePasswordForm.clickOnConnectButton();
                assertTrue(waitForTextPresent("Wrong username or password", changePasswordForm.getAuthStatusText()));
-               driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_BACK);
-               Actions.deleteAccount(settingView);
        }
        
 
        }
        
 
diff --git a/automationTest/src/test/java/androidtest/tests/LogoutTestSuite.java b/automationTest/src/test/java/androidtest/tests/LogoutTestSuite.java
new file mode 100644 (file)
index 0000000..a562441
--- /dev/null
@@ -0,0 +1,39 @@
+package androidtest.tests;
+
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import androidtest.actions.Actions;
+import androidtest.models.LoginForm;
+import androidtest.models.MainView;
+import androidtest.models.MenuList;
+import androidtest.models.SettingsView;
+
+public class LogoutTestSuite extends Common{
+
+       @Before
+       public void setUp() throws Exception {
+               setUpCommonDriver();
+       }
+
+       @Test
+       public void testLogout () throws Exception {
+               MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver);
+               waitForTextPresent("ownCloud", mainView.getTitleTextElement());
+               MenuList menulist = mainView.clickOnMenuButton();
+               SettingsView settingsView = menulist.clickOnSettingsButton();
+               settingsView.tapOnAccountElement(1, 1000);
+               LoginForm loginForm = settingsView.clickOnDeleteAccountElement();
+               assertEquals("Server address https://…", loginForm.gethostUrlInput().getText());
+               assertEquals("Username", loginForm.getUserNameInput().getText());
+               assertEquals("", loginForm.getPasswordInput().getText());
+       }
+
+       @After
+       public void tearDown() throws Exception {
+               driver.removeApp("com.owncloud.android");
+               driver.quit();
+       }
+}
diff --git a/automationTest/src/test/java/androidtest/tests/MoveFileTestSuite.java b/automationTest/src/test/java/androidtest/tests/MoveFileTestSuite.java
new file mode 100644 (file)
index 0000000..ca8a4ec
--- /dev/null
@@ -0,0 +1,78 @@
+package androidtest.tests;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.FixMethodOrder;
+import org.junit.Test;
+import org.junit.runners.MethodSorters;
+
+import androidtest.actions.Actions;
+import androidtest.models.ElementMenuOptions;
+import androidtest.models.MainView;
+import androidtest.models.MoveView;
+import androidtest.models.WaitAMomentPopUp;
+
+
+
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class MoveFileTestSuite extends Common{
+       private String FOLDER_WHERE_MOVE = "folderWhereMove";
+       private String FILE_NAME = "test";
+
+       @Before
+       public void setUp() throws Exception {
+               setUpCommonDriver();
+       }
+
+       @Test
+       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()));
+
+               waitTillElementIsNotPresent(mainView.getProgressCircular(), 1000);
+
+               //check if the folder already exists and if true, delete them
+               Actions.deleteElement(FOLDER_WHERE_MOVE, mainView, driver);
+               Actions.deleteElement(FILE_NAME, mainView, driver);
+
+               //Create the folder where the other is gone to be moved
+               waitAMomentPopUp = Actions.createFolder(FOLDER_WHERE_MOVE, mainView);
+               waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100);
+               mainView.scrollTillFindElement(FOLDER_WHERE_MOVE);
+               assertTrue(mainView.getFileElement().isDisplayed());
+
+               MainView mainViewAfterUploadFile = Actions.uploadFile(FILE_NAME, mainView);
+               mainViewAfterUploadFile.scrollTillFindElement(FILE_NAME);
+               assertTrue(mainViewAfterUploadFile.getFileElement().isDisplayed());
+
+               //select to move the file
+               ElementMenuOptions menuOptions = mainView.longPressOnElement(FILE_NAME);
+               MoveView moveView = menuOptions.clickOnMove();
+
+               //to move to a folder
+               moveView.scrollTillFindElement(FOLDER_WHERE_MOVE).tap(1,1);
+               waitAMomentPopUp = moveView.clickOnChoose();
+               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);
+               Thread.sleep(1000);
+               mainView.scrollTillFindElement(FILE_NAME);
+               assertEquals(FILE_NAME , mainView.getFileElement().getText());
+
+       }
+
+       @After
+       public void tearDown() throws Exception {
+               MainView mainView = new MainView(driver);
+               driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_BACK);
+               Actions.deleteElement(FOLDER_WHERE_MOVE, mainView, driver);
+               Actions.deleteElement(FILE_NAME, mainView, driver);
+               driver.removeApp("com.owncloud.android");
+               driver.quit();
+       }
+
+}
diff --git a/automationTest/src/test/java/androidtest/tests/MoveFolderTestSuite.java b/automationTest/src/test/java/androidtest/tests/MoveFolderTestSuite.java
new file mode 100644 (file)
index 0000000..a95c56c
--- /dev/null
@@ -0,0 +1,78 @@
+package androidtest.tests;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.runners.MethodSorters;
+import org.junit.FixMethodOrder;
+import org.junit.Test;
+import androidtest.actions.Actions;
+import androidtest.models.ElementMenuOptions;
+import androidtest.models.MainView;
+import androidtest.models.MoveView;
+import androidtest.models.WaitAMomentPopUp;
+
+
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class MoveFolderTestSuite extends Common{
+       private String FOLDER_TO_MOVE = "folderToMove";
+       private String FOLDER_WHERE_MOVE = "folderWhereMove";
+
+       @Before
+       public void setUp() throws Exception {
+               setUpCommonDriver();
+       }
+
+       @Test
+       public void testMoveFolder () throws Exception {
+               WaitAMomentPopUp waitAMomentPopUp;
+
+               MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver);
+               assertTrue(waitForTextPresent("ownCloud", mainView.getTitleTextElement()));
+
+               waitTillElementIsNotPresent(mainView.getProgressCircular(), 1000);
+
+               //check if the folder already exists and if true, delete them
+               Actions.deleteElement(FOLDER_WHERE_MOVE, mainView, driver);
+               Actions.deleteElement(FOLDER_TO_MOVE, mainView, driver);
+
+               //Create the folder where the other is gone to be moved
+               waitAMomentPopUp = Actions.createFolder(FOLDER_WHERE_MOVE, mainView);
+               waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100);
+               mainView.scrollTillFindElement(FOLDER_WHERE_MOVE);
+               assertTrue(mainView.getFileElement().isDisplayed());
+
+               //Create the folder which is going to be moved
+               waitAMomentPopUp = Actions.createFolder(FOLDER_TO_MOVE, mainView);
+               waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100);
+               mainView.scrollTillFindElement(FOLDER_TO_MOVE);
+               assertTrue(mainView.getFileElement().isDisplayed());
+
+               //select to move the folder
+               ElementMenuOptions menuOptions = mainView.longPressOnElement(FOLDER_TO_MOVE);
+               MoveView moveView = menuOptions.clickOnMove();
+
+               //to move to a folder
+               moveView.scrollTillFindElement(FOLDER_WHERE_MOVE).tap(1,1);
+               waitAMomentPopUp = moveView.clickOnChoose();
+               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);
+               Thread.sleep(1000);
+               mainView.scrollTillFindElement(FOLDER_TO_MOVE);
+               assertEquals(FOLDER_TO_MOVE , mainView.getFileElement().getText());
+       }
+
+       @After
+       public void tearDown() throws Exception {
+               MainView mainView = new MainView(driver);
+               driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_BACK);
+               Actions.deleteElement(FOLDER_WHERE_MOVE, mainView, driver);
+               Actions.deleteElement(FOLDER_TO_MOVE, mainView, driver);
+               driver.removeApp("com.owncloud.android");
+               driver.quit();
+       }
+
+
+}
diff --git a/automationTest/src/test/java/androidtest/tests/RenameFileTestSuite.java b/automationTest/src/test/java/androidtest/tests/RenameFileTestSuite.java
new file mode 100644 (file)
index 0000000..a95168a
--- /dev/null
@@ -0,0 +1,70 @@
+package androidtest.tests;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.runners.MethodSorters;
+import org.junit.FixMethodOrder;
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.support.ui.ExpectedConditions;
+
+import androidtest.actions.Actions;
+import androidtest.models.ElementMenuOptions;
+import androidtest.models.MainView;
+import androidtest.models.NewFolderPopUp;
+import androidtest.models.WaitAMomentPopUp;
+
+
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class RenameFileTestSuite extends Common{
+
+       private Boolean fileHasBeenCreated = false;
+       private final String OLD_FILE_NAME = "test";
+       private final String FILE_NAME = "newNameFile";
+       private String CurrentCreatedFile = "";
+
+
+       @Before
+       public void setUp() throws Exception {
+               setUpCommonDriver();
+       }
+
+       @Test
+       public void testRenameFile () throws Exception {
+               MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver);
+               waitForTextPresent("ownCloud", mainView.getTitleTextElement());
+
+               //TODO. if the file already exists, do not upload
+               MainView mainViewAfterUploadFile = Actions.uploadFile(OLD_FILE_NAME, mainView);
+
+               //check if the file with the new name already exists, if true delete it
+               Actions.deleteElement(FILE_NAME, mainView, driver);
+
+               mainViewAfterUploadFile.scrollTillFindElement(OLD_FILE_NAME);
+               assertTrue(fileHasBeenCreated = mainViewAfterUploadFile.getFileElement().isDisplayed());
+               CurrentCreatedFile = OLD_FILE_NAME;
+               waitTillElementIsNotPresent(mainViewAfterUploadFile.getProgressCircular(), 1000);
+               wait.until(ExpectedConditions.visibilityOf(mainViewAfterUploadFile.getFileElementLayout().findElement(By.id(MainView.getLocalFileIndicator()))));
+               ElementMenuOptions menuOptions = mainViewAfterUploadFile.longPressOnElement(OLD_FILE_NAME);
+               NewFolderPopUp newFolderPopUp = menuOptions.clickOnRename();
+               newFolderPopUp.typeNewFolderName(FILE_NAME);
+               WaitAMomentPopUp waitAMomentPopUp = newFolderPopUp.clickOnNewFolderOkButton();
+               waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100);
+               mainViewAfterUploadFile.scrollTillFindElement(FILE_NAME);
+               assertNotNull(mainViewAfterUploadFile.getFileElement());
+               assertTrue(mainViewAfterUploadFile.getFileElement().isDisplayed());     
+               assertEquals(FILE_NAME , mainViewAfterUploadFile.getFileElement().getText());
+               CurrentCreatedFile = FILE_NAME;
+       }
+
+       @After
+       public void tearDown() throws Exception {
+               if (fileHasBeenCreated) {
+                       MainView mainView = new MainView(driver);
+                       Actions.deleteElement(CurrentCreatedFile,mainView, driver);
+               }
+               driver.removeApp("com.owncloud.android");
+               driver.quit();
+       }
+
+}
diff --git a/automationTest/src/test/java/androidtest/tests/RenameFolderTestSuite.java b/automationTest/src/test/java/androidtest/tests/RenameFolderTestSuite.java
new file mode 100644 (file)
index 0000000..ef5d742
--- /dev/null
@@ -0,0 +1,68 @@
+package androidtest.tests;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.runners.MethodSorters;
+import org.junit.FixMethodOrder;
+import org.junit.Test;
+import androidtest.actions.Actions;
+import androidtest.models.ElementMenuOptions;
+import androidtest.models.MainView;
+import androidtest.models.NewFolderPopUp;
+import androidtest.models.WaitAMomentPopUp;
+
+
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class RenameFolderTestSuite extends Common{
+
+       private Boolean folderHasBeenCreated = false;
+       private final String OLD_FOLDER_NAME = "beforeRemoving";
+       private final String FOLDER_NAME = "testCreateFolder";
+       private String CurrentCreatedFolder = "";
+
+
+       @Before
+       public void setUp() throws Exception {
+               setUpCommonDriver();
+       }
+
+       @Test
+       public void testRenameFolder () throws Exception {
+               MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver);
+               waitForTextPresent("ownCloud", mainView.getTitleTextElement());
+
+               //TODO. if the folder already exists, do no created
+               //create the folder to rename
+               WaitAMomentPopUp waitAMomentPopUp = Actions.createFolder(OLD_FOLDER_NAME, mainView);
+               waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100);
+               mainView.scrollTillFindElement(OLD_FOLDER_NAME);
+
+               assertTrue(folderHasBeenCreated = mainView.getFileElement().isDisplayed());
+
+               //check if the folder with the new name already exists and if true, delete them
+               Actions.deleteElement(FOLDER_NAME, mainView, driver);
+
+               CurrentCreatedFolder = OLD_FOLDER_NAME;
+               ElementMenuOptions menuOptions = mainView.longPressOnElement(OLD_FOLDER_NAME);
+               NewFolderPopUp FolderPopUp = menuOptions.clickOnRename();
+               FolderPopUp.typeNewFolderName(FOLDER_NAME);
+               FolderPopUp.clickOnNewFolderOkButton();
+               CurrentCreatedFolder = FOLDER_NAME;
+               waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100);
+               mainView.scrollTillFindElement(FOLDER_NAME);
+               assertNotNull(mainView.getFileElement());
+               assertTrue(folderHasBeenCreated = mainView.getFileElement().isDisplayed());     
+               assertEquals(FOLDER_NAME , mainView.getFileElement().getText());
+       }
+
+       @After
+       public void tearDown() throws Exception {
+               if(folderHasBeenCreated){
+                       MainView mainView = new MainView(driver);
+                       Actions.deleteElement(CurrentCreatedFolder, mainView, driver);
+               }
+               driver.removeApp("com.owncloud.android");
+               driver.quit();
+       }
+
+}
index 4b1a500..20ddf64 100644 (file)
@@ -8,81 +8,74 @@ import org.junit.Before;
 import org.junit.runners.MethodSorters;
 import org.junit.FixMethodOrder;
 import org.junit.Test;
 import org.junit.runners.MethodSorters;
 import org.junit.FixMethodOrder;
 import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.support.ui.ExpectedConditions;
 
 import androidtest.actions.Actions;
 import androidtest.models.AppDetailsView;
 
 import androidtest.actions.Actions;
 import androidtest.models.AppDetailsView;
-import androidtest.models.FilesView;
+import androidtest.models.ElementMenuOptions;
 import androidtest.models.MainView;
 
 
 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
 import androidtest.models.MainView;
 
 
 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class UploadTestSuite extends CommonTest{
+public class UploadTestSuite extends Common{
+
+       String FILE_NAME = "test";
 
        @Before
        public void setUp() throws Exception {
 
        @Before
        public void setUp() throws Exception {
-                       setUpCommonDriver();
+               setUpCommonDriver();
        }
        }
-       
+
        @Test
        public void test1UploadFile () throws Exception {
        @Test
        public void test1UploadFile () throws Exception {
-               String FILE_NAME = "test";
-               
-               MainView mainView = login(Config.URL, Config.user,Config.password);
+
+               MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver);
                assertTrue(waitForTextPresent("ownCloud", mainView.getTitleTextElement()));
                assertTrue(waitForTextPresent("ownCloud", mainView.getTitleTextElement()));
-               mainView.clickOnUploadButton();
-               FilesView filesView = mainView.clickOnFilesElementUploadFile();
-               filesView.clickOnFileName(FILE_NAME);
-               MainView mainViewAfterUploadFile = filesView.clickOnUploadButton();
-               //TO DO. detect when the file is successfully uploaded
-               Thread.sleep(3000);
+
+               //check if the file already exists and if true, delete it
+               Actions.deleteElement(FILE_NAME, mainView, driver);
+
+               MainView mainViewAfterUploadFile = Actions.uploadFile(FILE_NAME, mainView);
+
                mainViewAfterUploadFile.scrollTillFindElement(FILE_NAME);
                assertTrue(mainViewAfterUploadFile.getFileElement().isDisplayed());
                mainViewAfterUploadFile.scrollTillFindElement(FILE_NAME);
                assertTrue(mainViewAfterUploadFile.getFileElement().isDisplayed());
-               mainViewAfterUploadFile.tapOnFileElement(FILE_NAME);
-               mainViewAfterUploadFile.clickOnRemoveFileElement();
-               mainViewAfterUploadFile.clickOnRemoteAndLocalButton();
-               assertTrue(waitForTextPresent("Wait a moment" , mainViewAfterUploadFile.getWaitAMomentTextElement()));
-               while(mainViewAfterUploadFile.getWaitAMomentTextElement().isDisplayed()){}
-               Actions.deleteAccount(mainViewAfterUploadFile);
-               
+               waitTillElementIsNotPresent(mainViewAfterUploadFile.getProgressCircular(), 1000);
+               wait.until(ExpectedConditions.visibilityOf(mainViewAfterUploadFile.getFileElementLayout().findElement(By.id(MainView.getLocalFileIndicator()))));
+
+
        }
        }
-       
+
        @Test
        public void test2KeepFileUpToDate () throws Exception {
        @Test
        public void test2KeepFileUpToDate () throws Exception {
-               String FILE_NAME = "test";
-               
-               MainView mainView = login(Config.URL, Config.user,Config.password);
+
+               MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver);
                assertTrue(waitForTextPresent("ownCloud", mainView.getTitleTextElement()));
                assertTrue(waitForTextPresent("ownCloud", mainView.getTitleTextElement()));
-               mainView.clickOnUploadButton();
-               FilesView filesView = mainView.clickOnFilesElementUploadFile();
-               filesView.clickOnFileName(FILE_NAME);
-               MainView mainViewAfterUploadFile = filesView.clickOnUploadButton();
-               //TO DO. detect when the file is successfully uploaded
-               Thread.sleep(3000);
+
+               waitTillElementIsNotPresent(mainView.getProgressCircular(), 1000);
+
+               MainView mainViewAfterUploadFile = Actions.uploadFile(FILE_NAME, mainView);
                mainViewAfterUploadFile.scrollTillFindElement(FILE_NAME);
                assertTrue(mainViewAfterUploadFile.getFileElement().isDisplayed());
                mainViewAfterUploadFile.scrollTillFindElement(FILE_NAME);
                assertTrue(mainViewAfterUploadFile.getFileElement().isDisplayed());
-               mainViewAfterUploadFile.tapOnFileElement(FILE_NAME);
-               AppDetailsView appDetailsView = mainViewAfterUploadFile.clickOnDetailsFileElement();
+
+               ElementMenuOptions menuOptions = mainViewAfterUploadFile.longPressOnElement(FILE_NAME);
+               AppDetailsView appDetailsView = menuOptions.clickOnDetails();
                appDetailsView.checkKeepFileUpToDateCheckbox();
                appDetailsView.checkKeepFileUpToDateCheckbox();
-               //assertTrue(appDetailsView.getProgressBar().isDisplayed());
                Thread.sleep(3000);
                driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_BACK);
                Thread.sleep(3000);
                driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_BACK);
-               assertTrue(isElementPresent(mainViewAfterUploadFile.getFileElementLayout(), MobileBy.id("com.owncloud.android:id/imageView3")));
-               mainViewAfterUploadFile.tapOnFileElement(FILE_NAME);
-               mainViewAfterUploadFile.clickOnRemoveFileElement();
-               mainViewAfterUploadFile.clickOnRemoteAndLocalButton();
-               assertTrue(waitForTextPresent("Wait a moment" , mainViewAfterUploadFile.getWaitAMomentTextElement()));
-               while(mainViewAfterUploadFile.getWaitAMomentTextElement().isDisplayed()){}
-               Actions.deleteAccount(mainViewAfterUploadFile);
-               
+               assertTrue(isElementPresent(mainViewAfterUploadFile.getFileElementLayout(), MobileBy.id(MainView.getFavoriteFileIndicator())));
+
        }
        }
-       
-       
+
+
        @After
        public void tearDown() throws Exception {
        @After
        public void tearDown() throws Exception {
+               MainView mainView = new MainView(driver);
+               Actions.deleteElement(FILE_NAME,mainView, driver);
                driver.removeApp("com.owncloud.android");
                driver.quit();
        }
                driver.removeApp("com.owncloud.android");
                driver.quit();
        }
-       
+
 
 }
 
 
 }