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
);
75 GmailEmailView gmailEmailView
= gmailEmailListView
.clickOnEmail();
76 ImageView imageView
= gmailEmailView
.clickOnfileButton();
77 imageView
.clickOnOptionsButton();
78 imageView
.clickOnShareButton();
79 imageView
.clickOnOwnCloudButton();
80 imageView
.clickOnJustOnceButton();
81 UploadView uploadView
= new UploadView(driver
);
82 uploadView
.clickOUploadButton();
83 driver
.startActivity("com.owncloud.android", ".ui.activity.FileDisplayActivity");
84 common
.wait
.until(ExpectedConditions
.visibilityOfAllElementsLocatedBy(By
.name(Config
.fileToTestSendByEmailName
)));
85 assertEquals(Config
.fileToTestSendByEmailName
, driver
.findElementByName(Config
.fileToTestSendByEmailName
).getText());
90 @Category({IgnoreTestCategory
.class, FailingTestCategory
.class})
91 public void testKeepFileUpToDate () throws Exception
{
93 FileListView fileListView
= Actions
.login(Config
.URL
, Config
.user
,Config
.password
, Config
.isTrusted
, driver
);
94 common
.assertIsInFileListView();
96 Common
.waitTillElementIsNotPresent(fileListView
.getProgressCircular(), 1000);
98 FileListView fileListViewAfterUploadFile
= Actions
.uploadFile(FILE_NAME
, fileListView
);
99 fileListViewAfterUploadFile
.scrollTillFindElement(FILE_NAME
);
100 assertTrue(fileListViewAfterUploadFile
.getFileElement().isDisplayed());
102 ElementMenuOptions menuOptions
= fileListViewAfterUploadFile
.longPressOnElement(FILE_NAME
);
103 FileDetailsView fileDetailsView
= menuOptions
.clickOnDetails();
104 fileDetailsView
.checkKeepFileUpToDateCheckbox();
106 driver
.sendKeyEvent(android
.view
.KeyEvent
.KEYCODE_BACK
);
107 //assertTrue(common.isElementPresent(fileListViewAfterUploadFile.getFileElementLayout(), MobileBy.id(FileListView.getFavoriteFileIndicator())));
108 assertTrue(fileListViewAfterUploadFile
.getFileElementLayout().findElement(By
.id(FileListView
.getFavoriteFileIndicator())).isDisplayed());
114 public void tearDown() throws Exception
{
115 common
.takeScreenShotOnFailed(name
.getMethodName());
116 FileListView fileListView
= new FileListView(driver
);
117 Actions
.deleteElement(FILE_NAME
,fileListView
, driver
);
118 driver
.removeApp("com.owncloud.android");