From 54d8a4ec5fe2b2fd23c9b31d415838af9fdf5b1f Mon Sep 17 00:00:00 2001 From: eshna Date: Mon, 13 Nov 2017 15:10:04 -0700 Subject: [PATCH 1/2] updated UserLoginActivity --- .../cupofjava/UserLoginActivityTest.java | 49 ++++++++++++++++--- 1 file changed, 41 insertions(+), 8 deletions(-) diff --git a/app/src/androidTest/java/com/cmput301f17t11/cupofjava/UserLoginActivityTest.java b/app/src/androidTest/java/com/cmput301f17t11/cupofjava/UserLoginActivityTest.java index 55f630e..6420d85 100644 --- a/app/src/androidTest/java/com/cmput301f17t11/cupofjava/UserLoginActivityTest.java +++ b/app/src/androidTest/java/com/cmput301f17t11/cupofjava/UserLoginActivityTest.java @@ -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"); @@ -66,24 +69,54 @@ 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); + 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(); + } From fe4dd6f607d3275d0598dc947a987f25d564799c Mon Sep 17 00:00:00 2001 From: eshna Date: Mon, 13 Nov 2017 15:34:35 -0700 Subject: [PATCH 2/2] update to unit tests --- .../cmput301f17t11/cupofjava/HabitEventHistoryTests.java} | 6 +++--- .../java/com/cmput301f17t11/cupofjava/HabitListTest.java | 0 .../com/cmput301f17t11/cupofjava/UserLoginActivityTest.java | 1 + .../com/cmput301f17t11/cupofjava/AllHabitViewActivity.java | 4 ++++ 4 files changed, 8 insertions(+), 3 deletions(-) rename app/src/{test/java/com/cmput301f17t11/cupofjava/HabitEventHistoryTest.java => androidTest/java/com/cmput301f17t11/cupofjava/HabitEventHistoryTests.java} (96%) rename app/src/{test => androidTest}/java/com/cmput301f17t11/cupofjava/HabitListTest.java (100%) diff --git a/app/src/test/java/com/cmput301f17t11/cupofjava/HabitEventHistoryTest.java b/app/src/androidTest/java/com/cmput301f17t11/cupofjava/HabitEventHistoryTests.java similarity index 96% rename from app/src/test/java/com/cmput301f17t11/cupofjava/HabitEventHistoryTest.java rename to app/src/androidTest/java/com/cmput301f17t11/cupofjava/HabitEventHistoryTests.java index bb37510..281f4c3 100644 --- a/app/src/test/java/com/cmput301f17t11/cupofjava/HabitEventHistoryTest.java +++ b/app/src/androidTest/java/com/cmput301f17t11/cupofjava/HabitEventHistoryTests.java @@ -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); } @@ -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(); diff --git a/app/src/test/java/com/cmput301f17t11/cupofjava/HabitListTest.java b/app/src/androidTest/java/com/cmput301f17t11/cupofjava/HabitListTest.java similarity index 100% rename from app/src/test/java/com/cmput301f17t11/cupofjava/HabitListTest.java rename to app/src/androidTest/java/com/cmput301f17t11/cupofjava/HabitListTest.java diff --git a/app/src/androidTest/java/com/cmput301f17t11/cupofjava/UserLoginActivityTest.java b/app/src/androidTest/java/com/cmput301f17t11/cupofjava/UserLoginActivityTest.java index 6420d85..6af5496 100644 --- a/app/src/androidTest/java/com/cmput301f17t11/cupofjava/UserLoginActivityTest.java +++ b/app/src/androidTest/java/com/cmput301f17t11/cupofjava/UserLoginActivityTest.java @@ -109,6 +109,7 @@ public void testLogin(){ 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); diff --git a/app/src/main/java/com/cmput301f17t11/cupofjava/AllHabitViewActivity.java b/app/src/main/java/com/cmput301f17t11/cupofjava/AllHabitViewActivity.java index 40d700a..b85cf6e 100644 --- a/app/src/main/java/com/cmput301f17t11/cupofjava/AllHabitViewActivity.java +++ b/app/src/main/java/com/cmput301f17t11/cupofjava/AllHabitViewActivity.java @@ -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);