c017bcf8423bb84c768e0f5a5f373bc9c1974df7
[pub/Android/ownCloud.git] / automationTest / src / test / java / com / owncloud / android / test / ui / testSuites / LoginTestSuite.java
1 /**
2 * ownCloud Android client application
3 *
4 * @author purigarcia
5 * Copyright (C) 2015 ownCloud Inc.
6 *
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.
10 *
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.
15 *
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/>.
18 *
19 */
20
21 package com.owncloud.android.test.ui.testSuites;
22
23 import static org.junit.Assert.*;
24 import io.appium.java_client.android.AndroidDriver;
25
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;
35
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;
42
43 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
44 public class LoginTestSuite{
45 AndroidDriver driver;
46 Common common;
47
48 @Rule public TestName name = new TestName();
49
50 @Before
51 public void setUp() throws Exception {
52 common=new Common();
53 driver=common.setUpCommonDriver();
54 }
55
56 @Test
57 @Category({NoIgnoreTestCategory.class})
58 public void test1LoginPortrait () throws Exception {
59 driver.rotate(ScreenOrientation.PORTRAIT);
60
61 Actions.login(Config.URL, Config.user,
62 Config.password, Config.isTrusted, driver);
63 common.assertIsInFileListView();
64 }
65
66 @Test
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();
73 }
74
75
76 @Test
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();
83
84 driver.rotate(ScreenOrientation.PORTRAIT);
85 MenuList menu = fileListView.clickOnMenuButton();
86 SettingsView settingsView = menu.clickOnSettingsButton();
87
88 settingsView.tapOnAddAccount(1, 1000);
89 fileListView = Actions.login(Config.URL2, Config.user2,
90 Config.password2, Config.isTrusted2, driver);
91 common.assertIsInSettingsView();
92 }
93
94 @Test
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();
101
102 driver.rotate(ScreenOrientation.LANDSCAPE);
103 MenuList menu = fileListView.clickOnMenuButton();
104 SettingsView settingsView = menu.clickOnSettingsButton();
105 settingsView.tapOnAddAccount(1, 1000);
106
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()));
113 }
114
115 @Test
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()));
131 }
132
133
134 @After
135 public void tearDown() throws Exception {
136 common.takeScreenShotOnFailed(name.getMethodName());
137 driver.removeApp("com.owncloud.android");
138 driver.quit();
139 }
140
141
142 }