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
;
39 import com
.owncloud
.android
.test
.ui
.actions
.Actions
;
40 import com
.owncloud
.android
.test
.ui
.groups
.FailingTestCategory
;
41 import com
.owncloud
.android
.test
.ui
.groups
.NoIgnoreTestCategory
;
42 import com
.owncloud
.android
.test
.ui
.groups
.SmokeTestCategory
;
43 import com
.owncloud
.android
.test
.ui
.groups
.UnfinishedTestCategory
;
44 import com
.owncloud
.android
.test
.ui
.models
.FileDetailsView
;
45 import com
.owncloud
.android
.test
.ui
.models
.ElementMenuOptions
;
46 import com
.owncloud
.android
.test
.ui
.models
.GmailEmailListView
;
47 import com
.owncloud
.android
.test
.ui
.models
.GmailEmailView
;
48 import com
.owncloud
.android
.test
.ui
.models
.ImageView
;
49 import com
.owncloud
.android
.test
.ui
.models
.FileListView
;
50 import com
.owncloud
.android
.test
.ui
.models
.UploadView
;
53 @FixMethodOrder(MethodSorters
.NAME_ASCENDING
)
54 @Category({NoIgnoreTestCategory
.class})
55 public class UploadTestSuite
{
59 String FILE_NAME
= Config
.fileToTestName
;
60 String FILE_GMAIL_NAME
= Config
.fileToTestSendByEmailName
;
61 private Boolean fileHasBeenUploadedFromGmail
= false
;
62 private Boolean fileHasBeenUploaded
= false
;
64 @Rule public TestName name
= new TestName();
68 public void setUp() throws Exception
{
70 driver
=common
.setUpCommonDriver();
74 @Category({NoIgnoreTestCategory
.class, SmokeTestCategory
.class})
75 public void testUploadFile () throws Exception
{
77 FileListView fileListView
= Actions
.login(Config
.URL
, Config
.user
,
78 Config
.password
, Config
.isTrusted
, driver
);
79 common
.assertIsInFileListView();
81 //check if the file already exists and if true, delete it
82 Actions
.deleteElement(FILE_NAME
, fileListView
, driver
);
84 FileListView fileListViewAfterUploadFile
= Actions
85 .uploadFile(FILE_NAME
, fileListView
);
87 fileListViewAfterUploadFile
.scrollTillFindElement(FILE_NAME
);
88 assertTrue(fileListViewAfterUploadFile
.getFileElement().isDisplayed());
89 Common
.waitTillElementIsNotPresentWithoutTimeout(
90 fileListViewAfterUploadFile
.getProgressCircular(), 1000);
91 common
.wait
.until(ExpectedConditions
.visibilityOf(
92 fileListViewAfterUploadFile
.getFileElementLayout()
93 .findElement(By
.id(FileListView
.getLocalFileIndicator()))));
94 assertTrue(fileListViewAfterUploadFile
.getFileElementLayout()
95 .findElement(By
.id(FileListView
.getLocalFileIndicator()))
97 fileListView
= new FileListView(driver
);
98 fileListView
.scrollTillFindElement(FILE_NAME
);
100 fileHasBeenUploaded
= fileListView
.getFileElement().isDisplayed());
104 @Category(UnfinishedTestCategory
.class)
105 public void testUploadFromGmail () throws Exception
{
106 FileListView fileListView
= Actions
.login(Config
.URL
, Config
.user
,
107 Config
.password
, Config
.isTrusted
, driver
);
108 driver
.startActivity("com.google.android.gm",
109 ".ConversationListActivityGmail");
110 GmailEmailListView gmailEmailListView
= new GmailEmailListView(driver
);
112 GmailEmailView gmailEmailView
= gmailEmailListView
.clickOnEmail();
113 ImageView imageView
= gmailEmailView
.clickOnfileButton();
114 imageView
.clickOnOptionsButton();
115 imageView
.clickOnShareButton();
116 imageView
.clickOnOwnCloudButton();
117 //justonce button do not appear always
119 imageView
.clickOnJustOnceButton();
120 }catch (NoSuchElementException e
) {
122 UploadView uploadView
= new UploadView(driver
);
123 uploadView
.clickOUploadButton();
124 driver
.sendKeyEvent(android
.view
.KeyEvent
.KEYCODE_HOME
);
125 driver
.startActivity("com.owncloud.android",
126 ".ui.activity.FileDisplayActivity");
127 common
.wait
.until(ExpectedConditions
128 .visibilityOfAllElementsLocatedBy(By
.name(FILE_GMAIL_NAME
)));
129 assertEquals(Config
.fileToTestSendByEmailName
,
130 driver
.findElementByName(FILE_GMAIL_NAME
).getText());
131 fileListView
= new FileListView(driver
);
132 fileListView
.scrollTillFindElement(FILE_GMAIL_NAME
);
133 assertTrue(fileHasBeenUploadedFromGmail
= fileListView
134 .getFileElement().isDisplayed());
135 //TODO. correct assert if fileListView is shown in grid mode
140 @Category({FailingTestCategory
.class})
141 public void testKeepFileUpToDate () throws Exception
{
143 FileListView fileListView
= Actions
.login(Config
.URL
, Config
.user
,
144 Config
.password
, Config
.isTrusted
, driver
);
145 common
.assertIsInFileListView();
147 Common
.waitTillElementIsNotPresentWithoutTimeout(fileListView
.getProgressCircular(),
150 FileListView fileListViewAfterUploadFile
= Actions
151 .uploadFile(FILE_NAME
, fileListView
);
152 fileListViewAfterUploadFile
.scrollTillFindElement(FILE_NAME
);
153 assertTrue(fileHasBeenUploaded
= fileListViewAfterUploadFile
154 .getFileElement().isDisplayed());
156 ElementMenuOptions menuOptions
= fileListViewAfterUploadFile
157 .longPressOnElement(FILE_NAME
);
158 FileDetailsView fileDetailsView
= menuOptions
.clickOnDetails();
159 fileDetailsView
.checkKeepFileUpToDateCheckbox();
161 driver
.sendKeyEvent(android
.view
.KeyEvent
.KEYCODE_BACK
);
162 assertTrue(common
.isElementPresent(
163 fileListViewAfterUploadFile
.getFileElementLayout(),
164 MobileBy
.id(FileListView
.getFavoriteFileIndicator())));
165 assertTrue(fileListViewAfterUploadFile
.getFileElementLayout()
166 .findElement(By
.id(FileListView
.getFavoriteFileIndicator()))
171 @Category({NoIgnoreTestCategory
.class})
172 public void testKeepFileUpToDateAndRefresh () throws Exception
{
174 FileListView fileListView
= Actions
.login(Config
.URL
, Config
.user
,
175 Config
.password
, Config
.isTrusted
, driver
);
176 common
.assertIsInFileListView();
178 Common
.waitTillElementIsNotPresentWithoutTimeout(fileListView
.getProgressCircular(),
181 FileListView fileListViewAfterUploadFile
= Actions
182 .uploadFile(FILE_NAME
, fileListView
);
183 fileListViewAfterUploadFile
.scrollTillFindElement(FILE_NAME
);
184 assertTrue(fileHasBeenUploaded
= fileListViewAfterUploadFile
185 .getFileElement().isDisplayed());
187 ElementMenuOptions menuOptions
= fileListViewAfterUploadFile
188 .longPressOnElement(FILE_NAME
);
189 FileDetailsView fileDetailsView
= menuOptions
.clickOnDetails();
190 fileDetailsView
.checkKeepFileUpToDateCheckbox();
192 driver
.sendKeyEvent(android
.view
.KeyEvent
.KEYCODE_BACK
);
194 fileListViewAfterUploadFile
.pulldownToRefresh();
195 //assertTrue(fileListView.getProgressCircular().isDisplayed());
196 Common
.waitTillElementIsNotPresentWithoutTimeout(fileListView
.getProgressCircular(),
199 assertTrue(common
.isElementPresent(
200 fileListViewAfterUploadFile
.getFileElementLayout(),
201 MobileBy
.id(FileListView
.getFavoriteFileIndicator())));
202 assertTrue(fileListViewAfterUploadFile
.getFileElementLayout()
203 .findElement(By
.id(FileListView
.getFavoriteFileIndicator()))
209 public void tearDown() throws Exception
{
210 common
.takeScreenShotOnFailed(name
.getMethodName());
211 FileListView fileListView
= new FileListView(driver
);
212 if (fileHasBeenUploadedFromGmail
) {
213 Actions
.deleteElement(FILE_GMAIL_NAME
,fileListView
, driver
);
215 if(fileHasBeenUploaded
){
216 Actions
.deleteElement(FILE_NAME
,fileListView
, driver
);
219 driver
.removeApp("com.owncloud.android");