Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
nbhuiyan committed Nov 13, 2017
2 parents c0d07c6 + fe4dd6f commit 6440892
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
import java.util.Comparator;
import java.util.Date;

public class HabitEventHistoryTest extends ActivityInstrumentationTestCase2 {
public HabitEventHistoryTest(){
public class HabitEventHistoryTests extends ActivityInstrumentationTestCase2 {
public HabitEventHistoryTests(){
super(com.cmput301f17t11.cupofjava.MainActivity.class);
}

Expand All @@ -37,7 +37,7 @@ public void testDelete(){
assertFalse(eventHistory.hasHabitEvent(event));
}

public void testGetHabitEvent(){
public void testGetHabitEvent(){
//Habit habit = new Habit("adding habit", "for test",Calendar.getInstance());
HabitEvent event = new HabitEvent("comment1");
HabitEventHistory eventHistory = new HabitEventHistory();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,16 @@ public void testLogin(){
solo.enterText((EditText)solo.getView(R.id.username), "Mary Poppins");
solo.clickOnButton("Sign in | Register");
solo.assertCurrentActivity("new activity", TodayViewActivity.class);
solo.assertCurrentActivity("new activity", TodayViewActivity.class);
//solo.assertCurrentActivity("new activity", TodayViewActivity.class);

//*Add habit button
solo.clickOnView((solo.getView(R.id.add_habit)));
solo.assertCurrentActivity("new activity", NewHabitActivity.class);
//NewHabit Activity
solo.enterText((EditText) solo.getView(R.id.habit_title),"Disciplining Kids");
assertTrue(solo.waitForText("Disciplining Kids"));
solo.enterText((EditText)solo.getView(R.id.habit_reason),"good Nanny");
assertTrue(solo.waitForText("good Nanny"));
solo.enterText((EditText)solo.getView(R.id.habit_reason),"Good Nanny");
assertTrue(solo.waitForText("Good Nanny"));
solo.clickOnView((solo.getView(R.id.habit_start_date)));
solo.setDatePicker(0,2017,10,13);
solo.clickOnText("OK");
Expand All @@ -66,24 +69,55 @@ public void testLogin(){
//testClickTodayHabitList
TodayViewActivity activity = (TodayViewActivity) solo.getCurrentActivity();

solo.assertCurrentActivity("parent activity", TodayViewActivity.class);
//solo.assertCurrentActivity("parent activity", TodayViewActivity.class);


final ListView habitList = activity.getListView();
//Habit myhabit = (Habit) habitList.getItemAtPosition(0);
//assertEquals("Test Tweet!", tweet.getMessage());
Habit habit = (Habit) habitList.getItemAtPosition(0);
assertEquals("Disciplining Kids", habit.getHabitTitle());
assertEquals("Good Nanny",habit.getHabitReason());

solo.clickInList(0);
solo.assertCurrentActivity("wrong activity", HabitDetailViewActivity.class);
//assertTrue(solo.waitForText("Test Tweet!", 1, 1000));
assertTrue(solo.waitForText("Disciplining Kids", 1, 1000));
assertTrue(solo.waitForText("Good Nanny", 1, 1000));
assertTrue(solo.waitForText("11 / 13 / 2017", 1, 1000));
solo.goBack();
//solo.assertCurrentActivity("wrong Activity", LonelyTwitterActivity.class);


//testALlHabitsButton(){
solo.assertCurrentActivity("Parent Activity",TodayViewActivity.class);
solo.clickOnView(solo.getView(R.id.action_all_habits));
solo.assertCurrentActivity("child activity", AllHabitViewActivity.class);
//click on habit in All Habits View
solo.sleep(5000);
AllHabitViewActivity activity2 = (AllHabitViewActivity)solo.getCurrentActivity();



final ListView habitList2 = activity2.getListView();
Habit myhabit = (Habit) habitList.getItemAtPosition(0);
assertEquals("Disciplining Kids", myhabit.getHabitTitle());
assertEquals("Good Nanny",myhabit.getHabitReason());

solo.clickInList(0);
solo.assertCurrentActivity("wrong activity", HabitDetailViewActivity.class);
assertTrue(solo.waitForText("Disciplining Kids", 1, 1000));
assertTrue(solo.waitForText("Good Nanny", 1, 1000));
assertTrue(solo.waitForText("11 / 13 / 2017", 1, 1000));
solo.clickOnButton("Delete");
solo.clickOnText("DELETE");

solo.sleep(2000);
//test timeline button
solo.assertCurrentActivity("parent activity", TodayViewActivity.class);
solo.clickOnView(solo.getView(R.id.action_timeline));
solo.assertCurrentActivity("child activity", HabitEventTimeLineActivity.class);

solo.sleep(2000);

solo.goBack();


}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ public class AllHabitViewActivity extends Activity {
private String userName;
private int userIndex;

public ListView getListView(){
return listView;
}

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand Down

0 comments on commit 6440892

Please sign in to comment.