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
;
26 import org
.junit
.After
;
27 import org
.junit
.Before
;
28 import org
.junit
.Rule
;
29 import org
.junit
.experimental
.categories
.Category
;
30 import org
.junit
.rules
.TestName
;
31 import org
.junit
.runners
.MethodSorters
;
32 import org
.junit
.FixMethodOrder
;
33 import org
.junit
.Test
;
34 import org
.openqa
.selenium
.ScreenOrientation
;
36 import com
.owncloud
.android
.test
.ui
.actions
.Actions
;
37 import com
.owncloud
.android
.test
.ui
.groups
.*;
38 import com
.owncloud
.android
.test
.ui
.models
.LoginForm
;
39 import com
.owncloud
.android
.test
.ui
.models
.FileListView
;
40 import com
.owncloud
.android
.test
.ui
.models
.MenuList
;
41 import com
.owncloud
.android
.test
.ui
.models
.SettingsView
;
43 @FixMethodOrder(MethodSorters
.NAME_ASCENDING
)
44 public class LoginTestSuite
{
48 @Rule public TestName name
= new TestName();
51 public void setUp() throws Exception
{
53 driver
=common
.setUpCommonDriver();
57 @Category({NoIgnoreTestCategory
.class})
58 public void test1LoginPortrait () throws Exception
{
59 driver
.rotate(ScreenOrientation
.PORTRAIT
);
61 Actions
.login(Config
.URL
, Config
.user
,
62 Config
.password
, Config
.isTrusted
, driver
);
63 common
.assertIsInFileListView();
67 @Category({NoIgnoreTestCategory
.class})
68 public void test2LoginLandscape () throws Exception
{
69 driver
.rotate(ScreenOrientation
.LANDSCAPE
);
70 Actions
.login(Config
.URL
, Config
.user
,
71 Config
.password
, Config
.isTrusted
, driver
);
72 common
.assertIsInFileListView();
76 @Category({NoIgnoreTestCategory
.class})
77 public void testLoginAndShowFiles () throws Exception
{
78 driver
.rotate(ScreenOrientation
.PORTRAIT
);
80 FileListView fileListView
= Actions
.login(Config
.URL
, Config
.user
,
81 Config
.password
, Config
.isTrusted
, driver
);
82 common
.assertIsInFileListView();
84 fileListView
.scrollTillFindElement(Config
.fileWhichIsInTheServer1
);
85 assertTrue(fileListView
.getFileElement().isDisplayed());
91 @Category({NoIgnoreTestCategory
.class, SmokeTestCategory
.class})
92 public void test3MultiAccountRotate () throws Exception
{
93 driver
.rotate(ScreenOrientation
.LANDSCAPE
);
94 FileListView fileListView
= Actions
.login(Config
.URL
, Config
.user
,
95 Config
.password
, Config
.isTrusted
, driver
);
96 common
.assertIsInFileListView();
98 driver
.rotate(ScreenOrientation
.PORTRAIT
);
99 MenuList menu
= fileListView
.clickOnMenuButton();
100 SettingsView settingsView
= menu
.clickOnSettingsButton();
102 settingsView
.tapOnAddAccount(1, 1000);
103 fileListView
= Actions
.login(Config
.URL2
, Config
.user2
,
104 Config
.password2
, Config
.isTrusted2
, driver
);
105 common
.assertIsInSettingsView();
109 @Category({NoIgnoreTestCategory
.class, SmokeTestCategory
.class})
110 public void testMultiAccountAndShowFiles () throws Exception
{
111 driver
.rotate(ScreenOrientation
.LANDSCAPE
);
112 FileListView fileListView
= Actions
.login(Config
.URL
, Config
.user
,
113 Config
.password
, Config
.isTrusted
, driver
);
114 common
.assertIsInFileListView();
115 fileListView
.scrollTillFindElement(Config
.fileWhichIsInTheServer1
);
116 assertTrue(fileListView
.getFileElement().isDisplayed());
118 driver
.rotate(ScreenOrientation
.PORTRAIT
);
119 MenuList menu
= fileListView
.clickOnMenuButton();
120 SettingsView settingsView
= menu
.clickOnSettingsButton();
122 settingsView
.tapOnAddAccount(1, 1000);
123 fileListView
= Actions
.login(Config
.URL2
, Config
.user2
,
124 Config
.password2
, Config
.isTrusted2
, driver
);
125 common
.assertIsInSettingsView();
126 settingsView
.tapOnAccountElement(2,1, 100);
127 common
.assertIsInFileListView();
129 fileListView
.scrollTillFindElement(Config
.fileWhichIsInTheServer2
);
130 assertTrue(fileListView
.getFileElement().isDisplayed());
134 @Category({NoIgnoreTestCategory
.class})
135 public void test4ExistingAccountRotate () throws Exception
{
136 driver
.rotate(ScreenOrientation
.PORTRAIT
);
137 FileListView fileListView
= Actions
.login(Config
.URL
, Config
.user
,
138 Config
.password
, Config
.isTrusted
, driver
);
139 common
.assertIsInFileListView();
141 driver
.rotate(ScreenOrientation
.LANDSCAPE
);
142 MenuList menu
= fileListView
.clickOnMenuButton();
143 SettingsView settingsView
= menu
.clickOnSettingsButton();
144 settingsView
.tapOnAddAccount(1, 1000);
146 LoginForm loginForm
= new LoginForm(driver
);
147 fileListView
= Actions
.login(Config
.URL
, Config
.user
,Config
.password
,
148 Config
.isTrusted
, driver
);
149 assertTrue(common
.waitForTextPresent("An account for the same user and"
150 + " server already exists in the device",
151 loginForm
.getAuthStatusText()));
155 @Category({NoIgnoreTestCategory
.class})
156 public void test5ChangePasswordWrong () throws Exception
{
157 driver
.rotate(ScreenOrientation
.PORTRAIT
);
158 FileListView fileListView
= Actions
.login(Config
.URL
, Config
.user
,
159 Config
.password
, Config
.isTrusted
, driver
);
160 common
.assertIsInFileListView();
161 MenuList menu
= fileListView
.clickOnMenuButton();
162 SettingsView settingsView
= menu
.clickOnSettingsButton();
163 settingsView
.tapOnAccountElement(1,1, 1000);
164 LoginForm changePasswordForm
= settingsView
165 .clickOnChangePasswordElement();
166 changePasswordForm
.typePassword("WrongPassword");
167 changePasswordForm
.clickOnConnectButton();
168 assertTrue(common
.waitForTextPresent("Wrong username or password",
169 changePasswordForm
.getAuthStatusText()));
174 public void tearDown() throws Exception
{
175 common
.takeScreenShotOnFailed(name
.getMethodName());
176 driver
.removeApp("com.owncloud.android");