Search in sources :

Example 6 with MainActivity

use of com.cmput301w18t05.taskzilla.activity.MainActivity in project Taskzilla by CMPUT301W18T05.

the class UserTaskActivityIntentTest method testEditTask.

public void testEditTask() {
    MainActivity activity = (MainActivity) solo.getCurrentActivity();
    solo.assertCurrentActivity("Wrong Activity", MainActivity.class);
    solo.clickOnText("Sign Up");
    solo.assertCurrentActivity("Wrong Activity", SignUpActivity.class);
    solo.enterText((EditText) solo.getView(R.id.usernameField), "TestUser");
    solo.enterText((EditText) solo.getView(R.id.nameField), "TestName");
    solo.enterText((EditText) solo.getView(R.id.emailField), "Test@Email.com");
    solo.enterText((EditText) solo.getView(R.id.phoneField), "1234567890");
    solo.clickOnButton("Sign Up");
    solo.enterText((EditText) solo.getView(R.id.usernameText), "TestUser");
    solo.clickOnButton("Log In");
    solo.assertCurrentActivity("Wrong Activity", WelcomeActivity.class);
    // taken from https://stackoverflow.com/questions/33125017/how-to-access-floatingactionmenu-and-floating-action-button-in-robotium
    // 2018-3-17
    // View v = inflater.inflate(R.layout.fragment_tasks_requester, container, false);
    solo.waitForText("Tasks");
    View fab = solo.getCurrentActivity().findViewById(R.id.fab);
    solo.clickOnView(fab);
    solo.assertCurrentActivity("Wrong Activity", NewTaskActivity.class);
    solo.enterText((EditText) solo.getView(R.id.TaskName), "Test Task Name");
    solo.enterText((EditText) solo.getView(R.id.Description), "Test Description");
    solo.clickOnButton("Add Task");
    solo.waitForActivity(WelcomeActivity.class);
    solo.assertCurrentActivity("Wrong Activity", WelcomeActivity.class);
    View fab2 = solo.getCurrentActivity().findViewById(R.id.fab);
    solo.clickOnView(fab2);
    assertTrue(solo.waitForText("Test Task Name"));
    solo.clickInList(0);
    solo.assertCurrentActivity("Wrong Activity", ViewTaskActivity.class);
    solo.waitForText("Test Task Name");
    // Click Edit Button
    View editButton = solo.getCurrentActivity().findViewById(R.id.EditButton);
    solo.clickOnView(editButton);
    solo.waitForActivity(EditTaskActivity.class);
    solo.assertCurrentActivity("Wrong Activity", EditTaskActivity.class);
    // No Task Name
    solo.clearEditText((EditText) solo.getCurrentActivity().findViewById(R.id.TaskName));
    solo.clickOnButton("Save");
    solo.assertCurrentActivity("Wrong Activity", EditTaskActivity.class);
    // Task Name Too Long
    solo.enterText((EditText) solo.getCurrentActivity().findViewById(R.id.TaskName), "Task Name Task Name Task Name Task Name Task Name Task Name Task Name Task Name Task Name Task Name Task Name");
    solo.clickOnButton("Save");
    solo.assertCurrentActivity("Wrong Activity", EditTaskActivity.class);
    // Task Description Too Long
    solo.clearEditText((EditText) solo.getCurrentActivity().findViewById(R.id.TaskName));
    solo.enterText((EditText) solo.getCurrentActivity().findViewById(R.id.TaskName), "Task Name Edited");
    solo.enterText((EditText) solo.getCurrentActivity().findViewById(R.id.Description), "Task Description Task Description Task Description Task Description Task Description Task Description Task Description Task Description Task Description Task Description" + "Task Description Task Description Task Description Task Description Task Description Task Description Task Description Task Description Task Description Task Description Task Description Task Description Task Description" + "Task Description Task Description Task Description Task Description Task Description Task Description Task Description Task Description Task Description Task Description Task Description Task Description Task Description Task Description Task Description" + "Task Description Task Description Task Description Task Description Task Description");
    solo.clickOnButton("Save");
    solo.assertCurrentActivity("Wrong Activity", EditTaskActivity.class);
    // Valid Information
    solo.clearEditText((EditText) solo.getCurrentActivity().findViewById(R.id.Description));
    solo.enterText((EditText) solo.getCurrentActivity().findViewById(R.id.Description), "Task Description Edited");
    solo.clickOnButton("Save");
    solo.waitForActivity(ViewTaskActivity.class);
    solo.assertCurrentActivity("Wrong Activity", ViewTaskActivity.class);
    assertTrue(solo.waitForText("Task Name Edited"));
    assertTrue(solo.waitForText("Task Description Edited"));
}
Also used : MainActivity(com.cmput301w18t05.taskzilla.activity.MainActivity) View(android.view.View)

Example 7 with MainActivity

use of com.cmput301w18t05.taskzilla.activity.MainActivity in project Taskzilla by CMPUT301W18T05.

the class UserProfileIntentTest method testkTaskProfile.

public void testkTaskProfile() {
    MainActivity activity = (MainActivity) solo.getCurrentActivity();
    solo.assertCurrentActivity("Wrong Activity", MainActivity.class);
    solo.clickOnText("Sign Up");
    solo.assertCurrentActivity("Wrong Activity", SignUpActivity.class);
    solo.enterText((EditText) solo.getView(R.id.usernameField), "TestUser");
    solo.enterText((EditText) solo.getView(R.id.nameField), "TestName");
    solo.enterText((EditText) solo.getView(R.id.emailField), "Test@Email.com");
    solo.enterText((EditText) solo.getView(R.id.passwordField), "a");
    solo.enterText((EditText) solo.getView(R.id.phoneField), "1234567890");
    solo.clickOnButton("Sign Up");
    // valid login
    solo.enterText((EditText) solo.getView(R.id.usernameText), "TestUser");
    solo.enterText((EditText) solo.getView(R.id.passwordText), "a");
    solo.clickOnButton("Log In");
    solo.assertCurrentActivity("Wrong Activity", WelcomeActivity.class);
    // create new task
    solo.waitForText("Tasks");
    View fab = solo.getView(R.id.fab);
    solo.clickOnView(fab);
    solo.assertCurrentActivity("Wrong Activity", NewTaskActivity.class);
    // validate info
    solo.enterText((EditText) solo.getView(R.id.TaskName), "Test Task Name");
    solo.enterText((EditText) solo.getView(R.id.Description), "Test Description");
    solo.clickOnButton("Add Task");
    assertTrue(solo.waitForText("Test Task Name"));
    // check intent of other user profile
    solo.clickInList(0);
    solo.assertCurrentActivity("Wrong Activity", ViewTaskActivity.class);
    solo.waitForText("Test Task Name");
    ImageButton editButton = (ImageButton) solo.getView(R.id.RequesterPicture);
    solo.clickOnView(editButton);
    solo.sleep(500);
    solo.assertCurrentActivity("Wrong Activity", ProfileActivity.class);
    // checks if name of user matches name in profile
    assertTrue(solo.waitForText(currentUser.getInstance().getName()));
    // checks if email of user matches email in profile
    assertTrue(solo.waitForText(currentUser.getInstance().getEmail().toString()));
    // checks if phone of user matches phone in profile
    assertTrue(solo.waitForText(currentUser.getInstance().getPhone().toString()));
}
Also used : ImageButton(android.widget.ImageButton) MainActivity(com.cmput301w18t05.taskzilla.activity.MainActivity) View(android.view.View)

Example 8 with MainActivity

use of com.cmput301w18t05.taskzilla.activity.MainActivity in project Taskzilla by CMPUT301W18T05.

the class MainActivityTest method testLogIn.

public void testLogIn() {
    // Set up for Test
    MainActivity activity = (MainActivity) solo.getCurrentActivity();
    solo.assertCurrentActivity("Wrong Activity", MainActivity.class);
    solo.clickOnText("Sign Up");
    solo.assertCurrentActivity("Wrong Activity", SignUpActivity.class);
    solo.enterText((EditText) solo.getView(R.id.usernameField), "TestUser");
    solo.enterText((EditText) solo.getView(R.id.nameField), "TestName");
    solo.enterText((EditText) solo.getView(R.id.emailField), "Test@Email.com");
    solo.enterText((EditText) solo.getView(R.id.phoneField), "1234567890");
    solo.clickOnButton("Sign Up");
    // No Log in Info
    solo.clickOnButton("Log In");
    solo.assertCurrentActivity("Wrong Activity", MainActivity.class);
    // Incorrect Log in Info
    solo.enterText((EditText) solo.getView(R.id.usernameText), "123456789101112131415161718192021222324252627282930");
    solo.clickOnButton("Log In");
    solo.assertCurrentActivity("Wrong Activity", MainActivity.class);
    // Correct Log in Info
    solo.clearEditText((EditText) solo.getView(R.id.usernameText));
    solo.enterText((EditText) solo.getView(R.id.usernameText), "TestUser");
    solo.clickOnButton("Log In");
    solo.assertCurrentActivity("Wrong Activity", WelcomeActivity.class);
    assertTrue(solo.waitForText("Tasks"));
}
Also used : MainActivity(com.cmput301w18t05.taskzilla.activity.MainActivity)

Example 9 with MainActivity

use of com.cmput301w18t05.taskzilla.activity.MainActivity in project Taskzilla by CMPUT301W18T05.

the class MainActivityTest method testSignUp.

public void testSignUp() {
    MainActivity activity = (MainActivity) solo.getCurrentActivity();
    solo.assertCurrentActivity("Wrong Activity", MainActivity.class);
    solo.clickOnText("Sign Up");
    solo.assertCurrentActivity("Wrong Activity", SignUpActivity.class);
    // Wrong Info - Long username
    solo.enterText((EditText) solo.getView(R.id.usernameField), "wowowowowowowowowowdkwodkwodwkodwkdowodkwdoksqsqw");
    solo.enterText((EditText) solo.getView(R.id.nameField), "TestName");
    solo.enterText((EditText) solo.getView(R.id.emailField), "Test@Email.com");
    solo.enterText((EditText) solo.getView(R.id.phoneField), "1234567890");
    solo.clickOnButton("Sign Up");
    solo.assertCurrentActivity("Wrong Activity", SignUpActivity.class);
    // Wrong Info - Illegal character in username
    solo.clearEditText((EditText) solo.getView(R.id.usernameField));
    solo.enterText((EditText) solo.getView(R.id.usernameField), "Test%^User");
    solo.sleep(1000);
    solo.clickOnButton("Sign Up");
    solo.assertCurrentActivity("Wrong Activity", SignUpActivity.class);
    // Wrong Info - Long name
    solo.clearEditText((EditText) solo.getView(R.id.usernameField));
    solo.enterText((EditText) solo.getView(R.id.usernameField), "TestUser");
    solo.enterText((EditText) solo.getView(R.id.nameField), "TestNameTestNameTestNameTestNameTestNameTestNameTestNameTestNameTestName");
    solo.clickOnButton("Sign Up");
    solo.assertCurrentActivity("Wrong Activity", SignUpActivity.class);
    // Wrong Info - Illegal character in name
    solo.clearEditText((EditText) solo.getView(R.id.nameField));
    solo.enterText((EditText) solo.getView(R.id.nameField), "$%**@(@)!)");
    solo.sleep(1000);
    solo.clickOnButton("Sign Up");
    solo.assertCurrentActivity("Wrong Activity", SignUpActivity.class);
    // Wrong Info - Email Invalid
    solo.clearEditText((EditText) solo.getView(R.id.nameField));
    solo.clearEditText((EditText) solo.getView(R.id.emailField));
    solo.enterText((EditText) solo.getView(R.id.nameField), "TestName");
    solo.enterText((EditText) solo.getView(R.id.emailField), "TestEmaillcom");
    solo.clickOnButton("Sign Up");
    solo.assertCurrentActivity("Wrong Activity", SignUpActivity.class);
    // Wrong Info - Email Too Long
    solo.clearEditText((EditText) solo.getView(R.id.emailField));
    solo.enterText((EditText) solo.getView(R.id.emailField), "TestEmailcomTestEmailcomTestEmailcomTestEmailcomTestEmailcomTestEmailcomTestEmailcom");
    solo.sleep(1000);
    solo.clickOnButton("Sign Up");
    solo.assertCurrentActivity("Wrong Activity", SignUpActivity.class);
    // Wrong Info - Incorrect Phone Number
    solo.clearEditText((EditText) solo.getView(R.id.emailField));
    solo.enterText((EditText) solo.getView(R.id.emailField), "Test@Email.com");
    solo.enterText((EditText) solo.getView(R.id.phoneField), "1290");
    solo.clickOnButton("Sign Up");
    solo.assertCurrentActivity("Wrong Activity", SignUpActivity.class);
    // Valid Information
    solo.clearEditText((EditText) solo.getView(R.id.phoneField));
    solo.enterText((EditText) solo.getView(R.id.phoneField), "1234567890");
    solo.sleep(1000);
    solo.clickOnButton("Sign Up");
    solo.assertCurrentActivity("Wrong Activity", MainActivity.class);
}
Also used : MainActivity(com.cmput301w18t05.taskzilla.activity.MainActivity)

