42195a77624eaabeb47129c6dbba9f8497cba4ef
[pub/Android/ownCloud.git] / automationTest / src / test / java / com / owncloud / android / test / ui / testSuites / ShareLinkFileTestSuite.java
1 /**
2 * ownCloud Android client application
3 *
4 * @author purigarcia
5 * Copyright (C) 2015 ownCloud Inc.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2,
9 * as published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 *
19 */
20
21 package com.owncloud.android.test.ui.testSuites;
22
23 import static org.junit.Assert.assertTrue;
24 import io.appium.java_client.android.AndroidDriver;
25
26 import org.junit.After;
27 import org.junit.Before;
28 import org.junit.Rule;
29 import org.junit.Test;
30 import org.junit.experimental.categories.Category;
31 import org.junit.rules.TestName;
32 import org.openqa.selenium.By;
33 import org.openqa.selenium.support.ui.ExpectedConditions;
34
35 import com.owncloud.android.test.ui.actions.Actions;
36 import com.owncloud.android.test.ui.groups.NoIgnoreTestCategory;
37 import com.owncloud.android.test.ui.groups.SmokeTestCategory;
38 import com.owncloud.android.test.ui.models.ElementMenuOptions;
39 import com.owncloud.android.test.ui.models.GmailSendMailView;
40 import com.owncloud.android.test.ui.models.FileListView;
41 import com.owncloud.android.test.ui.models.ShareView;
42
43 public class ShareLinkFileTestSuite{
44
45 AndroidDriver driver;
46 Common common;
47 private final String FILE_NAME = Config.fileToTestName;
48 private Boolean fileHasBeenCreated = false;
49
50 @Rule public TestName name = new TestName();
51
52 @Before
53 public void setUp() throws Exception {
54 common=new Common();
55 driver=common.setUpCommonDriver();
56 }
57
58 @Test
59 @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class})
60 public void testShareLinkFile () throws Exception {
61 FileListView fileListView = Actions.login(Config.URL, Config.user,
62 Config.password, Config.isTrusted, driver);
63 common.assertIsInFileListView();
64
65 //TODO. if the file already exists, do not upload
66 FileListView fileListViewAfterUploadFile = Actions
67 .uploadFile(FILE_NAME, fileListView);
68
69 fileListViewAfterUploadFile.scrollTillFindElement(FILE_NAME);
70 assertTrue(fileHasBeenCreated = fileListViewAfterUploadFile
71 .getFileElement().isDisplayed());
72
73 ElementMenuOptions elementMenuOption = fileListViewAfterUploadFile
74 .longPressOnElement(FILE_NAME);
75 ShareView shareView = elementMenuOption.clickOnShareLinkElement();
76 Actions.scrollTillFindElement("Gmail", shareView.getListViewLayout(),
77 driver).click();
78 GmailSendMailView gmailSendMailView = new GmailSendMailView(driver);
79 gmailSendMailView.typeToEmailAdress(Config.gmailAccount);
80 gmailSendMailView.clickOnSendButton();
81 Common.waitTillElementIsNotPresent(fileListViewAfterUploadFile
82 .getProgressCircular(), 1000);
83 common.wait.until(ExpectedConditions.visibilityOf(
84 fileListViewAfterUploadFile.getFileElementLayout()
85 .findElement(By.id(FileListView.getSharedElementIndicator()))));
86 assertTrue(fileListViewAfterUploadFile.getFileElementLayout()
87 .findElement(By.id(FileListView.getSharedElementIndicator()))
88 .isDisplayed());
89
90 }
91
92 @After
93 public void tearDown() throws Exception {
94 common.takeScreenShotOnFailed(name.getMethodName());
95 if (fileHasBeenCreated) {
96 FileListView fileListView = new FileListView(driver);
97 Actions.deleteElement(FILE_NAME,fileListView, driver);
98 }
99 driver.removeApp("com.owncloud.android");
100 driver.quit();
101 }
102 }