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
;
11 import androidtest
.actions
.Actions
;
12 import androidtest
.models
.LoginForm
;
13 import androidtest
.models
.MainView
;
14 import androidtest
.models
.SettingsView
;
16 @FixMethodOrder(MethodSorters
.NAME_ASCENDING
)
17 public class LoginTestSuite
extends CommonTest
{
20 public void setUp() throws Exception
{
25 public void test1LoginPortrait () throws Exception
{
27 System
.out
.println("Hello" + Config
.server
);
28 String testName
= "loginPortrait";
29 driver
.rotate(ScreenOrientation
.PORTRAIT
);
31 MainView mainView
= login(Config
.URL
, Config
.user
,Config
.password
);
32 assertTrue(waitForTextPresent("ownCloud", mainView
.getTitleTextElement()));
33 //TO DO. detect in which view is. it can be files view or settings view
34 /*if(mainView.getTitleTextElement().equals("ownCloud") || mainView.getTitleTextElement().equals("Settings")){
35 if(mainView.getTitleTextElement().getText().equals("ownCloud")){
36 assertTrue(waitForTextPresent("ownCloud", mainView.getTitleTextElement()));
38 assertTrue(waitForTextPresent("Settings", mainView.getTitleTextElement()));
42 Actions
.deleteAccount(mainView
);
46 public void test2LoginLandscape () throws Exception
{
48 String testName
= "loginLandscape";
49 driver
.rotate(ScreenOrientation
.LANDSCAPE
);
50 MainView mainView
= login(Config
.URL
, Config
.user
,Config
.password
);
51 assertTrue(waitForTextPresent("ownCloud", mainView
.getTitleTextElement()));
52 //TO DO. detect in which view is. it can be files view or settings view
53 Actions
.deleteAccount(mainView
);
58 public void test3MultiAccountRotate () throws Exception
{
60 String testName
= "MultiAccountRotate";
61 driver
.rotate(ScreenOrientation
.LANDSCAPE
);
62 MainView mainView
= login(Config
.URL
, Config
.user
,Config
.password
);
63 assertTrue(waitForTextPresent("ownCloud", mainView
.getTitleTextElement()));
65 driver
.rotate(ScreenOrientation
.PORTRAIT
);
66 mainView
.clickOnMenuButton();
67 SettingsView settingsView
= mainView
.clickOnSettingsButton();
68 settingsView
.tapOnAddAccount(1, 1000);
69 mainView
= login(Config
.URL
, Config
.user2
,Config
.password2
);
71 assertTrue(waitForTextPresent("Settings", mainView
.getTitleTextElement()));
72 //TO DO. detect in which view is. it can be files view or settings view
73 //Actions.deleteAccount(mainView);
74 Actions
.deleteAccount(settingsView
);
75 //TO DO. Delete the second user
79 public void test4ExistingAccountRotate () throws Exception
{
81 String testName
= "ExistingAccountRotate";
82 driver
.rotate(ScreenOrientation
.PORTRAIT
);
83 MainView mainView
= login(Config
.URL
, Config
.user
,Config
.password
);
84 assertTrue(waitForTextPresent("ownCloud", mainView
.getTitleTextElement()));
86 driver
.rotate(ScreenOrientation
.LANDSCAPE
);
87 mainView
.clickOnMenuButton();
88 SettingsView settingsView
= mainView
.clickOnSettingsButton();
89 settingsView
.tapOnAddAccount(1, 1000);
90 LoginForm loginForm
= new LoginForm(driver
);
91 loginForm
.typeHostUrl(Config
.URL
);
92 loginForm
.clickOnUserName();
93 waitForTextPresent("Secure connection established", loginForm
.getServerStatusTextElement());
94 assertTrue(waitForTextPresent("Secure connection established", loginForm
.getServerStatusTextElement()));
95 loginForm
.typeUserName(Config
.user
);
96 loginForm
.typePassword(Config
.password
);
97 mainView
= loginForm
.clickOnConnectButton();
99 assertTrue(waitForTextPresent("An account for the same user and server already exists in the device", loginForm
.getAuthStatusText()));
100 driver
.sendKeyEvent(android
.view
.KeyEvent
.KEYCODE_BACK
);
101 Actions
.deleteAccount(settingsView
);
105 public void test5ChangePasswordWrong () throws Exception
{
107 MainView mainView
= login(Config
.URL
, Config
.user
,Config
.password
);
108 assertTrue(waitForTextPresent("ownCloud", mainView
.getTitleTextElement()));
109 mainView
.clickOnMenuButton();
110 SettingsView settingView
= mainView
.clickOnSettingsButton();
111 settingView
.tapOnAccountElement(1, 1000);
112 LoginForm changePasswordForm
= settingView
.clickOnChangePasswordElement();
113 changePasswordForm
.typePassword("WrongPassword");
114 changePasswordForm
.clickOnConnectButton();
115 assertTrue(waitForTextPresent("Wrong username or password", changePasswordForm
.getAuthStatusText()));
116 driver
.sendKeyEvent(android
.view
.KeyEvent
.KEYCODE_BACK
);
117 Actions
.deleteAccount(settingView
);
122 public void tearDown() throws Exception
{
123 driver
.removeApp("com.owncloud.android");