1 package androidtest
.tests
;
3 import static org
.junit
.Assert
.*;
4 import io
.appium
.java_client
.android
.AndroidDriver
;
5 import org
.junit
.After
;
6 import org
.junit
.Before
;
8 import org
.junit
.experimental
.categories
.Category
;
9 import org
.junit
.rules
.TestName
;
10 import org
.junit
.runners
.MethodSorters
;
11 import org
.junit
.FixMethodOrder
;
12 import org
.junit
.Test
;
13 import org
.openqa
.selenium
.ScreenOrientation
;
14 import androidtest
.actions
.Actions
;
15 import androidtest
.groups
.*;
16 import androidtest
.models
.LoginForm
;
17 import androidtest
.models
.MainView
;
18 import androidtest
.models
.MenuList
;
19 import androidtest
.models
.SettingsView
;
21 @FixMethodOrder(MethodSorters
.NAME_ASCENDING
)
22 public class LoginTestSuite
{
26 @Rule public TestName name
= new TestName();
29 public void setUp() throws Exception
{
31 driver
=common
.setUpCommonDriver();
35 @Category({NoIgnoreTestCategory
.class})
36 public void test1LoginPortrait () throws Exception
{
37 driver
.rotate(ScreenOrientation
.PORTRAIT
);
39 MainView mainView
= Actions
.login(Config
.URL
, Config
.user
,Config
.password
, Config
.isTrusted
, driver
);
40 common
.assertIsInMainView();
44 @Category({NoIgnoreTestCategory
.class})
45 public void test2LoginLandscape () throws Exception
{
46 driver
.rotate(ScreenOrientation
.LANDSCAPE
);
47 MainView mainView
= Actions
.login(Config
.URL
, Config
.user
,Config
.password
, Config
.isTrusted
, driver
);
48 common
.assertIsInMainView();
53 @Category({NoIgnoreTestCategory
.class, SmokeTestCategory
.class})
54 public void test3MultiAccountRotate () throws Exception
{
55 driver
.rotate(ScreenOrientation
.LANDSCAPE
);
56 MainView mainView
= Actions
.login(Config
.URL
, Config
.user
,Config
.password
, Config
.isTrusted
, driver
);
57 common
.assertIsInMainView();
59 driver
.rotate(ScreenOrientation
.PORTRAIT
);
60 MenuList menu
= mainView
.clickOnMenuButton();
61 SettingsView settingsView
= menu
.clickOnSettingsButton();
63 settingsView
.tapOnAddAccount(1, 1000);
64 mainView
= Actions
.login(Config
.URL2
, Config
.user2
,Config
.password2
, Config
.isTrusted2
, driver
);
65 common
.assertIsInSettingsView();
69 @Category({NoIgnoreTestCategory
.class})
70 public void test4ExistingAccountRotate () throws Exception
{
71 driver
.rotate(ScreenOrientation
.PORTRAIT
);
72 MainView mainView
= Actions
.login(Config
.URL
, Config
.user
,Config
.password
, Config
.isTrusted
, driver
);
73 common
.assertIsInMainView();
75 driver
.rotate(ScreenOrientation
.LANDSCAPE
);
76 MenuList menu
= mainView
.clickOnMenuButton();
77 SettingsView settingsView
= menu
.clickOnSettingsButton();
78 settingsView
.tapOnAddAccount(1, 1000);
80 LoginForm loginForm
= new LoginForm(driver
);
81 mainView
= Actions
.login(Config
.URL
, Config
.user
,Config
.password
, Config
.isTrusted
, driver
);
82 assertTrue(common
.waitForTextPresent("An account for the same user and server already exists in the device", loginForm
.getAuthStatusText()));
86 @Category({NoIgnoreTestCategory
.class})
87 public void test5ChangePasswordWrong () throws Exception
{
88 driver
.rotate(ScreenOrientation
.PORTRAIT
);
89 MainView mainView
= Actions
.login(Config
.URL
, Config
.user
,Config
.password
, Config
.isTrusted
, driver
);
90 common
.assertIsInMainView();
91 MenuList menu
= mainView
.clickOnMenuButton();
92 SettingsView settingsView
= menu
.clickOnSettingsButton();
93 settingsView
.tapOnAccountElement(1, 1000);
94 LoginForm changePasswordForm
= settingsView
.clickOnChangePasswordElement();
95 changePasswordForm
.typePassword("WrongPassword");
96 changePasswordForm
.clickOnConnectButton();
97 assertTrue(common
.waitForTextPresent("Wrong username or password", changePasswordForm
.getAuthStatusText()));
102 public void tearDown() throws Exception
{
103 common
.takeScreenShotOnFailed(name
.getMethodName());
104 driver
.removeApp("com.owncloud.android");