4083e8eda4ec13d27780d774d5ce36013680c194
[pub/Android/ownCloud.git] / automationTest / src / test / java / com / owncloud / android / test / ui / testSuites / LoginTestSuite.java
1 package com.owncloud.android.test.ui.testSuites;
2
3 import static org.junit.Assert.*;
4 import io.appium.java_client.android.AndroidDriver;
5
6 import org.junit.After;
7 import org.junit.Before;
8 import org.junit.Rule;
9 import org.junit.experimental.categories.Category;
10 import org.junit.rules.TestName;
11 import org.junit.runners.MethodSorters;
12 import org.junit.FixMethodOrder;
13 import org.junit.Test;
14 import org.openqa.selenium.ScreenOrientation;
15
16 import com.owncloud.android.test.ui.actions.Actions;
17 import com.owncloud.android.test.ui.groups.*;
18 import com.owncloud.android.test.ui.models.LoginForm;
19 import com.owncloud.android.test.ui.models.FileListView;
20 import com.owncloud.android.test.ui.models.MenuList;
21 import com.owncloud.android.test.ui.models.SettingsView;
22
23 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
24 public class LoginTestSuite{
25 AndroidDriver driver;
26 Common common;
27
28 @Rule public TestName name = new TestName();
29
30 @Before
31 public void setUp() throws Exception {
32 common=new Common();
33 driver=common.setUpCommonDriver();
34 }
35
36 @Test
37 @Category({NoIgnoreTestCategory.class})
38 public void test1LoginPortrait () throws Exception {
39 driver.rotate(ScreenOrientation.PORTRAIT);
40
41 FileListView fileListView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver);
42 common.assertIsInFileListView();
43 }
44
45 @Test
46 @Category({NoIgnoreTestCategory.class})
47 public void test2LoginLandscape () throws Exception {
48 driver.rotate(ScreenOrientation.LANDSCAPE);
49 FileListView fileListView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver);
50 common.assertIsInFileListView();
51 }
52
53
54 @Test
55 @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class})
56 public void test3MultiAccountRotate () throws Exception {
57 driver.rotate(ScreenOrientation.LANDSCAPE);
58 FileListView fileListView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver);
59 common.assertIsInFileListView();
60
61 driver.rotate(ScreenOrientation.PORTRAIT);
62 MenuList menu = fileListView.clickOnMenuButton();
63 SettingsView settingsView = menu.clickOnSettingsButton();
64
65 settingsView.tapOnAddAccount(1, 1000);
66 fileListView = Actions.login(Config.URL2, Config.user2,Config.password2, Config.isTrusted2, driver);
67 common.assertIsInSettingsView();
68 }
69
70 @Test
71 @Category({NoIgnoreTestCategory.class})
72 public void test4ExistingAccountRotate () throws Exception {
73 driver.rotate(ScreenOrientation.PORTRAIT);
74 FileListView fileListView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver);
75 common.assertIsInFileListView();
76
77 driver.rotate(ScreenOrientation.LANDSCAPE);
78 MenuList menu = fileListView.clickOnMenuButton();
79 SettingsView settingsView = menu.clickOnSettingsButton();
80 settingsView.tapOnAddAccount(1, 1000);
81
82 LoginForm loginForm = new LoginForm(driver);
83 fileListView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver);
84 assertTrue(common.waitForTextPresent("An account for the same user and server already exists in the device", loginForm.getAuthStatusText()));
85 }
86
87 @Test
88 @Category({NoIgnoreTestCategory.class})
89 public void test5ChangePasswordWrong () throws Exception {
90 driver.rotate(ScreenOrientation.PORTRAIT);
91 FileListView fileListView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver);
92 common.assertIsInFileListView();
93 MenuList menu = fileListView.clickOnMenuButton();
94 SettingsView settingsView = menu.clickOnSettingsButton();
95 settingsView.tapOnAccountElement(1, 1000);
96 LoginForm changePasswordForm = settingsView.clickOnChangePasswordElement();
97 changePasswordForm.typePassword("WrongPassword");
98 changePasswordForm.clickOnConnectButton();
99 assertTrue(common.waitForTextPresent("Wrong username or password", changePasswordForm.getAuthStatusText()));
100 }
101
102
103 @After
104 public void tearDown() throws Exception {
105 common.takeScreenShotOnFailed(name.getMethodName());
106 driver.removeApp("com.owncloud.android");
107 driver.quit();
108 }
109
110
111 }