The Webfeed Flutter package for Appeto SDK.
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

217 satır
8.9 KiB

  1. import 'dart:core';
  2. import 'dart:io';
  3. import 'package:test/test.dart';
  4. import 'package:webfeed/webfeed.dart';
  5. void main() {
  6. test("parse Invalid.xml", () {
  7. var xmlString = new File("test/xml/Invalid.xml").readAsStringSync();
  8. try {
  9. new RssFeed.parse(xmlString);
  10. fail("Should throw Argument Error");
  11. } on ArgumentError {}
  12. });
  13. test("parse RSS.xml", () {
  14. var xmlString = new File("test/xml/RSS.xml").readAsStringSync();
  15. var feed = new RssFeed.parse(xmlString);
  16. expect(feed.title, "News - Foo bar News");
  17. expect(feed.description, "Foo bar News and Updates feed provided by Foo bar, Inc.");
  18. expect(feed.link, "https://foo.bar.news/");
  19. expect(feed.language, "en-US");
  20. expect(feed.lastBuildDate, "Mon, 26 Mar 2018 14:00:00 PDT");
  21. expect(feed.generator, "Custom");
  22. expect(feed.copyright, "Copyright 2018, Foo bar Inc.");
  23. expect(feed.docs, "https://foo.bar.news/docs");
  24. expect(feed.managingEditor, "alice@foo.bar.news");
  25. expect(feed.rating, "The PICS rating of the feed");
  26. expect(feed.webMaster, "webmaster@foo.bar.news");
  27. expect(feed.ttl, 60);
  28. expect(feed.image.title, "Foo bar News");
  29. expect(feed.image.url, "https://foo.bar.news/logo.gif");
  30. expect(feed.image.link, "https://foo.bar.news/");
  31. expect(feed.cloud.domain, "radio.foo.bar.news");
  32. expect(feed.cloud.port, "80");
  33. expect(feed.cloud.path, "/RPC2");
  34. expect(feed.cloud.registerProcedure, "foo.bar.rssPleaseNotify");
  35. expect(feed.cloud.protocol, "xml-rpc");
  36. expect(feed.categories.length, 2);
  37. expect(feed.categories[0].domain, null);
  38. expect(feed.categories[0].value, "Ipsum");
  39. expect(feed.categories[1].domain, "news");
  40. expect(feed.categories[1].value, "Lorem Ipsum");
  41. expect(feed.skipDays.length, 3);
  42. expect(feed.skipDays.contains("Monday"), true);
  43. expect(feed.skipDays.contains("Tuesday"), true);
  44. expect(feed.skipDays.contains("Sunday"), true);
  45. expect(feed.skipHours.length, 5);
  46. expect(feed.skipHours.contains(0), true);
  47. expect(feed.skipHours.contains(1), true);
  48. expect(feed.skipHours.contains(2), true);
  49. expect(feed.skipHours.contains(3), true);
  50. expect(feed.skipHours.contains(4), true);
  51. expect(feed.items.length, 2);
  52. expect(feed.items.first.title, "The standard Lorem Ipsum passage, used since the 1500s");
  53. expect(feed.items.first.description, "Lorem ipsum dolor sit amet, consectetur adipiscing elit");
  54. expect(feed.items.first.link, "https://foo.bar.news/1");
  55. expect(feed.items.first.guid, "https://foo.bar.news/1?guid");
  56. expect(feed.items.first.pubDate, "Mon, 26 Mar 2018 14:00:00 PDT");
  57. expect(feed.items.first.categories.first.domain, "news");
  58. expect(feed.items.first.categories.first.value, "Lorem");
  59. expect(feed.items.first.author, "alice@foo.bar.news");
  60. expect(feed.items.first.source.url, "https://foo.bar.news/1?source");
  61. expect(feed.items.first.source.value, "Foo Bar");
  62. expect(feed.items.first.comments, "https://foo.bar.news/1/comments");
  63. expect(feed.items.first.enclosure.url, "http://www.scripting.com/mp3s/weatherReportSuite.mp3");
  64. expect(feed.items.first.enclosure.length, 12216320);
  65. expect(feed.items.first.enclosure.type, "audio/mpeg");
  66. expect(feed.items.first.content.value, "<img width=\"1000\" height=\"690\" src=\"https://test.com/image_link\"/> Test content<br />");
  67. expect(feed.items.first.content.images.first, "https://test.com/image_link");
  68. });
  69. test("parse RSS-Media.xml", (){
  70. var xmlString = new File("test/xml/RSS-Media.xml").readAsStringSync();
  71. var feed = new RssFeed.parse(xmlString);
  72. expect(feed.title, "Song Site");
  73. expect(feed.description, "Media RSS example with new fields added in v1.5.0");
  74. expect(feed.items.length, 1);
  75. var item = feed.items.first;
  76. expect(item.title, null);
  77. expect(item.link, "http://www.foo.com");
  78. expect(item.pubDate, "Mon, 27 Aug 2001 16:08:56 PST");
  79. expect(item.media.group.contents.length, 5);
  80. expect(item.media.group.credits.length, 2);
  81. expect(item.media.group.category.value, "music/artist name/album/song");
  82. expect(item.media.group.rating.value, "nonadult");
  83. expect(item.media.contents.length, 2);
  84. var mediaContent = item.media.contents.first;
  85. expect(mediaContent.url, "http://www.foo.com/video.mov");
  86. expect(mediaContent.type, "video/quicktime");
  87. expect(mediaContent.fileSize, 2000);
  88. expect(mediaContent.medium, "video");
  89. expect(mediaContent.isDefault, true);
  90. expect(mediaContent.expression, "full");
  91. expect(mediaContent.bitrate, 128);
  92. expect(mediaContent.framerate, 25);
  93. expect(mediaContent.samplingrate, 44.1);
  94. expect(mediaContent.channels, 2);
  95. expect(item.media.credits.length, 2);
  96. var mediaCredit = item.media.credits.first;
  97. expect(mediaCredit.role, "owner1");
  98. expect(mediaCredit.scheme, "urn:yvs");
  99. expect(mediaCredit.value, "copyright holder of the entity");
  100. expect(item.media.category.scheme, "http://search.yahoo.com/mrss/category_ schema");
  101. expect(item.media.category.label, "Music");
  102. expect(item.media.category.value, "music/artist/album/song");
  103. expect(item.media.rating.scheme, "urn:simple");
  104. expect(item.media.rating.value, "adult");
  105. expect(item.media.title.type, "plain");
  106. expect(item.media.title.value, "The Judy's -- The Moo Song");
  107. expect(item.media.description.type, "plain");
  108. expect(item.media.description.value, "This was some really bizarre band I listened to as a young lad.");
  109. expect(item.media.keywords, "kitty, cat, big dog, yarn, fluffy");
  110. expect(item.media.thumbnails.length, 2);
  111. var mediaThumbnail = item.media.thumbnails.first;
  112. expect(mediaThumbnail.url, "http://www.foo.com/keyframe1.jpg");
  113. expect(mediaThumbnail.width, "75");
  114. expect(mediaThumbnail.height, "50");
  115. expect(mediaThumbnail.time, "12:05:01.123");
  116. expect(item.media.hash.algo, "md5");
  117. expect(item.media.hash.value, "dfdec888b72151965a34b4b59031290a");
  118. expect(item.media.player.url, "http://www.foo.com/player?id=1111");
  119. expect(item.media.player.width, 400);
  120. expect(item.media.player.height, 200);
  121. expect(item.media.player.value, "");
  122. expect(item.media.copyright.url, "http://blah.com/additional-info.html");
  123. expect(item.media.copyright.value, "2005 FooBar Media");
  124. expect(item.media.text.type, "plain");
  125. expect(item.media.text.lang, "en");
  126. expect(item.media.text.start, "00:00:03.000");
  127. expect(item.media.text.end, "00:00:10.000");
  128. expect(item.media.text.value, " Oh, say, can you see");
  129. expect(item.media.restriction.relationship, "allow");
  130. expect(item.media.restriction.type, "country");
  131. expect(item.media.restriction.value, "au us");
  132. expect(item.media.community.starRating.average, 3.5);
  133. expect(item.media.community.starRating.count, 20);
  134. expect(item.media.community.starRating.min, 1);
  135. expect(item.media.community.starRating.max, 10);
  136. expect(item.media.community.statistics.views, 5);
  137. expect(item.media.community.statistics.favorites, 4);
  138. expect(item.media.community.tags.tags, "news: 5, abc:3");
  139. expect(item.media.community.tags.weight, 1);
  140. expect(item.media.comments.length, 2);
  141. expect(item.media.comments.first, "comment1");
  142. expect(item.media.comments.last, "comment2");
  143. expect(item.media.embed.url, "http://www.foo.com/player.swf");
  144. expect(item.media.embed.width, 512);
  145. expect(item.media.embed.height, 323);
  146. expect(item.media.embed.params.length, 5);
  147. expect(item.media.embed.params.first.name, "type");
  148. expect(item.media.embed.params.first.value, "application/x-shockwave-flash");
  149. expect(item.media.responses.length, 2);
  150. expect(item.media.responses.first, "http://www.response1.com");
  151. expect(item.media.responses.last, "http://www.response2.com");
  152. expect(item.media.backLinks.length, 2);
  153. expect(item.media.backLinks.first, "http://www.backlink1.com");
  154. expect(item.media.backLinks.last, "http://www.backlink2.com");
  155. expect(item.media.status.state, "active");
  156. expect(item.media.status.reason, null);
  157. expect(item.media.prices.length, 2);
  158. expect(item.media.prices.first.price, 19.99);
  159. expect(item.media.prices.first.type, "rent");
  160. expect(item.media.prices.first.info, "http://www.dummy.jp/package_info.html");
  161. expect(item.media.prices.first.currency, "EUR");
  162. expect(item.media.license.type, "text/html");
  163. expect(item.media.license.href, "http://www.licensehost.com/license");
  164. expect(item.media.license.value, " Sample license for a video");
  165. expect(item.media.peerLink.type, "application/x-bittorrent");
  166. expect(item.media.peerLink.href, "http://www.foo.org/sampleFile.torrent");
  167. expect(item.media.peerLink.value, "");
  168. expect(item.media.rights.status, "official");
  169. expect(item.media.scenes.length, 2);
  170. expect(item.media.scenes.first.title, "sceneTitle1");
  171. expect(item.media.scenes.first.description, "sceneDesc1");
  172. expect(item.media.scenes.first.startTime, "00:15");
  173. expect(item.media.scenes.first.endTime, "00:45");
  174. });
  175. }