--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" output="target/classes" path="src/main/java">
+ <attributes>
+ <attribute name="optional" value="true"/>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="src" path="resources"/>
+ <classpathentry kind="src" output="target/test-classes" path="src/test/java">
+ <attributes>
+ <attribute name="optional" value="true"/>
+ <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">
+ <attributes>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
+ <attributes>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
--- /dev/null
+/target/
+.DS_Store
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>androidtest</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.m2e.core.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.m2e.core.maven2Nature</nature>
+ </natures>
+</projectDescription>
--- /dev/null
+eclipse.preferences.version=1
+encoding//src/main/java=UTF-8
+encoding//src/test/java=UTF-8
+encoding/<project>=UTF-8
--- /dev/null
+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.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.source=1.5
--- /dev/null
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<modelVersion>4.0.0</modelVersion>
+
+<groupId>com.owncloud</groupId>
+<artifactId>androidtest</artifactId>
+<version>1.0-SNAPSHOT</version>
+
+<dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ </dependency>
+ <dependency>
+ <groupId>org.seleniumhq.selenium</groupId>
+ <artifactId>selenium-java</artifactId>
+ <version>2.44.0</version>
+ </dependency>
+ <dependency>
+ <groupId>io.selendroid</groupId>
+ <version>0.9.0</version>
+ <artifactId>selendroid-standalone</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.selendroid</groupId>
+ <version>0.9.0</version>
+ <artifactId>selendroid-client</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.appium</groupId>
+ <artifactId>java-client</artifactId>
+ <version>2.1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ <version>2.6</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ <version>4.3.1</version>
+ </dependency>
+ <dependency>
+ <groupId>com.google.android</groupId>
+ <artifactId>android</artifactId>
+ <version>4.1.1.4</version>
+ <scope>provided</scope>
+ </dependency>
+</dependencies>
+
+</project>
\ No newline at end of file
--- /dev/null
+package androidtest.actions;
+
+import io.appium.java_client.android.AndroidDriver;
+import androidtest.models.MainView;
+import androidtest.models.SettingsView;
+
+public class Actions {
+
+ public static void deleteAccount (MainView mainView) {
+ mainView.clickOnMenuButton();
+ SettingsView settingView = mainView.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);
+ }
+
+
+}
--- /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;
+
+public class AppDetailsView {
+ final AndroidDriver driver;
+
+ @CacheLookup
+ @AndroidFindBy(name = "Keep file up to date")
+ private AndroidElement keepFileUpToDateCheckbox;
+
+ @AndroidFindBy(id = "com.owncloud.android:id/fdProgressBar")
+ private AndroidElement progressBar;
+
+ public AppDetailsView (AndroidDriver driver) {
+ this.driver = driver;
+ PageFactory.initElements(new AppiumFieldDecorator(driver), this);
+ }
+
+ public void checkKeepFileUpToDateCheckbox () {
+ if(keepFileUpToDateCheckbox.getAttribute("checked").equals("false")){
+ keepFileUpToDateCheckbox.click();
+ }
+ }
+
+ public void unCheckKeepFileUpToDateCheckbox () {
+ if(keepFileUpToDateCheckbox.getAttribute("checked").equals("true")){
+ keepFileUpToDateCheckbox.click();
+ }
+ }
+
+ public AndroidElement getProgressBar (){
+ return progressBar;
+ }
+}
--- /dev/null
+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;
+
+public class FilesView {
+ final AndroidDriver driver;
+
+ @CacheLookup
+ @AndroidFindBy(id = "com.owncloud.android:id/list_root")
+ private AndroidElement fileLayout;
+
+ @CacheLookup
+ @AndroidFindBy(id = "com.owncloud.android:id/upload_files_btn_upload")
+ private AndroidElement uploadButton;
+
+ private AndroidElement fileElement;
+
+ public FilesView (AndroidDriver driver) {
+ this.driver = driver;
+ PageFactory.initElements(new AppiumFieldDecorator(driver), this);
+ }
+
+ public MainView clickOnUploadButton () {
+ uploadButton.click();
+ MainView mainView = new MainView (driver);
+ return mainView;
+ }
+
+ 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);
+ }
+
+ public void clickOnFileName (String fileName) {
+ scrollTillFindFile(fileName);
+ fileElement.click();
+ }
+}
--- /dev/null
+package androidtest.models;
+
+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.pagefactory.AppiumFieldDecorator;
+
+public class LoginForm {
+ final AndroidDriver driver;
+
+ @CacheLookup
+ @AndroidFindBy(uiAutomator = "new UiSelector().description(\"Server address\")")
+ private AndroidElement hostUrlInput;
+
+ @CacheLookup
+ @AndroidFindBy(uiAutomator = "new UiSelector().description(\"Username\")")
+ private AndroidElement userNameInput;
+
+ @CacheLookup
+ @AndroidFindBy(uiAutomator = "new UiSelector().description(\"Password\")")
+ private AndroidElement passwordInput;
+
+ @CacheLookup
+ @AndroidFindBy(uiAutomator = "new UiSelector().description(\"Connect\")")
+ private AndroidElement connectButton;
+
+ @AndroidFindBy(uiAutomator = "new UiSelector().description(\"Testing connection\")")
+ private AndroidElement serverStatusText;
+
+ @AndroidFindBy(uiAutomator = "new UiSelector().description(\"Wrong username or password\")")
+ private AndroidElement authStatusText;
+
+ public LoginForm (AndroidDriver driver) {
+ this.driver = driver;
+ PageFactory.initElements(new AppiumFieldDecorator(driver), this);
+ }
+
+ public void typeHostUrl (String hostUrl) {
+ hostUrlInput.clear();
+ hostUrlInput.sendKeys(hostUrl);
+ driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_BACK);
+ }
+
+ public void clickOnUserName () {
+ userNameInput.click();
+ }
+
+ public void typeUserName (String userName) {
+ userNameInput.clear();
+ userNameInput.sendKeys(userName);
+ driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_BACK);
+ }
+
+ public void typePassword (String password) {
+ passwordInput.clear();
+ passwordInput.sendKeys(password);
+ driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_BACK);
+ }
+
+ public MainView clickOnConnectButton () {
+ connectButton.click();
+ MainView mainView = new MainView(driver);
+ return mainView;
+ }
+
+ public AndroidElement getServerStatusTextElement () {
+ return serverStatusText;
+ }
+
+ public AndroidElement getAuthStatusText () {
+ return authStatusText;
+ }
+}
--- /dev/null
+package androidtest.models;
+
+import java.util.HashMap;
+import java.util.List;
+
+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;
+
+public class MainView {
+ final AndroidDriver driver;
+
+ @CacheLookup
+ @AndroidFindBy(uiAutomator = "new UiSelector().description(\"More options\")")
+ private AndroidElement menuButton;
+
+ @CacheLookup
+ @AndroidFindBy(id = "com.owncloud.android:id/list_root")
+ private AndroidElement filesLayout;
+
+ @CacheLookup
+ @AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"android:id/action_bar_title\")")
+ private AndroidElement titleText;
+
+ @AndroidFindBy(name = "Settings")
+ private AndroidElement settingsButton;
+
+ @CacheLookup
+ @AndroidFindBy(uiAutomator = "new UiSelector().description(\"New folder\")")
+ private AndroidElement newFolderButton;
+
+ @CacheLookup
+ @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 List<AndroidElement> 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 fileElement;
+
+ private AndroidElement fileElementLayout;
+
+
+ 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();
+ //}
+ menuButton.click();
+ }
+
+ public SettingsView clickOnSettingsButton () {
+ settingsButton.click();
+ SettingsView settingsView = new SettingsView(driver);
+ return settingsView;
+ }
+
+ public SettingsView getSettingsView () {
+ SettingsView settingsView = new SettingsView(driver);
+ return settingsView;
+ }
+
+ public void 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");
+ }
+
+ public void clickOnUploadButton () {
+ uploadButton.click();
+ }
+
+ public FilesView clickOnFilesElementUploadFile () {
+ filesElementUploadFile.click();
+ FilesView filesView = new FilesView(driver);
+ return filesView;
+ }
+
+ public AndroidElement getTitleTextElement () {
+ return titleText;
+ }
+
+ public AndroidElement getWaitAMomentTextElement () {
+ return waitAMomentText;
+ }
+
+ public AndroidElement getListRootElement () {
+ return listRootLayout;
+ }
+
+ public List<AndroidElement> getListItemLayout () {
+ return listItemLayout;
+ }
+
+ public AndroidElement getFileElement () {
+ return fileElement;
+ }
+
+ public void tapOnFileElement (String fileName) {
+ scrollTillFindElement(fileName);
+ fileElement.tap(1, 1000);
+ }
+
+ 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);
+ }
+ fileElement = (AndroidElement) driver.findElementByName(fileName);
+ fileElementLayout = (AndroidElement) driver.findElementByAndroidUIAutomator("new UiSelector().description(\"LinearLayout-"+ fileName +"\")");
+ return fileElement;
+ }
+
+ public AndroidElement getFileElementLayout () {
+ return fileElementLayout;
+ }
+}
--- /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.tests.Config;
+
+public class SettingsView {
+ final AndroidDriver driver;
+
+ @CacheLookup
+ @AndroidFindBy(name = Config.userAccount)
+ private AndroidElement accountElement;
+
+ @CacheLookup
+ @AndroidFindBy(name = Config.userAccount2)
+ private AndroidElement accountElement2;
+
+ @AndroidFindBy(name = "Delete account")
+ private AndroidElement deleteAccountElement;
+
+ @AndroidFindBy(name = "Change password")
+ private AndroidElement changePasswordElement;
+
+ @AndroidFindBy(name = "Add account")
+ private AndroidElement addAccountElement;
+
+ public SettingsView (AndroidDriver driver) {
+ this.driver = driver;
+ PageFactory.initElements(new AppiumFieldDecorator(driver), this);
+ }
+
+ public void tapOnAccountElement (int fingers, int milliSeconds) {
+ accountElement.tap(fingers, milliSeconds);
+ }
+
+
+ public void tapOnAddAccount (int fingers, int milliSeconds) {
+ addAccountElement.tap(fingers, milliSeconds);
+ }
+
+ public LoginForm clickOnDeleteAccountElement () {
+ deleteAccountElement.click();
+ LoginForm loginForm = new LoginForm(driver);
+ return loginForm;
+ }
+
+ public LoginForm clickOnChangePasswordElement () {
+ changePasswordElement.click();
+ LoginForm loginForm = new LoginForm(driver);
+ return loginForm;
+ }
+
+}
--- /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();
+ }
+
+}
--- /dev/null
+package androidtest.tests;
+
+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 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 String GetURl(Boolean hasSubdirectory){
+ if(hasSubdirectory){
+ return server + "/owncloud";
+ }else{
+ return server;
+ }
+ }
+
+}
--- /dev/null
+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;
+
+
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class CreateFolderTestSuite extends CommonTest{
+
+ @Before
+ public void setUp() throws Exception {
+ setUpCommonDriver();
+ }
+
+
+ @Test
+ public void test6CreateNewFolder () throws Exception {
+ String NEW_FOLDER_NAME = "testCreateFolder";
+
+ MainView mainView = login(Config.URL, Config.user,Config.password);
+ 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);
+ }
+
+
+ @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.runners.MethodSorters;
+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.SettingsView;
+
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class LoginTestSuite extends CommonTest{
+
+ @Before
+ public void setUp() throws Exception {
+ setUpCommonDriver();
+ }
+
+ @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);
+ 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);
+ 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);
+ assertTrue(waitForTextPresent("ownCloud", mainView.getTitleTextElement()));
+
+ driver.rotate(ScreenOrientation.PORTRAIT);
+ mainView.clickOnMenuButton();
+ SettingsView settingsView = mainView.clickOnSettingsButton();
+ settingsView.tapOnAddAccount(1, 1000);
+ mainView = login(Config.URL, Config.user2,Config.password2);
+
+ 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);
+ assertTrue(waitForTextPresent("ownCloud", mainView.getTitleTextElement()));
+
+ driver.rotate(ScreenOrientation.LANDSCAPE);
+ mainView.clickOnMenuButton();
+ SettingsView settingsView = mainView.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();
+
+ 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);
+ assertTrue(waitForTextPresent("ownCloud", mainView.getTitleTextElement()));
+ mainView.clickOnMenuButton();
+ SettingsView settingView = mainView.clickOnSettingsButton();
+ settingView.tapOnAccountElement(1, 1000);
+ LoginForm changePasswordForm = settingView.clickOnChangePasswordElement();
+ changePasswordForm.typePassword("WrongPassword");
+ changePasswordForm.clickOnConnectButton();
+ assertTrue(waitForTextPresent("Wrong username or password", changePasswordForm.getAuthStatusText()));
+ driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_BACK);
+ Actions.deleteAccount(settingView);
+ }
+
+
+ @After
+ public void tearDown() throws Exception {
+ driver.removeApp("com.owncloud.android");
+ driver.quit();
+ }
+
+
+}
--- /dev/null
+package androidtest.tests;
+
+
+import io.appium.java_client.MobileBy;
+
+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.AppDetailsView;
+import androidtest.models.FilesView;
+import androidtest.models.MainView;
+
+
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class UploadTestSuite extends CommonTest{
+
+ @Before
+ public void setUp() throws Exception {
+ setUpCommonDriver();
+ }
+
+ @Test
+ public void test1UploadFile () throws Exception {
+ String FILE_NAME = "test";
+
+ MainView mainView = login(Config.URL, Config.user,Config.password);
+ 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);
+ 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);
+
+ }
+
+ @Test
+ public void test2KeepFileUpToDate () throws Exception {
+ String FILE_NAME = "test";
+
+ MainView mainView = login(Config.URL, Config.user,Config.password);
+ 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);
+ mainViewAfterUploadFile.scrollTillFindElement(FILE_NAME);
+ assertTrue(mainViewAfterUploadFile.getFileElement().isDisplayed());
+ mainViewAfterUploadFile.tapOnFileElement(FILE_NAME);
+ AppDetailsView appDetailsView = mainViewAfterUploadFile.clickOnDetailsFileElement();
+ 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);
+
+ }
+
+
+ @After
+ public void tearDown() throws Exception {
+ driver.removeApp("com.owncloud.android");
+ driver.quit();
+ }
+
+
+}
+