1 package com
.owncloud
.android
.test
.ui
.testSuites
;
4 import static org
.junit
.Assert
.*;
5 import io
.appium
.java_client
.MobileBy
;
6 import io
.appium
.java_client
.android
.AndroidDriver
;
8 import org
.junit
.After
;
9 import org
.junit
.Before
;
10 import org
.junit
.Rule
;
11 import org
.junit
.experimental
.categories
.Category
;
12 import org
.junit
.rules
.TestName
;
13 import org
.junit
.runners
.MethodSorters
;
14 import org
.junit
.FixMethodOrder
;
15 import org
.junit
.Test
;
16 import org
.openqa
.selenium
.By
;
17 import org
.openqa
.selenium
.NoSuchElementException
;
18 import org
.openqa
.selenium
.support
.ui
.ExpectedConditions
;
20 import com
.owncloud
.android
.test
.ui
.actions
.Actions
;
21 import com
.owncloud
.android
.test
.ui
.groups
.FailingTestCategory
;
22 import com
.owncloud
.android
.test
.ui
.groups
.IgnoreTestCategory
;
23 import com
.owncloud
.android
.test
.ui
.groups
.NoIgnoreTestCategory
;
24 import com
.owncloud
.android
.test
.ui
.groups
.UnfinishedTestCategory
;
25 import com
.owncloud
.android
.test
.ui
.models
.FileDetailsView
;
26 import com
.owncloud
.android
.test
.ui
.models
.ElementMenuOptions
;
27 import com
.owncloud
.android
.test
.ui
.models
.GmailEmailListView
;
28 import com
.owncloud
.android
.test
.ui
.models
.GmailEmailView
;
29 import com
.owncloud
.android
.test
.ui
.models
.ImageView
;
30 import com
.owncloud
.android
.test
.ui
.models
.FileListView
;
31 import com
.owncloud
.android
.test
.ui
.models
.UploadView
;
34 @FixMethodOrder(MethodSorters
.NAME_ASCENDING
)
35 @Category({NoIgnoreTestCategory
.class})
36 public class UploadTestSuite
{
40 String FILE_NAME
= Config
.fileToTestName
;
41 String FILE_GMAIL_NAME
= Config
.fileToTestSendByEmailName
;
42 private Boolean fileHasBeenUploadedFromGmail
= false
;
43 private Boolean fileHasBeenUploaded
= false
;
45 @Rule public TestName name
= new TestName();
49 public void setUp() throws Exception
{
51 driver
=common
.setUpCommonDriver();
55 @Category(NoIgnoreTestCategory
.class)
56 public void testUploadFile () throws Exception
{
58 FileListView fileListView
= Actions
.login(Config
.URL
, Config
.user
,Config
.password
, Config
.isTrusted
, driver
);
59 common
.assertIsInFileListView();
61 //check if the file already exists and if true, delete it
62 Actions
.deleteElement(FILE_NAME
, fileListView
, driver
);
64 FileListView fileListViewAfterUploadFile
= Actions
.uploadFile(FILE_NAME
, fileListView
);
66 fileListViewAfterUploadFile
.scrollTillFindElement(FILE_NAME
);
67 assertTrue(fileListViewAfterUploadFile
.getFileElement().isDisplayed());
68 Common
.waitTillElementIsNotPresent(fileListViewAfterUploadFile
.getProgressCircular(), 1000);
69 common
.wait
.until(ExpectedConditions
.visibilityOf(fileListViewAfterUploadFile
.getFileElementLayout().findElement(By
.id(FileListView
.getLocalFileIndicator()))));
70 assertTrue(fileListViewAfterUploadFile
.getFileElementLayout().findElement(By
.id(FileListView
.getLocalFileIndicator())).isDisplayed());
71 fileListView
= new FileListView(driver
);
72 fileListView
.scrollTillFindElement(FILE_NAME
);
73 assertTrue(fileHasBeenUploaded
= fileListView
.getFileElement().isDisplayed());
77 @Category(UnfinishedTestCategory
.class)
78 public void testUploadFromGmail () throws Exception
{
79 FileListView fileListView
= Actions
.login(Config
.URL
, Config
.user
,Config
.password
, Config
.isTrusted
, driver
);
80 driver
.startActivity("com.google.android.gm", ".ConversationListActivityGmail");
81 GmailEmailListView gmailEmailListView
= new GmailEmailListView(driver
);
83 GmailEmailView gmailEmailView
= gmailEmailListView
.clickOnEmail();
84 ImageView imageView
= gmailEmailView
.clickOnfileButton();
85 imageView
.clickOnOptionsButton();
86 imageView
.clickOnShareButton();
87 imageView
.clickOnOwnCloudButton();
88 //justonce button do not appear always
90 imageView
.clickOnJustOnceButton();
91 }catch (NoSuchElementException e
) {
93 UploadView uploadView
= new UploadView(driver
);
94 uploadView
.clickOUploadButton();
95 driver
.sendKeyEvent(android
.view
.KeyEvent
.KEYCODE_HOME
);
96 driver
.startActivity("com.owncloud.android", ".ui.activity.FileDisplayActivity");
97 common
.wait
.until(ExpectedConditions
.visibilityOfAllElementsLocatedBy(By
.name(FILE_GMAIL_NAME
)));
98 assertEquals(Config
.fileToTestSendByEmailName
, driver
.findElementByName(FILE_GMAIL_NAME
).getText());
99 fileListView
= new FileListView(driver
);
100 fileListView
.scrollTillFindElement(FILE_GMAIL_NAME
);
101 assertTrue(fileHasBeenUploadedFromGmail
= fileListView
.getFileElement().isDisplayed());
102 //TODO. correct assert if fileListView is shown in grid mode
107 @Category({FailingTestCategory
.class})
108 public void testKeepFileUpToDate () throws Exception
{
110 FileListView fileListView
= Actions
.login(Config
.URL
, Config
.user
,Config
.password
, Config
.isTrusted
, driver
);
111 common
.assertIsInFileListView();
113 Common
.waitTillElementIsNotPresent(fileListView
.getProgressCircular(), 1000);
115 FileListView fileListViewAfterUploadFile
= Actions
.uploadFile(FILE_NAME
, fileListView
);
116 fileListViewAfterUploadFile
.scrollTillFindElement(FILE_NAME
);
117 assertTrue(fileListViewAfterUploadFile
.getFileElement().isDisplayed());
119 ElementMenuOptions menuOptions
= fileListViewAfterUploadFile
.longPressOnElement(FILE_NAME
);
120 FileDetailsView fileDetailsView
= menuOptions
.clickOnDetails();
121 fileDetailsView
.checkKeepFileUpToDateCheckbox();
123 driver
.sendKeyEvent(android
.view
.KeyEvent
.KEYCODE_BACK
);
124 assertTrue(common
.isElementPresent(fileListViewAfterUploadFile
.getFileElementLayout(), MobileBy
.id(FileListView
.getFavoriteFileIndicator())));
125 assertTrue(fileListViewAfterUploadFile
.getFileElementLayout().findElement(By
.id(FileListView
.getFavoriteFileIndicator())).isDisplayed());
130 public void tearDown() throws Exception
{
131 common
.takeScreenShotOnFailed(name
.getMethodName());
132 FileListView fileListView
= new FileListView(driver
);
133 if (fileHasBeenUploadedFromGmail
) {
134 Actions
.deleteElement(FILE_GMAIL_NAME
,fileListView
, driver
);
136 if(fileHasBeenUploaded
){
137 Actions
.deleteElement(FILE_NAME
,fileListView
, driver
);
140 driver
.removeApp("com.owncloud.android");