From 3aa425a7b576c2e74672eb3a8731cf03afd8f38d Mon Sep 17 00:00:00 2001 From: purigarcia Date: Fri, 13 Mar 2015 09:42:18 +0100 Subject: [PATCH 01/27] upload a few automated test --- automationTest/.classpath | 27 +++ automationTest/.gitignore | 2 + automationTest/.project | 23 +++ .../org.eclipse.core.resources.prefs | 4 + .../.settings/org.eclipse.jdt.core.prefs | 5 + .../.settings/org.eclipse.m2e.core.prefs | 4 + automationTest/pom.xml | 55 ++++++ .../java/androidtest/actions/Actions.java | 26 +++ .../androidtest/models/AppDetailsView.java | 41 ++++ .../java/androidtest/models/FilesView.java | 50 +++++ .../java/androidtest/models/LoginForm.java | 75 ++++++++ .../java/androidtest/models/MainView.java | 179 ++++++++++++++++++ .../java/androidtest/models/SettingsView.java | 59 ++++++ .../java/androidtest/tests/CommonTest.java | 69 +++++++ .../test/java/androidtest/tests/Config.java | 24 +++ .../tests/CreateFolderTestSuite.java | 54 ++++++ .../androidtest/tests/LoginTestSuite.java | 128 +++++++++++++ .../androidtest/tests/UploadTestSuite.java | 88 +++++++++ 18 files changed, 913 insertions(+) create mode 100644 automationTest/.classpath create mode 100644 automationTest/.gitignore create mode 100644 automationTest/.project create mode 100644 automationTest/.settings/org.eclipse.core.resources.prefs create mode 100644 automationTest/.settings/org.eclipse.jdt.core.prefs create mode 100644 automationTest/.settings/org.eclipse.m2e.core.prefs create mode 100644 automationTest/pom.xml create mode 100644 automationTest/src/test/java/androidtest/actions/Actions.java create mode 100644 automationTest/src/test/java/androidtest/models/AppDetailsView.java create mode 100644 automationTest/src/test/java/androidtest/models/FilesView.java create mode 100644 automationTest/src/test/java/androidtest/models/LoginForm.java create mode 100644 automationTest/src/test/java/androidtest/models/MainView.java create mode 100644 automationTest/src/test/java/androidtest/models/SettingsView.java create mode 100644 automationTest/src/test/java/androidtest/tests/CommonTest.java create mode 100644 automationTest/src/test/java/androidtest/tests/Config.java create mode 100644 automationTest/src/test/java/androidtest/tests/CreateFolderTestSuite.java create mode 100644 automationTest/src/test/java/androidtest/tests/LoginTestSuite.java create mode 100644 automationTest/src/test/java/androidtest/tests/UploadTestSuite.java diff --git a/automationTest/.classpath b/automationTest/.classpath new file mode 100644 index 0000000000..53c35984d8 --- /dev/null +++ b/automationTest/.classpath @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/automationTest/.gitignore b/automationTest/.gitignore new file mode 100644 index 0000000000..7326dd9f11 --- /dev/null +++ b/automationTest/.gitignore @@ -0,0 +1,2 @@ +/target/ +.DS_Store \ No newline at end of file diff --git a/automationTest/.project b/automationTest/.project new file mode 100644 index 0000000000..b1e58409f8 --- /dev/null +++ b/automationTest/.project @@ -0,0 +1,23 @@ + + + androidtest + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/automationTest/.settings/org.eclipse.core.resources.prefs b/automationTest/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000000..f9fe34593f --- /dev/null +++ b/automationTest/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,4 @@ +eclipse.preferences.version=1 +encoding//src/main/java=UTF-8 +encoding//src/test/java=UTF-8 +encoding/=UTF-8 diff --git a/automationTest/.settings/org.eclipse.jdt.core.prefs b/automationTest/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000..abec6ca389 --- /dev/null +++ b/automationTest/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,5 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.source=1.5 diff --git a/automationTest/.settings/org.eclipse.m2e.core.prefs b/automationTest/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 0000000000..f897a7f1cb --- /dev/null +++ b/automationTest/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/automationTest/pom.xml b/automationTest/pom.xml new file mode 100644 index 0000000000..373128be64 --- /dev/null +++ b/automationTest/pom.xml @@ -0,0 +1,55 @@ + + +4.0.0 + +com.owncloud +androidtest +1.0-SNAPSHOT + + + + junit + junit + 4.11 + + + org.seleniumhq.selenium + selenium-java + 2.44.0 + + + io.selendroid + 0.9.0 + selendroid-standalone + + + io.selendroid + 0.9.0 + selendroid-client + + + io.appium + java-client + 2.1.0 + + + commons-lang + commons-lang + 2.6 + + + org.apache.httpcomponents + httpclient + 4.3.1 + + + com.google.android + android + 4.1.1.4 + provided + + + + \ No newline at end of file diff --git a/automationTest/src/test/java/androidtest/actions/Actions.java b/automationTest/src/test/java/androidtest/actions/Actions.java new file mode 100644 index 0000000000..952b01fd0f --- /dev/null +++ b/automationTest/src/test/java/androidtest/actions/Actions.java @@ -0,0 +1,26 @@ +package androidtest.actions; + +import io.appium.java_client.android.AndroidDriver; +import androidtest.models.MainView; +import androidtest.models.SettingsView; + +public class Actions { + + public static void deleteAccount (MainView mainView) { + mainView.clickOnMenuButton(); + SettingsView settingView = mainView.clickOnSettingsButton(); + deleteAccount(settingView); + + } + + public static void deleteAccount (SettingsView settingsView) { + settingsView.tapOnAccountElement(1, 1000); + settingsView.clickOnDeleteAccountElement(); + } + + public static void clickOnMainLayout(AndroidDriver driver){ + driver.tap(1, 0, 0, 1); + } + + +} diff --git a/automationTest/src/test/java/androidtest/models/AppDetailsView.java b/automationTest/src/test/java/androidtest/models/AppDetailsView.java new file mode 100644 index 0000000000..75ce4d9ff3 --- /dev/null +++ b/automationTest/src/test/java/androidtest/models/AppDetailsView.java @@ -0,0 +1,41 @@ +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/FilesView.java b/automationTest/src/test/java/androidtest/models/FilesView.java new file mode 100644 index 0000000000..73fb67f914 --- /dev/null +++ b/automationTest/src/test/java/androidtest/models/FilesView.java @@ -0,0 +1,50 @@ +package androidtest.models; + +import java.util.HashMap; + +import io.appium.java_client.android.AndroidDriver; +import io.appium.java_client.android.AndroidElement; +import io.appium.java_client.pagefactory.AndroidFindBy; +import io.appium.java_client.pagefactory.AppiumFieldDecorator; + +import org.openqa.selenium.remote.RemoteWebElement; +import org.openqa.selenium.support.CacheLookup; +import org.openqa.selenium.support.PageFactory; + +public class FilesView { + final AndroidDriver driver; + + @CacheLookup + @AndroidFindBy(id = "com.owncloud.android:id/list_root") + private AndroidElement fileLayout; + + @CacheLookup + @AndroidFindBy(id = "com.owncloud.android:id/upload_files_btn_upload") + private AndroidElement uploadButton; + + private AndroidElement fileElement; + + public FilesView (AndroidDriver driver) { + this.driver = driver; + PageFactory.initElements(new AppiumFieldDecorator(driver), this); + } + + public MainView clickOnUploadButton () { + uploadButton.click(); + MainView mainView = new MainView (driver); + return mainView; + } + + public void scrollTillFindFile (String fileName) { + HashMap scrollObject = new HashMap(); + scrollObject.put("text", fileName); + scrollObject.put("element", ( (RemoteWebElement) fileLayout).getId()); + driver.executeScript("mobile: scrollTo", scrollObject); + fileElement = (AndroidElement) driver.findElementByName(fileName); + } + + public void clickOnFileName (String fileName) { + scrollTillFindFile(fileName); + fileElement.click(); + } +} diff --git a/automationTest/src/test/java/androidtest/models/LoginForm.java b/automationTest/src/test/java/androidtest/models/LoginForm.java new file mode 100644 index 0000000000..2354269170 --- /dev/null +++ b/automationTest/src/test/java/androidtest/models/LoginForm.java @@ -0,0 +1,75 @@ +package androidtest.models; + +import org.openqa.selenium.support.CacheLookup; +import org.openqa.selenium.support.PageFactory; +import io.appium.java_client.android.AndroidDriver; +import io.appium.java_client.android.AndroidElement; +import io.appium.java_client.pagefactory.AndroidFindBy; +import io.appium.java_client.pagefactory.AppiumFieldDecorator; + +public class LoginForm { + final AndroidDriver driver; + + @CacheLookup + @AndroidFindBy(uiAutomator = "new UiSelector().description(\"Server address\")") + private AndroidElement hostUrlInput; + + @CacheLookup + @AndroidFindBy(uiAutomator = "new UiSelector().description(\"Username\")") + private AndroidElement userNameInput; + + @CacheLookup + @AndroidFindBy(uiAutomator = "new UiSelector().description(\"Password\")") + private AndroidElement passwordInput; + + @CacheLookup + @AndroidFindBy(uiAutomator = "new UiSelector().description(\"Connect\")") + private AndroidElement connectButton; + + @AndroidFindBy(uiAutomator = "new UiSelector().description(\"Testing connection\")") + private AndroidElement serverStatusText; + + @AndroidFindBy(uiAutomator = "new UiSelector().description(\"Wrong username or password\")") + private AndroidElement authStatusText; + + public LoginForm (AndroidDriver driver) { + this.driver = driver; + PageFactory.initElements(new AppiumFieldDecorator(driver), this); + } + + public void typeHostUrl (String hostUrl) { + hostUrlInput.clear(); + hostUrlInput.sendKeys(hostUrl); + driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_BACK); + } + + public void clickOnUserName () { + userNameInput.click(); + } + + public void typeUserName (String userName) { + userNameInput.clear(); + userNameInput.sendKeys(userName); + driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_BACK); + } + + public void typePassword (String password) { + passwordInput.clear(); + passwordInput.sendKeys(password); + driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_BACK); + } + + public MainView clickOnConnectButton () { + connectButton.click(); + MainView mainView = new MainView(driver); + return mainView; + } + + public AndroidElement getServerStatusTextElement () { + return serverStatusText; + } + + public AndroidElement getAuthStatusText () { + return authStatusText; + } +} diff --git a/automationTest/src/test/java/androidtest/models/MainView.java b/automationTest/src/test/java/androidtest/models/MainView.java new file mode 100644 index 0000000000..66523f9a81 --- /dev/null +++ b/automationTest/src/test/java/androidtest/models/MainView.java @@ -0,0 +1,179 @@ +package androidtest.models; + +import java.util.HashMap; +import java.util.List; + +import io.appium.java_client.android.AndroidDriver; +import io.appium.java_client.android.AndroidElement; +import io.appium.java_client.pagefactory.AndroidFindBy; +import io.appium.java_client.pagefactory.AppiumFieldDecorator; + +import org.openqa.selenium.remote.RemoteWebElement; +import org.openqa.selenium.support.CacheLookup; +import org.openqa.selenium.support.PageFactory; + +public class MainView { + final AndroidDriver driver; + + @CacheLookup + @AndroidFindBy(uiAutomator = "new UiSelector().description(\"More options\")") + private AndroidElement menuButton; + + @CacheLookup + @AndroidFindBy(id = "com.owncloud.android:id/list_root") + private AndroidElement filesLayout; + + @CacheLookup + @AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"android:id/action_bar_title\")") + private AndroidElement titleText; + + @AndroidFindBy(name = "Settings") + private AndroidElement settingsButton; + + @CacheLookup + @AndroidFindBy(uiAutomator = "new UiSelector().description(\"New folder\")") + private AndroidElement newFolderButton; + + @CacheLookup + @AndroidFindBy(uiAutomator = "new UiSelector().description(\"Upload\")") + private AndroidElement uploadButton; + + @AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"com.owncloud.android:id/user_input\")") + private AndroidElement newFolderNameField; + + @AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"android:id/button1\")") + private AndroidElement newFolderOkButton; + + private AndroidElement waitAMomentText; + + @AndroidFindBy(id = "com.owncloud.android:id/ListItemLayout") + private List listItemLayout; + + @AndroidFindBy(id = "com.owncloud.android:id/list_root") + private AndroidElement listRootLayout; + + @AndroidFindBy(name = "Remove") + private AndroidElement removeFileElement; + + @AndroidFindBy(name = "Details") + private AndroidElement detailsFileElement; + + @AndroidFindBy(name = "Remote and local") + private AndroidElement remoteAndLocalButton; + + @AndroidFindBy(name = "Files") + private AndroidElement filesElementUploadFile; + + private AndroidElement fileElement; + + private AndroidElement fileElementLayout; + + + public MainView (AndroidDriver driver) { + this.driver = driver; + PageFactory.initElements(new AppiumFieldDecorator(driver), this); + } + + public void clickOnMenuButton () { + //TODO. DETECT WHEN HAPPENS WHEN THERE IS NOT BUTTON IN THE TOPBAR + //if(menuButton.exists()){ + //menuButton.click(); + //}else{ + //Thread.sleep(10000); + //getUiDevice().pressMenu(); + //} + menuButton.click(); + } + + public SettingsView clickOnSettingsButton () { + settingsButton.click(); + SettingsView settingsView = new SettingsView(driver); + return settingsView; + } + + public SettingsView getSettingsView () { + SettingsView settingsView = new SettingsView(driver); + return settingsView; + } + + public void clickOnNewFolderButton () { + newFolderButton.click(); + } + + public void clickOnRemoveFileElement () { + removeFileElement.click(); + } + + public AppDetailsView clickOnDetailsFileElement () { + detailsFileElement.click(); + AppDetailsView appDetailsView = new AppDetailsView(driver); + return appDetailsView; + } + + public void typeNewFolderName (String newFolderName) { + newFolderNameField.clear(); + newFolderNameField.sendKeys(newFolderName); + driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_BACK); + } + + public void clickOnNewFolderOkButton () { + newFolderOkButton.click(); + waitAMomentText = (AndroidElement) driver.findElementByName("Wait a moment"); + } + + public void clickOnRemoteAndLocalButton () { + remoteAndLocalButton.click(); + waitAMomentText = (AndroidElement) driver.findElementByName("Wait a moment"); + } + + public void clickOnUploadButton () { + uploadButton.click(); + } + + public FilesView clickOnFilesElementUploadFile () { + filesElementUploadFile.click(); + FilesView filesView = new FilesView(driver); + return filesView; + } + + public AndroidElement getTitleTextElement () { + return titleText; + } + + public AndroidElement getWaitAMomentTextElement () { + return waitAMomentText; + } + + public AndroidElement getListRootElement () { + return listRootLayout; + } + + public List getListItemLayout () { + return listItemLayout; + } + + public AndroidElement getFileElement () { + return fileElement; + } + + public void tapOnFileElement (String fileName) { + scrollTillFindElement(fileName); + fileElement.tap(1, 1000); + } + + public AndroidElement scrollTillFindElement (String fileName) { + HashMap scrollObject = new HashMap(); + scrollObject.put("text", fileName); + scrollObject.put("element", ( (RemoteWebElement) filesLayout).getId()); + if(filesLayout.getAttribute("scrollable").equals("true")){ + driver.executeScript("mobile: scrollTo", scrollObject); + } + fileElement = (AndroidElement) driver.findElementByName(fileName); + fileElementLayout = (AndroidElement) driver.findElementByAndroidUIAutomator("new UiSelector().description(\"LinearLayout-"+ fileName +"\")"); + return fileElement; + } + + public AndroidElement getFileElementLayout () { + return fileElementLayout; + } +} diff --git a/automationTest/src/test/java/androidtest/models/SettingsView.java b/automationTest/src/test/java/androidtest/models/SettingsView.java new file mode 100644 index 0000000000..18c9c00872 --- /dev/null +++ b/automationTest/src/test/java/androidtest/models/SettingsView.java @@ -0,0 +1,59 @@ +package androidtest.models; + +import io.appium.java_client.android.AndroidDriver; +import io.appium.java_client.android.AndroidElement; +import io.appium.java_client.pagefactory.AndroidFindBy; +import io.appium.java_client.pagefactory.AppiumFieldDecorator; + +import org.openqa.selenium.support.CacheLookup; +import org.openqa.selenium.support.PageFactory; + +import androidtest.tests.Config; + +public class SettingsView { + final AndroidDriver driver; + + @CacheLookup + @AndroidFindBy(name = Config.userAccount) + private AndroidElement accountElement; + + @CacheLookup + @AndroidFindBy(name = Config.userAccount2) + private AndroidElement accountElement2; + + @AndroidFindBy(name = "Delete account") + private AndroidElement deleteAccountElement; + + @AndroidFindBy(name = "Change password") + private AndroidElement changePasswordElement; + + @AndroidFindBy(name = "Add account") + private AndroidElement addAccountElement; + + public SettingsView (AndroidDriver driver) { + this.driver = driver; + PageFactory.initElements(new AppiumFieldDecorator(driver), this); + } + + public void tapOnAccountElement (int fingers, int milliSeconds) { + accountElement.tap(fingers, milliSeconds); + } + + + public void tapOnAddAccount (int fingers, int milliSeconds) { + addAccountElement.tap(fingers, milliSeconds); + } + + public LoginForm clickOnDeleteAccountElement () { + deleteAccountElement.click(); + LoginForm loginForm = new LoginForm(driver); + return loginForm; + } + + public LoginForm clickOnChangePasswordElement () { + changePasswordElement.click(); + LoginForm loginForm = new LoginForm(driver); + return loginForm; + } + +} diff --git a/automationTest/src/test/java/androidtest/tests/CommonTest.java b/automationTest/src/test/java/androidtest/tests/CommonTest.java new file mode 100644 index 0000000000..b819544951 --- /dev/null +++ b/automationTest/src/test/java/androidtest/tests/CommonTest.java @@ -0,0 +1,69 @@ +package androidtest.tests; + +import java.io.File; +import java.net.URL; + +import org.openqa.selenium.By; +import org.openqa.selenium.NoSuchElementException; +import org.openqa.selenium.remote.DesiredCapabilities; + +import androidtest.models.LoginForm; +import androidtest.models.MainView; +import io.appium.java_client.android.AndroidDriver; +import io.appium.java_client.android.AndroidElement; +import junit.framework.TestCase; + +public class CommonTest extends TestCase{ + AndroidDriver driver; + final int waitingTime = 30; + + protected void setUpCommonDriver () throws Exception { + File rootPath = new File(System.getProperty("user.dir")); + File appDir = new File(rootPath,"src/test/resources"); + File app = new File(appDir,"ownCloud.apk"); + DesiredCapabilities capabilities = new DesiredCapabilities(); + capabilities.setCapability("platformName", "Android"); + capabilities.setCapability("deviceName", "Device"); + capabilities.setCapability("app", app.getAbsolutePath()); + capabilities.setCapability("app-package", "com.owncloud.android"); + capabilities.setCapability("app-activity", ".ui.activity.FileDisplayActivity"); + capabilities.setCapability("appWaitActivity", ".authentication.AuthenticatorActivity"); + driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities); + } + + protected boolean waitForTextPresent(String text, AndroidElement element) throws InterruptedException{ + for (int second = 0;;second++){ + if (second >= waitingTime) + return false; + try{ + if (text.equals(element.getText())) + break; + } catch (Exception e){ + + } + Thread.sleep(1000); + } + return true; + } + + protected boolean isElementPresent(AndroidElement element, By by) { + try { + element.findElement(by); + return true; + } catch (NoSuchElementException e) { + return false; + } + } + + protected MainView login(String url, String user, String password) throws InterruptedException { + LoginForm loginForm = new LoginForm(driver); + loginForm.typeHostUrl(url); + loginForm.clickOnUserName(); + waitForTextPresent("Secure connection established", loginForm.getServerStatusTextElement()); + assertTrue(waitForTextPresent("Secure connection established", loginForm.getServerStatusTextElement())); + loginForm.typeUserName(user); + loginForm.typePassword(password); + return loginForm.clickOnConnectButton(); + } + +} diff --git a/automationTest/src/test/java/androidtest/tests/Config.java b/automationTest/src/test/java/androidtest/tests/Config.java new file mode 100644 index 0000000000..4e1b0fe9fb --- /dev/null +++ b/automationTest/src/test/java/androidtest/tests/Config.java @@ -0,0 +1,24 @@ +package androidtest.tests; + +public final class Config { + + public static final String server = "owncloudServerVar"; + public static final Boolean hasSubdirectory = false; + public static String URL = GetURl(hasSubdirectory); + + public static final String user = "owncloudUserVar"; + public static final String password = "owncloudPasswordVar"; + public static final String user2 = "owncloudUser2Var"; + public static final String password2 = "owncloudPassword2Var"; + public static final String userAccount = user + "@"+server; + public static final String userAccount2 = user2 + "@"+server; + + public static String GetURl(Boolean hasSubdirectory){ + if(hasSubdirectory){ + return server + "/owncloud"; + }else{ + return server; + } + } + +} diff --git a/automationTest/src/test/java/androidtest/tests/CreateFolderTestSuite.java b/automationTest/src/test/java/androidtest/tests/CreateFolderTestSuite.java new file mode 100644 index 0000000000..873638406e --- /dev/null +++ b/automationTest/src/test/java/androidtest/tests/CreateFolderTestSuite.java @@ -0,0 +1,54 @@ +package androidtest.tests; + +import io.appium.java_client.android.AndroidElement; + +import org.junit.After; +import org.junit.Before; +import org.junit.runners.MethodSorters; +import org.junit.FixMethodOrder; +import org.junit.Test; + + +import androidtest.actions.Actions; +import androidtest.models.MainView; + + +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class CreateFolderTestSuite extends CommonTest{ + + @Before + public void setUp() throws Exception { + setUpCommonDriver(); + } + + + @Test + public void test6CreateNewFolder () throws Exception { + String NEW_FOLDER_NAME = "testCreateFolder"; + + MainView mainView = login(Config.URL, Config.user,Config.password); + assertTrue(waitForTextPresent("ownCloud", mainView.getTitleTextElement())); + mainView.clickOnNewFolderButton(); + mainView.typeNewFolderName(NEW_FOLDER_NAME); + mainView.clickOnNewFolderOkButton(); + assertTrue(waitForTextPresent("Wait a moment" , mainView.getWaitAMomentTextElement())); + while(mainView.getWaitAMomentTextElement().isDisplayed()){} + AndroidElement newFolderElement = mainView.scrollTillFindElement(NEW_FOLDER_NAME); + assertTrue(newFolderElement.isDisplayed()); + newFolderElement.tap(1, 1000); + mainView.clickOnRemoveFileElement(); + mainView.clickOnRemoteAndLocalButton(); + assertTrue(waitForTextPresent("Wait a moment" , mainView.getWaitAMomentTextElement())); + while(mainView.getWaitAMomentTextElement().isDisplayed()){} + Actions.deleteAccount(mainView); + } + + + @After + public void tearDown() throws Exception { + driver.removeApp("com.owncloud.android"); + driver.quit(); + } + +} + diff --git a/automationTest/src/test/java/androidtest/tests/LoginTestSuite.java b/automationTest/src/test/java/androidtest/tests/LoginTestSuite.java new file mode 100644 index 0000000000..a4cbda6638 --- /dev/null +++ b/automationTest/src/test/java/androidtest/tests/LoginTestSuite.java @@ -0,0 +1,128 @@ +package androidtest.tests; + +import org.junit.After; +import org.junit.Before; +import org.junit.runners.MethodSorters; +import org.junit.FixMethodOrder; +import org.junit.Test; +import org.openqa.selenium.ScreenOrientation; + + +import androidtest.actions.Actions; +import androidtest.models.LoginForm; +import androidtest.models.MainView; +import androidtest.models.SettingsView; + +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class LoginTestSuite extends CommonTest{ + + @Before + public void setUp() throws Exception { + setUpCommonDriver(); + } + + @Test + public void test1LoginPortrait () throws Exception { + + System.out.println("Hello" + Config.server); + String testName = "loginPortrait"; + driver.rotate(ScreenOrientation.PORTRAIT); + + MainView mainView = login(Config.URL, Config.user,Config.password); + assertTrue(waitForTextPresent("ownCloud", mainView.getTitleTextElement())); + //TO DO. detect in which view is. it can be files view or settings view + /*if(mainView.getTitleTextElement().equals("ownCloud") || mainView.getTitleTextElement().equals("Settings")){ + if(mainView.getTitleTextElement().getText().equals("ownCloud")){ + assertTrue(waitForTextPresent("ownCloud", mainView.getTitleTextElement())); + }else{ + assertTrue(waitForTextPresent("Settings", mainView.getTitleTextElement())); + } + fail(testName); + }*/ + Actions.deleteAccount(mainView); + } + + @Test + public void test2LoginLandscape () throws Exception { + + String testName = "loginLandscape"; + driver.rotate(ScreenOrientation.LANDSCAPE); + MainView mainView = login(Config.URL, Config.user,Config.password); + assertTrue(waitForTextPresent("ownCloud", mainView.getTitleTextElement())); + //TO DO. detect in which view is. it can be files view or settings view + Actions.deleteAccount(mainView); + } + + + @Test + public void test3MultiAccountRotate () throws Exception { + + String testName = "MultiAccountRotate"; + driver.rotate(ScreenOrientation.LANDSCAPE); + MainView mainView = login(Config.URL, Config.user,Config.password); + assertTrue(waitForTextPresent("ownCloud", mainView.getTitleTextElement())); + + driver.rotate(ScreenOrientation.PORTRAIT); + mainView.clickOnMenuButton(); + SettingsView settingsView = mainView.clickOnSettingsButton(); + settingsView.tapOnAddAccount(1, 1000); + mainView = login(Config.URL, Config.user2,Config.password2); + + assertTrue(waitForTextPresent("Settings", mainView.getTitleTextElement())); + //TO DO. detect in which view is. it can be files view or settings view + //Actions.deleteAccount(mainView); + Actions.deleteAccount(settingsView); + //TO DO. Delete the second user + } + + @Test + public void test4ExistingAccountRotate () throws Exception { + + String testName = "ExistingAccountRotate"; + driver.rotate(ScreenOrientation.PORTRAIT); + MainView mainView = login(Config.URL, Config.user,Config.password); + assertTrue(waitForTextPresent("ownCloud", mainView.getTitleTextElement())); + + driver.rotate(ScreenOrientation.LANDSCAPE); + mainView.clickOnMenuButton(); + SettingsView settingsView = mainView.clickOnSettingsButton(); + settingsView.tapOnAddAccount(1, 1000); + LoginForm loginForm = new LoginForm(driver); + loginForm.typeHostUrl(Config.URL); + loginForm.clickOnUserName(); + waitForTextPresent("Secure connection established", loginForm.getServerStatusTextElement()); + assertTrue(waitForTextPresent("Secure connection established", loginForm.getServerStatusTextElement())); + loginForm.typeUserName(Config.user); + loginForm.typePassword(Config.password); + mainView = loginForm.clickOnConnectButton(); + + assertTrue(waitForTextPresent("An account for the same user and server already exists in the device", loginForm.getAuthStatusText())); + driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_BACK); + Actions.deleteAccount(settingsView); + } + + + public void test5ChangePasswordWrong () throws Exception { + + MainView mainView = login(Config.URL, Config.user,Config.password); + assertTrue(waitForTextPresent("ownCloud", mainView.getTitleTextElement())); + mainView.clickOnMenuButton(); + SettingsView settingView = mainView.clickOnSettingsButton(); + settingView.tapOnAccountElement(1, 1000); + LoginForm changePasswordForm = settingView.clickOnChangePasswordElement(); + changePasswordForm.typePassword("WrongPassword"); + changePasswordForm.clickOnConnectButton(); + assertTrue(waitForTextPresent("Wrong username or password", changePasswordForm.getAuthStatusText())); + driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_BACK); + Actions.deleteAccount(settingView); + } + + + @After + public void tearDown() throws Exception { + driver.removeApp("com.owncloud.android"); + driver.quit(); + } + + +} diff --git a/automationTest/src/test/java/androidtest/tests/UploadTestSuite.java b/automationTest/src/test/java/androidtest/tests/UploadTestSuite.java new file mode 100644 index 0000000000..4b1a5006d8 --- /dev/null +++ b/automationTest/src/test/java/androidtest/tests/UploadTestSuite.java @@ -0,0 +1,88 @@ +package androidtest.tests; + + +import io.appium.java_client.MobileBy; + +import org.junit.After; +import org.junit.Before; +import org.junit.runners.MethodSorters; +import org.junit.FixMethodOrder; +import org.junit.Test; + +import androidtest.actions.Actions; +import androidtest.models.AppDetailsView; +import androidtest.models.FilesView; +import androidtest.models.MainView; + + +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class UploadTestSuite extends CommonTest{ + + @Before + public void setUp() throws Exception { + setUpCommonDriver(); + } + + @Test + public void test1UploadFile () throws Exception { + String FILE_NAME = "test"; + + MainView mainView = login(Config.URL, Config.user,Config.password); + assertTrue(waitForTextPresent("ownCloud", mainView.getTitleTextElement())); + mainView.clickOnUploadButton(); + FilesView filesView = mainView.clickOnFilesElementUploadFile(); + filesView.clickOnFileName(FILE_NAME); + MainView mainViewAfterUploadFile = filesView.clickOnUploadButton(); + //TO DO. detect when the file is successfully uploaded + Thread.sleep(3000); + mainViewAfterUploadFile.scrollTillFindElement(FILE_NAME); + assertTrue(mainViewAfterUploadFile.getFileElement().isDisplayed()); + mainViewAfterUploadFile.tapOnFileElement(FILE_NAME); + mainViewAfterUploadFile.clickOnRemoveFileElement(); + mainViewAfterUploadFile.clickOnRemoteAndLocalButton(); + assertTrue(waitForTextPresent("Wait a moment" , mainViewAfterUploadFile.getWaitAMomentTextElement())); + while(mainViewAfterUploadFile.getWaitAMomentTextElement().isDisplayed()){} + Actions.deleteAccount(mainViewAfterUploadFile); + + } + + @Test + public void test2KeepFileUpToDate () throws Exception { + String FILE_NAME = "test"; + + MainView mainView = login(Config.URL, Config.user,Config.password); + assertTrue(waitForTextPresent("ownCloud", mainView.getTitleTextElement())); + mainView.clickOnUploadButton(); + FilesView filesView = mainView.clickOnFilesElementUploadFile(); + filesView.clickOnFileName(FILE_NAME); + MainView mainViewAfterUploadFile = filesView.clickOnUploadButton(); + //TO DO. detect when the file is successfully uploaded + Thread.sleep(3000); + mainViewAfterUploadFile.scrollTillFindElement(FILE_NAME); + assertTrue(mainViewAfterUploadFile.getFileElement().isDisplayed()); + mainViewAfterUploadFile.tapOnFileElement(FILE_NAME); + AppDetailsView appDetailsView = mainViewAfterUploadFile.clickOnDetailsFileElement(); + appDetailsView.checkKeepFileUpToDateCheckbox(); + //assertTrue(appDetailsView.getProgressBar().isDisplayed()); + Thread.sleep(3000); + driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_BACK); + assertTrue(isElementPresent(mainViewAfterUploadFile.getFileElementLayout(), MobileBy.id("com.owncloud.android:id/imageView3"))); + mainViewAfterUploadFile.tapOnFileElement(FILE_NAME); + mainViewAfterUploadFile.clickOnRemoveFileElement(); + mainViewAfterUploadFile.clickOnRemoteAndLocalButton(); + assertTrue(waitForTextPresent("Wait a moment" , mainViewAfterUploadFile.getWaitAMomentTextElement())); + while(mainViewAfterUploadFile.getWaitAMomentTextElement().isDisplayed()){} + Actions.deleteAccount(mainViewAfterUploadFile); + + } + + + @After + public void tearDown() throws Exception { + driver.removeApp("com.owncloud.android"); + driver.quit(); + } + + +} + From 14da84b827b2ed966437263e7a3d6753cf546ec4 Mon Sep 17 00:00:00 2001 From: purigarcia Date: Wed, 18 Mar 2015 16:32:10 +0100 Subject: [PATCH 02/27] Add sunfire plugin to execute test as mvn test --- automationTest/pom.xml | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/automationTest/pom.xml b/automationTest/pom.xml index 373128be64..eded8e819a 100644 --- a/automationTest/pom.xml +++ b/automationTest/pom.xml @@ -7,7 +7,22 @@ com.owncloud androidtest 1.0-SNAPSHOT - + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.18.1 + + + **/*Test**.java + + + + + + junit @@ -17,7 +32,7 @@ org.seleniumhq.selenium selenium-java - 2.44.0 + 2.45.0 io.selendroid From d8e954d2d3fd0a14e1b24c3ea86d439e7e0b483e Mon Sep 17 00:00:00 2001 From: purigarcia Date: Wed, 25 Mar 2015 18:54:10 +0100 Subject: [PATCH 03/27] add id and contentdescription to a layout --- res/layout/file_details_empty.xml | 2 +- res/layout/files.xml | 2 ++ res/values/strings.xml | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/res/layout/file_details_empty.xml b/res/layout/file_details_empty.xml index 5d16b0724e..d24295443f 100644 --- a/res/layout/file_details_empty.xml +++ b/res/layout/file_details_empty.xml @@ -21,7 +21,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:background="#F7F7F7" - android:orientation="vertical" > + android:orientation="vertical"> Download Refresh file File was renamed to %1$s during upload + List Layout Share link Unshare link Yes From ba1470a9884507fa57b2b01fdb9c601f52587b83 Mon Sep 17 00:00:00 2001 From: purigarcia Date: Thu, 9 Apr 2015 10:41:42 +0200 Subject: [PATCH 04/27] add new test cases --- automationTest/.classpath | 2 +- automationTest/.gitignore | 2 +- .../.settings/org.eclipse.jdt.core.prefs | 13 +- .../java/androidtest/actions/Actions.java | 106 +++++++++++++++-- .../androidtest/models/CertificatePopUp.java | 29 +++++ .../models/ElementMenuOptions.java | 55 +++++++++ .../java/androidtest/models/FilesView.java | 16 +-- .../java/androidtest/models/LoginForm.java | 25 +++- .../java/androidtest/models/MainView.java | 111 ++++++------------ .../java/androidtest/models/MenuList.java | 27 +++++ .../java/androidtest/models/MoveView.java | 37 ++++++ .../androidtest/models/NewFolderPopUp.java | 36 ++++++ .../models/RemoveConfirmationView.java | 26 ++++ .../androidtest/models/WaitAMomentPopUp.java | 24 ++++ .../test/java/androidtest/tests/.gitignore | 1 + .../tests/{CommonTest.java => Common.java} | 46 +++++--- .../test/java/androidtest/tests/Config.java | 19 +-- .../tests/CreateFolderTestSuite.java | 47 ++++---- .../tests/DeleteFileTestSuite.java | 47 ++++++++ .../tests/DeleteFolderTestSuite.java | 52 ++++++++ .../androidtest/tests/LoginTestSuite.java | 70 +++-------- .../androidtest/tests/LogoutTestSuite.java | 39 ++++++ .../androidtest/tests/MoveFileTestSuite.java | 78 ++++++++++++ .../tests/MoveFolderTestSuite.java | 78 ++++++++++++ .../tests/RenameFileTestSuite.java | 70 +++++++++++ .../tests/RenameFolderTestSuite.java | 68 +++++++++++ .../androidtest/tests/UploadTestSuite.java | 81 ++++++------- 27 files changed, 963 insertions(+), 242 deletions(-) create mode 100644 automationTest/src/test/java/androidtest/models/CertificatePopUp.java create mode 100644 automationTest/src/test/java/androidtest/models/ElementMenuOptions.java create mode 100644 automationTest/src/test/java/androidtest/models/MenuList.java create mode 100644 automationTest/src/test/java/androidtest/models/MoveView.java create mode 100644 automationTest/src/test/java/androidtest/models/NewFolderPopUp.java create mode 100644 automationTest/src/test/java/androidtest/models/RemoveConfirmationView.java create mode 100644 automationTest/src/test/java/androidtest/models/WaitAMomentPopUp.java create mode 100644 automationTest/src/test/java/androidtest/tests/.gitignore rename automationTest/src/test/java/androidtest/tests/{CommonTest.java => Common.java} (64%) create mode 100644 automationTest/src/test/java/androidtest/tests/DeleteFileTestSuite.java create mode 100644 automationTest/src/test/java/androidtest/tests/DeleteFolderTestSuite.java create mode 100644 automationTest/src/test/java/androidtest/tests/LogoutTestSuite.java create mode 100644 automationTest/src/test/java/androidtest/tests/MoveFileTestSuite.java create mode 100644 automationTest/src/test/java/androidtest/tests/MoveFolderTestSuite.java create mode 100644 automationTest/src/test/java/androidtest/tests/RenameFileTestSuite.java create mode 100644 automationTest/src/test/java/androidtest/tests/RenameFolderTestSuite.java diff --git a/automationTest/.classpath b/automationTest/.classpath index 53c35984d8..069344d37a 100644 --- a/automationTest/.classpath +++ b/automationTest/.classpath @@ -13,7 +13,7 @@ - + diff --git a/automationTest/.gitignore b/automationTest/.gitignore index 7326dd9f11..3fe891d76b 100644 --- a/automationTest/.gitignore +++ b/automationTest/.gitignore @@ -1,2 +1,2 @@ /target/ -.DS_Store \ No newline at end of file +src/test/java/androidtest/tests/Config.java diff --git a/automationTest/.settings/org.eclipse.jdt.core.prefs b/automationTest/.settings/org.eclipse.jdt.core.prefs index abec6ca389..62492222ad 100644 --- a/automationTest/.settings/org.eclipse.jdt.core.prefs +++ b/automationTest/.settings/org.eclipse.jdt.core.prefs @@ -1,5 +1,12 @@ eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 -org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning -org.eclipse.jdt.core.compiler.source=1.5 +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/automationTest/src/test/java/androidtest/actions/Actions.java b/automationTest/src/test/java/androidtest/actions/Actions.java index 952b01fd0f..a89f5de527 100644 --- a/automationTest/src/test/java/androidtest/actions/Actions.java +++ b/automationTest/src/test/java/androidtest/actions/Actions.java @@ -1,26 +1,112 @@ package androidtest.actions; +import java.util.HashMap; + +import org.openqa.selenium.NoSuchElementException; +import org.openqa.selenium.remote.RemoteWebElement; + import io.appium.java_client.android.AndroidDriver; +import io.appium.java_client.android.AndroidElement; + +import org.openqa.selenium.support.ui.ExpectedConditions; +import org.openqa.selenium.support.ui.WebDriverWait; + +import androidtest.models.CertificatePopUp; +import androidtest.models.ElementMenuOptions; +import androidtest.models.FilesView; +import androidtest.models.LoginForm; import androidtest.models.MainView; +import androidtest.models.MenuList; +import androidtest.models.NewFolderPopUp; +import androidtest.models.RemoveConfirmationView; import androidtest.models.SettingsView; +import androidtest.models.WaitAMomentPopUp; +import androidtest.tests.Common; public class Actions { - - public static void deleteAccount (MainView mainView) { - mainView.clickOnMenuButton(); - SettingsView settingView = mainView.clickOnSettingsButton(); - deleteAccount(settingView); - + + public static MainView login(String url, String user, String password, Boolean isTrusted, AndroidDriver driver) throws InterruptedException { + LoginForm loginForm = new LoginForm(driver); + CertificatePopUp certificatePopUp = loginForm.typeHostUrl(url); + if(!isTrusted){ + driver.runAppInBackground(3); + WebDriverWait wait = new WebDriverWait(driver, 30); + wait.until(ExpectedConditions.visibilityOf(certificatePopUp.getOkButtonElement())); + certificatePopUp.clickOnOkButton(); + } + loginForm.typeUserName(user); + loginForm.typePassword(password); + //TODO. Assert related to check the connection? + return loginForm.clickOnConnectButton(); } - + + public static WaitAMomentPopUp createFolder(String folderName, MainView mainView){ + NewFolderPopUp newFolderPopUp = mainView.clickOnNewFolderButton(); + newFolderPopUp.typeNewFolderName(folderName); + WaitAMomentPopUp waitAMomentPopUp = newFolderPopUp.clickOnNewFolderOkButton(); + //TODO. assert here + return waitAMomentPopUp; + } + + + public static AndroidElement scrollTillFindElement (String elementName, AndroidElement element, AndroidDriver driver) { + AndroidElement fileElement; + + if(element.getAttribute("scrollable").equals("true")){ + HashMap 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{ + fileElement = (AndroidElement) driver.findElementByName(elementName); + ElementMenuOptions menuOptions = mainView.longPressOnElement(elementName); + RemoveConfirmationView removeConfirmationView = menuOptions.clickOnRemove();; + waitAMomentPopUp = removeConfirmationView.clickOnRemoteAndLocalButton(); + Common.waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100); + }catch(NoSuchElementException e){ + fileElement=null; + } + return fileElement; + } + + public static MainView uploadFile(String elementName, MainView mainView) throws InterruptedException{ + mainView.clickOnUploadButton(); + FilesView filesView = mainView.clickOnFilesElementUploadFile(); + filesView.clickOnFileName(elementName); + MainView mainViewAfterUploadFile = filesView.clickOnUploadButton(); + //TO DO. detect when the file is successfully uploaded + Thread.sleep(15000); + return mainViewAfterUploadFile; + } + + } diff --git a/automationTest/src/test/java/androidtest/models/CertificatePopUp.java b/automationTest/src/test/java/androidtest/models/CertificatePopUp.java new file mode 100644 index 0000000000..dbcffcc53e --- /dev/null +++ b/automationTest/src/test/java/androidtest/models/CertificatePopUp.java @@ -0,0 +1,29 @@ +package androidtest.models; + +import io.appium.java_client.android.AndroidDriver; +import io.appium.java_client.android.AndroidElement; +import io.appium.java_client.pagefactory.AndroidFindBy; +import io.appium.java_client.pagefactory.AppiumFieldDecorator; + +import org.openqa.selenium.support.PageFactory; + +public class CertificatePopUp { + final AndroidDriver driver; + + @AndroidFindBy(name = "OK") + private AndroidElement okButton; + + public CertificatePopUp (AndroidDriver driver) { + this.driver = driver; + PageFactory.initElements(new AppiumFieldDecorator(driver), this); + } + + public void clickOnOkButton () { + okButton.click(); + } + + public AndroidElement getOkButtonElement () { + return okButton; + } + +} diff --git a/automationTest/src/test/java/androidtest/models/ElementMenuOptions.java b/automationTest/src/test/java/androidtest/models/ElementMenuOptions.java new file mode 100644 index 0000000000..090e038bd6 --- /dev/null +++ b/automationTest/src/test/java/androidtest/models/ElementMenuOptions.java @@ -0,0 +1,55 @@ +package androidtest.models; + +import io.appium.java_client.android.AndroidDriver; +import io.appium.java_client.android.AndroidElement; +import io.appium.java_client.pagefactory.AndroidFindBy; +import io.appium.java_client.pagefactory.AppiumFieldDecorator; + +import org.openqa.selenium.support.PageFactory; + +public class ElementMenuOptions { + + final AndroidDriver driver; + + @AndroidFindBy(name = "Details") + private AndroidElement detailsFileElement; + + @AndroidFindBy(name = "Rename") + private AndroidElement renameFileElement; + + @AndroidFindBy(name = "Remove") + private AndroidElement removeFileElement; + + @AndroidFindBy(name = "Move") + private AndroidElement moveElement; + + public ElementMenuOptions (AndroidDriver driver) { + this.driver = driver; + PageFactory.initElements(new AppiumFieldDecorator(driver), this); + } + + public AppDetailsView clickOnDetails () { + detailsFileElement.click(); + AppDetailsView appDetailsView = new AppDetailsView(driver); + return appDetailsView; + } + + public RemoveConfirmationView clickOnRemove () { + removeFileElement.click(); + RemoveConfirmationView removeConfirmationView = new RemoveConfirmationView(driver); + return removeConfirmationView; + } + + + public MoveView clickOnMove () { + moveElement.click(); + MoveView moveView = new MoveView(driver); + return moveView; + } + + public NewFolderPopUp clickOnRename () { + renameFileElement.click(); + NewFolderPopUp newFolderPopUp = new NewFolderPopUp(driver); + return newFolderPopUp; + } +} diff --git a/automationTest/src/test/java/androidtest/models/FilesView.java b/automationTest/src/test/java/androidtest/models/FilesView.java index 73fb67f914..c913b1045d 100644 --- a/automationTest/src/test/java/androidtest/models/FilesView.java +++ b/automationTest/src/test/java/androidtest/models/FilesView.java @@ -1,22 +1,19 @@ package androidtest.models; -import java.util.HashMap; - import io.appium.java_client.android.AndroidDriver; import io.appium.java_client.android.AndroidElement; import io.appium.java_client.pagefactory.AndroidFindBy; import io.appium.java_client.pagefactory.AppiumFieldDecorator; - -import org.openqa.selenium.remote.RemoteWebElement; import org.openqa.selenium.support.CacheLookup; import org.openqa.selenium.support.PageFactory; +import androidtest.actions.Actions; -public class FilesView { +public class FilesView{ final AndroidDriver driver; @CacheLookup @AndroidFindBy(id = "com.owncloud.android:id/list_root") - private AndroidElement fileLayout; + private AndroidElement filesLayout; @CacheLookup @AndroidFindBy(id = "com.owncloud.android:id/upload_files_btn_upload") @@ -35,12 +32,9 @@ public class FilesView { return mainView; } + //change to scrollTillFindElement public void scrollTillFindFile (String fileName) { - HashMap scrollObject = new HashMap(); - scrollObject.put("text", fileName); - scrollObject.put("element", ( (RemoteWebElement) fileLayout).getId()); - driver.executeScript("mobile: scrollTo", scrollObject); - fileElement = (AndroidElement) driver.findElementByName(fileName); + fileElement = Actions.scrollTillFindElement (fileName,filesLayout,driver); } public void clickOnFileName (String fileName) { diff --git a/automationTest/src/test/java/androidtest/models/LoginForm.java b/automationTest/src/test/java/androidtest/models/LoginForm.java index 2354269170..ea78102e94 100644 --- a/automationTest/src/test/java/androidtest/models/LoginForm.java +++ b/automationTest/src/test/java/androidtest/models/LoginForm.java @@ -2,6 +2,7 @@ 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; @@ -37,10 +38,11 @@ public class LoginForm { PageFactory.initElements(new AppiumFieldDecorator(driver), this); } - public void typeHostUrl (String hostUrl) { + public CertificatePopUp typeHostUrl (String hostUrl) { hostUrlInput.clear(); - hostUrlInput.sendKeys(hostUrl); - driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_BACK); + hostUrlInput.sendKeys(hostUrl + "\n"); + CertificatePopUp certificatePopUp = new CertificatePopUp(driver); + return certificatePopUp; } public void clickOnUserName () { @@ -50,13 +52,13 @@ public class LoginForm { public void typeUserName (String userName) { userNameInput.clear(); userNameInput.sendKeys(userName); - driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_BACK); + driver.hideKeyboard(); } public void typePassword (String password) { passwordInput.clear(); passwordInput.sendKeys(password); - driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_BACK); + driver.hideKeyboard(); } public MainView clickOnConnectButton () { @@ -65,6 +67,19 @@ public class LoginForm { return mainView; } + public AndroidElement gethostUrlInput () { + return hostUrlInput; + } + + public AndroidElement getUserNameInput () { + return userNameInput; + } + + public AndroidElement getPasswordInput () { + return passwordInput; + } + + public AndroidElement getServerStatusTextElement () { return serverStatusText; } diff --git a/automationTest/src/test/java/androidtest/models/MainView.java b/automationTest/src/test/java/androidtest/models/MainView.java index 66523f9a81..6228f0e3be 100644 --- a/automationTest/src/test/java/androidtest/models/MainView.java +++ b/automationTest/src/test/java/androidtest/models/MainView.java @@ -1,6 +1,5 @@ package androidtest.models; -import java.util.HashMap; import java.util.List; import io.appium.java_client.android.AndroidDriver; @@ -8,14 +7,15 @@ import io.appium.java_client.android.AndroidElement; import io.appium.java_client.pagefactory.AndroidFindBy; import io.appium.java_client.pagefactory.AppiumFieldDecorator; -import org.openqa.selenium.remote.RemoteWebElement; +import org.openqa.selenium.NoSuchElementException; import org.openqa.selenium.support.CacheLookup; import org.openqa.selenium.support.PageFactory; +import androidtest.actions.Actions; + public class MainView { final AndroidDriver driver; - @CacheLookup @AndroidFindBy(uiAutomator = "new UiSelector().description(\"More options\")") private AndroidElement menuButton; @@ -27,8 +27,8 @@ public class MainView { @AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"android:id/action_bar_title\")") private AndroidElement titleText; - @AndroidFindBy(name = "Settings") - private AndroidElement settingsButton; + @AndroidFindBy(id = "android:id/progress_circular") + private AndroidElement progressCircular; @CacheLookup @AndroidFindBy(uiAutomator = "new UiSelector().description(\"New folder\")") @@ -38,12 +38,6 @@ public class MainView { @AndroidFindBy(uiAutomator = "new UiSelector().description(\"Upload\")") private AndroidElement uploadButton; - @AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"com.owncloud.android:id/user_input\")") - private AndroidElement newFolderNameField; - - @AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"android:id/button1\")") - private AndroidElement newFolderOkButton; - private AndroidElement waitAMomentText; @AndroidFindBy(id = "com.owncloud.android:id/ListItemLayout") @@ -52,15 +46,6 @@ public class MainView { @AndroidFindBy(id = "com.owncloud.android:id/list_root") private AndroidElement listRootLayout; - @AndroidFindBy(name = "Remove") - private AndroidElement removeFileElement; - - @AndroidFindBy(name = "Details") - private AndroidElement detailsFileElement; - - @AndroidFindBy(name = "Remote and local") - private AndroidElement remoteAndLocalButton; - @AndroidFindBy(name = "Files") private AndroidElement filesElementUploadFile; @@ -68,27 +53,19 @@ public class MainView { private AndroidElement fileElementLayout; + private static String localFileIndicator = "com.owncloud.android:id/localFileIndicator"; + private static String favoriteFileIndicator = "com.owncloud.android:id/favoriteIcon"; + public MainView (AndroidDriver driver) { this.driver = driver; PageFactory.initElements(new AppiumFieldDecorator(driver), this); } - public void clickOnMenuButton () { - //TODO. DETECT WHEN HAPPENS WHEN THERE IS NOT BUTTON IN THE TOPBAR - //if(menuButton.exists()){ - //menuButton.click(); - //}else{ - //Thread.sleep(10000); - //getUiDevice().pressMenu(); - //} + public MenuList clickOnMenuButton () { menuButton.click(); - } - - public SettingsView clickOnSettingsButton () { - settingsButton.click(); - SettingsView settingsView = new SettingsView(driver); - return settingsView; + MenuList menuList = new MenuList (driver); + return menuList; } public SettingsView getSettingsView () { @@ -96,34 +73,10 @@ public class MainView { return settingsView; } - public void clickOnNewFolderButton () { + public NewFolderPopUp clickOnNewFolderButton () { newFolderButton.click(); - } - - public void clickOnRemoveFileElement () { - removeFileElement.click(); - } - - public AppDetailsView clickOnDetailsFileElement () { - detailsFileElement.click(); - AppDetailsView appDetailsView = new AppDetailsView(driver); - return appDetailsView; - } - - public void typeNewFolderName (String newFolderName) { - newFolderNameField.clear(); - newFolderNameField.sendKeys(newFolderName); - driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_BACK); - } - - public void clickOnNewFolderOkButton () { - newFolderOkButton.click(); - waitAMomentText = (AndroidElement) driver.findElementByName("Wait a moment"); - } - - public void clickOnRemoteAndLocalButton () { - remoteAndLocalButton.click(); - waitAMomentText = (AndroidElement) driver.findElementByName("Wait a moment"); + NewFolderPopUp newFolderPopUp = new NewFolderPopUp(driver); + return newFolderPopUp; } public void clickOnUploadButton () { @@ -156,24 +109,38 @@ public class MainView { return fileElement; } - public void tapOnFileElement (String fileName) { - scrollTillFindElement(fileName); - fileElement.tap(1, 1000); + public ElementMenuOptions longPressOnElement (String elementName) { + scrollTillFindElement(elementName).tap(1, 1000); + //fileElement.tap(1, 1000); + ElementMenuOptions menuOptions = new ElementMenuOptions(driver); + return menuOptions; } - public AndroidElement scrollTillFindElement (String fileName) { - HashMap scrollObject = new HashMap(); - scrollObject.put("text", fileName); - scrollObject.put("element", ( (RemoteWebElement) filesLayout).getId()); - if(filesLayout.getAttribute("scrollable").equals("true")){ - driver.executeScript("mobile: scrollTo", scrollObject); + public AndroidElement scrollTillFindElement (String elementName) { + fileElement = Actions.scrollTillFindElement (elementName,filesLayout,driver); + try { + fileElementLayout = (AndroidElement) driver.findElementByAndroidUIAutomator("new UiSelector().description(\"LinearLayout-"+ elementName +"\")"); + } catch (NoSuchElementException e) { + fileElementLayout = null; } - fileElement = (AndroidElement) driver.findElementByName(fileName); - fileElementLayout = (AndroidElement) driver.findElementByAndroidUIAutomator("new UiSelector().description(\"LinearLayout-"+ fileName +"\")"); return fileElement; } public AndroidElement getFileElementLayout () { return fileElementLayout; } + + public AndroidElement getProgressCircular () { + return progressCircular; + } + + public static String getLocalFileIndicator() { + return localFileIndicator; + } + + public static String getFavoriteFileIndicator() { + return favoriteFileIndicator; + } + + } diff --git a/automationTest/src/test/java/androidtest/models/MenuList.java b/automationTest/src/test/java/androidtest/models/MenuList.java new file mode 100644 index 0000000000..466fa1c70a --- /dev/null +++ b/automationTest/src/test/java/androidtest/models/MenuList.java @@ -0,0 +1,27 @@ +package androidtest.models; + +import org.openqa.selenium.support.PageFactory; + +import io.appium.java_client.android.AndroidDriver; +import io.appium.java_client.android.AndroidElement; +import io.appium.java_client.pagefactory.AndroidFindBy; +import io.appium.java_client.pagefactory.AppiumFieldDecorator; + +public class MenuList { + + final AndroidDriver driver; + + @AndroidFindBy(name = "Settings") + private AndroidElement settingsButton; + + public MenuList (AndroidDriver driver) { + this.driver = driver; + PageFactory.initElements(new AppiumFieldDecorator(driver), this); + } + + public SettingsView clickOnSettingsButton () { + settingsButton.click(); + SettingsView settingsView = new SettingsView(driver); + return settingsView; + } +} diff --git a/automationTest/src/test/java/androidtest/models/MoveView.java b/automationTest/src/test/java/androidtest/models/MoveView.java new file mode 100644 index 0000000000..f54ba284d1 --- /dev/null +++ b/automationTest/src/test/java/androidtest/models/MoveView.java @@ -0,0 +1,37 @@ +package androidtest.models; + +import io.appium.java_client.android.AndroidDriver; +import io.appium.java_client.android.AndroidElement; +import io.appium.java_client.pagefactory.AndroidFindBy; +import io.appium.java_client.pagefactory.AppiumFieldDecorator; + +import org.openqa.selenium.support.CacheLookup; +import org.openqa.selenium.support.PageFactory; + +import androidtest.actions.Actions; + +public class MoveView { + final AndroidDriver driver; + + @CacheLookup + @AndroidFindBy(id = "com.owncloud.android:id/list_root") + private AndroidElement filesLayout; + + @AndroidFindBy(name = "Choose") + private AndroidElement chooseButton; + + public MoveView (AndroidDriver driver) { + this.driver = driver; + PageFactory.initElements(new AppiumFieldDecorator(driver), this); + } + + public WaitAMomentPopUp clickOnChoose () { + chooseButton.click(); + WaitAMomentPopUp waitAMomentPopUp = new WaitAMomentPopUp(driver); + return waitAMomentPopUp; + } + + public AndroidElement scrollTillFindElement (String elementName) { + return Actions.scrollTillFindElement (elementName,filesLayout,driver); + } +} \ No newline at end of file diff --git a/automationTest/src/test/java/androidtest/models/NewFolderPopUp.java b/automationTest/src/test/java/androidtest/models/NewFolderPopUp.java new file mode 100644 index 0000000000..658130ddac --- /dev/null +++ b/automationTest/src/test/java/androidtest/models/NewFolderPopUp.java @@ -0,0 +1,36 @@ +package androidtest.models; + +import org.openqa.selenium.support.PageFactory; + +import io.appium.java_client.android.AndroidDriver; +import io.appium.java_client.android.AndroidElement; +import io.appium.java_client.pagefactory.AndroidFindBy; +import io.appium.java_client.pagefactory.AppiumFieldDecorator; + +public class NewFolderPopUp { + + final AndroidDriver driver; + + @AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"android:id/button1\")") + private AndroidElement newFolderOkButton; + + @AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"com.owncloud.android:id/user_input\")") + private AndroidElement newFolderNameField; + + public NewFolderPopUp (AndroidDriver driver) { + this.driver = driver; + PageFactory.initElements(new AppiumFieldDecorator(driver), this); + } + + public void typeNewFolderName (String newFolderName) { + newFolderNameField.clear(); + newFolderNameField.sendKeys(newFolderName); + driver.hideKeyboard(); + } + + public WaitAMomentPopUp clickOnNewFolderOkButton () { + newFolderOkButton.click(); + WaitAMomentPopUp waitAMomentPopUp = new WaitAMomentPopUp(driver); + return waitAMomentPopUp; + } +} diff --git a/automationTest/src/test/java/androidtest/models/RemoveConfirmationView.java b/automationTest/src/test/java/androidtest/models/RemoveConfirmationView.java new file mode 100644 index 0000000000..e9a1ba9d1d --- /dev/null +++ b/automationTest/src/test/java/androidtest/models/RemoveConfirmationView.java @@ -0,0 +1,26 @@ +package androidtest.models; + +import io.appium.java_client.android.AndroidDriver; +import io.appium.java_client.android.AndroidElement; +import io.appium.java_client.pagefactory.AndroidFindBy; +import io.appium.java_client.pagefactory.AppiumFieldDecorator; + +import org.openqa.selenium.support.PageFactory; + +public class RemoveConfirmationView { + final AndroidDriver driver; + + @AndroidFindBy(name = "Remote and local") + private AndroidElement remoteAndLocalButton; + + public RemoveConfirmationView (AndroidDriver driver) { + this.driver = driver; + PageFactory.initElements(new AppiumFieldDecorator(driver), this); + } + + public WaitAMomentPopUp clickOnRemoteAndLocalButton () { + remoteAndLocalButton.click(); + WaitAMomentPopUp waitAMomentPopUp = new WaitAMomentPopUp(driver); + return waitAMomentPopUp; + } +} diff --git a/automationTest/src/test/java/androidtest/models/WaitAMomentPopUp.java b/automationTest/src/test/java/androidtest/models/WaitAMomentPopUp.java new file mode 100644 index 0000000000..f566e4a208 --- /dev/null +++ b/automationTest/src/test/java/androidtest/models/WaitAMomentPopUp.java @@ -0,0 +1,24 @@ +package androidtest.models; + +import org.openqa.selenium.support.PageFactory; + +import io.appium.java_client.android.AndroidDriver; +import io.appium.java_client.android.AndroidElement; +import io.appium.java_client.pagefactory.AndroidFindBy; +import io.appium.java_client.pagefactory.AppiumFieldDecorator; + +public class WaitAMomentPopUp { + final AndroidDriver driver; + + @AndroidFindBy(name = "Wait a moment") + private AndroidElement waitAMomentText; + + public WaitAMomentPopUp (AndroidDriver driver) { + this.driver = driver; + PageFactory.initElements(new AppiumFieldDecorator(driver), this); + } + + public AndroidElement getWaitAMomentTextElement () { + return waitAMomentText; + } +} diff --git a/automationTest/src/test/java/androidtest/tests/.gitignore b/automationTest/src/test/java/androidtest/tests/.gitignore new file mode 100644 index 0000000000..fa0f66dfc9 --- /dev/null +++ b/automationTest/src/test/java/androidtest/tests/.gitignore @@ -0,0 +1 @@ +Config.java \ No newline at end of file diff --git a/automationTest/src/test/java/androidtest/tests/CommonTest.java b/automationTest/src/test/java/androidtest/tests/Common.java similarity index 64% rename from automationTest/src/test/java/androidtest/tests/CommonTest.java rename to automationTest/src/test/java/androidtest/tests/Common.java index b819544951..7bf21bdc61 100644 --- a/automationTest/src/test/java/androidtest/tests/CommonTest.java +++ b/automationTest/src/test/java/androidtest/tests/Common.java @@ -2,20 +2,22 @@ package androidtest.tests; import java.io.File; import java.net.URL; +import java.util.concurrent.TimeUnit; import org.openqa.selenium.By; import org.openqa.selenium.NoSuchElementException; +import org.openqa.selenium.TimeoutException; import org.openqa.selenium.remote.DesiredCapabilities; - -import androidtest.models.LoginForm; -import androidtest.models.MainView; +import org.openqa.selenium.support.ui.WebDriverWait; import io.appium.java_client.android.AndroidDriver; import io.appium.java_client.android.AndroidElement; import junit.framework.TestCase; -public class CommonTest extends TestCase{ +public class Common extends TestCase{ AndroidDriver driver; - final int waitingTime = 30; + static int waitingTime = 30; + + WebDriverWait wait; protected void setUpCommonDriver () throws Exception { File rootPath = new File(System.getProperty("user.dir")); @@ -29,6 +31,9 @@ public class CommonTest extends TestCase{ capabilities.setCapability("app-activity", ".ui.activity.FileDisplayActivity"); capabilities.setCapability("appWaitActivity", ".authentication.AuthenticatorActivity"); driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities); + driver.manage().timeouts().implicitlyWait(waitingTime, TimeUnit.SECONDS); + wait = new WebDriverWait(driver, waitingTime, 50); + } protected boolean waitForTextPresent(String text, AndroidElement element) throws InterruptedException{ @@ -55,15 +60,28 @@ public class CommonTest extends TestCase{ } } - protected MainView login(String url, String user, String password) throws InterruptedException { - LoginForm loginForm = new LoginForm(driver); - loginForm.typeHostUrl(url); - loginForm.clickOnUserName(); - waitForTextPresent("Secure connection established", loginForm.getServerStatusTextElement()); - assertTrue(waitForTextPresent("Secure connection established", loginForm.getServerStatusTextElement())); - loginForm.typeUserName(user); - loginForm.typePassword(password); - return loginForm.clickOnConnectButton(); + protected boolean isElementPresent(AndroidElement element) { + try{ + element.isDisplayed(); + } catch (NoSuchElementException e){ + return false; + } + return true; + } + + //pollingTime in milliseconds + public static void waitTillElementIsNotPresent (AndroidElement element, int pollingTime) throws Exception { + for (int time = 0;;time += pollingTime){ + if (time >= waitingTime * 1000) //convert to milliseconds + break; + try{ + element.isDisplayed(); + } catch (NoSuchElementException e){ + return; + } + Thread.sleep(pollingTime); + } + throw new TimeoutException(); } } diff --git a/automationTest/src/test/java/androidtest/tests/Config.java b/automationTest/src/test/java/androidtest/tests/Config.java index 4e1b0fe9fb..5f5da2b614 100644 --- a/automationTest/src/test/java/androidtest/tests/Config.java +++ b/automationTest/src/test/java/androidtest/tests/Config.java @@ -3,22 +3,27 @@ package androidtest.tests; public final class Config { public static final String server = "owncloudServerVar"; - public static final Boolean hasSubdirectory = false; - public static String URL = GetURl(hasSubdirectory); + public static final Boolean hasResource = false; + public static String URL = GetURl(server, hasResource, "resourceServerVar"); + public static boolean isTrusted = true; + + public static final String server2 = "owncloudServer2Var"; + public static final Boolean hasResource2 = false; + public static String URL2 = GetURl(server2, hasResource2, "resourceServerVar"); + public static boolean isTrusted2 = true; public static final String user = "owncloudUserVar"; public static final String password = "owncloudPasswordVar"; public static final String user2 = "owncloudUser2Var"; public static final String password2 = "owncloudPassword2Var"; - public static final String userAccount = user + "@"+server; - public static final String userAccount2 = user2 + "@"+server; + public static final String userAccount = user + "@"+ server; + public static final String userAccount2 = user2 + "@"+ server2; - public static String GetURl(Boolean hasSubdirectory){ + public static String GetURl(String server, Boolean hasSubdirectory, String serverResource){ if(hasSubdirectory){ - return server + "/owncloud"; + return server + serverResource; }else{ return server; } } - } diff --git a/automationTest/src/test/java/androidtest/tests/CreateFolderTestSuite.java b/automationTest/src/test/java/androidtest/tests/CreateFolderTestSuite.java index 873638406e..61294da845 100644 --- a/automationTest/src/test/java/androidtest/tests/CreateFolderTestSuite.java +++ b/automationTest/src/test/java/androidtest/tests/CreateFolderTestSuite.java @@ -1,54 +1,55 @@ package androidtest.tests; -import io.appium.java_client.android.AndroidElement; - import org.junit.After; import org.junit.Before; import org.junit.runners.MethodSorters; import org.junit.FixMethodOrder; import org.junit.Test; - - import androidtest.actions.Actions; import androidtest.models.MainView; +import androidtest.models.WaitAMomentPopUp; @FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class CreateFolderTestSuite extends CommonTest{ +public class CreateFolderTestSuite extends Common{ + + private Boolean folderHasBeenCreated = false; + private final String FOLDER_NAME = "testCreateFolder"; + private String CurrentCreatedFolder = ""; + @Before public void setUp() throws Exception { setUpCommonDriver(); } - @Test - public void test6CreateNewFolder () throws Exception { + public void testCreateNewFolder () throws Exception { String NEW_FOLDER_NAME = "testCreateFolder"; - MainView mainView = login(Config.URL, Config.user,Config.password); + MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); assertTrue(waitForTextPresent("ownCloud", mainView.getTitleTextElement())); - mainView.clickOnNewFolderButton(); - mainView.typeNewFolderName(NEW_FOLDER_NAME); - mainView.clickOnNewFolderOkButton(); - assertTrue(waitForTextPresent("Wait a moment" , mainView.getWaitAMomentTextElement())); - while(mainView.getWaitAMomentTextElement().isDisplayed()){} - AndroidElement newFolderElement = mainView.scrollTillFindElement(NEW_FOLDER_NAME); - assertTrue(newFolderElement.isDisplayed()); - newFolderElement.tap(1, 1000); - mainView.clickOnRemoveFileElement(); - mainView.clickOnRemoteAndLocalButton(); - assertTrue(waitForTextPresent("Wait a moment" , mainView.getWaitAMomentTextElement())); - while(mainView.getWaitAMomentTextElement().isDisplayed()){} - Actions.deleteAccount(mainView); - } + //check if the folder already exists and if true, delete them + Actions.deleteElement(NEW_FOLDER_NAME, mainView, driver); + + WaitAMomentPopUp waitAMomentPopUp = Actions.createFolder(NEW_FOLDER_NAME, mainView); + waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100); + mainView.scrollTillFindElement(FOLDER_NAME); + assertNotNull(mainView.getFileElement()); + assertTrue(folderHasBeenCreated=mainView.getFileElement().isDisplayed()); + CurrentCreatedFolder = FOLDER_NAME; + assertEquals(FOLDER_NAME , mainView.getFileElement().getText()); + } @After public void tearDown() throws Exception { + if (folderHasBeenCreated) { + MainView mainView = new MainView(driver); + Actions.deleteElement(CurrentCreatedFolder, mainView, driver); + } driver.removeApp("com.owncloud.android"); driver.quit(); } } - diff --git a/automationTest/src/test/java/androidtest/tests/DeleteFileTestSuite.java b/automationTest/src/test/java/androidtest/tests/DeleteFileTestSuite.java new file mode 100644 index 0000000000..2ea23b677c --- /dev/null +++ b/automationTest/src/test/java/androidtest/tests/DeleteFileTestSuite.java @@ -0,0 +1,47 @@ +package androidtest.tests; + +import org.junit.After; +import org.junit.Before; +import org.junit.runners.MethodSorters; +import org.junit.FixMethodOrder; +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.support.ui.ExpectedConditions; + +import androidtest.actions.Actions; +import androidtest.models.MainView; + + +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class DeleteFileTestSuite extends Common{ + + private final String FILE_NAME = "test"; + + @Before + public void setUp() throws Exception { + setUpCommonDriver(); + } + + @Test + public void testDeleteFile () throws Exception { + MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); + waitForTextPresent("ownCloud", mainView.getTitleTextElement()); + + //TODO. if the file already exists, do not upload + MainView mainViewAfterUploadFile = Actions.uploadFile(FILE_NAME, mainView); + + mainViewAfterUploadFile.scrollTillFindElement(FILE_NAME); + waitTillElementIsNotPresent(mainViewAfterUploadFile.getProgressCircular(), 1000); + wait.until(ExpectedConditions.visibilityOf(mainViewAfterUploadFile.getFileElementLayout().findElement(By.id(MainView.getLocalFileIndicator())))); + + Actions.deleteElement(FILE_NAME,mainViewAfterUploadFile, driver); + assertFalse(mainViewAfterUploadFile.getFileElement().isDisplayed()); + } + + @After + public void tearDown() throws Exception { + driver.removeApp("com.owncloud.android"); + driver.quit(); + } + +} \ No newline at end of file diff --git a/automationTest/src/test/java/androidtest/tests/DeleteFolderTestSuite.java b/automationTest/src/test/java/androidtest/tests/DeleteFolderTestSuite.java new file mode 100644 index 0000000000..d5a8b35fca --- /dev/null +++ b/automationTest/src/test/java/androidtest/tests/DeleteFolderTestSuite.java @@ -0,0 +1,52 @@ +package androidtest.tests; + +import org.junit.After; +import org.junit.Before; +import org.junit.runners.MethodSorters; +import org.junit.FixMethodOrder; +import org.junit.Test; + +import androidtest.actions.Actions; +import androidtest.models.MainView; +import androidtest.models.WaitAMomentPopUp; + + +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class DeleteFolderTestSuite extends Common{ + private Boolean folderHasBeenCreated = false; + private final String FOLDER_NAME = "testCreateFolder"; + + + @Before + public void setUp() throws Exception { + setUpCommonDriver(); + } + + @Test + public void testDeleteFolder () throws Exception { + MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); + waitForTextPresent("ownCloud", mainView.getTitleTextElement()); + + //TODO. if the folder already exists, do no created + //create the folder + WaitAMomentPopUp waitAMomentPopUp = Actions.createFolder(FOLDER_NAME, mainView); + waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100); + mainView.scrollTillFindElement(FOLDER_NAME); + assertTrue(folderHasBeenCreated = mainView.getFileElement().isDisplayed()); + + //delete the folder + Actions.deleteElement(FOLDER_NAME, mainView, driver); + assertFalse(folderHasBeenCreated =mainView.getFileElement().isDisplayed()); + } + + @After + public void tearDown() throws Exception { + if(folderHasBeenCreated){ + MainView mainView = new MainView(driver); + Actions.deleteElement(FOLDER_NAME, mainView, driver); + } + driver.removeApp("com.owncloud.android"); + driver.quit(); + } + +} diff --git a/automationTest/src/test/java/androidtest/tests/LoginTestSuite.java b/automationTest/src/test/java/androidtest/tests/LoginTestSuite.java index a4cbda6638..a37bfa7733 100644 --- a/automationTest/src/test/java/androidtest/tests/LoginTestSuite.java +++ b/automationTest/src/test/java/androidtest/tests/LoginTestSuite.java @@ -6,15 +6,14 @@ import org.junit.runners.MethodSorters; import org.junit.FixMethodOrder; import org.junit.Test; import org.openqa.selenium.ScreenOrientation; - - import androidtest.actions.Actions; import androidtest.models.LoginForm; import androidtest.models.MainView; +import androidtest.models.MenuList; import androidtest.models.SettingsView; @FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class LoginTestSuite extends CommonTest{ +public class LoginTestSuite extends Common{ @Before public void setUp() throws Exception { @@ -23,98 +22,67 @@ public class LoginTestSuite extends CommonTest{ @Test public void test1LoginPortrait () throws Exception { - - System.out.println("Hello" + Config.server); - String testName = "loginPortrait"; driver.rotate(ScreenOrientation.PORTRAIT); - - MainView mainView = login(Config.URL, Config.user,Config.password); + + MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); assertTrue(waitForTextPresent("ownCloud", mainView.getTitleTextElement())); - //TO DO. detect in which view is. it can be files view or settings view - /*if(mainView.getTitleTextElement().equals("ownCloud") || mainView.getTitleTextElement().equals("Settings")){ - if(mainView.getTitleTextElement().getText().equals("ownCloud")){ - assertTrue(waitForTextPresent("ownCloud", mainView.getTitleTextElement())); - }else{ - assertTrue(waitForTextPresent("Settings", mainView.getTitleTextElement())); - } - fail(testName); - }*/ - Actions.deleteAccount(mainView); } @Test public void test2LoginLandscape () throws Exception { - - String testName = "loginLandscape"; driver.rotate(ScreenOrientation.LANDSCAPE); - MainView mainView = login(Config.URL, Config.user,Config.password); + MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); assertTrue(waitForTextPresent("ownCloud", mainView.getTitleTextElement())); //TO DO. detect in which view is. it can be files view or settings view - Actions.deleteAccount(mainView); } @Test public void test3MultiAccountRotate () throws Exception { - - String testName = "MultiAccountRotate"; driver.rotate(ScreenOrientation.LANDSCAPE); - MainView mainView = login(Config.URL, Config.user,Config.password); + MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); assertTrue(waitForTextPresent("ownCloud", mainView.getTitleTextElement())); driver.rotate(ScreenOrientation.PORTRAIT); - mainView.clickOnMenuButton(); - SettingsView settingsView = mainView.clickOnSettingsButton(); + MenuList menu = mainView.clickOnMenuButton(); + SettingsView settingsView = menu.clickOnSettingsButton(); settingsView.tapOnAddAccount(1, 1000); - mainView = login(Config.URL, Config.user2,Config.password2); + mainView = Actions.login(Config.URL2, Config.user2,Config.password2, Config.isTrusted2, driver); assertTrue(waitForTextPresent("Settings", mainView.getTitleTextElement())); //TO DO. detect in which view is. it can be files view or settings view //Actions.deleteAccount(mainView); - Actions.deleteAccount(settingsView); //TO DO. Delete the second user } @Test public void test4ExistingAccountRotate () throws Exception { - - String testName = "ExistingAccountRotate"; driver.rotate(ScreenOrientation.PORTRAIT); - MainView mainView = login(Config.URL, Config.user,Config.password); + MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); assertTrue(waitForTextPresent("ownCloud", mainView.getTitleTextElement())); driver.rotate(ScreenOrientation.LANDSCAPE); - mainView.clickOnMenuButton(); - SettingsView settingsView = mainView.clickOnSettingsButton(); + MenuList menu = mainView.clickOnMenuButton(); + SettingsView settingsView = menu.clickOnSettingsButton(); settingsView.tapOnAddAccount(1, 1000); - LoginForm loginForm = new LoginForm(driver); - loginForm.typeHostUrl(Config.URL); - loginForm.clickOnUserName(); - waitForTextPresent("Secure connection established", loginForm.getServerStatusTextElement()); - assertTrue(waitForTextPresent("Secure connection established", loginForm.getServerStatusTextElement())); - loginForm.typeUserName(Config.user); - loginForm.typePassword(Config.password); - mainView = loginForm.clickOnConnectButton(); + LoginForm loginForm = new LoginForm(driver); + mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); assertTrue(waitForTextPresent("An account for the same user and server already exists in the device", loginForm.getAuthStatusText())); - driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_BACK); - Actions.deleteAccount(settingsView); } public void test5ChangePasswordWrong () throws Exception { - MainView mainView = login(Config.URL, Config.user,Config.password); + MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); assertTrue(waitForTextPresent("ownCloud", mainView.getTitleTextElement())); - mainView.clickOnMenuButton(); - SettingsView settingView = mainView.clickOnSettingsButton(); - settingView.tapOnAccountElement(1, 1000); - LoginForm changePasswordForm = settingView.clickOnChangePasswordElement(); + MenuList menu = mainView.clickOnMenuButton(); + SettingsView settingsView = menu.clickOnSettingsButton(); + settingsView.tapOnAccountElement(1, 1000); + LoginForm changePasswordForm = settingsView.clickOnChangePasswordElement(); changePasswordForm.typePassword("WrongPassword"); changePasswordForm.clickOnConnectButton(); assertTrue(waitForTextPresent("Wrong username or password", changePasswordForm.getAuthStatusText())); - driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_BACK); - Actions.deleteAccount(settingView); } diff --git a/automationTest/src/test/java/androidtest/tests/LogoutTestSuite.java b/automationTest/src/test/java/androidtest/tests/LogoutTestSuite.java new file mode 100644 index 0000000000..a5624410dc --- /dev/null +++ b/automationTest/src/test/java/androidtest/tests/LogoutTestSuite.java @@ -0,0 +1,39 @@ +package androidtest.tests; + + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import androidtest.actions.Actions; +import androidtest.models.LoginForm; +import androidtest.models.MainView; +import androidtest.models.MenuList; +import androidtest.models.SettingsView; + +public class LogoutTestSuite extends Common{ + + @Before + public void setUp() throws Exception { + setUpCommonDriver(); + } + + @Test + public void testLogout () throws Exception { + MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); + waitForTextPresent("ownCloud", mainView.getTitleTextElement()); + MenuList menulist = mainView.clickOnMenuButton(); + SettingsView settingsView = menulist.clickOnSettingsButton(); + settingsView.tapOnAccountElement(1, 1000); + LoginForm loginForm = settingsView.clickOnDeleteAccountElement(); + assertEquals("Server address https://…", loginForm.gethostUrlInput().getText()); + assertEquals("Username", loginForm.getUserNameInput().getText()); + assertEquals("", loginForm.getPasswordInput().getText()); + } + + @After + public void tearDown() throws Exception { + driver.removeApp("com.owncloud.android"); + driver.quit(); + } +} diff --git a/automationTest/src/test/java/androidtest/tests/MoveFileTestSuite.java b/automationTest/src/test/java/androidtest/tests/MoveFileTestSuite.java new file mode 100644 index 0000000000..ca8a4ec107 --- /dev/null +++ b/automationTest/src/test/java/androidtest/tests/MoveFileTestSuite.java @@ -0,0 +1,78 @@ +package androidtest.tests; + +import org.junit.After; +import org.junit.Before; +import org.junit.FixMethodOrder; +import org.junit.Test; +import org.junit.runners.MethodSorters; + +import androidtest.actions.Actions; +import androidtest.models.ElementMenuOptions; +import androidtest.models.MainView; +import androidtest.models.MoveView; +import androidtest.models.WaitAMomentPopUp; + + + +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class MoveFileTestSuite extends Common{ + private String FOLDER_WHERE_MOVE = "folderWhereMove"; + private String FILE_NAME = "test"; + + @Before + public void setUp() throws Exception { + setUpCommonDriver(); + } + + @Test + public void testMoveFile () throws Exception { + WaitAMomentPopUp waitAMomentPopUp; + + MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); + assertTrue(waitForTextPresent("ownCloud", mainView.getTitleTextElement())); + + waitTillElementIsNotPresent(mainView.getProgressCircular(), 1000); + + //check if the folder already exists and if true, delete them + Actions.deleteElement(FOLDER_WHERE_MOVE, mainView, driver); + Actions.deleteElement(FILE_NAME, mainView, driver); + + //Create the folder where the other is gone to be moved + waitAMomentPopUp = Actions.createFolder(FOLDER_WHERE_MOVE, mainView); + waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100); + mainView.scrollTillFindElement(FOLDER_WHERE_MOVE); + assertTrue(mainView.getFileElement().isDisplayed()); + + MainView mainViewAfterUploadFile = Actions.uploadFile(FILE_NAME, mainView); + mainViewAfterUploadFile.scrollTillFindElement(FILE_NAME); + assertTrue(mainViewAfterUploadFile.getFileElement().isDisplayed()); + + //select to move the file + ElementMenuOptions menuOptions = mainView.longPressOnElement(FILE_NAME); + MoveView moveView = menuOptions.clickOnMove(); + + //to move to a folder + moveView.scrollTillFindElement(FOLDER_WHERE_MOVE).tap(1,1); + waitAMomentPopUp = moveView.clickOnChoose(); + waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100); + + //check that the folder moved is inside the other + mainView.scrollTillFindElement(FOLDER_WHERE_MOVE).tap(1,1); + waitTillElementIsNotPresent(mainView.getProgressCircular(), 1000); + Thread.sleep(1000); + mainView.scrollTillFindElement(FILE_NAME); + assertEquals(FILE_NAME , mainView.getFileElement().getText()); + + } + + @After + public void tearDown() throws Exception { + MainView mainView = new MainView(driver); + driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_BACK); + Actions.deleteElement(FOLDER_WHERE_MOVE, mainView, driver); + Actions.deleteElement(FILE_NAME, mainView, driver); + driver.removeApp("com.owncloud.android"); + driver.quit(); + } + +} diff --git a/automationTest/src/test/java/androidtest/tests/MoveFolderTestSuite.java b/automationTest/src/test/java/androidtest/tests/MoveFolderTestSuite.java new file mode 100644 index 0000000000..a95c56ca69 --- /dev/null +++ b/automationTest/src/test/java/androidtest/tests/MoveFolderTestSuite.java @@ -0,0 +1,78 @@ +package androidtest.tests; + +import org.junit.After; +import org.junit.Before; +import org.junit.runners.MethodSorters; +import org.junit.FixMethodOrder; +import org.junit.Test; +import androidtest.actions.Actions; +import androidtest.models.ElementMenuOptions; +import androidtest.models.MainView; +import androidtest.models.MoveView; +import androidtest.models.WaitAMomentPopUp; + + +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class MoveFolderTestSuite extends Common{ + private String FOLDER_TO_MOVE = "folderToMove"; + private String FOLDER_WHERE_MOVE = "folderWhereMove"; + + @Before + public void setUp() throws Exception { + setUpCommonDriver(); + } + + @Test + public void testMoveFolder () throws Exception { + WaitAMomentPopUp waitAMomentPopUp; + + MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); + assertTrue(waitForTextPresent("ownCloud", mainView.getTitleTextElement())); + + waitTillElementIsNotPresent(mainView.getProgressCircular(), 1000); + + //check if the folder already exists and if true, delete them + Actions.deleteElement(FOLDER_WHERE_MOVE, mainView, driver); + Actions.deleteElement(FOLDER_TO_MOVE, mainView, driver); + + //Create the folder where the other is gone to be moved + waitAMomentPopUp = Actions.createFolder(FOLDER_WHERE_MOVE, mainView); + waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100); + mainView.scrollTillFindElement(FOLDER_WHERE_MOVE); + assertTrue(mainView.getFileElement().isDisplayed()); + + //Create the folder which is going to be moved + waitAMomentPopUp = Actions.createFolder(FOLDER_TO_MOVE, mainView); + waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100); + mainView.scrollTillFindElement(FOLDER_TO_MOVE); + assertTrue(mainView.getFileElement().isDisplayed()); + + //select to move the folder + ElementMenuOptions menuOptions = mainView.longPressOnElement(FOLDER_TO_MOVE); + MoveView moveView = menuOptions.clickOnMove(); + + //to move to a folder + moveView.scrollTillFindElement(FOLDER_WHERE_MOVE).tap(1,1); + waitAMomentPopUp = moveView.clickOnChoose(); + waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100); + + //check that the folder moved is inside the other + mainView.scrollTillFindElement(FOLDER_WHERE_MOVE).tap(1,1); + waitTillElementIsNotPresent(mainView.getProgressCircular(), 1000); + Thread.sleep(1000); + mainView.scrollTillFindElement(FOLDER_TO_MOVE); + assertEquals(FOLDER_TO_MOVE , mainView.getFileElement().getText()); + } + + @After + public void tearDown() throws Exception { + MainView mainView = new MainView(driver); + driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_BACK); + Actions.deleteElement(FOLDER_WHERE_MOVE, mainView, driver); + Actions.deleteElement(FOLDER_TO_MOVE, mainView, driver); + driver.removeApp("com.owncloud.android"); + driver.quit(); + } + + +} diff --git a/automationTest/src/test/java/androidtest/tests/RenameFileTestSuite.java b/automationTest/src/test/java/androidtest/tests/RenameFileTestSuite.java new file mode 100644 index 0000000000..a95168a9a6 --- /dev/null +++ b/automationTest/src/test/java/androidtest/tests/RenameFileTestSuite.java @@ -0,0 +1,70 @@ +package androidtest.tests; + +import org.junit.After; +import org.junit.Before; +import org.junit.runners.MethodSorters; +import org.junit.FixMethodOrder; +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.support.ui.ExpectedConditions; + +import androidtest.actions.Actions; +import androidtest.models.ElementMenuOptions; +import androidtest.models.MainView; +import androidtest.models.NewFolderPopUp; +import androidtest.models.WaitAMomentPopUp; + + +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class RenameFileTestSuite extends Common{ + + private Boolean fileHasBeenCreated = false; + private final String OLD_FILE_NAME = "test"; + private final String FILE_NAME = "newNameFile"; + private String CurrentCreatedFile = ""; + + + @Before + public void setUp() throws Exception { + setUpCommonDriver(); + } + + @Test + public void testRenameFile () throws Exception { + MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); + waitForTextPresent("ownCloud", mainView.getTitleTextElement()); + + //TODO. if the file already exists, do not upload + MainView mainViewAfterUploadFile = Actions.uploadFile(OLD_FILE_NAME, mainView); + + //check if the file with the new name already exists, if true delete it + Actions.deleteElement(FILE_NAME, mainView, driver); + + mainViewAfterUploadFile.scrollTillFindElement(OLD_FILE_NAME); + assertTrue(fileHasBeenCreated = mainViewAfterUploadFile.getFileElement().isDisplayed()); + CurrentCreatedFile = OLD_FILE_NAME; + waitTillElementIsNotPresent(mainViewAfterUploadFile.getProgressCircular(), 1000); + wait.until(ExpectedConditions.visibilityOf(mainViewAfterUploadFile.getFileElementLayout().findElement(By.id(MainView.getLocalFileIndicator())))); + ElementMenuOptions menuOptions = mainViewAfterUploadFile.longPressOnElement(OLD_FILE_NAME); + NewFolderPopUp newFolderPopUp = menuOptions.clickOnRename(); + newFolderPopUp.typeNewFolderName(FILE_NAME); + WaitAMomentPopUp waitAMomentPopUp = newFolderPopUp.clickOnNewFolderOkButton(); + waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100); + mainViewAfterUploadFile.scrollTillFindElement(FILE_NAME); + assertNotNull(mainViewAfterUploadFile.getFileElement()); + assertTrue(mainViewAfterUploadFile.getFileElement().isDisplayed()); + assertEquals(FILE_NAME , mainViewAfterUploadFile.getFileElement().getText()); + CurrentCreatedFile = FILE_NAME; + } + + @After + public void tearDown() throws Exception { + if (fileHasBeenCreated) { + MainView mainView = new MainView(driver); + Actions.deleteElement(CurrentCreatedFile,mainView, driver); + } + driver.removeApp("com.owncloud.android"); + driver.quit(); + } + +} diff --git a/automationTest/src/test/java/androidtest/tests/RenameFolderTestSuite.java b/automationTest/src/test/java/androidtest/tests/RenameFolderTestSuite.java new file mode 100644 index 0000000000..ef5d742431 --- /dev/null +++ b/automationTest/src/test/java/androidtest/tests/RenameFolderTestSuite.java @@ -0,0 +1,68 @@ +package androidtest.tests; + +import org.junit.After; +import org.junit.Before; +import org.junit.runners.MethodSorters; +import org.junit.FixMethodOrder; +import org.junit.Test; +import androidtest.actions.Actions; +import androidtest.models.ElementMenuOptions; +import androidtest.models.MainView; +import androidtest.models.NewFolderPopUp; +import androidtest.models.WaitAMomentPopUp; + + +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class RenameFolderTestSuite extends Common{ + + private Boolean folderHasBeenCreated = false; + private final String OLD_FOLDER_NAME = "beforeRemoving"; + private final String FOLDER_NAME = "testCreateFolder"; + private String CurrentCreatedFolder = ""; + + + @Before + public void setUp() throws Exception { + setUpCommonDriver(); + } + + @Test + public void testRenameFolder () throws Exception { + MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); + waitForTextPresent("ownCloud", mainView.getTitleTextElement()); + + //TODO. if the folder already exists, do no created + //create the folder to rename + WaitAMomentPopUp waitAMomentPopUp = Actions.createFolder(OLD_FOLDER_NAME, mainView); + waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100); + mainView.scrollTillFindElement(OLD_FOLDER_NAME); + + assertTrue(folderHasBeenCreated = mainView.getFileElement().isDisplayed()); + + //check if the folder with the new name already exists and if true, delete them + Actions.deleteElement(FOLDER_NAME, mainView, driver); + + CurrentCreatedFolder = OLD_FOLDER_NAME; + ElementMenuOptions menuOptions = mainView.longPressOnElement(OLD_FOLDER_NAME); + NewFolderPopUp FolderPopUp = menuOptions.clickOnRename(); + FolderPopUp.typeNewFolderName(FOLDER_NAME); + FolderPopUp.clickOnNewFolderOkButton(); + CurrentCreatedFolder = FOLDER_NAME; + waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100); + mainView.scrollTillFindElement(FOLDER_NAME); + assertNotNull(mainView.getFileElement()); + assertTrue(folderHasBeenCreated = mainView.getFileElement().isDisplayed()); + assertEquals(FOLDER_NAME , mainView.getFileElement().getText()); + } + + @After + public void tearDown() throws Exception { + if(folderHasBeenCreated){ + MainView mainView = new MainView(driver); + Actions.deleteElement(CurrentCreatedFolder, mainView, driver); + } + driver.removeApp("com.owncloud.android"); + driver.quit(); + } + +} diff --git a/automationTest/src/test/java/androidtest/tests/UploadTestSuite.java b/automationTest/src/test/java/androidtest/tests/UploadTestSuite.java index 4b1a5006d8..20ddf64e77 100644 --- a/automationTest/src/test/java/androidtest/tests/UploadTestSuite.java +++ b/automationTest/src/test/java/androidtest/tests/UploadTestSuite.java @@ -8,81 +8,74 @@ import org.junit.Before; import org.junit.runners.MethodSorters; import org.junit.FixMethodOrder; import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.support.ui.ExpectedConditions; import androidtest.actions.Actions; import androidtest.models.AppDetailsView; -import androidtest.models.FilesView; +import androidtest.models.ElementMenuOptions; import androidtest.models.MainView; @FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class UploadTestSuite extends CommonTest{ +public class UploadTestSuite extends Common{ + + String FILE_NAME = "test"; @Before public void setUp() throws Exception { - setUpCommonDriver(); + setUpCommonDriver(); } - + @Test public void test1UploadFile () throws Exception { - String FILE_NAME = "test"; - - MainView mainView = login(Config.URL, Config.user,Config.password); + + MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); assertTrue(waitForTextPresent("ownCloud", mainView.getTitleTextElement())); - mainView.clickOnUploadButton(); - FilesView filesView = mainView.clickOnFilesElementUploadFile(); - filesView.clickOnFileName(FILE_NAME); - MainView mainViewAfterUploadFile = filesView.clickOnUploadButton(); - //TO DO. detect when the file is successfully uploaded - Thread.sleep(3000); + + //check if the file already exists and if true, delete it + Actions.deleteElement(FILE_NAME, mainView, driver); + + MainView mainViewAfterUploadFile = Actions.uploadFile(FILE_NAME, mainView); + mainViewAfterUploadFile.scrollTillFindElement(FILE_NAME); assertTrue(mainViewAfterUploadFile.getFileElement().isDisplayed()); - mainViewAfterUploadFile.tapOnFileElement(FILE_NAME); - mainViewAfterUploadFile.clickOnRemoveFileElement(); - mainViewAfterUploadFile.clickOnRemoteAndLocalButton(); - assertTrue(waitForTextPresent("Wait a moment" , mainViewAfterUploadFile.getWaitAMomentTextElement())); - while(mainViewAfterUploadFile.getWaitAMomentTextElement().isDisplayed()){} - Actions.deleteAccount(mainViewAfterUploadFile); - + waitTillElementIsNotPresent(mainViewAfterUploadFile.getProgressCircular(), 1000); + wait.until(ExpectedConditions.visibilityOf(mainViewAfterUploadFile.getFileElementLayout().findElement(By.id(MainView.getLocalFileIndicator())))); + + } - + @Test public void test2KeepFileUpToDate () throws Exception { - String FILE_NAME = "test"; - - MainView mainView = login(Config.URL, Config.user,Config.password); + + MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); assertTrue(waitForTextPresent("ownCloud", mainView.getTitleTextElement())); - mainView.clickOnUploadButton(); - FilesView filesView = mainView.clickOnFilesElementUploadFile(); - filesView.clickOnFileName(FILE_NAME); - MainView mainViewAfterUploadFile = filesView.clickOnUploadButton(); - //TO DO. detect when the file is successfully uploaded - Thread.sleep(3000); + + waitTillElementIsNotPresent(mainView.getProgressCircular(), 1000); + + MainView mainViewAfterUploadFile = Actions.uploadFile(FILE_NAME, mainView); mainViewAfterUploadFile.scrollTillFindElement(FILE_NAME); assertTrue(mainViewAfterUploadFile.getFileElement().isDisplayed()); - mainViewAfterUploadFile.tapOnFileElement(FILE_NAME); - AppDetailsView appDetailsView = mainViewAfterUploadFile.clickOnDetailsFileElement(); + + ElementMenuOptions menuOptions = mainViewAfterUploadFile.longPressOnElement(FILE_NAME); + AppDetailsView appDetailsView = menuOptions.clickOnDetails(); appDetailsView.checkKeepFileUpToDateCheckbox(); - //assertTrue(appDetailsView.getProgressBar().isDisplayed()); Thread.sleep(3000); driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_BACK); - assertTrue(isElementPresent(mainViewAfterUploadFile.getFileElementLayout(), MobileBy.id("com.owncloud.android:id/imageView3"))); - mainViewAfterUploadFile.tapOnFileElement(FILE_NAME); - mainViewAfterUploadFile.clickOnRemoveFileElement(); - mainViewAfterUploadFile.clickOnRemoteAndLocalButton(); - assertTrue(waitForTextPresent("Wait a moment" , mainViewAfterUploadFile.getWaitAMomentTextElement())); - while(mainViewAfterUploadFile.getWaitAMomentTextElement().isDisplayed()){} - Actions.deleteAccount(mainViewAfterUploadFile); - + assertTrue(isElementPresent(mainViewAfterUploadFile.getFileElementLayout(), MobileBy.id(MainView.getFavoriteFileIndicator()))); + } - - + + @After public void tearDown() throws Exception { + MainView mainView = new MainView(driver); + Actions.deleteElement(FILE_NAME,mainView, driver); driver.removeApp("com.owncloud.android"); driver.quit(); } - + } From aa9abc55b4195e3dadd8f0985322e4f49b88c4b9 Mon Sep 17 00:00:00 2001 From: purigarcia Date: Thu, 16 Apr 2015 09:08:41 +0200 Subject: [PATCH 05/27] add new changes --- automationTest/pom.xml | 10 +++++++++- .../test/java/androidtest/tests/Common.java | 18 ++++++++++++++++++ .../tests/CreateFolderTestSuite.java | 3 ++- .../androidtest/tests/DeleteFileTestSuite.java | 1 + .../tests/DeleteFolderTestSuite.java | 1 + .../java/androidtest/tests/LoginTestSuite.java | 1 + .../androidtest/tests/LogoutTestSuite.java | 1 + .../androidtest/tests/MoveFileTestSuite.java | 1 + .../androidtest/tests/MoveFolderTestSuite.java | 1 + .../androidtest/tests/RenameFileTestSuite.java | 1 + .../tests/RenameFolderTestSuite.java | 1 + .../androidtest/tests/UploadTestSuite.java | 1 + 12 files changed, 38 insertions(+), 2 deletions(-) diff --git a/automationTest/pom.xml b/automationTest/pom.xml index eded8e819a..773f1a6f21 100644 --- a/automationTest/pom.xml +++ b/automationTest/pom.xml @@ -20,6 +20,15 @@ + + org.apache.maven.plugins + maven-compiler-plugin + 3.3 + + 1.7 + 1.7 + + @@ -66,5 +75,4 @@ provided - \ 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 index 7bf21bdc61..c457d20af1 100644 --- a/automationTest/src/test/java/androidtest/tests/Common.java +++ b/automationTest/src/test/java/androidtest/tests/Common.java @@ -1,14 +1,24 @@ package androidtest.tests; 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.WebDriver; +import org.openqa.selenium.remote.Augmenter; 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; import junit.framework.TestCase; @@ -84,4 +94,12 @@ public class Common extends TestCase{ 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)); + } + } diff --git a/automationTest/src/test/java/androidtest/tests/CreateFolderTestSuite.java b/automationTest/src/test/java/androidtest/tests/CreateFolderTestSuite.java index 61294da845..ad72e36a12 100644 --- a/automationTest/src/test/java/androidtest/tests/CreateFolderTestSuite.java +++ b/automationTest/src/test/java/androidtest/tests/CreateFolderTestSuite.java @@ -5,6 +5,7 @@ import org.junit.Before; import org.junit.runners.MethodSorters; import org.junit.FixMethodOrder; import org.junit.Test; + import androidtest.actions.Actions; import androidtest.models.MainView; import androidtest.models.WaitAMomentPopUp; @@ -17,7 +18,6 @@ public class CreateFolderTestSuite extends Common{ private final String FOLDER_NAME = "testCreateFolder"; private String CurrentCreatedFolder = ""; - @Before public void setUp() throws Exception { setUpCommonDriver(); @@ -44,6 +44,7 @@ public class CreateFolderTestSuite extends Common{ @After public void tearDown() throws Exception { + takeScreenShotOnFailed(getName()); if (folderHasBeenCreated) { MainView mainView = new MainView(driver); Actions.deleteElement(CurrentCreatedFolder, mainView, driver); diff --git a/automationTest/src/test/java/androidtest/tests/DeleteFileTestSuite.java b/automationTest/src/test/java/androidtest/tests/DeleteFileTestSuite.java index 2ea23b677c..a07bb976d5 100644 --- a/automationTest/src/test/java/androidtest/tests/DeleteFileTestSuite.java +++ b/automationTest/src/test/java/androidtest/tests/DeleteFileTestSuite.java @@ -40,6 +40,7 @@ public class DeleteFileTestSuite extends Common{ @After public void tearDown() throws Exception { + takeScreenShotOnFailed(getName()); driver.removeApp("com.owncloud.android"); driver.quit(); } diff --git a/automationTest/src/test/java/androidtest/tests/DeleteFolderTestSuite.java b/automationTest/src/test/java/androidtest/tests/DeleteFolderTestSuite.java index d5a8b35fca..f015c1eede 100644 --- a/automationTest/src/test/java/androidtest/tests/DeleteFolderTestSuite.java +++ b/automationTest/src/test/java/androidtest/tests/DeleteFolderTestSuite.java @@ -41,6 +41,7 @@ public class DeleteFolderTestSuite extends Common{ @After public void tearDown() throws Exception { + takeScreenShotOnFailed(getName()); if(folderHasBeenCreated){ MainView mainView = new MainView(driver); Actions.deleteElement(FOLDER_NAME, mainView, driver); diff --git a/automationTest/src/test/java/androidtest/tests/LoginTestSuite.java b/automationTest/src/test/java/androidtest/tests/LoginTestSuite.java index a37bfa7733..0d2553a08b 100644 --- a/automationTest/src/test/java/androidtest/tests/LoginTestSuite.java +++ b/automationTest/src/test/java/androidtest/tests/LoginTestSuite.java @@ -88,6 +88,7 @@ public class LoginTestSuite extends Common{ @After public void tearDown() throws Exception { + takeScreenShotOnFailed(getName()); 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 index a5624410dc..f9f540277f 100644 --- a/automationTest/src/test/java/androidtest/tests/LogoutTestSuite.java +++ b/automationTest/src/test/java/androidtest/tests/LogoutTestSuite.java @@ -33,6 +33,7 @@ public class LogoutTestSuite extends Common{ @After public void tearDown() throws Exception { + takeScreenShotOnFailed(getName()); 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 index ca8a4ec107..502d45f473 100644 --- a/automationTest/src/test/java/androidtest/tests/MoveFileTestSuite.java +++ b/automationTest/src/test/java/androidtest/tests/MoveFileTestSuite.java @@ -67,6 +67,7 @@ public class MoveFileTestSuite extends Common{ @After public void tearDown() throws Exception { + takeScreenShotOnFailed(getName()); MainView mainView = new MainView(driver); driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_BACK); Actions.deleteElement(FOLDER_WHERE_MOVE, mainView, driver); diff --git a/automationTest/src/test/java/androidtest/tests/MoveFolderTestSuite.java b/automationTest/src/test/java/androidtest/tests/MoveFolderTestSuite.java index a95c56ca69..5b835d3e39 100644 --- a/automationTest/src/test/java/androidtest/tests/MoveFolderTestSuite.java +++ b/automationTest/src/test/java/androidtest/tests/MoveFolderTestSuite.java @@ -66,6 +66,7 @@ public class MoveFolderTestSuite extends Common{ @After public void tearDown() throws Exception { + takeScreenShotOnFailed(getName()); MainView mainView = new MainView(driver); driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_BACK); Actions.deleteElement(FOLDER_WHERE_MOVE, mainView, driver); diff --git a/automationTest/src/test/java/androidtest/tests/RenameFileTestSuite.java b/automationTest/src/test/java/androidtest/tests/RenameFileTestSuite.java index a95168a9a6..4909fbbb96 100644 --- a/automationTest/src/test/java/androidtest/tests/RenameFileTestSuite.java +++ b/automationTest/src/test/java/androidtest/tests/RenameFileTestSuite.java @@ -59,6 +59,7 @@ public class RenameFileTestSuite extends Common{ @After public void tearDown() throws Exception { + takeScreenShotOnFailed(getName()); if (fileHasBeenCreated) { MainView mainView = new MainView(driver); Actions.deleteElement(CurrentCreatedFile,mainView, driver); diff --git a/automationTest/src/test/java/androidtest/tests/RenameFolderTestSuite.java b/automationTest/src/test/java/androidtest/tests/RenameFolderTestSuite.java index ef5d742431..24c64848ec 100644 --- a/automationTest/src/test/java/androidtest/tests/RenameFolderTestSuite.java +++ b/automationTest/src/test/java/androidtest/tests/RenameFolderTestSuite.java @@ -57,6 +57,7 @@ public class RenameFolderTestSuite extends Common{ @After public void tearDown() throws Exception { + takeScreenShotOnFailed(getName()); if(folderHasBeenCreated){ MainView mainView = new MainView(driver); Actions.deleteElement(CurrentCreatedFolder, mainView, driver); diff --git a/automationTest/src/test/java/androidtest/tests/UploadTestSuite.java b/automationTest/src/test/java/androidtest/tests/UploadTestSuite.java index 20ddf64e77..6038930ee1 100644 --- a/automationTest/src/test/java/androidtest/tests/UploadTestSuite.java +++ b/automationTest/src/test/java/androidtest/tests/UploadTestSuite.java @@ -70,6 +70,7 @@ public class UploadTestSuite extends Common{ @After public void tearDown() throws Exception { + takeScreenShotOnFailed(getName()); MainView mainView = new MainView(driver); Actions.deleteElement(FILE_NAME,mainView, driver); driver.removeApp("com.owncloud.android"); From a52fc9424444400d4c774b76cf9f59ba43f9dc12 Mon Sep 17 00:00:00 2001 From: purigarcia Date: Mon, 11 May 2015 08:20:21 +0200 Subject: [PATCH 06/27] add new testCases. prepare the test to have them into categories --- automationTest/.gitignore | 5 +- .../org.eclipse.core.resources.prefs | 4 -- automationTest/pom.xml | 2 +- .../java/androidtest/actions/Actions.java | 17 ++++- .../models/ElementMenuOptions.java | 9 +++ .../java/androidtest/models/LoginForm.java | 9 +-- .../java/androidtest/models/MainView.java | 22 ++++++- .../androidtest/models/NewFolderPopUp.java | 4 +- .../java/androidtest/models/SettingsView.java | 39 ++++++++--- .../test/java/androidtest/tests/Common.java | 59 ++++++++++++----- .../test/java/androidtest/tests/Config.java | 29 +++------ .../tests/CreateFolderTestSuite.java | 24 +++++-- .../tests/DeleteFileTestSuite.java | 26 ++++++-- .../tests/DeleteFolderTestSuite.java | 24 +++++-- .../androidtest/tests/LoginTestSuite.java | 50 ++++++++------ .../androidtest/tests/LogoutTestSuite.java | 25 +++++-- .../androidtest/tests/MoveFileTestSuite.java | 31 ++++++--- .../tests/MoveFolderTestSuite.java | 33 +++++++--- .../tests/RenameFileTestSuite.java | 29 ++++++--- .../tests/RenameFolderTestSuite.java | 27 ++++++-- .../androidtest/tests/UploadTestSuite.java | 65 +++++++++++++++---- 21 files changed, 385 insertions(+), 148 deletions(-) delete mode 100644 automationTest/.settings/org.eclipse.core.resources.prefs diff --git a/automationTest/.gitignore b/automationTest/.gitignore index 3fe891d76b..a47ace0fca 100644 --- a/automationTest/.gitignore +++ b/automationTest/.gitignore @@ -1,2 +1,3 @@ -/target/ -src/test/java/androidtest/tests/Config.java + +target/ +ScreenShots/ diff --git a/automationTest/.settings/org.eclipse.core.resources.prefs b/automationTest/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index f9fe34593f..0000000000 --- a/automationTest/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,4 +0,0 @@ -eclipse.preferences.version=1 -encoding//src/main/java=UTF-8 -encoding//src/test/java=UTF-8 -encoding/=UTF-8 diff --git a/automationTest/pom.xml b/automationTest/pom.xml index 773f1a6f21..548da37e84 100644 --- a/automationTest/pom.xml +++ b/automationTest/pom.xml @@ -56,7 +56,7 @@ io.appium java-client - 2.1.0 + 2.2.0 commons-lang diff --git a/automationTest/src/test/java/androidtest/actions/Actions.java b/automationTest/src/test/java/androidtest/actions/Actions.java index a89f5de527..b5bebb19db 100644 --- a/automationTest/src/test/java/androidtest/actions/Actions.java +++ b/automationTest/src/test/java/androidtest/actions/Actions.java @@ -3,6 +3,7 @@ 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; @@ -29,10 +30,18 @@ public class Actions { LoginForm loginForm = new LoginForm(driver); CertificatePopUp certificatePopUp = loginForm.typeHostUrl(url); if(!isTrusted){ - driver.runAppInBackground(3); WebDriverWait wait = new WebDriverWait(driver, 30); - wait.until(ExpectedConditions.visibilityOf(certificatePopUp.getOkButtonElement())); - certificatePopUp.clickOnOkButton(); + //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); @@ -87,6 +96,8 @@ public class Actions { 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();; diff --git a/automationTest/src/test/java/androidtest/models/ElementMenuOptions.java b/automationTest/src/test/java/androidtest/models/ElementMenuOptions.java index 090e038bd6..a809d47e24 100644 --- a/automationTest/src/test/java/androidtest/models/ElementMenuOptions.java +++ b/automationTest/src/test/java/androidtest/models/ElementMenuOptions.java @@ -11,6 +11,9 @@ public class ElementMenuOptions { final AndroidDriver driver; + @AndroidFindBy(name = "Share link") + private AndroidElement shareLinkElement; + @AndroidFindBy(name = "Details") private AndroidElement detailsFileElement; @@ -52,4 +55,10 @@ public class ElementMenuOptions { 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/LoginForm.java b/automationTest/src/test/java/androidtest/models/LoginForm.java index ea78102e94..11755d6f57 100644 --- a/automationTest/src/test/java/androidtest/models/LoginForm.java +++ b/automationTest/src/test/java/androidtest/models/LoginForm.java @@ -51,14 +51,15 @@ public class LoginForm { public void typeUserName (String userName) { userNameInput.clear(); - userNameInput.sendKeys(userName); - driver.hideKeyboard(); + //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); - driver.hideKeyboard(); + passwordInput.sendKeys(password + "\n"); + //driver.hideKeyboard(); } public MainView clickOnConnectButton () { diff --git a/automationTest/src/test/java/androidtest/models/MainView.java b/automationTest/src/test/java/androidtest/models/MainView.java index 6228f0e3be..0c28bf09ac 100644 --- a/automationTest/src/test/java/androidtest/models/MainView.java +++ b/automationTest/src/test/java/androidtest/models/MainView.java @@ -4,6 +4,7 @@ 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; @@ -11,6 +12,7 @@ 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 { @@ -49,6 +51,10 @@ public class MainView { @AndroidFindBy(name = "Files") private AndroidElement filesElementUploadFile; + @CacheLookup + @AndroidFindBy(uiAutomator = "new UiSelector().description(\"List Layout\")") + private AndroidElement listLayout; + private AndroidElement fileElement; private AndroidElement fileElementLayout; @@ -63,7 +69,12 @@ public class MainView { } public MenuList clickOnMenuButton () { - menuButton.click(); + //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; } @@ -93,6 +104,10 @@ public class MainView { return titleText; } + public AndroidElement getUploadButton () { + return uploadButton; + } + public AndroidElement getWaitAMomentTextElement () { return waitAMomentText; } @@ -141,6 +156,11 @@ public class MainView { 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/NewFolderPopUp.java b/automationTest/src/test/java/androidtest/models/NewFolderPopUp.java index 658130ddac..31a2124a9e 100644 --- a/automationTest/src/test/java/androidtest/models/NewFolderPopUp.java +++ b/automationTest/src/test/java/androidtest/models/NewFolderPopUp.java @@ -24,8 +24,8 @@ public class NewFolderPopUp { public void typeNewFolderName (String newFolderName) { newFolderNameField.clear(); - newFolderNameField.sendKeys(newFolderName); - driver.hideKeyboard(); + newFolderNameField.sendKeys(newFolderName + "\n"); + //driver.hideKeyboard(); } public WaitAMomentPopUp clickOnNewFolderOkButton () { diff --git a/automationTest/src/test/java/androidtest/models/SettingsView.java b/automationTest/src/test/java/androidtest/models/SettingsView.java index 18c9c00872..4e3aa48e8a 100644 --- a/automationTest/src/test/java/androidtest/models/SettingsView.java +++ b/automationTest/src/test/java/androidtest/models/SettingsView.java @@ -12,24 +12,27 @@ 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); @@ -38,22 +41,38 @@ public class SettingsView { 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/tests/Common.java b/automationTest/src/test/java/androidtest/tests/Common.java index c457d20af1..aeab97d67b 100644 --- a/automationTest/src/test/java/androidtest/tests/Common.java +++ b/automationTest/src/test/java/androidtest/tests/Common.java @@ -1,5 +1,6 @@ package androidtest.tests; +import static org.junit.Assert.*; import java.io.File; import java.io.IOException; import java.net.URL; @@ -7,45 +8,41 @@ 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.WebDriver; -import org.openqa.selenium.remote.Augmenter; 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; -import junit.framework.TestCase; -public class Common extends TestCase{ +public class Common{ AndroidDriver driver; static int waitingTime = 30; - + WebDriverWait wait; - - protected void setUpCommonDriver () throws Exception { + + 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", "Device"); + capabilities.setCapability("deviceName", "test"); capabilities.setCapability("app", app.getAbsolutePath()); - capabilities.setCapability("app-package", "com.owncloud.android"); - capabilities.setCapability("app-activity", ".ui.activity.FileDisplayActivity"); + 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) @@ -54,13 +51,13 @@ public class Common extends TestCase{ 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); @@ -69,7 +66,7 @@ public class Common extends TestCase{ return false; } } - + protected boolean isElementPresent(AndroidElement element) { try{ element.isDisplayed(); @@ -78,7 +75,7 @@ public class Common extends TestCase{ } return true; } - + //pollingTime in milliseconds public static void waitTillElementIsNotPresent (AndroidElement element, int pollingTime) throws Exception { for (int time = 0;;time += pollingTime){ @@ -93,7 +90,7 @@ public class Common extends TestCase{ } throw new TimeoutException(); } - + protected void takeScreenShotOnFailed (String testName) throws IOException { File file = ((RemoteWebDriver) driver).getScreenshotAs(OutputType.FILE); SimpleDateFormat dt1 = new SimpleDateFormat("yyyy-MM-dd"); @@ -102,4 +99,30 @@ public class Common extends TestCase{ 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 index 5f5da2b614..928e27c2af 100644 --- a/automationTest/src/test/java/androidtest/tests/Config.java +++ b/automationTest/src/test/java/androidtest/tests/Config.java @@ -1,29 +1,20 @@ package androidtest.tests; public final class Config { - - public static final String server = "owncloudServerVar"; - public static final Boolean hasResource = false; - public static String URL = GetURl(server, hasResource, "resourceServerVar"); + + //without http or https + public static final String URL = "owncloudServerVar"; public static boolean isTrusted = true; - - public static final String server2 = "owncloudServer2Var"; - public static final Boolean hasResource2 = false; - public static String URL2 = GetURl(server2, hasResource2, "resourceServerVar"); + + //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 + "@"+ server; - public static final String userAccount2 = user2 + "@"+ server2; - - public static String GetURl(String server, Boolean hasSubdirectory, String serverResource){ - if(hasSubdirectory){ - return server + serverResource; - }else{ - return server; - } - } + 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 index ad72e36a12..feaeb0ab95 100644 --- a/automationTest/src/test/java/androidtest/tests/CreateFolderTestSuite.java +++ b/automationTest/src/test/java/androidtest/tests/CreateFolderTestSuite.java @@ -1,40 +1,54 @@ 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 extends Common{ +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 { - setUpCommonDriver(); + 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); - assertTrue(waitForTextPresent("ownCloud", mainView.getTitleTextElement())); + 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); - waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100); + Common.waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100); mainView.scrollTillFindElement(FOLDER_NAME); assertNotNull(mainView.getFileElement()); assertTrue(folderHasBeenCreated=mainView.getFileElement().isDisplayed()); @@ -44,7 +58,7 @@ public class CreateFolderTestSuite extends Common{ @After public void tearDown() throws Exception { - takeScreenShotOnFailed(getName()); + common.takeScreenShotOnFailed(name.getMethodName()); if (folderHasBeenCreated) { MainView mainView = new MainView(driver); Actions.deleteElement(CurrentCreatedFolder, mainView, driver); diff --git a/automationTest/src/test/java/androidtest/tests/DeleteFileTestSuite.java b/automationTest/src/test/java/androidtest/tests/DeleteFileTestSuite.java index a07bb976d5..d30b4c6cb1 100644 --- a/automationTest/src/test/java/androidtest/tests/DeleteFileTestSuite.java +++ b/automationTest/src/test/java/androidtest/tests/DeleteFileTestSuite.java @@ -1,7 +1,13 @@ 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; @@ -9,30 +15,38 @@ 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 extends Common{ +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 { - setUpCommonDriver(); + 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); - waitForTextPresent("ownCloud", mainView.getTitleTextElement()); + common.assertIsInMainView(); //TODO. if the file already exists, do not upload MainView mainViewAfterUploadFile = Actions.uploadFile(FILE_NAME, mainView); mainViewAfterUploadFile.scrollTillFindElement(FILE_NAME); - waitTillElementIsNotPresent(mainViewAfterUploadFile.getProgressCircular(), 1000); - wait.until(ExpectedConditions.visibilityOf(mainViewAfterUploadFile.getFileElementLayout().findElement(By.id(MainView.getLocalFileIndicator())))); + 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()); @@ -40,7 +54,7 @@ public class DeleteFileTestSuite extends Common{ @After public void tearDown() throws Exception { - takeScreenShotOnFailed(getName()); + common.takeScreenShotOnFailed(name.getMethodName()); driver.removeApp("com.owncloud.android"); driver.quit(); } diff --git a/automationTest/src/test/java/androidtest/tests/DeleteFolderTestSuite.java b/automationTest/src/test/java/androidtest/tests/DeleteFolderTestSuite.java index f015c1eede..fe7aabda2b 100644 --- a/automationTest/src/test/java/androidtest/tests/DeleteFolderTestSuite.java +++ b/automationTest/src/test/java/androidtest/tests/DeleteFolderTestSuite.java @@ -1,36 +1,50 @@ 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 extends Common{ +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 { - setUpCommonDriver(); + 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); - waitForTextPresent("ownCloud", mainView.getTitleTextElement()); + common.assertIsInMainView(); //TODO. if the folder already exists, do no created //create the folder WaitAMomentPopUp waitAMomentPopUp = Actions.createFolder(FOLDER_NAME, mainView); - waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100); + Common.waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100); mainView.scrollTillFindElement(FOLDER_NAME); assertTrue(folderHasBeenCreated = mainView.getFileElement().isDisplayed()); @@ -41,7 +55,7 @@ public class DeleteFolderTestSuite extends Common{ @After public void tearDown() throws Exception { - takeScreenShotOnFailed(getName()); + common.takeScreenShotOnFailed(name.getMethodName()); if(folderHasBeenCreated){ MainView mainView = new MainView(driver); Actions.deleteElement(FOLDER_NAME, mainView, driver); diff --git a/automationTest/src/test/java/androidtest/tests/LoginTestSuite.java b/automationTest/src/test/java/androidtest/tests/LoginTestSuite.java index 0d2553a08b..6aa6c2bb60 100644 --- a/automationTest/src/test/java/androidtest/tests/LoginTestSuite.java +++ b/automationTest/src/test/java/androidtest/tests/LoginTestSuite.java @@ -1,65 +1,76 @@ 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 extends Common{ - +public class LoginTestSuite{ + AndroidDriver driver; + Common common; + + @Rule public TestName name = new TestName(); + @Before public void setUp() throws Exception { - setUpCommonDriver(); + 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); - assertTrue(waitForTextPresent("ownCloud", mainView.getTitleTextElement())); + 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); - assertTrue(waitForTextPresent("ownCloud", mainView.getTitleTextElement())); - //TO DO. detect in which view is. it can be files view or settings view + 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); - assertTrue(waitForTextPresent("ownCloud", mainView.getTitleTextElement())); + 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); - - assertTrue(waitForTextPresent("Settings", mainView.getTitleTextElement())); - //TO DO. detect in which view is. it can be files view or settings view - //Actions.deleteAccount(mainView); - //TO DO. Delete the second user + 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); - assertTrue(waitForTextPresent("ownCloud", mainView.getTitleTextElement())); + common.assertIsInMainView(); driver.rotate(ScreenOrientation.LANDSCAPE); MenuList menu = mainView.clickOnMenuButton(); @@ -68,27 +79,28 @@ public class LoginTestSuite extends Common{ LoginForm loginForm = new LoginForm(driver); mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); - assertTrue(waitForTextPresent("An account for the same user and server already exists in the device", loginForm.getAuthStatusText())); + assertTrue(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); - assertTrue(waitForTextPresent("ownCloud", mainView.getTitleTextElement())); + common.assertIsInMainView(); MenuList menu = mainView.clickOnMenuButton(); SettingsView settingsView = menu.clickOnSettingsButton(); settingsView.tapOnAccountElement(1, 1000); LoginForm changePasswordForm = settingsView.clickOnChangePasswordElement(); changePasswordForm.typePassword("WrongPassword"); changePasswordForm.clickOnConnectButton(); - assertTrue(waitForTextPresent("Wrong username or password", changePasswordForm.getAuthStatusText())); + assertTrue(common.waitForTextPresent("Wrong username or password", changePasswordForm.getAuthStatusText())); } @After public void tearDown() throws Exception { - takeScreenShotOnFailed(getName()); + 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 index f9f540277f..876c0ce41c 100644 --- a/automationTest/src/test/java/androidtest/tests/LogoutTestSuite.java +++ b/automationTest/src/test/java/androidtest/tests/LogoutTestSuite.java @@ -1,27 +1,42 @@ 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 extends Common{ +public class LogoutTestSuite{ + + AndroidDriver driver; + Common common; + @Rule public TestName name = new TestName(); + @Before public void setUp() throws Exception { - setUpCommonDriver(); + common=new Common(); + driver=common.setUpCommonDriver(); } @Test + @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class}) public void testLogout () throws Exception { MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); - waitForTextPresent("ownCloud", mainView.getTitleTextElement()); + common.assertIsInMainView(); MenuList menulist = mainView.clickOnMenuButton(); SettingsView settingsView = menulist.clickOnSettingsButton(); settingsView.tapOnAccountElement(1, 1000); @@ -33,8 +48,8 @@ public class LogoutTestSuite extends Common{ @After public void tearDown() throws Exception { - takeScreenShotOnFailed(getName()); - driver.removeApp("com.owncloud.android"); + 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 index 502d45f473..3d57ee07b4 100644 --- a/automationTest/src/test/java/androidtest/tests/MoveFileTestSuite.java +++ b/automationTest/src/test/java/androidtest/tests/MoveFileTestSuite.java @@ -1,12 +1,20 @@ package androidtest.tests; +import static org.junit.Assert.*; +import io.appium.java_client.android.AndroidDriver; + import org.junit.After; import org.junit.Before; import org.junit.FixMethodOrder; +import org.junit.Rule; import org.junit.Test; +import org.junit.experimental.categories.Category; +import org.junit.rules.TestName; import org.junit.runners.MethodSorters; import androidtest.actions.Actions; +import androidtest.groups.NoIgnoreTestCategory; +import androidtest.groups.SmokeTestCategory; import androidtest.models.ElementMenuOptions; import androidtest.models.MainView; import androidtest.models.MoveView; @@ -15,23 +23,28 @@ import androidtest.models.WaitAMomentPopUp; @FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class MoveFileTestSuite extends Common{ +public class MoveFileTestSuite{ + AndroidDriver driver; + Common common; private String FOLDER_WHERE_MOVE = "folderWhereMove"; private String FILE_NAME = "test"; - + @Rule public TestName name = new TestName(); + @Before public void setUp() throws Exception { - setUpCommonDriver(); + common=new Common(); + driver=common.setUpCommonDriver(); } @Test + @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class}) public void testMoveFile () throws Exception { WaitAMomentPopUp waitAMomentPopUp; MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); - assertTrue(waitForTextPresent("ownCloud", mainView.getTitleTextElement())); + common.assertIsInMainView(); - waitTillElementIsNotPresent(mainView.getProgressCircular(), 1000); + Common.waitTillElementIsNotPresent(mainView.getProgressCircular(), 1000); //check if the folder already exists and if true, delete them Actions.deleteElement(FOLDER_WHERE_MOVE, mainView, driver); @@ -39,7 +52,7 @@ public class MoveFileTestSuite extends Common{ //Create the folder where the other is gone to be moved waitAMomentPopUp = Actions.createFolder(FOLDER_WHERE_MOVE, mainView); - waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100); + Common.waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100); mainView.scrollTillFindElement(FOLDER_WHERE_MOVE); assertTrue(mainView.getFileElement().isDisplayed()); @@ -54,11 +67,11 @@ public class MoveFileTestSuite extends Common{ //to move to a folder moveView.scrollTillFindElement(FOLDER_WHERE_MOVE).tap(1,1); waitAMomentPopUp = moveView.clickOnChoose(); - waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100); + Common.waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100); //check that the folder moved is inside the other mainView.scrollTillFindElement(FOLDER_WHERE_MOVE).tap(1,1); - waitTillElementIsNotPresent(mainView.getProgressCircular(), 1000); + Common.waitTillElementIsNotPresent(mainView.getProgressCircular(), 1000); Thread.sleep(1000); mainView.scrollTillFindElement(FILE_NAME); assertEquals(FILE_NAME , mainView.getFileElement().getText()); @@ -67,7 +80,7 @@ public class MoveFileTestSuite extends Common{ @After public void tearDown() throws Exception { - takeScreenShotOnFailed(getName()); + common.takeScreenShotOnFailed(name.getMethodName()); MainView mainView = new MainView(driver); driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_BACK); Actions.deleteElement(FOLDER_WHERE_MOVE, mainView, driver); diff --git a/automationTest/src/test/java/androidtest/tests/MoveFolderTestSuite.java b/automationTest/src/test/java/androidtest/tests/MoveFolderTestSuite.java index 5b835d3e39..532eff2132 100644 --- a/automationTest/src/test/java/androidtest/tests/MoveFolderTestSuite.java +++ b/automationTest/src/test/java/androidtest/tests/MoveFolderTestSuite.java @@ -1,11 +1,20 @@ package androidtest.tests; +import static org.junit.Assert.*; +import io.appium.java_client.android.AndroidDriver; + import org.junit.After; import org.junit.Before; +import org.junit.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; @@ -13,23 +22,29 @@ import androidtest.models.WaitAMomentPopUp; @FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class MoveFolderTestSuite extends Common{ +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 { - setUpCommonDriver(); + 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); - assertTrue(waitForTextPresent("ownCloud", mainView.getTitleTextElement())); + common.assertIsInMainView(); - waitTillElementIsNotPresent(mainView.getProgressCircular(), 1000); + Common.waitTillElementIsNotPresent(mainView.getProgressCircular(), 1000); //check if the folder already exists and if true, delete them Actions.deleteElement(FOLDER_WHERE_MOVE, mainView, driver); @@ -37,13 +52,13 @@ public class MoveFolderTestSuite extends Common{ //Create the folder where the other is gone to be moved waitAMomentPopUp = Actions.createFolder(FOLDER_WHERE_MOVE, mainView); - waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100); + Common.waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100); mainView.scrollTillFindElement(FOLDER_WHERE_MOVE); assertTrue(mainView.getFileElement().isDisplayed()); //Create the folder which is going to be moved waitAMomentPopUp = Actions.createFolder(FOLDER_TO_MOVE, mainView); - waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100); + Common.waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100); mainView.scrollTillFindElement(FOLDER_TO_MOVE); assertTrue(mainView.getFileElement().isDisplayed()); @@ -54,11 +69,11 @@ public class MoveFolderTestSuite extends Common{ //to move to a folder moveView.scrollTillFindElement(FOLDER_WHERE_MOVE).tap(1,1); waitAMomentPopUp = moveView.clickOnChoose(); - waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100); + Common.waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100); //check that the folder moved is inside the other mainView.scrollTillFindElement(FOLDER_WHERE_MOVE).tap(1,1); - waitTillElementIsNotPresent(mainView.getProgressCircular(), 1000); + Common.waitTillElementIsNotPresent(mainView.getProgressCircular(), 1000); Thread.sleep(1000); mainView.scrollTillFindElement(FOLDER_TO_MOVE); assertEquals(FOLDER_TO_MOVE , mainView.getFileElement().getText()); @@ -66,7 +81,7 @@ public class MoveFolderTestSuite extends Common{ @After public void tearDown() throws Exception { - takeScreenShotOnFailed(getName()); + common.takeScreenShotOnFailed(name.getMethodName()); MainView mainView = new MainView(driver); driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_BACK); Actions.deleteElement(FOLDER_WHERE_MOVE, mainView, driver); diff --git a/automationTest/src/test/java/androidtest/tests/RenameFileTestSuite.java b/automationTest/src/test/java/androidtest/tests/RenameFileTestSuite.java index 4909fbbb96..8a07e0348a 100644 --- a/automationTest/src/test/java/androidtest/tests/RenameFileTestSuite.java +++ b/automationTest/src/test/java/androidtest/tests/RenameFileTestSuite.java @@ -1,7 +1,13 @@ 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; @@ -9,6 +15,8 @@ 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; @@ -16,23 +24,28 @@ import androidtest.models.WaitAMomentPopUp; @FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class RenameFileTestSuite extends Common{ +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 { - setUpCommonDriver(); + 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); - waitForTextPresent("ownCloud", mainView.getTitleTextElement()); + common.assertIsInMainView(); //TODO. if the file already exists, do not upload MainView mainViewAfterUploadFile = Actions.uploadFile(OLD_FILE_NAME, mainView); @@ -43,13 +56,13 @@ public class RenameFileTestSuite extends Common{ mainViewAfterUploadFile.scrollTillFindElement(OLD_FILE_NAME); assertTrue(fileHasBeenCreated = mainViewAfterUploadFile.getFileElement().isDisplayed()); CurrentCreatedFile = OLD_FILE_NAME; - waitTillElementIsNotPresent(mainViewAfterUploadFile.getProgressCircular(), 1000); - wait.until(ExpectedConditions.visibilityOf(mainViewAfterUploadFile.getFileElementLayout().findElement(By.id(MainView.getLocalFileIndicator())))); + 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(); - waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100); + Common.waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100); mainViewAfterUploadFile.scrollTillFindElement(FILE_NAME); assertNotNull(mainViewAfterUploadFile.getFileElement()); assertTrue(mainViewAfterUploadFile.getFileElement().isDisplayed()); @@ -59,7 +72,7 @@ public class RenameFileTestSuite extends Common{ @After public void tearDown() throws Exception { - takeScreenShotOnFailed(getName()); + common.takeScreenShotOnFailed(name.getMethodName()); if (fileHasBeenCreated) { MainView mainView = new MainView(driver); Actions.deleteElement(CurrentCreatedFile,mainView, driver); diff --git a/automationTest/src/test/java/androidtest/tests/RenameFolderTestSuite.java b/automationTest/src/test/java/androidtest/tests/RenameFolderTestSuite.java index 24c64848ec..c97c3e0be9 100644 --- a/automationTest/src/test/java/androidtest/tests/RenameFolderTestSuite.java +++ b/automationTest/src/test/java/androidtest/tests/RenameFolderTestSuite.java @@ -1,11 +1,20 @@ package androidtest.tests; +import static org.junit.Assert.*; +import io.appium.java_client.android.AndroidDriver; + import org.junit.After; import org.junit.Before; +import org.junit.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; @@ -13,28 +22,34 @@ import androidtest.models.WaitAMomentPopUp; @FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class RenameFolderTestSuite extends Common{ +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 { - setUpCommonDriver(); + 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); - waitForTextPresent("ownCloud", mainView.getTitleTextElement()); + common.assertIsInMainView(); //TODO. if the folder already exists, do no created //create the folder to rename WaitAMomentPopUp waitAMomentPopUp = Actions.createFolder(OLD_FOLDER_NAME, mainView); - waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100); + Common.waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100); mainView.scrollTillFindElement(OLD_FOLDER_NAME); assertTrue(folderHasBeenCreated = mainView.getFileElement().isDisplayed()); @@ -48,7 +63,7 @@ public class RenameFolderTestSuite extends Common{ FolderPopUp.typeNewFolderName(FOLDER_NAME); FolderPopUp.clickOnNewFolderOkButton(); CurrentCreatedFolder = FOLDER_NAME; - waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100); + Common.waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100); mainView.scrollTillFindElement(FOLDER_NAME); assertNotNull(mainView.getFileElement()); assertTrue(folderHasBeenCreated = mainView.getFileElement().isDisplayed()); @@ -57,7 +72,7 @@ public class RenameFolderTestSuite extends Common{ @After public void tearDown() throws Exception { - takeScreenShotOnFailed(getName()); + common.takeScreenShotOnFailed(name.getMethodName()); if(folderHasBeenCreated){ MainView mainView = new MainView(driver); Actions.deleteElement(CurrentCreatedFolder, mainView, driver); diff --git a/automationTest/src/test/java/androidtest/tests/UploadTestSuite.java b/automationTest/src/test/java/androidtest/tests/UploadTestSuite.java index 6038930ee1..358024d78c 100644 --- a/automationTest/src/test/java/androidtest/tests/UploadTestSuite.java +++ b/automationTest/src/test/java/androidtest/tests/UploadTestSuite.java @@ -1,10 +1,15 @@ 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; @@ -12,26 +17,41 @@ 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) -public class UploadTestSuite extends Common{ +@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 { - setUpCommonDriver(); + common=new Common(); + driver=common.setUpCommonDriver(); } @Test - public void test1UploadFile () throws Exception { + @Category(NoIgnoreTestCategory.class) + public void testUploadFile () throws Exception { MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); - assertTrue(waitForTextPresent("ownCloud", mainView.getTitleTextElement())); + common.assertIsInMainView(); //check if the file already exists and if true, delete it Actions.deleteElement(FILE_NAME, mainView, driver); @@ -40,19 +60,40 @@ public class UploadTestSuite extends Common{ mainViewAfterUploadFile.scrollTillFindElement(FILE_NAME); assertTrue(mainViewAfterUploadFile.getFileElement().isDisplayed()); - waitTillElementIsNotPresent(mainViewAfterUploadFile.getProgressCircular(), 1000); - wait.until(ExpectedConditions.visibilityOf(mainViewAfterUploadFile.getFileElementLayout().findElement(By.id(MainView.getLocalFileIndicator())))); + Common.waitTillElementIsNotPresent(mainViewAfterUploadFile.getProgressCircular(), 1000); + common.wait.until(ExpectedConditions.visibilityOf(mainViewAfterUploadFile.getFileElementLayout().findElement(By.id(MainView.getLocalFileIndicator())))); } - + @Test - public void test2KeepFileUpToDate () throws Exception { + @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); - assertTrue(waitForTextPresent("ownCloud", mainView.getTitleTextElement())); + common.assertIsInMainView(); - waitTillElementIsNotPresent(mainView.getProgressCircular(), 1000); + Common.waitTillElementIsNotPresent(mainView.getProgressCircular(), 1000); MainView mainViewAfterUploadFile = Actions.uploadFile(FILE_NAME, mainView); mainViewAfterUploadFile.scrollTillFindElement(FILE_NAME); @@ -63,14 +104,14 @@ public class UploadTestSuite extends Common{ appDetailsView.checkKeepFileUpToDateCheckbox(); Thread.sleep(3000); driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_BACK); - assertTrue(isElementPresent(mainViewAfterUploadFile.getFileElementLayout(), MobileBy.id(MainView.getFavoriteFileIndicator()))); + assertTrue(common.isElementPresent(mainViewAfterUploadFile.getFileElementLayout(), MobileBy.id(MainView.getFavoriteFileIndicator()))); } @After public void tearDown() throws Exception { - takeScreenShotOnFailed(getName()); + common.takeScreenShotOnFailed(name.getMethodName()); MainView mainView = new MainView(driver); Actions.deleteElement(FILE_NAME,mainView, driver); driver.removeApp("com.owncloud.android"); From 2f1e6343428d0c2fceaf221326bd632ea510f1e6 Mon Sep 17 00:00:00 2001 From: purigarcia Date: Mon, 11 May 2015 11:45:49 +0200 Subject: [PATCH 07/27] rename the package, changes some files names, more config variables --- automationTest/.classpath | 5 + .../test/java/androidtest/tests/Config.java | 20 --- .../androidtest/tests/MoveFileTestSuite.java | 92 ------------ .../tests/RenameFileTestSuite.java | 84 ----------- .../androidtest/tests/UploadTestSuite.java | 123 --------------- .../android/test/ui}/actions/Actions.java | 50 +++---- .../test/ui/groups/FailingTestCategory.java | 3 + .../test/ui/groups/FlexibleCategories.java | 138 +++++++++++++++++ .../test/ui/groups/IgnoreTestCategory.java | 4 + .../test/ui/groups/NoIgnoreTestCategory.java | 5 + .../test/ui/groups/OtherTestCategory.java | 3 + .../groups/PatternClasspathClassesFinder.java | 141 ++++++++++++++++++ .../test/ui/groups/SmokeTestCategory.java | 5 + .../ui/groups/UnfinishedTestCategory.java | 5 + .../test/ui}/models/CertificatePopUp.java | 2 +- .../test/ui}/models/ElementMenuOptions.java | 8 +- .../test/ui/models/FileDetailsView.java} | 6 +- .../android/test/ui/models/FileListView.java} | 20 ++- .../test/ui/models/GmailEmailListView.java | 27 ++++ .../test/ui/models/GmailEmailView.java | 30 ++++ .../test/ui/models/GmailSendMailView.java | 43 ++++++ .../android/test/ui/models/ImageView.java | 56 +++++++ .../android/test/ui}/models/LoginForm.java | 8 +- .../android/test/ui}/models/MenuList.java | 2 +- .../android/test/ui}/models/MoveView.java | 4 +- .../test/ui}/models/NewFolderPopUp.java | 2 +- .../test/ui/models/PassCodeRequestView.java | 34 +++++ .../android/test/ui/models/PassCodeView.java | 43 ++++++ .../ui}/models/RemoveConfirmationView.java | 2 +- .../android/test/ui}/models/SettingsView.java | 4 +- .../android/test/ui/models/ShareView.java | 28 ++++ .../test/ui/models/UploadFilesView.java} | 16 +- .../android/test/ui/models/UploadView.java | 26 ++++ .../test/ui}/models/WaitAMomentPopUp.java | 2 +- .../android/test/ui/testSuites}/.gitignore | 0 .../android/test/ui/testSuites}/Common.java | 6 +- .../ui/testSuites}/CreateFolderTestSuite.java | 32 ++-- .../ui/testSuites}/DeleteFileTestSuite.java | 28 ++-- .../ui/testSuites}/DeleteFolderTestSuite.java | 30 ++-- .../test/ui/testSuites}/LoginTestSuite.java | 46 +++--- .../test/ui/testSuites}/LogoutTestSuite.java | 22 +-- .../test/ui/testSuites/MoveFileTestSuite.java | 92 ++++++++++++ .../ui/testSuites}/MoveFolderTestSuite.java | 54 +++---- .../test/ui/testSuites/PasscodeTestSuite.java | 70 +++++++++ .../ui/testSuites/RefreshFolderTestSuite.java | 55 +++++++ .../ui/testSuites/RenameFileTestSuite.java | 84 +++++++++++ .../ui/testSuites}/RenameFolderTestSuite.java | 42 +++--- .../test/ui/testSuites/RunFailingTests.java | 24 +++ .../test/ui/testSuites/RunNoIgnoreTests.java | 22 +++ .../test/ui/testSuites/RunSmokeTests.java | 22 +++ .../ui/testSuites/ShareLinkFileTestSuite.java | 72 +++++++++ .../test/ui/testSuites/UploadTestSuite.java | 124 +++++++++++++++ 52 files changed, 1358 insertions(+), 508 deletions(-) delete mode 100644 automationTest/src/test/java/androidtest/tests/Config.java delete mode 100644 automationTest/src/test/java/androidtest/tests/MoveFileTestSuite.java delete mode 100644 automationTest/src/test/java/androidtest/tests/RenameFileTestSuite.java delete mode 100644 automationTest/src/test/java/androidtest/tests/UploadTestSuite.java rename automationTest/src/test/java/{androidtest => com/owncloud/android/test/ui}/actions/Actions.java (67%) create mode 100644 automationTest/src/test/java/com/owncloud/android/test/ui/groups/FailingTestCategory.java create mode 100644 automationTest/src/test/java/com/owncloud/android/test/ui/groups/FlexibleCategories.java create mode 100644 automationTest/src/test/java/com/owncloud/android/test/ui/groups/IgnoreTestCategory.java create mode 100644 automationTest/src/test/java/com/owncloud/android/test/ui/groups/NoIgnoreTestCategory.java create mode 100644 automationTest/src/test/java/com/owncloud/android/test/ui/groups/OtherTestCategory.java create mode 100644 automationTest/src/test/java/com/owncloud/android/test/ui/groups/PatternClasspathClassesFinder.java create mode 100644 automationTest/src/test/java/com/owncloud/android/test/ui/groups/SmokeTestCategory.java create mode 100644 automationTest/src/test/java/com/owncloud/android/test/ui/groups/UnfinishedTestCategory.java rename automationTest/src/test/java/{androidtest => com/owncloud/android/test/ui}/models/CertificatePopUp.java (93%) rename automationTest/src/test/java/{androidtest => com/owncloud/android/test/ui}/models/ElementMenuOptions.java (89%) rename automationTest/src/test/java/{androidtest/models/AppDetailsView.java => com/owncloud/android/test/ui/models/FileDetailsView.java} (89%) rename automationTest/src/test/java/{androidtest/models/MainView.java => com/owncloud/android/test/ui/models/FileListView.java} (90%) create mode 100644 automationTest/src/test/java/com/owncloud/android/test/ui/models/GmailEmailListView.java create mode 100644 automationTest/src/test/java/com/owncloud/android/test/ui/models/GmailEmailView.java create mode 100644 automationTest/src/test/java/com/owncloud/android/test/ui/models/GmailSendMailView.java create mode 100644 automationTest/src/test/java/com/owncloud/android/test/ui/models/ImageView.java rename automationTest/src/test/java/{androidtest => com/owncloud/android/test/ui}/models/LoginForm.java (93%) rename automationTest/src/test/java/{androidtest => com/owncloud/android/test/ui}/models/MenuList.java (94%) rename automationTest/src/test/java/{androidtest => com/owncloud/android/test/ui}/models/MoveView.java (91%) rename automationTest/src/test/java/{androidtest => com/owncloud/android/test/ui}/models/NewFolderPopUp.java (96%) create mode 100644 automationTest/src/test/java/com/owncloud/android/test/ui/models/PassCodeRequestView.java create mode 100644 automationTest/src/test/java/com/owncloud/android/test/ui/models/PassCodeView.java rename automationTest/src/test/java/{androidtest => com/owncloud/android/test/ui}/models/RemoveConfirmationView.java (94%) rename automationTest/src/test/java/{androidtest => com/owncloud/android/test/ui}/models/SettingsView.java (95%) create mode 100644 automationTest/src/test/java/com/owncloud/android/test/ui/models/ShareView.java rename automationTest/src/test/java/{androidtest/models/FilesView.java => com/owncloud/android/test/ui/models/UploadFilesView.java} (77%) create mode 100644 automationTest/src/test/java/com/owncloud/android/test/ui/models/UploadView.java rename automationTest/src/test/java/{androidtest => com/owncloud/android/test/ui}/models/WaitAMomentPopUp.java (93%) rename automationTest/src/test/java/{androidtest/tests => com/owncloud/android/test/ui/testSuites}/.gitignore (100%) rename automationTest/src/test/java/{androidtest/tests => com/owncloud/android/test/ui/testSuites}/Common.java (95%) rename automationTest/src/test/java/{androidtest/tests => com/owncloud/android/test/ui/testSuites}/CreateFolderTestSuite.java (59%) rename automationTest/src/test/java/{androidtest/tests => com/owncloud/android/test/ui/testSuites}/DeleteFileTestSuite.java (50%) rename automationTest/src/test/java/{androidtest/tests => com/owncloud/android/test/ui/testSuites}/DeleteFolderTestSuite.java (59%) rename automationTest/src/test/java/{androidtest/tests => com/owncloud/android/test/ui/testSuites}/LoginTestSuite.java (63%) rename automationTest/src/test/java/{androidtest/tests => com/owncloud/android/test/ui/testSuites}/LogoutTestSuite.java (64%) create mode 100644 automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/MoveFileTestSuite.java rename automationTest/src/test/java/{androidtest/tests => com/owncloud/android/test/ui/testSuites}/MoveFolderTestSuite.java (51%) create mode 100644 automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/PasscodeTestSuite.java create mode 100644 automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/RefreshFolderTestSuite.java create mode 100644 automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/RenameFileTestSuite.java rename automationTest/src/test/java/{androidtest/tests => com/owncloud/android/test/ui/testSuites}/RenameFolderTestSuite.java (58%) create mode 100644 automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/RunFailingTests.java create mode 100644 automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/RunNoIgnoreTests.java create mode 100644 automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/RunSmokeTests.java create mode 100644 automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/ShareLinkFileTestSuite.java create mode 100644 automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/UploadTestSuite.java diff --git a/automationTest/.classpath b/automationTest/.classpath index 069344d37a..c52bcedcbe 100644 --- a/automationTest/.classpath +++ b/automationTest/.classpath @@ -23,5 +23,10 @@ + + + + + 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 928e27c2af..0000000000 --- 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/MoveFileTestSuite.java b/automationTest/src/test/java/androidtest/tests/MoveFileTestSuite.java deleted file mode 100644 index 3d57ee07b4..0000000000 --- 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/RenameFileTestSuite.java b/automationTest/src/test/java/androidtest/tests/RenameFileTestSuite.java deleted file mode 100644 index 8a07e0348a..0000000000 --- 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/UploadTestSuite.java b/automationTest/src/test/java/androidtest/tests/UploadTestSuite.java deleted file mode 100644 index 358024d78c..0000000000 --- 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/androidtest/actions/Actions.java b/automationTest/src/test/java/com/owncloud/android/test/ui/actions/Actions.java similarity index 67% rename from automationTest/src/test/java/androidtest/actions/Actions.java rename to automationTest/src/test/java/com/owncloud/android/test/ui/actions/Actions.java index b5bebb19db..ae41573ce2 100644 --- a/automationTest/src/test/java/androidtest/actions/Actions.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/actions/Actions.java @@ -1,4 +1,4 @@ -package androidtest.actions; +package com.owncloud.android.test.ui.actions; import java.util.HashMap; @@ -12,21 +12,21 @@ 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; +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 MainView login(String url, String user, String password, Boolean isTrusted, AndroidDriver driver) throws InterruptedException { + 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){ @@ -49,8 +49,8 @@ public class Actions { return loginForm.clickOnConnectButton(); } - public static WaitAMomentPopUp createFolder(String folderName, MainView mainView){ - NewFolderPopUp newFolderPopUp = mainView.clickOnNewFolderButton(); + public static WaitAMomentPopUp createFolder(String folderName, FileListView fileListView){ + NewFolderPopUp newFolderPopUp = fileListView.clickOnNewFolderButton(); newFolderPopUp.typeNewFolderName(folderName); WaitAMomentPopUp waitAMomentPopUp = newFolderPopUp.clickOnNewFolderOkButton(); //TODO. assert here @@ -76,8 +76,8 @@ public class Actions { } - public static void deleteAccount (MainView mainView) { - MenuList menulist = mainView.clickOnMenuButton(); + public static void deleteAccount (FileListView fileListView) { + MenuList menulist = fileListView.clickOnMenuButton(); SettingsView settingView = menulist.clickOnSettingsButton(); deleteAccount(settingView); } @@ -92,14 +92,14 @@ public class Actions { } //TODO. convert deleteFodler and deleteFile in deleteElement - public static AndroidElement deleteElement(String elementName, MainView mainView, AndroidDriver driver) throws Exception{ + 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 = mainView.longPressOnElement(elementName); + ElementMenuOptions menuOptions = fileListView.longPressOnElement(elementName); RemoveConfirmationView removeConfirmationView = menuOptions.clickOnRemove();; waitAMomentPopUp = removeConfirmationView.clickOnRemoteAndLocalButton(); Common.waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100); @@ -109,14 +109,14 @@ public class Actions { 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(); + 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 mainViewAfterUploadFile; + 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 0000000000..b8f6eae546 --- /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 0000000000..94a019afff --- /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 0000000000..6d252f3e10 --- /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 0000000000..50d4170151 --- /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 0000000000..8f0094e3b6 --- /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 0000000000..b59888309d --- /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 0000000000..69f3ad100f --- /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 0000000000..8d66b2bde0 --- /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/androidtest/models/CertificatePopUp.java b/automationTest/src/test/java/com/owncloud/android/test/ui/models/CertificatePopUp.java similarity index 93% rename from automationTest/src/test/java/androidtest/models/CertificatePopUp.java rename to automationTest/src/test/java/com/owncloud/android/test/ui/models/CertificatePopUp.java index dbcffcc53e..41cd4ae47c 100644 --- a/automationTest/src/test/java/androidtest/models/CertificatePopUp.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/models/CertificatePopUp.java @@ -1,4 +1,4 @@ -package androidtest.models; +package com.owncloud.android.test.ui.models; import io.appium.java_client.android.AndroidDriver; import io.appium.java_client.android.AndroidElement; diff --git a/automationTest/src/test/java/androidtest/models/ElementMenuOptions.java b/automationTest/src/test/java/com/owncloud/android/test/ui/models/ElementMenuOptions.java similarity index 89% rename from automationTest/src/test/java/androidtest/models/ElementMenuOptions.java rename to automationTest/src/test/java/com/owncloud/android/test/ui/models/ElementMenuOptions.java index a809d47e24..844ad1fe43 100644 --- a/automationTest/src/test/java/androidtest/models/ElementMenuOptions.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/models/ElementMenuOptions.java @@ -1,4 +1,4 @@ -package androidtest.models; +package com.owncloud.android.test.ui.models; import io.appium.java_client.android.AndroidDriver; import io.appium.java_client.android.AndroidElement; @@ -31,10 +31,10 @@ public class ElementMenuOptions { PageFactory.initElements(new AppiumFieldDecorator(driver), this); } - public AppDetailsView clickOnDetails () { + public FileDetailsView clickOnDetails () { detailsFileElement.click(); - AppDetailsView appDetailsView = new AppDetailsView(driver); - return appDetailsView; + FileDetailsView fileDetailsView = new FileDetailsView(driver); + return fileDetailsView; } public RemoveConfirmationView clickOnRemove () { diff --git a/automationTest/src/test/java/androidtest/models/AppDetailsView.java b/automationTest/src/test/java/com/owncloud/android/test/ui/models/FileDetailsView.java similarity index 89% rename from automationTest/src/test/java/androidtest/models/AppDetailsView.java rename to automationTest/src/test/java/com/owncloud/android/test/ui/models/FileDetailsView.java index 75ce4d9ff3..1410d95816 100644 --- a/automationTest/src/test/java/androidtest/models/AppDetailsView.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/models/FileDetailsView.java @@ -1,4 +1,4 @@ -package androidtest.models; +package com.owncloud.android.test.ui.models; import io.appium.java_client.android.AndroidDriver; import io.appium.java_client.android.AndroidElement; @@ -8,7 +8,7 @@ import io.appium.java_client.pagefactory.AppiumFieldDecorator; import org.openqa.selenium.support.CacheLookup; import org.openqa.selenium.support.PageFactory; -public class AppDetailsView { +public class FileDetailsView { final AndroidDriver driver; @CacheLookup @@ -18,7 +18,7 @@ public class AppDetailsView { @AndroidFindBy(id = "com.owncloud.android:id/fdProgressBar") private AndroidElement progressBar; - public AppDetailsView (AndroidDriver driver) { + public FileDetailsView (AndroidDriver driver) { this.driver = driver; PageFactory.initElements(new AppiumFieldDecorator(driver), this); } diff --git a/automationTest/src/test/java/androidtest/models/MainView.java b/automationTest/src/test/java/com/owncloud/android/test/ui/models/FileListView.java similarity index 90% rename from automationTest/src/test/java/androidtest/models/MainView.java rename to automationTest/src/test/java/com/owncloud/android/test/ui/models/FileListView.java index 0c28bf09ac..f75347472e 100644 --- a/automationTest/src/test/java/androidtest/models/MainView.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/models/FileListView.java @@ -1,4 +1,4 @@ -package androidtest.models; +package com.owncloud.android.test.ui.models; import java.util.List; @@ -11,11 +11,11 @@ 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 { +import com.owncloud.android.test.ui.actions.Actions; + +public class FileListView { final AndroidDriver driver; @AndroidFindBy(uiAutomator = "new UiSelector().description(\"More options\")") @@ -61,9 +61,10 @@ public class MainView { 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 MainView (AndroidDriver driver) { + public FileListView (AndroidDriver driver) { this.driver = driver; PageFactory.initElements(new AppiumFieldDecorator(driver), this); } @@ -94,10 +95,10 @@ public class MainView { uploadButton.click(); } - public FilesView clickOnFilesElementUploadFile () { + public UploadFilesView clickOnFilesElementUploadFile () { filesElementUploadFile.click(); - FilesView filesView = new FilesView(driver); - return filesView; + UploadFilesView uploadFilesView = new UploadFilesView(driver); + return uploadFilesView; } public AndroidElement getTitleTextElement () { @@ -157,6 +158,9 @@ public class MainView { 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 0000000000..5bf3690197 --- /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 0000000000..a5797014a1 --- /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 0000000000..264a61c4e4 --- /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 0000000000..da8c30b682 --- /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/androidtest/models/LoginForm.java b/automationTest/src/test/java/com/owncloud/android/test/ui/models/LoginForm.java similarity index 93% rename from automationTest/src/test/java/androidtest/models/LoginForm.java rename to automationTest/src/test/java/com/owncloud/android/test/ui/models/LoginForm.java index 11755d6f57..6971cc233f 100644 --- a/automationTest/src/test/java/androidtest/models/LoginForm.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/models/LoginForm.java @@ -1,4 +1,4 @@ -package androidtest.models; +package com.owncloud.android.test.ui.models; import org.openqa.selenium.support.CacheLookup; import org.openqa.selenium.support.PageFactory; @@ -62,10 +62,10 @@ public class LoginForm { //driver.hideKeyboard(); } - public MainView clickOnConnectButton () { + public FileListView clickOnConnectButton () { connectButton.click(); - MainView mainView = new MainView(driver); - return mainView; + FileListView fileListView = new FileListView(driver); + return fileListView; } public AndroidElement gethostUrlInput () { diff --git a/automationTest/src/test/java/androidtest/models/MenuList.java b/automationTest/src/test/java/com/owncloud/android/test/ui/models/MenuList.java similarity index 94% rename from automationTest/src/test/java/androidtest/models/MenuList.java rename to automationTest/src/test/java/com/owncloud/android/test/ui/models/MenuList.java index 466fa1c70a..9dade478f3 100644 --- a/automationTest/src/test/java/androidtest/models/MenuList.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/models/MenuList.java @@ -1,4 +1,4 @@ -package androidtest.models; +package com.owncloud.android.test.ui.models; import org.openqa.selenium.support.PageFactory; diff --git a/automationTest/src/test/java/androidtest/models/MoveView.java b/automationTest/src/test/java/com/owncloud/android/test/ui/models/MoveView.java similarity index 91% rename from automationTest/src/test/java/androidtest/models/MoveView.java rename to automationTest/src/test/java/com/owncloud/android/test/ui/models/MoveView.java index f54ba284d1..5be7b69dc9 100644 --- a/automationTest/src/test/java/androidtest/models/MoveView.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/models/MoveView.java @@ -1,4 +1,4 @@ -package androidtest.models; +package com.owncloud.android.test.ui.models; import io.appium.java_client.android.AndroidDriver; import io.appium.java_client.android.AndroidElement; @@ -8,7 +8,7 @@ import io.appium.java_client.pagefactory.AppiumFieldDecorator; import org.openqa.selenium.support.CacheLookup; import org.openqa.selenium.support.PageFactory; -import androidtest.actions.Actions; +import com.owncloud.android.test.ui.actions.Actions; public class MoveView { final AndroidDriver driver; diff --git a/automationTest/src/test/java/androidtest/models/NewFolderPopUp.java b/automationTest/src/test/java/com/owncloud/android/test/ui/models/NewFolderPopUp.java similarity index 96% rename from automationTest/src/test/java/androidtest/models/NewFolderPopUp.java rename to automationTest/src/test/java/com/owncloud/android/test/ui/models/NewFolderPopUp.java index 31a2124a9e..560c9abe57 100644 --- a/automationTest/src/test/java/androidtest/models/NewFolderPopUp.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/models/NewFolderPopUp.java @@ -1,4 +1,4 @@ -package androidtest.models; +package com.owncloud.android.test.ui.models; import org.openqa.selenium.support.PageFactory; 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 0000000000..05d5248706 --- /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 0000000000..a101823f5e --- /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/androidtest/models/RemoveConfirmationView.java b/automationTest/src/test/java/com/owncloud/android/test/ui/models/RemoveConfirmationView.java similarity index 94% rename from automationTest/src/test/java/androidtest/models/RemoveConfirmationView.java rename to automationTest/src/test/java/com/owncloud/android/test/ui/models/RemoveConfirmationView.java index e9a1ba9d1d..1458e4fe28 100644 --- a/automationTest/src/test/java/androidtest/models/RemoveConfirmationView.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/models/RemoveConfirmationView.java @@ -1,4 +1,4 @@ -package androidtest.models; +package com.owncloud.android.test.ui.models; import io.appium.java_client.android.AndroidDriver; import io.appium.java_client.android.AndroidElement; diff --git a/automationTest/src/test/java/androidtest/models/SettingsView.java b/automationTest/src/test/java/com/owncloud/android/test/ui/models/SettingsView.java similarity index 95% rename from automationTest/src/test/java/androidtest/models/SettingsView.java rename to automationTest/src/test/java/com/owncloud/android/test/ui/models/SettingsView.java index 4e3aa48e8a..eeea7bf3e9 100644 --- a/automationTest/src/test/java/androidtest/models/SettingsView.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/models/SettingsView.java @@ -1,4 +1,4 @@ -package androidtest.models; +package com.owncloud.android.test.ui.models; import io.appium.java_client.android.AndroidDriver; import io.appium.java_client.android.AndroidElement; @@ -8,7 +8,7 @@ import io.appium.java_client.pagefactory.AppiumFieldDecorator; import org.openqa.selenium.support.CacheLookup; import org.openqa.selenium.support.PageFactory; -import androidtest.tests.Config; +import com.owncloud.android.test.ui.testSuites.Config; public class SettingsView { final AndroidDriver driver; 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 0000000000..b9258bd4f6 --- /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/androidtest/models/FilesView.java b/automationTest/src/test/java/com/owncloud/android/test/ui/models/UploadFilesView.java similarity index 77% rename from automationTest/src/test/java/androidtest/models/FilesView.java rename to automationTest/src/test/java/com/owncloud/android/test/ui/models/UploadFilesView.java index c913b1045d..f2af739eb9 100644 --- a/automationTest/src/test/java/androidtest/models/FilesView.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/models/UploadFilesView.java @@ -1,14 +1,16 @@ -package androidtest.models; +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 androidtest.actions.Actions; -public class FilesView{ +import com.owncloud.android.test.ui.actions.Actions; + +public class UploadFilesView{ final AndroidDriver driver; @CacheLookup @@ -21,15 +23,15 @@ public class FilesView{ private AndroidElement fileElement; - public FilesView (AndroidDriver driver) { + public UploadFilesView (AndroidDriver driver) { this.driver = driver; PageFactory.initElements(new AppiumFieldDecorator(driver), this); } - public MainView clickOnUploadButton () { + public FileListView clickOnUploadButton () { uploadButton.click(); - MainView mainView = new MainView (driver); - return mainView; + FileListView fileListView = new FileListView (driver); + return fileListView; } //change to scrollTillFindElement 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 0000000000..26397f5500 --- /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/androidtest/models/WaitAMomentPopUp.java b/automationTest/src/test/java/com/owncloud/android/test/ui/models/WaitAMomentPopUp.java similarity index 93% rename from automationTest/src/test/java/androidtest/models/WaitAMomentPopUp.java rename to automationTest/src/test/java/com/owncloud/android/test/ui/models/WaitAMomentPopUp.java index f566e4a208..edef1d172c 100644 --- a/automationTest/src/test/java/androidtest/models/WaitAMomentPopUp.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/models/WaitAMomentPopUp.java @@ -1,4 +1,4 @@ -package androidtest.models; +package com.owncloud.android.test.ui.models; import org.openqa.selenium.support.PageFactory; diff --git a/automationTest/src/test/java/androidtest/tests/.gitignore b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/.gitignore similarity index 100% rename from automationTest/src/test/java/androidtest/tests/.gitignore rename to automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/.gitignore diff --git a/automationTest/src/test/java/androidtest/tests/Common.java b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/Common.java similarity index 95% rename from automationTest/src/test/java/androidtest/tests/Common.java rename to automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/Common.java index aeab97d67b..d34e6e22a3 100644 --- a/automationTest/src/test/java/androidtest/tests/Common.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/Common.java @@ -1,4 +1,4 @@ -package androidtest.tests; +package com.owncloud.android.test.ui.testSuites; import static org.junit.Assert.*; import java.io.File; @@ -99,12 +99,12 @@ public class Common{ FileUtils.copyFile(file, new File(screenShotName)); } - protected void assertIsInMainView() throws InterruptedException { + 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 assertIsNotInMainView() throws InterruptedException { + protected void assertIsNotInFileListView() throws InterruptedException { AndroidElement fileElement; assertTrue(waitForTextPresent("ownCloud", (AndroidElement) driver.findElementByAndroidUIAutomator("new UiSelector().resourceId(\"android:id/action_bar_title\")"))); try { diff --git a/automationTest/src/test/java/androidtest/tests/CreateFolderTestSuite.java b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/CreateFolderTestSuite.java similarity index 59% rename from automationTest/src/test/java/androidtest/tests/CreateFolderTestSuite.java rename to automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/CreateFolderTestSuite.java index feaeb0ab95..a2bdab33f0 100644 --- a/automationTest/src/test/java/androidtest/tests/CreateFolderTestSuite.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/CreateFolderTestSuite.java @@ -1,4 +1,4 @@ -package androidtest.tests; +package com.owncloud.android.test.ui.testSuites; import static org.junit.Assert.*; import io.appium.java_client.android.AndroidDriver; @@ -12,11 +12,11 @@ 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; +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) @@ -41,27 +41,27 @@ public class CreateFolderTestSuite{ 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(); + 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, mainView, driver); + Actions.deleteElement(NEW_FOLDER_NAME, fileListView, driver); - WaitAMomentPopUp waitAMomentPopUp = Actions.createFolder(NEW_FOLDER_NAME, mainView); + WaitAMomentPopUp waitAMomentPopUp = Actions.createFolder(NEW_FOLDER_NAME, fileListView); Common.waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100); - mainView.scrollTillFindElement(FOLDER_NAME); - assertNotNull(mainView.getFileElement()); - assertTrue(folderHasBeenCreated=mainView.getFileElement().isDisplayed()); + fileListView.scrollTillFindElement(FOLDER_NAME); + assertNotNull(fileListView.getFileElement()); + assertTrue(folderHasBeenCreated=fileListView.getFileElement().isDisplayed()); CurrentCreatedFolder = FOLDER_NAME; - assertEquals(FOLDER_NAME , mainView.getFileElement().getText()); + assertEquals(FOLDER_NAME , fileListView.getFileElement().getText()); } @After public void tearDown() throws Exception { common.takeScreenShotOnFailed(name.getMethodName()); if (folderHasBeenCreated) { - MainView mainView = new MainView(driver); - Actions.deleteElement(CurrentCreatedFolder, mainView, driver); + FileListView fileListView = new FileListView(driver); + Actions.deleteElement(CurrentCreatedFolder, fileListView, driver); } driver.removeApp("com.owncloud.android"); driver.quit(); diff --git a/automationTest/src/test/java/androidtest/tests/DeleteFileTestSuite.java b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/DeleteFileTestSuite.java similarity index 50% rename from automationTest/src/test/java/androidtest/tests/DeleteFileTestSuite.java rename to automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/DeleteFileTestSuite.java index d30b4c6cb1..28e6b25131 100644 --- a/automationTest/src/test/java/androidtest/tests/DeleteFileTestSuite.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/DeleteFileTestSuite.java @@ -1,4 +1,4 @@ -package androidtest.tests; +package com.owncloud.android.test.ui.testSuites; import static org.junit.Assert.*; import io.appium.java_client.android.AndroidDriver; @@ -14,10 +14,10 @@ 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; +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) @@ -25,7 +25,7 @@ public class DeleteFileTestSuite{ AndroidDriver driver; Common common; - private final String FILE_NAME = "test"; + private final String FILE_NAME = Config.fileToTestName; @Rule public TestName name = new TestName(); @@ -38,18 +38,18 @@ public class DeleteFileTestSuite{ @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(); + FileListView fileListView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); + common.assertIsInFileListView(); //TODO. if the file already exists, do not upload - MainView mainViewAfterUploadFile = Actions.uploadFile(FILE_NAME, mainView); + FileListView fileListViewAfterUploadFile = Actions.uploadFile(FILE_NAME, fileListView); - mainViewAfterUploadFile.scrollTillFindElement(FILE_NAME); - Common.waitTillElementIsNotPresent(mainViewAfterUploadFile.getProgressCircular(), 1000); - common.wait.until(ExpectedConditions.visibilityOf(mainViewAfterUploadFile.getFileElementLayout().findElement(By.id(MainView.getLocalFileIndicator())))); + 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,mainViewAfterUploadFile, driver); - assertFalse(mainViewAfterUploadFile.getFileElement().isDisplayed()); + Actions.deleteElement(FILE_NAME,fileListViewAfterUploadFile, driver); + assertFalse(fileListViewAfterUploadFile.getFileElement().isDisplayed()); } @After diff --git a/automationTest/src/test/java/androidtest/tests/DeleteFolderTestSuite.java b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/DeleteFolderTestSuite.java similarity index 59% rename from automationTest/src/test/java/androidtest/tests/DeleteFolderTestSuite.java rename to automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/DeleteFolderTestSuite.java index fe7aabda2b..105a42dc57 100644 --- a/automationTest/src/test/java/androidtest/tests/DeleteFolderTestSuite.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/DeleteFolderTestSuite.java @@ -1,4 +1,4 @@ -package androidtest.tests; +package com.owncloud.android.test.ui.testSuites; import static org.junit.Assert.*; import io.appium.java_client.android.AndroidDriver; @@ -12,11 +12,11 @@ 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; +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) @@ -38,27 +38,27 @@ public class DeleteFolderTestSuite{ @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(); + 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, mainView); + WaitAMomentPopUp waitAMomentPopUp = Actions.createFolder(FOLDER_NAME, fileListView); Common.waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100); - mainView.scrollTillFindElement(FOLDER_NAME); - assertTrue(folderHasBeenCreated = mainView.getFileElement().isDisplayed()); + fileListView.scrollTillFindElement(FOLDER_NAME); + assertTrue(folderHasBeenCreated = fileListView.getFileElement().isDisplayed()); //delete the folder - Actions.deleteElement(FOLDER_NAME, mainView, driver); - assertFalse(folderHasBeenCreated =mainView.getFileElement().isDisplayed()); + Actions.deleteElement(FOLDER_NAME, fileListView, driver); + assertFalse(folderHasBeenCreated =fileListView.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); + 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/androidtest/tests/LoginTestSuite.java b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/LoginTestSuite.java similarity index 63% rename from automationTest/src/test/java/androidtest/tests/LoginTestSuite.java rename to automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/LoginTestSuite.java index 6aa6c2bb60..4083e8eda4 100644 --- a/automationTest/src/test/java/androidtest/tests/LoginTestSuite.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/LoginTestSuite.java @@ -1,7 +1,8 @@ -package androidtest.tests; +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; @@ -11,12 +12,13 @@ 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; + +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{ @@ -36,16 +38,16 @@ public class LoginTestSuite{ public void test1LoginPortrait () throws Exception { driver.rotate(ScreenOrientation.PORTRAIT); - MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); - common.assertIsInMainView(); + 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); - MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); - common.assertIsInMainView(); + FileListView fileListView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); + common.assertIsInFileListView(); } @@ -53,15 +55,15 @@ public class LoginTestSuite{ @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(); + FileListView fileListView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); + common.assertIsInFileListView(); driver.rotate(ScreenOrientation.PORTRAIT); - MenuList menu = mainView.clickOnMenuButton(); + MenuList menu = fileListView.clickOnMenuButton(); SettingsView settingsView = menu.clickOnSettingsButton(); settingsView.tapOnAddAccount(1, 1000); - mainView = Actions.login(Config.URL2, Config.user2,Config.password2, Config.isTrusted2, driver); + fileListView = Actions.login(Config.URL2, Config.user2,Config.password2, Config.isTrusted2, driver); common.assertIsInSettingsView(); } @@ -69,16 +71,16 @@ public class LoginTestSuite{ @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(); + FileListView fileListView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); + common.assertIsInFileListView(); driver.rotate(ScreenOrientation.LANDSCAPE); - MenuList menu = mainView.clickOnMenuButton(); + MenuList menu = fileListView.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); + 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())); } @@ -86,9 +88,9 @@ public class LoginTestSuite{ @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(); + 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(); diff --git a/automationTest/src/test/java/androidtest/tests/LogoutTestSuite.java b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/LogoutTestSuite.java similarity index 64% rename from automationTest/src/test/java/androidtest/tests/LogoutTestSuite.java rename to automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/LogoutTestSuite.java index 876c0ce41c..6ebfb635a4 100644 --- a/automationTest/src/test/java/androidtest/tests/LogoutTestSuite.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/LogoutTestSuite.java @@ -1,4 +1,4 @@ -package androidtest.tests; +package com.owncloud.android.test.ui.testSuites; import static org.junit.Assert.*; @@ -11,13 +11,13 @@ 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; +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{ @@ -35,9 +35,9 @@ public class LogoutTestSuite{ @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(); + 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(); 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 0000000000..c5070a0adc --- /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/androidtest/tests/MoveFolderTestSuite.java b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/MoveFolderTestSuite.java similarity index 51% rename from automationTest/src/test/java/androidtest/tests/MoveFolderTestSuite.java rename to automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/MoveFolderTestSuite.java index 532eff2132..d7439040c8 100644 --- a/automationTest/src/test/java/androidtest/tests/MoveFolderTestSuite.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/MoveFolderTestSuite.java @@ -1,4 +1,4 @@ -package androidtest.tests; +package com.owncloud.android.test.ui.testSuites; import static org.junit.Assert.*; import io.appium.java_client.android.AndroidDriver; @@ -12,13 +12,13 @@ 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; +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) @@ -41,29 +41,29 @@ public class MoveFolderTestSuite{ public void testMoveFolder () throws Exception { WaitAMomentPopUp waitAMomentPopUp; - MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); - common.assertIsInMainView(); + FileListView fileListView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); + common.assertIsInFileListView(); - Common.waitTillElementIsNotPresent(mainView.getProgressCircular(), 1000); + //Common.waitTillElementIsNotPresent(fileListView.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); + 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, mainView); + waitAMomentPopUp = Actions.createFolder(FOLDER_WHERE_MOVE, fileListView); Common.waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100); - mainView.scrollTillFindElement(FOLDER_WHERE_MOVE); - assertTrue(mainView.getFileElement().isDisplayed()); + fileListView.scrollTillFindElement(FOLDER_WHERE_MOVE); + assertTrue(fileListView.getFileElement().isDisplayed()); //Create the folder which is going to be moved - waitAMomentPopUp = Actions.createFolder(FOLDER_TO_MOVE, mainView); + waitAMomentPopUp = Actions.createFolder(FOLDER_TO_MOVE, fileListView); Common.waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100); - mainView.scrollTillFindElement(FOLDER_TO_MOVE); - assertTrue(mainView.getFileElement().isDisplayed()); + fileListView.scrollTillFindElement(FOLDER_TO_MOVE); + assertTrue(fileListView.getFileElement().isDisplayed()); //select to move the folder - ElementMenuOptions menuOptions = mainView.longPressOnElement(FOLDER_TO_MOVE); + ElementMenuOptions menuOptions = fileListView.longPressOnElement(FOLDER_TO_MOVE); MoveView moveView = menuOptions.clickOnMove(); //to move to a folder @@ -72,20 +72,20 @@ public class MoveFolderTestSuite{ 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); + fileListView.scrollTillFindElement(FOLDER_WHERE_MOVE).tap(1,1); + Common.waitTillElementIsNotPresent(fileListView.getProgressCircular(), 1000); Thread.sleep(1000); - mainView.scrollTillFindElement(FOLDER_TO_MOVE); - assertEquals(FOLDER_TO_MOVE , mainView.getFileElement().getText()); + fileListView.scrollTillFindElement(FOLDER_TO_MOVE); + assertEquals(FOLDER_TO_MOVE , fileListView.getFileElement().getText()); } @After public void tearDown() throws Exception { common.takeScreenShotOnFailed(name.getMethodName()); - MainView mainView = new MainView(driver); + FileListView fileListView = new FileListView(driver); driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_BACK); - Actions.deleteElement(FOLDER_WHERE_MOVE, mainView, driver); - Actions.deleteElement(FOLDER_TO_MOVE, mainView, driver); + 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 0000000000..7b50af8863 --- /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 0000000000..15015c0699 --- /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 0000000000..4c9b293be9 --- /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/androidtest/tests/RenameFolderTestSuite.java b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/RenameFolderTestSuite.java similarity index 58% rename from automationTest/src/test/java/androidtest/tests/RenameFolderTestSuite.java rename to automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/RenameFolderTestSuite.java index c97c3e0be9..0983f017f7 100644 --- a/automationTest/src/test/java/androidtest/tests/RenameFolderTestSuite.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/RenameFolderTestSuite.java @@ -1,4 +1,4 @@ -package androidtest.tests; +package com.owncloud.android.test.ui.testSuites; import static org.junit.Assert.*; import io.appium.java_client.android.AndroidDriver; @@ -12,13 +12,13 @@ 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; +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) @@ -43,39 +43,39 @@ public class RenameFolderTestSuite{ @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(); + 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, mainView); + WaitAMomentPopUp waitAMomentPopUp = Actions.createFolder(OLD_FOLDER_NAME, fileListView); Common.waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100); - mainView.scrollTillFindElement(OLD_FOLDER_NAME); + fileListView.scrollTillFindElement(OLD_FOLDER_NAME); - assertTrue(folderHasBeenCreated = mainView.getFileElement().isDisplayed()); + assertTrue(folderHasBeenCreated = fileListView.getFileElement().isDisplayed()); //check if the folder with the new name already exists and if true, delete them - Actions.deleteElement(FOLDER_NAME, mainView, driver); + Actions.deleteElement(FOLDER_NAME, fileListView, driver); CurrentCreatedFolder = OLD_FOLDER_NAME; - ElementMenuOptions menuOptions = mainView.longPressOnElement(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); - mainView.scrollTillFindElement(FOLDER_NAME); - assertNotNull(mainView.getFileElement()); - assertTrue(folderHasBeenCreated = mainView.getFileElement().isDisplayed()); - assertEquals(FOLDER_NAME , mainView.getFileElement().getText()); + 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){ - MainView mainView = new MainView(driver); - Actions.deleteElement(CurrentCreatedFolder, mainView, driver); + 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 0000000000..53d69fd025 --- /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 0000000000..bfa7dbf5ed --- /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 0000000000..ad4738f030 --- /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 0000000000..147801f8e2 --- /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 0000000000..cbea9785ae --- /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(); + } + + +} + From 7f24cb41fbd2a60edbd5ba29a789dabb6a45d697 Mon Sep 17 00:00:00 2001 From: purigarcia Date: Tue, 12 May 2015 13:36:38 +0200 Subject: [PATCH 08/27] some changes needed to uploads from gmail --- .../com/owncloud/android/test/ui/models/GmailEmailListView.java | 2 +- .../owncloud/android/test/ui/testSuites/UploadTestSuite.java | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) 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 index 5bf3690197..8690eb5084 100644 --- 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 @@ -10,7 +10,7 @@ public class GmailEmailListView { final AndroidDriver driver; - @AndroidFindBy(uiAutomator = "new UiSelector().description(\"me about UploadFile, at 9:53 AM, conversation read\")") + @AndroidFindBy(uiAutomator = "new UiSelector().description(\"me about UploadFile, on May 11, conversation read\")") private AndroidElement email; public GmailEmailListView (AndroidDriver driver) { 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 index cbea9785ae..5e1354c975 100644 --- 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 @@ -72,6 +72,7 @@ public class UploadTestSuite{ 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); + Thread.sleep(3000); GmailEmailView gmailEmailView = gmailEmailListView.clickOnEmail(); ImageView imageView = gmailEmailView.clickOnfileButton(); imageView.clickOnOptionsButton(); From 3567b86e77b872060665c8ea863180ca60403904 Mon Sep 17 00:00:00 2001 From: purigarcia Date: Thu, 14 May 2015 10:13:14 +0200 Subject: [PATCH 09/27] fix upload test cases --- .../test/ui/models/GmailEmailListView.java | 11 ++++- .../android/test/ui/models/ImageView.java | 31 ++++++------ .../android/test/ui/testSuites/Common.java | 2 +- .../test/ui/testSuites/UploadTestSuite.java | 47 ++++++++++++++----- 4 files changed, 62 insertions(+), 29 deletions(-) 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 index 8690eb5084..43084fffd5 100644 --- 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 @@ -4,6 +4,8 @@ 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.NoSuchElementException; import org.openqa.selenium.support.PageFactory; public class GmailEmailListView { @@ -12,6 +14,9 @@ public class GmailEmailListView { @AndroidFindBy(uiAutomator = "new UiSelector().description(\"me about UploadFile, on May 11, conversation read\")") private AndroidElement email; + @AndroidFindBy(uiAutomator = "new UiSelector().description(\"me about UploadFile, on 11 May, conversation read\")") + private AndroidElement email2; + public GmailEmailListView (AndroidDriver driver) { this.driver = driver; @@ -19,7 +24,11 @@ public class GmailEmailListView { } public GmailEmailView clickOnEmail (){ - email.click(); + try{ + email.click(); + }catch (NoSuchElementException e) { + email2.click(); + } GmailEmailView gmailEmailView = new GmailEmailView(driver); return gmailEmailView; } 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 index da8c30b682..8803b29080 100644 --- 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 @@ -4,52 +4,55 @@ 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; +import com.owncloud.android.test.ui.testSuites.Common; 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 = "Share with ownCloud") + private AndroidElement shareWithOwnCloudButton; + @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()) { + if(Common.isElementPresent(ownCloudButton)){ Actions.scrollTillFindElement("ownCloud", sharingAppsLayout, driver); - } - ownCloudButton.click(); + ownCloudButton.click(); + }else if(Common.isElementPresent(shareWithOwnCloudButton)){} } - + public void clickOnJustOnceButton(){ justOnceButton.click(); } 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 index d34e6e22a3..4e45bb6c22 100644 --- 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 @@ -67,7 +67,7 @@ public class Common{ } } - protected boolean isElementPresent(AndroidElement element) { + public static boolean isElementPresent(AndroidElement element) { try{ element.isDisplayed(); } catch (NoSuchElementException e){ 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 index 5e1354c975..84c228edca 100644 --- 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 @@ -14,12 +14,14 @@ import org.junit.runners.MethodSorters; import org.junit.FixMethodOrder; import org.junit.Test; import org.openqa.selenium.By; +import org.openqa.selenium.NoSuchElementException; 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.groups.UnfinishedTestCategory; import com.owncloud.android.test.ui.models.FileDetailsView; import com.owncloud.android.test.ui.models.ElementMenuOptions; import com.owncloud.android.test.ui.models.GmailEmailListView; @@ -36,9 +38,12 @@ public class UploadTestSuite{ AndroidDriver driver; Common common; String FILE_NAME = Config.fileToTestName; - + String FILE_GMAIL_NAME = Config.fileToTestSendByEmailName; + private Boolean fileHasBeenUploadedFromGmail = false; + private Boolean fileHasBeenUploaded = false; + @Rule public TestName name = new TestName(); - + @Before public void setUp() throws Exception { @@ -63,11 +68,13 @@ public class UploadTestSuite{ 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()); - + fileListView = new FileListView(driver); + fileListView.scrollTillFindElement(FILE_NAME); + assertTrue(fileHasBeenUploaded = fileListView.getFileElement().isDisplayed()); } - + @Test - @Category(IgnoreTestCategory.class) + @Category(UnfinishedTestCategory.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"); @@ -78,17 +85,26 @@ public class UploadTestSuite{ imageView.clickOnOptionsButton(); imageView.clickOnShareButton(); imageView.clickOnOwnCloudButton(); - imageView.clickOnJustOnceButton(); + //justonce button do not appear always + try{ + imageView.clickOnJustOnceButton(); + }catch (NoSuchElementException e) { + } UploadView uploadView = new UploadView(driver); uploadView.clickOUploadButton(); + driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_HOME); 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()); + common.wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.name(FILE_GMAIL_NAME))); + assertEquals(Config.fileToTestSendByEmailName , driver.findElementByName(FILE_GMAIL_NAME).getText()); + fileListView = new FileListView(driver); + fileListView.scrollTillFindElement(FILE_GMAIL_NAME); + assertTrue(fileHasBeenUploadedFromGmail = fileListView.getFileElement().isDisplayed()); + //TODO. correct assert if fileListView is shown in grid mode } - + @Test - @Category({IgnoreTestCategory.class, FailingTestCategory.class}) + @Category({FailingTestCategory.class}) public void testKeepFileUpToDate () throws Exception { FileListView fileListView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); @@ -105,9 +121,8 @@ public class UploadTestSuite{ fileDetailsView.checkKeepFileUpToDateCheckbox(); Thread.sleep(3000); driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_BACK); - //assertTrue(common.isElementPresent(fileListViewAfterUploadFile.getFileElementLayout(), MobileBy.id(FileListView.getFavoriteFileIndicator()))); + assertTrue(common.isElementPresent(fileListViewAfterUploadFile.getFileElementLayout(), MobileBy.id(FileListView.getFavoriteFileIndicator()))); assertTrue(fileListViewAfterUploadFile.getFileElementLayout().findElement(By.id(FileListView.getFavoriteFileIndicator())).isDisplayed()); - } @@ -115,7 +130,13 @@ public class UploadTestSuite{ public void tearDown() throws Exception { common.takeScreenShotOnFailed(name.getMethodName()); FileListView fileListView = new FileListView(driver); - Actions.deleteElement(FILE_NAME,fileListView, driver); + if (fileHasBeenUploadedFromGmail) { + Actions.deleteElement(FILE_GMAIL_NAME,fileListView, driver); + } + if(fileHasBeenUploaded){ + Actions.deleteElement(FILE_NAME,fileListView, driver); + } + driver.removeApp("com.owncloud.android"); driver.quit(); } From b4b160d21909e2c9051d8f78036f625bdec75f0b Mon Sep 17 00:00:00 2001 From: purigarcia Date: Thu, 14 May 2015 10:15:34 +0200 Subject: [PATCH 10/27] change the name of a variable --- .../android/test/ui/models/GmailEmailListView.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 index 43084fffd5..f3d0f8100f 100644 --- 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 @@ -13,9 +13,9 @@ public class GmailEmailListView { final AndroidDriver driver; @AndroidFindBy(uiAutomator = "new UiSelector().description(\"me about UploadFile, on May 11, conversation read\")") - private AndroidElement email; + private AndroidElement emailAmericanFormatDate; @AndroidFindBy(uiAutomator = "new UiSelector().description(\"me about UploadFile, on 11 May, conversation read\")") - private AndroidElement email2; + private AndroidElement emailEuropeanFormatDate; public GmailEmailListView (AndroidDriver driver) { @@ -25,9 +25,9 @@ public class GmailEmailListView { public GmailEmailView clickOnEmail (){ try{ - email.click(); + emailAmericanFormatDate.click(); }catch (NoSuchElementException e) { - email2.click(); + emailEuropeanFormatDate.click(); } GmailEmailView gmailEmailView = new GmailEmailView(driver); return gmailEmailView; From 8386357e687544f53a7e4417bcbab1eff6a0d135 Mon Sep 17 00:00:00 2001 From: purigarcia Date: Fri, 15 May 2015 12:32:16 +0200 Subject: [PATCH 11/27] add headers. reformat files --- .../android/test/ui/actions/Actions.java | 80 ++++++++++++++----- .../test/ui/groups/FailingTestCategory.java | 19 +++++ .../test/ui/groups/IgnoreTestCategory.java | 20 +++++ .../test/ui/groups/NoIgnoreTestCategory.java | 20 +++++ .../test/ui/groups/OtherTestCategory.java | 20 +++++ .../test/ui/groups/SmokeTestCategory.java | 20 +++++ .../ui/groups/UnfinishedTestCategory.java | 20 +++++ .../test/ui/models/CertificatePopUp.java | 20 +++++ .../test/ui/models/ElementMenuOptions.java | 23 +++++- .../test/ui/models/FileDetailsView.java | 20 +++++ .../android/test/ui/models/FileListView.java | 51 +++++++++--- .../test/ui/models/GmailEmailListView.java | 26 +++++- .../test/ui/models/GmailEmailView.java | 20 +++++ .../test/ui/models/GmailSendMailView.java | 20 +++++ .../android/test/ui/models/ImageView.java | 25 +++++- .../android/test/ui/models/LoginForm.java | 32 +++++++- .../android/test/ui/models/MenuList.java | 20 +++++ .../android/test/ui/models/MoveView.java | 20 +++++ .../test/ui/models/NewFolderPopUp.java | 26 +++++- .../test/ui/models/PassCodeRequestView.java | 38 +++++++-- .../android/test/ui/models/PassCodeView.java | 44 ++++++++-- .../ui/models/RemoveConfirmationView.java | 20 +++++ .../android/test/ui/models/SettingsView.java | 23 +++++- .../android/test/ui/models/ShareView.java | 20 +++++ .../test/ui/models/UploadFilesView.java | 23 +++++- .../android/test/ui/models/UploadView.java | 20 +++++ .../test/ui/models/WaitAMomentPopUp.java | 20 +++++ .../android/test/ui/testSuites/Common.java | 75 +++++++++++++---- .../ui/testSuites/CreateFolderTestSuite.java | 32 +++++++- .../ui/testSuites/DeleteFileTestSuite.java | 33 +++++++- .../ui/testSuites/DeleteFolderTestSuite.java | 35 ++++++-- .../test/ui/testSuites/LoginTestSuite.java | 51 +++++++++--- .../test/ui/testSuites/LogoutTestSuite.java | 26 +++++- .../test/ui/testSuites/MoveFileTestSuite.java | 44 ++++++++-- .../ui/testSuites/MoveFolderTestSuite.java | 44 ++++++++-- .../test/ui/testSuites/PasscodeTestSuite.java | 42 ++++++++-- .../ui/testSuites/RefreshFolderTestSuite.java | 26 +++++- .../ui/testSuites/RenameFileTestSuite.java | 48 ++++++++--- .../ui/testSuites/RenameFolderTestSuite.java | 44 ++++++++-- .../test/ui/testSuites/RunFailingTests.java | 20 +++++ .../test/ui/testSuites/RunNoIgnoreTests.java | 20 +++++ .../test/ui/testSuites/RunSmokeTests.java | 20 +++++ .../ui/testSuites/ShareLinkFileTestSuite.java | 46 +++++++++-- .../test/ui/testSuites/UploadTestSuite.java | 78 +++++++++++++----- 44 files changed, 1228 insertions(+), 166 deletions(-) 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 index ae41573ce2..6d592179bb 100644 --- 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 @@ -1,3 +1,23 @@ +/** + * ownCloud Android client application + * + * @author purigarcia + * Copyright (C) 2015 ownCloud Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + package com.owncloud.android.test.ui.actions; import java.util.HashMap; @@ -26,15 +46,20 @@ 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 { + 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 + //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 + 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(); @@ -49,26 +74,30 @@ public class Actions { return loginForm.clickOnConnectButton(); } - public static WaitAMomentPopUp createFolder(String folderName, FileListView fileListView){ + public static WaitAMomentPopUp createFolder(String folderName, + FileListView fileListView){ NewFolderPopUp newFolderPopUp = fileListView.clickOnNewFolderButton(); newFolderPopUp.typeNewFolderName(folderName); - WaitAMomentPopUp waitAMomentPopUp = newFolderPopUp.clickOnNewFolderOkButton(); + WaitAMomentPopUp waitAMomentPopUp = newFolderPopUp + .clickOnNewFolderOkButton(); //TODO. assert here return waitAMomentPopUp; } - public static AndroidElement scrollTillFindElement (String elementName, AndroidElement element, AndroidDriver driver) { + public static AndroidElement scrollTillFindElement (String elementName, + AndroidElement element, AndroidDriver driver) { AndroidElement fileElement; if(element.getAttribute("scrollable").equals("true")){ - HashMap scrollObject = new HashMap(); + 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); + fileElement = (AndroidElement) driver + .findElementByName(elementName); } catch (NoSuchElementException e) { fileElement = null; } @@ -92,28 +121,39 @@ public class Actions { } //TODO. convert deleteFodler and deleteFile in deleteElement - public static AndroidElement deleteElement(String elementName, FileListView fileListView, AndroidDriver driver) throws Exception{ + 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); + //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{ + public static FileListView uploadFile(String elementName, + FileListView fileListView) throws InterruptedException{ fileListView.clickOnUploadButton(); - UploadFilesView uploadFilesView = fileListView.clickOnFilesElementUploadFile(); + UploadFilesView uploadFilesView = fileListView + .clickOnFilesElementUploadFile(); uploadFilesView.clickOnFileName(elementName); - FileListView fileListViewAfterUploadFile = uploadFilesView.clickOnUploadButton(); + 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 index b8f6eae546..2a91e7ffc9 100644 --- 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 @@ -1,3 +1,22 @@ +/** + * ownCloud Android client application + * + * @author purigarcia + * Copyright (C) 2015 ownCloud Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ 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/IgnoreTestCategory.java b/automationTest/src/test/java/com/owncloud/android/test/ui/groups/IgnoreTestCategory.java index 6d252f3e10..2586edb7d5 100644 --- 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 @@ -1,3 +1,23 @@ +/** + * ownCloud Android client application + * + * @author purigarcia + * Copyright (C) 2015 ownCloud Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + 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 index 50d4170151..321fb08855 100644 --- 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 @@ -1,3 +1,23 @@ +/** + * ownCloud Android client application + * + * @author purigarcia + * Copyright (C) 2015 ownCloud Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + 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 index 8f0094e3b6..b14c36e48b 100644 --- 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 @@ -1,3 +1,23 @@ +/** + * ownCloud Android client application + * + * @author purigarcia + * Copyright (C) 2015 ownCloud Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + 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/SmokeTestCategory.java b/automationTest/src/test/java/com/owncloud/android/test/ui/groups/SmokeTestCategory.java index 69f3ad100f..ebac5fecf4 100644 --- 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 @@ -1,3 +1,23 @@ +/** + * ownCloud Android client application + * + * @author purigarcia + * Copyright (C) 2015 ownCloud Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + 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 index 8d66b2bde0..2a1451d557 100644 --- 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 @@ -1,3 +1,23 @@ +/** + * ownCloud Android client application + * + * @author purigarcia + * Copyright (C) 2015 ownCloud Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + 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 index 41cd4ae47c..1908ac9feb 100644 --- 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 @@ -1,3 +1,23 @@ +/** + * ownCloud Android client application + * + * @author purigarcia + * Copyright (C) 2015 ownCloud Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + package com.owncloud.android.test.ui.models; import io.appium.java_client.android.AndroidDriver; 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 index 844ad1fe43..ccf9bd4e16 100644 --- 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 @@ -1,3 +1,23 @@ +/** + * ownCloud Android client application + * + * @author purigarcia + * Copyright (C) 2015 ownCloud Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + package com.owncloud.android.test.ui.models; import io.appium.java_client.android.AndroidDriver; @@ -39,7 +59,8 @@ public class ElementMenuOptions { public RemoveConfirmationView clickOnRemove () { removeFileElement.click(); - RemoveConfirmationView removeConfirmationView = new RemoveConfirmationView(driver); + RemoveConfirmationView removeConfirmationView = + new RemoveConfirmationView(driver); return removeConfirmationView; } 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 index 1410d95816..46da42fd29 100644 --- 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 @@ -1,3 +1,23 @@ +/** + * ownCloud Android client application + * + * @author purigarcia + * Copyright (C) 2015 ownCloud Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + package com.owncloud.android.test.ui.models; import io.appium.java_client.android.AndroidDriver; 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 index f75347472e..f10e7aa3c6 100644 --- 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 @@ -1,3 +1,23 @@ +/** + * ownCloud Android client application + * + * @author purigarcia + * Copyright (C) 2015 ownCloud Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + package com.owncloud.android.test.ui.models; import java.util.List; @@ -18,7 +38,8 @@ import com.owncloud.android.test.ui.actions.Actions; public class FileListView { final AndroidDriver driver; - @AndroidFindBy(uiAutomator = "new UiSelector().description(\"More options\")") + @AndroidFindBy(uiAutomator = "new UiSelector()" + + ".description(\"More options\")") private AndroidElement menuButton; @CacheLookup @@ -26,14 +47,16 @@ public class FileListView { private AndroidElement filesLayout; @CacheLookup - @AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"android:id/action_bar_title\")") + @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\")") + @AndroidFindBy(uiAutomator = "new UiSelector()" + + ".description(\"New folder\")") private AndroidElement newFolderButton; @CacheLookup @@ -52,16 +75,20 @@ public class FileListView { private AndroidElement filesElementUploadFile; @CacheLookup - @AndroidFindBy(uiAutomator = "new UiSelector().description(\"List Layout\")") + @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"; + 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) { @@ -133,9 +160,12 @@ public class FileListView { } public AndroidElement scrollTillFindElement (String elementName) { - fileElement = Actions.scrollTillFindElement (elementName,filesLayout,driver); + fileElement = Actions + .scrollTillFindElement (elementName,filesLayout,driver); try { - fileElementLayout = (AndroidElement) driver.findElementByAndroidUIAutomator("new UiSelector().description(\"LinearLayout-"+ elementName +"\")"); + fileElementLayout = (AndroidElement) driver + .findElementByAndroidUIAutomator("new UiSelector()" + + ".description(\"LinearLayout-"+ elementName +"\")"); } catch (NoSuchElementException e) { fileElementLayout = null; } @@ -163,7 +193,8 @@ public class FileListView { } public void pulldownToRefresh () throws InterruptedException { Point listLocation = listLayout.getLocation(); - driver.swipe(listLocation.getX(),listLocation.getY(), listLocation.getX(),listLocation.getY()+1000, 5000); + 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 index f3d0f8100f..a6b6975141 100644 --- 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 @@ -1,3 +1,23 @@ +/** + * ownCloud Android client application + * + * @author purigarcia + * Copyright (C) 2015 ownCloud Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + package com.owncloud.android.test.ui.models; import io.appium.java_client.android.AndroidDriver; @@ -12,9 +32,11 @@ public class GmailEmailListView { final AndroidDriver driver; - @AndroidFindBy(uiAutomator = "new UiSelector().description(\"me about UploadFile, on May 11, conversation read\")") + @AndroidFindBy(uiAutomator = "new UiSelector().description(\"" + + "me about UploadFile, on May 11, conversation read\")") private AndroidElement emailAmericanFormatDate; - @AndroidFindBy(uiAutomator = "new UiSelector().description(\"me about UploadFile, on 11 May, conversation read\")") + @AndroidFindBy(uiAutomator = "new UiSelector().description(\"" + + "me about UploadFile, on 11 May, conversation read\")") private AndroidElement emailEuropeanFormatDate; 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 index a5797014a1..6d6acd7973 100644 --- 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 @@ -1,3 +1,23 @@ +/** + * ownCloud Android client application + * + * @author purigarcia + * Copyright (C) 2015 ownCloud Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + package com.owncloud.android.test.ui.models; import io.appium.java_client.android.AndroidDriver; 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 index 264a61c4e4..a8688157cf 100644 --- 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 @@ -1,3 +1,23 @@ +/** + * ownCloud Android client application + * + * @author purigarcia + * Copyright (C) 2015 ownCloud Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + package com.owncloud.android.test.ui.models; import io.appium.java_client.android.AndroidDriver; 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 index 8803b29080..c0f13fcc14 100644 --- 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 @@ -1,3 +1,23 @@ +/** + * ownCloud Android client application + * + * @author purigarcia + * Copyright (C) 2015 ownCloud Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + package com.owncloud.android.test.ui.models; import io.appium.java_client.android.AndroidDriver; @@ -15,7 +35,8 @@ public class ImageView { final AndroidDriver driver; @CacheLookup - @AndroidFindBy(uiAutomator = "new UiSelector().description(\"More options\")") + @AndroidFindBy(uiAutomator = "new UiSelector()" + + ".description(\"More options\")") private AndroidElement optionsButton; @AndroidFindBy(name = "Share") @@ -48,7 +69,7 @@ public class ImageView { public void clickOnOwnCloudButton(){ if(Common.isElementPresent(ownCloudButton)){ - Actions.scrollTillFindElement("ownCloud", sharingAppsLayout, driver); + Actions.scrollTillFindElement("ownCloud",sharingAppsLayout,driver); ownCloudButton.click(); }else if(Common.isElementPresent(shareWithOwnCloudButton)){} } 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 index 6971cc233f..aaef6aedfd 100644 --- 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 @@ -1,3 +1,23 @@ +/** + * ownCloud Android client application + * + * @author purigarcia + * Copyright (C) 2015 ownCloud Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + package com.owncloud.android.test.ui.models; import org.openqa.selenium.support.CacheLookup; @@ -12,7 +32,8 @@ public class LoginForm { final AndroidDriver driver; @CacheLookup - @AndroidFindBy(uiAutomator = "new UiSelector().description(\"Server address\")") + @AndroidFindBy(uiAutomator = "new UiSelector()" + + ".description(\"Server address\")") private AndroidElement hostUrlInput; @CacheLookup @@ -27,10 +48,12 @@ public class LoginForm { @AndroidFindBy(uiAutomator = "new UiSelector().description(\"Connect\")") private AndroidElement connectButton; - @AndroidFindBy(uiAutomator = "new UiSelector().description(\"Testing connection\")") + @AndroidFindBy(uiAutomator = "new UiSelector()" + + ".description(\"Testing connection\")") private AndroidElement serverStatusText; - @AndroidFindBy(uiAutomator = "new UiSelector().description(\"Wrong username or password\")") + @AndroidFindBy(uiAutomator = "new UiSelector()" + + ".description(\"Wrong username or password\")") private AndroidElement authStatusText; public LoginForm (AndroidDriver driver) { @@ -51,7 +74,8 @@ public class LoginForm { public void typeUserName (String userName) { userNameInput.clear(); - //using the \n , it not need to hide the keyboard which sometimes gives problems + //using the \n , it not need to hide the keyboard + //which sometimes gives problems userNameInput.sendKeys(userName + "\n"); //driver.hideKeyboard(); } 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 index 9dade478f3..132e6717cf 100644 --- 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 @@ -1,3 +1,23 @@ +/** + * ownCloud Android client application + * + * @author purigarcia + * Copyright (C) 2015 ownCloud Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + package com.owncloud.android.test.ui.models; import org.openqa.selenium.support.PageFactory; 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 index 5be7b69dc9..222a268eff 100644 --- 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 @@ -1,3 +1,23 @@ +/** + * ownCloud Android client application + * + * @author purigarcia + * Copyright (C) 2015 ownCloud Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + package com.owncloud.android.test.ui.models; import io.appium.java_client.android.AndroidDriver; 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 index 560c9abe57..fb28066272 100644 --- 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 @@ -1,3 +1,23 @@ +/** + * ownCloud Android client application + * + * @author purigarcia + * Copyright (C) 2015 ownCloud Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + package com.owncloud.android.test.ui.models; import org.openqa.selenium.support.PageFactory; @@ -11,10 +31,12 @@ public class NewFolderPopUp { final AndroidDriver driver; - @AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"android:id/button1\")") + @AndroidFindBy(uiAutomator = "new UiSelector()" + + ".resourceId(\"android:id/button1\")") private AndroidElement newFolderOkButton; - @AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"com.owncloud.android:id/user_input\")") + @AndroidFindBy(uiAutomator = "new UiSelector()" + + ".resourceId(\"com.owncloud.android:id/user_input\")") private AndroidElement newFolderNameField; public NewFolderPopUp (AndroidDriver driver) { 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 index 05d5248706..52744cb568 100644 --- 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 @@ -1,3 +1,23 @@ +/** + * ownCloud Android client application + * + * @author purigarcia + * Copyright (C) 2015 ownCloud Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + package com.owncloud.android.test.ui.models; import org.openqa.selenium.support.PageFactory; @@ -10,16 +30,20 @@ import io.appium.java_client.pagefactory.AppiumFieldDecorator; public class PassCodeRequestView { final AndroidDriver driver; - @AndroidFindBy(uiAutomator = "new UiSelector().className(\"android.widget.EditText\").index(0)") + @AndroidFindBy(uiAutomator = "new UiSelector()" + + ".className(\"android.widget.EditText\").index(0)") private AndroidElement codeElement1; - @AndroidFindBy(uiAutomator = "new UiSelector().className(\"android.widget.EditText\").index(1)") + @AndroidFindBy(uiAutomator = "new UiSelector()" + + ".className(\"android.widget.EditText\").index(1)") private AndroidElement codeElement2; - @AndroidFindBy(uiAutomator = "new UiSelector().className(\"android.widget.EditText\").index(2)") + @AndroidFindBy(uiAutomator = "new UiSelector()" + + ".className(\"android.widget.EditText\").index(2)") private AndroidElement codeElement3; - @AndroidFindBy(uiAutomator = "new UiSelector().className(\"android.widget.EditText\").index(3)") + @AndroidFindBy(uiAutomator = "new UiSelector()" + + ".className(\"android.widget.EditText\").index(3)") private AndroidElement codeElement4; public PassCodeRequestView (AndroidDriver driver) { @@ -27,8 +51,10 @@ final AndroidDriver driver; PageFactory.initElements(new AppiumFieldDecorator(driver), this); } - public void enterPasscode(String codeNumber1, String codeNumber2, String codeNumber3, String codeNumber4){ - codeElement1.sendKeys(codeNumber1 + codeNumber1 + codeNumber1 + codeNumber1); + 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 index a101823f5e..6f84fca582 100644 --- 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 @@ -1,3 +1,23 @@ +/** + * ownCloud Android client application + * + * @author purigarcia + * Copyright (C) 2015 ownCloud Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + package com.owncloud.android.test.ui.models; import io.appium.java_client.android.AndroidDriver; @@ -10,16 +30,20 @@ import org.openqa.selenium.support.PageFactory; public class PassCodeView { final AndroidDriver driver; - @AndroidFindBy(uiAutomator = "new UiSelector().className(\"android.widget.EditText\").index(0)") + @AndroidFindBy(uiAutomator = "new UiSelector()" + + ".className(\"android.widget.EditText\").index(0)") private AndroidElement codeElement1; - @AndroidFindBy(uiAutomator = "new UiSelector().className(\"android.widget.EditText\").index(1)") + @AndroidFindBy(uiAutomator = "new UiSelector()" + + ".className(\"android.widget.EditText\").index(1)") private AndroidElement codeElement2; - @AndroidFindBy(uiAutomator = "new UiSelector().className(\"android.widget.EditText\").index(2)") + @AndroidFindBy(uiAutomator = "new UiSelector()" + + ".className(\"android.widget.EditText\").index(2)") private AndroidElement codeElement3; - @AndroidFindBy(uiAutomator = "new UiSelector().className(\"android.widget.EditText\").index(3)") + @AndroidFindBy(uiAutomator = "new UiSelector()" + + ".className(\"android.widget.EditText\").index(3)") private AndroidElement codeElement4; @AndroidFindBy(name = "Cancel") @@ -30,12 +54,16 @@ public class PassCodeView { PageFactory.initElements(new AppiumFieldDecorator(driver), this); } - public PassCodeView enterPasscode(String codeNumber1, String codeNumber2, String codeNumber3, String codeNumber4){ - codeElement1.sendKeys(codeNumber1 + codeNumber1 + codeNumber1 + codeNumber1); + 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); + 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 index 1458e4fe28..5b0c06617b 100644 --- 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 @@ -1,3 +1,23 @@ +/** + * ownCloud Android client application + * + * @author purigarcia + * Copyright (C) 2015 ownCloud Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + package com.owncloud.android.test.ui.models; import io.appium.java_client.android.AndroidDriver; 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 index eeea7bf3e9..43d31ecd28 100644 --- 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 @@ -1,3 +1,23 @@ +/** + * ownCloud Android client application + * + * @author purigarcia + * Copyright (C) 2015 ownCloud Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + package com.owncloud.android.test.ui.models; import io.appium.java_client.android.AndroidDriver; @@ -30,7 +50,8 @@ public class SettingsView { @AndroidFindBy(name = "Add account") private AndroidElement addAccountElement; - @AndroidFindBy(uiAutomator = "new UiSelector().className(\"android.widget.CheckBox\").index(0)") + @AndroidFindBy(uiAutomator = "new UiSelector()" + + ".className(\"android.widget.CheckBox\").index(0)") private AndroidElement passcodeCheckbox; public SettingsView (AndroidDriver driver) { 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 index b9258bd4f6..650671ba35 100644 --- 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 @@ -1,3 +1,23 @@ +/** + * ownCloud Android client application + * + * @author purigarcia + * Copyright (C) 2015 ownCloud Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + package com.owncloud.android.test.ui.models; import io.appium.java_client.android.AndroidDriver; 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 index f2af739eb9..599e90c1da 100644 --- 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 @@ -1,3 +1,23 @@ +/** + * ownCloud Android client application + * + * @author purigarcia + * Copyright (C) 2015 ownCloud Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + package com.owncloud.android.test.ui.models; import io.appium.java_client.android.AndroidDriver; @@ -36,7 +56,8 @@ public class UploadFilesView{ //change to scrollTillFindElement public void scrollTillFindFile (String fileName) { - fileElement = Actions.scrollTillFindElement (fileName,filesLayout,driver); + fileElement = Actions + .scrollTillFindElement(fileName,filesLayout,driver); } public void clickOnFileName (String fileName) { 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 index 26397f5500..5975c9af7d 100644 --- 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 @@ -1,3 +1,23 @@ +/** + * ownCloud Android client application + * + * @author purigarcia + * Copyright (C) 2015 ownCloud Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + package com.owncloud.android.test.ui.models; import io.appium.java_client.android.AndroidDriver; 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 index edef1d172c..d296235b57 100644 --- 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 @@ -1,3 +1,23 @@ +/** + * ownCloud Android client application + * + * @author purigarcia + * Copyright (C) 2015 ownCloud Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + package com.owncloud.android.test.ui.models; import org.openqa.selenium.support.PageFactory; 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 index 4e45bb6c22..6a40be29e0 100644 --- 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 @@ -1,3 +1,23 @@ +/** + * ownCloud Android client application + * + * @author purigarcia + * Copyright (C) 2015 ownCloud Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + package com.owncloud.android.test.ui.testSuites; import static org.junit.Assert.*; @@ -34,16 +54,21 @@ public class Common{ 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); + 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{ + protected boolean waitForTextPresent(String text, AndroidElement element) + throws InterruptedException{ for (int second = 0;;second++){ if (second >= waitingTime) return false; @@ -77,7 +102,8 @@ public class Common{ } //pollingTime in milliseconds - public static void waitTillElementIsNotPresent (AndroidElement element, int pollingTime) throws Exception { + public static void waitTillElementIsNotPresent (AndroidElement element, + int pollingTime) throws Exception { for (int time = 0;;time += pollingTime){ if (time >= waitingTime * 1000) //convert to milliseconds break; @@ -91,24 +117,35 @@ public class Common{ throw new TimeoutException(); } - protected void takeScreenShotOnFailed (String testName) throws IOException { - File file = ((RemoteWebDriver) driver).getScreenshotAs(OutputType.FILE); + 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"; + 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\")"))); + 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\")"))); + assertTrue(waitForTextPresent("ownCloud", (AndroidElement) driver + .findElementByAndroidUIAutomator("new UiSelector()" + + ".resourceId(\"android:id/action_bar_title\")"))); try { - fileElement = (AndroidElement) driver.findElementByAndroidUIAutomator("new UiSelector().description(\"Upload\")"); + fileElement = (AndroidElement) driver + .findElementByAndroidUIAutomator("new UiSelector()" + + ".description(\"Upload\")"); } catch (NoSuchElementException e) { fileElement = null; } @@ -116,13 +153,19 @@ public class Common{ } 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()); + 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\")"))); + 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 index a2bdab33f0..d9d5b272f2 100644 --- 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 @@ -1,3 +1,23 @@ +/** + * ownCloud Android client application + * + * @author purigarcia + * Copyright (C) 2015 ownCloud Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + package com.owncloud.android.test.ui.testSuites; import static org.junit.Assert.*; @@ -41,17 +61,21 @@ public class CreateFolderTestSuite{ public void testCreateNewFolder () throws Exception { String NEW_FOLDER_NAME = "testCreateFolder"; - FileListView fileListView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); + 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); + 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()); + assertTrue( + folderHasBeenCreated=fileListView.getFileElement().isDisplayed()); CurrentCreatedFolder = FOLDER_NAME; assertEquals(FOLDER_NAME , fileListView.getFileElement().getText()); } 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 index 28e6b25131..af6e37d1f2 100644 --- 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 @@ -1,3 +1,23 @@ +/** + * ownCloud Android client application + * + * @author purigarcia + * Copyright (C) 2015 ownCloud Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + package com.owncloud.android.test.ui.testSuites; import static org.junit.Assert.*; @@ -38,15 +58,20 @@ public class DeleteFileTestSuite{ @Test @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class}) public void testDeleteFile () throws Exception { - FileListView fileListView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); + 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); + 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())))); + 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()); 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 index 105a42dc57..5e0e2cd1b9 100644 --- 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 @@ -1,3 +1,23 @@ +/** + * ownCloud Android client application + * + * @author purigarcia + * Copyright (C) 2015 ownCloud Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + package com.owncloud.android.test.ui.testSuites; import static org.junit.Assert.*; @@ -38,19 +58,24 @@ public class DeleteFolderTestSuite{ @Test @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class}) public void testDeleteFolder () throws Exception { - FileListView fileListView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); + 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); + WaitAMomentPopUp waitAMomentPopUp = Actions + .createFolder(FOLDER_NAME, fileListView); + Common.waitTillElementIsNotPresent( + waitAMomentPopUp.getWaitAMomentTextElement(), 100); fileListView.scrollTillFindElement(FOLDER_NAME); - assertTrue(folderHasBeenCreated = fileListView.getFileElement().isDisplayed()); + assertTrue( + folderHasBeenCreated = fileListView.getFileElement().isDisplayed()); //delete the folder Actions.deleteElement(FOLDER_NAME, fileListView, driver); - assertFalse(folderHasBeenCreated =fileListView.getFileElement().isDisplayed()); + assertFalse( + folderHasBeenCreated =fileListView.getFileElement().isDisplayed()); } @After 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 index 4083e8eda4..4c6c4cceda 100644 --- 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 @@ -1,3 +1,23 @@ +/** + * ownCloud Android client application + * + * @author purigarcia + * Copyright (C) 2015 ownCloud Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + package com.owncloud.android.test.ui.testSuites; import static org.junit.Assert.*; @@ -38,7 +58,8 @@ public class LoginTestSuite{ public void test1LoginPortrait () throws Exception { driver.rotate(ScreenOrientation.PORTRAIT); - FileListView fileListView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); + FileListView fileListView = Actions.login(Config.URL, Config.user, + Config.password, Config.isTrusted, driver); common.assertIsInFileListView(); } @@ -46,7 +67,8 @@ public class LoginTestSuite{ @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); + FileListView fileListView = Actions.login(Config.URL, Config.user, + Config.password, Config.isTrusted, driver); common.assertIsInFileListView(); } @@ -55,7 +77,8 @@ public class LoginTestSuite{ @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); + FileListView fileListView = Actions.login(Config.URL, Config.user, + Config.password, Config.isTrusted, driver); common.assertIsInFileListView(); driver.rotate(ScreenOrientation.PORTRAIT); @@ -63,7 +86,8 @@ public class LoginTestSuite{ SettingsView settingsView = menu.clickOnSettingsButton(); settingsView.tapOnAddAccount(1, 1000); - fileListView = Actions.login(Config.URL2, Config.user2,Config.password2, Config.isTrusted2, driver); + fileListView = Actions.login(Config.URL2, Config.user2, + Config.password2, Config.isTrusted2, driver); common.assertIsInSettingsView(); } @@ -71,7 +95,8 @@ public class LoginTestSuite{ @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); + FileListView fileListView = Actions.login(Config.URL, Config.user, + Config.password, Config.isTrusted, driver); common.assertIsInFileListView(); driver.rotate(ScreenOrientation.LANDSCAPE); @@ -80,23 +105,29 @@ public class LoginTestSuite{ 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())); + 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); + 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(); + LoginForm changePasswordForm = settingsView + .clickOnChangePasswordElement(); changePasswordForm.typePassword("WrongPassword"); changePasswordForm.clickOnConnectButton(); - assertTrue(common.waitForTextPresent("Wrong username or password", changePasswordForm.getAuthStatusText())); + assertTrue(common.waitForTextPresent("Wrong username or password", + changePasswordForm.getAuthStatusText())); } 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 index 6ebfb635a4..d99a4a611b 100644 --- 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 @@ -1,3 +1,23 @@ +/** + * ownCloud Android client application + * + * @author purigarcia + * Copyright (C) 2015 ownCloud Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + package com.owncloud.android.test.ui.testSuites; @@ -35,13 +55,15 @@ public class LogoutTestSuite{ @Test @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class}) public void testLogout () throws Exception { - FileListView fileListView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); + 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("Server address https://…", + loginForm.gethostUrlInput().getText()); assertEquals("Username", loginForm.getUserNameInput().getText()); assertEquals("", loginForm.getPasswordInput().getText()); } 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 index c5070a0adc..d950d4130b 100644 --- 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 @@ -1,3 +1,23 @@ +/** + * ownCloud Android client application + * + * @author purigarcia + * Copyright (C) 2015 ownCloud Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + package com.owncloud.android.test.ui.testSuites; import static org.junit.Assert.*; @@ -41,37 +61,45 @@ public class MoveFileTestSuite{ public void testMoveFile () throws Exception { WaitAMomentPopUp waitAMomentPopUp; - FileListView fileListView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); + FileListView fileListView = Actions.login(Config.URL, Config.user, + Config.password, Config.isTrusted, driver); common.assertIsInFileListView(); - //Common.waitTillElementIsNotPresent(fileListView.getProgressCircular(), 1000); + //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); + 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); + 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); + 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); + 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); + Common.waitTillElementIsNotPresent(fileListView.getProgressCircular(), + 1000); Thread.sleep(1000); fileListView.scrollTillFindElement(FILE_NAME); assertEquals(FILE_NAME , fileListView.getFileElement().getText()); 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 index d7439040c8..790336c949 100644 --- 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 @@ -1,3 +1,23 @@ +/** + * ownCloud Android client application + * + * @author purigarcia + * Copyright (C) 2015 ownCloud Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + package com.owncloud.android.test.ui.testSuites; import static org.junit.Assert.*; @@ -41,39 +61,47 @@ public class MoveFolderTestSuite{ public void testMoveFolder () throws Exception { WaitAMomentPopUp waitAMomentPopUp; - FileListView fileListView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); + FileListView fileListView = Actions.login(Config.URL, Config.user, + Config.password, Config.isTrusted, driver); common.assertIsInFileListView(); - //Common.waitTillElementIsNotPresent(fileListView.getProgressCircular(), 1000); + //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); + 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); + 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); + 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); + 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); + Common.waitTillElementIsNotPresent(fileListView.getProgressCircular(), + 1000); Thread.sleep(1000); fileListView.scrollTillFindElement(FOLDER_TO_MOVE); assertEquals(FOLDER_TO_MOVE , fileListView.getFileElement().getText()); 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 index 7b50af8863..9f671ce806 100644 --- 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 @@ -1,3 +1,23 @@ +/** + * ownCloud Android client application + * + * @author purigarcia + * Copyright (C) 2015 ownCloud Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + package com.owncloud.android.test.ui.testSuites; import io.appium.java_client.android.AndroidDriver; @@ -37,25 +57,33 @@ public class PasscodeTestSuite { @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); + 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); + 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 + 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); + PassCodeRequestView passCodeReequestView = new + PassCodeRequestView(driver); + passCodeReequestView.enterPasscode(Config.passcode1, Config.passcode2, + Config.passcode3, Config.passcode4); common.assertIsInFileListView(); } 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 index 15015c0699..1d4c76c02c 100644 --- 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 @@ -1,3 +1,23 @@ +/** + * ownCloud Android client application + * + * @author purigarcia + * Copyright (C) 2015 ownCloud Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + package com.owncloud.android.test.ui.testSuites; import static org.junit.Assert.*; @@ -34,9 +54,11 @@ public class RefreshFolderTestSuite{ @Test @Category({UnfinishedTestCategory.class}) public void testPulldownToRefreshFolder () throws Exception { - FileListView fileListView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); + 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 + //TODO. Remove the sleep and check why is not working the assert + //when using waitTillElementIsNotPresent Thread.sleep(5000); //waitTillElementIsNotPresent(fileListView.getProgressCircular(), 1000); fileListView.pulldownToRefresh(); 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 index 4c9b293be9..6e04a20d2b 100644 --- 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 @@ -1,3 +1,23 @@ +/** + * ownCloud Android client application + * + * @author purigarcia + * Copyright (C) 2015 ownCloud Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + package com.owncloud.android.test.ui.testSuites; import static org.junit.Assert.*; @@ -44,29 +64,39 @@ public class RenameFileTestSuite{ @Test @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class}) public void testRenameFile () throws Exception { - FileListView fileListView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); + 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); + 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()); + 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); + 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); + 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()); + assertEquals(FILE_NAME , fileListViewAfterUploadFile.getFileElement() + .getText()); CurrentCreatedFile = FILE_NAME; } 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 index 0983f017f7..0298bd469f 100644 --- 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 @@ -1,3 +1,23 @@ +/** + * ownCloud Android client application + * + * @author purigarcia + * Copyright (C) 2015 ownCloud Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + package com.owncloud.android.test.ui.testSuites; import static org.junit.Assert.*; @@ -43,30 +63,38 @@ public class RenameFolderTestSuite{ @Test @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class}) public void testRenameFolder () throws Exception { - FileListView fileListView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); + 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); + WaitAMomentPopUp waitAMomentPopUp = Actions + .createFolder(OLD_FOLDER_NAME, fileListView); + Common.waitTillElementIsNotPresent( + waitAMomentPopUp.getWaitAMomentTextElement(), 100); fileListView.scrollTillFindElement(OLD_FOLDER_NAME); - assertTrue(folderHasBeenCreated = fileListView.getFileElement().isDisplayed()); + assertTrue( + folderHasBeenCreated = fileListView.getFileElement().isDisplayed()); - //check if the folder with the new name already exists and if true, delete them + //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); + 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); + Common.waitTillElementIsNotPresent(waitAMomentPopUp + .getWaitAMomentTextElement(), 100); fileListView.scrollTillFindElement(FOLDER_NAME); assertNotNull(fileListView.getFileElement()); - assertTrue(folderHasBeenCreated = fileListView.getFileElement().isDisplayed()); + assertTrue( + folderHasBeenCreated = fileListView.getFileElement().isDisplayed()); assertEquals(FOLDER_NAME , fileListView.getFileElement().getText()); } 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 index 53d69fd025..9633abca3e 100644 --- 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 @@ -1,3 +1,23 @@ +/** + * ownCloud Android client application + * + * @author purigarcia + * Copyright (C) 2015 ownCloud Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + package com.owncloud.android.test.ui.testSuites; 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 index bfa7dbf5ed..4d90438760 100644 --- 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 @@ -1,3 +1,23 @@ +/** + * ownCloud Android client application + * + * @author purigarcia + * Copyright (C) 2015 ownCloud Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + package com.owncloud.android.test.ui.testSuites; import org.junit.experimental.categories.Categories.ExcludeCategory; 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 index ad4738f030..5c2e6ebdba 100644 --- 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 @@ -1,3 +1,23 @@ +/** + * ownCloud Android client application + * + * @author purigarcia + * Copyright (C) 2015 ownCloud Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + package com.owncloud.android.test.ui.testSuites; import org.junit.experimental.categories.Categories.ExcludeCategory; 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 index 147801f8e2..42195a7762 100644 --- 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 @@ -1,3 +1,23 @@ +/** + * ownCloud Android client application + * + * @author purigarcia + * Copyright (C) 2015 ownCloud Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + package com.owncloud.android.test.ui.testSuites; import static org.junit.Assert.assertTrue; @@ -38,24 +58,34 @@ public class ShareLinkFileTestSuite{ @Test @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class}) public void testShareLinkFile () throws Exception { - FileListView fileListView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); + 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); + FileListView fileListViewAfterUploadFile = Actions + .uploadFile(FILE_NAME, fileListView); fileListViewAfterUploadFile.scrollTillFindElement(FILE_NAME); - assertTrue(fileHasBeenCreated = fileListViewAfterUploadFile.getFileElement().isDisplayed()); + assertTrue(fileHasBeenCreated = fileListViewAfterUploadFile + .getFileElement().isDisplayed()); - ElementMenuOptions elementMenuOption = fileListViewAfterUploadFile.longPressOnElement(FILE_NAME); + ElementMenuOptions elementMenuOption = fileListViewAfterUploadFile + .longPressOnElement(FILE_NAME); ShareView shareView = elementMenuOption.clickOnShareLinkElement(); - Actions.scrollTillFindElement("Gmail", shareView.getListViewLayout(), driver).click(); + 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()); + 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()); } 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 index 84c228edca..50ddb39042 100644 --- 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 @@ -1,3 +1,23 @@ +/** + * ownCloud Android client application + * + * @author purigarcia + * Copyright (C) 2015 ownCloud Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + package com.owncloud.android.test.ui.testSuites; @@ -55,29 +75,39 @@ public class UploadTestSuite{ @Category(NoIgnoreTestCategory.class) public void testUploadFile () throws Exception { - FileListView fileListView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); + 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); + 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()); + 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()); fileListView = new FileListView(driver); fileListView.scrollTillFindElement(FILE_NAME); - assertTrue(fileHasBeenUploaded = fileListView.getFileElement().isDisplayed()); + assertTrue( + fileHasBeenUploaded = fileListView.getFileElement().isDisplayed()); } @Test @Category(UnfinishedTestCategory.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"); + 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); Thread.sleep(3000); GmailEmailView gmailEmailView = gmailEmailListView.clickOnEmail(); @@ -93,12 +123,16 @@ public class UploadTestSuite{ UploadView uploadView = new UploadView(driver); uploadView.clickOUploadButton(); driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_HOME); - driver.startActivity("com.owncloud.android", ".ui.activity.FileDisplayActivity"); - common.wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.name(FILE_GMAIL_NAME))); - assertEquals(Config.fileToTestSendByEmailName , driver.findElementByName(FILE_GMAIL_NAME).getText()); + driver.startActivity("com.owncloud.android", + ".ui.activity.FileDisplayActivity"); + common.wait.until(ExpectedConditions + .visibilityOfAllElementsLocatedBy(By.name(FILE_GMAIL_NAME))); + assertEquals(Config.fileToTestSendByEmailName , + driver.findElementByName(FILE_GMAIL_NAME).getText()); fileListView = new FileListView(driver); fileListView.scrollTillFindElement(FILE_GMAIL_NAME); - assertTrue(fileHasBeenUploadedFromGmail = fileListView.getFileElement().isDisplayed()); + assertTrue(fileHasBeenUploadedFromGmail = fileListView + .getFileElement().isDisplayed()); //TODO. correct assert if fileListView is shown in grid mode } @@ -107,22 +141,30 @@ public class UploadTestSuite{ @Category({FailingTestCategory.class}) public void testKeepFileUpToDate () throws Exception { - FileListView fileListView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver); + FileListView fileListView = Actions.login(Config.URL, Config.user, + Config.password, Config.isTrusted, driver); common.assertIsInFileListView(); - Common.waitTillElementIsNotPresent(fileListView.getProgressCircular(), 1000); + Common.waitTillElementIsNotPresent(fileListView.getProgressCircular(), + 1000); - FileListView fileListViewAfterUploadFile = Actions.uploadFile(FILE_NAME, fileListView); + FileListView fileListViewAfterUploadFile = Actions + .uploadFile(FILE_NAME, fileListView); fileListViewAfterUploadFile.scrollTillFindElement(FILE_NAME); assertTrue(fileListViewAfterUploadFile.getFileElement().isDisplayed()); - ElementMenuOptions menuOptions = fileListViewAfterUploadFile.longPressOnElement(FILE_NAME); + 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()); + assertTrue(common.isElementPresent( + fileListViewAfterUploadFile.getFileElementLayout(), + MobileBy.id(FileListView.getFavoriteFileIndicator()))); + assertTrue(fileListViewAfterUploadFile.getFileElementLayout() + .findElement(By.id(FileListView.getFavoriteFileIndicator())) + .isDisplayed()); } From d9a541d32a1d07efc7172ce2fb47d7d1900e4d87 Mon Sep 17 00:00:00 2001 From: purigarcia Date: Mon, 25 May 2015 09:15:03 +0200 Subject: [PATCH 12/27] test: favorite + refresh --- .../test/ui/groups/InProgressCategory.java | 5 +++ .../test/ui/testSuites/RunInProgressTest.java | 19 ++++++++ .../test/ui/testSuites/UploadTestSuite.java | 44 ++++++++++++++++++- 3 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 automationTest/src/test/java/com/owncloud/android/test/ui/groups/InProgressCategory.java create mode 100644 automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/RunInProgressTest.java diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/groups/InProgressCategory.java b/automationTest/src/test/java/com/owncloud/android/test/ui/groups/InProgressCategory.java new file mode 100644 index 0000000000..850ff45139 --- /dev/null +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/groups/InProgressCategory.java @@ -0,0 +1,5 @@ +package com.owncloud.android.test.ui.groups; + +public interface InProgressCategory extends IgnoreTestCategory{ + +} diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/RunInProgressTest.java b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/RunInProgressTest.java new file mode 100644 index 0000000000..9fb14a053f --- /dev/null +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/RunInProgressTest.java @@ -0,0 +1,19 @@ +package com.owncloud.android.test.ui.testSuites; + +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.InProgressCategory; +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) +@IncludeCategory(InProgressCategory.class) +@TestScanPackage("com.owncloud.android.test.ui.testSuites") +@TestClassPrefix("") +@TestClassSuffix("TestSuite") +public class RunInProgressTest { + +} 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 index 50ddb39042..2495d600aa 100644 --- 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 @@ -40,7 +40,9 @@ 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.InProgressCategory; import com.owncloud.android.test.ui.groups.NoIgnoreTestCategory; +import com.owncloud.android.test.ui.groups.SmokeTestCategory; import com.owncloud.android.test.ui.groups.UnfinishedTestCategory; import com.owncloud.android.test.ui.models.FileDetailsView; import com.owncloud.android.test.ui.models.ElementMenuOptions; @@ -72,7 +74,7 @@ public class UploadTestSuite{ } @Test - @Category(NoIgnoreTestCategory.class) + @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class}) public void testUploadFile () throws Exception { FileListView fileListView = Actions.login(Config.URL, Config.user, @@ -151,7 +153,8 @@ public class UploadTestSuite{ FileListView fileListViewAfterUploadFile = Actions .uploadFile(FILE_NAME, fileListView); fileListViewAfterUploadFile.scrollTillFindElement(FILE_NAME); - assertTrue(fileListViewAfterUploadFile.getFileElement().isDisplayed()); + assertTrue(fileHasBeenUploaded = fileListViewAfterUploadFile + .getFileElement().isDisplayed()); ElementMenuOptions menuOptions = fileListViewAfterUploadFile .longPressOnElement(FILE_NAME); @@ -166,6 +169,43 @@ public class UploadTestSuite{ .findElement(By.id(FileListView.getFavoriteFileIndicator())) .isDisplayed()); } + + @Test + @Category({NoIgnoreTestCategory.class}) + public void testKeepFileUpToDateAndRefresh () 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(fileHasBeenUploaded = 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); + + fileListViewAfterUploadFile.pulldownToRefresh(); + //assertTrue(fileListView.getProgressCircular().isDisplayed()); + Common.waitTillElementIsNotPresent(fileListView.getProgressCircular(), + 100); + + assertTrue(common.isElementPresent( + fileListViewAfterUploadFile.getFileElementLayout(), + MobileBy.id(FileListView.getFavoriteFileIndicator()))); + assertTrue(fileListViewAfterUploadFile.getFileElementLayout() + .findElement(By.id(FileListView.getFavoriteFileIndicator())) + .isDisplayed()); + } @After From 9c639003bc7d93173124b921d502a7700e3e9b6c Mon Sep 17 00:00:00 2001 From: purigarcia Date: Thu, 28 May 2015 17:31:47 +0200 Subject: [PATCH 13/27] unshare link test case --- .../android/test/ui/actions/Actions.java | 98 +++++++++++++++++-- .../test/ui/models/ElementMenuOptions.java | 9 ++ .../android/test/ui/testSuites/Common.java | 26 +++-- .../ui/testSuites/CreateFolderTestSuite.java | 2 +- .../ui/testSuites/DeleteFileTestSuite.java | 2 +- .../ui/testSuites/DeleteFolderTestSuite.java | 2 +- .../test/ui/testSuites/LoginTestSuite.java | 4 +- .../test/ui/testSuites/MoveFileTestSuite.java | 8 +- .../ui/testSuites/MoveFolderTestSuite.java | 8 +- .../ui/testSuites/RefreshFolderTestSuite.java | 2 +- .../ui/testSuites/RenameFileTestSuite.java | 4 +- .../ui/testSuites/RenameFolderTestSuite.java | 4 +- .../ui/testSuites/ShareLinkFileTestSuite.java | 82 +++++++++++----- .../test/ui/testSuites/UploadTestSuite.java | 11 +-- 14 files changed, 196 insertions(+), 66 deletions(-) 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 index 6d592179bb..c2349c48fd 100644 --- 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 @@ -22,18 +22,18 @@ package com.owncloud.android.test.ui.actions; import java.util.HashMap; +import org.openqa.selenium.By; 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.GmailSendMailView; +import com.owncloud.android.test.ui.models.ShareView; import com.owncloud.android.test.ui.models.UploadFilesView; import com.owncloud.android.test.ui.models.LoginForm; import com.owncloud.android.test.ui.models.FileListView; @@ -43,6 +43,7 @@ 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; +import com.owncloud.android.test.ui.testSuites.Config; public class Actions { @@ -120,7 +121,7 @@ public class Actions { 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; @@ -136,16 +137,97 @@ public class Actions { .longPressOnElement(elementName); RemoveConfirmationView removeConfirmationView = menuOptions .clickOnRemove();; - waitAMomentPopUp = removeConfirmationView - .clickOnRemoteAndLocalButton(); - Common.waitTillElementIsNotPresent( - waitAMomentPopUp.getWaitAMomentTextElement(), 100); + waitAMomentPopUp = removeConfirmationView + .clickOnRemoteAndLocalButton(); + Common.waitTillElementIsNotPresent( + waitAMomentPopUp.getWaitAMomentTextElement(), 100); }catch(NoSuchElementException e){ fileElement=null; } return fileElement; } + public static AndroidElement shareLinkElementByGmail(String elementName, + FileListView fileListView, AndroidDriver driver, Common common) + throws Exception{ + 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"); + ElementMenuOptions menuOptions = fileListView + .longPressOnElement(elementName); + ShareView shareView = menuOptions.clickOnShareLinkElement(); + Actions.scrollTillFindElement("Gmail", shareView + .getListViewLayout(), driver).click(); + GmailSendMailView gmailSendMailView = new GmailSendMailView(driver); + gmailSendMailView.typeToEmailAdress(Config.gmailAccount); + gmailSendMailView.clickOnSendButton(); + Common.waitTillElementIsNotPresentWithoutTimeout(fileListView + .getProgressCircular(), 1000); + common.wait.until(ExpectedConditions.visibilityOf( + fileListView.getFileElementLayout() + .findElement(By.id(FileListView + .getSharedElementIndicator())))); + + }catch(NoSuchElementException e){ + return null; + } + return (AndroidElement) fileListView.getFileElementLayout() + .findElement(By.id(FileListView.getSharedElementIndicator())); + } + + public static AndroidElement shareLinkElementByCopyLink(String elementName, + FileListView fileListView, AndroidDriver driver, Common common) + throws Exception{ + 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"); + ElementMenuOptions menuOptions = fileListView + .longPressOnElement(elementName); + ShareView shareView = menuOptions.clickOnShareLinkElement(); + Actions.scrollTillFindElement("Copy link", shareView.getListViewLayout(), + driver).click(); + WaitAMomentPopUp waitAMomentPopUp = new WaitAMomentPopUp(driver); + Common.waitTillElementIsNotPresentWithoutTimeout(waitAMomentPopUp + .getWaitAMomentTextElement(), 100); + common.wait.until(ExpectedConditions.visibilityOf( + fileListView.getFileElementLayout() + .findElement(By.id(FileListView.getSharedElementIndicator())))); + }catch(NoSuchElementException e){ + return null; + } + return (AndroidElement) fileListView.getFileElementLayout() + .findElement(By.id(FileListView.getSharedElementIndicator())); + } + + + public static void unshareLinkElement(String elementName, + FileListView fileListView, AndroidDriver driver, Common common) + throws Exception{ + 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"); + ElementMenuOptions menuOptions = fileListView + .longPressOnElement(elementName); + WaitAMomentPopUp waitAMomentPopUp = menuOptions + .clickOnUnshareLinkElement(); + Common.waitTillElementIsNotPresentWithoutTimeout(waitAMomentPopUp + .getWaitAMomentTextElement(), 100); + Common.waitTillElementIsNotPresent((AndroidElement) fileListView + .getFileElementLayout() + .findElement(By.id(FileListView.getSharedElementIndicator()) + ),100); + }catch(NoSuchElementException e){ + + } + } + + public static FileListView uploadFile(String elementName, FileListView fileListView) throws InterruptedException{ fileListView.clickOnUploadButton(); 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 index ccf9bd4e16..7480360706 100644 --- 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 @@ -34,6 +34,9 @@ public class ElementMenuOptions { @AndroidFindBy(name = "Share link") private AndroidElement shareLinkElement; + @AndroidFindBy(name = "Unshare link") + private AndroidElement unshareLinkElement; + @AndroidFindBy(name = "Details") private AndroidElement detailsFileElement; @@ -82,4 +85,10 @@ public class ElementMenuOptions { ShareView shareView = new ShareView(driver); return shareView; } + + public WaitAMomentPopUp clickOnUnshareLinkElement () { + unshareLinkElement.click(); + WaitAMomentPopUp waitAMomentPopUp = new WaitAMomentPopUp(driver); + return waitAMomentPopUp; + } } 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 index 6a40be29e0..1baa30b350 100644 --- 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 @@ -21,6 +21,7 @@ package com.owncloud.android.test.ui.testSuites; import static org.junit.Assert.*; + import java.io.File; import java.io.IOException; import java.net.URL; @@ -28,6 +29,7 @@ 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; @@ -36,6 +38,7 @@ 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; @@ -43,7 +46,7 @@ public class Common{ AndroidDriver driver; static int waitingTime = 30; - WebDriverWait wait; + public WebDriverWait wait; protected AndroidDriver setUpCommonDriver () throws Exception { File rootPath = new File(System.getProperty("user.dir")); @@ -104,9 +107,7 @@ public class Common{ //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; + for (int time = 0;time <= waitingTime * 1000;time += pollingTime){ try{ element.isDisplayed(); } catch (NoSuchElementException e){ @@ -117,6 +118,19 @@ public class Common{ throw new TimeoutException(); } + public static void waitTillElementIsNotPresentWithoutTimeout ( + AndroidElement element,int pollingTime) + throws InterruptedException { + for (int time = 0;time <= waitingTime * 1000;time += pollingTime){ + try{ + element.isDisplayed(); + } catch (NoSuchElementException e){ + return; + } + Thread.sleep(pollingTime); + } + } + protected void takeScreenShotOnFailed (String testName) throws IOException { File file = ((RemoteWebDriver) driver) @@ -124,7 +138,7 @@ public class Common{ SimpleDateFormat dt1 = new SimpleDateFormat("yyyy-MM-dd"); Date today = Calendar.getInstance().getTime(); String screenShotName = "ScreenShots/" + dt1.format(today) + "/" - + testName + ".png"; + + testName + ".png"; FileUtils.copyFile(file, new File(screenShotName)); } @@ -151,7 +165,7 @@ public class Common{ } assertNull(fileElement); } - + protected void assertIsPasscodeRequestView() throws InterruptedException { assertTrue(waitForTextPresent("ownCloud", (AndroidElement) driver .findElementByAndroidUIAutomator("new UiSelector()" 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 index d9d5b272f2..1394875554 100644 --- 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 @@ -70,7 +70,7 @@ public class CreateFolderTestSuite{ WaitAMomentPopUp waitAMomentPopUp = Actions .createFolder(NEW_FOLDER_NAME, fileListView); - Common.waitTillElementIsNotPresent(waitAMomentPopUp + Common.waitTillElementIsNotPresentWithoutTimeout(waitAMomentPopUp .getWaitAMomentTextElement(), 100); fileListView.scrollTillFindElement(FOLDER_NAME); assertNotNull(fileListView.getFileElement()); 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 index af6e37d1f2..5970ec970b 100644 --- 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 @@ -67,7 +67,7 @@ public class DeleteFileTestSuite{ .uploadFile(FILE_NAME, fileListView); fileListViewAfterUploadFile.scrollTillFindElement(FILE_NAME); - Common.waitTillElementIsNotPresent( + Common.waitTillElementIsNotPresentWithoutTimeout( fileListViewAfterUploadFile.getProgressCircular(), 1000); common.wait.until(ExpectedConditions.visibilityOf( fileListViewAfterUploadFile.getFileElementLayout() 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 index 5e0e2cd1b9..375de02a9a 100644 --- 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 @@ -66,7 +66,7 @@ public class DeleteFolderTestSuite{ //create the folder WaitAMomentPopUp waitAMomentPopUp = Actions .createFolder(FOLDER_NAME, fileListView); - Common.waitTillElementIsNotPresent( + Common.waitTillElementIsNotPresentWithoutTimeout( waitAMomentPopUp.getWaitAMomentTextElement(), 100); fileListView.scrollTillFindElement(FOLDER_NAME); assertTrue( 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 index 4c6c4cceda..c017bcf842 100644 --- 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 @@ -58,7 +58,7 @@ public class LoginTestSuite{ public void test1LoginPortrait () throws Exception { driver.rotate(ScreenOrientation.PORTRAIT); - FileListView fileListView = Actions.login(Config.URL, Config.user, + Actions.login(Config.URL, Config.user, Config.password, Config.isTrusted, driver); common.assertIsInFileListView(); } @@ -67,7 +67,7 @@ public class LoginTestSuite{ @Category({NoIgnoreTestCategory.class}) public void test2LoginLandscape () throws Exception { driver.rotate(ScreenOrientation.LANDSCAPE); - FileListView fileListView = Actions.login(Config.URL, Config.user, + Actions.login(Config.URL, Config.user, Config.password, Config.isTrusted, driver); common.assertIsInFileListView(); } 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 index d950d4130b..38c004b580 100644 --- 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 @@ -65,7 +65,7 @@ public class MoveFileTestSuite{ Config.password, Config.isTrusted, driver); common.assertIsInFileListView(); - //Common.waitTillElementIsNotPresent( + //Common.waitTillElementIsNotPresentWithoutTimeout( //fileListView.getProgressCircular(), 1000); //check if the folder already exists and if true, delete them @@ -75,7 +75,7 @@ public class MoveFileTestSuite{ //Create the folder where the other is gone to be moved waitAMomentPopUp = Actions .createFolder(FOLDER_WHERE_MOVE, fileListView); - Common.waitTillElementIsNotPresent( + Common.waitTillElementIsNotPresentWithoutTimeout( waitAMomentPopUp.getWaitAMomentTextElement(), 100); fileListView.scrollTillFindElement(FOLDER_WHERE_MOVE); assertTrue(fileListView.getFileElement().isDisplayed()); @@ -93,12 +93,12 @@ public class MoveFileTestSuite{ //to move to a folder moveView.scrollTillFindElement(FOLDER_WHERE_MOVE).tap(1,1); waitAMomentPopUp = moveView.clickOnChoose(); - Common.waitTillElementIsNotPresent( + Common.waitTillElementIsNotPresentWithoutTimeout( waitAMomentPopUp.getWaitAMomentTextElement(), 100); //check that the folder moved is inside the other fileListView.scrollTillFindElement(FOLDER_WHERE_MOVE).tap(1,1); - Common.waitTillElementIsNotPresent(fileListView.getProgressCircular(), + Common.waitTillElementIsNotPresentWithoutTimeout(fileListView.getProgressCircular(), 1000); Thread.sleep(1000); fileListView.scrollTillFindElement(FILE_NAME); 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 index 790336c949..a6f8769f57 100644 --- 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 @@ -65,7 +65,7 @@ public class MoveFolderTestSuite{ Config.password, Config.isTrusted, driver); common.assertIsInFileListView(); - //Common.waitTillElementIsNotPresent( + //Common.waitTillElementIsNotPresentWithoutTimeout( //fileListView.getProgressCircular(), 1000); //check if the folder already exists and if true, delete them @@ -75,7 +75,7 @@ public class MoveFolderTestSuite{ //Create the folder where the other is gone to be moved waitAMomentPopUp = Actions .createFolder(FOLDER_WHERE_MOVE, fileListView); - Common.waitTillElementIsNotPresent( + Common.waitTillElementIsNotPresentWithoutTimeout( waitAMomentPopUp.getWaitAMomentTextElement(), 100); fileListView.scrollTillFindElement(FOLDER_WHERE_MOVE); assertTrue(fileListView.getFileElement().isDisplayed()); @@ -95,12 +95,12 @@ public class MoveFolderTestSuite{ //to move to a folder moveView.scrollTillFindElement(FOLDER_WHERE_MOVE).tap(1,1); waitAMomentPopUp = moveView.clickOnChoose(); - Common.waitTillElementIsNotPresent(waitAMomentPopUp + Common.waitTillElementIsNotPresentWithoutTimeout(waitAMomentPopUp .getWaitAMomentTextElement(), 100); //check that the folder moved is inside the other fileListView.scrollTillFindElement(FOLDER_WHERE_MOVE).tap(1,1); - Common.waitTillElementIsNotPresent(fileListView.getProgressCircular(), + Common.waitTillElementIsNotPresentWithoutTimeout(fileListView.getProgressCircular(), 1000); Thread.sleep(1000); fileListView.scrollTillFindElement(FOLDER_TO_MOVE); 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 index 1d4c76c02c..850a757271 100644 --- 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 @@ -60,7 +60,7 @@ public class RefreshFolderTestSuite{ //TODO. Remove the sleep and check why is not working the assert //when using waitTillElementIsNotPresent Thread.sleep(5000); - //waitTillElementIsNotPresent(fileListView.getProgressCircular(), 1000); + //waitTillElementIsNotPresentWithoutTimeout(fileListView.getProgressCircular(), 1000); fileListView.pulldownToRefresh(); assertTrue(fileListView.getProgressCircular().isDisplayed()); //TODO insert a file in the web, and check that it's shown here 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 index 6e04a20d2b..d82cd1191b 100644 --- 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 @@ -79,7 +79,7 @@ public class RenameFileTestSuite{ assertTrue(fileHasBeenCreated = fileListViewAfterUploadFile .getFileElement().isDisplayed()); CurrentCreatedFile = OLD_FILE_NAME; - Common.waitTillElementIsNotPresent(fileListViewAfterUploadFile + Common.waitTillElementIsNotPresentWithoutTimeout(fileListViewAfterUploadFile .getProgressCircular(), 1000); common.wait.until(ExpectedConditions.visibilityOf( fileListViewAfterUploadFile.getFileElementLayout() @@ -90,7 +90,7 @@ public class RenameFileTestSuite{ newFolderPopUp.typeNewFolderName(FILE_NAME); WaitAMomentPopUp waitAMomentPopUp = newFolderPopUp .clickOnNewFolderOkButton(); - Common.waitTillElementIsNotPresent(waitAMomentPopUp + Common.waitTillElementIsNotPresentWithoutTimeout(waitAMomentPopUp .getWaitAMomentTextElement(), 100); fileListViewAfterUploadFile.scrollTillFindElement(FILE_NAME); assertNotNull(fileListViewAfterUploadFile.getFileElement()); 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 index 0298bd469f..271295f00c 100644 --- 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 @@ -71,7 +71,7 @@ public class RenameFolderTestSuite{ //create the folder to rename WaitAMomentPopUp waitAMomentPopUp = Actions .createFolder(OLD_FOLDER_NAME, fileListView); - Common.waitTillElementIsNotPresent( + Common.waitTillElementIsNotPresentWithoutTimeout( waitAMomentPopUp.getWaitAMomentTextElement(), 100); fileListView.scrollTillFindElement(OLD_FOLDER_NAME); @@ -89,7 +89,7 @@ public class RenameFolderTestSuite{ FolderPopUp.typeNewFolderName(FOLDER_NAME); FolderPopUp.clickOnNewFolderOkButton(); CurrentCreatedFolder = FOLDER_NAME; - Common.waitTillElementIsNotPresent(waitAMomentPopUp + Common.waitTillElementIsNotPresentWithoutTimeout(waitAMomentPopUp .getWaitAMomentTextElement(), 100); fileListView.scrollTillFindElement(FOLDER_NAME); assertNotNull(fileListView.getFileElement()); 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 index 42195a7762..c22525eb09 100644 --- 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 @@ -20,25 +20,20 @@ package com.owncloud.android.test.ui.testSuites; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; import io.appium.java_client.android.AndroidDriver; - +import io.appium.java_client.android.AndroidElement; 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.IgnoreTestCategory; 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; +import com.owncloud.android.test.ui.models.FileListView;; public class ShareLinkFileTestSuite{ @@ -56,8 +51,9 @@ public class ShareLinkFileTestSuite{ } @Test - @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class}) - public void testShareLinkFile () throws Exception { + @Category({NoIgnoreTestCategory.class}) + public void testShareLinkFileByGmail () throws Exception { + AndroidElement sharedElementIndicator; FileListView fileListView = Actions.login(Config.URL, Config.user, Config.password, Config.isTrusted, driver); common.assertIsInFileListView(); @@ -70,22 +66,54 @@ public class ShareLinkFileTestSuite{ 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()); + sharedElementIndicator = Actions.shareLinkElementByGmail(FILE_NAME, + fileListViewAfterUploadFile,driver,common); + assertTrue(sharedElementIndicator.isDisplayed()); + } + + @Test + @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class}) + public void testShareLinkFileByCopyLink () throws Exception { + AndroidElement sharedElementIndicator; + 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()); + + sharedElementIndicator = Actions.shareLinkElementByCopyLink(FILE_NAME, + fileListViewAfterUploadFile,driver,common); + assertTrue(sharedElementIndicator.isDisplayed()); + } + + @Test + @Category({IgnoreTestCategory.class, SmokeTestCategory.class}) + public void testUnshareLinkFile () throws Exception { + AndroidElement sharedElementIndicator; + 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()); + + sharedElementIndicator = Actions.shareLinkElementByCopyLink(FILE_NAME, + fileListViewAfterUploadFile,driver,common); + assertTrue(sharedElementIndicator.isDisplayed()); + Actions.unshareLinkElement(FILE_NAME, + fileListViewAfterUploadFile,driver,common); + assertFalse(sharedElementIndicator.isDisplayed()); } 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 index 2495d600aa..cf8f84d06a 100644 --- 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 @@ -36,11 +36,8 @@ import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.NoSuchElementException; 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.InProgressCategory; import com.owncloud.android.test.ui.groups.NoIgnoreTestCategory; import com.owncloud.android.test.ui.groups.SmokeTestCategory; import com.owncloud.android.test.ui.groups.UnfinishedTestCategory; @@ -89,7 +86,7 @@ public class UploadTestSuite{ fileListViewAfterUploadFile.scrollTillFindElement(FILE_NAME); assertTrue(fileListViewAfterUploadFile.getFileElement().isDisplayed()); - Common.waitTillElementIsNotPresent( + Common.waitTillElementIsNotPresentWithoutTimeout( fileListViewAfterUploadFile.getProgressCircular(), 1000); common.wait.until(ExpectedConditions.visibilityOf( fileListViewAfterUploadFile.getFileElementLayout() @@ -147,7 +144,7 @@ public class UploadTestSuite{ Config.password, Config.isTrusted, driver); common.assertIsInFileListView(); - Common.waitTillElementIsNotPresent(fileListView.getProgressCircular(), + Common.waitTillElementIsNotPresentWithoutTimeout(fileListView.getProgressCircular(), 1000); FileListView fileListViewAfterUploadFile = Actions @@ -178,7 +175,7 @@ public class UploadTestSuite{ Config.password, Config.isTrusted, driver); common.assertIsInFileListView(); - Common.waitTillElementIsNotPresent(fileListView.getProgressCircular(), + Common.waitTillElementIsNotPresentWithoutTimeout(fileListView.getProgressCircular(), 1000); FileListView fileListViewAfterUploadFile = Actions @@ -196,7 +193,7 @@ public class UploadTestSuite{ fileListViewAfterUploadFile.pulldownToRefresh(); //assertTrue(fileListView.getProgressCircular().isDisplayed()); - Common.waitTillElementIsNotPresent(fileListView.getProgressCircular(), + Common.waitTillElementIsNotPresentWithoutTimeout(fileListView.getProgressCircular(), 100); assertTrue(common.isElementPresent( From f973a1db0eae8ff2df538caad210ef3f6fa2bae7 Mon Sep 17 00:00:00 2001 From: purigarcia Date: Fri, 29 May 2015 14:16:35 +0200 Subject: [PATCH 14/27] upload a big file. not finished --- .../android/test/ui/actions/Actions.java | 3 +- .../android/test/ui/models/FileListView.java | 10 +++ .../test/ui/models/NotificationView.java | 54 +++++++++++++++ .../android/test/ui/testSuites/Common.java | 17 ++++- .../ui/testSuites/ShareLinkFileTestSuite.java | 3 + .../test/ui/testSuites/UploadTestSuite.java | 67 +++++++++++++++++-- 6 files changed, 147 insertions(+), 7 deletions(-) create mode 100644 automationTest/src/test/java/com/owncloud/android/test/ui/models/NotificationView.java 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 index c2349c48fd..938d277d53 100644 --- 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 @@ -240,6 +240,5 @@ public class Actions { Thread.sleep(15000); return fileListViewAfterUploadFile; } - - + } 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 index f10e7aa3c6..3c33864e0b 100644 --- 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 @@ -79,6 +79,9 @@ public class FileListView { + ".description(\"List Layout\")") private AndroidElement listLayout; + @AndroidFindBy(uiAutomator = "new UiSelector().className(\"android.widget.FrameLayout\").index(0)") + private AndroidElement deviceScreen; + private AndroidElement fileElement; private AndroidElement fileElementLayout; @@ -197,5 +200,12 @@ public class FileListView { listLocation.getX(),listLocation.getY()+1000, 5000); } + + + public void pulldownToSeeNotification () throws InterruptedException { + Point listLocation = deviceScreen.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/NotificationView.java b/automationTest/src/test/java/com/owncloud/android/test/ui/models/NotificationView.java new file mode 100644 index 0000000000..35de73c861 --- /dev/null +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/models/NotificationView.java @@ -0,0 +1,54 @@ +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 NotificationView { +final AndroidDriver driver; + + @AndroidFindBy(name = "Upload succeeded") + private static AndroidElement uploadSucceededNotification; + + @AndroidFindBy(name = "Uploading ?") + private static AndroidElement uploadingNotification; + + @AndroidFindBy(uiAutomator = "new UiSelector().description(\"Clear all notifications.\")") + private AndroidElement clearAllNotificationButton; + + @AndroidFindBy(uiAutomator = "new UiSelector().className(\"android.widget.FrameLayout\").index(0)") + private AndroidElement notificationArea; + + + public NotificationView (AndroidDriver driver) { + this.driver = driver; + PageFactory.initElements(new AppiumFieldDecorator(driver), this); + } + + + public AndroidElement getUploadSucceededNotification() { + return uploadSucceededNotification; + } + + public AndroidElement getUploadingNotification() { + return uploadingNotification; + } + + public AndroidElement getClearAllNotificationButton() { + return clearAllNotificationButton; + } + + public void tapOnClearAllNotification () { + clearAllNotificationButton.tap(1, 1000); + } + + public void tapOnBottomNotificationArea(){ + //TODO. it is not working + notificationArea.getSize(); + notificationArea.tap(1, 1000); + } + +} 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 index 1baa30b350..36287dab28 100644 --- 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 @@ -130,7 +130,22 @@ public class Common{ Thread.sleep(pollingTime); } } - + + public static void waitTillElementIsPresent ( + AndroidElement element,int pollingTime) + throws InterruptedException { + for (int time = 0;time <= waitingTime * 1000;time += pollingTime){ + try{ + if(element.isDisplayed()){ + return; + } + } catch (NoSuchElementException e){ + + } + Thread.sleep(pollingTime); + } + } + protected void takeScreenShotOnFailed (String testName) throws IOException { File file = ((RemoteWebDriver) driver) 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 index c22525eb09..5e604cd326 100644 --- 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 @@ -23,14 +23,17 @@ package com.owncloud.android.test.ui.testSuites; import static org.junit.Assert.*; import io.appium.java_client.android.AndroidDriver; import io.appium.java_client.android.AndroidElement; + 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.IgnoreTestCategory; +import com.owncloud.android.test.ui.groups.InProgressCategory; import com.owncloud.android.test.ui.groups.NoIgnoreTestCategory; import com.owncloud.android.test.ui.groups.SmokeTestCategory; import com.owncloud.android.test.ui.models.FileListView;; 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 index cf8f84d06a..af956477d4 100644 --- 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 @@ -36,8 +36,10 @@ import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.NoSuchElementException; 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.InProgressCategory; import com.owncloud.android.test.ui.groups.NoIgnoreTestCategory; import com.owncloud.android.test.ui.groups.SmokeTestCategory; import com.owncloud.android.test.ui.groups.UnfinishedTestCategory; @@ -47,6 +49,8 @@ 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.NotificationView; +import com.owncloud.android.test.ui.models.SettingsView; import com.owncloud.android.test.ui.models.UploadView; @@ -57,6 +61,7 @@ public class UploadTestSuite{ AndroidDriver driver; Common common; String FILE_NAME = Config.fileToTestName; + String BIG_FILE_NAME = Config.bigFileToTestName; String FILE_GMAIL_NAME = Config.fileToTestSendByEmailName; private Boolean fileHasBeenUploadedFromGmail = false; private Boolean fileHasBeenUploaded = false; @@ -97,7 +102,60 @@ public class UploadTestSuite{ fileListView = new FileListView(driver); fileListView.scrollTillFindElement(FILE_NAME); assertTrue( - fileHasBeenUploaded = fileListView.getFileElement().isDisplayed()); + fileHasBeenUploaded = fileListView.getFileElement().isDisplayed()); + } + + @Test + @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class, InProgressCategory.class}) + public void testUploadBigFile () 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(BIG_FILE_NAME, fileListView, driver); + + FileListView fileListViewAfterUploadFile = Actions + .uploadFile(BIG_FILE_NAME, fileListView); + + fileListViewAfterUploadFile.scrollTillFindElement(BIG_FILE_NAME); + driver.openNotifications(); + NotificationView notificationView = new NotificationView(driver); + + try{ + if(notificationView.getUploadingNotification().isDisplayed()){ + Common.waitTillElementIsPresent( + notificationView.getUploadSucceededNotification(),1000); + } + } catch (NoSuchElementException e) { + try{ + if(notificationView.getClearAllNotificationButton().isDisplayed()){ + notificationView.tapOnClearAllNotification(); + } + } catch (NoSuchElementException e2) { + notificationView.tapOnBottomNotificationArea(); + } + } + + + + + //fileListViewAfterUploadFile.pulldownToSeeNotification(); + + assertTrue(fileListViewAfterUploadFile.getFileElement().isDisplayed()); + Common.waitTillElementIsNotPresentWithoutTimeout( + fileListViewAfterUploadFile.getProgressCircular(), 1000); + common.wait.until(ExpectedConditions.visibilityOf( + fileListViewAfterUploadFile.getFileElementLayout() + .findElement(By.id(FileListView.getLocalFileIndicator())))); + assertTrue(fileListViewAfterUploadFile.getFileElementLayout() + .findElement(By.id(FileListView.getLocalFileIndicator())) + .isDisplayed()); + fileListView = new FileListView(driver); + fileListView.scrollTillFindElement(BIG_FILE_NAME); + assertTrue( + fileHasBeenUploaded = fileListView.getFileElement().isDisplayed()); } @Test @@ -166,7 +224,7 @@ public class UploadTestSuite{ .findElement(By.id(FileListView.getFavoriteFileIndicator())) .isDisplayed()); } - + @Test @Category({NoIgnoreTestCategory.class}) public void testKeepFileUpToDateAndRefresh () throws Exception { @@ -190,12 +248,12 @@ public class UploadTestSuite{ fileDetailsView.checkKeepFileUpToDateCheckbox(); Thread.sleep(3000); driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_BACK); - + fileListViewAfterUploadFile.pulldownToRefresh(); //assertTrue(fileListView.getProgressCircular().isDisplayed()); Common.waitTillElementIsNotPresentWithoutTimeout(fileListView.getProgressCircular(), 100); - + assertTrue(common.isElementPresent( fileListViewAfterUploadFile.getFileElementLayout(), MobileBy.id(FileListView.getFavoriteFileIndicator()))); @@ -214,6 +272,7 @@ public class UploadTestSuite{ } if(fileHasBeenUploaded){ Actions.deleteElement(FILE_NAME,fileListView, driver); + Actions.deleteElement(BIG_FILE_NAME,fileListView, driver); } driver.removeApp("com.owncloud.android"); From 104df3e2aa67dd9b14dce939fa7d52b2e5c8962e Mon Sep 17 00:00:00 2001 From: purigarcia Date: Wed, 3 Jun 2015 12:32:14 +0200 Subject: [PATCH 15/27] WIP upload a big file --- .../test/ui/testSuites/UploadTestSuite.java | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) 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 index af956477d4..287b43da00 100644 --- 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 @@ -105,8 +105,10 @@ public class UploadTestSuite{ fileHasBeenUploaded = fileListView.getFileElement().isDisplayed()); } + + @Test - @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class, InProgressCategory.class}) + @Category({UnfinishedTestCategory.class, InProgressCategory.class}) public void testUploadBigFile () throws Exception { FileListView fileListView = Actions.login(Config.URL, Config.user, @@ -119,31 +121,29 @@ public class UploadTestSuite{ FileListView fileListViewAfterUploadFile = Actions .uploadFile(BIG_FILE_NAME, fileListView); - fileListViewAfterUploadFile.scrollTillFindElement(BIG_FILE_NAME); + driver.openNotifications(); NotificationView notificationView = new NotificationView(driver); try{ if(notificationView.getUploadingNotification().isDisplayed()){ Common.waitTillElementIsPresent( - notificationView.getUploadSucceededNotification(),1000); + notificationView.getUploadSucceededNotification(),300000); + driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_HOME); + driver.startActivity("com.owncloud.android", + ".ui.activity.FileDisplayActivity"); + } } catch (NoSuchElementException e) { - try{ - if(notificationView.getClearAllNotificationButton().isDisplayed()){ - notificationView.tapOnClearAllNotification(); - } - } catch (NoSuchElementException e2) { - notificationView.tapOnBottomNotificationArea(); - } + driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_HOME); + driver.startActivity("com.owncloud.android", + ".ui.activity.FileDisplayActivity"); } - - - - //fileListViewAfterUploadFile.pulldownToSeeNotification(); + fileListViewAfterUploadFile.scrollTillFindElement(BIG_FILE_NAME); assertTrue(fileListViewAfterUploadFile.getFileElement().isDisplayed()); + Common.waitTillElementIsNotPresentWithoutTimeout( fileListViewAfterUploadFile.getProgressCircular(), 1000); common.wait.until(ExpectedConditions.visibilityOf( @@ -158,6 +158,7 @@ public class UploadTestSuite{ fileHasBeenUploaded = fileListView.getFileElement().isDisplayed()); } + @Test @Category(UnfinishedTestCategory.class) public void testUploadFromGmail () throws Exception { @@ -275,7 +276,7 @@ public class UploadTestSuite{ Actions.deleteElement(BIG_FILE_NAME,fileListView, driver); } - driver.removeApp("com.owncloud.android"); + //driver.removeApp("com.owncloud.android"); driver.quit(); } From a555ed1a5abe21628c92f61518910608eca57dec Mon Sep 17 00:00:00 2001 From: purigarcia Date: Thu, 4 Jun 2015 08:49:30 +0200 Subject: [PATCH 16/27] add config file --- .../android/test/ui/testSuites/Config.java | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/Config.java diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/Config.java b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/Config.java new file mode 100644 index 0000000000..b682db22f5 --- /dev/null +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/Config.java @@ -0,0 +1,50 @@ +/** + * ownCloud Android client application + * + * @author purigarcia + * Copyright (C) 2015 ownCloud Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +package com.owncloud.android.test.ui.testSuites; + +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; + + public static final String gmailAccount = "gmailAccountVar"; + + public static final String fileToTestName = "test"; + public static final String fileToTestSendByEmailName = "test"; + + public static final String passcode1 = "passcode1"; + public static final String passcode2 = "passcode2"; + public static final String passcode3 = "passcode3"; + public static final String passcode4 = "passcode4"; + +} From dd9845bf808e46fca2338d3d39adde2ca5511265 Mon Sep 17 00:00:00 2001 From: purigarcia Date: Thu, 4 Jun 2015 09:30:29 +0200 Subject: [PATCH 17/27] update config --- .../java/com/owncloud/android/test/ui/testSuites/Config.java | 1 + 1 file changed, 1 insertion(+) diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/Config.java b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/Config.java index b682db22f5..d2ab77f78d 100644 --- a/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/Config.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/Config.java @@ -40,6 +40,7 @@ public final class Config { public static final String gmailAccount = "gmailAccountVar"; public static final String fileToTestName = "test"; + public static final String bigFileToTestName = "test"; public static final String fileToTestSendByEmailName = "test"; public static final String passcode1 = "passcode1"; From 78baa1277795765ebdebf2dc59d5db4337c2e340 Mon Sep 17 00:00:00 2001 From: purigarcia Date: Thu, 4 Jun 2015 09:32:44 +0200 Subject: [PATCH 18/27] update files of the project --- automationTest/resources/.DS_Store | Bin 0 -> 6148 bytes automationTest/target/classes/.DS_Store | Bin 0 -> 6148 bytes .../default-testCompile/createdFiles.lst | 11 +++++++++++ .../default-testCompile/inputFiles.lst | 11 +++++++++++ 4 files changed, 22 insertions(+) create mode 100644 automationTest/resources/.DS_Store create mode 100644 automationTest/target/classes/.DS_Store create mode 100644 automationTest/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst create mode 100644 automationTest/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst diff --git a/automationTest/resources/.DS_Store b/automationTest/resources/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5008ddfcf53c02e82d7eee2e57c38e5672ef89f6 GIT binary patch literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0 Date: Thu, 4 Jun 2015 09:34:42 +0200 Subject: [PATCH 19/27] update the project --- automationTest/src/test/resources/.DS_Store | Bin 0 -> 6148 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 automationTest/src/test/resources/.DS_Store diff --git a/automationTest/src/test/resources/.DS_Store b/automationTest/src/test/resources/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5008ddfcf53c02e82d7eee2e57c38e5672ef89f6 GIT binary patch literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0 Date: Thu, 4 Jun 2015 09:36:10 +0200 Subject: [PATCH 20/27] update the project --- automationTest/target/surefire-reports/.DS_Store | Bin 0 -> 6148 bytes automationTest/target/test-classes/.DS_Store | Bin 0 -> 6148 bytes 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 automationTest/target/surefire-reports/.DS_Store create mode 100644 automationTest/target/test-classes/.DS_Store diff --git a/automationTest/target/surefire-reports/.DS_Store b/automationTest/target/surefire-reports/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5008ddfcf53c02e82d7eee2e57c38e5672ef89f6 GIT binary patch literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0 Date: Thu, 4 Jun 2015 11:08:59 +0200 Subject: [PATCH 21/27] update the project structure --- automationTest/.gitignore | 1 + automationTest/target/classes/.DS_Store | Bin 6148 -> 0 bytes .../default-testCompile/createdFiles.lst | 11 ----------- .../default-testCompile/inputFiles.lst | 11 ----------- automationTest/target/surefire-reports/.DS_Store | Bin 6148 -> 0 bytes automationTest/target/test-classes/.DS_Store | Bin 6148 -> 0 bytes 6 files changed, 1 insertion(+), 22 deletions(-) delete mode 100644 automationTest/target/classes/.DS_Store delete mode 100644 automationTest/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst delete mode 100644 automationTest/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst delete mode 100644 automationTest/target/surefire-reports/.DS_Store delete mode 100644 automationTest/target/test-classes/.DS_Store diff --git a/automationTest/.gitignore b/automationTest/.gitignore index a47ace0fca..6eb2094835 100644 --- a/automationTest/.gitignore +++ b/automationTest/.gitignore @@ -1,3 +1,4 @@ target/ ScreenShots/ +.DS_Store diff --git a/automationTest/target/classes/.DS_Store b/automationTest/target/classes/.DS_Store deleted file mode 100644 index 5008ddfcf53c02e82d7eee2e57c38e5672ef89f6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0 Date: Thu, 4 Jun 2015 11:11:28 +0200 Subject: [PATCH 22/27] update project structure --- automationTest/resources/.DS_Store | Bin 6148 -> 0 bytes automationTest/src/test/resources/.DS_Store | Bin 6148 -> 0 bytes 2 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 automationTest/resources/.DS_Store delete mode 100644 automationTest/src/test/resources/.DS_Store diff --git a/automationTest/resources/.DS_Store b/automationTest/resources/.DS_Store deleted file mode 100644 index 5008ddfcf53c02e82d7eee2e57c38e5672ef89f6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0 Date: Thu, 4 Jun 2015 12:29:27 +0200 Subject: [PATCH 23/27] update the project structure --- automationTest/resources/.gitignore | 4 ++++ automationTest/src/test/resources/.gitignore | 4 ++++ 2 files changed, 8 insertions(+) create mode 100644 automationTest/resources/.gitignore create mode 100644 automationTest/src/test/resources/.gitignore diff --git a/automationTest/resources/.gitignore b/automationTest/resources/.gitignore new file mode 100644 index 0000000000..86d0cb2726 --- /dev/null +++ b/automationTest/resources/.gitignore @@ -0,0 +1,4 @@ +# Ignore everything in this directory +* +# Except this file +!.gitignore \ No newline at end of file diff --git a/automationTest/src/test/resources/.gitignore b/automationTest/src/test/resources/.gitignore new file mode 100644 index 0000000000..86d0cb2726 --- /dev/null +++ b/automationTest/src/test/resources/.gitignore @@ -0,0 +1,4 @@ +# Ignore everything in this directory +* +# Except this file +!.gitignore \ No newline at end of file From 171ae0b5745cc853c2f419f533ee294d09d1ef39 Mon Sep 17 00:00:00 2001 From: purigarcia Date: Fri, 5 Jun 2015 13:23:03 +0200 Subject: [PATCH 24/27] new test cases about login and check that there are some files --- .../android/test/ui/actions/Actions.java | 8 ++-- .../android/test/ui/models/SettingsView.java | 10 +++-- .../android/test/ui/testSuites/Common.java | 3 ++ .../android/test/ui/testSuites/Config.java | 5 ++- .../test/ui/testSuites/LoginTestSuite.java | 41 ++++++++++++++++++- .../test/ui/testSuites/LogoutTestSuite.java | 2 +- .../test/ui/testSuites/UploadTestSuite.java | 2 +- 7 files changed, 59 insertions(+), 12 deletions(-) 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 index 938d277d53..ecec7f5625 100644 --- 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 @@ -106,14 +106,14 @@ public class Actions { } - public static void deleteAccount (FileListView fileListView) { + public static void deleteAccount (int accountPosition,FileListView fileListView) { MenuList menulist = fileListView.clickOnMenuButton(); SettingsView settingView = menulist.clickOnSettingsButton(); - deleteAccount(settingView); + deleteAccount(accountPosition,settingView); } - public static void deleteAccount (SettingsView settingsView) { - settingsView.tapOnAccountElement(1, 1000); + public static void deleteAccount (int accountPosition, SettingsView settingsView) { + settingsView.tapOnAccountElement(accountPosition,1, 1000); settingsView.clickOnDeleteAccountElement(); } 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 index 43d31ecd28..900c03b2a0 100644 --- 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 @@ -59,11 +59,13 @@ public class SettingsView { PageFactory.initElements(new AppiumFieldDecorator(driver), this); } - public void tapOnAccountElement (int fingers, int milliSeconds) { - accountElement.tap(fingers, milliSeconds); + public void tapOnAccountElement (int accountPosition, int fingers, int milliSeconds) { + if(accountPosition==1) + accountElement.tap(fingers, milliSeconds); + else + accountElement2.tap(fingers, milliSeconds); } - public void tapOnAddAccount (int fingers, int milliSeconds) { addAccountElement.tap(fingers, milliSeconds); } @@ -87,7 +89,7 @@ public class SettingsView { PassCodeView passcodeview = new PassCodeView(driver); return passcodeview; } - + public PassCodeView DisablePassCode(){ if(passcodeCheckbox.isSelected()){ passcodeCheckbox.click(); 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 index 36287dab28..7510cd99b2 100644 --- 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 @@ -158,6 +158,9 @@ public class Common{ } protected void assertIsInFileListView() throws InterruptedException { + //waitForTextPresent("Wrong username or password", + // changePasswordForm.getAuthStatusText()); + Thread.sleep(2000); assertTrue(waitForTextPresent("ownCloud", (AndroidElement) driver .findElementByAndroidUIAutomator("new UiSelector()" + ".resourceId(\"android:id/action_bar_title\")"))); diff --git a/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/Config.java b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/Config.java index d2ab77f78d..4674fab209 100644 --- a/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/Config.java +++ b/automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/Config.java @@ -39,9 +39,12 @@ public final class Config { public static final String gmailAccount = "gmailAccountVar"; + public static final String fileWhichIsInTheServer1 ="test"; + public static final String fileWhichIsInTheServer2 ="test"; + public static final String fileToTestName = "test"; - public static final String bigFileToTestName = "test"; public static final String fileToTestSendByEmailName = "test"; + public static final String bigFileToTestName = "test"; public static final String passcode1 = "passcode1"; public static final String passcode2 = "passcode2"; 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 index c017bcf842..8f1bccf9d1 100644 --- 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 @@ -72,6 +72,20 @@ public class LoginTestSuite{ common.assertIsInFileListView(); } + @Test + @Category({NoIgnoreTestCategory.class}) + public void testLoginAndShowFiles () throws Exception { + driver.rotate(ScreenOrientation.PORTRAIT); + + FileListView fileListView = Actions.login(Config.URL, Config.user, + Config.password, Config.isTrusted, driver); + common.assertIsInFileListView(); + + fileListView.scrollTillFindElement(Config.fileWhichIsInTheServer1); + assertTrue(fileListView.getFileElement().isDisplayed()); + } + + @Test @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class}) @@ -91,6 +105,31 @@ public class LoginTestSuite{ common.assertIsInSettingsView(); } + @Test + @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class}) + public void testMultiAccountAndShowFiles () throws Exception { + driver.rotate(ScreenOrientation.LANDSCAPE); + FileListView fileListView = Actions.login(Config.URL, Config.user, + Config.password, Config.isTrusted, driver); + common.assertIsInFileListView(); + fileListView.scrollTillFindElement(Config.fileWhichIsInTheServer1); + assertTrue(fileListView.getFileElement().isDisplayed()); + + 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(); + settingsView.tapOnAccountElement(2,1, 100); + common.assertIsInFileListView(); + + fileListView.scrollTillFindElement(Config.fileWhichIsInTheServer2); + assertTrue(fileListView.getFileElement().isDisplayed()); + } + @Test @Category({NoIgnoreTestCategory.class}) public void test4ExistingAccountRotate () throws Exception { @@ -121,7 +160,7 @@ public class LoginTestSuite{ common.assertIsInFileListView(); MenuList menu = fileListView.clickOnMenuButton(); SettingsView settingsView = menu.clickOnSettingsButton(); - settingsView.tapOnAccountElement(1, 1000); + settingsView.tapOnAccountElement(1,1, 1000); LoginForm changePasswordForm = settingsView .clickOnChangePasswordElement(); changePasswordForm.typePassword("WrongPassword"); 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 index d99a4a611b..8927dacecf 100644 --- 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 @@ -60,7 +60,7 @@ public class LogoutTestSuite{ common.assertIsInFileListView(); MenuList menulist = fileListView.clickOnMenuButton(); SettingsView settingsView = menulist.clickOnSettingsButton(); - settingsView.tapOnAccountElement(1, 1000); + settingsView.tapOnAccountElement(1,1, 1000); LoginForm loginForm = settingsView.clickOnDeleteAccountElement(); assertEquals("Server address https://…", loginForm.gethostUrlInput().getText()); 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 index 287b43da00..d8ffeff572 100644 --- 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 @@ -108,7 +108,7 @@ public class UploadTestSuite{ @Test - @Category({UnfinishedTestCategory.class, InProgressCategory.class}) + @Category({UnfinishedTestCategory.class}) public void testUploadBigFile () throws Exception { FileListView fileListView = Actions.login(Config.URL, Config.user, From 8d5ffec8a5441fb0424e41955bc425ab9d1edf9e Mon Sep 17 00:00:00 2001 From: purigarcia Date: Fri, 5 Jun 2015 13:26:19 +0200 Subject: [PATCH 25/27] add the test to smoke test --- .../com/owncloud/android/test/ui/testSuites/LoginTestSuite.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index 8f1bccf9d1..d9a95535c0 100644 --- 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 @@ -73,7 +73,7 @@ public class LoginTestSuite{ } @Test - @Category({NoIgnoreTestCategory.class}) + @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class}) public void testLoginAndShowFiles () throws Exception { driver.rotate(ScreenOrientation.PORTRAIT); From 7be0fd039b2eb25a5e58d2fbc10fe2aaba809fae Mon Sep 17 00:00:00 2001 From: "David A. Velasco" Date: Mon, 8 Jun 2015 11:15:11 +0200 Subject: [PATCH 26/27] Quick instructions to use automation tests --- automationTest/README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 automationTest/README.md diff --git a/automationTest/README.md b/automationTest/README.md new file mode 100644 index 0000000000..7bbe790b4a --- /dev/null +++ b/automationTest/README.md @@ -0,0 +1,15 @@ +** Work in progress + +This project contains a set of automatic tests operating in the UI level. + +Tests are to be run with the tool Appium. Check [0] to install it and all its dependencies (including Maven). + +You will need to modify the constants in automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/Config.java to assign appropiate values for your test server and accounts. + +To run the tests from command line, plug a device to your computer or start and emulator. Then type + +mvn clean tests + +The project may also be imported in Eclipse, with the appropiate plug-ins, and run from it. + +[0]: http://appium.io/slate/en/master/?java#about-appium \ No newline at end of file From 478ca7c2057e1f1dcf1a1e1e65ba12621995e857 Mon Sep 17 00:00:00 2001 From: "David A. Velasco" Date: Mon, 8 Jun 2015 11:26:10 +0200 Subject: [PATCH 27/27] Update link --- automationTest/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automationTest/README.md b/automationTest/README.md index 7bbe790b4a..938e47a258 100644 --- a/automationTest/README.md +++ b/automationTest/README.md @@ -2,7 +2,7 @@ This project contains a set of automatic tests operating in the UI level. -Tests are to be run with the tool Appium. Check [0] to install it and all its dependencies (including Maven). +Tests are to be run with the tool Appium. Check [here][0] to install it and all its dependencies (including Maven). You will need to modify the constants in automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/Config.java to assign appropiate values for your test server and accounts.