From: purigarcia Date: Fri, 29 May 2015 12:16:35 +0000 (+0200) Subject: upload a big file. not finished X-Git-Tag: oc-android-1.7.2~1^2~32^2~13 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/f973a1db0eae8ff2df538caad210ef3f6fa2bae7?ds=sidebyside upload a big file. not finished --- 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 c2349c48..938d277d 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 f10e7aa3..3c33864e 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 00000000..35de73c8 --- /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 1baa30b3..36287dab 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 c22525eb..5e604cd3 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 cf8f84d0..af956477 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");