upload a few automated test
[pub/Android/ownCloud.git] / automationTest / src / test / java / androidtest / tests / LoginTestSuite.java
1 package androidtest.tests;
2
3 import org.junit.After;
4 import org.junit.Before;
5 import org.junit.runners.MethodSorters;
6 import org.junit.FixMethodOrder;
7 import org.junit.Test;
8 import org.openqa.selenium.ScreenOrientation;
9
10
11 import androidtest.actions.Actions;
12 import androidtest.models.LoginForm;
13 import androidtest.models.MainView;
14 import androidtest.models.SettingsView;
15
16 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
17 public class LoginTestSuite extends CommonTest{
18
19 @Before
20 public void setUp() throws Exception {
21 setUpCommonDriver();
22 }
23
24 @Test
25 public void test1LoginPortrait () throws Exception {
26
27 System.out.println("Hello" + Config.server);
28 String testName = "loginPortrait";
29 driver.rotate(ScreenOrientation.PORTRAIT);
30
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()));
37 }else{
38 assertTrue(waitForTextPresent("Settings", mainView.getTitleTextElement()));
39 }
40 fail(testName);
41 }*/
42 Actions.deleteAccount(mainView);
43 }
44
45 @Test
46 public void test2LoginLandscape () throws Exception {
47
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);
54 }
55
56
57 @Test
58 public void test3MultiAccountRotate () throws Exception {
59
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()));
64
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);
70
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
76 }
77
78 @Test
79 public void test4ExistingAccountRotate () throws Exception {
80
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()));
85
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();
98
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);
102 }
103
104
105 public void test5ChangePasswordWrong () throws Exception {
106
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);
118 }
119
120
121 @After
122 public void tearDown() throws Exception {
123 driver.removeApp("com.owncloud.android");
124 driver.quit();
125 }
126
127
128 }