Search in sources :

Example 41 with Task

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

the class RequestManagerTest method addTask.

public void addTask() {
    AddTaskRequest addTaskRequest = new AddTaskRequest(task);
    RequestManager.getInstance().invokeRequest(addTaskRequest);
    assertTrue(addTaskRequest.getResult());
}
Also used : AddTaskRequest(com.cmput301w18t05.taskzilla.request.command.AddTaskRequest)

Example 42 with Task

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

the class UserTaskActivityIntentTest 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.fab);
    solo.clickOnView(fab2);
    assertTrue(solo.waitForText("Test Task Name"));
}
Also used : MainActivity(com.cmput301w18t05.taskzilla.activity.MainActivity) View(android.view.View)

Example 43 with Task

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

the class Bid method toString.

/**
 * Returns a string with the bid details
 * @return the string which is with the details of the bid
 */
public String toString() {
    GetTaskRequest taskRequest = new GetTaskRequest(this.taskId);
    RequestManager.getInstance().invokeRequest(taskRequest);
    DecimalFormat cents = new DecimalFormat("#0.00");
    return "Task: " + taskRequest.getResult().getName() + " \nRequester: " + taskRequest.getResult().getTaskRequester().getName() + " \nStatus: " + taskRequest.getResult().getStatus() + "\nBid amount: $" + cents.format(this.bidAmount) + " Lowest bid: $" + cents.format(taskRequest.getResult().getBestBid());
}
Also used : GetTaskRequest(com.cmput301w18t05.taskzilla.request.command.GetTaskRequest) DecimalFormat(java.text.DecimalFormat)

Example 44 with Task

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

the class Notification method acknowledge.

/**
 *  If the notification is new, it is set to acknowledge to next time there wont be a
 *  heads up notification shown.
 *
 *  @see NotificationManager
 */
public void acknowledge() {
    if (id == null)
        return;
    this.acknowledged = true;
    AddNotificationRequest task = new AddNotificationRequest(this);
    RequestManager.getInstance().invokeRequest(task);
}
Also used : AddNotificationRequest(com.cmput301w18t05.taskzilla.request.command.AddNotificationRequest)

Example 45 with Task

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

the class BidActivityIntentTest method testBid.

public void testBid() {
    // 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.passwordField), "a");
    solo.enterText((EditText) solo.getView(R.id.emailField), "Test@Email.com");
    solo.enterText((EditText) solo.getView(R.id.phoneField), "1234567890");
    solo.clickOnButton("Sign Up");
    // Correct Log in Info
    solo.clearEditText((EditText) solo.getView(R.id.usernameText));
    solo.enterText((EditText) solo.getView(R.id.usernameText), "TestUser");
    solo.enterText((EditText) solo.getView(R.id.passwordText), "a");
    solo.clickOnButton("Log In");
    solo.waitForText("Tasks");
    solo.assertCurrentActivity("Wrong Activity", WelcomeActivity.class);
    solo.sleep(5000);
    View fab = solo.getCurrentActivity().findViewById(R.id.fab);
    solo.clickOnView(fab);
    solo.waitForActivity(NewTaskActivity.class);
    solo.assertCurrentActivity("Wrong Activity", NewTaskActivity.class);
    // Valid Information
    solo.clearEditText((EditText) solo.getView(R.id.Description));
    solo.enterText((EditText) solo.getView(R.id.TaskName), "Test Task Name");
    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);
    solo.waitForText("Profile");
    solo.clickOnText("Profile");
    solo.clickOnText("Log out");
    solo.waitForActivity(MainActivity.class);
    solo.assertCurrentActivity("Wrong Activity", MainActivity.class);
    solo.clickOnText("Sign Up");
    solo.assertCurrentActivity("Wrong Activity", SignUpActivity.class);
    solo.enterText((EditText) solo.getView(R.id.usernameField), "TestUserOne");
    solo.enterText((EditText) solo.getView(R.id.nameField), "TestNameOne");
    solo.enterText((EditText) solo.getView(R.id.passwordField), "a");
    solo.enterText((EditText) solo.getView(R.id.emailField), "Test1@Email.com");
    solo.enterText((EditText) solo.getView(R.id.phoneField), "1234567890");
    solo.clickOnButton("Sign Up");
    // Correct Log in Info
    solo.clearEditText((EditText) solo.getView(R.id.usernameText));
    solo.enterText((EditText) solo.getView(R.id.usernameText), "TestUserOne");
    solo.enterText((EditText) solo.getView(R.id.passwordText), "a");
    solo.clickOnButton("Log In");
    solo.assertCurrentActivity("Wrong Activity", WelcomeActivity.class);
    // Test Bid on task
    solo.sleep(3000);
    solo.waitForText("Search");
    solo.clickOnText("Search");
    solo.sleep(3000);
    solo.waitForText("Status: ");
    solo.clickOnText("Status: ");
    solo.assertCurrentActivity("Wrong Activity", ViewTaskActivity.class);
    solo.clickOnButton("PLACE BID");
    solo.enterText((EditText) solo.getView(R.id.place_bid_edittext), "25.22");
    solo.clickOnButton("Place Bid");
    solo.sleep(1000);
    solo.goBack();
    // Test Bid in bid list
    solo.waitForText("Bids");
    solo.assertCurrentActivity("Wrong Activity", WelcomeActivity.class);
    solo.clickOnText("Bids");
    solo.waitForText("Bid amount: ");
    solo.clickOnText("25.22");
    solo.assertCurrentActivity("Wrong Activity", ViewTaskActivity.class);
    // Test update bid
    solo.sleep(500);
    solo.waitForText("PLACE BID");
    solo.clickOnButton("PLACE BID");
    solo.enterText((EditText) solo.getView(R.id.place_bid_edittext), "29.22");
    solo.clickOnButton("Place Bid");
    solo.goBack();
    solo.clickLongOnText("29.22");
    // Test Delete bid
    solo.sleep(2000);
    assertTrue(solo.waitForText("29.22"));
}
Also used : 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