PageRenderTime 47ms CodeModel.GetById 28ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/llui/tests/llurlentry_test.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 864 lines | 605 code | 176 blank | 83 comment | 3 complexity | 5bb79c50139657e09a310d2ddfe67b1b MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llurlentry_test.cpp
  3. * @author Martin Reddy
  4. * @brief Unit tests for LLUrlEntry objects
  5. *
  6. * $LicenseInfo:firstyear=2009&license=viewerlgpl$
  7. * Second Life Viewer Source Code
  8. * Copyright (C) 2010, Linden Research, Inc.
  9. *
  10. * This library is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU Lesser General Public
  12. * License as published by the Free Software Foundation;
  13. * version 2.1 of the License only.
  14. *
  15. * This library is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18. * Lesser General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Lesser General Public
  21. * License along with this library; if not, write to the Free Software
  22. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  23. *
  24. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  25. * $/LicenseInfo$
  26. */
  27. #include "linden_common.h"
  28. #include "../llurlentry.h"
  29. #include "../lluictrl.h"
  30. #include "llurlentry_stub.cpp"
  31. #include "lltut.h"
  32. #include "../lluicolortable.h"
  33. #include "../lluiimage.h"
  34. #include <boost/regex.hpp>
  35. typedef std::map<std::string, LLControlGroup*> settings_map_t;
  36. settings_map_t LLUI::sSettingGroups;
  37. BOOL LLControlGroup::getBOOL(const std::string& name)
  38. {
  39. return false;
  40. }
  41. LLUIColor LLUIColorTable::getColor(const std::string& name, const LLColor4& default_color) const
  42. {
  43. return LLUIColor();
  44. }
  45. LLUIColor::LLUIColor() : mColorPtr(NULL) {}
  46. LLUIImage::LLUIImage(const std::string& name, LLPointer<LLTexture> image)
  47. {
  48. }
  49. LLUIImage::~LLUIImage()
  50. {
  51. }
  52. //virtual
  53. S32 LLUIImage::getWidth() const
  54. {
  55. return 0;
  56. }
  57. //virtual
  58. S32 LLUIImage::getHeight() const
  59. {
  60. return 0;
  61. }
  62. namespace LLInitParam
  63. {
  64. BlockDescriptor::BlockDescriptor() {}
  65. ParamDescriptor::ParamDescriptor(param_handle_t p,
  66. merge_func_t merge_func,
  67. deserialize_func_t deserialize_func,
  68. serialize_func_t serialize_func,
  69. validation_func_t validation_func,
  70. inspect_func_t inspect_func,
  71. S32 min_count,
  72. S32 max_count){}
  73. ParamDescriptor::~ParamDescriptor() {}
  74. }
  75. namespace tut
  76. {
  77. struct LLUrlEntryData
  78. {
  79. };
  80. typedef test_group<LLUrlEntryData> factory;
  81. typedef factory::object object;
  82. }
  83. namespace
  84. {
  85. tut::factory tf("LLUrlEntry");
  86. }
  87. namespace tut
  88. {
  89. void testRegex(const std::string &testname, LLUrlEntryBase &entry,
  90. const char *text, const std::string &expected)
  91. {
  92. boost::regex regex = entry.getPattern();
  93. std::string url = "";
  94. boost::cmatch result;
  95. bool found = boost::regex_search(text, result, regex);
  96. if (found)
  97. {
  98. S32 start = static_cast<U32>(result[0].first - text);
  99. S32 end = static_cast<U32>(result[0].second - text);
  100. url = entry.getUrl(std::string(text+start, end-start));
  101. }
  102. ensure_equals(testname, url, expected);
  103. }
  104. void dummyCallback(const std::string &url, const std::string &label, const std::string& icon)
  105. {
  106. }
  107. void testLabel(const std::string &testname, LLUrlEntryBase &entry,
  108. const char *text, const std::string &expected)
  109. {
  110. boost::regex regex = entry.getPattern();
  111. std::string label = "";
  112. boost::cmatch result;
  113. bool found = boost::regex_search(text, result, regex);
  114. if (found)
  115. {
  116. S32 start = static_cast<U32>(result[0].first - text);
  117. S32 end = static_cast<U32>(result[0].second - text);
  118. std::string url = std::string(text+start, end-start);
  119. label = entry.getLabel(url, boost::bind(dummyCallback, _1, _2, _3));
  120. }
  121. ensure_equals(testname, label, expected);
  122. }
  123. void testLocation(const std::string &testname, LLUrlEntryBase &entry,
  124. const char *text, const std::string &expected)
  125. {
  126. boost::regex regex = entry.getPattern();
  127. std::string location = "";
  128. boost::cmatch result;
  129. bool found = boost::regex_search(text, result, regex);
  130. if (found)
  131. {
  132. S32 start = static_cast<U32>(result[0].first - text);
  133. S32 end = static_cast<U32>(result[0].second - text);
  134. std::string url = std::string(text+start, end-start);
  135. location = entry.getLocation(url);
  136. }
  137. ensure_equals(testname, location, expected);
  138. }
  139. template<> template<>
  140. void object::test<1>()
  141. {
  142. //
  143. // test LLUrlEntryHTTP - standard http Urls
  144. //
  145. LLUrlEntryHTTP url;
  146. testRegex("no valid url", url,
  147. "htp://slurl.com/",
  148. "");
  149. testRegex("simple http (1)", url,
  150. "http://slurl.com/",
  151. "http://slurl.com/");
  152. testRegex("simple http (2)", url,
  153. "http://slurl.com",
  154. "http://slurl.com");
  155. testRegex("simple http (3)", url,
  156. "http://slurl.com/about.php",
  157. "http://slurl.com/about.php");
  158. testRegex("simple https", url,
  159. "https://slurl.com/about.php",
  160. "https://slurl.com/about.php");
  161. testRegex("http in text (1)", url,
  162. "XX http://slurl.com/ XX",
  163. "http://slurl.com/");
  164. testRegex("http in text (2)", url,
  165. "XX http://slurl.com/about.php XX",
  166. "http://slurl.com/about.php");
  167. testRegex("https in text", url,
  168. "XX https://slurl.com/about.php XX",
  169. "https://slurl.com/about.php");
  170. testRegex("two http urls", url,
  171. "XX http://slurl.com/about.php http://secondlife.com/ XX",
  172. "http://slurl.com/about.php");
  173. testRegex("http url with port and username", url,
  174. "XX http://nobody@slurl.com:80/about.php http://secondlife.com/ XX",
  175. "http://nobody@slurl.com:80/about.php");
  176. testRegex("http url with port, username, and query string", url,
  177. "XX http://nobody@slurl.com:80/about.php?title=hi%20there http://secondlife.com/ XX",
  178. "http://nobody@slurl.com:80/about.php?title=hi%20there");
  179. // note: terminating commas will be removed by LLUrlRegistry:findUrl()
  180. testRegex("http url with commas in middle and terminating", url,
  181. "XX http://slurl.com/?title=Hi,There, XX",
  182. "http://slurl.com/?title=Hi,There,");
  183. // note: terminating periods will be removed by LLUrlRegistry:findUrl()
  184. testRegex("http url with periods in middle and terminating", url,
  185. "XX http://slurl.com/index.php. XX",
  186. "http://slurl.com/index.php.");
  187. // DEV-19842: Closing parenthesis ")" breaks urls
  188. testRegex("http url with brackets (1)", url,
  189. "XX http://en.wikipedia.org/wiki/JIRA_(software) XX",
  190. "http://en.wikipedia.org/wiki/JIRA_(software)");
  191. // DEV-19842: Closing parenthesis ")" breaks urls
  192. testRegex("http url with brackets (2)", url,
  193. "XX http://jira.secondlife.com/secure/attachment/17990/eggy+avs+in+1.21.0+(93713)+public+nightly.jpg XX",
  194. "http://jira.secondlife.com/secure/attachment/17990/eggy+avs+in+1.21.0+(93713)+public+nightly.jpg");
  195. // DEV-10353: URLs in chat log terminated incorrectly when newline in chat
  196. testRegex("http url with newlines", url,
  197. "XX\nhttp://www.secondlife.com/\nXX",
  198. "http://www.secondlife.com/");
  199. }
  200. template<> template<>
  201. void object::test<2>()
  202. {
  203. //
  204. // test LLUrlEntryHTTPLabel - wiki-style http Urls with labels
  205. //
  206. LLUrlEntryHTTPLabel url;
  207. testRegex("invalid wiki url [1]", url,
  208. "[http://www.example.org]",
  209. "");
  210. testRegex("invalid wiki url [2]", url,
  211. "[http://www.example.org",
  212. "");
  213. testRegex("invalid wiki url [3]", url,
  214. "[http://www.example.org Label",
  215. "");
  216. testRegex("example.org with label (spaces)", url,
  217. "[http://www.example.org Text]",
  218. "http://www.example.org");
  219. testRegex("example.org with label (tabs)", url,
  220. "[http://www.example.org\t Text]",
  221. "http://www.example.org");
  222. testRegex("SL http URL with label", url,
  223. "[http://www.secondlife.com/ Second Life]",
  224. "http://www.secondlife.com/");
  225. testRegex("SL https URL with label", url,
  226. "XXX [https://www.secondlife.com/ Second Life] YYY",
  227. "https://www.secondlife.com/");
  228. testRegex("SL http URL with label", url,
  229. "[http://www.secondlife.com/?test=Hi%20There Second Life]",
  230. "http://www.secondlife.com/?test=Hi%20There");
  231. }
  232. template<> template<>
  233. void object::test<3>()
  234. {
  235. //
  236. // test LLUrlEntrySLURL - second life URLs
  237. //
  238. LLUrlEntrySLURL url;
  239. testRegex("no valid slurl [1]", url,
  240. "htp://slurl.com/secondlife/Ahern/50/50/50/",
  241. "");
  242. testRegex("no valid slurl [2]", url,
  243. "http://slurl.com/secondlife/",
  244. "");
  245. testRegex("no valid slurl [3]", url,
  246. "hhtp://slurl.com/secondlife/Ahern/50/FOO/50/",
  247. "");
  248. testRegex("Ahern (50,50,50) [1]", url,
  249. "http://slurl.com/secondlife/Ahern/50/50/50/",
  250. "http://slurl.com/secondlife/Ahern/50/50/50/");
  251. testRegex("Ahern (50,50,50) [2]", url,
  252. "XXX http://slurl.com/secondlife/Ahern/50/50/50/ XXX",
  253. "http://slurl.com/secondlife/Ahern/50/50/50/");
  254. testRegex("Ahern (50,50,50) [3]", url,
  255. "XXX http://slurl.com/secondlife/Ahern/50/50/50 XXX",
  256. "http://slurl.com/secondlife/Ahern/50/50/50");
  257. testRegex("Ahern (50,50,50) multicase", url,
  258. "XXX http://SLUrl.com/SecondLife/Ahern/50/50/50/ XXX",
  259. "http://SLUrl.com/SecondLife/Ahern/50/50/50/");
  260. testRegex("Ahern (50,50) [1]", url,
  261. "XXX http://slurl.com/secondlife/Ahern/50/50/ XXX",
  262. "http://slurl.com/secondlife/Ahern/50/50/");
  263. testRegex("Ahern (50,50) [2]", url,
  264. "XXX http://slurl.com/secondlife/Ahern/50/50 XXX",
  265. "http://slurl.com/secondlife/Ahern/50/50");
  266. testRegex("Ahern (50)", url,
  267. "XXX http://slurl.com/secondlife/Ahern/50 XXX",
  268. "http://slurl.com/secondlife/Ahern/50");
  269. testRegex("Ahern", url,
  270. "XXX http://slurl.com/secondlife/Ahern/ XXX",
  271. "http://slurl.com/secondlife/Ahern/");
  272. testRegex("Ahern SLURL with title", url,
  273. "XXX http://slurl.com/secondlife/Ahern/50/50/50/?title=YOUR%20TITLE%20HERE! XXX",
  274. "http://slurl.com/secondlife/Ahern/50/50/50/?title=YOUR%20TITLE%20HERE!");
  275. testRegex("Ahern SLURL with msg", url,
  276. "XXX http://slurl.com/secondlife/Ahern/50/50/50/?msg=Your%20text%20here. XXX",
  277. "http://slurl.com/secondlife/Ahern/50/50/50/?msg=Your%20text%20here.");
  278. // DEV-21577: In-world SLURLs containing "(" or ")" are not treated as a hyperlink in chat
  279. testRegex("SLURL with brackets", url,
  280. "XXX http://slurl.com/secondlife/Burning%20Life%20(Hyper)/27/210/30 XXX",
  281. "http://slurl.com/secondlife/Burning%20Life%20(Hyper)/27/210/30");
  282. // DEV-35459: SLURLs and teleport Links not parsed properly
  283. testRegex("SLURL with quote", url,
  284. "XXX http://slurl.com/secondlife/A'ksha%20Oasis/41/166/701 XXX",
  285. "http://slurl.com/secondlife/A%27ksha%20Oasis/41/166/701");
  286. }
  287. template<> template<>
  288. void object::test<4>()
  289. {
  290. //
  291. // test LLUrlEntryAgent - secondlife://app/agent Urls
  292. //
  293. LLUrlEntryAgent url;
  294. testRegex("Invalid Agent Url", url,
  295. "secondlife:///app/agent/0e346d8b-4433-4d66-XXXX-fd37083abc4c/about",
  296. "");
  297. testRegex("Agent Url ", url,
  298. "secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about",
  299. "secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about");
  300. testRegex("Agent Url in text", url,
  301. "XXX secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about XXX",
  302. "secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about");
  303. testRegex("Agent Url multicase", url,
  304. "XXX secondlife:///App/AGENT/0E346D8B-4433-4d66-a6b0-fd37083abc4c/About XXX",
  305. "secondlife:///App/AGENT/0E346D8B-4433-4d66-a6b0-fd37083abc4c/About");
  306. testRegex("Agent Url alternate command", url,
  307. "XXX secondlife:///App/AGENT/0E346D8B-4433-4d66-a6b0-fd37083abc4c/foobar",
  308. "secondlife:///App/AGENT/0E346D8B-4433-4d66-a6b0-fd37083abc4c/foobar");
  309. testRegex("Standalone Agent Url ", url,
  310. "x-grid-location-info://lincoln.lindenlab.com/app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about",
  311. "x-grid-location-info://lincoln.lindenlab.com/app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about");
  312. testRegex("Standalone Agent Url Multicase with Text", url,
  313. "M x-grid-location-info://lincoln.lindenlab.com/app/AGENT/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about M",
  314. "x-grid-location-info://lincoln.lindenlab.com/app/AGENT/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about");
  315. }
  316. template<> template<>
  317. void object::test<5>()
  318. {
  319. //
  320. // test LLUrlEntryGroup - secondlife://app/group Urls
  321. //
  322. LLUrlEntryGroup url;
  323. testRegex("Invalid Group Url", url,
  324. "secondlife:///app/group/00005ff3-4044-c79f-XXXX-fb28ae0df991/about",
  325. "");
  326. testRegex("Group Url ", url,
  327. "secondlife:///app/group/00005ff3-4044-c79f-9de8-fb28ae0df991/about",
  328. "secondlife:///app/group/00005ff3-4044-c79f-9de8-fb28ae0df991/about");
  329. testRegex("Group Url ", url,
  330. "secondlife:///app/group/00005ff3-4044-c79f-9de8-fb28ae0df991/inspect",
  331. "secondlife:///app/group/00005ff3-4044-c79f-9de8-fb28ae0df991/inspect");
  332. testRegex("Group Url in text", url,
  333. "XXX secondlife:///app/group/00005ff3-4044-c79f-9de8-fb28ae0df991/about XXX",
  334. "secondlife:///app/group/00005ff3-4044-c79f-9de8-fb28ae0df991/about");
  335. testRegex("Group Url multicase", url,
  336. "XXX secondlife:///APP/Group/00005FF3-4044-c79f-9de8-fb28ae0df991/About XXX",
  337. "secondlife:///APP/Group/00005FF3-4044-c79f-9de8-fb28ae0df991/About");
  338. testRegex("Standalone Group Url ", url,
  339. "x-grid-location-info://lincoln.lindenlab.com/app/group/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about",
  340. "x-grid-location-info://lincoln.lindenlab.com/app/group/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about");
  341. testRegex("Standalone Group Url Multicase ith Text", url,
  342. "M x-grid-location-info://lincoln.lindenlab.com/app/GROUP/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about M",
  343. "x-grid-location-info://lincoln.lindenlab.com/app/GROUP/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about");
  344. }
  345. template<> template<>
  346. void object::test<6>()
  347. {
  348. //
  349. // test LLUrlEntryPlace - secondlife://<location> URLs
  350. //
  351. LLUrlEntryPlace url;
  352. testRegex("no valid slurl [1]", url,
  353. "secondlife://Ahern/FOO/50/",
  354. "");
  355. testRegex("Ahern (50,50,50) [1]", url,
  356. "secondlife://Ahern/50/50/50/",
  357. "secondlife://Ahern/50/50/50/");
  358. testRegex("Ahern (50,50,50) [2]", url,
  359. "XXX secondlife://Ahern/50/50/50/ XXX",
  360. "secondlife://Ahern/50/50/50/");
  361. testRegex("Ahern (50,50,50) [3]", url,
  362. "XXX secondlife://Ahern/50/50/50 XXX",
  363. "secondlife://Ahern/50/50/50");
  364. testRegex("Ahern (50,50,50) multicase", url,
  365. "XXX SecondLife://Ahern/50/50/50/ XXX",
  366. "SecondLife://Ahern/50/50/50/");
  367. testRegex("Ahern (50,50) [1]", url,
  368. "XXX secondlife://Ahern/50/50/ XXX",
  369. "secondlife://Ahern/50/50/");
  370. testRegex("Ahern (50,50) [2]", url,
  371. "XXX secondlife://Ahern/50/50 XXX",
  372. "secondlife://Ahern/50/50");
  373. // DEV-21577: In-world SLURLs containing "(" or ")" are not treated as a hyperlink in chat
  374. testRegex("SLURL with brackets", url,
  375. "XXX secondlife://Burning%20Life%20(Hyper)/27/210/30 XXX",
  376. "secondlife://Burning%20Life%20(Hyper)/27/210/30");
  377. // DEV-35459: SLURLs and teleport Links not parsed properly
  378. testRegex("SLURL with quote", url,
  379. "XXX secondlife://A'ksha%20Oasis/41/166/701 XXX",
  380. "secondlife://A%27ksha%20Oasis/41/166/701");
  381. testRegex("Standalone All Hands (50,50) [2] with text", url,
  382. "XXX x-grid-location-info://lincoln.lindenlab.com/region/All%20Hands/50/50/50 XXX",
  383. "x-grid-location-info://lincoln.lindenlab.com/region/All%20Hands/50/50/50");
  384. }
  385. template<> template<>
  386. void object::test<7>()
  387. {
  388. //
  389. // test LLUrlEntryParcel - secondlife://app/parcel Urls
  390. //
  391. LLUrlEntryParcel url;
  392. testRegex("Invalid Classified Url", url,
  393. "secondlife:///app/parcel/0000060e-4b39-e00b-XXXX-d98b1934e3a8/about",
  394. "");
  395. testRegex("Classified Url ", url,
  396. "secondlife:///app/parcel/0000060e-4b39-e00b-d0c3-d98b1934e3a8/about",
  397. "secondlife:///app/parcel/0000060e-4b39-e00b-d0c3-d98b1934e3a8/about");
  398. testRegex("Classified Url in text", url,
  399. "XXX secondlife:///app/parcel/0000060e-4b39-e00b-d0c3-d98b1934e3a8/about XXX",
  400. "secondlife:///app/parcel/0000060e-4b39-e00b-d0c3-d98b1934e3a8/about");
  401. testRegex("Classified Url multicase", url,
  402. "XXX secondlife:///APP/Parcel/0000060e-4b39-e00b-d0c3-d98b1934e3a8/About XXX",
  403. "secondlife:///APP/Parcel/0000060e-4b39-e00b-d0c3-d98b1934e3a8/About");
  404. }
  405. template<> template<>
  406. void object::test<8>()
  407. {
  408. //
  409. // test LLUrlEntryTeleport - secondlife://app/teleport URLs
  410. //
  411. LLUrlEntryTeleport url;
  412. testRegex("no valid teleport [1]", url,
  413. "http://slurl.com/secondlife/Ahern/50/50/50/",
  414. "");
  415. testRegex("no valid teleport [2]", url,
  416. "secondlife:///app/teleport/",
  417. "");
  418. testRegex("no valid teleport [3]", url,
  419. "second-life:///app/teleport/Ahern/50/50/50/",
  420. "");
  421. testRegex("no valid teleport [3]", url,
  422. "hhtp://slurl.com/secondlife/Ahern/50/FOO/50/",
  423. "");
  424. testRegex("Ahern (50,50,50) [1]", url,
  425. "secondlife:///app/teleport/Ahern/50/50/50/",
  426. "secondlife:///app/teleport/Ahern/50/50/50/");
  427. testRegex("Ahern (50,50,50) [2]", url,
  428. "XXX secondlife:///app/teleport/Ahern/50/50/50/ XXX",
  429. "secondlife:///app/teleport/Ahern/50/50/50/");
  430. testRegex("Ahern (50,50,50) [3]", url,
  431. "XXX secondlife:///app/teleport/Ahern/50/50/50 XXX",
  432. "secondlife:///app/teleport/Ahern/50/50/50");
  433. testRegex("Ahern (50,50,50) multicase", url,
  434. "XXX secondlife:///app/teleport/Ahern/50/50/50/ XXX",
  435. "secondlife:///app/teleport/Ahern/50/50/50/");
  436. testRegex("Ahern (50,50) [1]", url,
  437. "XXX secondlife:///app/teleport/Ahern/50/50/ XXX",
  438. "secondlife:///app/teleport/Ahern/50/50/");
  439. testRegex("Ahern (50,50) [2]", url,
  440. "XXX secondlife:///app/teleport/Ahern/50/50 XXX",
  441. "secondlife:///app/teleport/Ahern/50/50");
  442. testRegex("Ahern (50)", url,
  443. "XXX secondlife:///app/teleport/Ahern/50 XXX",
  444. "secondlife:///app/teleport/Ahern/50");
  445. testRegex("Ahern", url,
  446. "XXX secondlife:///app/teleport/Ahern/ XXX",
  447. "secondlife:///app/teleport/Ahern/");
  448. testRegex("Ahern teleport with title", url,
  449. "XXX secondlife:///app/teleport/Ahern/50/50/50/?title=YOUR%20TITLE%20HERE! XXX",
  450. "secondlife:///app/teleport/Ahern/50/50/50/?title=YOUR%20TITLE%20HERE!");
  451. testRegex("Ahern teleport with msg", url,
  452. "XXX secondlife:///app/teleport/Ahern/50/50/50/?msg=Your%20text%20here. XXX",
  453. "secondlife:///app/teleport/Ahern/50/50/50/?msg=Your%20text%20here.");
  454. // DEV-21577: In-world SLURLs containing "(" or ")" are not treated as a hyperlink in chat
  455. testRegex("Teleport with brackets", url,
  456. "XXX secondlife:///app/teleport/Burning%20Life%20(Hyper)/27/210/30 XXX",
  457. "secondlife:///app/teleport/Burning%20Life%20(Hyper)/27/210/30");
  458. // DEV-35459: SLURLs and teleport Links not parsed properly
  459. testRegex("Teleport url with quote", url,
  460. "XXX secondlife:///app/teleport/A'ksha%20Oasis/41/166/701 XXX",
  461. "secondlife:///app/teleport/A%27ksha%20Oasis/41/166/701");
  462. testRegex("Standalone All Hands", url,
  463. "XXX x-grid-location-info://lincoln.lindenlab.com/app/teleport/All%20Hands/50/50/50 XXX",
  464. "x-grid-location-info://lincoln.lindenlab.com/app/teleport/All%20Hands/50/50/50");
  465. }
  466. template<> template<>
  467. void object::test<9>()
  468. {
  469. //
  470. // test LLUrlEntrySL - general secondlife:// URLs
  471. //
  472. LLUrlEntrySL url;
  473. testRegex("no valid slapp [1]", url,
  474. "http:///app/",
  475. "");
  476. testRegex("valid slapp [1]", url,
  477. "secondlife:///app/",
  478. "secondlife:///app/");
  479. testRegex("valid slapp [2]", url,
  480. "secondlife:///app/teleport/Ahern/50/50/50/",
  481. "secondlife:///app/teleport/Ahern/50/50/50/");
  482. testRegex("valid slapp [3]", url,
  483. "secondlife:///app/foo",
  484. "secondlife:///app/foo");
  485. testRegex("valid slapp [4]", url,
  486. "secondlife:///APP/foo?title=Hi%20There",
  487. "secondlife:///APP/foo?title=Hi%20There");
  488. testRegex("valid slapp [5]", url,
  489. "secondlife://host/app/",
  490. "secondlife://host/app/");
  491. testRegex("valid slapp [6]", url,
  492. "secondlife://host:8080/foo/bar",
  493. "secondlife://host:8080/foo/bar");
  494. }
  495. template<> template<>
  496. void object::test<10>()
  497. {
  498. //
  499. // test LLUrlEntrySLLabel - general secondlife:// URLs with labels
  500. //
  501. LLUrlEntrySLLabel url;
  502. testRegex("invalid wiki url [1]", url,
  503. "[secondlife:///app/]",
  504. "");
  505. testRegex("invalid wiki url [2]", url,
  506. "[secondlife:///app/",
  507. "");
  508. testRegex("invalid wiki url [3]", url,
  509. "[secondlife:///app/ Label",
  510. "");
  511. testRegex("agent slurl with label (spaces)", url,
  512. "[secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about Text]",
  513. "secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about");
  514. testRegex("agent slurl with label (tabs)", url,
  515. "[secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about\t Text]",
  516. "secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about");
  517. testRegex("agent slurl with label", url,
  518. "[secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about FirstName LastName]",
  519. "secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about");
  520. testRegex("teleport slurl with label", url,
  521. "XXX [secondlife:///app/teleport/Ahern/50/50/50/ Teleport to Ahern] YYY",
  522. "secondlife:///app/teleport/Ahern/50/50/50/");
  523. }
  524. template<> template<>
  525. void object::test<11>()
  526. {
  527. //
  528. // test LLUrlEntryHTTPNoProtocol - general URLs without a protocol
  529. //
  530. LLUrlEntryHTTPNoProtocol url;
  531. testRegex("naked .com URL", url,
  532. "see google.com",
  533. "http://google.com");
  534. testRegex("naked .org URL", url,
  535. "see en.wikipedia.org for details",
  536. "http://en.wikipedia.org");
  537. testRegex("naked .net URL", url,
  538. "example.net",
  539. "http://example.net");
  540. testRegex("naked .edu URL (2 instances)", url,
  541. "MIT web site is at web.mit.edu and also www.mit.edu",
  542. "http://web.mit.edu");
  543. testRegex("don't match e-mail addresses", url,
  544. "test@lindenlab.com",
  545. "");
  546. testRegex(".com URL with path", url,
  547. "see secondlife.com/status for grid status",
  548. "http://secondlife.com/status");
  549. testRegex(".com URL with port", url,
  550. "secondlife.com:80",
  551. "http://secondlife.com:80");
  552. testRegex(".com URL with port and path", url,
  553. "see secondlife.com:80/status",
  554. "http://secondlife.com:80/status");
  555. testRegex("www.*.com URL with port and path", url,
  556. "see www.secondlife.com:80/status",
  557. "http://www.secondlife.com:80/status");
  558. testRegex("invalid .com URL [1]", url,
  559. "..com",
  560. "");
  561. testRegex("invalid .com URL [2]", url,
  562. "you.come",
  563. "");
  564. testRegex("invalid .com URL [3]", url,
  565. "recommended",
  566. "");
  567. testRegex("invalid .edu URL", url,
  568. "hi there scheduled maitenance has begun",
  569. "");
  570. testRegex("invalid .net URL", url,
  571. "foo.netty",
  572. "");
  573. testRegex("XML tags around URL [1]", url,
  574. "<foo>secondlife.com</foo>",
  575. "http://secondlife.com");
  576. testRegex("XML tags around URL [2]", url,
  577. "<foo>secondlife.com/status?bar=1</foo>",
  578. "http://secondlife.com/status?bar=1");
  579. }
  580. template<> template<>
  581. void object::test<12>()
  582. {
  583. //
  584. // test LLUrlEntryNoLink - turn off hyperlinking
  585. //
  586. LLUrlEntryNoLink url;
  587. testRegex("<nolink> [1]", url,
  588. "<nolink>google.com</nolink>",
  589. "google.com");
  590. testRegex("<nolink> [2]", url,
  591. "<nolink>google.com",
  592. "");
  593. testRegex("<nolink> [3]", url,
  594. "google.com</nolink>",
  595. "");
  596. testRegex("<nolink> [4]", url,
  597. "<nolink>Hello World</nolink>",
  598. "Hello World");
  599. testRegex("<nolink> [5]", url,
  600. "<nolink>My Object</nolink>",
  601. "My Object");
  602. }
  603. template<> template<>
  604. void object::test<13>()
  605. {
  606. //
  607. // test LLUrlEntryRegion - secondlife:///app/region/<location> URLs
  608. //
  609. LLUrlEntryRegion url;
  610. // Regex tests.
  611. testRegex("no valid region", url,
  612. "secondlife:///app/region/",
  613. "");
  614. testRegex("invalid coords", url,
  615. "secondlife:///app/region/Korea2/a/b/c",
  616. "secondlife:///app/region/Korea2/"); // don't count invalid coords
  617. testRegex("Ahern (50,50,50) [1]", url,
  618. "secondlife:///app/region/Ahern/50/50/50/",
  619. "secondlife:///app/region/Ahern/50/50/50/");
  620. testRegex("Ahern (50,50,50) [2]", url,
  621. "XXX secondlife:///app/region/Ahern/50/50/50/ XXX",
  622. "secondlife:///app/region/Ahern/50/50/50/");
  623. testRegex("Ahern (50,50,50) [3]", url,
  624. "XXX secondlife:///app/region/Ahern/50/50/50 XXX",
  625. "secondlife:///app/region/Ahern/50/50/50");
  626. testRegex("Ahern (50,50,50) multicase", url,
  627. "XXX secondlife:///app/region/Ahern/50/50/50/ XXX",
  628. "secondlife:///app/region/Ahern/50/50/50/");
  629. testRegex("Ahern (50,50) [1]", url,
  630. "XXX secondlife:///app/region/Ahern/50/50/ XXX",
  631. "secondlife:///app/region/Ahern/50/50/");
  632. testRegex("Ahern (50,50) [2]", url,
  633. "XXX secondlife:///app/region/Ahern/50/50 XXX",
  634. "secondlife:///app/region/Ahern/50/50");
  635. // DEV-21577: In-world SLURLs containing "(" or ")" are not treated as a hyperlink in chat
  636. testRegex("Region with brackets", url,
  637. "XXX secondlife:///app/region/Burning%20Life%20(Hyper)/27/210/30 XXX",
  638. "secondlife:///app/region/Burning%20Life%20(Hyper)/27/210/30");
  639. // DEV-35459: SLURLs and teleport Links not parsed properly
  640. testRegex("Region with quote", url,
  641. "XXX secondlife:///app/region/A'ksha%20Oasis/41/166/701 XXX",
  642. "secondlife:///app/region/A%27ksha%20Oasis/41/166/701");
  643. // Rendering tests.
  644. testLabel("Render /app/region/Ahern/50/50/50/", url,
  645. "secondlife:///app/region/Ahern/50/50/50/",
  646. "Ahern (50,50,50)");
  647. testLabel("Render /app/region/Ahern/50/50/50", url,
  648. "secondlife:///app/region/Ahern/50/50/50",
  649. "Ahern (50,50,50)");
  650. testLabel("Render /app/region/Ahern/50/50/", url,
  651. "secondlife:///app/region/Ahern/50/50/",
  652. "Ahern (50,50)");
  653. testLabel("Render /app/region/Ahern/50/50", url,
  654. "secondlife:///app/region/Ahern/50/50",
  655. "Ahern (50,50)");
  656. testLabel("Render /app/region/Ahern/50/", url,
  657. "secondlife:///app/region/Ahern/50/",
  658. "Ahern (50)");
  659. testLabel("Render /app/region/Ahern/50", url,
  660. "secondlife:///app/region/Ahern/50",
  661. "Ahern (50)");
  662. testLabel("Render /app/region/Ahern/", url,
  663. "secondlife:///app/region/Ahern/",
  664. "Ahern");
  665. testLabel("Render /app/region/Ahern/ within context", url,
  666. "XXX secondlife:///app/region/Ahern/ XXX",
  667. "Ahern");
  668. testLabel("Render /app/region/Ahern", url,
  669. "secondlife:///app/region/Ahern",
  670. "Ahern");
  671. testLabel("Render /app/region/Ahern within context", url,
  672. "XXX secondlife:///app/region/Ahern XXX",
  673. "Ahern");
  674. testLabel("Render /app/region/Product%20Engine/", url,
  675. "secondlife:///app/region/Product%20Engine/",
  676. "Product Engine");
  677. testLabel("Render /app/region/Product%20Engine", url,
  678. "secondlife:///app/region/Product%20Engine",
  679. "Product Engine");
  680. // Location parsing texts.
  681. testLocation("Location /app/region/Ahern/50/50/50/", url,
  682. "secondlife:///app/region/Ahern/50/50/50/",
  683. "Ahern");
  684. testLocation("Location /app/region/Product%20Engine", url,
  685. "secondlife:///app/region/Product%20Engine",
  686. "Product Engine");
  687. }
  688. }