147801f8e216805da0976098370e8a89f43a4d1e
[pub/Android/ownCloud.git] / automationTest / src / test / java / com / owncloud / android / test / ui / testSuites / ShareLinkFileTestSuite.java
1 package com.owncloud.android.test.ui.testSuites;
2
3 import static org.junit.Assert.assertTrue;
4 import io.appium.java_client.android.AndroidDriver;
5
6 import org.junit.After;
7 import org.junit.Before;
8 import org.junit.Rule;
9 import org.junit.Test;
10 import org.junit.experimental.categories.Category;
11 import org.junit.rules.TestName;
12 import org.openqa.selenium.By;
13 import org.openqa.selenium.support.ui.ExpectedConditions;
14
15 import com.owncloud.android.test.ui.actions.Actions;
16 import com.owncloud.android.test.ui.groups.NoIgnoreTestCategory;
17 import com.owncloud.android.test.ui.groups.SmokeTestCategory;
18 import com.owncloud.android.test.ui.models.ElementMenuOptions;
19 import com.owncloud.android.test.ui.models.GmailSendMailView;
20 import com.owncloud.android.test.ui.models.FileListView;
21 import com.owncloud.android.test.ui.models.ShareView;
22
23 public class ShareLinkFileTestSuite{
24
25 AndroidDriver driver;
26 Common common;
27 private final String FILE_NAME = Config.fileToTestName;
28 private Boolean fileHasBeenCreated = false;
29
30 @Rule public TestName name = new TestName();
31
32 @Before
33 public void setUp() throws Exception {
34 common=new Common();
35 driver=common.setUpCommonDriver();
36 }
37
38 @Test
39 @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class})
40 public void testShareLinkFile () throws Exception {
41 FileListView fileListView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver);
42 common.assertIsInFileListView();
43
44 //TODO. if the file already exists, do not upload
45 FileListView fileListViewAfterUploadFile = Actions.uploadFile(FILE_NAME, fileListView);
46
47 fileListViewAfterUploadFile.scrollTillFindElement(FILE_NAME);
48 assertTrue(fileHasBeenCreated = fileListViewAfterUploadFile.getFileElement().isDisplayed());
49
50 ElementMenuOptions elementMenuOption = fileListViewAfterUploadFile.longPressOnElement(FILE_NAME);
51 ShareView shareView = elementMenuOption.clickOnShareLinkElement();
52 Actions.scrollTillFindElement("Gmail", shareView.getListViewLayout(), driver).click();
53 GmailSendMailView gmailSendMailView = new GmailSendMailView(driver);
54 gmailSendMailView.typeToEmailAdress(Config.gmailAccount);
55 gmailSendMailView.clickOnSendButton();
56 Common.waitTillElementIsNotPresent(fileListViewAfterUploadFile.getProgressCircular(), 1000);
57 common.wait.until(ExpectedConditions.visibilityOf(fileListViewAfterUploadFile.getFileElementLayout().findElement(By.id(FileListView.getSharedElementIndicator()))));
58 assertTrue(fileListViewAfterUploadFile.getFileElementLayout().findElement(By.id(FileListView.getSharedElementIndicator())).isDisplayed());
59
60 }
61
62 @After
63 public void tearDown() throws Exception {
64 common.takeScreenShotOnFailed(name.getMethodName());
65 if (fileHasBeenCreated) {
66 FileListView fileListView = new FileListView(driver);
67 Actions.deleteElement(FILE_NAME,fileListView, driver);
68 }
69 driver.removeApp("com.owncloud.android");
70 driver.quit();
71 }
72 }