Advertisement
Guest User

Untitled

a guest
Nov 24th, 2014
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.21 KB | None | 0 0
  1. package ru.bossnote.test.UC;
  2.  
  3. import android.app.Instrumentation;
  4. import android.content.res.Resources;
  5. import android.content.Context;
  6. import android.test.ActivityInstrumentationTestCase2;
  7. import android.util.Log;
  8. import android.support.v4.app.Fragment;
  9.  
  10. import com.robotium.solo.Solo;
  11.  
  12. import java.lang.Object;
  13. import java.util.*;
  14. import java.text.DateFormat;
  15. import java.text.ParseException;
  16. import java.text.SimpleDateFormat;
  17. import java.util.Calendar;
  18. import java.util.Date;
  19. import java.util.GregorianCalendar;
  20.  
  21. import ru.bossnote.R;
  22. import com.simplanum.*;
  23. import ru.simplanum.entry.SPLaunch;
  24. import ru.simplanum.phone.SPPhone;
  25.  
  26. import static com.simplanum.actions.AttachmentViewerActions.*;
  27. import static com.simplanum.actions.AuthActions.*;
  28. import static com.simplanum.actions.EventActions.*;
  29. import static com.simplanum.actions.NoteEditActions.*;
  30. import static com.simplanum.actions.NotepadActions.*;
  31. import static com.simplanum.actions.WeekCalendarActions.*;
  32. import static com.simplanum.actions.MonthCalendarActions.*;
  33. import static com.simplanum.actions.DiaryActions.*;
  34. import static com.simplanum.actions.BrowserActions.*;
  35. import static com.simplanum.actions.SettingsActions.*;
  36. import static com.simplanum.actions.GeolocationActions.*;
  37. import static com.simplanum.actions.DateAndTimeActions.*;
  38. import static junit.framework.Assert.*;
  39. import static utils.Utils.*;
  40.  
  41. import com.robotium.solo.Solo;
  42. import com.simplanum.actions.DateAndTimeActions;
  43.  
  44. import junit.framework.TestCase;
  45.  
  46. public class Courier {
  47. private static String LOGIN = "courier@adr.at";
  48. private static String PASSWORD = "test";
  49.  
  50. public static void var1(Solo solo, Instrumentation instrumentation){
  51. closeBugReportIfNeed(solo);
  52. logoutIfNeed(solo, instrumentation);
  53. login(solo, LOGIN, PASSWORD);
  54.  
  55. //2
  56. newNote(solo);
  57. typeText(solo, "Adress1");
  58. clickOnAcceptButton(solo);
  59. solo.sleep(5000);//добавить гео
  60. assertTrue("Count of attachments doesn't match.", getAttachmentsCount(solo) == 1);
  61. swipeAttachmentsToEnd(solo);
  62. assertTrue("Buttons for attachments adding are invisible.",
  63. solo.getView(R.id.editor_attach_add_filemanager).isShown()
  64. & solo.getView(R.id.editor_attach_add_photo).isShown()
  65. & solo.getView(R.id.editor_attach_add_geo).isShown());
  66. solo.sleep(5000);//добавить гео
  67. assertTrue("Count of attachments doesn't match.", getAttachmentsCount(solo) == 2);
  68. swipeAttachmentsToEnd(solo);
  69. solo.sleep(5000);//добавить гео
  70. assertTrue("Count of attachments doesn't match.", getAttachmentsCount(solo) == 3);
  71. solo.goBack();
  72. assertTrue("Text is incorrect", getTextByIndex(solo, 0, instrumentation).equals("Adress1"));
  73. assertTrue("Attachments count is incorrect.", getAttachmentsCountByIndexInList(solo, 0, instrumentation) == 3);
  74.  
  75. //3
  76. newNote(solo);
  77. typeText(solo, "Adresse");
  78. clickOnAcceptButton(solo);
  79. assertTrue("Text didn't saved.", getText(solo).startsWith("Adresse"));
  80. swipeEventFlag(solo);
  81. solo.sleep(2000);
  82. scrollDatePicker(solo, 1, true);
  83. if(getHour(0) > 10) clickOnAfterMidday(solo);
  84. setTime(solo, 10, 0);
  85. setEventDuration(solo, instrumentation, 120);
  86. setNotification(solo, instrumentation, 1, 6);
  87. clickOnSave(solo);
  88. solo.sleep(2000);
  89. assertTrue("Incorrect date on event flag",
  90. getDateFromFlag(solo).equals(dateToString(1) +" 10:00 - 12:00 "));
  91. assertTrue("Notification icon is invisible", checkNotificationIcon(solo));
  92. solo.sleep(5000);//добавить гео
  93. assertTrue("Incorrect attachments count", getAttachmentsCount(solo) == 1);
  94. solo.goBack();
  95. assertTrue("Incorrect text of event in notepad",
  96. getTextByIndex(solo, 0, instrumentation).startsWith("Adresse"));
  97. assertTrue("Incorrect date on event flag",
  98. getEventDateByIndexInNotepad(solo, 0, instrumentation).equals(dateToString(1) +" 10:00-12:00"));
  99. assertTrue("Notification icon is invisible", checkNotificationIcon(solo, 0, instrumentation));
  100. assertTrue("Incorrect attachments count",
  101. getAttachmentsCountByIndexInList(solo, 0, instrumentation) == 1);
  102.  
  103. //4
  104. newNote(solo);
  105. typeText(solo, "Text");
  106. openEventEdit(solo);
  107. scrollDatePicker(solo, 1, true);
  108. if(getHour(0) >13) clickOnAfterMidday(solo);
  109. setTime(solo, 13, 0);
  110. setNotification(solo, instrumentation, 1, 5);
  111. solo.sleep(2000);
  112. clickOnSave(solo);
  113. clickOnAcceptButton(solo);
  114. solo.sleep(3000);
  115. assertTrue("Text didn't saved.", getText(solo).startsWith("Text"));
  116. assertTrue("Incorrect date on event flag",
  117. getDateFromFlag(solo).equals(dateToString(1) +" 13:00 - 13:30 "));
  118. assertTrue("Notification icon is invisible", checkNotificationIcon(solo));
  119. solo.sleep(1000);
  120. solo.goBack();
  121. assertTrue("Incorrect text of event in notepad",
  122. getTextByIndex(solo, 0, instrumentation).startsWith("Text"));
  123. assertTrue("Incorrect date on event flag",
  124. getEventDateByIndexInNotepad(solo, 0, instrumentation).equals(dateToString(1) +" 13:00-13:30"));
  125. assertTrue("Notification icon is invisible", checkNotificationIcon(solo, 0, instrumentation));
  126. }
  127.  
  128. public static void var2(Solo solo, Instrumentation instrumentation){
  129. closeBugReportIfNeed(solo);
  130. loginIfNeed(solo, LOGIN, PASSWORD);
  131.  
  132. //1
  133. openNoteByText(solo, "Text");
  134. removeNote(solo);
  135. for (int i = 0; i < getNotesCount(solo); i++)
  136. assertTrue("Note didn't deleted",
  137. !(getTextByIndex(solo, i, instrumentation).startsWith("Text")));
  138. newNote(solo);
  139. typeText(solo, "Adresse");
  140. clickOnAcceptButton(solo);
  141. solo.sleep(1000);
  142. assertTrue("Text didn't saved.", getText(solo).startsWith("Adresse"));
  143. solo.goBack();
  144. assertTrue("Incorrect text of note in notepad",
  145. getTextByIndex(solo, 0, instrumentation).startsWith("Adresse"));
  146.  
  147. //2
  148. openNoteByText(solo, "Adress1");
  149. typeText(solo, "");
  150. clearText(solo);
  151. typeText(solo, "Adres");
  152. clickOnAcceptButton(solo);
  153. assertTrue("", getText(solo).startsWith("Adres"));
  154. openAttachmentFromNoteView(solo);
  155. clickOnRemove(solo);
  156. clickOnNext(solo);
  157. clickOnRemove(solo);
  158. solo.goBack();
  159. assertTrue("Attachments didn't deleted", getAttachmentsCount(solo) == 1);
  160. solo.goBack();
  161. assertTrue("Text didn't saved.", getTextByIndex(solo, 0, instrumentation).startsWith("Adres"));
  162. assertTrue("Attachments count didnt changed", getAttachmentsCountByIndexInList(solo, 0, instrumentation) == 1);
  163.  
  164. //3
  165. toggleMultiSelectModeByIndex(solo, instrumentation, getIndexByText(solo, "Pay for internet during walk", instrumentation));
  166. selectNoteWithMultiselect(solo, getIndexByText(solo, "Take meal to work!!!", instrumentation), instrumentation);
  167. selectNoteWithMultiselect(solo, getIndexByText(solo, "Work", instrumentation), instrumentation);
  168. selectNoteWithMultiselect(solo, getIndexByText(solo, "Adress2", instrumentation), instrumentation);
  169. assertTrue("Any of items didn't selected", getSelectedEventsCount(solo) == 3);
  170. assertTrue("Any of items didn't selected", getSelectedNotesCount(solo) == 1);
  171. }
  172.  
  173. public static void var3(Solo solo, Instrumentation instrumentation){
  174. closeBugReportIfNeed(solo);
  175. loginIfNeed(solo, LOGIN, PASSWORD);
  176.  
  177. //1
  178. openNoteByText(solo, "Take letters to adresses: 2. Gor'kogo 27, letter to Salahova Angelina.");
  179. openEventEdit(solo);
  180. scrollDatePicker(solo, 1, true);
  181. if (getHour(0)>9) clickOnAfterMidday(solo);
  182. setTime(solo, 9, 0);
  183. setEventDuration(solo, instrumentation, 60);
  184. setNotification(solo, instrumentation, 1, 5);
  185. clickOnSave(solo);
  186. Log.d("date", getDateFromFlag(solo));
  187. Log.d("date", dateToString(1) + " 9:00 - 10:00");
  188. assertTrue("Date saved incorrectly.", getDateFromFlag(solo).startsWith(dateToString(1) + " 09:00 - 10:00"));
  189. assertTrue("Notificationicon is invisible", checkNotificationIcon(solo));
  190. typeText(solo, "QUICKLY!!!");
  191. clickOnAcceptButton(solo);
  192. assertTrue("Text didn't saved.", getText(solo).startsWith("Take letters to adresses: 2. Gor'kogo 27, letter to Salahova Angelina.QUICKLY!!!"));
  193. assertTrue("Date saved incorrectly.", getDateFromFlag(solo).startsWith(dateToString(1) + " 09:00 - 10:00"));
  194. assertTrue("Notificationicon is invisible", checkNotificationIcon(solo));
  195. solo.goBack();
  196. assertTrue("Text didn't saved.", getTextByIndex(solo, 0, instrumentation).startsWith("Take letters to adresses: 2. Gor'kogo 27, letter to Salahova Angelina.QUICKLY!!!"));
  197. assertTrue("Date saved incorrectly.", getEventDateByIndexInNotepad(solo, 0, instrumentation).startsWith(dateToString(1) + " 09:00-10:00"));
  198. assertTrue("Notificationicon is invisible", checkNotificationIcon(solo, 0, instrumentation));
  199.  
  200. //2
  201. // openNoteByText(solo, "");
  202. // //удалить две строки
  203. // clickOnAcceptButton(solo);
  204. // assertTrue("Incorrect text", getText(solo).startsWith(""));
  205. // solo.goBack();
  206. // assertTrue("Incorrect text", getTextByIndex(solo, 0, instrumentation).startsWith(""));
  207.  
  208. //3
  209. newNote(solo);
  210. typeText(solo, "Give bookkeeping reports to N.Ivanovna before midday");
  211. solo.sleep(2000);
  212. openEventEdit(solo);
  213. scrollDatePicker(solo, 1, true);
  214. if (getHour(0)>9) clickOnAfterMidday(solo);
  215. setTime(solo, 9, 0);
  216. setEventDuration(solo, instrumentation, 180);
  217. setNotification(solo, instrumentation, 1, 1);
  218. clickOnSave(solo);
  219. clickOnAcceptButton(solo);
  220. assertTrue("Text didn't saved.", getText(solo).startsWith("Give bookkeeping reports to N.Ivanovna before midday"));
  221. assertTrue("Date saved incorrectly.", getDateFromFlag(solo).startsWith(dateToString(1) + " 09:00 - 12:00"));
  222. assertTrue("Notificationicon is invisible", checkNotificationIcon(solo));
  223. solo.goBack();
  224. assertTrue("Text didn't saved.", getTextByIndex(solo, 0, instrumentation).startsWith("Give bookkeeping reports to N.Ivanovna before midday"));
  225. assertTrue("Date saved incorrectly.", getEventDateByIndexInNotepad(solo, 0, instrumentation).startsWith(dateToString(1) + " 09:00-10:00"));
  226. assertTrue("Notificationicon is invisible", checkNotificationIcon(solo, 0, instrumentation));
  227. }
  228.  
  229. public static void var4(Solo solo, Instrumentation instrumentation){
  230. closeBugReportIfNeed(solo);
  231. loginIfNeed(solo, LOGIN, PASSWORD);
  232.  
  233. //1
  234. newNote(solo);
  235. typeText(solo, solo.getString(R.string.adress3));
  236. clickOnAcceptButton(solo);
  237. assertTrue("Text didn't saved.", getText(solo).startsWith( solo.getString(R.string.adress3)));
  238. solo.goBack();
  239. solo.sleep(2000);
  240. Log.d("text1", getTextByIndex(solo, 0, instrumentation));
  241. Log.d("text1", solo.getString(R.string.adress3));
  242. assertTrue("Text didn't saved.", getTextByIndex(solo, 0, instrumentation).startsWith( solo.getString(R.string.adress3)));
  243.  
  244. //2
  245. openNoteByText(solo, solo.getString(R.string.adress3), instrumentation);
  246. typeText(solo, "");
  247. //скопировать текст
  248. clickOnCloseTextEdit(solo);
  249. assertTrue("Text changed.", getText(solo).startsWith( solo.getString(R.string.adress3)));
  250. solo.goBack();
  251. assertTrue("Text changed.", getTextByIndex(solo, 0, instrumentation).startsWith( solo.getString(R.string.adress3)));
  252. newEvent(solo);
  253. scrollDatePicker(solo, 1, true);
  254. if(getHour(0) > 12) clickOnAfterMidday(solo);
  255. setTime(solo, 12, 0);
  256. setEventDuration(solo, instrumentation, 90);
  257. setNotification(solo, instrumentation, 1, 4);
  258. clickOnSave(solo);
  259. //вставить текст
  260. typeText(solo, solo.getString(R.string.adress3));
  261. clickOnAcceptButton(solo);
  262. assertTrue("Text didn't saved.", getText(solo).startsWith(solo.getString(R.string.adress3)));
  263. assertTrue("Date saved incorrectly.", getDateFromFlag(solo).startsWith(dateToString(1) + " 12:00 - 13:30"));
  264. assertTrue("Notificationicon is invisible", checkNotificationIcon(solo));
  265. //добавить гео
  266. solo.sleep(5000);
  267. assertTrue("Attachments count doesn't match", getAttachmentsCount(solo) == 1);
  268. solo.goBack();
  269. assertTrue("Text didn't saved.", getTextByIndex(solo, 0, instrumentation).startsWith(solo.getString(R.string.adress3)));
  270. assertTrue("Date saved incorrectly.", getEventDateByIndexInNotepad(solo, 0, instrumentation).startsWith(dateToString(1) + " 12:00-13:30"));
  271. assertTrue("Notificationicon is invisible", checkNotificationIcon(solo, 0, instrumentation));
  272. assertTrue("Attachments count doesn't match" ,getAttachmentsCountByIndexInList(solo, 0, instrumentation) == 1);
  273.  
  274. //3
  275. //4
  276. newNote(solo);
  277. typeText(solo, solo.getString(R.string.how_to_drive));
  278. clickOnAcceptButton(solo);
  279. assertTrue("Text didn't saved.", getText(solo).startsWith( solo.getString(R.string.how_to_drive)));
  280. solo.goBack();
  281. assertTrue("Text didn't saved.", getTextByIndex(solo, 0, instrumentation)
  282. .startsWith( solo.getString(R.string.how_to_drive)));
  283.  
  284. }
  285.  
  286. public static void var5(Solo solo, Instrumentation instrumentation){
  287. closeBugReportIfNeed(solo);
  288. loginIfNeed(solo, LOGIN, PASSWORD);
  289.  
  290. //1
  291. moveFromNotepadToCalendar(solo);
  292. openMonthCalendar(solo);
  293. swipeTo(solo, 1);
  294. tapToDay(solo, 23);
  295. clickOnTime(solo, instrumentation, 8, 0);
  296. //растянуть до 10
  297. setEventDuration(solo, instrumentation, 120);
  298. clickOnSave(solo);
  299. typeText(solo, solo.getString(R.string.salary));
  300. clickOnAcceptButton(solo);
  301. assertTrue("Text didn't saved.", getText(solo).startsWith(solo.getString(R.string.salary)));
  302. assertTrue("Date saved incorrectly.", getDateFromFlag(solo)
  303. .startsWith("25 " + getMonthName(1) + " " + getYear(0) + " 08:00 - 10:00"));
  304. solo.goBack();
  305. //проверка отображения в календаре
  306. moveFromCalendarToNotepad(solo);
  307. assertTrue("Text didn't saved.", getTextByIndex(solo, 0, instrumentation)
  308. .startsWith(solo.getString(R.string.salary)));
  309. assertTrue("Date saved incorrectly.",
  310. getEventDateByIndexInNotepad(solo, 0, instrumentation)
  311. .startsWith("25 " + getMonthName(1) + " " + getYear(0) + " 08:00-10:00"));
  312.  
  313. //2
  314. newNote(solo);
  315. typeText(solo, "Buy laptop");
  316. clickOnAcceptButton(solo);
  317. assertTrue("Text didn't saved.", getText(solo).startsWith("Buy laptop"));
  318. solo.sleep(5000);//addPhoto(solo);
  319. assertTrue("Attachment count doesn't match", getAttachmentsCount(solo) == 1);
  320. swipeAttachmentsToEnd(solo);
  321. solo.sleep(5000);//addPhoto(solo);
  322. assertTrue("Attachment count doesn't match", getAttachmentsCount(solo) == 2);
  323. solo.goBack();
  324. assertTrue("Text didn't saved.", getTextByIndex(solo, 0, instrumentation)
  325. .startsWith("Buy laptop"));
  326. assertTrue("Attachment count doesn't match",
  327. getAttachmentsCountByIndexInList(solo, 0, instrumentation) == 2);
  328.  
  329. //3
  330. moveFromNotepadToCalendar(solo);
  331. //clickOnHome(solo);
  332. int n = getDayOfWeek(0) - 1;
  333. moveCalendarToOffset(solo, instrumentation, 8 - n); //на ближайший понедельник
  334. clickOnTime(solo, instrumentation, 8, 0);
  335. clickOnSave(solo);
  336. openEventEdit(solo);
  337. if (getHour(0) > 8) clickOnAfterMidday(solo);
  338. setTime(solo, 8, 0);
  339. setEventDuration(solo, instrumentation, 480);
  340. setNotification(solo, instrumentation, 1, 6);
  341. setNotification(solo, instrumentation, 2, 5);
  342. clickOnSave(solo);
  343. typeText(solo, "work");
  344. clickOnAcceptButton(solo);
  345. assertTrue("Text didn't saved.", getText(solo).startsWith("work"));
  346. assertTrue("Date saved incorrectly.", getDateFromFlag(solo).startsWith(dateToString(7 - n) + " 8:00 - 16:00"));
  347. assertTrue("Notification icon is invisible", checkNotificationIcon(solo));
  348. }
  349. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement