Search in sources :

Example 16 with MainActivity

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

the class UserProfileIntentTest method testProfile.

public void testProfile() {
    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);
    solo.waitForText("Profile");
    solo.clickOnText("Profile");
    solo.sleep(500);
    solo.waitForText("Number");
    View EditButton = solo.getView("editButton");
    solo.clickOnView(EditButton);
    solo.waitForActivity(EditProfileActivity.class);
    solo.assertCurrentActivity("Wrong Activity", EditProfileActivity.class);
    solo.clearEditText((EditText) solo.getView(R.id.Phone));
    solo.clearEditText((EditText) solo.getView(R.id.NameField));
    solo.clearEditText((EditText) solo.getView(R.id.EmailField));
    // Name Empty
    solo.enterText((EditText) solo.getView(R.id.Phone), "1234567890");
    solo.enterText((EditText) solo.getView(R.id.EmailField), "Test@Email.com");
    solo.clickOnText("Save");
    solo.assertCurrentActivity("Wrong Activity", EditProfileActivity.class);
    // Name Too Long
    solo.enterText((EditText) solo.getView(R.id.NameField), "TestNameTestNameTestNameTestNameTestNameTestNameTestNameTestNameTestNameTestNameTestNameTestNameTestNameTestNameTestNameTestNameTestNameTestNameTestNameTestNameTestNameTestName");
    solo.clickOnText("Save");
    solo.assertCurrentActivity("Wrong Activity", EditProfileActivity.class);
    // Phone Empty
    solo.clearEditText((EditText) solo.getView(R.id.NameField));
    solo.clearEditText((EditText) solo.getView(R.id.Phone));
    solo.enterText((EditText) solo.getView(R.id.NameField), "TestName");
    solo.clickOnText("Save");
    solo.assertCurrentActivity("Wrong Activity", EditProfileActivity.class);
    // Phone Too Long
    solo.enterText((EditText) solo.getView(R.id.Phone), "12345678901234567890");
    solo.clickOnText("Save");
    solo.assertCurrentActivity("Wrong Activity", EditProfileActivity.class);
    // Invalid Email
    solo.clearEditText((EditText) solo.getView(R.id.Phone));
    solo.enterText((EditText) solo.getView(R.id.Phone), "1234567890");
    solo.clearEditText((EditText) solo.getView(R.id.EmailField));
    solo.enterText((EditText) solo.getView(R.id.EmailField), "Test");
    solo.clickOnText("Save");
    solo.assertCurrentActivity("Wrong Activity", EditProfileActivity.class);
    // Valid Info
    solo.enterText((EditText) solo.getView(R.id.EmailField), "Test@Email.com");
    solo.clickOnText("Save");
    solo.waitForText("Number");
    solo.assertCurrentActivity("Wrong Activity", WelcomeActivity.class);
/*
        //checks if logout button brings the user back to the home screen
        View logoutButton = solo.getCurrentActivity().findViewById(R.id.LogOutButton);
        solo.clickOnView(logoutButton);
        solo.waitForActivity(MainActivity.class);
        solo.assertCurrentActivity("Wrong Acvitivy", MainActivity.class);
        assertTrue(solo.waitForText(userName));
        */
}
Also used : MainActivity(com.cmput301w18t05.taskzilla.activity.MainActivity) View(android.view.View)

Example 17 with MainActivity

use of com.cmput301w18t05.taskzilla.activity.MainActivity 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

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