add new testCases. prepare the test to have them into categories

This commit is contained in:
purigarcia 2015-05-11 08:20:21 +02:00
parent 2d95a83959
commit a52fc94244
21 changed files with 385 additions and 148 deletions

View file

@ -1,2 +1,3 @@
/target/
src/test/java/androidtest/tests/Config.java
target/
ScreenShots/

View file

@ -1,4 +0,0 @@
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/test/java=UTF-8
encoding/<project>=UTF-8

View file

@ -56,7 +56,7 @@
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>2.1.0</version>
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>

View file

@ -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();;

View file

@ -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;
}
}

View file

@ -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 () {

View file

@ -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;
}
@ -142,5 +157,10 @@ public class MainView {
return favoriteFileIndicator;
}
public void pulldownToRefresh () throws InterruptedException {
Point listLocation = listLayout.getLocation();
driver.swipe(listLocation.getX(),listLocation.getY(), listLocation.getX(),listLocation.getY()+1000, 5000);
}
}

View file

@ -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 () {

View file

@ -30,6 +30,9 @@ public class SettingsView {
@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);
@ -56,4 +59,20 @@ public class SettingsView {
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;
}
}

View file

@ -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,42 +8,38 @@ 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;
}
@ -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\")")));
}
}

View file

@ -2,28 +2,19 @@ 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 final String userAccount = user + "@"+ URL;
public static final String userAccount2 = user2 + "@"+ URL2;
public static String GetURl(String server, Boolean hasSubdirectory, String serverResource){
if(hasSubdirectory){
return server + serverResource;
}else{
return server;
}
}
}

View file

@ -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);

View file

@ -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();
}

View file

@ -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);

View file

@ -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();
}

View file

@ -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();
}
}

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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");