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();
77 @Category({NoIgnoreTestCategory
.class, SmokeTestCategory
.class})
78 public void test3MultiAccountRotate () throws Exception
{
79 driver
.rotate(ScreenOrientation
.LANDSCAPE
);
80 FileListView fileListView
= Actions
.login(Config
.URL
, Config
.user
,
81 Config
.password
, Config
.isTrusted
, driver
);
82 common
.assertIsInFileListView();
84 driver
.rotate(ScreenOrientation
.PORTRAIT
);
85 MenuList menu
= fileListView
.clickOnMenuButton();
86 SettingsView settingsView
= menu
.clickOnSettingsButton();
88 settingsView
.tapOnAddAccount(1, 1000);
89 fileListView
= Actions
.login(Config
.URL2
, Config
.user2
,
90 Config
.password2
, Config
.isTrusted2
, driver
);
91 common
.assertIsInSettingsView();
95 @Category({NoIgnoreTestCategory
.class})
96 public void test4ExistingAccountRotate () throws Exception
{
97 driver
.rotate(ScreenOrientation
.PORTRAIT
);
98 FileListView fileListView
= Actions
.login(Config
.URL
, Config
.user
,
99 Config
.password
, Config
.isTrusted
, driver
);
100 common
.assertIsInFileListView();
102 driver
.rotate(ScreenOrientation
.LANDSCAPE
);
103 MenuList menu
= fileListView
.clickOnMenuButton();
104 SettingsView settingsView
= menu
.clickOnSettingsButton();
105 settingsView
.tapOnAddAccount(1, 1000);
107 LoginForm loginForm
= new LoginForm(driver
);
108 fileListView
= Actions
.login(Config
.URL
, Config
.user
,Config
.password
,
109 Config
.isTrusted
, driver
);
110 assertTrue(common
.waitForTextPresent("An account for the same user and"
111 + " server already exists in the device",
112 loginForm
.getAuthStatusText()));
116 @Category({NoIgnoreTestCategory
.class})
117 public void test5ChangePasswordWrong () throws Exception
{
118 driver
.rotate(ScreenOrientation
.PORTRAIT
);
119 FileListView fileListView
= Actions
.login(Config
.URL
, Config
.user
,
120 Config
.password
, Config
.isTrusted
, driver
);
121 common
.assertIsInFileListView();
122 MenuList menu
= fileListView
.clickOnMenuButton();
123 SettingsView settingsView
= menu
.clickOnSettingsButton();
124 settingsView
.tapOnAccountElement(1, 1000);
125 LoginForm changePasswordForm
= settingsView
126 .clickOnChangePasswordElement();
127 changePasswordForm
.typePassword("WrongPassword");
128 changePasswordForm
.clickOnConnectButton();
129 assertTrue(common
.waitForTextPresent("Wrong username or password",
130 changePasswordForm
.getAuthStatusText()));
135 public void tearDown() throws Exception
{
136 common
.takeScreenShotOnFailed(name
.getMethodName());
137 driver
.removeApp("com.owncloud.android");