Search in sources :

Example 16 with Task

use of com.cmput301w18t05.taskzilla.Task in project Taskzilla by CMPUT301W18T05.

the class RequestManagerTest method testSearchTaskRequest.

public void testSearchTaskRequest() {
    addUser();
    addTask();
    String keywords = task.getDescription();
    SearchTaskRequest request = new SearchTaskRequest(keywords);
    RequestManager.getInstance().invokeRequest(ctx, request);
    assertNotNull(request.getTasks());
    System.out.println("------- Search output -------");
    System.out.println("******************************");
    ArrayList<Task> ret = request.getTasks();
    System.out.println(ret);
    for (Task t : ret) {
        System.out.println(t);
        Log.i("Found Task", t.getId());
    }
}
Also used : SearchTaskRequest(com.cmput301w18t05.taskzilla.request.command.SearchTaskRequest)

Example 17 with Task

use of com.cmput301w18t05.taskzilla.Task in project Taskzilla by CMPUT301W18T05.

the class UserTest method testGetTasksRequested.

// Test for getting a list of tasks that the user has requested
public void testGetTasksRequested() {
    User user = new User();
    user.setUsername("abc");
    AddUserRequest addUserRequest = new AddUserRequest(user);
    RequestManager.getInstance().invokeRequest(getActivity(), addUserRequest);
    Task task1 = new Task("Task name", user, "Task description");
    AddTaskRequest addTaskRequest1 = new AddTaskRequest(task1);
    RequestManager.getInstance().invokeRequest(getActivity(), addTaskRequest1);
    Task task2 = new Task("Task name", user, "Task description");
    AddTaskRequest addTaskRequest2 = new AddTaskRequest(task2);
    RequestManager.getInstance().invokeRequest(getActivity(), addTaskRequest2);
    ArrayList<Task> tasks = new ArrayList<>();
    tasks.add(task1);
    tasks.add(task2);
    ArrayList<Task> result = new ArrayList<>();
    result = user.getTasksRequested();
    assertTrue(tasks.containsAll(result) && result.containsAll(tasks));
}
Also used : ArrayList(java.util.ArrayList) AddTaskRequest(com.cmput301w18t05.taskzilla.request.command.AddTaskRequest) AddUserRequest(com.cmput301w18t05.taskzilla.request.command.AddUserRequest)

Example 18 with Task

use of com.cmput301w18t05.taskzilla.Task in project Taskzilla by CMPUT301W18T05.

the class UserTaskActivityIntentTest method testDeleteTask.

public void testDeleteTask() {
    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 To Be Deleted");
    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 To Be Deleted"));
    solo.clickOnText("Test Task To Be Deleted");
    solo.assertCurrentActivity("Wrong Activity", ViewTaskActivity.class);
    solo.waitForText("Test Task to Be Deleted");
    View DeleteButton = solo.getCurrentActivity().findViewById(R.id.DeleteButton);
    solo.clickOnView(DeleteButton);
    solo.clickOnText(("Yes"));
    solo.waitForActivity(WelcomeActivity.class);
    solo.assertCurrentActivity("Wrong Activity", WelcomeActivity.class);
}
Also used : MainActivity(com.cmput301w18t05.taskzilla.activity.MainActivity) View(android.view.View)

Example 19 with Task

use of com.cmput301w18t05.taskzilla.Task 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 20 with Task

use of com.cmput301w18t05.taskzilla.Task 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)

Aggregations

View (android.view.View)18 Task (com.cmput301w18t05.taskzilla.Task)16 MainActivity (com.cmput301w18t05.taskzilla.activity.MainActivity)10 AddTaskRequest (com.cmput301w18t05.taskzilla.request.command.AddTaskRequest)9 AlertDialog (android.support.v7.app.AlertDialog)6 AdapterView (android.widget.AdapterView)6 ListView (android.widget.ListView)6 GetTaskRequest (com.cmput301w18t05.taskzilla.request.command.GetTaskRequest)6 Intent (android.content.Intent)5 RecyclerView (android.support.v7.widget.RecyclerView)5 EditText (android.widget.EditText)5 ImageButton (android.widget.ImageButton)5 DecimalFormat (java.text.DecimalFormat)5 DialogInterface (android.content.DialogInterface)4 Button (android.widget.Button)4 TextView (android.widget.TextView)4 AppCache (com.cmput301w18t05.taskzilla.AppCache)4 Bid (com.cmput301w18t05.taskzilla.Bid)4 ColorDrawable (android.graphics.drawable.ColorDrawable)3 ActionBar (android.support.v7.app.ActionBar)3