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
.models
;
23 import java
.util
.List
;
25 import io
.appium
.java_client
.android
.AndroidDriver
;
26 import io
.appium
.java_client
.android
.AndroidElement
;
27 import io
.appium
.java_client
.android
.AndroidKeyCode
;
28 import io
.appium
.java_client
.pagefactory
.AndroidFindBy
;
29 import io
.appium
.java_client
.pagefactory
.AppiumFieldDecorator
;
31 import org
.openqa
.selenium
.NoSuchElementException
;
32 import org
.openqa
.selenium
.support
.CacheLookup
;
33 import org
.openqa
.selenium
.support
.PageFactory
;
34 import org
.openqa
.selenium
.Point
;
36 import com
.owncloud
.android
.test
.ui
.actions
.Actions
;
38 public class FileListView
{
39 final AndroidDriver driver
;
41 @AndroidFindBy(uiAutomator
= "new UiSelector()"
42 + ".description(\"More options\")")
43 private AndroidElement menuButton
;
46 @AndroidFindBy(id
= "com.owncloud.android:id/list_root")
47 private AndroidElement filesLayout
;
50 @AndroidFindBy(uiAutomator
= "new UiSelector()"
51 + ".resourceId(\"android:id/action_bar_title\")")
52 private AndroidElement titleText
;
54 @AndroidFindBy(id
= "android:id/progress_circular")
55 private AndroidElement progressCircular
;
58 @AndroidFindBy(uiAutomator
= "new UiSelector()"
59 + ".description(\"New folder\")")
60 private AndroidElement newFolderButton
;
63 @AndroidFindBy(uiAutomator
= "new UiSelector().description(\"Upload\")")
64 private AndroidElement uploadButton
;
66 private AndroidElement waitAMomentText
;
68 @AndroidFindBy(id
= "com.owncloud.android:id/ListItemLayout")
69 private List
<AndroidElement
> listItemLayout
;
71 @AndroidFindBy(id
= "com.owncloud.android:id/list_root")
72 private AndroidElement listRootLayout
;
74 @AndroidFindBy(name
= "Files")
75 private AndroidElement filesElementUploadFile
;
78 @AndroidFindBy(uiAutomator
= "new UiSelector()"
79 + ".description(\"List Layout\")")
80 private AndroidElement listLayout
;
82 private AndroidElement fileElement
;
84 private AndroidElement fileElementLayout
;
86 private static String localFileIndicator
=
87 "com.owncloud.android:id/localFileIndicator";
88 private static String favoriteFileIndicator
=
89 "com.owncloud.android:id/favoriteIcon";
90 private static String sharedElementIndicator
=
91 "com.owncloud.android:id/sharedIcon";
94 public FileListView (AndroidDriver driver
) {
96 PageFactory
.initElements(new AppiumFieldDecorator(driver
), this);
99 public MenuList
clickOnMenuButton () {
100 //if the menu option is not in the actionBar, it is opening again
103 } catch (NoSuchElementException e
){
104 driver
.sendKeyEvent(AndroidKeyCode
.MENU
);
106 MenuList menuList
= new MenuList (driver
);
110 public SettingsView
getSettingsView () {
111 SettingsView settingsView
= new SettingsView(driver
);
115 public NewFolderPopUp
clickOnNewFolderButton () {
116 newFolderButton
.click();
117 NewFolderPopUp newFolderPopUp
= new NewFolderPopUp(driver
);
118 return newFolderPopUp
;
121 public void clickOnUploadButton () {
122 uploadButton
.click();
125 public UploadFilesView
clickOnFilesElementUploadFile () {
126 filesElementUploadFile
.click();
127 UploadFilesView uploadFilesView
= new UploadFilesView(driver
);
128 return uploadFilesView
;
131 public AndroidElement
getTitleTextElement () {
135 public AndroidElement
getUploadButton () {
139 public AndroidElement
getWaitAMomentTextElement () {
140 return waitAMomentText
;
143 public AndroidElement
getListRootElement () {
144 return listRootLayout
;
147 public List
<AndroidElement
> getListItemLayout () {
148 return listItemLayout
;
151 public AndroidElement
getFileElement () {
155 public ElementMenuOptions
longPressOnElement (String elementName
) {
156 scrollTillFindElement(elementName
).tap(1, 1000);
157 //fileElement.tap(1, 1000);
158 ElementMenuOptions menuOptions
= new ElementMenuOptions(driver
);
162 public AndroidElement
scrollTillFindElement (String elementName
) {
163 fileElement
= Actions
164 .scrollTillFindElement (elementName
,filesLayout
,driver
);
166 fileElementLayout
= (AndroidElement
) driver
167 .findElementByAndroidUIAutomator("new UiSelector()"
168 + ".description(\"LinearLayout-"+ elementName
+"\")");
169 } catch (NoSuchElementException e
) {
170 fileElementLayout
= null
;
175 public AndroidElement
getFileElementLayout () {
176 return fileElementLayout
;
179 public AndroidElement
getProgressCircular () {
180 return progressCircular
;
183 public static String
getLocalFileIndicator() {
184 return localFileIndicator
;
187 public static String
getFavoriteFileIndicator() {
188 return favoriteFileIndicator
;
191 public static String
getSharedElementIndicator() {
192 return sharedElementIndicator
;
194 public void pulldownToRefresh () throws InterruptedException
{
195 Point listLocation
= listLayout
.getLocation();
196 driver
.swipe(listLocation
.getX(),listLocation
.getY(),
197 listLocation
.getX(),listLocation
.getY()+1000, 5000);