From: purigarcia Date: Mon, 11 May 2015 09:45:49 +0000 (+0200) Subject: rename the package, changes some files names, more config variables X-Git-Tag: oc-android-1.7.2~1^2~32^2~21 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/2f1e6343428d0c2fceaf221326bd632ea510f1e6?ds=inline;hp=--cc rename the package, changes some files names, more config variables --- 2f1e6343428d0c2fceaf221326bd632ea510f1e6 diff --git a/automationTest/.classpath b/automationTest/.classpath index 069344d3..c52bcedc 100644 --- a/automationTest/.classpath +++ b/automationTest/.classpath @@ -23,5 +23,10 @@ + + + + + diff --git a/automationTest/src/test/java/androidtest/actions/Actions.java b/automationTest/src/test/java/androidtest/actions/Actions.java deleted file mode 100644 index b5bebb19..00000000 --- a/automationTest/src/test/java/androidtest/actions/Actions.java +++ /dev/null @@ -1,123 +0,0 @@ -package androidtest.actions; - -import java.util.HashMap; - -import org.openqa.selenium.NoSuchElementException; -import org.openqa.selenium.ScreenOrientation; -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){ - WebDriverWait wait = new WebDriverWait(driver, 30); - //sometimes the certificate has been already accept and it doesn't appear again - try { - wait.until(ExpectedConditions.visibilityOf(certificatePopUp.getOkButtonElement())); - //we need to repaint the screen because of some element are misplaced - driver.rotate(ScreenOrientation.LANDSCAPE); - driver.rotate(ScreenOrientation.PORTRAIT); - certificatePopUp.clickOnOkButton(); - }catch (NoSuchElementException e) { - - } - - } - 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 scrollObject = new HashMap(); - 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) { - 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{ - //To open directly the "file list view" and we don't need to know in which view we are - driver.startActivity("com.owncloud.android", ".ui.activity.FileDisplayActivity"); - 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/AppDetailsView.java b/automationTest/src/test/java/androidtest/models/AppDetailsView.java deleted file mode 100644 index 75ce4d9f..00000000 --- a/automationTest/src/test/java/androidtest/models/AppDetailsView.java +++ /dev/null @@ -1,41 +0,0 @@ -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; - } -} diff --git a/automationTest/src/test/java/androidtest/models/CertificatePopUp.java b/automationTest/src/test/java/androidtest/models/CertificatePopUp.java deleted file mode 100644 index dbcffcc5..00000000 --- a/automationTest/src/test/java/androidtest/models/CertificatePopUp.java +++ /dev/null @@ -1,29 +0,0 @@ -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 deleted file mode 100644 index a809d47e..00000000 --- a/automationTest/src/test/java/androidtest/models/ElementMenuOptions.java +++ /dev/null @@ -1,64 +0,0 @@ -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 = "Share link") - private AndroidElement shareLinkElement; - - @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; - } - - public ShareView clickOnShareLinkElement () { - shareLinkElement.click(); - ShareView shareView = new ShareView(driver); - return shareView; - } -} diff --git a/automationTest/src/test/java/androidtest/models/FilesView.java b/automationTest/src/test/java/androidtest/models/FilesView.java deleted file mode 100644 index c913b104..00000000 --- a/automationTest/src/test/java/androidtest/models/FilesView.java +++ /dev/null @@ -1,44 +0,0 @@ -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 FilesView{ - final AndroidDriver driver; - - @CacheLookup - @AndroidFindBy(id = "com.owncloud.android:id/list_root") - private AndroidElement filesLayout; - - @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; - } - - //change to scrollTillFindElement - public void scrollTillFindFile (String fileName) { - fileElement = Actions.scrollTillFindElement (fileName,filesLayout,driver); - } - - public void clickOnFileName (String fileName) { - scrollTillFindFile(fileName); - fileElement.click(); - } -} diff --git a/automationTest/src/test/java/androidtest/models/LoginForm.java b/automationTest/src/test/java/androidtest/models/LoginForm.java deleted file mode 100644 index 11755d6f..00000000 --- a/automationTest/src/test/java/androidtest/models/LoginForm.java +++ /dev/null @@ -1,91 +0,0 @@ -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 CertificatePopUp typeHostUrl (String hostUrl) { - hostUrlInput.clear(); - hostUrlInput.sendKeys(hostUrl + "\n"); - CertificatePopUp certificatePopUp = new CertificatePopUp(driver); - return certificatePopUp; - } - - public void clickOnUserName () { - userNameInput.click(); - } - - public void typeUserName (String userName) { - userNameInput.clear(); - //using the \n , it not need to hide the keyboard which sometimes gives problems - userNameInput.sendKeys(userName + "\n"); - //driver.hideKeyboard(); - } - - public void typePassword (String password) { - passwordInput.clear(); - passwordInput.sendKeys(password + "\n"); - //driver.hideKeyboard(); - } - - public MainView clickOnConnectButton () { - connectButton.click(); - MainView mainView = new MainView(driver); - return mainView; - } - - public AndroidElement gethostUrlInput () { - return hostUrlInput; - } - - public AndroidElement getUserNameInput () { - return userNameInput; - } - - public AndroidElement getPasswordInput () { - return passwordInput; - } - - - public AndroidElement getServerStatusTextElement () { - return serverStatusText; - } - - public AndroidElement getAuthStatusText () { - return authStatusText; - } -} diff --git a/automationTest/src/test/java/androidtest/models/MainView.java b/automationTest/src/test/java/androidtest/models/MainView.java deleted file mode 100644 index 0c28bf09..00000000 --- a/automationTest/src/test/java/androidtest/models/MainView.java +++ /dev/null @@ -1,166 +0,0 @@ -package androidtest.models; - -import java.util.List; - -import io.appium.java_client.android.AndroidDriver; -import io.appium.java_client.android.AndroidElement; -import io.appium.java_client.android.AndroidKeyCode; -import io.appium.java_client.pagefactory.AndroidFindBy; -import io.appium.java_client.pagefactory.AppiumFieldDecorator; - -import org.openqa.selenium.NoSuchElementException; -import org.openqa.selenium.support.CacheLookup; -import org.openqa.selenium.support.PageFactory; - -import org.openqa.selenium.Point; -import androidtest.actions.Actions; - -public class MainView { - final AndroidDriver driver; - - @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(id = "android:id/progress_circular") - private AndroidElement progressCircular; - - @CacheLookup - @AndroidFindBy(uiAutomator = "new UiSelector().description(\"New folder\")") - private AndroidElement newFolderButton; - - @CacheLookup - @AndroidFindBy(uiAutomator = "new UiSelector().description(\"Upload\")") - private AndroidElement uploadButton; - - private AndroidElement waitAMomentText; - - @AndroidFindBy(id = "com.owncloud.android:id/ListItemLayout") - private List listItemLayout; - - @AndroidFindBy(id = "com.owncloud.android:id/list_root") - private AndroidElement listRootLayout; - - @AndroidFindBy(name = "Files") - private AndroidElement filesElementUploadFile; - - @CacheLookup - @AndroidFindBy(uiAutomator = "new UiSelector().description(\"List Layout\")") - private AndroidElement listLayout; - - private AndroidElement fileElement; - - 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 MenuList clickOnMenuButton () { - //if the menu option is not in the actionBar, it is opening again - try { - menuButton.click(); - } catch (NoSuchElementException e){ - driver.sendKeyEvent(AndroidKeyCode.MENU); - } - MenuList menuList = new MenuList (driver); - return menuList; - } - - public SettingsView getSettingsView () { - SettingsView settingsView = new SettingsView(driver); - return settingsView; - } - - public NewFolderPopUp clickOnNewFolderButton () { - newFolderButton.click(); - NewFolderPopUp newFolderPopUp = new NewFolderPopUp(driver); - return newFolderPopUp; - } - - public void clickOnUploadButton () { - uploadButton.click(); - } - - public FilesView clickOnFilesElementUploadFile () { - filesElementUploadFile.click(); - FilesView filesView = new FilesView(driver); - return filesView; - } - - public AndroidElement getTitleTextElement () { - return titleText; - } - - public AndroidElement getUploadButton () { - return uploadButton; - } - - public AndroidElement getWaitAMomentTextElement () { - return waitAMomentText; - } - - public AndroidElement getListRootElement () { - return listRootLayout; - } - - public List getListItemLayout () { - return listItemLayout; - } - - public AndroidElement getFileElement () { - return fileElement; - } - - 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 elementName) { - fileElement = Actions.scrollTillFindElement (elementName,filesLayout,driver); - try { - fileElementLayout = (AndroidElement) driver.findElementByAndroidUIAutomator("new UiSelector().description(\"LinearLayout-"+ elementName +"\")"); - } catch (NoSuchElementException e) { - fileElementLayout = null; - } - return fileElement; - } - - public AndroidElement getFileElementLayout () { - return fileElementLayout; - } - - public AndroidElement getProgressCircular () { - return progressCircular; - } - - public static String getLocalFileIndicator() { - return localFileIndicator; - } - - public static String getFavoriteFileIndicator() { - return favoriteFileIndicator; - } - - public void pulldownToRefresh () throws InterruptedException { - Point listLocation = listLayout.getLocation(); - driver.swipe(listLocation.getX(),listLocation.getY(), listLocation.getX(),listLocation.getY()+1000, 5000); - } - - -} diff --git a/automationTest/src/test/java/androidtest/models/MenuList.java b/automationTest/src/test/java/androidtest/models/MenuList.java deleted file mode 100644 index 466fa1c7..00000000 --- a/automationTest/src/test/java/androidtest/models/MenuList.java +++ /dev/null @@ -1,27 +0,0 @@ -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 deleted file mode 100644 index f54ba284..00000000 --- a/automationTest/src/test/java/androidtest/models/MoveView.java +++ /dev/null @@ -1,37 +0,0 @@ -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 deleted file mode 100644 index 31a2124a..00000000 --- a/automationTest/src/test/java/androidtest/models/NewFolderPopUp.java +++ /dev/null @@ -1,36 +0,0 @@ -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 + "\n"); - //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 deleted file mode 100644 index e9a1ba9d..00000000 --- a/automationTest/src/test/java/androidtest/models/RemoveConfirmationView.java +++ /dev/null @@ -1,26 +0,0 @@ -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/SettingsView.java b/automationTest/src/test/java/androidtest/models/SettingsView.java deleted file mode 100644 index 4e3aa48e..00000000 --- a/automationTest/src/test/java/androidtest/models/SettingsView.java +++ /dev/null @@ -1,78 +0,0 @@ -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; - - @AndroidFindBy(uiAutomator = "new UiSelector().className(\"android.widget.CheckBox\").index(0)") - private AndroidElement passcodeCheckbox; - - 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; - } - - public PassCodeView EnablePassCode(){ - if(!passcodeCheckbox.isSelected()){ - passcodeCheckbox.click(); - } - PassCodeView passcodeview = new PassCodeView(driver); - return passcodeview; - } - - public PassCodeView DisablePassCode(){ - if(passcodeCheckbox.isSelected()){ - passcodeCheckbox.click(); - } - PassCodeView passcodeview = new PassCodeView(driver); - return passcodeview; - } - -} diff --git a/automationTest/src/test/java/androidtest/models/WaitAMomentPopUp.java b/automationTest/src/test/java/androidtest/models/WaitAMomentPopUp.java deleted file mode 100644 index f566e4a2..00000000 --- a/automationTest/src/test/java/androidtest/models/WaitAMomentPopUp.java +++ /dev/null @@ -1,24 +0,0 @@ -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 deleted file mode 100644 index fa0f66df..00000000 --- a/automationTest/src/test/java/androidtest/tests/.gitignore +++ /dev/null @@ -1 +0,0 @@ -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 deleted file mode 100644 index aeab97d6..00000000 --- a/automationTest/src/test/java/androidtest/tests/Common.java +++ /dev/null @@ -1,128 +0,0 @@ -package androidtest.tests; - -import static org.junit.Assert.*; -import java.io.File; -import java.io.IOException; -import java.net.URL; -import java.text.SimpleDateFormat; -import java.util.Calendar; -import java.util.Date; -import java.util.concurrent.TimeUnit; -import org.apache.commons.io.FileUtils; -import org.openqa.selenium.By; -import org.openqa.selenium.NoSuchElementException; -import org.openqa.selenium.OutputType; -import org.openqa.selenium.TimeoutException; -import org.openqa.selenium.remote.DesiredCapabilities; -import org.openqa.selenium.remote.RemoteWebDriver; -import org.openqa.selenium.support.ui.WebDriverWait; -import io.appium.java_client.android.AndroidDriver; -import io.appium.java_client.android.AndroidElement; - -public class Common{ - AndroidDriver driver; - static int waitingTime = 30; - - WebDriverWait wait; - - protected AndroidDriver 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", "test"); - capabilities.setCapability("app", app.getAbsolutePath()); - capabilities.setCapability("appPackage", "com.owncloud.android"); - capabilities.setCapability("appActivity", ".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); - return driver; - - } - - 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(); - } - - protected void takeScreenShotOnFailed (String testName) throws IOException { - File file = ((RemoteWebDriver) driver).getScreenshotAs(OutputType.FILE); - SimpleDateFormat dt1 = new SimpleDateFormat("yyyy-MM-dd"); - Date today = Calendar.getInstance().getTime(); - String screenShotName = "ScreenShots/" + dt1.format(today) + "/" + testName + ".png"; - FileUtils.copyFile(file, new File(screenShotName)); - } - - protected void assertIsInMainView() throws InterruptedException { - assertTrue(waitForTextPresent("ownCloud", (AndroidElement) driver.findElementByAndroidUIAutomator("new UiSelector().resourceId(\"android:id/action_bar_title\")"))); - assertTrue(isElementPresent((AndroidElement) driver.findElementByAndroidUIAutomator("new UiSelector().description(\"Upload\")"))); - } - - protected void assertIsNotInMainView() throws InterruptedException { - AndroidElement fileElement; - assertTrue(waitForTextPresent("ownCloud", (AndroidElement) driver.findElementByAndroidUIAutomator("new UiSelector().resourceId(\"android:id/action_bar_title\")"))); - try { - fileElement = (AndroidElement) driver.findElementByAndroidUIAutomator("new UiSelector().description(\"Upload\")"); - } catch (NoSuchElementException e) { - fileElement = null; - } - assertNull(fileElement); - } - - protected void assertIsPasscodeRequestView() throws InterruptedException { - assertTrue(waitForTextPresent("ownCloud", (AndroidElement) driver.findElementByAndroidUIAutomator("new UiSelector().resourceId(\"android:id/action_bar_title\")"))); - assertTrue(((AndroidElement) driver.findElementByAndroidUIAutomator("new UiSelector().text(\"Please, insert your pass code\")")).isDisplayed()); - - } - - protected void assertIsInSettingsView() throws InterruptedException { - assertTrue(waitForTextPresent("Settings", (AndroidElement) driver.findElementByAndroidUIAutomator("new UiSelector().resourceId(\"android:id/action_bar_title\")"))); - } - -} diff --git a/automationTest/src/test/java/androidtest/tests/Config.java b/automationTest/src/test/java/androidtest/tests/Config.java deleted file mode 100644 index 928e27c2..00000000 --- a/automationTest/src/test/java/androidtest/tests/Config.java +++ /dev/null @@ -1,20 +0,0 @@ -package androidtest.tests; - -public final class Config { - - //without http or https - public static final String URL = "owncloudServerVar"; - public static boolean isTrusted = true; - - //without http or https - public static final String URL2 = "owncloudServer2Var"; - 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 + "@"+ URL; - public static final String userAccount2 = user2 + "@"+ URL2; - -} diff --git a/automationTest/src/test/java/androidtest/tests/CreateFolderTestSuite.java b/automationTest/src/test/java/androidtest/tests/CreateFolderTestSuite.java deleted file mode 100644 index feaeb0ab..00000000 --- a/automationTest/src/test/java/androidtest/tests/CreateFolderTestSuite.java +++ /dev/null @@ -1,70 +0,0 @@ -package androidtest.tests; - -import static org.junit.Assert.*; -import io.appium.java_client.android.AndroidDriver; - -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.experimental.categories.Category; -import org.junit.rules.TestName; -import org.junit.runners.MethodSorters; -import org.junit.FixMethodOrder; -import org.junit.Test; - -import androidtest.actions.Actions; -import androidtest.groups.NoIgnoreTestCategory; -import androidtest.groups.SmokeTestCategory; -import androidtest.models.MainView; -import androidtest.models.WaitAMomentPopUp; - - -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class CreateFolderTestSuite{ - - AndroidDriver driver; - Common common; - private Boolean folderHasBeenCreated = false; - private final String FOLDER_NAME = "testCreateFolder"; - private String CurrentCreatedFolder = ""; - - @Rule public TestName name = new TestName(); - - @Before - public void setUp() throws Exception { - common=new Common(); - driver=common.setUpCommonDriver(); - } - - @Test - @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class}) - public void testCreateNewFolder () throws Exception { - String NEW_FOLDER_NAME = "testCreateFolder"; - - MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); - common.assertIsInMainView(); - - //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); - Common.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 { - common.takeScreenShotOnFailed(name.getMethodName()); - if (folderHasBeenCreated) { - MainView mainView = new MainView(driver); - Actions.deleteElement(CurrentCreatedFolder, mainView, driver); - } - 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 deleted file mode 100644 index d30b4c6c..00000000 --- a/automationTest/src/test/java/androidtest/tests/DeleteFileTestSuite.java +++ /dev/null @@ -1,62 +0,0 @@ -package androidtest.tests; - -import static org.junit.Assert.*; -import io.appium.java_client.android.AndroidDriver; - -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.experimental.categories.Category; -import org.junit.rules.TestName; -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.groups.NoIgnoreTestCategory; -import androidtest.groups.SmokeTestCategory; -import androidtest.models.MainView; - - -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class DeleteFileTestSuite{ - - AndroidDriver driver; - Common common; - private final String FILE_NAME = "test"; - - @Rule public TestName name = new TestName(); - - @Before - public void setUp() throws Exception { - common=new Common(); - driver=common.setUpCommonDriver(); - } - - @Test - @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class}) - public void testDeleteFile () throws Exception { - MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); - common.assertIsInMainView(); - - //TODO. if the file already exists, do not upload - MainView mainViewAfterUploadFile = Actions.uploadFile(FILE_NAME, mainView); - - mainViewAfterUploadFile.scrollTillFindElement(FILE_NAME); - Common.waitTillElementIsNotPresent(mainViewAfterUploadFile.getProgressCircular(), 1000); - common.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 { - common.takeScreenShotOnFailed(name.getMethodName()); - 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 deleted file mode 100644 index fe7aabda..00000000 --- a/automationTest/src/test/java/androidtest/tests/DeleteFolderTestSuite.java +++ /dev/null @@ -1,67 +0,0 @@ -package androidtest.tests; - -import static org.junit.Assert.*; -import io.appium.java_client.android.AndroidDriver; - -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.experimental.categories.Category; -import org.junit.rules.TestName; -import org.junit.runners.MethodSorters; -import org.junit.FixMethodOrder; -import org.junit.Test; - -import androidtest.actions.Actions; -import androidtest.groups.NoIgnoreTestCategory; -import androidtest.groups.SmokeTestCategory; -import androidtest.models.MainView; -import androidtest.models.WaitAMomentPopUp; - - -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class DeleteFolderTestSuite{ - AndroidDriver driver; - Common common; - private Boolean folderHasBeenCreated = false; - private final String FOLDER_NAME = "testCreateFolder"; - - @Rule public TestName name = new TestName(); - - - @Before - public void setUp() throws Exception { - common=new Common(); - driver=common.setUpCommonDriver(); - } - - @Test - @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class}) - public void testDeleteFolder () throws Exception { - MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); - common.assertIsInMainView(); - - //TODO. if the folder already exists, do no created - //create the folder - WaitAMomentPopUp waitAMomentPopUp = Actions.createFolder(FOLDER_NAME, mainView); - Common.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 { - common.takeScreenShotOnFailed(name.getMethodName()); - if(folderHasBeenCreated){ - MainView mainView = new MainView(driver); - Actions.deleteElement(FOLDER_NAME, mainView, driver); - } - driver.removeApp("com.owncloud.android"); - driver.quit(); - } - -} diff --git a/automationTest/src/test/java/androidtest/tests/LoginTestSuite.java b/automationTest/src/test/java/androidtest/tests/LoginTestSuite.java deleted file mode 100644 index 6aa6c2bb..00000000 --- a/automationTest/src/test/java/androidtest/tests/LoginTestSuite.java +++ /dev/null @@ -1,109 +0,0 @@ -package androidtest.tests; - -import static org.junit.Assert.*; -import io.appium.java_client.android.AndroidDriver; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.experimental.categories.Category; -import org.junit.rules.TestName; -import org.junit.runners.MethodSorters; -import org.junit.FixMethodOrder; -import org.junit.Test; -import org.openqa.selenium.ScreenOrientation; -import androidtest.actions.Actions; -import androidtest.groups.*; -import androidtest.models.LoginForm; -import androidtest.models.MainView; -import androidtest.models.MenuList; -import androidtest.models.SettingsView; - -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class LoginTestSuite{ - AndroidDriver driver; - Common common; - - @Rule public TestName name = new TestName(); - - @Before - public void setUp() throws Exception { - common=new Common(); - driver=common.setUpCommonDriver(); - } - - @Test - @Category({NoIgnoreTestCategory.class}) - public void test1LoginPortrait () throws Exception { - driver.rotate(ScreenOrientation.PORTRAIT); - - MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); - common.assertIsInMainView(); - } - - @Test - @Category({NoIgnoreTestCategory.class}) - public void test2LoginLandscape () throws Exception { - driver.rotate(ScreenOrientation.LANDSCAPE); - MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); - common.assertIsInMainView(); - } - - - @Test - @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class}) - public void test3MultiAccountRotate () throws Exception { - driver.rotate(ScreenOrientation.LANDSCAPE); - MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); - common.assertIsInMainView(); - - driver.rotate(ScreenOrientation.PORTRAIT); - MenuList menu = mainView.clickOnMenuButton(); - SettingsView settingsView = menu.clickOnSettingsButton(); - - settingsView.tapOnAddAccount(1, 1000); - mainView = Actions.login(Config.URL2, Config.user2,Config.password2, Config.isTrusted2, driver); - common.assertIsInSettingsView(); - } - - @Test - @Category({NoIgnoreTestCategory.class}) - public void test4ExistingAccountRotate () throws Exception { - driver.rotate(ScreenOrientation.PORTRAIT); - MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); - common.assertIsInMainView(); - - driver.rotate(ScreenOrientation.LANDSCAPE); - MenuList menu = mainView.clickOnMenuButton(); - SettingsView settingsView = menu.clickOnSettingsButton(); - settingsView.tapOnAddAccount(1, 1000); - - LoginForm loginForm = new LoginForm(driver); - mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); - assertTrue(common.waitForTextPresent("An account for the same user and server already exists in the device", loginForm.getAuthStatusText())); - } - - @Test - @Category({NoIgnoreTestCategory.class}) - public void test5ChangePasswordWrong () throws Exception { - driver.rotate(ScreenOrientation.PORTRAIT); - MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); - common.assertIsInMainView(); - MenuList menu = mainView.clickOnMenuButton(); - SettingsView settingsView = menu.clickOnSettingsButton(); - settingsView.tapOnAccountElement(1, 1000); - LoginForm changePasswordForm = settingsView.clickOnChangePasswordElement(); - changePasswordForm.typePassword("WrongPassword"); - changePasswordForm.clickOnConnectButton(); - assertTrue(common.waitForTextPresent("Wrong username or password", changePasswordForm.getAuthStatusText())); - } - - - @After - public void tearDown() throws Exception { - common.takeScreenShotOnFailed(name.getMethodName()); - driver.removeApp("com.owncloud.android"); - driver.quit(); - } - - -} diff --git a/automationTest/src/test/java/androidtest/tests/LogoutTestSuite.java b/automationTest/src/test/java/androidtest/tests/LogoutTestSuite.java deleted file mode 100644 index 876c0ce4..00000000 --- a/automationTest/src/test/java/androidtest/tests/LogoutTestSuite.java +++ /dev/null @@ -1,55 +0,0 @@ -package androidtest.tests; - - -import static org.junit.Assert.*; -import io.appium.java_client.android.AndroidDriver; - -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.junit.rules.TestName; - -import androidtest.actions.Actions; -import androidtest.groups.NoIgnoreTestCategory; -import androidtest.groups.SmokeTestCategory; -import androidtest.models.LoginForm; -import androidtest.models.MainView; -import androidtest.models.MenuList; -import androidtest.models.SettingsView; - -public class LogoutTestSuite{ - - AndroidDriver driver; - Common common; - - @Rule public TestName name = new TestName(); - - @Before - public void setUp() throws Exception { - common=new Common(); - driver=common.setUpCommonDriver(); - } - - @Test - @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class}) - public void testLogout () throws Exception { - MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); - common.assertIsInMainView(); - 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 { - common.takeScreenShotOnFailed(name.getMethodName()); - //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 deleted file mode 100644 index 3d57ee07..00000000 --- a/automationTest/src/test/java/androidtest/tests/MoveFileTestSuite.java +++ /dev/null @@ -1,92 +0,0 @@ -package androidtest.tests; - -import static org.junit.Assert.*; -import io.appium.java_client.android.AndroidDriver; - -import org.junit.After; -import org.junit.Before; -import org.junit.FixMethodOrder; -import org.junit.Rule; -import org.junit.Test; -import org.junit.experimental.categories.Category; -import org.junit.rules.TestName; -import org.junit.runners.MethodSorters; - -import androidtest.actions.Actions; -import androidtest.groups.NoIgnoreTestCategory; -import androidtest.groups.SmokeTestCategory; -import androidtest.models.ElementMenuOptions; -import androidtest.models.MainView; -import androidtest.models.MoveView; -import androidtest.models.WaitAMomentPopUp; - - - -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class MoveFileTestSuite{ - AndroidDriver driver; - Common common; - private String FOLDER_WHERE_MOVE = "folderWhereMove"; - private String FILE_NAME = "test"; - @Rule public TestName name = new TestName(); - - @Before - public void setUp() throws Exception { - common=new Common(); - driver=common.setUpCommonDriver(); - } - - @Test - @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class}) - public void testMoveFile () throws Exception { - WaitAMomentPopUp waitAMomentPopUp; - - MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); - common.assertIsInMainView(); - - Common.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); - Common.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(); - Common.waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100); - - //check that the folder moved is inside the other - mainView.scrollTillFindElement(FOLDER_WHERE_MOVE).tap(1,1); - Common.waitTillElementIsNotPresent(mainView.getProgressCircular(), 1000); - Thread.sleep(1000); - mainView.scrollTillFindElement(FILE_NAME); - assertEquals(FILE_NAME , mainView.getFileElement().getText()); - - } - - @After - public void tearDown() throws Exception { - common.takeScreenShotOnFailed(name.getMethodName()); - MainView mainView = new MainView(driver); - driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_BACK); - Actions.deleteElement(FOLDER_WHERE_MOVE, mainView, driver); - 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 deleted file mode 100644 index 532eff21..00000000 --- a/automationTest/src/test/java/androidtest/tests/MoveFolderTestSuite.java +++ /dev/null @@ -1,94 +0,0 @@ -package androidtest.tests; - -import static org.junit.Assert.*; -import io.appium.java_client.android.AndroidDriver; - -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.experimental.categories.Category; -import org.junit.rules.TestName; -import org.junit.runners.MethodSorters; -import org.junit.FixMethodOrder; -import org.junit.Test; - -import androidtest.actions.Actions; -import androidtest.groups.NoIgnoreTestCategory; -import androidtest.groups.SmokeTestCategory; -import androidtest.models.ElementMenuOptions; -import androidtest.models.MainView; -import androidtest.models.MoveView; -import androidtest.models.WaitAMomentPopUp; - - -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class MoveFolderTestSuite{ - AndroidDriver driver; - Common common; - private String FOLDER_TO_MOVE = "folderToMove"; - private String FOLDER_WHERE_MOVE = "folderWhereMove"; - - @Rule public TestName name = new TestName(); - - @Before - public void setUp() throws Exception { - common=new Common(); - driver=common.setUpCommonDriver(); - } - - @Test - @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class}) - public void testMoveFolder () throws Exception { - WaitAMomentPopUp waitAMomentPopUp; - - MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); - common.assertIsInMainView(); - - Common.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); - Common.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); - Common.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(); - Common.waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100); - - //check that the folder moved is inside the other - mainView.scrollTillFindElement(FOLDER_WHERE_MOVE).tap(1,1); - Common.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 { - common.takeScreenShotOnFailed(name.getMethodName()); - 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 deleted file mode 100644 index 8a07e034..00000000 --- a/automationTest/src/test/java/androidtest/tests/RenameFileTestSuite.java +++ /dev/null @@ -1,84 +0,0 @@ -package androidtest.tests; - -import static org.junit.Assert.*; -import io.appium.java_client.android.AndroidDriver; - -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.experimental.categories.Category; -import org.junit.rules.TestName; -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.groups.NoIgnoreTestCategory; -import androidtest.groups.SmokeTestCategory; -import androidtest.models.ElementMenuOptions; -import androidtest.models.MainView; -import androidtest.models.NewFolderPopUp; -import androidtest.models.WaitAMomentPopUp; - - -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class RenameFileTestSuite{ - - AndroidDriver driver; - Common common; - private Boolean fileHasBeenCreated = false; - private final String OLD_FILE_NAME = "test"; - private final String FILE_NAME = "newNameFile"; - private String CurrentCreatedFile = ""; - - @Rule public TestName name = new TestName(); - - @Before - public void setUp() throws Exception { - common=new Common(); - driver=common.setUpCommonDriver(); - } - - @Test - @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class}) - public void testRenameFile () throws Exception { - MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); - common.assertIsInMainView(); - - //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; - Common.waitTillElementIsNotPresent(mainViewAfterUploadFile.getProgressCircular(), 1000); - common.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(); - Common.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 { - common.takeScreenShotOnFailed(name.getMethodName()); - 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 deleted file mode 100644 index c97c3e0b..00000000 --- a/automationTest/src/test/java/androidtest/tests/RenameFolderTestSuite.java +++ /dev/null @@ -1,84 +0,0 @@ -package androidtest.tests; - -import static org.junit.Assert.*; -import io.appium.java_client.android.AndroidDriver; - -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.experimental.categories.Category; -import org.junit.rules.TestName; -import org.junit.runners.MethodSorters; -import org.junit.FixMethodOrder; -import org.junit.Test; - -import androidtest.actions.Actions; -import androidtest.groups.NoIgnoreTestCategory; -import androidtest.groups.SmokeTestCategory; -import androidtest.models.ElementMenuOptions; -import androidtest.models.MainView; -import androidtest.models.NewFolderPopUp; -import androidtest.models.WaitAMomentPopUp; - - -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class RenameFolderTestSuite{ - - AndroidDriver driver; - Common common; - private Boolean folderHasBeenCreated = false; - private final String OLD_FOLDER_NAME = "beforeRemoving"; - private final String FOLDER_NAME = "testCreateFolder"; - private String CurrentCreatedFolder = ""; - - @Rule public TestName name = new TestName(); - - - @Before - public void setUp() throws Exception { - common=new Common(); - driver=common.setUpCommonDriver(); - } - - @Test - @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class}) - public void testRenameFolder () throws Exception { - MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); - common.assertIsInMainView(); - - //TODO. if the folder already exists, do no created - //create the folder to rename - WaitAMomentPopUp waitAMomentPopUp = Actions.createFolder(OLD_FOLDER_NAME, mainView); - Common.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; - Common.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 { - common.takeScreenShotOnFailed(name.getMethodName()); - if(folderHasBeenCreated){ - MainView mainView = new MainView(driver); - Actions.deleteElement(CurrentCreatedFolder, mainView, driver); - } - driver.removeApp("com.owncloud.android"); - driver.quit(); - } - -} diff --git a/automationTest/src/test/java/androidtest/tests/UploadTestSuite.java b/automationTest/src/test/java/androidtest/tests/UploadTestSuite.java deleted file mode 100644 index 358024d7..00000000 --- a/automationTest/src/test/java/androidtest/tests/UploadTestSuite.java +++ /dev/null @@ -1,123 +0,0 @@ -package androidtest.tests; - - -import static org.junit.Assert.*; -import io.appium.java_client.MobileBy; -import io.appium.java_client.android.AndroidDriver; - -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.experimental.categories.Category; -import org.junit.rules.TestName; -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.groups.FailingTestCategory; -import androidtest.groups.IgnoreTestCategory; -import androidtest.groups.NoIgnoreTestCategory; -import androidtest.models.AppDetailsView; -import androidtest.models.ElementMenuOptions; -import androidtest.models.GmailEmailListView; -import androidtest.models.GmailEmailView; -import androidtest.models.ImageView; -import androidtest.models.MainView; -import androidtest.models.UploadView; - - -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -@Category({NoIgnoreTestCategory.class}) -public class UploadTestSuite{ - - AndroidDriver driver; - Common common; - String FILE_NAME = "test"; - - @Rule public TestName name = new TestName(); - - - @Before - public void setUp() throws Exception { - common=new Common(); - driver=common.setUpCommonDriver(); - } - - @Test - @Category(NoIgnoreTestCategory.class) - public void testUploadFile () throws Exception { - - MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); - common.assertIsInMainView(); - - //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()); - Common.waitTillElementIsNotPresent(mainViewAfterUploadFile.getProgressCircular(), 1000); - common.wait.until(ExpectedConditions.visibilityOf(mainViewAfterUploadFile.getFileElementLayout().findElement(By.id(MainView.getLocalFileIndicator())))); - - - } - - @Test - @Category(IgnoreTestCategory.class) - public void testUploadFromGmail () throws Exception { - MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); - driver.startActivity("com.google.android.gm", ".ConversationListActivityGmail"); - GmailEmailListView gmailEmailListView = new GmailEmailListView(driver); - GmailEmailView gmailEmailView = gmailEmailListView.clickOnEmail(); - ImageView imageView = gmailEmailView.clickOnfileButton(); - imageView.clickOnOptionsButton(); - imageView.clickOnShareButton(); - imageView.clickOnOwnCloudButton(); - imageView.clickOnJustOnceButton(); - UploadView uploadView = new UploadView(driver); - uploadView.clickOUploadButton(); - driver.startActivity("com.owncloud.android", ".ui.activity.FileDisplayActivity"); - common.wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.name("test.jpg"))); - assertEquals("test.jpg" , driver.findElementByName("test.jpg").getText()); - } - - - @Test - @Category({IgnoreTestCategory.class, FailingTestCategory.class}) - public void testKeepFileUpToDate () throws Exception { - - MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); - common.assertIsInMainView(); - - Common.waitTillElementIsNotPresent(mainView.getProgressCircular(), 1000); - - MainView mainViewAfterUploadFile = Actions.uploadFile(FILE_NAME, mainView); - mainViewAfterUploadFile.scrollTillFindElement(FILE_NAME); - assertTrue(mainViewAfterUploadFile.getFileElement().isDisplayed()); - - ElementMenuOptions menuOptions = mainViewAfterUploadFile.longPressOnElement(FILE_NAME); - AppDetailsView appDetailsView = menuOptions.clickOnDetails(); - appDetailsView.checkKeepFileUpToDateCheckbox(); - Thread.sleep(3000); - driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_BACK); - assertTrue(common.isElementPresent(mainViewAfterUploadFile.getFileElementLayout(), MobileBy.id(MainView.getFavoriteFileIndicator()))); - - } - - - @After - public void tearDown() throws Exception { - common.takeScreenShotOnFailed(name.getMethodName()); - MainView mainView = new MainView(driver); - Actions.deleteElement(FILE_NAME,mainView, driver); - driver.removeApp("com.owncloud.android"); - driver.quit(); - } - - -} - diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/actions/Actions.java b/automationTest/src/test/java/com/owncloud/android/test/ui/actions/Actions.java new file mode 100644 index 00000000..ae41573c --- /dev/null +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/actions/Actions.java @@ -0,0 +1,123 @@ +package com.owncloud.android.test.ui.actions; + +import java.util.HashMap; + +import org.openqa.selenium.NoSuchElementException; +import org.openqa.selenium.ScreenOrientation; +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 com.owncloud.android.test.ui.models.CertificatePopUp; +import com.owncloud.android.test.ui.models.ElementMenuOptions; +import com.owncloud.android.test.ui.models.UploadFilesView; +import com.owncloud.android.test.ui.models.LoginForm; +import com.owncloud.android.test.ui.models.FileListView; +import com.owncloud.android.test.ui.models.MenuList; +import com.owncloud.android.test.ui.models.NewFolderPopUp; +import com.owncloud.android.test.ui.models.RemoveConfirmationView; +import com.owncloud.android.test.ui.models.SettingsView; +import com.owncloud.android.test.ui.models.WaitAMomentPopUp; +import com.owncloud.android.test.ui.testSuites.Common; + +public class Actions { + + public static FileListView 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){ + WebDriverWait wait = new WebDriverWait(driver, 30); + //sometimes the certificate has been already accept and it doesn't appear again + try { + wait.until(ExpectedConditions.visibilityOf(certificatePopUp.getOkButtonElement())); + //we need to repaint the screen because of some element are misplaced + driver.rotate(ScreenOrientation.LANDSCAPE); + driver.rotate(ScreenOrientation.PORTRAIT); + certificatePopUp.clickOnOkButton(); + }catch (NoSuchElementException e) { + + } + + } + loginForm.typeUserName(user); + loginForm.typePassword(password); + //TODO. Assert related to check the connection? + return loginForm.clickOnConnectButton(); + } + + public static WaitAMomentPopUp createFolder(String folderName, FileListView fileListView){ + NewFolderPopUp newFolderPopUp = fileListView.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 scrollObject = new HashMap(); + 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 (FileListView fileListView) { + MenuList menulist = fileListView.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, FileListView fileListView, AndroidDriver driver) throws Exception{ + AndroidElement fileElement; + WaitAMomentPopUp waitAMomentPopUp; + try{ + //To open directly the "file list view" and we don't need to know in which view we are + driver.startActivity("com.owncloud.android", ".ui.activity.FileDisplayActivity"); + fileElement = (AndroidElement) driver.findElementByName(elementName); + ElementMenuOptions menuOptions = fileListView.longPressOnElement(elementName); + RemoveConfirmationView removeConfirmationView = menuOptions.clickOnRemove();; + waitAMomentPopUp = removeConfirmationView.clickOnRemoteAndLocalButton(); + Common.waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100); + }catch(NoSuchElementException e){ + fileElement=null; + } + return fileElement; + } + + public static FileListView uploadFile(String elementName, FileListView fileListView) throws InterruptedException{ + fileListView.clickOnUploadButton(); + UploadFilesView uploadFilesView = fileListView.clickOnFilesElementUploadFile(); + uploadFilesView.clickOnFileName(elementName); + FileListView fileListViewAfterUploadFile = uploadFilesView.clickOnUploadButton(); + //TO DO. detect when the file is successfully uploaded + Thread.sleep(15000); + return fileListViewAfterUploadFile; + } + + +} diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/groups/FailingTestCategory.java b/automationTest/src/test/java/com/owncloud/android/test/ui/groups/FailingTestCategory.java new file mode 100644 index 00000000..b8f6eae5 --- /dev/null +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/groups/FailingTestCategory.java @@ -0,0 +1,3 @@ +package com.owncloud.android.test.ui.groups; + +public interface FailingTestCategory extends IgnoreTestCategory {} diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/groups/FlexibleCategories.java b/automationTest/src/test/java/com/owncloud/android/test/ui/groups/FlexibleCategories.java new file mode 100644 index 00000000..94a019af --- /dev/null +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/groups/FlexibleCategories.java @@ -0,0 +1,138 @@ +package com.owncloud.android.test.ui.groups; + +import java.lang.annotation.Annotation; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +import org.junit.Test; +import org.junit.experimental.categories.Categories.CategoryFilter; +import org.junit.experimental.categories.Categories.ExcludeCategory; +import org.junit.experimental.categories.Categories.IncludeCategory; +import org.junit.experimental.categories.Category; +import org.junit.runner.Description; +import org.junit.runner.manipulation.NoTestsRemainException; +import org.junit.runners.Suite; +import org.junit.runners.model.InitializationError; +import org.junit.runners.model.RunnerBuilder; + +/** + * This class is based on org.junit.experimental.categories.Categories from JUnit 4.10. + * + * All anotations and inner classes from the original class Categories are removed, + * since they will be re-used. + * Unfortunately sub-classing Categories did not work. + */ +public class FlexibleCategories extends Suite { + + /** + * Specifies the package which should be scanned for test classes (e.g. @TestScanPackage("my.package")). + * This annotation is required. + */ + @Retention(RetentionPolicy.RUNTIME) + public @interface TestScanPackage { + public String value(); + } + + /** + * Specifies the prefix of matching class names (e.g. @TestClassPrefix("Test")). + * This annotation is optional (default: ""). + */ + @Retention(RetentionPolicy.RUNTIME) + public @interface TestClassPrefix { + public String value(); + } + + /** + * Specifies the suffix of matching class names (e.g. @TestClassSuffix("Test")). + * This annotation is optional (default: "Test"). + */ + @Retention(RetentionPolicy.RUNTIME) + public @interface TestClassSuffix { + public String value(); + } + + /** + * Specifies an annotation for methods which must be present in a matching class (e.g. @TestMethodAnnotationFilter(Test.class)). + * This annotation is optional (default: org.junit.Test.class). + */ + @Retention(RetentionPolicy.RUNTIME) + public @interface TestMethodAnnotation { + public Class value(); + } + + public FlexibleCategories(Class clazz, RunnerBuilder builder) + throws InitializationError { + this(builder, clazz, PatternClasspathClassesFinder.getSuiteClasses( + getTestScanPackage(clazz), getTestClassPrefix(clazz), getTestClassSuffix(clazz), + getTestMethodAnnotation(clazz))); + try { + filter(new CategoryFilter(getIncludedCategory(clazz), + getExcludedCategory(clazz))); + } catch (NoTestsRemainException e) { + // Ignore all classes with no matching tests. + } + assertNoCategorizedDescendentsOfUncategorizeableParents(getDescription()); + } + + public FlexibleCategories(RunnerBuilder builder, Class clazz, + Class[] suiteClasses) throws InitializationError { + super(builder, clazz, suiteClasses); + } + + private static String getTestScanPackage(Class clazz) throws InitializationError { + TestScanPackage annotation = clazz.getAnnotation(TestScanPackage.class); + if (annotation == null) { + throw new InitializationError("No package given to scan for tests!\nUse the annotation @TestScanPackage(\"my.package\") on the test suite " + clazz + "."); + } + return annotation.value(); + } + + private static String getTestClassPrefix(Class clazz) { + TestClassPrefix annotation = clazz.getAnnotation(TestClassPrefix.class); + return annotation == null ? "" : annotation.value(); + } + + private static String getTestClassSuffix(Class clazz) { + TestClassSuffix annotation = clazz.getAnnotation(TestClassSuffix.class); + return annotation == null ? "Test" : annotation.value(); + } + + private static Class getTestMethodAnnotation(Class clazz) { + TestMethodAnnotation annotation = clazz.getAnnotation(TestMethodAnnotation.class); + return annotation == null ? Test.class : annotation.value(); + } + + private Class getIncludedCategory(Class clazz) { + IncludeCategory annotation= clazz.getAnnotation(IncludeCategory.class); + return annotation == null ? null : annotation.value(); + } + + private Class getExcludedCategory(Class clazz) { + ExcludeCategory annotation= clazz.getAnnotation(ExcludeCategory.class); + return annotation == null ? null : annotation.value(); + } + + private void assertNoCategorizedDescendentsOfUncategorizeableParents(Description description) throws InitializationError { + if (!canHaveCategorizedChildren(description)) + assertNoDescendantsHaveCategoryAnnotations(description); + for (Description each : description.getChildren()) + assertNoCategorizedDescendentsOfUncategorizeableParents(each); + } + + private void assertNoDescendantsHaveCategoryAnnotations(Description description) throws InitializationError { + for (Description each : description.getChildren()) { + if (each.getAnnotation(Category.class) != null) + throw new InitializationError("Category annotations on Parameterized classes are not supported on individual methods."); + assertNoDescendantsHaveCategoryAnnotations(each); + } + } + + // If children have names like [0], our current magical category code can't determine their + // parentage. + private static boolean canHaveCategorizedChildren(Description description) { + for (Description each : description.getChildren()) + if (each.getTestClass() == null) + return false; + return true; + } +} \ No newline at end of file diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/groups/IgnoreTestCategory.java b/automationTest/src/test/java/com/owncloud/android/test/ui/groups/IgnoreTestCategory.java new file mode 100644 index 00000000..6d252f3e --- /dev/null +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/groups/IgnoreTestCategory.java @@ -0,0 +1,4 @@ +package com.owncloud.android.test.ui.groups; + +public interface IgnoreTestCategory {} + diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/groups/NoIgnoreTestCategory.java b/automationTest/src/test/java/com/owncloud/android/test/ui/groups/NoIgnoreTestCategory.java new file mode 100644 index 00000000..50d41701 --- /dev/null +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/groups/NoIgnoreTestCategory.java @@ -0,0 +1,5 @@ +package com.owncloud.android.test.ui.groups; + +public interface NoIgnoreTestCategory { + +} diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/groups/OtherTestCategory.java b/automationTest/src/test/java/com/owncloud/android/test/ui/groups/OtherTestCategory.java new file mode 100644 index 00000000..8f0094e3 --- /dev/null +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/groups/OtherTestCategory.java @@ -0,0 +1,3 @@ +package com.owncloud.android.test.ui.groups; + +public interface OtherTestCategory extends IgnoreTestCategory {} diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/groups/PatternClasspathClassesFinder.java b/automationTest/src/test/java/com/owncloud/android/test/ui/groups/PatternClasspathClassesFinder.java new file mode 100644 index 00000000..b5988830 --- /dev/null +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/groups/PatternClasspathClassesFinder.java @@ -0,0 +1,141 @@ +package com.owncloud.android.test.ui.groups; + +import java.io.File; +import java.io.IOException; +import java.lang.annotation.Annotation; +import java.lang.reflect.Method; +import java.net.URL; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.List; + +/** + * + * Modified version of ClasspathClassesFinder from: + * http://linsolas.free.fr/wordpress/index.php/2011/02/how-to-categorize-junit-tests-with-maven/ + * + * The difference is, that it does not search for annotated classes but for classes with a certain + * class name prefix and suffix. + */ +public final class PatternClasspathClassesFinder { + + /** + * Get the list of classes of a given package name, and that are annotated + * by a given annotation. + * + * @param packageName + * The package name of the classes. + * @param classPrefix + * The prefix of the class name. + * @param classSuffix + * The suffix of the class name. + * @param methodAnnotation + * Only return classes containing methods annotated with methodAnnotation. + * @return The List of classes that matches the requirements. + */ + public static Class[] getSuiteClasses(String packageName, + String classPrefix, String classSuffix, + Class methodAnnotation) { + try { + return getClasses(packageName, classPrefix, classSuffix, methodAnnotation); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + /** + * Get the list of classes of a given package name, and that are annotated + * by a given annotation. + * + * @param packageName + * The package name of the classes. + * @param classPrefix + * The prefix of the class name. + * @param classSuffix + * The suffix of the class name. + * @param methodAnnotation + * Only return classes containing methods annotated with methodAnnotation. + * @return The List of classes that matches the requirements. + * @throws ClassNotFoundException + * If something goes wrong... + * @throws IOException + * If something goes wrong... + */ + private static Class[] getClasses(String packageName, + String classPrefix, String classSuffix, + Class methodAnnotation) + throws ClassNotFoundException, IOException { + ClassLoader classLoader = Thread.currentThread() + .getContextClassLoader(); + String path = packageName.replace('.', '/'); + // Get classpath + Enumeration resources = classLoader.getResources(path); + List dirs = new ArrayList(); + while (resources.hasMoreElements()) { + URL resource = resources.nextElement(); + dirs.add(new File(resource.getFile())); + } + // For each classpath, get the classes. + ArrayList> classes = new ArrayList>(); + for (File directory : dirs) { + classes.addAll(findClasses(directory, packageName, classPrefix, classSuffix, methodAnnotation)); + } + return classes.toArray(new Class[classes.size()]); + } + + /** + * Find classes, in a given directory (recursively), for a given package + * name, that are annotated by a given annotation. + * + * @param directory + * The directory where to look for. + * @param packageName + * The package name of the classes. + * @param classPrefix + * The prefix of the class name. + * @param classSuffix + * The suffix of the class name. + * @param methodAnnotation + * Only return classes containing methods annotated with methodAnnotation. + * @return The List of classes that matches the requirements. + * @throws ClassNotFoundException + * If something goes wrong... + */ + private static List> findClasses(File directory, + String packageName, String classPrefix, String classSuffix, + Class methodAnnotation) + throws ClassNotFoundException { + List> classes = new ArrayList>(); + if (!directory.exists()) { + return classes; + } + File[] files = directory.listFiles(); + for (File file : files) { + if (file.isDirectory()) { + classes.addAll(findClasses(file, + packageName + "." + file.getName(), classPrefix, classSuffix, methodAnnotation)); + } else if (file.getName().startsWith(classPrefix) && file.getName().endsWith(classSuffix + ".class")) { + // We remove the .class at the end of the filename to get the + // class name... + Class clazz = Class.forName(packageName + + '.' + + file.getName().substring(0, + file.getName().length() - 6)); + + // Check, if class contains test methods (prevent "No runnable methods" exception): + boolean classHasTest = false; + for (Method method : clazz.getMethods()) { + if (method.getAnnotation(methodAnnotation) != null) { + classHasTest = true; + break; + } + } + if (classHasTest) { + classes.add(clazz); + } + } + } + return classes; + } +} \ No newline at end of file diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/groups/SmokeTestCategory.java b/automationTest/src/test/java/com/owncloud/android/test/ui/groups/SmokeTestCategory.java new file mode 100644 index 00000000..69f3ad10 --- /dev/null +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/groups/SmokeTestCategory.java @@ -0,0 +1,5 @@ +package com.owncloud.android.test.ui.groups; + +public interface SmokeTestCategory { + +} diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/groups/UnfinishedTestCategory.java b/automationTest/src/test/java/com/owncloud/android/test/ui/groups/UnfinishedTestCategory.java new file mode 100644 index 00000000..8d66b2bd --- /dev/null +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/groups/UnfinishedTestCategory.java @@ -0,0 +1,5 @@ +package com.owncloud.android.test.ui.groups; + +public interface UnfinishedTestCategory extends IgnoreTestCategory{ + +} diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/models/CertificatePopUp.java b/automationTest/src/test/java/com/owncloud/android/test/ui/models/CertificatePopUp.java new file mode 100644 index 00000000..41cd4ae4 --- /dev/null +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/models/CertificatePopUp.java @@ -0,0 +1,29 @@ +package com.owncloud.android.test.ui.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/com/owncloud/android/test/ui/models/ElementMenuOptions.java b/automationTest/src/test/java/com/owncloud/android/test/ui/models/ElementMenuOptions.java new file mode 100644 index 00000000..844ad1fe --- /dev/null +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/models/ElementMenuOptions.java @@ -0,0 +1,64 @@ +package com.owncloud.android.test.ui.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 = "Share link") + private AndroidElement shareLinkElement; + + @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 FileDetailsView clickOnDetails () { + detailsFileElement.click(); + FileDetailsView fileDetailsView = new FileDetailsView(driver); + return fileDetailsView; + } + + 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; + } + + public ShareView clickOnShareLinkElement () { + shareLinkElement.click(); + ShareView shareView = new ShareView(driver); + return shareView; + } +} diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/models/FileDetailsView.java b/automationTest/src/test/java/com/owncloud/android/test/ui/models/FileDetailsView.java new file mode 100644 index 00000000..1410d958 --- /dev/null +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/models/FileDetailsView.java @@ -0,0 +1,41 @@ +package com.owncloud.android.test.ui.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 FileDetailsView { + 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 FileDetailsView (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; + } +} diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/models/FileListView.java b/automationTest/src/test/java/com/owncloud/android/test/ui/models/FileListView.java new file mode 100644 index 00000000..f7534747 --- /dev/null +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/models/FileListView.java @@ -0,0 +1,170 @@ +package com.owncloud.android.test.ui.models; + +import java.util.List; + +import io.appium.java_client.android.AndroidDriver; +import io.appium.java_client.android.AndroidElement; +import io.appium.java_client.android.AndroidKeyCode; +import io.appium.java_client.pagefactory.AndroidFindBy; +import io.appium.java_client.pagefactory.AppiumFieldDecorator; + +import org.openqa.selenium.NoSuchElementException; +import org.openqa.selenium.support.CacheLookup; +import org.openqa.selenium.support.PageFactory; +import org.openqa.selenium.Point; + +import com.owncloud.android.test.ui.actions.Actions; + +public class FileListView { + final AndroidDriver driver; + + @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(id = "android:id/progress_circular") + private AndroidElement progressCircular; + + @CacheLookup + @AndroidFindBy(uiAutomator = "new UiSelector().description(\"New folder\")") + private AndroidElement newFolderButton; + + @CacheLookup + @AndroidFindBy(uiAutomator = "new UiSelector().description(\"Upload\")") + private AndroidElement uploadButton; + + private AndroidElement waitAMomentText; + + @AndroidFindBy(id = "com.owncloud.android:id/ListItemLayout") + private List listItemLayout; + + @AndroidFindBy(id = "com.owncloud.android:id/list_root") + private AndroidElement listRootLayout; + + @AndroidFindBy(name = "Files") + private AndroidElement filesElementUploadFile; + + @CacheLookup + @AndroidFindBy(uiAutomator = "new UiSelector().description(\"List Layout\")") + private AndroidElement listLayout; + + private AndroidElement fileElement; + + private AndroidElement fileElementLayout; + + private static String localFileIndicator = "com.owncloud.android:id/localFileIndicator"; + private static String favoriteFileIndicator = "com.owncloud.android:id/favoriteIcon"; + private static String sharedElementIndicator = "com.owncloud.android:id/sharedIcon"; + + + public FileListView (AndroidDriver driver) { + this.driver = driver; + PageFactory.initElements(new AppiumFieldDecorator(driver), this); + } + + public MenuList clickOnMenuButton () { + //if the menu option is not in the actionBar, it is opening again + try { + menuButton.click(); + } catch (NoSuchElementException e){ + driver.sendKeyEvent(AndroidKeyCode.MENU); + } + MenuList menuList = new MenuList (driver); + return menuList; + } + + public SettingsView getSettingsView () { + SettingsView settingsView = new SettingsView(driver); + return settingsView; + } + + public NewFolderPopUp clickOnNewFolderButton () { + newFolderButton.click(); + NewFolderPopUp newFolderPopUp = new NewFolderPopUp(driver); + return newFolderPopUp; + } + + public void clickOnUploadButton () { + uploadButton.click(); + } + + public UploadFilesView clickOnFilesElementUploadFile () { + filesElementUploadFile.click(); + UploadFilesView uploadFilesView = new UploadFilesView(driver); + return uploadFilesView; + } + + public AndroidElement getTitleTextElement () { + return titleText; + } + + public AndroidElement getUploadButton () { + return uploadButton; + } + + public AndroidElement getWaitAMomentTextElement () { + return waitAMomentText; + } + + public AndroidElement getListRootElement () { + return listRootLayout; + } + + public List getListItemLayout () { + return listItemLayout; + } + + public AndroidElement getFileElement () { + return fileElement; + } + + 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 elementName) { + fileElement = Actions.scrollTillFindElement (elementName,filesLayout,driver); + try { + fileElementLayout = (AndroidElement) driver.findElementByAndroidUIAutomator("new UiSelector().description(\"LinearLayout-"+ elementName +"\")"); + } catch (NoSuchElementException e) { + fileElementLayout = null; + } + return fileElement; + } + + public AndroidElement getFileElementLayout () { + return fileElementLayout; + } + + public AndroidElement getProgressCircular () { + return progressCircular; + } + + public static String getLocalFileIndicator() { + return localFileIndicator; + } + + public static String getFavoriteFileIndicator() { + return favoriteFileIndicator; + } + + public static String getSharedElementIndicator() { + return sharedElementIndicator; + } + public void pulldownToRefresh () throws InterruptedException { + Point listLocation = listLayout.getLocation(); + driver.swipe(listLocation.getX(),listLocation.getY(), listLocation.getX(),listLocation.getY()+1000, 5000); + } + + +} diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/models/GmailEmailListView.java b/automationTest/src/test/java/com/owncloud/android/test/ui/models/GmailEmailListView.java new file mode 100644 index 00000000..5bf36901 --- /dev/null +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/models/GmailEmailListView.java @@ -0,0 +1,27 @@ +package com.owncloud.android.test.ui.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 GmailEmailListView { + + final AndroidDriver driver; + + @AndroidFindBy(uiAutomator = "new UiSelector().description(\"me about UploadFile, at 9:53 AM, conversation read\")") + private AndroidElement email; + + public GmailEmailListView (AndroidDriver driver) { + this.driver = driver; + PageFactory.initElements(new AppiumFieldDecorator(driver), this); + } + + public GmailEmailView clickOnEmail (){ + email.click(); + GmailEmailView gmailEmailView = new GmailEmailView(driver); + return gmailEmailView; + } + +} diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/models/GmailEmailView.java b/automationTest/src/test/java/com/owncloud/android/test/ui/models/GmailEmailView.java new file mode 100644 index 00000000..a5797014 --- /dev/null +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/models/GmailEmailView.java @@ -0,0 +1,30 @@ +package com.owncloud.android.test.ui.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 com.owncloud.android.test.ui.testSuites.Config; + +public class GmailEmailView { + final AndroidDriver driver; + + @CacheLookup + @AndroidFindBy(name = Config.fileToTestSendByEmailName) + private AndroidElement fileButton; + + public GmailEmailView (AndroidDriver driver) { + this.driver = driver; + PageFactory.initElements(new AppiumFieldDecorator(driver), this); + } + + public ImageView clickOnfileButton (){ + fileButton.click(); + ImageView imageView = new ImageView(driver); + return imageView; + } +} \ No newline at end of file diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/models/GmailSendMailView.java b/automationTest/src/test/java/com/owncloud/android/test/ui/models/GmailSendMailView.java new file mode 100644 index 00000000..264a61c4 --- /dev/null +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/models/GmailSendMailView.java @@ -0,0 +1,43 @@ +package com.owncloud.android.test.ui.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 GmailSendMailView { + final AndroidDriver driver; + + @CacheLookup + @AndroidFindBy(uiAutomator = "new UiSelector().description(\"To\")") + private AndroidElement toTextField; + + @CacheLookup + @AndroidFindBy(name = "Subject") + private AndroidElement subjectTextField; + + @CacheLookup + @AndroidFindBy(uiAutomator = "new UiSelector().description(\"Send\")") + private AndroidElement sendButton; + + public GmailSendMailView (AndroidDriver driver) { + this.driver = driver; + PageFactory.initElements(new AppiumFieldDecorator(driver), this); + } + + public void typeToEmailAdress (String email) { + toTextField.sendKeys(email + "\n"); + } + + public void clickOnSendButton () { + sendButton.click(); + } + + public void typeSubject (String subject) { + subjectTextField.clear(); + subjectTextField.sendKeys(subject); + } +} diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/models/ImageView.java b/automationTest/src/test/java/com/owncloud/android/test/ui/models/ImageView.java new file mode 100644 index 00000000..da8c30b6 --- /dev/null +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/models/ImageView.java @@ -0,0 +1,56 @@ +package com.owncloud.android.test.ui.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 com.owncloud.android.test.ui.actions.Actions; + + +public class ImageView { + final AndroidDriver driver; + + @CacheLookup + @AndroidFindBy(uiAutomator = "new UiSelector().description(\"More options\")") + private AndroidElement optionsButton; + + @AndroidFindBy(name = "Share") + private AndroidElement shareButton; + + @AndroidFindBy(name = "ownCloud") + private AndroidElement ownCloudButton; + + @AndroidFindBy(name = "Just once") + private AndroidElement justOnceButton; + + @AndroidFindBy(id = "android:id/resolver_list") + private AndroidElement sharingAppsLayout; + + public ImageView (AndroidDriver driver) { + this.driver = driver; + PageFactory.initElements(new AppiumFieldDecorator(driver), this); + } + + public void clickOnOptionsButton(){ + optionsButton.click(); + } + + public void clickOnShareButton(){ + shareButton.click(); + } + + public void clickOnOwnCloudButton(){ + if (! ownCloudButton.isDisplayed()) { + Actions.scrollTillFindElement("ownCloud", sharingAppsLayout, driver); + } + ownCloudButton.click(); + } + + public void clickOnJustOnceButton(){ + justOnceButton.click(); + } +} diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/models/LoginForm.java b/automationTest/src/test/java/com/owncloud/android/test/ui/models/LoginForm.java new file mode 100644 index 00000000..6971cc23 --- /dev/null +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/models/LoginForm.java @@ -0,0 +1,91 @@ +package com.owncloud.android.test.ui.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 CertificatePopUp typeHostUrl (String hostUrl) { + hostUrlInput.clear(); + hostUrlInput.sendKeys(hostUrl + "\n"); + CertificatePopUp certificatePopUp = new CertificatePopUp(driver); + return certificatePopUp; + } + + public void clickOnUserName () { + userNameInput.click(); + } + + public void typeUserName (String userName) { + userNameInput.clear(); + //using the \n , it not need to hide the keyboard which sometimes gives problems + userNameInput.sendKeys(userName + "\n"); + //driver.hideKeyboard(); + } + + public void typePassword (String password) { + passwordInput.clear(); + passwordInput.sendKeys(password + "\n"); + //driver.hideKeyboard(); + } + + public FileListView clickOnConnectButton () { + connectButton.click(); + FileListView fileListView = new FileListView(driver); + return fileListView; + } + + public AndroidElement gethostUrlInput () { + return hostUrlInput; + } + + public AndroidElement getUserNameInput () { + return userNameInput; + } + + public AndroidElement getPasswordInput () { + return passwordInput; + } + + + public AndroidElement getServerStatusTextElement () { + return serverStatusText; + } + + public AndroidElement getAuthStatusText () { + return authStatusText; + } +} diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/models/MenuList.java b/automationTest/src/test/java/com/owncloud/android/test/ui/models/MenuList.java new file mode 100644 index 00000000..9dade478 --- /dev/null +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/models/MenuList.java @@ -0,0 +1,27 @@ +package com.owncloud.android.test.ui.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/com/owncloud/android/test/ui/models/MoveView.java b/automationTest/src/test/java/com/owncloud/android/test/ui/models/MoveView.java new file mode 100644 index 00000000..5be7b69d --- /dev/null +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/models/MoveView.java @@ -0,0 +1,37 @@ +package com.owncloud.android.test.ui.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 com.owncloud.android.test.ui.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/com/owncloud/android/test/ui/models/NewFolderPopUp.java b/automationTest/src/test/java/com/owncloud/android/test/ui/models/NewFolderPopUp.java new file mode 100644 index 00000000..560c9abe --- /dev/null +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/models/NewFolderPopUp.java @@ -0,0 +1,36 @@ +package com.owncloud.android.test.ui.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 + "\n"); + //driver.hideKeyboard(); + } + + public WaitAMomentPopUp clickOnNewFolderOkButton () { + newFolderOkButton.click(); + WaitAMomentPopUp waitAMomentPopUp = new WaitAMomentPopUp(driver); + return waitAMomentPopUp; + } +} diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/models/PassCodeRequestView.java b/automationTest/src/test/java/com/owncloud/android/test/ui/models/PassCodeRequestView.java new file mode 100644 index 00000000..05d52487 --- /dev/null +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/models/PassCodeRequestView.java @@ -0,0 +1,34 @@ +package com.owncloud.android.test.ui.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 PassCodeRequestView { +final AndroidDriver driver; + + @AndroidFindBy(uiAutomator = "new UiSelector().className(\"android.widget.EditText\").index(0)") + private AndroidElement codeElement1; + + @AndroidFindBy(uiAutomator = "new UiSelector().className(\"android.widget.EditText\").index(1)") + private AndroidElement codeElement2; + + @AndroidFindBy(uiAutomator = "new UiSelector().className(\"android.widget.EditText\").index(2)") + private AndroidElement codeElement3; + + @AndroidFindBy(uiAutomator = "new UiSelector().className(\"android.widget.EditText\").index(3)") + private AndroidElement codeElement4; + + public PassCodeRequestView (AndroidDriver driver) { + this.driver = driver; + PageFactory.initElements(new AppiumFieldDecorator(driver), this); + } + + public void enterPasscode(String codeNumber1, String codeNumber2, String codeNumber3, String codeNumber4){ + codeElement1.sendKeys(codeNumber1 + codeNumber1 + codeNumber1 + codeNumber1); + } + +} diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/models/PassCodeView.java b/automationTest/src/test/java/com/owncloud/android/test/ui/models/PassCodeView.java new file mode 100644 index 00000000..a101823f --- /dev/null +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/models/PassCodeView.java @@ -0,0 +1,43 @@ +package com.owncloud.android.test.ui.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 PassCodeView { + final AndroidDriver driver; + + @AndroidFindBy(uiAutomator = "new UiSelector().className(\"android.widget.EditText\").index(0)") + private AndroidElement codeElement1; + + @AndroidFindBy(uiAutomator = "new UiSelector().className(\"android.widget.EditText\").index(1)") + private AndroidElement codeElement2; + + @AndroidFindBy(uiAutomator = "new UiSelector().className(\"android.widget.EditText\").index(2)") + private AndroidElement codeElement3; + + @AndroidFindBy(uiAutomator = "new UiSelector().className(\"android.widget.EditText\").index(3)") + private AndroidElement codeElement4; + + @AndroidFindBy(name = "Cancel") + private AndroidElement cancelButton; + + public PassCodeView (AndroidDriver driver) { + this.driver = driver; + PageFactory.initElements(new AppiumFieldDecorator(driver), this); + } + + public PassCodeView enterPasscode(String codeNumber1, String codeNumber2, String codeNumber3, String codeNumber4){ + codeElement1.sendKeys(codeNumber1 + codeNumber1 + codeNumber1 + codeNumber1); + return this; + } + public SettingsView reenterPasscode(String codeNumber1, String codeNumber2, String codeNumber3, String codeNumber4){ + codeElement1.sendKeys(codeNumber1 + codeNumber1 + codeNumber1 + codeNumber1); + SettingsView settingsView = new SettingsView(driver); + return settingsView; + } + +} diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/models/RemoveConfirmationView.java b/automationTest/src/test/java/com/owncloud/android/test/ui/models/RemoveConfirmationView.java new file mode 100644 index 00000000..1458e4fe --- /dev/null +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/models/RemoveConfirmationView.java @@ -0,0 +1,26 @@ +package com.owncloud.android.test.ui.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/com/owncloud/android/test/ui/models/SettingsView.java b/automationTest/src/test/java/com/owncloud/android/test/ui/models/SettingsView.java new file mode 100644 index 00000000..eeea7bf3 --- /dev/null +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/models/SettingsView.java @@ -0,0 +1,78 @@ +package com.owncloud.android.test.ui.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 com.owncloud.android.test.ui.testSuites.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; + + @AndroidFindBy(uiAutomator = "new UiSelector().className(\"android.widget.CheckBox\").index(0)") + private AndroidElement passcodeCheckbox; + + 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; + } + + public PassCodeView EnablePassCode(){ + if(!passcodeCheckbox.isSelected()){ + passcodeCheckbox.click(); + } + PassCodeView passcodeview = new PassCodeView(driver); + return passcodeview; + } + + public PassCodeView DisablePassCode(){ + if(passcodeCheckbox.isSelected()){ + passcodeCheckbox.click(); + } + PassCodeView passcodeview = new PassCodeView(driver); + return passcodeview; + } + +} diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/models/ShareView.java b/automationTest/src/test/java/com/owncloud/android/test/ui/models/ShareView.java new file mode 100644 index 00000000..b9258bd4 --- /dev/null +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/models/ShareView.java @@ -0,0 +1,28 @@ +package com.owncloud.android.test.ui.models; + +import io.appium.java_client.android.AndroidDriver; +import io.appium.java_client.android.AndroidElement; +import io.appium.java_client.pagefactory.AppiumFieldDecorator; + +import org.openqa.selenium.support.CacheLookup; +import org.openqa.selenium.support.FindBy; +import org.openqa.selenium.support.PageFactory; + +public class ShareView { + final AndroidDriver driver; + + @CacheLookup + @FindBy(id = "android:id/select_dialog_listview") + private AndroidElement listViewLayout; + + public ShareView (AndroidDriver driver) { + this.driver = driver; + PageFactory.initElements(new AppiumFieldDecorator(driver), this); + } + + public AndroidElement getListViewLayout () { + return listViewLayout; + } + + +} diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/models/UploadFilesView.java b/automationTest/src/test/java/com/owncloud/android/test/ui/models/UploadFilesView.java new file mode 100644 index 00000000..f2af739e --- /dev/null +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/models/UploadFilesView.java @@ -0,0 +1,46 @@ +package com.owncloud.android.test.ui.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 com.owncloud.android.test.ui.actions.Actions; + +public class UploadFilesView{ + final AndroidDriver driver; + + @CacheLookup + @AndroidFindBy(id = "com.owncloud.android:id/list_root") + private AndroidElement filesLayout; + + @CacheLookup + @AndroidFindBy(id = "com.owncloud.android:id/upload_files_btn_upload") + private AndroidElement uploadButton; + + private AndroidElement fileElement; + + public UploadFilesView (AndroidDriver driver) { + this.driver = driver; + PageFactory.initElements(new AppiumFieldDecorator(driver), this); + } + + public FileListView clickOnUploadButton () { + uploadButton.click(); + FileListView fileListView = new FileListView (driver); + return fileListView; + } + + //change to scrollTillFindElement + public void scrollTillFindFile (String fileName) { + fileElement = Actions.scrollTillFindElement (fileName,filesLayout,driver); + } + + public void clickOnFileName (String fileName) { + scrollTillFindFile(fileName); + fileElement.click(); + } +} diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/models/UploadView.java b/automationTest/src/test/java/com/owncloud/android/test/ui/models/UploadView.java new file mode 100644 index 00000000..26397f55 --- /dev/null +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/models/UploadView.java @@ -0,0 +1,26 @@ +package com.owncloud.android.test.ui.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 UploadView { + final AndroidDriver driver; + + @CacheLookup + @AndroidFindBy(name = "Upload") + private AndroidElement uploadButton; + + public UploadView (AndroidDriver driver) { + this.driver = driver; + PageFactory.initElements(new AppiumFieldDecorator(driver), this); + } + + public void clickOUploadButton () { + uploadButton.click(); + } +} diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/models/WaitAMomentPopUp.java b/automationTest/src/test/java/com/owncloud/android/test/ui/models/WaitAMomentPopUp.java new file mode 100644 index 00000000..edef1d17 --- /dev/null +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/models/WaitAMomentPopUp.java @@ -0,0 +1,24 @@ +package com.owncloud.android.test.ui.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/com/owncloud/android/test/ui/testSuites/.gitignore b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/.gitignore new file mode 100644 index 00000000..fa0f66df --- /dev/null +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/.gitignore @@ -0,0 +1 @@ +Config.java \ No newline at end of file diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/Common.java b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/Common.java new file mode 100644 index 00000000..d34e6e22 --- /dev/null +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/Common.java @@ -0,0 +1,128 @@ +package com.owncloud.android.test.ui.testSuites; + +import static org.junit.Assert.*; +import java.io.File; +import java.io.IOException; +import java.net.URL; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.concurrent.TimeUnit; +import org.apache.commons.io.FileUtils; +import org.openqa.selenium.By; +import org.openqa.selenium.NoSuchElementException; +import org.openqa.selenium.OutputType; +import org.openqa.selenium.TimeoutException; +import org.openqa.selenium.remote.DesiredCapabilities; +import org.openqa.selenium.remote.RemoteWebDriver; +import org.openqa.selenium.support.ui.WebDriverWait; +import io.appium.java_client.android.AndroidDriver; +import io.appium.java_client.android.AndroidElement; + +public class Common{ + AndroidDriver driver; + static int waitingTime = 30; + + WebDriverWait wait; + + protected AndroidDriver 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", "test"); + capabilities.setCapability("app", app.getAbsolutePath()); + capabilities.setCapability("appPackage", "com.owncloud.android"); + capabilities.setCapability("appActivity", ".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); + return driver; + + } + + 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(); + } + + protected void takeScreenShotOnFailed (String testName) throws IOException { + File file = ((RemoteWebDriver) driver).getScreenshotAs(OutputType.FILE); + SimpleDateFormat dt1 = new SimpleDateFormat("yyyy-MM-dd"); + Date today = Calendar.getInstance().getTime(); + String screenShotName = "ScreenShots/" + dt1.format(today) + "/" + testName + ".png"; + FileUtils.copyFile(file, new File(screenShotName)); + } + + protected void assertIsInFileListView() throws InterruptedException { + assertTrue(waitForTextPresent("ownCloud", (AndroidElement) driver.findElementByAndroidUIAutomator("new UiSelector().resourceId(\"android:id/action_bar_title\")"))); + assertTrue(isElementPresent((AndroidElement) driver.findElementByAndroidUIAutomator("new UiSelector().description(\"Upload\")"))); + } + + protected void assertIsNotInFileListView() throws InterruptedException { + AndroidElement fileElement; + assertTrue(waitForTextPresent("ownCloud", (AndroidElement) driver.findElementByAndroidUIAutomator("new UiSelector().resourceId(\"android:id/action_bar_title\")"))); + try { + fileElement = (AndroidElement) driver.findElementByAndroidUIAutomator("new UiSelector().description(\"Upload\")"); + } catch (NoSuchElementException e) { + fileElement = null; + } + assertNull(fileElement); + } + + protected void assertIsPasscodeRequestView() throws InterruptedException { + assertTrue(waitForTextPresent("ownCloud", (AndroidElement) driver.findElementByAndroidUIAutomator("new UiSelector().resourceId(\"android:id/action_bar_title\")"))); + assertTrue(((AndroidElement) driver.findElementByAndroidUIAutomator("new UiSelector().text(\"Please, insert your pass code\")")).isDisplayed()); + + } + + protected void assertIsInSettingsView() throws InterruptedException { + assertTrue(waitForTextPresent("Settings", (AndroidElement) driver.findElementByAndroidUIAutomator("new UiSelector().resourceId(\"android:id/action_bar_title\")"))); + } + +} diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/CreateFolderTestSuite.java b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/CreateFolderTestSuite.java new file mode 100644 index 00000000..a2bdab33 --- /dev/null +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/CreateFolderTestSuite.java @@ -0,0 +1,70 @@ +package com.owncloud.android.test.ui.testSuites; + +import static org.junit.Assert.*; +import io.appium.java_client.android.AndroidDriver; + +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.experimental.categories.Category; +import org.junit.rules.TestName; +import org.junit.runners.MethodSorters; +import org.junit.FixMethodOrder; +import org.junit.Test; + +import com.owncloud.android.test.ui.actions.Actions; +import com.owncloud.android.test.ui.groups.NoIgnoreTestCategory; +import com.owncloud.android.test.ui.groups.SmokeTestCategory; +import com.owncloud.android.test.ui.models.FileListView; +import com.owncloud.android.test.ui.models.WaitAMomentPopUp; + + +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class CreateFolderTestSuite{ + + AndroidDriver driver; + Common common; + private Boolean folderHasBeenCreated = false; + private final String FOLDER_NAME = "testCreateFolder"; + private String CurrentCreatedFolder = ""; + + @Rule public TestName name = new TestName(); + + @Before + public void setUp() throws Exception { + common=new Common(); + driver=common.setUpCommonDriver(); + } + + @Test + @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class}) + public void testCreateNewFolder () throws Exception { + String NEW_FOLDER_NAME = "testCreateFolder"; + + FileListView fileListView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); + common.assertIsInFileListView(); + + //check if the folder already exists and if true, delete them + Actions.deleteElement(NEW_FOLDER_NAME, fileListView, driver); + + WaitAMomentPopUp waitAMomentPopUp = Actions.createFolder(NEW_FOLDER_NAME, fileListView); + Common.waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100); + fileListView.scrollTillFindElement(FOLDER_NAME); + assertNotNull(fileListView.getFileElement()); + assertTrue(folderHasBeenCreated=fileListView.getFileElement().isDisplayed()); + CurrentCreatedFolder = FOLDER_NAME; + assertEquals(FOLDER_NAME , fileListView.getFileElement().getText()); + } + + @After + public void tearDown() throws Exception { + common.takeScreenShotOnFailed(name.getMethodName()); + if (folderHasBeenCreated) { + FileListView fileListView = new FileListView(driver); + Actions.deleteElement(CurrentCreatedFolder, fileListView, driver); + } + driver.removeApp("com.owncloud.android"); + driver.quit(); + } + +} diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/DeleteFileTestSuite.java b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/DeleteFileTestSuite.java new file mode 100644 index 00000000..28e6b251 --- /dev/null +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/DeleteFileTestSuite.java @@ -0,0 +1,62 @@ +package com.owncloud.android.test.ui.testSuites; + +import static org.junit.Assert.*; +import io.appium.java_client.android.AndroidDriver; + +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.experimental.categories.Category; +import org.junit.rules.TestName; +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 com.owncloud.android.test.ui.actions.Actions; +import com.owncloud.android.test.ui.groups.NoIgnoreTestCategory; +import com.owncloud.android.test.ui.groups.SmokeTestCategory; +import com.owncloud.android.test.ui.models.FileListView; + + +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class DeleteFileTestSuite{ + + AndroidDriver driver; + Common common; + private final String FILE_NAME = Config.fileToTestName; + + @Rule public TestName name = new TestName(); + + @Before + public void setUp() throws Exception { + common=new Common(); + driver=common.setUpCommonDriver(); + } + + @Test + @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class}) + public void testDeleteFile () throws Exception { + FileListView fileListView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); + common.assertIsInFileListView(); + + //TODO. if the file already exists, do not upload + FileListView fileListViewAfterUploadFile = Actions.uploadFile(FILE_NAME, fileListView); + + fileListViewAfterUploadFile.scrollTillFindElement(FILE_NAME); + Common.waitTillElementIsNotPresent(fileListViewAfterUploadFile.getProgressCircular(), 1000); + common.wait.until(ExpectedConditions.visibilityOf(fileListViewAfterUploadFile.getFileElementLayout().findElement(By.id(FileListView.getLocalFileIndicator())))); + + Actions.deleteElement(FILE_NAME,fileListViewAfterUploadFile, driver); + assertFalse(fileListViewAfterUploadFile.getFileElement().isDisplayed()); + } + + @After + public void tearDown() throws Exception { + common.takeScreenShotOnFailed(name.getMethodName()); + driver.removeApp("com.owncloud.android"); + driver.quit(); + } + +} \ No newline at end of file diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/DeleteFolderTestSuite.java b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/DeleteFolderTestSuite.java new file mode 100644 index 00000000..105a42dc --- /dev/null +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/DeleteFolderTestSuite.java @@ -0,0 +1,67 @@ +package com.owncloud.android.test.ui.testSuites; + +import static org.junit.Assert.*; +import io.appium.java_client.android.AndroidDriver; + +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.experimental.categories.Category; +import org.junit.rules.TestName; +import org.junit.runners.MethodSorters; +import org.junit.FixMethodOrder; +import org.junit.Test; + +import com.owncloud.android.test.ui.actions.Actions; +import com.owncloud.android.test.ui.groups.NoIgnoreTestCategory; +import com.owncloud.android.test.ui.groups.SmokeTestCategory; +import com.owncloud.android.test.ui.models.FileListView; +import com.owncloud.android.test.ui.models.WaitAMomentPopUp; + + +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class DeleteFolderTestSuite{ + AndroidDriver driver; + Common common; + private Boolean folderHasBeenCreated = false; + private final String FOLDER_NAME = "testCreateFolder"; + + @Rule public TestName name = new TestName(); + + + @Before + public void setUp() throws Exception { + common=new Common(); + driver=common.setUpCommonDriver(); + } + + @Test + @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class}) + public void testDeleteFolder () throws Exception { + FileListView fileListView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); + common.assertIsInFileListView(); + + //TODO. if the folder already exists, do no created + //create the folder + WaitAMomentPopUp waitAMomentPopUp = Actions.createFolder(FOLDER_NAME, fileListView); + Common.waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100); + fileListView.scrollTillFindElement(FOLDER_NAME); + assertTrue(folderHasBeenCreated = fileListView.getFileElement().isDisplayed()); + + //delete the folder + Actions.deleteElement(FOLDER_NAME, fileListView, driver); + assertFalse(folderHasBeenCreated =fileListView.getFileElement().isDisplayed()); + } + + @After + public void tearDown() throws Exception { + common.takeScreenShotOnFailed(name.getMethodName()); + if(folderHasBeenCreated){ + FileListView fileListView = new FileListView(driver); + Actions.deleteElement(FOLDER_NAME, fileListView, driver); + } + driver.removeApp("com.owncloud.android"); + driver.quit(); + } + +} diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/LoginTestSuite.java b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/LoginTestSuite.java new file mode 100644 index 00000000..4083e8ed --- /dev/null +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/LoginTestSuite.java @@ -0,0 +1,111 @@ +package com.owncloud.android.test.ui.testSuites; + +import static org.junit.Assert.*; +import io.appium.java_client.android.AndroidDriver; + +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.experimental.categories.Category; +import org.junit.rules.TestName; +import org.junit.runners.MethodSorters; +import org.junit.FixMethodOrder; +import org.junit.Test; +import org.openqa.selenium.ScreenOrientation; + +import com.owncloud.android.test.ui.actions.Actions; +import com.owncloud.android.test.ui.groups.*; +import com.owncloud.android.test.ui.models.LoginForm; +import com.owncloud.android.test.ui.models.FileListView; +import com.owncloud.android.test.ui.models.MenuList; +import com.owncloud.android.test.ui.models.SettingsView; + +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class LoginTestSuite{ + AndroidDriver driver; + Common common; + + @Rule public TestName name = new TestName(); + + @Before + public void setUp() throws Exception { + common=new Common(); + driver=common.setUpCommonDriver(); + } + + @Test + @Category({NoIgnoreTestCategory.class}) + public void test1LoginPortrait () throws Exception { + driver.rotate(ScreenOrientation.PORTRAIT); + + FileListView fileListView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); + common.assertIsInFileListView(); + } + + @Test + @Category({NoIgnoreTestCategory.class}) + public void test2LoginLandscape () throws Exception { + driver.rotate(ScreenOrientation.LANDSCAPE); + FileListView fileListView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); + common.assertIsInFileListView(); + } + + + @Test + @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class}) + public void test3MultiAccountRotate () throws Exception { + driver.rotate(ScreenOrientation.LANDSCAPE); + FileListView fileListView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); + common.assertIsInFileListView(); + + driver.rotate(ScreenOrientation.PORTRAIT); + MenuList menu = fileListView.clickOnMenuButton(); + SettingsView settingsView = menu.clickOnSettingsButton(); + + settingsView.tapOnAddAccount(1, 1000); + fileListView = Actions.login(Config.URL2, Config.user2,Config.password2, Config.isTrusted2, driver); + common.assertIsInSettingsView(); + } + + @Test + @Category({NoIgnoreTestCategory.class}) + public void test4ExistingAccountRotate () throws Exception { + driver.rotate(ScreenOrientation.PORTRAIT); + FileListView fileListView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); + common.assertIsInFileListView(); + + driver.rotate(ScreenOrientation.LANDSCAPE); + MenuList menu = fileListView.clickOnMenuButton(); + SettingsView settingsView = menu.clickOnSettingsButton(); + settingsView.tapOnAddAccount(1, 1000); + + LoginForm loginForm = new LoginForm(driver); + fileListView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); + assertTrue(common.waitForTextPresent("An account for the same user and server already exists in the device", loginForm.getAuthStatusText())); + } + + @Test + @Category({NoIgnoreTestCategory.class}) + public void test5ChangePasswordWrong () throws Exception { + driver.rotate(ScreenOrientation.PORTRAIT); + FileListView fileListView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); + common.assertIsInFileListView(); + MenuList menu = fileListView.clickOnMenuButton(); + SettingsView settingsView = menu.clickOnSettingsButton(); + settingsView.tapOnAccountElement(1, 1000); + LoginForm changePasswordForm = settingsView.clickOnChangePasswordElement(); + changePasswordForm.typePassword("WrongPassword"); + changePasswordForm.clickOnConnectButton(); + assertTrue(common.waitForTextPresent("Wrong username or password", changePasswordForm.getAuthStatusText())); + } + + + @After + public void tearDown() throws Exception { + common.takeScreenShotOnFailed(name.getMethodName()); + driver.removeApp("com.owncloud.android"); + driver.quit(); + } + + +} diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/LogoutTestSuite.java b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/LogoutTestSuite.java new file mode 100644 index 00000000..6ebfb635 --- /dev/null +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/LogoutTestSuite.java @@ -0,0 +1,55 @@ +package com.owncloud.android.test.ui.testSuites; + + +import static org.junit.Assert.*; +import io.appium.java_client.android.AndroidDriver; + +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.experimental.categories.Category; +import org.junit.rules.TestName; + +import com.owncloud.android.test.ui.actions.Actions; +import com.owncloud.android.test.ui.groups.NoIgnoreTestCategory; +import com.owncloud.android.test.ui.groups.SmokeTestCategory; +import com.owncloud.android.test.ui.models.LoginForm; +import com.owncloud.android.test.ui.models.FileListView; +import com.owncloud.android.test.ui.models.MenuList; +import com.owncloud.android.test.ui.models.SettingsView; + +public class LogoutTestSuite{ + + AndroidDriver driver; + Common common; + + @Rule public TestName name = new TestName(); + + @Before + public void setUp() throws Exception { + common=new Common(); + driver=common.setUpCommonDriver(); + } + + @Test + @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class}) + public void testLogout () throws Exception { + FileListView fileListView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); + common.assertIsInFileListView(); + MenuList menulist = fileListView.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 { + common.takeScreenShotOnFailed(name.getMethodName()); + //driver.removeApp("com.owncloud.android"); + driver.quit(); + } +} diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/MoveFileTestSuite.java b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/MoveFileTestSuite.java new file mode 100644 index 00000000..c5070a0a --- /dev/null +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/MoveFileTestSuite.java @@ -0,0 +1,92 @@ +package com.owncloud.android.test.ui.testSuites; + +import static org.junit.Assert.*; +import io.appium.java_client.android.AndroidDriver; + +import org.junit.After; +import org.junit.Before; +import org.junit.FixMethodOrder; +import org.junit.Rule; +import org.junit.Test; +import org.junit.experimental.categories.Category; +import org.junit.rules.TestName; +import org.junit.runners.MethodSorters; + +import com.owncloud.android.test.ui.actions.Actions; +import com.owncloud.android.test.ui.groups.NoIgnoreTestCategory; +import com.owncloud.android.test.ui.groups.SmokeTestCategory; +import com.owncloud.android.test.ui.models.ElementMenuOptions; +import com.owncloud.android.test.ui.models.FileListView; +import com.owncloud.android.test.ui.models.MoveView; +import com.owncloud.android.test.ui.models.WaitAMomentPopUp; + + + +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class MoveFileTestSuite{ + AndroidDriver driver; + Common common; + private String FOLDER_WHERE_MOVE = "folderWhereMove"; + private String FILE_NAME = Config.fileToTestName; + @Rule public TestName name = new TestName(); + + @Before + public void setUp() throws Exception { + common=new Common(); + driver=common.setUpCommonDriver(); + } + + @Test + @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class}) + public void testMoveFile () throws Exception { + WaitAMomentPopUp waitAMomentPopUp; + + FileListView fileListView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); + common.assertIsInFileListView(); + + //Common.waitTillElementIsNotPresent(fileListView.getProgressCircular(), 1000); + + //check if the folder already exists and if true, delete them + Actions.deleteElement(FOLDER_WHERE_MOVE, fileListView, driver); + Actions.deleteElement(FILE_NAME, fileListView, driver); + + //Create the folder where the other is gone to be moved + waitAMomentPopUp = Actions.createFolder(FOLDER_WHERE_MOVE, fileListView); + Common.waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100); + fileListView.scrollTillFindElement(FOLDER_WHERE_MOVE); + assertTrue(fileListView.getFileElement().isDisplayed()); + + FileListView fileListViewAfterUploadFile = Actions.uploadFile(FILE_NAME, fileListView); + fileListViewAfterUploadFile.scrollTillFindElement(FILE_NAME); + assertTrue(fileListViewAfterUploadFile.getFileElement().isDisplayed()); + + //select to move the file + ElementMenuOptions menuOptions = fileListView.longPressOnElement(FILE_NAME); + MoveView moveView = menuOptions.clickOnMove(); + + //to move to a folder + moveView.scrollTillFindElement(FOLDER_WHERE_MOVE).tap(1,1); + waitAMomentPopUp = moveView.clickOnChoose(); + Common.waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100); + + //check that the folder moved is inside the other + fileListView.scrollTillFindElement(FOLDER_WHERE_MOVE).tap(1,1); + Common.waitTillElementIsNotPresent(fileListView.getProgressCircular(), 1000); + Thread.sleep(1000); + fileListView.scrollTillFindElement(FILE_NAME); + assertEquals(FILE_NAME , fileListView.getFileElement().getText()); + + } + + @After + public void tearDown() throws Exception { + common.takeScreenShotOnFailed(name.getMethodName()); + FileListView fileListView = new FileListView(driver); + driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_BACK); + Actions.deleteElement(FOLDER_WHERE_MOVE, fileListView, driver); + Actions.deleteElement(FILE_NAME, fileListView, driver); + driver.removeApp("com.owncloud.android"); + driver.quit(); + } + +} diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/MoveFolderTestSuite.java b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/MoveFolderTestSuite.java new file mode 100644 index 00000000..d7439040 --- /dev/null +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/MoveFolderTestSuite.java @@ -0,0 +1,94 @@ +package com.owncloud.android.test.ui.testSuites; + +import static org.junit.Assert.*; +import io.appium.java_client.android.AndroidDriver; + +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.experimental.categories.Category; +import org.junit.rules.TestName; +import org.junit.runners.MethodSorters; +import org.junit.FixMethodOrder; +import org.junit.Test; + +import com.owncloud.android.test.ui.actions.Actions; +import com.owncloud.android.test.ui.groups.NoIgnoreTestCategory; +import com.owncloud.android.test.ui.groups.SmokeTestCategory; +import com.owncloud.android.test.ui.models.ElementMenuOptions; +import com.owncloud.android.test.ui.models.FileListView; +import com.owncloud.android.test.ui.models.MoveView; +import com.owncloud.android.test.ui.models.WaitAMomentPopUp; + + +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class MoveFolderTestSuite{ + AndroidDriver driver; + Common common; + private String FOLDER_TO_MOVE = "folderToMove"; + private String FOLDER_WHERE_MOVE = "folderWhereMove"; + + @Rule public TestName name = new TestName(); + + @Before + public void setUp() throws Exception { + common=new Common(); + driver=common.setUpCommonDriver(); + } + + @Test + @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class}) + public void testMoveFolder () throws Exception { + WaitAMomentPopUp waitAMomentPopUp; + + FileListView fileListView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); + common.assertIsInFileListView(); + + //Common.waitTillElementIsNotPresent(fileListView.getProgressCircular(), 1000); + + //check if the folder already exists and if true, delete them + Actions.deleteElement(FOLDER_WHERE_MOVE, fileListView, driver); + Actions.deleteElement(FOLDER_TO_MOVE, fileListView, driver); + + //Create the folder where the other is gone to be moved + waitAMomentPopUp = Actions.createFolder(FOLDER_WHERE_MOVE, fileListView); + Common.waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100); + fileListView.scrollTillFindElement(FOLDER_WHERE_MOVE); + assertTrue(fileListView.getFileElement().isDisplayed()); + + //Create the folder which is going to be moved + waitAMomentPopUp = Actions.createFolder(FOLDER_TO_MOVE, fileListView); + Common.waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100); + fileListView.scrollTillFindElement(FOLDER_TO_MOVE); + assertTrue(fileListView.getFileElement().isDisplayed()); + + //select to move the folder + ElementMenuOptions menuOptions = fileListView.longPressOnElement(FOLDER_TO_MOVE); + MoveView moveView = menuOptions.clickOnMove(); + + //to move to a folder + moveView.scrollTillFindElement(FOLDER_WHERE_MOVE).tap(1,1); + waitAMomentPopUp = moveView.clickOnChoose(); + Common.waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100); + + //check that the folder moved is inside the other + fileListView.scrollTillFindElement(FOLDER_WHERE_MOVE).tap(1,1); + Common.waitTillElementIsNotPresent(fileListView.getProgressCircular(), 1000); + Thread.sleep(1000); + fileListView.scrollTillFindElement(FOLDER_TO_MOVE); + assertEquals(FOLDER_TO_MOVE , fileListView.getFileElement().getText()); + } + + @After + public void tearDown() throws Exception { + common.takeScreenShotOnFailed(name.getMethodName()); + FileListView fileListView = new FileListView(driver); + driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_BACK); + Actions.deleteElement(FOLDER_WHERE_MOVE, fileListView, driver); + Actions.deleteElement(FOLDER_TO_MOVE, fileListView, driver); + driver.removeApp("com.owncloud.android"); + driver.quit(); + } + + +} diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/PasscodeTestSuite.java b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/PasscodeTestSuite.java new file mode 100644 index 00000000..7b50af88 --- /dev/null +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/PasscodeTestSuite.java @@ -0,0 +1,70 @@ +package com.owncloud.android.test.ui.testSuites; + +import io.appium.java_client.android.AndroidDriver; + +import org.junit.After; +import org.junit.Before; +import org.junit.FixMethodOrder; +import org.junit.Rule; +import org.junit.Test; +import org.junit.experimental.categories.Category; +import org.junit.rules.TestName; +import org.junit.runners.MethodSorters; +import org.openqa.selenium.ScreenOrientation; + +import com.owncloud.android.test.ui.actions.Actions; +import com.owncloud.android.test.ui.groups.NoIgnoreTestCategory; +import com.owncloud.android.test.ui.models.FileListView; +import com.owncloud.android.test.ui.models.MenuList; +import com.owncloud.android.test.ui.models.PassCodeRequestView; +import com.owncloud.android.test.ui.models.PassCodeView; +import com.owncloud.android.test.ui.models.SettingsView; + +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class PasscodeTestSuite { + AndroidDriver driver; + Common common; + + @Rule public TestName name = new TestName(); + + @Before + public void setUp() throws Exception { + common=new Common(); + driver=common.setUpCommonDriver(); + } + + @Test + @Category({NoIgnoreTestCategory.class}) + public void testPincodeEnable () throws Exception { + driver.rotate(ScreenOrientation.PORTRAIT); + FileListView fileListView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); + common.assertIsInFileListView(); + + MenuList menu = fileListView.clickOnMenuButton(); + SettingsView settingsView = menu.clickOnSettingsButton(); + + PassCodeView passCodeview = settingsView.EnablePassCode(); + PassCodeView passCodeview2 = passCodeview.enterPasscode(Config.passcode1, Config.passcode2, Config.passcode3, Config.passcode4); + passCodeview2.reenterPasscode(Config.passcode1, Config.passcode2, Config.passcode3, Config.passcode4); + + driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_HOME); + //TO DO. Open the app instead of start an activity + driver.startActivity("com.owncloud.android", ".ui.activity.FileDisplayActivity"); + //here we check that we are not in the fileDisplayActivity, because pincode is asked + common.assertIsNotInFileListView(); + common.assertIsPasscodeRequestView(); + + PassCodeRequestView passCodeReequestView = new PassCodeRequestView(driver); + passCodeReequestView.enterPasscode(Config.passcode1, Config.passcode2, Config.passcode3, Config.passcode4); + common.assertIsInFileListView(); + } + + + @After + public void tearDown() throws Exception { + common.takeScreenShotOnFailed(name.getMethodName()); + driver.removeApp("com.owncloud.android"); + driver.quit(); + } + +} diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/RefreshFolderTestSuite.java b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/RefreshFolderTestSuite.java new file mode 100644 index 00000000..15015c06 --- /dev/null +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/RefreshFolderTestSuite.java @@ -0,0 +1,55 @@ +package com.owncloud.android.test.ui.testSuites; + +import static org.junit.Assert.*; +import io.appium.java_client.android.AndroidDriver; + +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.experimental.categories.Category; +import org.junit.rules.TestName; +import org.junit.runners.MethodSorters; +import org.junit.FixMethodOrder; +import org.junit.Test; + +import com.owncloud.android.test.ui.actions.Actions; +import com.owncloud.android.test.ui.groups.UnfinishedTestCategory; +import com.owncloud.android.test.ui.models.FileListView; + + +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class RefreshFolderTestSuite{ + AndroidDriver driver; + Common common; + + @Rule public TestName name = new TestName(); + + @Before + public void setUp() throws Exception { + common=new Common(); + driver=common.setUpCommonDriver(); + } + + + @Test + @Category({UnfinishedTestCategory.class}) + public void testPulldownToRefreshFolder () throws Exception { + FileListView fileListView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); + common.assertIsInFileListView(); + //TODO. Remove the sleep and check why is not working the assert when using waitTillElementIsNotPresent + Thread.sleep(5000); + //waitTillElementIsNotPresent(fileListView.getProgressCircular(), 1000); + fileListView.pulldownToRefresh(); + assertTrue(fileListView.getProgressCircular().isDisplayed()); + //TODO insert a file in the web, and check that it's shown here + } + + + @After + public void tearDown() throws Exception { + common.takeScreenShotOnFailed(name.getMethodName()); + driver.removeApp("com.owncloud.android"); + driver.quit(); + } + +} diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/RenameFileTestSuite.java b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/RenameFileTestSuite.java new file mode 100644 index 00000000..4c9b293b --- /dev/null +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/RenameFileTestSuite.java @@ -0,0 +1,84 @@ +package com.owncloud.android.test.ui.testSuites; + +import static org.junit.Assert.*; +import io.appium.java_client.android.AndroidDriver; + +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.experimental.categories.Category; +import org.junit.rules.TestName; +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 com.owncloud.android.test.ui.actions.Actions; +import com.owncloud.android.test.ui.groups.NoIgnoreTestCategory; +import com.owncloud.android.test.ui.groups.SmokeTestCategory; +import com.owncloud.android.test.ui.models.ElementMenuOptions; +import com.owncloud.android.test.ui.models.FileListView; +import com.owncloud.android.test.ui.models.NewFolderPopUp; +import com.owncloud.android.test.ui.models.WaitAMomentPopUp; + + +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class RenameFileTestSuite{ + + AndroidDriver driver; + Common common; + private Boolean fileHasBeenCreated = false; + private final String OLD_FILE_NAME = Config.fileToTestName; + private final String FILE_NAME = "newNameFile"; + private String CurrentCreatedFile = ""; + + @Rule public TestName name = new TestName(); + + @Before + public void setUp() throws Exception { + common=new Common(); + driver=common.setUpCommonDriver(); + } + + @Test + @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class}) + public void testRenameFile () throws Exception { + FileListView fileListView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); + common.assertIsInFileListView(); + + //TODO. if the file already exists, do not upload + FileListView fileListViewAfterUploadFile = Actions.uploadFile(OLD_FILE_NAME, fileListView); + + //check if the file with the new name already exists, if true delete it + Actions.deleteElement(FILE_NAME, fileListView, driver); + + fileListViewAfterUploadFile.scrollTillFindElement(OLD_FILE_NAME); + assertTrue(fileHasBeenCreated = fileListViewAfterUploadFile.getFileElement().isDisplayed()); + CurrentCreatedFile = OLD_FILE_NAME; + Common.waitTillElementIsNotPresent(fileListViewAfterUploadFile.getProgressCircular(), 1000); + common.wait.until(ExpectedConditions.visibilityOf(fileListViewAfterUploadFile.getFileElementLayout().findElement(By.id(FileListView.getLocalFileIndicator())))); + ElementMenuOptions menuOptions = fileListViewAfterUploadFile.longPressOnElement(OLD_FILE_NAME); + NewFolderPopUp newFolderPopUp = menuOptions.clickOnRename(); + newFolderPopUp.typeNewFolderName(FILE_NAME); + WaitAMomentPopUp waitAMomentPopUp = newFolderPopUp.clickOnNewFolderOkButton(); + Common.waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100); + fileListViewAfterUploadFile.scrollTillFindElement(FILE_NAME); + assertNotNull(fileListViewAfterUploadFile.getFileElement()); + assertTrue(fileListViewAfterUploadFile.getFileElement().isDisplayed()); + assertEquals(FILE_NAME , fileListViewAfterUploadFile.getFileElement().getText()); + CurrentCreatedFile = FILE_NAME; + } + + @After + public void tearDown() throws Exception { + common.takeScreenShotOnFailed(name.getMethodName()); + if (fileHasBeenCreated) { + FileListView fileListView = new FileListView(driver); + Actions.deleteElement(CurrentCreatedFile,fileListView, driver); + } + driver.removeApp("com.owncloud.android"); + driver.quit(); + } + +} diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/RenameFolderTestSuite.java b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/RenameFolderTestSuite.java new file mode 100644 index 00000000..0983f017 --- /dev/null +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/RenameFolderTestSuite.java @@ -0,0 +1,84 @@ +package com.owncloud.android.test.ui.testSuites; + +import static org.junit.Assert.*; +import io.appium.java_client.android.AndroidDriver; + +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.experimental.categories.Category; +import org.junit.rules.TestName; +import org.junit.runners.MethodSorters; +import org.junit.FixMethodOrder; +import org.junit.Test; + +import com.owncloud.android.test.ui.actions.Actions; +import com.owncloud.android.test.ui.groups.NoIgnoreTestCategory; +import com.owncloud.android.test.ui.groups.SmokeTestCategory; +import com.owncloud.android.test.ui.models.ElementMenuOptions; +import com.owncloud.android.test.ui.models.FileListView; +import com.owncloud.android.test.ui.models.NewFolderPopUp; +import com.owncloud.android.test.ui.models.WaitAMomentPopUp; + + +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class RenameFolderTestSuite{ + + AndroidDriver driver; + Common common; + private Boolean folderHasBeenCreated = false; + private final String OLD_FOLDER_NAME = "beforeRemoving"; + private final String FOLDER_NAME = "testCreateFolder"; + private String CurrentCreatedFolder = ""; + + @Rule public TestName name = new TestName(); + + + @Before + public void setUp() throws Exception { + common=new Common(); + driver=common.setUpCommonDriver(); + } + + @Test + @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class}) + public void testRenameFolder () throws Exception { + FileListView fileListView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); + common.assertIsInFileListView(); + + //TODO. if the folder already exists, do no created + //create the folder to rename + WaitAMomentPopUp waitAMomentPopUp = Actions.createFolder(OLD_FOLDER_NAME, fileListView); + Common.waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100); + fileListView.scrollTillFindElement(OLD_FOLDER_NAME); + + assertTrue(folderHasBeenCreated = fileListView.getFileElement().isDisplayed()); + + //check if the folder with the new name already exists and if true, delete them + Actions.deleteElement(FOLDER_NAME, fileListView, driver); + + CurrentCreatedFolder = OLD_FOLDER_NAME; + ElementMenuOptions menuOptions = fileListView.longPressOnElement(OLD_FOLDER_NAME); + NewFolderPopUp FolderPopUp = menuOptions.clickOnRename(); + FolderPopUp.typeNewFolderName(FOLDER_NAME); + FolderPopUp.clickOnNewFolderOkButton(); + CurrentCreatedFolder = FOLDER_NAME; + Common.waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100); + fileListView.scrollTillFindElement(FOLDER_NAME); + assertNotNull(fileListView.getFileElement()); + assertTrue(folderHasBeenCreated = fileListView.getFileElement().isDisplayed()); + assertEquals(FOLDER_NAME , fileListView.getFileElement().getText()); + } + + @After + public void tearDown() throws Exception { + common.takeScreenShotOnFailed(name.getMethodName()); + if(folderHasBeenCreated){ + FileListView fileListView = new FileListView(driver); + Actions.deleteElement(CurrentCreatedFolder, fileListView, driver); + } + driver.removeApp("com.owncloud.android"); + driver.quit(); + } + +} diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/RunFailingTests.java b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/RunFailingTests.java new file mode 100644 index 00000000..53d69fd0 --- /dev/null +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/RunFailingTests.java @@ -0,0 +1,24 @@ +package com.owncloud.android.test.ui.testSuites; + + +import org.junit.experimental.categories.Categories.ExcludeCategory; +import org.junit.experimental.categories.Categories.IncludeCategory; +import org.junit.runner.RunWith; + +import com.owncloud.android.test.ui.groups.FailingTestCategory; +import com.owncloud.android.test.ui.groups.FlexibleCategories; +import com.owncloud.android.test.ui.groups.NoIgnoreTestCategory; +import com.owncloud.android.test.ui.groups.FlexibleCategories.TestClassPrefix; +import com.owncloud.android.test.ui.groups.FlexibleCategories.TestClassSuffix; +import com.owncloud.android.test.ui.groups.FlexibleCategories.TestScanPackage; + + +@RunWith(FlexibleCategories.class) +@ExcludeCategory(NoIgnoreTestCategory.class) +@IncludeCategory(FailingTestCategory.class) +@TestScanPackage("com.owncloud.android.test.ui.testSuites") +@TestClassPrefix("") +@TestClassSuffix("TestSuite") +public class RunFailingTests { + +} diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/RunNoIgnoreTests.java b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/RunNoIgnoreTests.java new file mode 100644 index 00000000..bfa7dbf5 --- /dev/null +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/RunNoIgnoreTests.java @@ -0,0 +1,22 @@ +package com.owncloud.android.test.ui.testSuites; + +import org.junit.experimental.categories.Categories.ExcludeCategory; +import org.junit.experimental.categories.Categories.IncludeCategory; +import org.junit.runner.RunWith; + +import com.owncloud.android.test.ui.groups.FlexibleCategories; +import com.owncloud.android.test.ui.groups.IgnoreTestCategory; +import com.owncloud.android.test.ui.groups.NoIgnoreTestCategory; +import com.owncloud.android.test.ui.groups.FlexibleCategories.TestClassPrefix; +import com.owncloud.android.test.ui.groups.FlexibleCategories.TestClassSuffix; +import com.owncloud.android.test.ui.groups.FlexibleCategories.TestScanPackage; + + +@RunWith(FlexibleCategories.class) +@ExcludeCategory(IgnoreTestCategory.class) +@IncludeCategory(NoIgnoreTestCategory.class) +@TestScanPackage("com.owncloud.android.test.ui.testSuites") +@TestClassPrefix("") +@TestClassSuffix("TestSuite") +public class RunNoIgnoreTests { +} \ No newline at end of file diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/RunSmokeTests.java b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/RunSmokeTests.java new file mode 100644 index 00000000..ad4738f0 --- /dev/null +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/RunSmokeTests.java @@ -0,0 +1,22 @@ +package com.owncloud.android.test.ui.testSuites; + +import org.junit.experimental.categories.Categories.ExcludeCategory; +import org.junit.experimental.categories.Categories.IncludeCategory; +import org.junit.runner.RunWith; + +import com.owncloud.android.test.ui.groups.FlexibleCategories; +import com.owncloud.android.test.ui.groups.IgnoreTestCategory; +import com.owncloud.android.test.ui.groups.SmokeTestCategory; +import com.owncloud.android.test.ui.groups.FlexibleCategories.TestClassPrefix; +import com.owncloud.android.test.ui.groups.FlexibleCategories.TestClassSuffix; +import com.owncloud.android.test.ui.groups.FlexibleCategories.TestScanPackage; + + +@RunWith(FlexibleCategories.class) +@ExcludeCategory(IgnoreTestCategory.class) +@IncludeCategory(SmokeTestCategory.class) +@TestScanPackage("com.owncloud.android.test.ui.testSuites") +@TestClassPrefix("") +@TestClassSuffix("TestSuite") +public class RunSmokeTests { +} \ No newline at end of file diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/ShareLinkFileTestSuite.java b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/ShareLinkFileTestSuite.java new file mode 100644 index 00000000..147801f8 --- /dev/null +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/ShareLinkFileTestSuite.java @@ -0,0 +1,72 @@ +package com.owncloud.android.test.ui.testSuites; + +import static org.junit.Assert.assertTrue; +import io.appium.java_client.android.AndroidDriver; + +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.experimental.categories.Category; +import org.junit.rules.TestName; +import org.openqa.selenium.By; +import org.openqa.selenium.support.ui.ExpectedConditions; + +import com.owncloud.android.test.ui.actions.Actions; +import com.owncloud.android.test.ui.groups.NoIgnoreTestCategory; +import com.owncloud.android.test.ui.groups.SmokeTestCategory; +import com.owncloud.android.test.ui.models.ElementMenuOptions; +import com.owncloud.android.test.ui.models.GmailSendMailView; +import com.owncloud.android.test.ui.models.FileListView; +import com.owncloud.android.test.ui.models.ShareView; + +public class ShareLinkFileTestSuite{ + + AndroidDriver driver; + Common common; + private final String FILE_NAME = Config.fileToTestName; + private Boolean fileHasBeenCreated = false; + + @Rule public TestName name = new TestName(); + + @Before + public void setUp() throws Exception { + common=new Common(); + driver=common.setUpCommonDriver(); + } + + @Test + @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class}) + public void testShareLinkFile () throws Exception { + FileListView fileListView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); + common.assertIsInFileListView(); + + //TODO. if the file already exists, do not upload + FileListView fileListViewAfterUploadFile = Actions.uploadFile(FILE_NAME, fileListView); + + fileListViewAfterUploadFile.scrollTillFindElement(FILE_NAME); + assertTrue(fileHasBeenCreated = fileListViewAfterUploadFile.getFileElement().isDisplayed()); + + ElementMenuOptions elementMenuOption = fileListViewAfterUploadFile.longPressOnElement(FILE_NAME); + ShareView shareView = elementMenuOption.clickOnShareLinkElement(); + Actions.scrollTillFindElement("Gmail", shareView.getListViewLayout(), driver).click(); + GmailSendMailView gmailSendMailView = new GmailSendMailView(driver); + gmailSendMailView.typeToEmailAdress(Config.gmailAccount); + gmailSendMailView.clickOnSendButton(); + Common.waitTillElementIsNotPresent(fileListViewAfterUploadFile.getProgressCircular(), 1000); + common.wait.until(ExpectedConditions.visibilityOf(fileListViewAfterUploadFile.getFileElementLayout().findElement(By.id(FileListView.getSharedElementIndicator())))); + assertTrue(fileListViewAfterUploadFile.getFileElementLayout().findElement(By.id(FileListView.getSharedElementIndicator())).isDisplayed()); + + } + + @After + public void tearDown() throws Exception { + common.takeScreenShotOnFailed(name.getMethodName()); + if (fileHasBeenCreated) { + FileListView fileListView = new FileListView(driver); + Actions.deleteElement(FILE_NAME,fileListView, driver); + } + driver.removeApp("com.owncloud.android"); + driver.quit(); + } +} diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/UploadTestSuite.java b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/UploadTestSuite.java new file mode 100644 index 00000000..cbea9785 --- /dev/null +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/UploadTestSuite.java @@ -0,0 +1,124 @@ +package com.owncloud.android.test.ui.testSuites; + + +import static org.junit.Assert.*; +import io.appium.java_client.MobileBy; +import io.appium.java_client.android.AndroidDriver; + +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.experimental.categories.Category; +import org.junit.rules.TestName; +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 com.owncloud.android.test.ui.actions.Actions; +import com.owncloud.android.test.ui.groups.FailingTestCategory; +import com.owncloud.android.test.ui.groups.IgnoreTestCategory; +import com.owncloud.android.test.ui.groups.NoIgnoreTestCategory; +import com.owncloud.android.test.ui.models.FileDetailsView; +import com.owncloud.android.test.ui.models.ElementMenuOptions; +import com.owncloud.android.test.ui.models.GmailEmailListView; +import com.owncloud.android.test.ui.models.GmailEmailView; +import com.owncloud.android.test.ui.models.ImageView; +import com.owncloud.android.test.ui.models.FileListView; +import com.owncloud.android.test.ui.models.UploadView; + + +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +@Category({NoIgnoreTestCategory.class}) +public class UploadTestSuite{ + + AndroidDriver driver; + Common common; + String FILE_NAME = Config.fileToTestName; + + @Rule public TestName name = new TestName(); + + + @Before + public void setUp() throws Exception { + common=new Common(); + driver=common.setUpCommonDriver(); + } + + @Test + @Category(NoIgnoreTestCategory.class) + public void testUploadFile () throws Exception { + + FileListView fileListView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); + common.assertIsInFileListView(); + + //check if the file already exists and if true, delete it + Actions.deleteElement(FILE_NAME, fileListView, driver); + + FileListView fileListViewAfterUploadFile = Actions.uploadFile(FILE_NAME, fileListView); + + fileListViewAfterUploadFile.scrollTillFindElement(FILE_NAME); + assertTrue(fileListViewAfterUploadFile.getFileElement().isDisplayed()); + Common.waitTillElementIsNotPresent(fileListViewAfterUploadFile.getProgressCircular(), 1000); + common.wait.until(ExpectedConditions.visibilityOf(fileListViewAfterUploadFile.getFileElementLayout().findElement(By.id(FileListView.getLocalFileIndicator())))); + assertTrue(fileListViewAfterUploadFile.getFileElementLayout().findElement(By.id(FileListView.getLocalFileIndicator())).isDisplayed()); + + } + + @Test + @Category(IgnoreTestCategory.class) + public void testUploadFromGmail () throws Exception { + FileListView fileListView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); + driver.startActivity("com.google.android.gm", ".ConversationListActivityGmail"); + GmailEmailListView gmailEmailListView = new GmailEmailListView(driver); + GmailEmailView gmailEmailView = gmailEmailListView.clickOnEmail(); + ImageView imageView = gmailEmailView.clickOnfileButton(); + imageView.clickOnOptionsButton(); + imageView.clickOnShareButton(); + imageView.clickOnOwnCloudButton(); + imageView.clickOnJustOnceButton(); + UploadView uploadView = new UploadView(driver); + uploadView.clickOUploadButton(); + driver.startActivity("com.owncloud.android", ".ui.activity.FileDisplayActivity"); + common.wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.name(Config.fileToTestSendByEmailName))); + assertEquals(Config.fileToTestSendByEmailName , driver.findElementByName(Config.fileToTestSendByEmailName).getText()); + } + + + @Test + @Category({IgnoreTestCategory.class, FailingTestCategory.class}) + public void testKeepFileUpToDate () throws Exception { + + FileListView fileListView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); + common.assertIsInFileListView(); + + Common.waitTillElementIsNotPresent(fileListView.getProgressCircular(), 1000); + + FileListView fileListViewAfterUploadFile = Actions.uploadFile(FILE_NAME, fileListView); + fileListViewAfterUploadFile.scrollTillFindElement(FILE_NAME); + assertTrue(fileListViewAfterUploadFile.getFileElement().isDisplayed()); + + ElementMenuOptions menuOptions = fileListViewAfterUploadFile.longPressOnElement(FILE_NAME); + FileDetailsView fileDetailsView = menuOptions.clickOnDetails(); + fileDetailsView.checkKeepFileUpToDateCheckbox(); + Thread.sleep(3000); + driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_BACK); + //assertTrue(common.isElementPresent(fileListViewAfterUploadFile.getFileElementLayout(), MobileBy.id(FileListView.getFavoriteFileIndicator()))); + assertTrue(fileListViewAfterUploadFile.getFileElementLayout().findElement(By.id(FileListView.getFavoriteFileIndicator())).isDisplayed()); + + } + + + @After + public void tearDown() throws Exception { + common.takeScreenShotOnFailed(name.getMethodName()); + FileListView fileListView = new FileListView(driver); + Actions.deleteElement(FILE_NAME,fileListView, driver); + driver.removeApp("com.owncloud.android"); + driver.quit(); + } + + +} +