1 package com
.owncloud
.android
.test
.ui
.models
;
5 import io
.appium
.java_client
.android
.AndroidDriver
;
6 import io
.appium
.java_client
.android
.AndroidElement
;
7 import io
.appium
.java_client
.android
.AndroidKeyCode
;
8 import io
.appium
.java_client
.pagefactory
.AndroidFindBy
;
9 import io
.appium
.java_client
.pagefactory
.AppiumFieldDecorator
;
11 import org
.openqa
.selenium
.NoSuchElementException
;
12 import org
.openqa
.selenium
.support
.CacheLookup
;
13 import org
.openqa
.selenium
.support
.PageFactory
;
14 import org
.openqa
.selenium
.Point
;
16 import com
.owncloud
.android
.test
.ui
.actions
.Actions
;
18 public class FileListView
{
19 final AndroidDriver driver
;
21 @AndroidFindBy(uiAutomator
= "new UiSelector().description(\"More options\")")
22 private AndroidElement menuButton
;
25 @AndroidFindBy(id
= "com.owncloud.android:id/list_root")
26 private AndroidElement filesLayout
;
29 @AndroidFindBy(uiAutomator
= "new UiSelector().resourceId(\"android:id/action_bar_title\")")
30 private AndroidElement titleText
;
32 @AndroidFindBy(id
= "android:id/progress_circular")
33 private AndroidElement progressCircular
;
36 @AndroidFindBy(uiAutomator
= "new UiSelector().description(\"New folder\")")
37 private AndroidElement newFolderButton
;
40 @AndroidFindBy(uiAutomator
= "new UiSelector().description(\"Upload\")")
41 private AndroidElement uploadButton
;
43 private AndroidElement waitAMomentText
;
45 @AndroidFindBy(id
= "com.owncloud.android:id/ListItemLayout")
46 private List
<AndroidElement
> listItemLayout
;
48 @AndroidFindBy(id
= "com.owncloud.android:id/list_root")
49 private AndroidElement listRootLayout
;
51 @AndroidFindBy(name
= "Files")
52 private AndroidElement filesElementUploadFile
;
55 @AndroidFindBy(uiAutomator
= "new UiSelector().description(\"List Layout\")")
56 private AndroidElement listLayout
;
58 private AndroidElement fileElement
;
60 private AndroidElement fileElementLayout
;
62 private static String localFileIndicator
= "com.owncloud.android:id/localFileIndicator";
63 private static String favoriteFileIndicator
= "com.owncloud.android:id/favoriteIcon";
64 private static String sharedElementIndicator
= "com.owncloud.android:id/sharedIcon";
67 public FileListView (AndroidDriver driver
) {
69 PageFactory
.initElements(new AppiumFieldDecorator(driver
), this);
72 public MenuList
clickOnMenuButton () {
73 //if the menu option is not in the actionBar, it is opening again
76 } catch (NoSuchElementException e
){
77 driver
.sendKeyEvent(AndroidKeyCode
.MENU
);
79 MenuList menuList
= new MenuList (driver
);
83 public SettingsView
getSettingsView () {
84 SettingsView settingsView
= new SettingsView(driver
);
88 public NewFolderPopUp
clickOnNewFolderButton () {
89 newFolderButton
.click();
90 NewFolderPopUp newFolderPopUp
= new NewFolderPopUp(driver
);
91 return newFolderPopUp
;
94 public void clickOnUploadButton () {
98 public UploadFilesView
clickOnFilesElementUploadFile () {
99 filesElementUploadFile
.click();
100 UploadFilesView uploadFilesView
= new UploadFilesView(driver
);
101 return uploadFilesView
;
104 public AndroidElement
getTitleTextElement () {
108 public AndroidElement
getUploadButton () {
112 public AndroidElement
getWaitAMomentTextElement () {
113 return waitAMomentText
;
116 public AndroidElement
getListRootElement () {
117 return listRootLayout
;
120 public List
<AndroidElement
> getListItemLayout () {
121 return listItemLayout
;
124 public AndroidElement
getFileElement () {
128 public ElementMenuOptions
longPressOnElement (String elementName
) {
129 scrollTillFindElement(elementName
).tap(1, 1000);
130 //fileElement.tap(1, 1000);
131 ElementMenuOptions menuOptions
= new ElementMenuOptions(driver
);
135 public AndroidElement
scrollTillFindElement (String elementName
) {
136 fileElement
= Actions
.scrollTillFindElement (elementName
,filesLayout
,driver
);
138 fileElementLayout
= (AndroidElement
) driver
.findElementByAndroidUIAutomator("new UiSelector().description(\"LinearLayout-"+ elementName
+"\")");
139 } catch (NoSuchElementException e
) {
140 fileElementLayout
= null
;
145 public AndroidElement
getFileElementLayout () {
146 return fileElementLayout
;
149 public AndroidElement
getProgressCircular () {
150 return progressCircular
;
153 public static String
getLocalFileIndicator() {
154 return localFileIndicator
;
157 public static String
getFavoriteFileIndicator() {
158 return favoriteFileIndicator
;
161 public static String
getSharedElementIndicator() {
162 return sharedElementIndicator
;
164 public void pulldownToRefresh () throws InterruptedException
{
165 Point listLocation
= listLayout
.getLocation();
166 driver
.swipe(listLocation
.getX(),listLocation
.getY(), listLocation
.getX(),listLocation
.getY()+1000, 5000);