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
.testSuites
;
23 import static org
.junit
.Assert
.*;
24 import io
.appium
.java_client
.android
.AndroidDriver
;
25 import io
.appium
.java_client
.android
.AndroidElement
;
26 import org
.junit
.After
;
27 import org
.junit
.Before
;
28 import org
.junit
.Rule
;
29 import org
.junit
.Test
;
30 import org
.junit
.experimental
.categories
.Category
;
31 import org
.junit
.rules
.TestName
;
32 import com
.owncloud
.android
.test
.ui
.actions
.Actions
;
33 import com
.owncloud
.android
.test
.ui
.groups
.IgnoreTestCategory
;
34 import com
.owncloud
.android
.test
.ui
.groups
.NoIgnoreTestCategory
;
35 import com
.owncloud
.android
.test
.ui
.groups
.SmokeTestCategory
;
36 import com
.owncloud
.android
.test
.ui
.models
.FileListView
;;
38 public class ShareLinkFileTestSuite
{
42 private final String FILE_NAME
= Config
.fileToTestName
;
43 private Boolean fileHasBeenCreated
= false
;
45 @Rule public TestName name
= new TestName();
48 public void setUp() throws Exception
{
50 driver
=common
.setUpCommonDriver();
54 @Category({NoIgnoreTestCategory
.class})
55 public void testShareLinkFileByGmail () throws Exception
{
56 AndroidElement sharedElementIndicator
;
57 FileListView fileListView
= Actions
.login(Config
.URL
, Config
.user
,
58 Config
.password
, Config
.isTrusted
, driver
);
59 common
.assertIsInFileListView();
61 //TODO. if the file already exists, do not upload
62 FileListView fileListViewAfterUploadFile
= Actions
63 .uploadFile(FILE_NAME
, fileListView
);
65 fileListViewAfterUploadFile
.scrollTillFindElement(FILE_NAME
);
66 assertTrue(fileHasBeenCreated
= fileListViewAfterUploadFile
67 .getFileElement().isDisplayed());
69 sharedElementIndicator
= Actions
.shareLinkElementByGmail(FILE_NAME
,
70 fileListViewAfterUploadFile
,driver
,common
);
71 assertTrue(sharedElementIndicator
.isDisplayed());
75 @Category({NoIgnoreTestCategory
.class, SmokeTestCategory
.class})
76 public void testShareLinkFileByCopyLink () throws Exception
{
77 AndroidElement sharedElementIndicator
;
78 FileListView fileListView
= Actions
.login(Config
.URL
, Config
.user
,
79 Config
.password
, Config
.isTrusted
, driver
);
80 common
.assertIsInFileListView();
82 //TODO. if the file already exists, do not upload
83 FileListView fileListViewAfterUploadFile
= Actions
84 .uploadFile(FILE_NAME
, fileListView
);
86 fileListViewAfterUploadFile
.scrollTillFindElement(FILE_NAME
);
87 assertTrue(fileHasBeenCreated
= fileListViewAfterUploadFile
88 .getFileElement().isDisplayed());
90 sharedElementIndicator
= Actions
.shareLinkElementByCopyLink(FILE_NAME
,
91 fileListViewAfterUploadFile
,driver
,common
);
92 assertTrue(sharedElementIndicator
.isDisplayed());
96 @Category({IgnoreTestCategory
.class, SmokeTestCategory
.class})
97 public void testUnshareLinkFile () throws Exception
{
98 AndroidElement sharedElementIndicator
;
99 FileListView fileListView
= Actions
.login(Config
.URL
, Config
.user
,
100 Config
.password
, Config
.isTrusted
, driver
);
101 common
.assertIsInFileListView();
103 //TODO. if the file already exists, do not upload
104 FileListView fileListViewAfterUploadFile
= Actions
105 .uploadFile(FILE_NAME
, fileListView
);
107 fileListViewAfterUploadFile
.scrollTillFindElement(FILE_NAME
);
108 assertTrue(fileHasBeenCreated
= fileListViewAfterUploadFile
109 .getFileElement().isDisplayed());
111 sharedElementIndicator
= Actions
.shareLinkElementByCopyLink(FILE_NAME
,
112 fileListViewAfterUploadFile
,driver
,common
);
113 assertTrue(sharedElementIndicator
.isDisplayed());
114 Actions
.unshareLinkElement(FILE_NAME
,
115 fileListViewAfterUploadFile
,driver
,common
);
116 assertFalse(sharedElementIndicator
.isDisplayed());
121 public void tearDown() throws Exception
{
122 common
.takeScreenShotOnFailed(name
.getMethodName());
123 if (fileHasBeenCreated
) {
124 FileListView fileListView
= new FileListView(driver
);
125 Actions
.deleteElement(FILE_NAME
,fileListView
, driver
);
127 driver
.removeApp("com.owncloud.android");