<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>
/target/
-.DS_Store
\ No newline at end of file
+src/test/java/androidtest/tests/Config.java
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.source=1.5
+org.eclipse.jdt.core.compiler.source=1.7
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.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.MenuList;
+import androidtest.models.NewFolderPopUp;
+import androidtest.models.RemoveConfirmationView;
import androidtest.models.SettingsView;
+import androidtest.models.WaitAMomentPopUp;
+import androidtest.tests.Common;
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) {
- mainView.clickOnMenuButton();
- SettingsView settingView = mainView.clickOnSettingsButton();
+ MenuList menulist = mainView.clickOnMenuButton();
+ SettingsView settingView = menulist.clickOnSettingsButton();
deleteAccount(settingView);
-
}
-
+
public static void deleteAccount (SettingsView settingsView) {
settingsView.tapOnAccountElement(1, 1000);
settingsView.clickOnDeleteAccountElement();
}
-
+
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;
+ }
+
+
}
--- /dev/null
+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;
+ }
+
+}
--- /dev/null
+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;
+ }
+}
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 org.openqa.selenium.remote.RemoteWebElement;
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")
- private AndroidElement fileLayout;
+ private AndroidElement filesLayout;
@CacheLookup
@AndroidFindBy(id = "com.owncloud.android:id/upload_files_btn_upload")
return mainView;
}
+ //change to scrollTillFindElement
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) {
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;
PageFactory.initElements(new AppiumFieldDecorator(driver), this);
}
- public void typeHostUrl (String hostUrl) {
+ public CertificatePopUp typeHostUrl (String hostUrl) {
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 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);
- driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_BACK);
+ driver.hideKeyboard();
}
public MainView clickOnConnectButton () {
return mainView;
}
+ public AndroidElement gethostUrlInput () {
+ return hostUrlInput;
+ }
+
+ public AndroidElement getUserNameInput () {
+ return userNameInput;
+ }
+
+ public AndroidElement getPasswordInput () {
+ return passwordInput;
+ }
+
+
public AndroidElement getServerStatusTextElement () {
return serverStatusText;
}
package androidtest.models;
-import java.util.HashMap;
import java.util.List;
import io.appium.java_client.android.AndroidDriver;
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 androidtest.actions.Actions;
+
public class MainView {
final AndroidDriver driver;
- @CacheLookup
@AndroidFindBy(uiAutomator = "new UiSelector().description(\"More options\")")
private AndroidElement menuButton;
@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\")")
@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")
@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;
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 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();
- }
-
- public SettingsView clickOnSettingsButton () {
- settingsButton.click();
- SettingsView settingsView = new SettingsView(driver);
- return settingsView;
+ MenuList menuList = new MenuList (driver);
+ return menuList;
}
public SettingsView getSettingsView () {
return settingsView;
}
- public void clickOnNewFolderButton () {
+ public NewFolderPopUp clickOnNewFolderButton () {
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 () {
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;
}
+
+ public AndroidElement getProgressCircular () {
+ return progressCircular;
+ }
+
+ public static String getLocalFileIndicator() {
+ return localFileIndicator;
+ }
+
+ public static String getFavoriteFileIndicator() {
+ return favoriteFileIndicator;
+ }
+
+
}
--- /dev/null
+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;
+ }
+}
--- /dev/null
+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
--- /dev/null
+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;
+ }
+}
--- /dev/null
+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;
+ }
+}
--- /dev/null
+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;
+ }
+}
--- /dev/null
+Config.java
\ No newline at end of file
--- /dev/null
+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();
+ }
+
+}
+++ /dev/null
-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();
- }
-
-}
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 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){
- return server + "/owncloud";
+ return server + serverResource;
}else{
return server;
}
}
-
}
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 androidtest.actions.Actions;
import androidtest.models.MainView;
+import androidtest.models.WaitAMomentPopUp;
@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();
}
-
@Test
- public void test6CreateNewFolder () throws Exception {
+ public void testCreateNewFolder () throws Exception {
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()));
- 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 {
+ if (folderHasBeenCreated) {
+ MainView mainView = new MainView(driver);
+ Actions.deleteElement(CurrentCreatedFolder, mainView, driver);
+ }
driver.removeApp("com.owncloud.android");
driver.quit();
}
}
-
--- /dev/null
+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
--- /dev/null
+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();
+ }
+
+}
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.models.MenuList;
import androidtest.models.SettingsView;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class LoginTestSuite extends CommonTest{
+public class LoginTestSuite extends Common{
@Before
public void setUp() throws Exception {
@Test
public void test1LoginPortrait () throws Exception {
-
- System.out.println("Hello" + Config.server);
- String testName = "loginPortrait";
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()));
- //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 {
-
- String testName = "loginLandscape";
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
- Actions.deleteAccount(mainView);
}
@Test
public void test3MultiAccountRotate () throws Exception {
-
- String testName = "MultiAccountRotate";
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);
- mainView.clickOnMenuButton();
- SettingsView settingsView = mainView.clickOnSettingsButton();
+ MenuList menu = mainView.clickOnMenuButton();
+ SettingsView settingsView = menu.clickOnSettingsButton();
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);
- Actions.deleteAccount(settingsView);
//TO DO. Delete the second user
}
@Test
public void test4ExistingAccountRotate () throws Exception {
-
- String testName = "ExistingAccountRotate";
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);
- mainView.clickOnMenuButton();
- SettingsView settingsView = mainView.clickOnSettingsButton();
+ MenuList menu = mainView.clickOnMenuButton();
+ SettingsView settingsView = menu.clickOnSettingsButton();
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()));
- driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_BACK);
- Actions.deleteAccount(settingsView);
}
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()));
- 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()));
- driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_BACK);
- Actions.deleteAccount(settingView);
}
--- /dev/null
+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();
+ }
+}
--- /dev/null
+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();
+ }
+
+}
--- /dev/null
+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();
+ }
+
+
+}
--- /dev/null
+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();
+ }
+
+}
--- /dev/null
+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();
+ }
+
+}
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.models.FilesView;
+import androidtest.models.ElementMenuOptions;
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 {
- setUpCommonDriver();
+ setUpCommonDriver();
}
-
+
@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()));
- 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.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 {
- 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()));
- 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.tapOnFileElement(FILE_NAME);
- AppDetailsView appDetailsView = mainViewAfterUploadFile.clickOnDetailsFileElement();
+
+ ElementMenuOptions menuOptions = mainViewAfterUploadFile.longPressOnElement(FILE_NAME);
+ AppDetailsView appDetailsView = menuOptions.clickOnDetails();
appDetailsView.checkKeepFileUpToDateCheckbox();
- //assertTrue(appDetailsView.getProgressBar().isDisplayed());
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 {
+ MainView mainView = new MainView(driver);
+ Actions.deleteElement(FILE_NAME,mainView, driver);
driver.removeApp("com.owncloud.android");
driver.quit();
}
-
+
}