c22525eb091525adaae414dac5dbbbf5bc98a5d2
[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.*;
24 import io.appium.java_client.android.AndroidDriver;
25 import io.appium.java_client.android.AndroidElement;
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 com.owncloud.android.test.ui.actions.Actions;
33 import com.owncloud.android.test.ui.groups.IgnoreTestCategory;
34 import com.owncloud.android.test.ui.groups.NoIgnoreTestCategory;
35 import com.owncloud.android.test.ui.groups.SmokeTestCategory;
36 import com.owncloud.android.test.ui.models.FileListView;;
37
38 public class ShareLinkFileTestSuite{
39
40 AndroidDriver driver;
41 Common common;
42 private final String FILE_NAME = Config.fileToTestName;
43 private Boolean fileHasBeenCreated = false;
44
45 @Rule public TestName name = new TestName();
46
47 @Before
48 public void setUp() throws Exception {
49 common=new Common();
50 driver=common.setUpCommonDriver();
51 }
52
53 @Test
54 @Category({NoIgnoreTestCategory.class})
55 public void testShareLinkFileByGmail () throws Exception {
56 AndroidElement sharedElementIndicator;
57 FileListView fileListView = Actions.login(Config.URL, Config.user,
58 Config.password, Config.isTrusted, driver);
59 common.assertIsInFileListView();
60
61 //TODO. if the file already exists, do not upload
62 FileListView fileListViewAfterUploadFile = Actions
63 .uploadFile(FILE_NAME, fileListView);
64
65 fileListViewAfterUploadFile.scrollTillFindElement(FILE_NAME);
66 assertTrue(fileHasBeenCreated = fileListViewAfterUploadFile
67 .getFileElement().isDisplayed());
68
69 sharedElementIndicator = Actions.shareLinkElementByGmail(FILE_NAME,
70 fileListViewAfterUploadFile,driver,common);
71 assertTrue(sharedElementIndicator.isDisplayed());
72 }
73
74 @Test
75 @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class})
76 public void testShareLinkFileByCopyLink () throws Exception {
77 AndroidElement sharedElementIndicator;
78 FileListView fileListView = Actions.login(Config.URL, Config.user,
79 Config.password, Config.isTrusted, driver);
80 common.assertIsInFileListView();
81
82 //TODO. if the file already exists, do not upload
83 FileListView fileListViewAfterUploadFile = Actions
84 .uploadFile(FILE_NAME, fileListView);
85
86 fileListViewAfterUploadFile.scrollTillFindElement(FILE_NAME);
87 assertTrue(fileHasBeenCreated = fileListViewAfterUploadFile
88 .getFileElement().isDisplayed());
89
90 sharedElementIndicator = Actions.shareLinkElementByCopyLink(FILE_NAME,
91 fileListViewAfterUploadFile,driver,common);
92 assertTrue(sharedElementIndicator.isDisplayed());
93 }
94
95 @Test
96 @Category({IgnoreTestCategory.class, SmokeTestCategory.class})
97 public void testUnshareLinkFile () throws Exception {
98 AndroidElement sharedElementIndicator;
99 FileListView fileListView = Actions.login(Config.URL, Config.user,
100 Config.password, Config.isTrusted, driver);
101 common.assertIsInFileListView();
102
103 //TODO. if the file already exists, do not upload
104 FileListView fileListViewAfterUploadFile = Actions
105 .uploadFile(FILE_NAME, fileListView);
106
107 fileListViewAfterUploadFile.scrollTillFindElement(FILE_NAME);
108 assertTrue(fileHasBeenCreated = fileListViewAfterUploadFile
109 .getFileElement().isDisplayed());
110
111 sharedElementIndicator = Actions.shareLinkElementByCopyLink(FILE_NAME,
112 fileListViewAfterUploadFile,driver,common);
113 assertTrue(sharedElementIndicator.isDisplayed());
114 Actions.unshareLinkElement(FILE_NAME,
115 fileListViewAfterUploadFile,driver,common);
116 assertFalse(sharedElementIndicator.isDisplayed());
117
118 }
119
120 @After
121 public void tearDown() throws Exception {
122 common.takeScreenShotOnFailed(name.getMethodName());
123 if (fileHasBeenCreated) {
124 FileListView fileListView = new FileListView(driver);
125 Actions.deleteElement(FILE_NAME,fileListView, driver);
126 }
127 driver.removeApp("com.owncloud.android");
128 driver.quit();
129 }
130 }