Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ru.bossnote.test.UC;
- import android.app.Instrumentation;
- import android.content.res.Resources;
- import android.content.Context;
- import android.test.ActivityInstrumentationTestCase2;
- import android.util.Log;
- import android.support.v4.app.Fragment;
- import com.robotium.solo.Solo;
- import java.lang.Object;
- import java.util.*;
- import java.text.DateFormat;
- import java.text.ParseException;
- import java.text.SimpleDateFormat;
- import java.util.Calendar;
- import java.util.Date;
- import java.util.GregorianCalendar;
- import ru.bossnote.R;
- import com.simplanum.*;
- import ru.simplanum.entry.SPLaunch;
- import ru.simplanum.phone.SPPhone;
- import static com.simplanum.actions.AttachmentViewerActions.*;
- import static com.simplanum.actions.AuthActions.*;
- import static com.simplanum.actions.EventActions.*;
- import static com.simplanum.actions.NoteEditActions.*;
- import static com.simplanum.actions.NotepadActions.*;
- import static com.simplanum.actions.WeekCalendarActions.*;
- import static com.simplanum.actions.MonthCalendarActions.*;
- import static com.simplanum.actions.DiaryActions.*;
- import static com.simplanum.actions.BrowserActions.*;
- import static com.simplanum.actions.SettingsActions.*;
- import static com.simplanum.actions.GeolocationActions.*;
- import static com.simplanum.actions.DateAndTimeActions.*;
- import static junit.framework.Assert.*;
- import static utils.Utils.*;
- import com.robotium.solo.Solo;
- import com.simplanum.actions.DateAndTimeActions;
- import junit.framework.TestCase;
- public class Courier {
- private static String LOGIN = "courier@adr.at";
- private static String PASSWORD = "test";
- public static void var1(Solo solo, Instrumentation instrumentation){
- closeBugReportIfNeed(solo);
- logoutIfNeed(solo, instrumentation);
- login(solo, LOGIN, PASSWORD);
- //2
- newNote(solo);
- typeText(solo, "Adress1");
- clickOnAcceptButton(solo);
- solo.sleep(5000);//добавить гео
- assertTrue("Count of attachments doesn't match.", getAttachmentsCount(solo) == 1);
- swipeAttachmentsToEnd(solo);
- assertTrue("Buttons for attachments adding are invisible.",
- solo.getView(R.id.editor_attach_add_filemanager).isShown()
- & solo.getView(R.id.editor_attach_add_photo).isShown()
- & solo.getView(R.id.editor_attach_add_geo).isShown());
- solo.sleep(5000);//добавить гео
- assertTrue("Count of attachments doesn't match.", getAttachmentsCount(solo) == 2);
- swipeAttachmentsToEnd(solo);
- solo.sleep(5000);//добавить гео
- assertTrue("Count of attachments doesn't match.", getAttachmentsCount(solo) == 3);
- solo.goBack();
- assertTrue("Text is incorrect", getTextByIndex(solo, 0, instrumentation).equals("Adress1"));
- assertTrue("Attachments count is incorrect.", getAttachmentsCountByIndexInList(solo, 0, instrumentation) == 3);
- //3
- newNote(solo);
- typeText(solo, "Adresse");
- clickOnAcceptButton(solo);
- assertTrue("Text didn't saved.", getText(solo).startsWith("Adresse"));
- swipeEventFlag(solo);
- solo.sleep(2000);
- scrollDatePicker(solo, 1, true);
- if(getHour(0) > 10) clickOnAfterMidday(solo);
- setTime(solo, 10, 0);
- setEventDuration(solo, instrumentation, 120);
- setNotification(solo, instrumentation, 1, 6);
- clickOnSave(solo);
- solo.sleep(2000);
- assertTrue("Incorrect date on event flag",
- getDateFromFlag(solo).equals(dateToString(1) +" 10:00 - 12:00 "));
- assertTrue("Notification icon is invisible", checkNotificationIcon(solo));
- solo.sleep(5000);//добавить гео
- assertTrue("Incorrect attachments count", getAttachmentsCount(solo) == 1);
- solo.goBack();
- assertTrue("Incorrect text of event in notepad",
- getTextByIndex(solo, 0, instrumentation).startsWith("Adresse"));
- assertTrue("Incorrect date on event flag",
- getEventDateByIndexInNotepad(solo, 0, instrumentation).equals(dateToString(1) +" 10:00-12:00"));
- assertTrue("Notification icon is invisible", checkNotificationIcon(solo, 0, instrumentation));
- assertTrue("Incorrect attachments count",
- getAttachmentsCountByIndexInList(solo, 0, instrumentation) == 1);
- //4
- newNote(solo);
- typeText(solo, "Text");
- openEventEdit(solo);
- scrollDatePicker(solo, 1, true);
- if(getHour(0) >13) clickOnAfterMidday(solo);
- setTime(solo, 13, 0);
- setNotification(solo, instrumentation, 1, 5);
- solo.sleep(2000);
- clickOnSave(solo);
- clickOnAcceptButton(solo);
- solo.sleep(3000);
- assertTrue("Text didn't saved.", getText(solo).startsWith("Text"));
- assertTrue("Incorrect date on event flag",
- getDateFromFlag(solo).equals(dateToString(1) +" 13:00 - 13:30 "));
- assertTrue("Notification icon is invisible", checkNotificationIcon(solo));
- solo.sleep(1000);
- solo.goBack();
- assertTrue("Incorrect text of event in notepad",
- getTextByIndex(solo, 0, instrumentation).startsWith("Text"));
- assertTrue("Incorrect date on event flag",
- getEventDateByIndexInNotepad(solo, 0, instrumentation).equals(dateToString(1) +" 13:00-13:30"));
- assertTrue("Notification icon is invisible", checkNotificationIcon(solo, 0, instrumentation));
- }
- public static void var2(Solo solo, Instrumentation instrumentation){
- closeBugReportIfNeed(solo);
- loginIfNeed(solo, LOGIN, PASSWORD);
- //1
- openNoteByText(solo, "Text");
- removeNote(solo);
- for (int i = 0; i < getNotesCount(solo); i++)
- assertTrue("Note didn't deleted",
- !(getTextByIndex(solo, i, instrumentation).startsWith("Text")));
- newNote(solo);
- typeText(solo, "Adresse");
- clickOnAcceptButton(solo);
- solo.sleep(1000);
- assertTrue("Text didn't saved.", getText(solo).startsWith("Adresse"));
- solo.goBack();
- assertTrue("Incorrect text of note in notepad",
- getTextByIndex(solo, 0, instrumentation).startsWith("Adresse"));
- //2
- openNoteByText(solo, "Adress1");
- typeText(solo, "");
- clearText(solo);
- typeText(solo, "Adres");
- clickOnAcceptButton(solo);
- assertTrue("", getText(solo).startsWith("Adres"));
- openAttachmentFromNoteView(solo);
- clickOnRemove(solo);
- clickOnNext(solo);
- clickOnRemove(solo);
- solo.goBack();
- assertTrue("Attachments didn't deleted", getAttachmentsCount(solo) == 1);
- solo.goBack();
- assertTrue("Text didn't saved.", getTextByIndex(solo, 0, instrumentation).startsWith("Adres"));
- assertTrue("Attachments count didnt changed", getAttachmentsCountByIndexInList(solo, 0, instrumentation) == 1);
- //3
- toggleMultiSelectModeByIndex(solo, instrumentation, getIndexByText(solo, "Pay for internet during walk", instrumentation));
- selectNoteWithMultiselect(solo, getIndexByText(solo, "Take meal to work!!!", instrumentation), instrumentation);
- selectNoteWithMultiselect(solo, getIndexByText(solo, "Work", instrumentation), instrumentation);
- selectNoteWithMultiselect(solo, getIndexByText(solo, "Adress2", instrumentation), instrumentation);
- assertTrue("Any of items didn't selected", getSelectedEventsCount(solo) == 3);
- assertTrue("Any of items didn't selected", getSelectedNotesCount(solo) == 1);
- }
- public static void var3(Solo solo, Instrumentation instrumentation){
- closeBugReportIfNeed(solo);
- loginIfNeed(solo, LOGIN, PASSWORD);
- //1
- openNoteByText(solo, "Take letters to adresses: 2. Gor'kogo 27, letter to Salahova Angelina.");
- openEventEdit(solo);
- scrollDatePicker(solo, 1, true);
- if (getHour(0)>9) clickOnAfterMidday(solo);
- setTime(solo, 9, 0);
- setEventDuration(solo, instrumentation, 60);
- setNotification(solo, instrumentation, 1, 5);
- clickOnSave(solo);
- Log.d("date", getDateFromFlag(solo));
- Log.d("date", dateToString(1) + " 9:00 - 10:00");
- assertTrue("Date saved incorrectly.", getDateFromFlag(solo).startsWith(dateToString(1) + " 09:00 - 10:00"));
- assertTrue("Notificationicon is invisible", checkNotificationIcon(solo));
- typeText(solo, "QUICKLY!!!");
- clickOnAcceptButton(solo);
- assertTrue("Text didn't saved.", getText(solo).startsWith("Take letters to adresses: 2. Gor'kogo 27, letter to Salahova Angelina.QUICKLY!!!"));
- assertTrue("Date saved incorrectly.", getDateFromFlag(solo).startsWith(dateToString(1) + " 09:00 - 10:00"));
- assertTrue("Notificationicon is invisible", checkNotificationIcon(solo));
- solo.goBack();
- assertTrue("Text didn't saved.", getTextByIndex(solo, 0, instrumentation).startsWith("Take letters to adresses: 2. Gor'kogo 27, letter to Salahova Angelina.QUICKLY!!!"));
- assertTrue("Date saved incorrectly.", getEventDateByIndexInNotepad(solo, 0, instrumentation).startsWith(dateToString(1) + " 09:00-10:00"));
- assertTrue("Notificationicon is invisible", checkNotificationIcon(solo, 0, instrumentation));
- //2
- // openNoteByText(solo, "");
- // //удалить две строки
- // clickOnAcceptButton(solo);
- // assertTrue("Incorrect text", getText(solo).startsWith(""));
- // solo.goBack();
- // assertTrue("Incorrect text", getTextByIndex(solo, 0, instrumentation).startsWith(""));
- //3
- newNote(solo);
- typeText(solo, "Give bookkeeping reports to N.Ivanovna before midday");
- solo.sleep(2000);
- openEventEdit(solo);
- scrollDatePicker(solo, 1, true);
- if (getHour(0)>9) clickOnAfterMidday(solo);
- setTime(solo, 9, 0);
- setEventDuration(solo, instrumentation, 180);
- setNotification(solo, instrumentation, 1, 1);
- clickOnSave(solo);
- clickOnAcceptButton(solo);
- assertTrue("Text didn't saved.", getText(solo).startsWith("Give bookkeeping reports to N.Ivanovna before midday"));
- assertTrue("Date saved incorrectly.", getDateFromFlag(solo).startsWith(dateToString(1) + " 09:00 - 12:00"));
- assertTrue("Notificationicon is invisible", checkNotificationIcon(solo));
- solo.goBack();
- assertTrue("Text didn't saved.", getTextByIndex(solo, 0, instrumentation).startsWith("Give bookkeeping reports to N.Ivanovna before midday"));
- assertTrue("Date saved incorrectly.", getEventDateByIndexInNotepad(solo, 0, instrumentation).startsWith(dateToString(1) + " 09:00-10:00"));
- assertTrue("Notificationicon is invisible", checkNotificationIcon(solo, 0, instrumentation));
- }
- public static void var4(Solo solo, Instrumentation instrumentation){
- closeBugReportIfNeed(solo);
- loginIfNeed(solo, LOGIN, PASSWORD);
- //1
- newNote(solo);
- typeText(solo, solo.getString(R.string.adress3));
- clickOnAcceptButton(solo);
- assertTrue("Text didn't saved.", getText(solo).startsWith( solo.getString(R.string.adress3)));
- solo.goBack();
- solo.sleep(2000);
- Log.d("text1", getTextByIndex(solo, 0, instrumentation));
- Log.d("text1", solo.getString(R.string.adress3));
- assertTrue("Text didn't saved.", getTextByIndex(solo, 0, instrumentation).startsWith( solo.getString(R.string.adress3)));
- //2
- openNoteByText(solo, solo.getString(R.string.adress3), instrumentation);
- typeText(solo, "");
- //скопировать текст
- clickOnCloseTextEdit(solo);
- assertTrue("Text changed.", getText(solo).startsWith( solo.getString(R.string.adress3)));
- solo.goBack();
- assertTrue("Text changed.", getTextByIndex(solo, 0, instrumentation).startsWith( solo.getString(R.string.adress3)));
- newEvent(solo);
- scrollDatePicker(solo, 1, true);
- if(getHour(0) > 12) clickOnAfterMidday(solo);
- setTime(solo, 12, 0);
- setEventDuration(solo, instrumentation, 90);
- setNotification(solo, instrumentation, 1, 4);
- clickOnSave(solo);
- //вставить текст
- typeText(solo, solo.getString(R.string.adress3));
- clickOnAcceptButton(solo);
- assertTrue("Text didn't saved.", getText(solo).startsWith(solo.getString(R.string.adress3)));
- assertTrue("Date saved incorrectly.", getDateFromFlag(solo).startsWith(dateToString(1) + " 12:00 - 13:30"));
- assertTrue("Notificationicon is invisible", checkNotificationIcon(solo));
- //добавить гео
- solo.sleep(5000);
- assertTrue("Attachments count doesn't match", getAttachmentsCount(solo) == 1);
- solo.goBack();
- assertTrue("Text didn't saved.", getTextByIndex(solo, 0, instrumentation).startsWith(solo.getString(R.string.adress3)));
- assertTrue("Date saved incorrectly.", getEventDateByIndexInNotepad(solo, 0, instrumentation).startsWith(dateToString(1) + " 12:00-13:30"));
- assertTrue("Notificationicon is invisible", checkNotificationIcon(solo, 0, instrumentation));
- assertTrue("Attachments count doesn't match" ,getAttachmentsCountByIndexInList(solo, 0, instrumentation) == 1);
- //3
- //4
- newNote(solo);
- typeText(solo, solo.getString(R.string.how_to_drive));
- clickOnAcceptButton(solo);
- assertTrue("Text didn't saved.", getText(solo).startsWith( solo.getString(R.string.how_to_drive)));
- solo.goBack();
- assertTrue("Text didn't saved.", getTextByIndex(solo, 0, instrumentation)
- .startsWith( solo.getString(R.string.how_to_drive)));
- }
- public static void var5(Solo solo, Instrumentation instrumentation){
- closeBugReportIfNeed(solo);
- loginIfNeed(solo, LOGIN, PASSWORD);
- //1
- moveFromNotepadToCalendar(solo);
- openMonthCalendar(solo);
- swipeTo(solo, 1);
- tapToDay(solo, 23);
- clickOnTime(solo, instrumentation, 8, 0);
- //растянуть до 10
- setEventDuration(solo, instrumentation, 120);
- clickOnSave(solo);
- typeText(solo, solo.getString(R.string.salary));
- clickOnAcceptButton(solo);
- assertTrue("Text didn't saved.", getText(solo).startsWith(solo.getString(R.string.salary)));
- assertTrue("Date saved incorrectly.", getDateFromFlag(solo)
- .startsWith("25 " + getMonthName(1) + " " + getYear(0) + " 08:00 - 10:00"));
- solo.goBack();
- //проверка отображения в календаре
- moveFromCalendarToNotepad(solo);
- assertTrue("Text didn't saved.", getTextByIndex(solo, 0, instrumentation)
- .startsWith(solo.getString(R.string.salary)));
- assertTrue("Date saved incorrectly.",
- getEventDateByIndexInNotepad(solo, 0, instrumentation)
- .startsWith("25 " + getMonthName(1) + " " + getYear(0) + " 08:00-10:00"));
- //2
- newNote(solo);
- typeText(solo, "Buy laptop");
- clickOnAcceptButton(solo);
- assertTrue("Text didn't saved.", getText(solo).startsWith("Buy laptop"));
- solo.sleep(5000);//addPhoto(solo);
- assertTrue("Attachment count doesn't match", getAttachmentsCount(solo) == 1);
- swipeAttachmentsToEnd(solo);
- solo.sleep(5000);//addPhoto(solo);
- assertTrue("Attachment count doesn't match", getAttachmentsCount(solo) == 2);
- solo.goBack();
- assertTrue("Text didn't saved.", getTextByIndex(solo, 0, instrumentation)
- .startsWith("Buy laptop"));
- assertTrue("Attachment count doesn't match",
- getAttachmentsCountByIndexInList(solo, 0, instrumentation) == 2);
- //3
- moveFromNotepadToCalendar(solo);
- //clickOnHome(solo);
- int n = getDayOfWeek(0) - 1;
- moveCalendarToOffset(solo, instrumentation, 8 - n); //на ближайший понедельник
- clickOnTime(solo, instrumentation, 8, 0);
- clickOnSave(solo);
- openEventEdit(solo);
- if (getHour(0) > 8) clickOnAfterMidday(solo);
- setTime(solo, 8, 0);
- setEventDuration(solo, instrumentation, 480);
- setNotification(solo, instrumentation, 1, 6);
- setNotification(solo, instrumentation, 2, 5);
- clickOnSave(solo);
- typeText(solo, "work");
- clickOnAcceptButton(solo);
- assertTrue("Text didn't saved.", getText(solo).startsWith("work"));
- assertTrue("Date saved incorrectly.", getDateFromFlag(solo).startsWith(dateToString(7 - n) + " 8:00 - 16:00"));
- assertTrue("Notification icon is invisible", checkNotificationIcon(solo));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement