Search in sources :

Example 31 with Task

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

Example 32 with Task

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

the class UserTaskActivityTest 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.fab2);
    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 33 with Task

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

the class UserTaskActivityTest 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.fab2);
    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 34 with Task

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

the class BidActivityTest 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.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.clickOnButton("Log In");
    solo.assertCurrentActivity("Wrong Activity", WelcomeActivity.class);
    solo.waitForText("Tasks");
    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);
    View fab2 = solo.getCurrentActivity().findViewById(R.id.fab2);
    solo.clickOnView(fab2);
    assertTrue(solo.waitForText("Test Task Name"));
    solo.waitForText("Profile");
    solo.clickOnText("Profile");
    solo.clickOnView(solo.getView(R.id.LogOutButton));
    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.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.clickOnButton("Log In");
    solo.assertCurrentActivity("Wrong Activity", WelcomeActivity.class);
    // Test Bid on task
    solo.waitForText("Search");
    solo.clickOnText("Search");
    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.goBack();
    // Test Bid in bid list
    solo.waitForText("My Bids");
    solo.assertCurrentActivity("Wrong Activity", WelcomeActivity.class);
    solo.clickOnText("My Bids");
    solo.waitForText("Bid amount: ");
    solo.clickOnText("25.22");
    solo.assertCurrentActivity("Wrong Activity", ViewTaskActivity.class);
    // Test update 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(1000);
    solo.clickOnButton("Yes");
    assertFalse(solo.waitForText("25.22", 1, 1000));
}
Also used : MainActivity(com.cmput301w18t05.taskzilla.activity.MainActivity) View(android.view.View)

Example 35 with Task

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

the class NewTaskActivity method onCreate.

/**
 * Activity uses the activity_new_task.xml layout
 * New tasks are created through NewTaskController
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    setTitle("Add a Task");
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_new_task);
    AppColors appColors = AppColors.getInstance();
    ActionBar actionBar = getSupportActionBar();
    actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor(appColors.getActionBarColor())));
    actionBar.setTitle(Html.fromHtml("<font color='" + appColors.getActionBarTextColor() + "'>Taskzilla</font>"));
    // Obtain the SupportMapFragment and get notified when the map is ready to be used.
    SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.dragdropMap);
    mapFragment.getMapAsync(this);
    locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    newTaskController = new NewTaskController(this, getApplicationContext());
    currentLocationButton = findViewById(R.id.currentLocationButton);
    Button cancel = findViewById(R.id.CancelButton);
    Button addTask = findViewById(R.id.addTaskButton);
    final EditText taskName = findViewById(R.id.TaskName);
    final EditText taskDescription = findViewById(R.id.Description);
    addPhotoButton = findViewById(R.id.AddPhotoButton);
    autocompleteFragment = (PlaceAutocompleteFragment) getFragmentManager().findFragmentById(R.id.place_autocomplete_fragment);
    autocompleteFragment.setOnPlaceSelectedListener(new PlaceSelectionListener() {

        /**
         * When user select a location
         * Set hint and set place
         * @param place
         */
        @Override
        public void onPlaceSelected(Place place) {
            // TODO: Get info about the selected place.
            autocompleteFragment.setHint(place.getName());
            taskLocation = place.getLatLng();
        }

        @Override
        public void onError(Status status) {
            // TODO: Handle the error.
            taskLocation = null;
            Log.i("err", "An error occurred: " + status);
        }
    });
    photos = new ArrayList<>();
    recyclerPhotosView = findViewById(R.id.listOfPhotos);
    layoutManager = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false);
    recyclerPhotosView.setLayoutManager(layoutManager);
    recyclerPhotosViewAdapter = new RecyclerViewAdapter(this, photos, new CustomOnItemClick() {

        @Override
        public void onColumnClicked(final int position) {
            // taken from https://stackoverflow.com/questions/2115758/how-do-i-display-an-alert-dialog-on-android
            // 2018-03-16
            AlertDialog.Builder alert = new AlertDialog.Builder(NewTaskActivity.this);
            alert.setTitle("Delete Photo");
            alert.setMessage("Are you sure you want to delete this photo?");
            // DELETE CODE
            alert.setPositiveButton("Yes", new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    photos.remove(position);
                    dialogInterface.dismiss();
                    recyclerPhotosViewAdapter.notifyDataSetChanged();
                }
            });
            // DELETE CANCEL CODE
            alert.setNegativeButton("No", new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    dialogInterface.dismiss();
                }
            });
            alert.show();
        }
    });
    recyclerPhotosView.setAdapter(recyclerPhotosViewAdapter);
    autocompleteFragment.setHint("Task Location");
    getLocation();
    autocompleteFragment.setBoundsBias(new LatLngBounds(new LatLng(lat - 0.25, lon - 0.25), new LatLng(lat + 0.25, lon + 0.25)));
    /* cancel button */
    cancel.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            newTaskController.cancelTask();
        }
    });
    currentLocationButton.setOnClickListener(new View.OnClickListener() {

        /**
         * Set loaction to the users current location
         * @param view
         */
        @Override
        public void onClick(View view) {
            setCurrentLocation();
        }
    });
    /* add task button */
    addTask.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            newTaskController.addTask(taskName.getText().toString(), cUser, taskDescription.getText().toString(), taskLocation, photos);
        }
    });
    addPhotoButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            AddPhotoButtonClicked();
        }
    });
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) RecyclerViewAdapter(com.cmput301w18t05.taskzilla.RecyclerViewAdapter) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) CustomOnItemClick(com.cmput301w18t05.taskzilla.CustomOnItemClick) NewTaskController(com.cmput301w18t05.taskzilla.controller.NewTaskController) AppColors(com.cmput301w18t05.taskzilla.AppColors) SupportMapFragment(com.google.android.gms.maps.SupportMapFragment) ImageButton(android.widget.ImageButton) Button(android.widget.Button) LatLng(com.google.android.gms.maps.model.LatLng) ActionBar(android.support.v7.app.ActionBar) EditText(android.widget.EditText) Status(com.google.android.gms.common.api.Status) LatLngBounds(com.google.android.gms.maps.model.LatLngBounds) PlaceSelectionListener(com.google.android.gms.location.places.ui.PlaceSelectionListener) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) ColorDrawable(android.graphics.drawable.ColorDrawable) Place(com.google.android.gms.location.places.Place)

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