Example 10 with MainActivity

use of com.cmput301w18t05.taskzilla.activity.MainActivity in project Taskzilla by CMPUT301W18T05.

the class UserTaskActivityTest method testNewTask.

public void testNewTask() {
    MainActivity activity = (MainActivity) solo.getCurrentActivity();
    solo.assertCurrentActivity("Wrong Activity", MainActivity.class);
    solo.clickOnText("Sign Up");
    solo.assertCurrentActivity("Wrong Activity", SignUpActivity.class);
    solo.enterText((EditText) solo.getView(R.id.usernameField), "TestUser");
    solo.enterText((EditText) solo.getView(R.id.nameField), "TestName");
    solo.enterText((EditText) solo.getView(R.id.emailField), "Test@Email.com");
    solo.enterText((EditText) solo.getView(R.id.phoneField), "1234567890");
    solo.clickOnButton("Sign Up");
    solo.enterText((EditText) solo.getView(R.id.usernameText), "TestUser");
    solo.clickOnButton("Log In");
    solo.assertCurrentActivity("Wrong Activity", WelcomeActivity.class);
    // taken from https://stackoverflow.com/questions/33125017/how-to-access-floatingactionmenu-and-floating-action-button-in-robotium
    // 2018-3-17
    // View v = inflater.inflate(R.layout.fragment_tasks_requester, container, false);
    solo.waitForText("Tasks");
    View fab = solo.getCurrentActivity().findViewById(R.id.fab);
    solo.clickOnView(fab);
    solo.assertCurrentActivity("Wrong Activity", NewTaskActivity.class);
    // No Task Name
    solo.enterText((EditText) solo.getView(R.id.Description), "Test Description");
    solo.clickOnButton("Add Task");
    solo.assertCurrentActivity("Wrong Activity", NewTaskActivity.class);
    // Task Name Too Long
    solo.clearEditText((EditText) solo.getView(R.id.TaskName));
    solo.enterText((EditText) solo.getView(R.id.TaskName), "Test Task Test Task Test Task Test Task Test Task Test Task Test Task Test Task Test Task");
    solo.clickOnButton("Add Task");
    solo.assertCurrentActivity("Wrong Activity", NewTaskActivity.class);
    // No Task Description
    solo.clearEditText((EditText) solo.getView(R.id.TaskName));
    solo.clearEditText((EditText) solo.getView(R.id.Description));
    solo.enterText((EditText) solo.getView(R.id.TaskName), "Test Task Name");
    solo.clickOnButton("Add Task");
    solo.assertCurrentActivity("Wrong Activity", NewTaskActivity.class);
    // Task Description too long
    solo.enterText((EditText) solo.getView(R.id.Description), "Test Description Test Description Test Description Test Description Test Description Test Description Test Description Test Description Test Description Test Description " + "Test Description Test Description Test Description Test Description Test Description Test Description Test Description Test Description Test Description Test Description Test Description Test Description Test Description " + "Test Description Test Description Test Description Test Description Test Description Test Description Test Description Test Description Test Description Test Description Test Description Test Description Test Description");
    solo.clickOnButton("Add Task");
    solo.assertCurrentActivity("Wrong Activity", NewTaskActivity.class);
    // Valid Information
    solo.clearEditText((EditText) solo.getView(R.id.Description));
    solo.enterText((EditText) solo.getView(R.id.Description), "Test Description");
    solo.clickOnButton("Add Task");
    solo.waitForActivity(WelcomeActivity.class);
    solo.assertCurrentActivity("Wrong Activity", WelcomeActivity.class);
    View fab2 = solo.getCurrentActivity().findViewById(R.id.fab2);
    solo.clickOnView(fab2);
    assertTrue(solo.waitForText("Test Task Name"));
}
Also used : MainActivity(com.cmput301w18t05.taskzilla.activity.MainActivity) View(android.view.View)

Aggregations

MainActivity (com.cmput301w18t05.taskzilla.activity.MainActivity)17 View (android.view.View)11 WelcomeActivity (com.cmput301w18t05.taskzilla.activity.WelcomeActivity)2 EditText (android.widget.EditText)1 ImageButton (android.widget.ImageButton)1 SearchView (android.widget.SearchView)1