X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/2d95a83959c77a0c4820c6668b439f8e1b0d038a..a52fc9424444400d4c774b76cf9f59ba43f9dc12:/automationTest/src/test/java/androidtest/tests/UploadTestSuite.java diff --git a/automationTest/src/test/java/androidtest/tests/UploadTestSuite.java b/automationTest/src/test/java/androidtest/tests/UploadTestSuite.java index 6038930e..358024d7 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");