forked from federicoiosue/Omni-Notes
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More tests for reminders' RecurrenceRules workflows
- Loading branch information
1 parent
0ff8e2a
commit 6a64dd2
Showing
7 changed files
with
162 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
omniNotes/src/androidTest/java/it/feio/android/omninotes/RecurrenceRuleTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/* | ||
* Copyright (C) 2013-2019 Federico Iosue ([email protected]) | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package it.feio.android.omninotes; | ||
|
||
import static androidx.test.espresso.Espresso.onView; | ||
import static androidx.test.espresso.action.ViewActions.click; | ||
import static androidx.test.espresso.assertion.ViewAssertions.matches; | ||
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; | ||
import static androidx.test.espresso.matcher.ViewMatchers.withContentDescription; | ||
import static androidx.test.espresso.matcher.ViewMatchers.withId; | ||
import static androidx.test.espresso.matcher.ViewMatchers.withText; | ||
import static org.hamcrest.Matchers.allOf; | ||
|
||
import androidx.test.ext.junit.runners.AndroidJUnit4; | ||
import it.feio.android.omninotes.helpers.date.RecurrenceHelper; | ||
import it.feio.android.omninotes.models.Note; | ||
import java.util.Calendar; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
@RunWith(AndroidJUnit4.class) | ||
public class RecurrenceRuleTest extends BaseEspressoTest { | ||
|
||
private Note testNote; | ||
|
||
@Before | ||
@Override | ||
public void setUp () throws Exception { | ||
super.setUp(); | ||
testNote = new Note(); | ||
testNote.setTitle("Title 1"); | ||
Calendar c = Calendar.getInstance(); | ||
c.add(Calendar.MINUTE, 2); | ||
testNote.setAlarm(c.getTimeInMillis()); | ||
testNote.setRecurrenceRule("FREQ=WEEKLY;WKST=MO;BYDAY=MO,TU,TH"); | ||
dbHelper.updateNote(testNote, false); | ||
} | ||
|
||
@Test | ||
public void recurrenceRuleTextHasValue () throws InterruptedException { | ||
|
||
Thread.sleep(1500); | ||
|
||
onView(allOf(withId(R.id.menu_sort), withContentDescription("Sort"), | ||
childAtPosition( | ||
childAtPosition( | ||
withId(R.id.toolbar), | ||
2), | ||
1), | ||
isDisplayed())).perform(click()); | ||
|
||
Thread.sleep(1500); | ||
|
||
onView(allOf(withId(R.id.title), withText("Creation date"), | ||
childAtPosition( | ||
childAtPosition( | ||
withId(R.id.content), | ||
0), | ||
0), | ||
isDisplayed())).perform(click()); | ||
|
||
selectNoteInList(0); | ||
|
||
String expectedText = RecurrenceHelper.getNoteRecurrentReminderText(Long.parseLong(testNote.getAlarm()), | ||
testNote.getRecurrenceRule()); | ||
onView(withId(R.id.datetime)).check(matches(withText(expectedText))); | ||
} | ||
|
||
} |
39 changes: 39 additions & 0 deletions
39
...Notes/src/androidTest/java/it/feio/android/omninotes/utils/date/RecurrenceHelperTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright (C) 2013-2019 Federico Iosue ([email protected]) | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package it.feio.android.omninotes.utils.date; | ||
|
||
import androidx.test.ext.junit.runners.AndroidJUnit4; | ||
import it.feio.android.omninotes.helpers.date.RecurrenceHelper; | ||
import java.util.Calendar; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
@RunWith(AndroidJUnit4.class) | ||
public class RecurrenceHelperTest { | ||
|
||
@Test | ||
public void testGetNoteRecurrentReminderText () { | ||
long reminder = 1577369824425L; | ||
String rrule = "FREQ=WEEKLY;WKST=MO;BYDAY=MO,TU,TH"; | ||
String alarmText = RecurrenceHelper.getNoteRecurrentReminderText(reminder, rrule); | ||
|
||
Assert.assertEquals("Weekly on Mon, Tue, Thu starting from Thu, Dec 26 3:17 PM", alarmText); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters