1 package androidtest
.tests
;
3 import org
.junit
.After
;
4 import org
.junit
.Before
;
5 import org
.junit
.runners
.MethodSorters
;
6 import org
.junit
.FixMethodOrder
;
8 import org
.openqa
.selenium
.ScreenOrientation
;
9 import androidtest
.actions
.Actions
;
10 import androidtest
.models
.LoginForm
;
11 import androidtest
.models
.MainView
;
12 import androidtest
.models
.MenuList
;
13 import androidtest
.models
.SettingsView
;
15 @FixMethodOrder(MethodSorters
.NAME_ASCENDING
)
16 public class LoginTestSuite
extends Common
{
19 public void setUp() throws Exception
{
24 public void test1LoginPortrait () throws Exception
{
25 driver
.rotate(ScreenOrientation
.PORTRAIT
);
27 MainView mainView
= Actions
.login(Config
.URL
, Config
.user
,Config
.password
, Config
.isTrusted
, driver
);
28 assertTrue(waitForTextPresent("ownCloud", mainView
.getTitleTextElement()));
32 public void test2LoginLandscape () throws Exception
{
33 driver
.rotate(ScreenOrientation
.LANDSCAPE
);
34 MainView mainView
= Actions
.login(Config
.URL
, Config
.user
,Config
.password
, Config
.isTrusted
, driver
);
35 assertTrue(waitForTextPresent("ownCloud", mainView
.getTitleTextElement()));
36 //TO DO. detect in which view is. it can be files view or settings view
41 public void test3MultiAccountRotate () throws Exception
{
42 driver
.rotate(ScreenOrientation
.LANDSCAPE
);
43 MainView mainView
= Actions
.login(Config
.URL
, Config
.user
,Config
.password
, Config
.isTrusted
, driver
);
44 assertTrue(waitForTextPresent("ownCloud", mainView
.getTitleTextElement()));
46 driver
.rotate(ScreenOrientation
.PORTRAIT
);
47 MenuList menu
= mainView
.clickOnMenuButton();
48 SettingsView settingsView
= menu
.clickOnSettingsButton();
49 settingsView
.tapOnAddAccount(1, 1000);
50 mainView
= Actions
.login(Config
.URL2
, Config
.user2
,Config
.password2
, Config
.isTrusted2
, driver
);
52 assertTrue(waitForTextPresent("Settings", mainView
.getTitleTextElement()));
53 //TO DO. detect in which view is. it can be files view or settings view
54 //Actions.deleteAccount(mainView);
55 //TO DO. Delete the second user
59 public void test4ExistingAccountRotate () throws Exception
{
60 driver
.rotate(ScreenOrientation
.PORTRAIT
);
61 MainView mainView
= Actions
.login(Config
.URL
, Config
.user
,Config
.password
, Config
.isTrusted
, driver
);
62 assertTrue(waitForTextPresent("ownCloud", mainView
.getTitleTextElement()));
64 driver
.rotate(ScreenOrientation
.LANDSCAPE
);
65 MenuList menu
= mainView
.clickOnMenuButton();
66 SettingsView settingsView
= menu
.clickOnSettingsButton();
67 settingsView
.tapOnAddAccount(1, 1000);
69 LoginForm loginForm
= new LoginForm(driver
);
70 mainView
= Actions
.login(Config
.URL
, Config
.user
,Config
.password
, Config
.isTrusted
, driver
);
71 assertTrue(waitForTextPresent("An account for the same user and server already exists in the device", loginForm
.getAuthStatusText()));
75 public void test5ChangePasswordWrong () throws Exception
{
77 MainView mainView
= Actions
.login(Config
.URL
, Config
.user
,Config
.password
, Config
.isTrusted
, driver
);
78 assertTrue(waitForTextPresent("ownCloud", mainView
.getTitleTextElement()));
79 MenuList menu
= mainView
.clickOnMenuButton();
80 SettingsView settingsView
= menu
.clickOnSettingsButton();
81 settingsView
.tapOnAccountElement(1, 1000);
82 LoginForm changePasswordForm
= settingsView
.clickOnChangePasswordElement();
83 changePasswordForm
.typePassword("WrongPassword");
84 changePasswordForm
.clickOnConnectButton();
85 assertTrue(waitForTextPresent("Wrong username or password", changePasswordForm
.getAuthStatusText()));
90 public void tearDown() throws Exception
{
91 takeScreenShotOnFailed(getName());
92 driver
.removeApp("com.owncloud.android");