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;
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 {
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;
.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();
@AndroidFindBy(name = "Share link")
private AndroidElement shareLinkElement;
+ @AndroidFindBy(name = "Unshare link")
+ private AndroidElement unshareLinkElement;
+
@AndroidFindBy(name = "Details")
private AndroidElement detailsFileElement;
ShareView shareView = new ShareView(driver);
return shareView;
}
+
+ public WaitAMomentPopUp clickOnUnshareLinkElement () {
+ unshareLinkElement.click();
+ WaitAMomentPopUp waitAMomentPopUp = new WaitAMomentPopUp(driver);
+ return waitAMomentPopUp;
+ }
}
package com.owncloud.android.test.ui.testSuites;
import static org.junit.Assert.*;
+
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.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.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;
AndroidDriver driver;
static int waitingTime = 30;
- WebDriverWait wait;
+ public WebDriverWait wait;
protected AndroidDriver setUpCommonDriver () throws Exception {
File rootPath = new File(System.getProperty("user.dir"));
//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){
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)
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));
}
}
assertNull(fileElement);
}
-
+
protected void assertIsPasscodeRequestView() throws InterruptedException {
assertTrue(waitForTextPresent("ownCloud", (AndroidElement) driver
.findElementByAndroidUIAutomator("new UiSelector()"
WaitAMomentPopUp waitAMomentPopUp = Actions
.createFolder(NEW_FOLDER_NAME, fileListView);
- Common.waitTillElementIsNotPresent(waitAMomentPopUp
+ Common.waitTillElementIsNotPresentWithoutTimeout(waitAMomentPopUp
.getWaitAMomentTextElement(), 100);
fileListView.scrollTillFindElement(FOLDER_NAME);
assertNotNull(fileListView.getFileElement());
.uploadFile(FILE_NAME, fileListView);
fileListViewAfterUploadFile.scrollTillFindElement(FILE_NAME);
- Common.waitTillElementIsNotPresent(
+ Common.waitTillElementIsNotPresentWithoutTimeout(
fileListViewAfterUploadFile.getProgressCircular(), 1000);
common.wait.until(ExpectedConditions.visibilityOf(
fileListViewAfterUploadFile.getFileElementLayout()
//create the folder
WaitAMomentPopUp waitAMomentPopUp = Actions
.createFolder(FOLDER_NAME, fileListView);
- Common.waitTillElementIsNotPresent(
+ Common.waitTillElementIsNotPresentWithoutTimeout(
waitAMomentPopUp.getWaitAMomentTextElement(), 100);
fileListView.scrollTillFindElement(FOLDER_NAME);
assertTrue(
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();
}
@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();
}
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
//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());
//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);
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
//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());
//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);
//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
assertTrue(fileHasBeenCreated = fileListViewAfterUploadFile
.getFileElement().isDisplayed());
CurrentCreatedFile = OLD_FILE_NAME;
- Common.waitTillElementIsNotPresent(fileListViewAfterUploadFile
+ Common.waitTillElementIsNotPresentWithoutTimeout(fileListViewAfterUploadFile
.getProgressCircular(), 1000);
common.wait.until(ExpectedConditions.visibilityOf(
fileListViewAfterUploadFile.getFileElementLayout()
newFolderPopUp.typeNewFolderName(FILE_NAME);
WaitAMomentPopUp waitAMomentPopUp = newFolderPopUp
.clickOnNewFolderOkButton();
- Common.waitTillElementIsNotPresent(waitAMomentPopUp
+ Common.waitTillElementIsNotPresentWithoutTimeout(waitAMomentPopUp
.getWaitAMomentTextElement(), 100);
fileListViewAfterUploadFile.scrollTillFindElement(FILE_NAME);
assertNotNull(fileListViewAfterUploadFile.getFileElement());
//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);
FolderPopUp.typeNewFolderName(FOLDER_NAME);
FolderPopUp.clickOnNewFolderOkButton();
CurrentCreatedFolder = FOLDER_NAME;
- Common.waitTillElementIsNotPresent(waitAMomentPopUp
+ Common.waitTillElementIsNotPresentWithoutTimeout(waitAMomentPopUp
.getWaitAMomentTextElement(), 100);
fileListView.scrollTillFindElement(FOLDER_NAME);
assertNotNull(fileListView.getFileElement());
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{
}
@Test
+ @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();
+
+ //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.shareLinkElementByGmail(FILE_NAME,
+ fileListViewAfterUploadFile,driver,common);
+ assertTrue(sharedElementIndicator.isDisplayed());
+ }
+
+ @Test
@Category({NoIgnoreTestCategory.class, SmokeTestCategory.class})
- public void testShareLinkFile () throws Exception {
+ 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();
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.shareLinkElementByCopyLink(FILE_NAME,
+ fileListViewAfterUploadFile,driver,common);
+ assertTrue(sharedElementIndicator.isDisplayed());
+ Actions.unshareLinkElement(FILE_NAME,
+ fileListViewAfterUploadFile,driver,common);
+ assertFalse(sharedElementIndicator.isDisplayed());
}
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;
fileListViewAfterUploadFile.scrollTillFindElement(FILE_NAME);
assertTrue(fileListViewAfterUploadFile.getFileElement().isDisplayed());
- Common.waitTillElementIsNotPresent(
+ Common.waitTillElementIsNotPresentWithoutTimeout(
fileListViewAfterUploadFile.getProgressCircular(), 1000);
common.wait.until(ExpectedConditions.visibilityOf(
fileListViewAfterUploadFile.getFileElementLayout()
Config.password, Config.isTrusted, driver);
common.assertIsInFileListView();
- Common.waitTillElementIsNotPresent(fileListView.getProgressCircular(),
+ Common.waitTillElementIsNotPresentWithoutTimeout(fileListView.getProgressCircular(),
1000);
FileListView fileListViewAfterUploadFile = Actions
Config.password, Config.isTrusted, driver);
common.assertIsInFileListView();
- Common.waitTillElementIsNotPresent(fileListView.getProgressCircular(),
+ Common.waitTillElementIsNotPresentWithoutTimeout(fileListView.getProgressCircular(),
1000);
FileListView fileListViewAfterUploadFile = Actions
fileListViewAfterUploadFile.pulldownToRefresh();
//assertTrue(fileListView.getProgressCircular().isDisplayed());
- Common.waitTillElementIsNotPresent(fileListView.getProgressCircular(),
+ Common.waitTillElementIsNotPresentWithoutTimeout(fileListView.getProgressCircular(),
100);
assertTrue(common.isElementPresent(