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
.support
.ui
.ExpectedConditions
;
19 import com
.owncloud
.android
.test
.ui
.actions
.Actions
;
20 import com
.owncloud
.android
.test
.ui
.groups
.FailingTestCategory
;
21 import com
.owncloud
.android
.test
.ui
.groups
.IgnoreTestCategory
;
22 import com
.owncloud
.android
.test
.ui
.groups
.NoIgnoreTestCategory
;
23 import com
.owncloud
.android
.test
.ui
.models
.FileDetailsView
;
24 import com
.owncloud
.android
.test
.ui
.models
.ElementMenuOptions
;
25 import com
.owncloud
.android
.test
.ui
.models
.GmailEmailListView
;
26 import com
.owncloud
.android
.test
.ui
.models
.GmailEmailView
;
27 import com
.owncloud
.android
.test
.ui
.models
.ImageView
;
28 import com
.owncloud
.android
.test
.ui
.models
.FileListView
;
29 import com
.owncloud
.android
.test
.ui
.models
.UploadView
;
32 @FixMethodOrder(MethodSorters
.NAME_ASCENDING
)
33 @Category({NoIgnoreTestCategory
.class})
34 public class UploadTestSuite
{
38 String FILE_NAME
= Config
.fileToTestName
;
40 @Rule public TestName name
= new TestName();
44 public void setUp() throws Exception
{
46 driver
=common
.setUpCommonDriver();
50 @Category(NoIgnoreTestCategory
.class)
51 public void testUploadFile () throws Exception
{
53 FileListView fileListView
= Actions
.login(Config
.URL
, Config
.user
,Config
.password
, Config
.isTrusted
, driver
);
54 common
.assertIsInFileListView();
56 //check if the file already exists and if true, delete it
57 Actions
.deleteElement(FILE_NAME
, fileListView
, driver
);
59 FileListView fileListViewAfterUploadFile
= Actions
.uploadFile(FILE_NAME
, fileListView
);
61 fileListViewAfterUploadFile
.scrollTillFindElement(FILE_NAME
);
62 assertTrue(fileListViewAfterUploadFile
.getFileElement().isDisplayed());
63 Common
.waitTillElementIsNotPresent(fileListViewAfterUploadFile
.getProgressCircular(), 1000);
64 common
.wait
.until(ExpectedConditions
.visibilityOf(fileListViewAfterUploadFile
.getFileElementLayout().findElement(By
.id(FileListView
.getLocalFileIndicator()))));
65 assertTrue(fileListViewAfterUploadFile
.getFileElementLayout().findElement(By
.id(FileListView
.getLocalFileIndicator())).isDisplayed());
70 @Category(IgnoreTestCategory
.class)
71 public void testUploadFromGmail () throws Exception
{
72 FileListView fileListView
= Actions
.login(Config
.URL
, Config
.user
,Config
.password
, Config
.isTrusted
, driver
);
73 driver
.startActivity("com.google.android.gm", ".ConversationListActivityGmail");
74 GmailEmailListView gmailEmailListView
= new GmailEmailListView(driver
);
76 GmailEmailView gmailEmailView
= gmailEmailListView
.clickOnEmail();
77 ImageView imageView
= gmailEmailView
.clickOnfileButton();
78 imageView
.clickOnOptionsButton();
79 imageView
.clickOnShareButton();
80 imageView
.clickOnOwnCloudButton();
81 imageView
.clickOnJustOnceButton();
82 UploadView uploadView
= new UploadView(driver
);
83 uploadView
.clickOUploadButton();
84 driver
.startActivity("com.owncloud.android", ".ui.activity.FileDisplayActivity");
85 common
.wait
.until(ExpectedConditions
.visibilityOfAllElementsLocatedBy(By
.name(Config
.fileToTestSendByEmailName
)));
86 assertEquals(Config
.fileToTestSendByEmailName
, driver
.findElementByName(Config
.fileToTestSendByEmailName
).getText());
91 @Category({IgnoreTestCategory
.class, FailingTestCategory
.class})
92 public void testKeepFileUpToDate () throws Exception
{
94 FileListView fileListView
= Actions
.login(Config
.URL
, Config
.user
,Config
.password
, Config
.isTrusted
, driver
);
95 common
.assertIsInFileListView();
97 Common
.waitTillElementIsNotPresent(fileListView
.getProgressCircular(), 1000);
99 FileListView fileListViewAfterUploadFile
= Actions
.uploadFile(FILE_NAME
, fileListView
);
100 fileListViewAfterUploadFile
.scrollTillFindElement(FILE_NAME
);
101 assertTrue(fileListViewAfterUploadFile
.getFileElement().isDisplayed());
103 ElementMenuOptions menuOptions
= fileListViewAfterUploadFile
.longPressOnElement(FILE_NAME
);
104 FileDetailsView fileDetailsView
= menuOptions
.clickOnDetails();
105 fileDetailsView
.checkKeepFileUpToDateCheckbox();
107 driver
.sendKeyEvent(android
.view
.KeyEvent
.KEYCODE_BACK
);
108 //assertTrue(common.isElementPresent(fileListViewAfterUploadFile.getFileElementLayout(), MobileBy.id(FileListView.getFavoriteFileIndicator())));
109 assertTrue(fileListViewAfterUploadFile
.getFileElementLayout().findElement(By
.id(FileListView
.getFavoriteFileIndicator())).isDisplayed());
115 public void tearDown() throws Exception
{
116 common
.takeScreenShotOnFailed(name
.getMethodName());
117 FileListView fileListView
= new FileListView(driver
);
118 Actions
.deleteElement(FILE_NAME
,fileListView
, driver
);
119 driver
.removeApp("com.owncloud.android");