2 * ownCloud Android client application
5 * Copyright (C) 2015 ownCloud Inc.
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.
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.
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/>.
21 package com
.owncloud
.android
.test
.ui
.testSuites
;
24 import static org
.junit
.Assert
.*;
25 import io
.appium
.java_client
.MobileBy
;
26 import io
.appium
.java_client
.android
.AndroidDriver
;
28 import org
.junit
.After
;
29 import org
.junit
.Before
;
30 import org
.junit
.Rule
;
31 import org
.junit
.experimental
.categories
.Category
;
32 import org
.junit
.rules
.TestName
;
33 import org
.junit
.runners
.MethodSorters
;
34 import org
.junit
.FixMethodOrder
;
35 import org
.junit
.Test
;
36 import org
.openqa
.selenium
.By
;
37 import org
.openqa
.selenium
.NoSuchElementException
;
38 import org
.openqa
.selenium
.support
.ui
.ExpectedConditions
;
40 import com
.owncloud
.android
.test
.ui
.actions
.Actions
;
41 import com
.owncloud
.android
.test
.ui
.groups
.FailingTestCategory
;
42 import com
.owncloud
.android
.test
.ui
.groups
.InProgressCategory
;
43 import com
.owncloud
.android
.test
.ui
.groups
.NoIgnoreTestCategory
;
44 import com
.owncloud
.android
.test
.ui
.groups
.SmokeTestCategory
;
45 import com
.owncloud
.android
.test
.ui
.groups
.UnfinishedTestCategory
;
46 import com
.owncloud
.android
.test
.ui
.models
.FileDetailsView
;
47 import com
.owncloud
.android
.test
.ui
.models
.ElementMenuOptions
;
48 import com
.owncloud
.android
.test
.ui
.models
.GmailEmailListView
;
49 import com
.owncloud
.android
.test
.ui
.models
.GmailEmailView
;
50 import com
.owncloud
.android
.test
.ui
.models
.ImageView
;
51 import com
.owncloud
.android
.test
.ui
.models
.FileListView
;
52 import com
.owncloud
.android
.test
.ui
.models
.NotificationView
;
53 import com
.owncloud
.android
.test
.ui
.models
.SettingsView
;
54 import com
.owncloud
.android
.test
.ui
.models
.UploadView
;
57 @FixMethodOrder(MethodSorters
.NAME_ASCENDING
)
58 @Category({NoIgnoreTestCategory
.class})
59 public class UploadTestSuite
{
63 String FILE_NAME
= Config
.fileToTestName
;
64 String BIG_FILE_NAME
= Config
.bigFileToTestName
;
65 String FILE_GMAIL_NAME
= Config
.fileToTestSendByEmailName
;
66 private Boolean fileHasBeenUploadedFromGmail
= false
;
67 private Boolean fileHasBeenUploaded
= false
;
69 @Rule public TestName name
= new TestName();
73 public void setUp() throws Exception
{
75 driver
=common
.setUpCommonDriver();
79 @Category({NoIgnoreTestCategory
.class, SmokeTestCategory
.class})
80 public void testUploadFile () throws Exception
{
82 FileListView fileListView
= Actions
.login(Config
.URL
, Config
.user
,
83 Config
.password
, Config
.isTrusted
, driver
);
84 common
.assertIsInFileListView();
86 //check if the file already exists and if true, delete it
87 Actions
.deleteElement(FILE_NAME
, fileListView
, driver
);
89 FileListView fileListViewAfterUploadFile
= Actions
90 .uploadFile(FILE_NAME
, fileListView
);
92 fileListViewAfterUploadFile
.scrollTillFindElement(FILE_NAME
);
93 assertTrue(fileListViewAfterUploadFile
.getFileElement().isDisplayed());
94 Common
.waitTillElementIsNotPresentWithoutTimeout(
95 fileListViewAfterUploadFile
.getProgressCircular(), 1000);
96 common
.wait
.until(ExpectedConditions
.visibilityOf(
97 fileListViewAfterUploadFile
.getFileElementLayout()
98 .findElement(By
.id(FileListView
.getLocalFileIndicator()))));
99 assertTrue(fileListViewAfterUploadFile
.getFileElementLayout()
100 .findElement(By
.id(FileListView
.getLocalFileIndicator()))
102 fileListView
= new FileListView(driver
);
103 fileListView
.scrollTillFindElement(FILE_NAME
);
105 fileHasBeenUploaded
= fileListView
.getFileElement().isDisplayed());
111 @Category({UnfinishedTestCategory
.class, InProgressCategory
.class})
112 public void testUploadBigFile () throws Exception
{
114 FileListView fileListView
= Actions
.login(Config
.URL
, Config
.user
,
115 Config
.password
, Config
.isTrusted
, driver
);
116 common
.assertIsInFileListView();
118 //check if the file already exists and if true, delete it
119 Actions
.deleteElement(BIG_FILE_NAME
, fileListView
, driver
);
121 FileListView fileListViewAfterUploadFile
= Actions
122 .uploadFile(BIG_FILE_NAME
, fileListView
);
125 driver
.openNotifications();
126 NotificationView notificationView
= new NotificationView(driver
);
129 if(notificationView
.getUploadingNotification().isDisplayed()){
130 Common
.waitTillElementIsPresent(
131 notificationView
.getUploadSucceededNotification(),300000);
132 driver
.sendKeyEvent(android
.view
.KeyEvent
.KEYCODE_HOME
);
133 driver
.startActivity("com.owncloud.android",
134 ".ui.activity.FileDisplayActivity");
137 } catch (NoSuchElementException e
) {
138 driver
.sendKeyEvent(android
.view
.KeyEvent
.KEYCODE_HOME
);
139 driver
.startActivity("com.owncloud.android",
140 ".ui.activity.FileDisplayActivity");
143 fileListViewAfterUploadFile
.scrollTillFindElement(BIG_FILE_NAME
);
145 assertTrue(fileListViewAfterUploadFile
.getFileElement().isDisplayed());
147 Common
.waitTillElementIsNotPresentWithoutTimeout(
148 fileListViewAfterUploadFile
.getProgressCircular(), 1000);
149 common
.wait
.until(ExpectedConditions
.visibilityOf(
150 fileListViewAfterUploadFile
.getFileElementLayout()
151 .findElement(By
.id(FileListView
.getLocalFileIndicator()))));
152 assertTrue(fileListViewAfterUploadFile
.getFileElementLayout()
153 .findElement(By
.id(FileListView
.getLocalFileIndicator()))
155 fileListView
= new FileListView(driver
);
156 fileListView
.scrollTillFindElement(BIG_FILE_NAME
);
158 fileHasBeenUploaded
= fileListView
.getFileElement().isDisplayed());
163 @Category(UnfinishedTestCategory
.class)
164 public void testUploadFromGmail () throws Exception
{
165 FileListView fileListView
= Actions
.login(Config
.URL
, Config
.user
,
166 Config
.password
, Config
.isTrusted
, driver
);
167 driver
.startActivity("com.google.android.gm",
168 ".ConversationListActivityGmail");
169 GmailEmailListView gmailEmailListView
= new GmailEmailListView(driver
);
171 GmailEmailView gmailEmailView
= gmailEmailListView
.clickOnEmail();
172 ImageView imageView
= gmailEmailView
.clickOnfileButton();
173 imageView
.clickOnOptionsButton();
174 imageView
.clickOnShareButton();
175 imageView
.clickOnOwnCloudButton();
176 //justonce button do not appear always
178 imageView
.clickOnJustOnceButton();
179 }catch (NoSuchElementException e
) {
181 UploadView uploadView
= new UploadView(driver
);
182 uploadView
.clickOUploadButton();
183 driver
.sendKeyEvent(android
.view
.KeyEvent
.KEYCODE_HOME
);
184 driver
.startActivity("com.owncloud.android",
185 ".ui.activity.FileDisplayActivity");
186 common
.wait
.until(ExpectedConditions
187 .visibilityOfAllElementsLocatedBy(By
.name(FILE_GMAIL_NAME
)));
188 assertEquals(Config
.fileToTestSendByEmailName
,
189 driver
.findElementByName(FILE_GMAIL_NAME
).getText());
190 fileListView
= new FileListView(driver
);
191 fileListView
.scrollTillFindElement(FILE_GMAIL_NAME
);
192 assertTrue(fileHasBeenUploadedFromGmail
= fileListView
193 .getFileElement().isDisplayed());
194 //TODO. correct assert if fileListView is shown in grid mode
199 @Category({FailingTestCategory
.class})
200 public void testKeepFileUpToDate () throws Exception
{
202 FileListView fileListView
= Actions
.login(Config
.URL
, Config
.user
,
203 Config
.password
, Config
.isTrusted
, driver
);
204 common
.assertIsInFileListView();
206 Common
.waitTillElementIsNotPresentWithoutTimeout(fileListView
.getProgressCircular(),
209 FileListView fileListViewAfterUploadFile
= Actions
210 .uploadFile(FILE_NAME
, fileListView
);
211 fileListViewAfterUploadFile
.scrollTillFindElement(FILE_NAME
);
212 assertTrue(fileHasBeenUploaded
= fileListViewAfterUploadFile
213 .getFileElement().isDisplayed());
215 ElementMenuOptions menuOptions
= fileListViewAfterUploadFile
216 .longPressOnElement(FILE_NAME
);
217 FileDetailsView fileDetailsView
= menuOptions
.clickOnDetails();
218 fileDetailsView
.checkKeepFileUpToDateCheckbox();
220 driver
.sendKeyEvent(android
.view
.KeyEvent
.KEYCODE_BACK
);
221 assertTrue(common
.isElementPresent(
222 fileListViewAfterUploadFile
.getFileElementLayout(),
223 MobileBy
.id(FileListView
.getFavoriteFileIndicator())));
224 assertTrue(fileListViewAfterUploadFile
.getFileElementLayout()
225 .findElement(By
.id(FileListView
.getFavoriteFileIndicator()))
230 @Category({NoIgnoreTestCategory
.class})
231 public void testKeepFileUpToDateAndRefresh () throws Exception
{
233 FileListView fileListView
= Actions
.login(Config
.URL
, Config
.user
,
234 Config
.password
, Config
.isTrusted
, driver
);
235 common
.assertIsInFileListView();
237 Common
.waitTillElementIsNotPresentWithoutTimeout(fileListView
.getProgressCircular(),
240 FileListView fileListViewAfterUploadFile
= Actions
241 .uploadFile(FILE_NAME
, fileListView
);
242 fileListViewAfterUploadFile
.scrollTillFindElement(FILE_NAME
);
243 assertTrue(fileHasBeenUploaded
= fileListViewAfterUploadFile
244 .getFileElement().isDisplayed());
246 ElementMenuOptions menuOptions
= fileListViewAfterUploadFile
247 .longPressOnElement(FILE_NAME
);
248 FileDetailsView fileDetailsView
= menuOptions
.clickOnDetails();
249 fileDetailsView
.checkKeepFileUpToDateCheckbox();
251 driver
.sendKeyEvent(android
.view
.KeyEvent
.KEYCODE_BACK
);
253 fileListViewAfterUploadFile
.pulldownToRefresh();
254 //assertTrue(fileListView.getProgressCircular().isDisplayed());
255 Common
.waitTillElementIsNotPresentWithoutTimeout(fileListView
.getProgressCircular(),
258 assertTrue(common
.isElementPresent(
259 fileListViewAfterUploadFile
.getFileElementLayout(),
260 MobileBy
.id(FileListView
.getFavoriteFileIndicator())));
261 assertTrue(fileListViewAfterUploadFile
.getFileElementLayout()
262 .findElement(By
.id(FileListView
.getFavoriteFileIndicator()))
268 public void tearDown() throws Exception
{
269 common
.takeScreenShotOnFailed(name
.getMethodName());
270 FileListView fileListView
= new FileListView(driver
);
271 if (fileHasBeenUploadedFromGmail
) {
272 Actions
.deleteElement(FILE_GMAIL_NAME
,fileListView
, driver
);
274 if(fileHasBeenUploaded
){
275 Actions
.deleteElement(FILE_NAME
,fileListView
, driver
);
276 Actions
.deleteElement(BIG_FILE_NAME
,fileListView
, driver
);
279 //driver.removeApp("com.owncloud.android");