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