summaryrefslogtreecommitdiff
path: root/indra/llui/tests
diff options
context:
space:
mode:
authorAnsariel <ansariel.hiller@phoenixviewer.com>2024-05-22 19:04:52 +0200
committerAnsariel <ansariel.hiller@phoenixviewer.com>2024-05-22 19:04:52 +0200
commit1b67dd855c41f5a0cda7ec2a68d98071986ca703 (patch)
treeab243607f74f78200787bba5b9b88f07ef1b966f /indra/llui/tests
parent6d6eabca44d08d5b97bfe3e941d2b9687c2246ea (diff)
parente1623bb276f83a43ce7a197e388720c05bdefe61 (diff)
Merge remote-tracking branch 'origin/main' into DRTVWR-600-maint-A
# Conflicts: # autobuild.xml # indra/cmake/CMakeLists.txt # indra/cmake/GoogleMock.cmake # indra/llaudio/llaudioengine_fmodstudio.cpp # indra/llaudio/llaudioengine_fmodstudio.h # indra/llaudio/lllistener_fmodstudio.cpp # indra/llaudio/lllistener_fmodstudio.h # indra/llaudio/llstreamingaudio_fmodstudio.cpp # indra/llaudio/llstreamingaudio_fmodstudio.h # indra/llcharacter/llmultigesture.cpp # indra/llcharacter/llmultigesture.h # indra/llimage/llimage.cpp # indra/llimage/llimagepng.cpp # indra/llimage/llimageworker.cpp # indra/llimage/tests/llimageworker_test.cpp # indra/llmessage/tests/llmockhttpclient.h # indra/llprimitive/llgltfmaterial.h # indra/llrender/llfontfreetype.cpp # indra/llui/llcombobox.cpp # indra/llui/llfolderview.cpp # indra/llui/llfolderviewmodel.h # indra/llui/lllineeditor.cpp # indra/llui/lllineeditor.h # indra/llui/lltextbase.cpp # indra/llui/lltextbase.h # indra/llui/lltexteditor.cpp # indra/llui/lltextvalidate.cpp # indra/llui/lltextvalidate.h # indra/llui/lluictrl.h # indra/llui/llview.cpp # indra/llwindow/llwindowmacosx.cpp # indra/newview/app_settings/settings.xml # indra/newview/llappearancemgr.cpp # indra/newview/llappearancemgr.h # indra/newview/llavatarpropertiesprocessor.cpp # indra/newview/llavatarpropertiesprocessor.h # indra/newview/llbreadcrumbview.cpp # indra/newview/llbreadcrumbview.h # indra/newview/llbreastmotion.cpp # indra/newview/llbreastmotion.h # indra/newview/llconversationmodel.h # indra/newview/lldensityctrl.cpp # indra/newview/lldensityctrl.h # indra/newview/llface.inl # indra/newview/llfloatereditsky.cpp # indra/newview/llfloatereditwater.cpp # indra/newview/llfloateremojipicker.h # indra/newview/llfloaterimsessiontab.cpp # indra/newview/llfloaterprofiletexture.cpp # indra/newview/llfloaterprofiletexture.h # indra/newview/llgesturemgr.cpp # indra/newview/llgesturemgr.h # indra/newview/llimpanel.cpp # indra/newview/llimpanel.h # indra/newview/llinventorybridge.cpp # indra/newview/llinventorybridge.h # indra/newview/llinventoryclipboard.cpp # indra/newview/llinventoryclipboard.h # indra/newview/llinventoryfunctions.cpp # indra/newview/llinventoryfunctions.h # indra/newview/llinventorygallery.cpp # indra/newview/lllistbrowser.cpp # indra/newview/lllistbrowser.h # indra/newview/llpanelobjectinventory.cpp # indra/newview/llpanelprofile.cpp # indra/newview/llpanelprofile.h # indra/newview/llpreviewgesture.cpp # indra/newview/llsavedsettingsglue.cpp # indra/newview/llsavedsettingsglue.h # indra/newview/lltooldraganddrop.cpp # indra/newview/llurllineeditorctrl.cpp # indra/newview/llvectorperfoptions.cpp # indra/newview/llvectorperfoptions.h # indra/newview/llviewerparceloverlay.cpp # indra/newview/llviewertexlayer.cpp # indra/newview/llviewertexturelist.cpp # indra/newview/macmain.h # indra/test/test.cpp
Diffstat (limited to 'indra/llui/tests')
-rwxr-xr-xindra/llui/tests/llurlentry_stub.cpp136
-rw-r--r--indra/llui/tests/llurlentry_test.cpp1870
-rw-r--r--indra/llui/tests/llurlmatch_test.cpp400
3 files changed, 1203 insertions, 1203 deletions
diff --git a/indra/llui/tests/llurlentry_stub.cpp b/indra/llui/tests/llurlentry_stub.cpp
index 338be1808d..95d1586495 100755
--- a/indra/llui/tests/llurlentry_stub.cpp
+++ b/indra/llui/tests/llurlentry_stub.cpp
@@ -6,21 +6,21 @@
* $LicenseInfo:firstyear=2009&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2010, Linden Research, Inc.
- *
+ *
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
- *
+ *
* This library 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
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
+ *
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
@@ -38,13 +38,13 @@
// Stub for LLAvatarNameCache
bool LLAvatarNameCache::get(const LLUUID& agent_id, LLAvatarName *av_name)
{
- return false;
+ return false;
}
LLAvatarNameCache::callback_connection_t LLAvatarNameCache::get(const LLUUID& agent_id, callback_slot_t slot)
{
- callback_connection_t connection;
- return connection;
+ callback_connection_t connection;
+ return connection;
}
//
@@ -52,24 +52,24 @@ LLAvatarNameCache::callback_connection_t LLAvatarNameCache::get(const LLUUID& ag
//
BOOL LLCacheName::getFullName(const LLUUID& id, std::string& fullname)
{
- fullname = "Lynx Linden";
- return TRUE;
+ fullname = "Lynx Linden";
+ return TRUE;
}
BOOL LLCacheName::getGroupName(const LLUUID& id, std::string& group)
{
- group = "My Group";
- return TRUE;
+ group = "My Group";
+ return TRUE;
}
boost::signals2::connection LLCacheName::get(const LLUUID& id, bool is_group, const LLCacheNameCallback& callback)
{
- return boost::signals2::connection();
+ return boost::signals2::connection();
}
boost::signals2::connection LLCacheName::getGroup(const LLUUID& id, const LLCacheNameCallback& callback)
{
- return boost::signals2::connection();
+ return boost::signals2::connection();
}
LLCacheName* gCacheName = NULL;
@@ -80,12 +80,12 @@ LLCacheName* gCacheName = NULL;
class LLTrans
{
public:
- static std::string getString(const std::string &xml_desc, const LLStringUtil::format_map_t& args);
+ static std::string getString(const std::string &xml_desc, const LLStringUtil::format_map_t& args);
};
std::string LLTrans::getString(const std::string &xml_desc, const LLStringUtil::format_map_t& args)
{
- return std::string();
+ return std::string();
}
//
@@ -102,65 +102,65 @@ LLStyle::Params::Params()
namespace LLInitParam
{
- ParamValue<LLUIColor>::ParamValue(const LLUIColor& color)
- : super_t(color)
- {}
-
- void ParamValue<LLUIColor>::updateValueFromBlock()
- {}
-
- void ParamValue<LLUIColor>::updateBlockFromValue(bool)
- {}
-
- bool ParamCompare<const LLFontGL*, false>::equals(const LLFontGL* a, const LLFontGL* b)
- {
- return false;
- }
-
- ParamValue<const LLFontGL*>::ParamValue(const LLFontGL* fontp)
- : super_t(fontp)
- {}
-
- void ParamValue<const LLFontGL*>::updateValueFromBlock()
- {}
-
- void ParamValue<const LLFontGL*>::updateBlockFromValue(bool)
- {}
-
- void TypeValues<LLFontGL::HAlign>::declareValues()
- {}
-
- void TypeValues<LLFontGL::VAlign>::declareValues()
- {}
-
- void TypeValues<LLFontGL::ShadowType>::declareValues()
- {}
-
- void ParamValue<LLUIImage*>::updateValueFromBlock()
- {}
-
- void ParamValue<LLUIImage*>::updateBlockFromValue(bool)
- {}
-
-
- bool ParamCompare<LLUIImage*, false>::equals(
- LLUIImage* const &a,
- LLUIImage* const &b)
- {
- return false;
- }
-
- bool ParamCompare<LLUIColor, false>::equals(const LLUIColor &a, const LLUIColor &b)
- {
- return false;
- }
+ ParamValue<LLUIColor>::ParamValue(const LLUIColor& color)
+ : super_t(color)
+ {}
+
+ void ParamValue<LLUIColor>::updateValueFromBlock()
+ {}
+
+ void ParamValue<LLUIColor>::updateBlockFromValue(bool)
+ {}
+
+ bool ParamCompare<const LLFontGL*, false>::equals(const LLFontGL* a, const LLFontGL* b)
+ {
+ return false;
+ }
+
+ ParamValue<const LLFontGL*>::ParamValue(const LLFontGL* fontp)
+ : super_t(fontp)
+ {}
+
+ void ParamValue<const LLFontGL*>::updateValueFromBlock()
+ {}
+
+ void ParamValue<const LLFontGL*>::updateBlockFromValue(bool)
+ {}
+
+ void TypeValues<LLFontGL::HAlign>::declareValues()
+ {}
+
+ void TypeValues<LLFontGL::VAlign>::declareValues()
+ {}
+
+ void TypeValues<LLFontGL::ShadowType>::declareValues()
+ {}
+
+ void ParamValue<LLUIImage*>::updateValueFromBlock()
+ {}
+
+ void ParamValue<LLUIImage*>::updateBlockFromValue(bool)
+ {}
+
+
+ bool ParamCompare<LLUIImage*, false>::equals(
+ LLUIImage* const &a,
+ LLUIImage* const &b)
+ {
+ return false;
+ }
+
+ bool ParamCompare<LLUIColor, false>::equals(const LLUIColor &a, const LLUIColor &b)
+ {
+ return false;
+ }
}
//static
LLFontGL* LLFontGL::getFontDefault()
{
- return NULL;
+ return NULL;
}
char const* const _PREHASH_AgentData = (char *)"AgentData";
diff --git a/indra/llui/tests/llurlentry_test.cpp b/indra/llui/tests/llurlentry_test.cpp
index 2b44e61dea..3f0b230a4f 100644
--- a/indra/llui/tests/llurlentry_test.cpp
+++ b/indra/llui/tests/llurlentry_test.cpp
@@ -1,935 +1,935 @@
-/**
- * @file llurlentry_test.cpp
- * @author Martin Reddy
- * @brief Unit tests for LLUrlEntry objects
- *
- * $LicenseInfo:firstyear=2009&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#include "linden_common.h"
-#include "../llurlentry.h"
-#include "../lluictrl.h"
-//#include "llurlentry_stub.cpp"
-#include "lltut.h"
-#include "../lluicolortable.h"
-#include "../llrender/lluiimage.h"
-#include "../llmessage/llexperiencecache.h"
-
-#include <boost/regex.hpp>
-
-#if LL_WINDOWS
-// because something pulls in window and lldxdiag dependencies which in turn need wbemuuid.lib
- #pragma comment(lib, "wbemuuid.lib")
-#endif
-
-
-// namespace LLExperienceCache
-// {
-// const LLSD& get( const LLUUID& key)
-// {
-// static LLSD boo;
-// return boo;
-// }
-//
-// void get( const LLUUID& key, callback_slot_t slot ){}
-//
-// }
-
-/*==========================================================================*|
-typedef std::map<std::string, LLControlGroup*> settings_map_t;
-settings_map_t LLUI::sSettingGroups;
-
-bool LLControlGroup::getBOOL(const std::string& name)
-{
- return false;
-}
-
-LLUIColor LLUIColorTable::getColor(const std::string& name, const LLColor4& default_color) const
-{
- return LLUIColor();
-}
-
-LLUIColor::LLUIColor() : mColorPtr(NULL) {}
-
-LLUIImage::LLUIImage(const std::string& name, LLPointer<LLTexture> image)
-{
-}
-
-LLUIImage::~LLUIImage()
-{
-}
-
-//virtual
-S32 LLUIImage::getWidth() const
-{
- return 0;
-}
-
-//virtual
-S32 LLUIImage::getHeight() const
-{
- return 0;
-}
-|*==========================================================================*/
-
-namespace tut
-{
- struct LLUrlEntryData
- {
- };
-
- typedef test_group<LLUrlEntryData> factory;
- typedef factory::object object;
-}
-
-namespace
-{
- tut::factory tf("LLUrlEntry");
-}
-
-namespace tut
-{
- void testRegex(const std::string &testname, LLUrlEntryBase &entry,
- const char *text, const std::string &expected)
- {
- boost::regex regex = entry.getPattern();
- std::string url = "";
- boost::cmatch result;
- bool found = boost::regex_search(text, result, regex);
- if (found)
- {
- S32 start = static_cast<U32>(result[0].first - text);
- S32 end = static_cast<U32>(result[0].second - text);
- url = entry.getUrl(std::string(text+start, end-start));
- }
- ensure_equals(testname, url, expected);
- }
-
- void dummyCallback(const std::string &url, const std::string &label, const std::string& icon)
- {
- }
-
- void testLabel(const std::string &testname, LLUrlEntryBase &entry,
- const char *text, const std::string &expected)
- {
- boost::regex regex = entry.getPattern();
- std::string label = "";
- boost::cmatch result;
- bool found = boost::regex_search(text, result, regex);
- if (found)
- {
- S32 start = static_cast<U32>(result[0].first - text);
- S32 end = static_cast<U32>(result[0].second - text);
- std::string url = std::string(text+start, end-start);
- label = entry.getLabel(url, boost::bind(dummyCallback, _1, _2, _3));
- }
- ensure_equals(testname, label, expected);
- }
-
- void testLocation(const std::string &testname, LLUrlEntryBase &entry,
- const char *text, const std::string &expected)
- {
- boost::regex regex = entry.getPattern();
- std::string location = "";
- boost::cmatch result;
- bool found = boost::regex_search(text, result, regex);
- if (found)
- {
- S32 start = static_cast<U32>(result[0].first - text);
- S32 end = static_cast<U32>(result[0].second - text);
- std::string url = std::string(text+start, end-start);
- location = entry.getLocation(url);
- }
- ensure_equals(testname, location, expected);
- }
-
-
- template<> template<>
- void object::test<1>()
- {
- //
- // test LLUrlEntryHTTP - standard http Urls
- //
- LLUrlEntryHTTP url;
-
- testRegex("no valid url", url,
- "htp://slurl.com/",
- "");
-
- testRegex("simple http (1)", url,
- "http://slurl.com/",
- "http://slurl.com/");
-
- testRegex("simple http (2)", url,
- "http://slurl.com",
- "http://slurl.com");
-
- testRegex("simple http (3)", url,
- "http://slurl.com/about.php",
- "http://slurl.com/about.php");
-
- testRegex("simple https", url,
- "https://slurl.com/about.php",
- "https://slurl.com/about.php");
-
- testRegex("http in text (1)", url,
- "XX http://slurl.com/ XX",
- "http://slurl.com/");
-
- testRegex("http in text (2)", url,
- "XX http://slurl.com/about.php XX",
- "http://slurl.com/about.php");
-
- testRegex("https in text", url,
- "XX https://slurl.com/about.php XX",
- "https://slurl.com/about.php");
-
- testRegex("two http urls", url,
- "XX http://slurl.com/about.php http://secondlife.com/ XX",
- "http://slurl.com/about.php");
-
- testRegex("http url with port and username", url,
- "XX http://nobody@slurl.com:80/about.php http://secondlife.com/ XX",
- "http://nobody@slurl.com:80/about.php");
-
- testRegex("http url with port, username, and query string", url,
- "XX http://nobody@slurl.com:80/about.php?title=hi%20there http://secondlife.com/ XX",
- "http://nobody@slurl.com:80/about.php?title=hi%20there");
-
- // note: terminating commas will be removed by LLUrlRegistry:findUrl()
- testRegex("http url with commas in middle and terminating", url,
- "XX http://slurl.com/?title=Hi,There, XX",
- "http://slurl.com/?title=Hi,There,");
-
- // note: terminating periods will be removed by LLUrlRegistry:findUrl()
- testRegex("http url with periods in middle and terminating", url,
- "XX http://slurl.com/index.php. XX",
- "http://slurl.com/index.php.");
-
- // DEV-19842: Closing parenthesis ")" breaks urls
- testRegex("http url with brackets (1)", url,
- "XX http://en.wikipedia.org/wiki/JIRA_(software) XX",
- "http://en.wikipedia.org/wiki/JIRA_(software)");
-
- // DEV-19842: Closing parenthesis ")" breaks urls
- testRegex("http url with brackets (2)", url,
- "XX http://jira.secondlife.com/secure/attachment/17990/eggy+avs+in+1.21.0+(93713)+public+nightly.jpg XX",
- "http://jira.secondlife.com/secure/attachment/17990/eggy+avs+in+1.21.0+(93713)+public+nightly.jpg");
-
- // DEV-10353: URLs in chat log terminated incorrectly when newline in chat
- testRegex("http url with newlines", url,
- "XX\nhttp://www.secondlife.com/\nXX",
- "http://www.secondlife.com/");
-
- testRegex("http url without tld shouldn't be decorated (1)", url,
- "http://test",
- "");
-
- testRegex("http url without tld shouldn't be decorated (2)", url,
- "http://test .com",
- "");
- }
-
- template<> template<>
- void object::test<2>()
- {
- //
- // test LLUrlEntryHTTPLabel - wiki-style http Urls with labels
- //
- LLUrlEntryHTTPLabel url;
-
- testRegex("invalid wiki url [1]", url,
- "[http://www.example.org]",
- "");
-
- testRegex("invalid wiki url [2]", url,
- "[http://www.example.org",
- "");
-
- testRegex("invalid wiki url [3]", url,
- "[http://www.example.org Label",
- "");
-
- testRegex("example.org with label (spaces)", url,
- "[http://www.example.org Text]",
- "http://www.example.org");
-
- testRegex("example.org with label (tabs)", url,
- "[http://www.example.org\t Text]",
- "http://www.example.org");
-
- testRegex("SL http URL with label", url,
- "[http://www.secondlife.com/ Second Life]",
- "http://www.secondlife.com/");
-
- testRegex("SL https URL with label", url,
- "XXX [https://www.secondlife.com/ Second Life] YYY",
- "https://www.secondlife.com/");
-
- testRegex("SL http URL with label", url,
- "[http://www.secondlife.com/?test=Hi%20There Second Life]",
- "http://www.secondlife.com/?test=Hi%20There");
- }
-
- template<> template<>
- void object::test<3>()
- {
- //
- // test LLUrlEntrySLURL - second life URLs
- //
- LLUrlEntrySLURL url;
-
- testRegex("no valid slurl [1]", url,
- "htp://slurl.com/secondlife/Ahern/50/50/50/",
- "");
-
- testRegex("no valid slurl [2]", url,
- "http://slurl.com/secondlife/",
- "");
-
- testRegex("no valid slurl [3]", url,
- "hhtp://slurl.com/secondlife/Ahern/50/FOO/50/",
- "");
-
- testRegex("Ahern (50,50,50) [1]", url,
- "http://slurl.com/secondlife/Ahern/50/50/50/",
- "http://slurl.com/secondlife/Ahern/50/50/50/");
-
- testRegex("Ahern (50,50,50) [2]", url,
- "XXX http://slurl.com/secondlife/Ahern/50/50/50/ XXX",
- "http://slurl.com/secondlife/Ahern/50/50/50/");
-
- testRegex("Ahern (50,50,50) [3]", url,
- "XXX http://slurl.com/secondlife/Ahern/50/50/50 XXX",
- "http://slurl.com/secondlife/Ahern/50/50/50");
-
- testRegex("Ahern (50,50,50) multicase", url,
- "XXX http://SLUrl.com/SecondLife/Ahern/50/50/50/ XXX",
- "http://SLUrl.com/SecondLife/Ahern/50/50/50/");
-
- testRegex("Ahern (50,50) [1]", url,
- "XXX http://slurl.com/secondlife/Ahern/50/50/ XXX",
- "http://slurl.com/secondlife/Ahern/50/50/");
-
- testRegex("Ahern (50,50) [2]", url,
- "XXX http://slurl.com/secondlife/Ahern/50/50 XXX",
- "http://slurl.com/secondlife/Ahern/50/50");
-
- testRegex("Ahern (50)", url,
- "XXX http://slurl.com/secondlife/Ahern/50 XXX",
- "http://slurl.com/secondlife/Ahern/50");
-
- testRegex("Ahern", url,
- "XXX http://slurl.com/secondlife/Ahern/ XXX",
- "http://slurl.com/secondlife/Ahern/");
-
- testRegex("Ahern SLURL with title", url,
- "XXX http://slurl.com/secondlife/Ahern/50/50/50/?title=YOUR%20TITLE%20HERE! XXX",
- "http://slurl.com/secondlife/Ahern/50/50/50/?title=YOUR%20TITLE%20HERE!");
-
- testRegex("Ahern SLURL with msg", url,
- "XXX http://slurl.com/secondlife/Ahern/50/50/50/?msg=Your%20text%20here. XXX",
- "http://slurl.com/secondlife/Ahern/50/50/50/?msg=Your%20text%20here.");
-
- // DEV-21577: In-world SLURLs containing "(" or ")" are not treated as a hyperlink in chat
- testRegex("SLURL with brackets", url,
- "XXX http://slurl.com/secondlife/Burning%20Life%20(Hyper)/27/210/30 XXX",
- "http://slurl.com/secondlife/Burning%20Life%20(Hyper)/27/210/30");
-
- // DEV-35459: SLURLs and teleport Links not parsed properly
- testRegex("SLURL with quote", url,
- "XXX http://slurl.com/secondlife/A'ksha%20Oasis/41/166/701 XXX",
- "http://slurl.com/secondlife/A%27ksha%20Oasis/41/166/701");
- }
-
- template<> template<>
- void object::test<4>()
- {
- //
- // test LLUrlEntryAgent - secondlife://app/agent Urls
- //
- LLUrlEntryAgent url;
-
- testRegex("Invalid Agent Url", url,
- "secondlife:///app/agent/0e346d8b-4433-4d66-XXXX-fd37083abc4c/about",
- "");
-
- testRegex("Agent Url ", url,
- "secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about",
- "secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about");
-
- testRegex("Agent Url in text", url,
- "XXX secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about XXX",
- "secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about");
-
- testRegex("Agent Url multicase", url,
- "XXX secondlife:///App/AGENT/0E346D8B-4433-4d66-a6b0-fd37083abc4c/About XXX",
- "secondlife:///App/AGENT/0E346D8B-4433-4d66-a6b0-fd37083abc4c/About");
-
- testRegex("Agent Url alternate command", url,
- "XXX secondlife:///App/AGENT/0E346D8B-4433-4d66-a6b0-fd37083abc4c/foobar",
- "secondlife:///App/AGENT/0E346D8B-4433-4d66-a6b0-fd37083abc4c/foobar");
-
- testRegex("Standalone Agent Url ", url,
- "x-grid-location-info://lincoln.lindenlab.com/app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about",
- "x-grid-location-info://lincoln.lindenlab.com/app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about");
-
- testRegex("Standalone Agent Url Multicase with Text", url,
- "M x-grid-location-info://lincoln.lindenlab.com/app/AGENT/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about M",
- "x-grid-location-info://lincoln.lindenlab.com/app/AGENT/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about");
- }
-
- template<> template<>
- void object::test<5>()
- {
- //
- // test LLUrlEntryGroup - secondlife://app/group Urls
- //
- LLUrlEntryGroup url;
-
- testRegex("Invalid Group Url", url,
- "secondlife:///app/group/00005ff3-4044-c79f-XXXX-fb28ae0df991/about",
- "");
-
- testRegex("Group Url ", url,
- "secondlife:///app/group/00005ff3-4044-c79f-9de8-fb28ae0df991/about",
- "secondlife:///app/group/00005ff3-4044-c79f-9de8-fb28ae0df991/about");
-
- testRegex("Group Url ", url,
- "secondlife:///app/group/00005ff3-4044-c79f-9de8-fb28ae0df991/inspect",
- "secondlife:///app/group/00005ff3-4044-c79f-9de8-fb28ae0df991/inspect");
-
- testRegex("Group Url in text", url,
- "XXX secondlife:///app/group/00005ff3-4044-c79f-9de8-fb28ae0df991/about XXX",
- "secondlife:///app/group/00005ff3-4044-c79f-9de8-fb28ae0df991/about");
-
- testRegex("Group Url multicase", url,
- "XXX secondlife:///APP/Group/00005FF3-4044-c79f-9de8-fb28ae0df991/About XXX",
- "secondlife:///APP/Group/00005FF3-4044-c79f-9de8-fb28ae0df991/About");
-
- testRegex("Standalone Group Url ", url,
- "x-grid-location-info://lincoln.lindenlab.com/app/group/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about",
- "x-grid-location-info://lincoln.lindenlab.com/app/group/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about");
-
- testRegex("Standalone Group Url Multicase ith Text", url,
- "M x-grid-location-info://lincoln.lindenlab.com/app/GROUP/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about M",
- "x-grid-location-info://lincoln.lindenlab.com/app/GROUP/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about");
-
- }
-
- template<> template<>
- void object::test<6>()
- {
- //
- // test LLUrlEntryPlace - secondlife://<location> URLs
- //
- LLUrlEntryPlace url;
-
- testRegex("no valid slurl [1]", url,
- "secondlife://Ahern/FOO/50/",
- "");
-
- testRegex("Ahern (50,50,50) [1]", url,
- "secondlife://Ahern/50/50/50/",
- "secondlife://Ahern/50/50/50/");
-
- testRegex("Ahern (50,50,50) [2]", url,
- "XXX secondlife://Ahern/50/50/50/ XXX",
- "secondlife://Ahern/50/50/50/");
-
- testRegex("Ahern (50,50,50) [3]", url,
- "XXX secondlife://Ahern/50/50/50 XXX",
- "secondlife://Ahern/50/50/50");
-
- testRegex("Ahern (50,50,50) multicase", url,
- "XXX SecondLife://Ahern/50/50/50/ XXX",
- "SecondLife://Ahern/50/50/50/");
-
- testRegex("Ahern (50,50) [1]", url,
- "XXX secondlife://Ahern/50/50/ XXX",
- "secondlife://Ahern/50/50/");
-
- testRegex("Ahern (50,50) [2]", url,
- "XXX secondlife://Ahern/50/50 XXX",
- "secondlife://Ahern/50/50");
-
- // DEV-21577: In-world SLURLs containing "(" or ")" are not treated as a hyperlink in chat
- testRegex("SLURL with brackets", url,
- "XXX secondlife://Burning%20Life%20(Hyper)/27/210/30 XXX",
- "secondlife://Burning%20Life%20(Hyper)/27/210/30");
-
- // DEV-35459: SLURLs and teleport Links not parsed properly
- testRegex("SLURL with quote", url,
- "XXX secondlife://A'ksha%20Oasis/41/166/701 XXX",
- "secondlife://A%27ksha%20Oasis/41/166/701");
-
- testRegex("Standalone All Hands (50,50) [2] with text", url,
- "XXX x-grid-location-info://lincoln.lindenlab.com/region/All%20Hands/50/50/50 XXX",
- "x-grid-location-info://lincoln.lindenlab.com/region/All%20Hands/50/50/50");
- }
-
- template<> template<>
- void object::test<7>()
- {
- //
- // test LLUrlEntryParcel - secondlife://app/parcel Urls
- //
- LLUrlEntryParcel url;
-
- testRegex("Invalid Classified Url", url,
- "secondlife:///app/parcel/0000060e-4b39-e00b-XXXX-d98b1934e3a8/about",
- "");
-
- testRegex("Classified Url ", url,
- "secondlife:///app/parcel/0000060e-4b39-e00b-d0c3-d98b1934e3a8/about",
- "secondlife:///app/parcel/0000060e-4b39-e00b-d0c3-d98b1934e3a8/about");
-
- testRegex("Classified Url in text", url,
- "XXX secondlife:///app/parcel/0000060e-4b39-e00b-d0c3-d98b1934e3a8/about XXX",
- "secondlife:///app/parcel/0000060e-4b39-e00b-d0c3-d98b1934e3a8/about");
-
- testRegex("Classified Url multicase", url,
- "XXX secondlife:///APP/Parcel/0000060e-4b39-e00b-d0c3-d98b1934e3a8/About XXX",
- "secondlife:///APP/Parcel/0000060e-4b39-e00b-d0c3-d98b1934e3a8/About");
- }
- template<> template<>
- void object::test<8>()
- {
- //
- // test LLUrlEntryTeleport - secondlife://app/teleport URLs
- //
- LLUrlEntryTeleport url;
-
- testRegex("no valid teleport [1]", url,
- "http://slurl.com/secondlife/Ahern/50/50/50/",
- "");
-
- testRegex("no valid teleport [2]", url,
- "secondlife:///app/teleport/",
- "");
-
- testRegex("no valid teleport [3]", url,
- "second-life:///app/teleport/Ahern/50/50/50/",
- "");
-
- testRegex("no valid teleport [3]", url,
- "hhtp://slurl.com/secondlife/Ahern/50/FOO/50/",
- "");
-
- testRegex("Ahern (50,50,50) [1]", url,
- "secondlife:///app/teleport/Ahern/50/50/50/",
- "secondlife:///app/teleport/Ahern/50/50/50/");
-
- testRegex("Ahern (50,50,50) [2]", url,
- "XXX secondlife:///app/teleport/Ahern/50/50/50/ XXX",
- "secondlife:///app/teleport/Ahern/50/50/50/");
-
- testRegex("Ahern (50,50,50) [3]", url,
- "XXX secondlife:///app/teleport/Ahern/50/50/50 XXX",
- "secondlife:///app/teleport/Ahern/50/50/50");
-
- testRegex("Ahern (50,50,50) multicase", url,
- "XXX secondlife:///app/teleport/Ahern/50/50/50/ XXX",
- "secondlife:///app/teleport/Ahern/50/50/50/");
-
- testRegex("Ahern (50,50) [1]", url,
- "XXX secondlife:///app/teleport/Ahern/50/50/ XXX",
- "secondlife:///app/teleport/Ahern/50/50/");
-
- testRegex("Ahern (50,50) [2]", url,
- "XXX secondlife:///app/teleport/Ahern/50/50 XXX",
- "secondlife:///app/teleport/Ahern/50/50");
-
- testRegex("Ahern (50)", url,
- "XXX secondlife:///app/teleport/Ahern/50 XXX",
- "secondlife:///app/teleport/Ahern/50");
-
- testRegex("Ahern", url,
- "XXX secondlife:///app/teleport/Ahern/ XXX",
- "secondlife:///app/teleport/Ahern/");
-
- testRegex("Ahern teleport with title", url,
- "XXX secondlife:///app/teleport/Ahern/50/50/50/?title=YOUR%20TITLE%20HERE! XXX",
- "secondlife:///app/teleport/Ahern/50/50/50/?title=YOUR%20TITLE%20HERE!");
-
- testRegex("Ahern teleport with msg", url,
- "XXX secondlife:///app/teleport/Ahern/50/50/50/?msg=Your%20text%20here. XXX",
- "secondlife:///app/teleport/Ahern/50/50/50/?msg=Your%20text%20here.");
-
- // DEV-21577: In-world SLURLs containing "(" or ")" are not treated as a hyperlink in chat
- testRegex("Teleport with brackets", url,
- "XXX secondlife:///app/teleport/Burning%20Life%20(Hyper)/27/210/30 XXX",
- "secondlife:///app/teleport/Burning%20Life%20(Hyper)/27/210/30");
-
- // DEV-35459: SLURLs and teleport Links not parsed properly
- testRegex("Teleport url with quote", url,
- "XXX secondlife:///app/teleport/A'ksha%20Oasis/41/166/701 XXX",
- "secondlife:///app/teleport/A%27ksha%20Oasis/41/166/701");
-
- testRegex("Standalone All Hands", url,
- "XXX x-grid-location-info://lincoln.lindenlab.com/app/teleport/All%20Hands/50/50/50 XXX",
- "x-grid-location-info://lincoln.lindenlab.com/app/teleport/All%20Hands/50/50/50");
- }
-
- template<> template<>
- void object::test<9>()
- {
- //
- // test LLUrlEntrySL - general secondlife:// URLs
- //
- LLUrlEntrySL url;
-
- testRegex("no valid slapp [1]", url,
- "http:///app/",
- "");
-
- testRegex("valid slapp [1]", url,
- "secondlife:///app/",
- "secondlife:///app/");
-
- testRegex("valid slapp [2]", url,
- "secondlife:///app/teleport/Ahern/50/50/50/",
- "secondlife:///app/teleport/Ahern/50/50/50/");
-
- testRegex("valid slapp [3]", url,
- "secondlife:///app/foo",
- "secondlife:///app/foo");
-
- testRegex("valid slapp [4]", url,
- "secondlife:///APP/foo?title=Hi%20There",
- "secondlife:///APP/foo?title=Hi%20There");
-
- testRegex("valid slapp [5]", url,
- "secondlife://host/app/",
- "secondlife://host/app/");
-
- testRegex("valid slapp [6]", url,
- "secondlife://host:8080/foo/bar",
- "secondlife://host:8080/foo/bar");
- }
-
- template<> template<>
- void object::test<10>()
- {
- //
- // test LLUrlEntrySLLabel - general secondlife:// URLs with labels
- //
- LLUrlEntrySLLabel url;
-
- testRegex("invalid wiki url [1]", url,
- "[secondlife:///app/]",
- "");
-
- testRegex("invalid wiki url [2]", url,
- "[secondlife:///app/",
- "");
-
- testRegex("invalid wiki url [3]", url,
- "[secondlife:///app/ Label",
- "");
-
- testRegex("agent slurl with label (spaces)", url,
- "[secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about Text]",
- "secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about");
-
- testRegex("agent slurl with label (tabs)", url,
- "[secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about\t Text]",
- "secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about");
-
- testRegex("agent slurl with label", url,
- "[secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about FirstName LastName]",
- "secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about");
-
- testRegex("teleport slurl with label", url,
- "XXX [secondlife:///app/teleport/Ahern/50/50/50/ Teleport to Ahern] YYY",
- "secondlife:///app/teleport/Ahern/50/50/50/");
- }
-
- template<> template<>
- void object::test<11>()
- {
- //
- // test LLUrlEntryNoLink - turn off hyperlinking
- //
- LLUrlEntryNoLink url;
-
- testRegex("<nolink> [1]", url,
- "<nolink>google.com</nolink>",
- "google.com");
-
- testRegex("<nolink> [2]", url,
- "<nolink>google.com",
- "");
-
- testRegex("<nolink> [3]", url,
- "google.com</nolink>",
- "");
-
- testRegex("<nolink> [4]", url,
- "<nolink>Hello World</nolink>",
- "Hello World");
-
- testRegex("<nolink> [5]", url,
- "<nolink>My Object</nolink>",
- "My Object");
- }
-
- template<> template<>
- void object::test<12>()
- {
- //
- // test LLUrlEntryRegion - secondlife:///app/region/<location> URLs
- //
- LLUrlEntryRegion url;
-
- // Regex tests.
- testRegex("no valid region", url,
- "secondlife:///app/region/",
- "");
-
- testRegex("invalid coords", url,
- "secondlife:///app/region/Korea2/a/b/c",
- "secondlife:///app/region/Korea2/"); // don't count invalid coords
-
- testRegex("Ahern (50,50,50) [1]", url,
- "secondlife:///app/region/Ahern/50/50/50/",
- "secondlife:///app/region/Ahern/50/50/50/");
-
- testRegex("Ahern (50,50,50) [2]", url,
- "XXX secondlife:///app/region/Ahern/50/50/50/ XXX",
- "secondlife:///app/region/Ahern/50/50/50/");
-
- testRegex("Ahern (50,50,50) [3]", url,
- "XXX secondlife:///app/region/Ahern/50/50/50 XXX",
- "secondlife:///app/region/Ahern/50/50/50");
-
- testRegex("Ahern (50,50,50) multicase", url,
- "XXX secondlife:///app/region/Ahern/50/50/50/ XXX",
- "secondlife:///app/region/Ahern/50/50/50/");
-
- testRegex("Ahern (50,50) [1]", url,
- "XXX secondlife:///app/region/Ahern/50/50/ XXX",
- "secondlife:///app/region/Ahern/50/50/");
-
- testRegex("Ahern (50,50) [2]", url,
- "XXX secondlife:///app/region/Ahern/50/50 XXX",
- "secondlife:///app/region/Ahern/50/50");
-
- // DEV-21577: In-world SLURLs containing "(" or ")" are not treated as a hyperlink in chat
- testRegex("Region with brackets", url,
- "XXX secondlife:///app/region/Burning%20Life%20(Hyper)/27/210/30 XXX",
- "secondlife:///app/region/Burning%20Life%20(Hyper)/27/210/30");
-
- // Rendering tests.
- testLabel("Render /app/region/Ahern/50/50/50/", url,
- "secondlife:///app/region/Ahern/50/50/50/",
- "Ahern (50,50,50)");
-
- testLabel("Render /app/region/Ahern/50/50/50", url,
- "secondlife:///app/region/Ahern/50/50/50",
- "Ahern (50,50,50)");
-
- testLabel("Render /app/region/Ahern/50/50/", url,
- "secondlife:///app/region/Ahern/50/50/",
- "Ahern (50,50)");
-
- testLabel("Render /app/region/Ahern/50/50", url,
- "secondlife:///app/region/Ahern/50/50",
- "Ahern (50,50)");
-
- testLabel("Render /app/region/Ahern/50/", url,
- "secondlife:///app/region/Ahern/50/",
- "Ahern (50)");
-
- testLabel("Render /app/region/Ahern/50", url,
- "secondlife:///app/region/Ahern/50",
- "Ahern (50)");
-
- testLabel("Render /app/region/Ahern/", url,
- "secondlife:///app/region/Ahern/",
- "Ahern");
-
- testLabel("Render /app/region/Ahern/ within context", url,
- "XXX secondlife:///app/region/Ahern/ XXX",
- "Ahern");
-
- testLabel("Render /app/region/Ahern", url,
- "secondlife:///app/region/Ahern",
- "Ahern");
-
- testLabel("Render /app/region/Ahern within context", url,
- "XXX secondlife:///app/region/Ahern XXX",
- "Ahern");
-
- testLabel("Render /app/region/Product%20Engine/", url,
- "secondlife:///app/region/Product%20Engine/",
- "Product Engine");
-
- testLabel("Render /app/region/Product%20Engine", url,
- "secondlife:///app/region/Product%20Engine",
- "Product Engine");
-
- // Location parsing texts.
- testLocation("Location /app/region/Ahern/50/50/50/", url,
- "secondlife:///app/region/Ahern/50/50/50/",
- "Ahern");
-
- testLocation("Location /app/region/Product%20Engine", url,
- "secondlife:///app/region/Product%20Engine",
- "Product Engine");
- }
-
- template<> template<>
- void object::test<13>()
- {
- //
- // test LLUrlEntryemail - general emails
- //
- LLUrlEntryEmail url;
-
- // Regex tests.
- testRegex("match e-mail addresses", url,
- "test@lindenlab.com",
- "mailto:test@lindenlab.com");
-
- testRegex("match e-mail addresses with mailto: prefix", url,
- "mailto:test@lindenlab.com",
- "mailto:test@lindenlab.com");
-
- testRegex("match e-mail addresses with different domains", url,
- "test@foo.org.us",
- "mailto:test@foo.org.us");
-
- testRegex("match e-mail addresses with different domains", url,
- "test@foo.bar",
- "mailto:test@foo.bar");
-
- testRegex("don't match incorrect e-mail addresses", url,
- "test @foo.com",
- "");
-
- testRegex("don't match incorrect e-mail addresses", url,
- "test@ foo.com",
- "");
- }
-
- template<> template<>
- void object::test<14>()
- {
- //
- // test LLUrlEntrySimpleSecondlifeURL - http://*.secondlife.com/* and http://*lindenlab.com/* urls
- //
- LLUrlEntrySecondlifeURL url;
-
- testRegex("match urls with protocol", url,
- "this url should match http://lindenlab.com/products/second-life",
- "http://lindenlab.com/products/second-life");
-
- testRegex("match urls with protocol", url,
- "search something https://marketplace.secondlife.com/products/search on marketplace and test the https",
- "https://marketplace.secondlife.com/products/search");
-
- testRegex("match HTTPS urls with port", url,
- "let's specify some port https://secondlife.com:888/status",
- "https://secondlife.com:888/status");
-
- testRegex("don't match HTTP urls with port", url,
- "let's specify some port for HTTP http://secondlife.com:888/status",
- "");
-
- testRegex("don't match urls w/o protocol", url,
- "looks like an url something www.marketplace.secondlife.com/products but no https prefix",
- "");
-
- testRegex("but with a protocol www is fine", url,
- "so let's add a protocol https://www.marketplace.secondlife.com:8888/products",
- "https://www.marketplace.secondlife.com:8888/products");
-
- testRegex("don't match urls w/o protocol", url,
- "and even no www something secondlife.com/status",
- "");
- }
-
- template<> template<>
- void object::test<15>()
- {
- //
- // test LLUrlEntrySimpleSecondlifeURL - http://*.secondlife.com and http://*lindenlab.com urls
- //
-
- LLUrlEntrySimpleSecondlifeURL url;
-
- testRegex("match urls with a protocol", url,
- "this url should match http://lindenlab.com",
- "http://lindenlab.com");
-
- testRegex("match urls with a protocol", url,
- "search something https://marketplace.secondlife.com on marketplace and test the https",
- "https://marketplace.secondlife.com");
-
- testRegex("don't match urls w/o protocol", url,
- "looks like an url something www.marketplace.secondlife.com but no https prefix",
- "");
-
- testRegex("but with a protocol www is fine", url,
- "so let's add a protocol http://www.marketplace.secondlife.com",
- "http://www.marketplace.secondlife.com");
-
- testRegex("don't match urls w/o protocol", url,
- "and even no www something lindenlab.com",
- "");
- }
-
- template<> template<>
- void object::test<16>()
- {
- //
- // test LLUrlEntryIPv6
- //
- LLUrlEntryIPv6 url;
-
- // Regex tests.
- testRegex("match urls with a protocol", url,
- "this url should match http://[::1]",
- "http://[::1]");
-
- testRegex("match urls with a protocol and query", url,
- "this url should match http://[::1]/file.mp3",
- "http://[::1]/file.mp3");
-
- testRegex("match urls with a protocol", url,
- "this url should match http://[2001:0db8:11a3:09d7:1f34:8a2e:07a0:765d]",
- "http://[2001:0db8:11a3:09d7:1f34:8a2e:07a0:765d]");
-
- testRegex("match urls with port", url,
- "let's specify some port http://[2001:0db8:11a3:09d7:1f34:8a2e:07a0:765d]:8080",
- "http://[2001:0db8:11a3:09d7:1f34:8a2e:07a0:765d]:8080");
-
- testRegex("don't match urls w/o protocol", url,
- "looks like an url something [2001:0db8:11a3:09d7:1f34:8a2e:07a0:765d] but no https prefix",
- "");
-
- testRegex("don't match incorrect urls", url,
- "http://[ 2001:0db8:11a3:09d7:1f34:8a2e:07a0:765d ]",
- "");
- }
-}
+/**
+ * @file llurlentry_test.cpp
+ * @author Martin Reddy
+ * @brief Unit tests for LLUrlEntry objects
+ *
+ * $LicenseInfo:firstyear=2009&license=viewerlgpl$
+ * Second Life Viewer Source Code
+ * Copyright (C) 2010, Linden Research, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License only.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
+ * $/LicenseInfo$
+ */
+
+#include "linden_common.h"
+#include "../llurlentry.h"
+#include "../lluictrl.h"
+//#include "llurlentry_stub.cpp"
+#include "lltut.h"
+#include "../lluicolortable.h"
+#include "../llrender/lluiimage.h"
+#include "../llmessage/llexperiencecache.h"
+
+#include <boost/regex.hpp>
+
+#if LL_WINDOWS
+// because something pulls in window and lldxdiag dependencies which in turn need wbemuuid.lib
+ #pragma comment(lib, "wbemuuid.lib")
+#endif
+
+
+// namespace LLExperienceCache
+// {
+// const LLSD& get( const LLUUID& key)
+// {
+// static LLSD boo;
+// return boo;
+// }
+//
+// void get( const LLUUID& key, callback_slot_t slot ){}
+//
+// }
+
+/*==========================================================================*|
+typedef std::map<std::string, LLControlGroup*> settings_map_t;
+settings_map_t LLUI::sSettingGroups;
+
+bool LLControlGroup::getBOOL(const std::string& name)
+{
+ return false;
+}
+
+LLUIColor LLUIColorTable::getColor(const std::string& name, const LLColor4& default_color) const
+{
+ return LLUIColor();
+}
+
+LLUIColor::LLUIColor() : mColorPtr(NULL) {}
+
+LLUIImage::LLUIImage(const std::string& name, LLPointer<LLTexture> image)
+{
+}
+
+LLUIImage::~LLUIImage()
+{
+}
+
+//virtual
+S32 LLUIImage::getWidth() const
+{
+ return 0;
+}
+
+//virtual
+S32 LLUIImage::getHeight() const
+{
+ return 0;
+}
+|*==========================================================================*/
+
+namespace tut
+{
+ struct LLUrlEntryData
+ {
+ };
+
+ typedef test_group<LLUrlEntryData> factory;
+ typedef factory::object object;
+}
+
+namespace
+{
+ tut::factory tf("LLUrlEntry");
+}
+
+namespace tut
+{
+ void testRegex(const std::string &testname, LLUrlEntryBase &entry,
+ const char *text, const std::string &expected)
+ {
+ boost::regex regex = entry.getPattern();
+ std::string url = "";
+ boost::cmatch result;
+ bool found = boost::regex_search(text, result, regex);
+ if (found)
+ {
+ S32 start = static_cast<U32>(result[0].first - text);
+ S32 end = static_cast<U32>(result[0].second - text);
+ url = entry.getUrl(std::string(text+start, end-start));
+ }
+ ensure_equals(testname, url, expected);
+ }
+
+ void dummyCallback(const std::string &url, const std::string &label, const std::string& icon)
+ {
+ }
+
+ void testLabel(const std::string &testname, LLUrlEntryBase &entry,
+ const char *text, const std::string &expected)
+ {
+ boost::regex regex = entry.getPattern();
+ std::string label = "";
+ boost::cmatch result;
+ bool found = boost::regex_search(text, result, regex);
+ if (found)
+ {
+ S32 start = static_cast<U32>(result[0].first - text);
+ S32 end = static_cast<U32>(result[0].second - text);
+ std::string url = std::string(text+start, end-start);
+ label = entry.getLabel(url, boost::bind(dummyCallback, _1, _2, _3));
+ }
+ ensure_equals(testname, label, expected);
+ }
+
+ void testLocation(const std::string &testname, LLUrlEntryBase &entry,
+ const char *text, const std::string &expected)
+ {
+ boost::regex regex = entry.getPattern();
+ std::string location = "";
+ boost::cmatch result;
+ bool found = boost::regex_search(text, result, regex);
+ if (found)
+ {
+ S32 start = static_cast<U32>(result[0].first - text);
+ S32 end = static_cast<U32>(result[0].second - text);
+ std::string url = std::string(text+start, end-start);
+ location = entry.getLocation(url);
+ }
+ ensure_equals(testname, location, expected);
+ }
+
+
+ template<> template<>
+ void object::test<1>()
+ {
+ //
+ // test LLUrlEntryHTTP - standard http Urls
+ //
+ LLUrlEntryHTTP url;
+
+ testRegex("no valid url", url,
+ "htp://slurl.com/",
+ "");
+
+ testRegex("simple http (1)", url,
+ "http://slurl.com/",
+ "http://slurl.com/");
+
+ testRegex("simple http (2)", url,
+ "http://slurl.com",
+ "http://slurl.com");
+
+ testRegex("simple http (3)", url,
+ "http://slurl.com/about.php",
+ "http://slurl.com/about.php");
+
+ testRegex("simple https", url,
+ "https://slurl.com/about.php",
+ "https://slurl.com/about.php");
+
+ testRegex("http in text (1)", url,
+ "XX http://slurl.com/ XX",
+ "http://slurl.com/");
+
+ testRegex("http in text (2)", url,
+ "XX http://slurl.com/about.php XX",
+ "http://slurl.com/about.php");
+
+ testRegex("https in text", url,
+ "XX https://slurl.com/about.php XX",
+ "https://slurl.com/about.php");
+
+ testRegex("two http urls", url,
+ "XX http://slurl.com/about.php http://secondlife.com/ XX",
+ "http://slurl.com/about.php");
+
+ testRegex("http url with port and username", url,
+ "XX http://nobody@slurl.com:80/about.php http://secondlife.com/ XX",
+ "http://nobody@slurl.com:80/about.php");
+
+ testRegex("http url with port, username, and query string", url,
+ "XX http://nobody@slurl.com:80/about.php?title=hi%20there http://secondlife.com/ XX",
+ "http://nobody@slurl.com:80/about.php?title=hi%20there");
+
+ // note: terminating commas will be removed by LLUrlRegistry:findUrl()
+ testRegex("http url with commas in middle and terminating", url,
+ "XX http://slurl.com/?title=Hi,There, XX",
+ "http://slurl.com/?title=Hi,There,");
+
+ // note: terminating periods will be removed by LLUrlRegistry:findUrl()
+ testRegex("http url with periods in middle and terminating", url,
+ "XX http://slurl.com/index.php. XX",
+ "http://slurl.com/index.php.");
+
+ // DEV-19842: Closing parenthesis ")" breaks urls
+ testRegex("http url with brackets (1)", url,
+ "XX http://en.wikipedia.org/wiki/JIRA_(software) XX",
+ "http://en.wikipedia.org/wiki/JIRA_(software)");
+
+ // DEV-19842: Closing parenthesis ")" breaks urls
+ testRegex("http url with brackets (2)", url,
+ "XX http://jira.secondlife.com/secure/attachment/17990/eggy+avs+in+1.21.0+(93713)+public+nightly.jpg XX",
+ "http://jira.secondlife.com/secure/attachment/17990/eggy+avs+in+1.21.0+(93713)+public+nightly.jpg");
+
+ // DEV-10353: URLs in chat log terminated incorrectly when newline in chat
+ testRegex("http url with newlines", url,
+ "XX\nhttp://www.secondlife.com/\nXX",
+ "http://www.secondlife.com/");
+
+ testRegex("http url without tld shouldn't be decorated (1)", url,
+ "http://test",
+ "");
+
+ testRegex("http url without tld shouldn't be decorated (2)", url,
+ "http://test .com",
+ "");
+ }
+
+ template<> template<>
+ void object::test<2>()
+ {
+ //
+ // test LLUrlEntryHTTPLabel - wiki-style http Urls with labels
+ //
+ LLUrlEntryHTTPLabel url;
+
+ testRegex("invalid wiki url [1]", url,
+ "[http://www.example.org]",
+ "");
+
+ testRegex("invalid wiki url [2]", url,
+ "[http://www.example.org",
+ "");
+
+ testRegex("invalid wiki url [3]", url,
+ "[http://www.example.org Label",
+ "");
+
+ testRegex("example.org with label (spaces)", url,
+ "[http://www.example.org Text]",
+ "http://www.example.org");
+
+ testRegex("example.org with label (tabs)", url,
+ "[http://www.example.org\t Text]",
+ "http://www.example.org");
+
+ testRegex("SL http URL with label", url,
+ "[http://www.secondlife.com/ Second Life]",
+ "http://www.secondlife.com/");
+
+ testRegex("SL https URL with label", url,
+ "XXX [https://www.secondlife.com/ Second Life] YYY",
+ "https://www.secondlife.com/");
+
+ testRegex("SL http URL with label", url,
+ "[http://www.secondlife.com/?test=Hi%20There Second Life]",
+ "http://www.secondlife.com/?test=Hi%20There");
+ }
+
+ template<> template<>
+ void object::test<3>()
+ {
+ //
+ // test LLUrlEntrySLURL - second life URLs
+ //
+ LLUrlEntrySLURL url;
+
+ testRegex("no valid slurl [1]", url,
+ "htp://slurl.com/secondlife/Ahern/50/50/50/",
+ "");
+
+ testRegex("no valid slurl [2]", url,
+ "http://slurl.com/secondlife/",
+ "");
+
+ testRegex("no valid slurl [3]", url,
+ "hhtp://slurl.com/secondlife/Ahern/50/FOO/50/",
+ "");
+
+ testRegex("Ahern (50,50,50) [1]", url,
+ "http://slurl.com/secondlife/Ahern/50/50/50/",
+ "http://slurl.com/secondlife/Ahern/50/50/50/");
+
+ testRegex("Ahern (50,50,50) [2]", url,
+ "XXX http://slurl.com/secondlife/Ahern/50/50/50/ XXX",
+ "http://slurl.com/secondlife/Ahern/50/50/50/");
+
+ testRegex("Ahern (50,50,50) [3]", url,
+ "XXX http://slurl.com/secondlife/Ahern/50/50/50 XXX",
+ "http://slurl.com/secondlife/Ahern/50/50/50");
+
+ testRegex("Ahern (50,50,50) multicase", url,
+ "XXX http://SLUrl.com/SecondLife/Ahern/50/50/50/ XXX",
+ "http://SLUrl.com/SecondLife/Ahern/50/50/50/");
+
+ testRegex("Ahern (50,50) [1]", url,
+ "XXX http://slurl.com/secondlife/Ahern/50/50/ XXX",
+ "http://slurl.com/secondlife/Ahern/50/50/");
+
+ testRegex("Ahern (50,50) [2]", url,
+ "XXX http://slurl.com/secondlife/Ahern/50/50 XXX",
+ "http://slurl.com/secondlife/Ahern/50/50");
+
+ testRegex("Ahern (50)", url,
+ "XXX http://slurl.com/secondlife/Ahern/50 XXX",
+ "http://slurl.com/secondlife/Ahern/50");
+
+ testRegex("Ahern", url,
+ "XXX http://slurl.com/secondlife/Ahern/ XXX",
+ "http://slurl.com/secondlife/Ahern/");
+
+ testRegex("Ahern SLURL with title", url,
+ "XXX http://slurl.com/secondlife/Ahern/50/50/50/?title=YOUR%20TITLE%20HERE! XXX",
+ "http://slurl.com/secondlife/Ahern/50/50/50/?title=YOUR%20TITLE%20HERE!");
+
+ testRegex("Ahern SLURL with msg", url,
+ "XXX http://slurl.com/secondlife/Ahern/50/50/50/?msg=Your%20text%20here. XXX",
+ "http://slurl.com/secondlife/Ahern/50/50/50/?msg=Your%20text%20here.");
+
+ // DEV-21577: In-world SLURLs containing "(" or ")" are not treated as a hyperlink in chat
+ testRegex("SLURL with brackets", url,
+ "XXX http://slurl.com/secondlife/Burning%20Life%20(Hyper)/27/210/30 XXX",
+ "http://slurl.com/secondlife/Burning%20Life%20(Hyper)/27/210/30");
+
+ // DEV-35459: SLURLs and teleport Links not parsed properly
+ testRegex("SLURL with quote", url,
+ "XXX http://slurl.com/secondlife/A'ksha%20Oasis/41/166/701 XXX",
+ "http://slurl.com/secondlife/A%27ksha%20Oasis/41/166/701");
+ }
+
+ template<> template<>
+ void object::test<4>()
+ {
+ //
+ // test LLUrlEntryAgent - secondlife://app/agent Urls
+ //
+ LLUrlEntryAgent url;
+
+ testRegex("Invalid Agent Url", url,
+ "secondlife:///app/agent/0e346d8b-4433-4d66-XXXX-fd37083abc4c/about",
+ "");
+
+ testRegex("Agent Url ", url,
+ "secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about",
+ "secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about");
+
+ testRegex("Agent Url in text", url,
+ "XXX secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about XXX",
+ "secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about");
+
+ testRegex("Agent Url multicase", url,
+ "XXX secondlife:///App/AGENT/0E346D8B-4433-4d66-a6b0-fd37083abc4c/About XXX",
+ "secondlife:///App/AGENT/0E346D8B-4433-4d66-a6b0-fd37083abc4c/About");
+
+ testRegex("Agent Url alternate command", url,
+ "XXX secondlife:///App/AGENT/0E346D8B-4433-4d66-a6b0-fd37083abc4c/foobar",
+ "secondlife:///App/AGENT/0E346D8B-4433-4d66-a6b0-fd37083abc4c/foobar");
+
+ testRegex("Standalone Agent Url ", url,
+ "x-grid-location-info://lincoln.lindenlab.com/app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about",
+ "x-grid-location-info://lincoln.lindenlab.com/app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about");
+
+ testRegex("Standalone Agent Url Multicase with Text", url,
+ "M x-grid-location-info://lincoln.lindenlab.com/app/AGENT/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about M",
+ "x-grid-location-info://lincoln.lindenlab.com/app/AGENT/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about");
+ }
+
+ template<> template<>
+ void object::test<5>()
+ {
+ //
+ // test LLUrlEntryGroup - secondlife://app/group Urls
+ //
+ LLUrlEntryGroup url;
+
+ testRegex("Invalid Group Url", url,
+ "secondlife:///app/group/00005ff3-4044-c79f-XXXX-fb28ae0df991/about",
+ "");
+
+ testRegex("Group Url ", url,
+ "secondlife:///app/group/00005ff3-4044-c79f-9de8-fb28ae0df991/about",
+ "secondlife:///app/group/00005ff3-4044-c79f-9de8-fb28ae0df991/about");
+
+ testRegex("Group Url ", url,
+ "secondlife:///app/group/00005ff3-4044-c79f-9de8-fb28ae0df991/inspect",
+ "secondlife:///app/group/00005ff3-4044-c79f-9de8-fb28ae0df991/inspect");
+
+ testRegex("Group Url in text", url,
+ "XXX secondlife:///app/group/00005ff3-4044-c79f-9de8-fb28ae0df991/about XXX",
+ "secondlife:///app/group/00005ff3-4044-c79f-9de8-fb28ae0df991/about");
+
+ testRegex("Group Url multicase", url,
+ "XXX secondlife:///APP/Group/00005FF3-4044-c79f-9de8-fb28ae0df991/About XXX",
+ "secondlife:///APP/Group/00005FF3-4044-c79f-9de8-fb28ae0df991/About");
+
+ testRegex("Standalone Group Url ", url,
+ "x-grid-location-info://lincoln.lindenlab.com/app/group/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about",
+ "x-grid-location-info://lincoln.lindenlab.com/app/group/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about");
+
+ testRegex("Standalone Group Url Multicase ith Text", url,
+ "M x-grid-location-info://lincoln.lindenlab.com/app/GROUP/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about M",
+ "x-grid-location-info://lincoln.lindenlab.com/app/GROUP/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about");
+
+ }
+
+ template<> template<>
+ void object::test<6>()
+ {
+ //
+ // test LLUrlEntryPlace - secondlife://<location> URLs
+ //
+ LLUrlEntryPlace url;
+
+ testRegex("no valid slurl [1]", url,
+ "secondlife://Ahern/FOO/50/",
+ "");
+
+ testRegex("Ahern (50,50,50) [1]", url,
+ "secondlife://Ahern/50/50/50/",
+ "secondlife://Ahern/50/50/50/");
+
+ testRegex("Ahern (50,50,50) [2]", url,
+ "XXX secondlife://Ahern/50/50/50/ XXX",
+ "secondlife://Ahern/50/50/50/");
+
+ testRegex("Ahern (50,50,50) [3]", url,
+ "XXX secondlife://Ahern/50/50/50 XXX",
+ "secondlife://Ahern/50/50/50");
+
+ testRegex("Ahern (50,50,50) multicase", url,
+ "XXX SecondLife://Ahern/50/50/50/ XXX",
+ "SecondLife://Ahern/50/50/50/");
+
+ testRegex("Ahern (50,50) [1]", url,
+ "XXX secondlife://Ahern/50/50/ XXX",
+ "secondlife://Ahern/50/50/");
+
+ testRegex("Ahern (50,50) [2]", url,
+ "XXX secondlife://Ahern/50/50 XXX",
+ "secondlife://Ahern/50/50");
+
+ // DEV-21577: In-world SLURLs containing "(" or ")" are not treated as a hyperlink in chat
+ testRegex("SLURL with brackets", url,
+ "XXX secondlife://Burning%20Life%20(Hyper)/27/210/30 XXX",
+ "secondlife://Burning%20Life%20(Hyper)/27/210/30");
+
+ // DEV-35459: SLURLs and teleport Links not parsed properly
+ testRegex("SLURL with quote", url,
+ "XXX secondlife://A'ksha%20Oasis/41/166/701 XXX",
+ "secondlife://A%27ksha%20Oasis/41/166/701");
+
+ testRegex("Standalone All Hands (50,50) [2] with text", url,
+ "XXX x-grid-location-info://lincoln.lindenlab.com/region/All%20Hands/50/50/50 XXX",
+ "x-grid-location-info://lincoln.lindenlab.com/region/All%20Hands/50/50/50");
+ }
+
+ template<> template<>
+ void object::test<7>()
+ {
+ //
+ // test LLUrlEntryParcel - secondlife://app/parcel Urls
+ //
+ LLUrlEntryParcel url;
+
+ testRegex("Invalid Classified Url", url,
+ "secondlife:///app/parcel/0000060e-4b39-e00b-XXXX-d98b1934e3a8/about",
+ "");
+
+ testRegex("Classified Url ", url,
+ "secondlife:///app/parcel/0000060e-4b39-e00b-d0c3-d98b1934e3a8/about",
+ "secondlife:///app/parcel/0000060e-4b39-e00b-d0c3-d98b1934e3a8/about");
+
+ testRegex("Classified Url in text", url,
+ "XXX secondlife:///app/parcel/0000060e-4b39-e00b-d0c3-d98b1934e3a8/about XXX",
+ "secondlife:///app/parcel/0000060e-4b39-e00b-d0c3-d98b1934e3a8/about");
+
+ testRegex("Classified Url multicase", url,
+ "XXX secondlife:///APP/Parcel/0000060e-4b39-e00b-d0c3-d98b1934e3a8/About XXX",
+ "secondlife:///APP/Parcel/0000060e-4b39-e00b-d0c3-d98b1934e3a8/About");
+ }
+ template<> template<>
+ void object::test<8>()
+ {
+ //
+ // test LLUrlEntryTeleport - secondlife://app/teleport URLs
+ //
+ LLUrlEntryTeleport url;
+
+ testRegex("no valid teleport [1]", url,
+ "http://slurl.com/secondlife/Ahern/50/50/50/",
+ "");
+
+ testRegex("no valid teleport [2]", url,
+ "secondlife:///app/teleport/",
+ "");
+
+ testRegex("no valid teleport [3]", url,
+ "second-life:///app/teleport/Ahern/50/50/50/",
+ "");
+
+ testRegex("no valid teleport [3]", url,
+ "hhtp://slurl.com/secondlife/Ahern/50/FOO/50/",
+ "");
+
+ testRegex("Ahern (50,50,50) [1]", url,
+ "secondlife:///app/teleport/Ahern/50/50/50/",
+ "secondlife:///app/teleport/Ahern/50/50/50/");
+
+ testRegex("Ahern (50,50,50) [2]", url,
+ "XXX secondlife:///app/teleport/Ahern/50/50/50/ XXX",
+ "secondlife:///app/teleport/Ahern/50/50/50/");
+
+ testRegex("Ahern (50,50,50) [3]", url,
+ "XXX secondlife:///app/teleport/Ahern/50/50/50 XXX",
+ "secondlife:///app/teleport/Ahern/50/50/50");
+
+ testRegex("Ahern (50,50,50) multicase", url,
+ "XXX secondlife:///app/teleport/Ahern/50/50/50/ XXX",
+ "secondlife:///app/teleport/Ahern/50/50/50/");
+
+ testRegex("Ahern (50,50) [1]", url,
+ "XXX secondlife:///app/teleport/Ahern/50/50/ XXX",
+ "secondlife:///app/teleport/Ahern/50/50/");
+
+ testRegex("Ahern (50,50) [2]", url,
+ "XXX secondlife:///app/teleport/Ahern/50/50 XXX",
+ "secondlife:///app/teleport/Ahern/50/50");
+
+ testRegex("Ahern (50)", url,
+ "XXX secondlife:///app/teleport/Ahern/50 XXX",
+ "secondlife:///app/teleport/Ahern/50");
+
+ testRegex("Ahern", url,
+ "XXX secondlife:///app/teleport/Ahern/ XXX",
+ "secondlife:///app/teleport/Ahern/");
+
+ testRegex("Ahern teleport with title", url,
+ "XXX secondlife:///app/teleport/Ahern/50/50/50/?title=YOUR%20TITLE%20HERE! XXX",
+ "secondlife:///app/teleport/Ahern/50/50/50/?title=YOUR%20TITLE%20HERE!");
+
+ testRegex("Ahern teleport with msg", url,
+ "XXX secondlife:///app/teleport/Ahern/50/50/50/?msg=Your%20text%20here. XXX",
+ "secondlife:///app/teleport/Ahern/50/50/50/?msg=Your%20text%20here.");
+
+ // DEV-21577: In-world SLURLs containing "(" or ")" are not treated as a hyperlink in chat
+ testRegex("Teleport with brackets", url,
+ "XXX secondlife:///app/teleport/Burning%20Life%20(Hyper)/27/210/30 XXX",
+ "secondlife:///app/teleport/Burning%20Life%20(Hyper)/27/210/30");
+
+ // DEV-35459: SLURLs and teleport Links not parsed properly
+ testRegex("Teleport url with quote", url,
+ "XXX secondlife:///app/teleport/A'ksha%20Oasis/41/166/701 XXX",
+ "secondlife:///app/teleport/A%27ksha%20Oasis/41/166/701");
+
+ testRegex("Standalone All Hands", url,
+ "XXX x-grid-location-info://lincoln.lindenlab.com/app/teleport/All%20Hands/50/50/50 XXX",
+ "x-grid-location-info://lincoln.lindenlab.com/app/teleport/All%20Hands/50/50/50");
+ }
+
+ template<> template<>
+ void object::test<9>()
+ {
+ //
+ // test LLUrlEntrySL - general secondlife:// URLs
+ //
+ LLUrlEntrySL url;
+
+ testRegex("no valid slapp [1]", url,
+ "http:///app/",
+ "");
+
+ testRegex("valid slapp [1]", url,
+ "secondlife:///app/",
+ "secondlife:///app/");
+
+ testRegex("valid slapp [2]", url,
+ "secondlife:///app/teleport/Ahern/50/50/50/",
+ "secondlife:///app/teleport/Ahern/50/50/50/");
+
+ testRegex("valid slapp [3]", url,
+ "secondlife:///app/foo",
+ "secondlife:///app/foo");
+
+ testRegex("valid slapp [4]", url,
+ "secondlife:///APP/foo?title=Hi%20There",
+ "secondlife:///APP/foo?title=Hi%20There");
+
+ testRegex("valid slapp [5]", url,
+ "secondlife://host/app/",
+ "secondlife://host/app/");
+
+ testRegex("valid slapp [6]", url,
+ "secondlife://host:8080/foo/bar",
+ "secondlife://host:8080/foo/bar");
+ }
+
+ template<> template<>
+ void object::test<10>()
+ {
+ //
+ // test LLUrlEntrySLLabel - general secondlife:// URLs with labels
+ //
+ LLUrlEntrySLLabel url;
+
+ testRegex("invalid wiki url [1]", url,
+ "[secondlife:///app/]",
+ "");
+
+ testRegex("invalid wiki url [2]", url,
+ "[secondlife:///app/",
+ "");
+
+ testRegex("invalid wiki url [3]", url,
+ "[secondlife:///app/ Label",
+ "");
+
+ testRegex("agent slurl with label (spaces)", url,
+ "[secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about Text]",
+ "secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about");
+
+ testRegex("agent slurl with label (tabs)", url,
+ "[secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about\t Text]",
+ "secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about");
+
+ testRegex("agent slurl with label", url,
+ "[secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about FirstName LastName]",
+ "secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/about");
+
+ testRegex("teleport slurl with label", url,
+ "XXX [secondlife:///app/teleport/Ahern/50/50/50/ Teleport to Ahern] YYY",
+ "secondlife:///app/teleport/Ahern/50/50/50/");
+ }
+
+ template<> template<>
+ void object::test<11>()
+ {
+ //
+ // test LLUrlEntryNoLink - turn off hyperlinking
+ //
+ LLUrlEntryNoLink url;
+
+ testRegex("<nolink> [1]", url,
+ "<nolink>google.com</nolink>",
+ "google.com");
+
+ testRegex("<nolink> [2]", url,
+ "<nolink>google.com",
+ "");
+
+ testRegex("<nolink> [3]", url,
+ "google.com</nolink>",
+ "");
+
+ testRegex("<nolink> [4]", url,
+ "<nolink>Hello World</nolink>",
+ "Hello World");
+
+ testRegex("<nolink> [5]", url,
+ "<nolink>My Object</nolink>",
+ "My Object");
+ }
+
+ template<> template<>
+ void object::test<12>()
+ {
+ //
+ // test LLUrlEntryRegion - secondlife:///app/region/<location> URLs
+ //
+ LLUrlEntryRegion url;
+
+ // Regex tests.
+ testRegex("no valid region", url,
+ "secondlife:///app/region/",
+ "");
+
+ testRegex("invalid coords", url,
+ "secondlife:///app/region/Korea2/a/b/c",
+ "secondlife:///app/region/Korea2/"); // don't count invalid coords
+
+ testRegex("Ahern (50,50,50) [1]", url,
+ "secondlife:///app/region/Ahern/50/50/50/",
+ "secondlife:///app/region/Ahern/50/50/50/");
+
+ testRegex("Ahern (50,50,50) [2]", url,
+ "XXX secondlife:///app/region/Ahern/50/50/50/ XXX",
+ "secondlife:///app/region/Ahern/50/50/50/");
+
+ testRegex("Ahern (50,50,50) [3]", url,
+ "XXX secondlife:///app/region/Ahern/50/50/50 XXX",
+ "secondlife:///app/region/Ahern/50/50/50");
+
+ testRegex("Ahern (50,50,50) multicase", url,
+ "XXX secondlife:///app/region/Ahern/50/50/50/ XXX",
+ "secondlife:///app/region/Ahern/50/50/50/");
+
+ testRegex("Ahern (50,50) [1]", url,
+ "XXX secondlife:///app/region/Ahern/50/50/ XXX",
+ "secondlife:///app/region/Ahern/50/50/");
+
+ testRegex("Ahern (50,50) [2]", url,
+ "XXX secondlife:///app/region/Ahern/50/50 XXX",
+ "secondlife:///app/region/Ahern/50/50");
+
+ // DEV-21577: In-world SLURLs containing "(" or ")" are not treated as a hyperlink in chat
+ testRegex("Region with brackets", url,
+ "XXX secondlife:///app/region/Burning%20Life%20(Hyper)/27/210/30 XXX",
+ "secondlife:///app/region/Burning%20Life%20(Hyper)/27/210/30");
+
+ // Rendering tests.
+ testLabel("Render /app/region/Ahern/50/50/50/", url,
+ "secondlife:///app/region/Ahern/50/50/50/",
+ "Ahern (50,50,50)");
+
+ testLabel("Render /app/region/Ahern/50/50/50", url,
+ "secondlife:///app/region/Ahern/50/50/50",
+ "Ahern (50,50,50)");
+
+ testLabel("Render /app/region/Ahern/50/50/", url,
+ "secondlife:///app/region/Ahern/50/50/",
+ "Ahern (50,50)");
+
+ testLabel("Render /app/region/Ahern/50/50", url,
+ "secondlife:///app/region/Ahern/50/50",
+ "Ahern (50,50)");
+
+ testLabel("Render /app/region/Ahern/50/", url,
+ "secondlife:///app/region/Ahern/50/",
+ "Ahern (50)");
+
+ testLabel("Render /app/region/Ahern/50", url,
+ "secondlife:///app/region/Ahern/50",
+ "Ahern (50)");
+
+ testLabel("Render /app/region/Ahern/", url,
+ "secondlife:///app/region/Ahern/",
+ "Ahern");
+
+ testLabel("Render /app/region/Ahern/ within context", url,
+ "XXX secondlife:///app/region/Ahern/ XXX",
+ "Ahern");
+
+ testLabel("Render /app/region/Ahern", url,
+ "secondlife:///app/region/Ahern",
+ "Ahern");
+
+ testLabel("Render /app/region/Ahern within context", url,
+ "XXX secondlife:///app/region/Ahern XXX",
+ "Ahern");
+
+ testLabel("Render /app/region/Product%20Engine/", url,
+ "secondlife:///app/region/Product%20Engine/",
+ "Product Engine");
+
+ testLabel("Render /app/region/Product%20Engine", url,
+ "secondlife:///app/region/Product%20Engine",
+ "Product Engine");
+
+ // Location parsing texts.
+ testLocation("Location /app/region/Ahern/50/50/50/", url,
+ "secondlife:///app/region/Ahern/50/50/50/",
+ "Ahern");
+
+ testLocation("Location /app/region/Product%20Engine", url,
+ "secondlife:///app/region/Product%20Engine",
+ "Product Engine");
+ }
+
+ template<> template<>
+ void object::test<13>()
+ {
+ //
+ // test LLUrlEntryemail - general emails
+ //
+ LLUrlEntryEmail url;
+
+ // Regex tests.
+ testRegex("match e-mail addresses", url,
+ "test@lindenlab.com",
+ "mailto:test@lindenlab.com");
+
+ testRegex("match e-mail addresses with mailto: prefix", url,
+ "mailto:test@lindenlab.com",
+ "mailto:test@lindenlab.com");
+
+ testRegex("match e-mail addresses with different domains", url,
+ "test@foo.org.us",
+ "mailto:test@foo.org.us");
+
+ testRegex("match e-mail addresses with different domains", url,
+ "test@foo.bar",
+ "mailto:test@foo.bar");
+
+ testRegex("don't match incorrect e-mail addresses", url,
+ "test @foo.com",
+ "");
+
+ testRegex("don't match incorrect e-mail addresses", url,
+ "test@ foo.com",
+ "");
+ }
+
+ template<> template<>
+ void object::test<14>()
+ {
+ //
+ // test LLUrlEntrySimpleSecondlifeURL - http://*.secondlife.com/* and http://*lindenlab.com/* urls
+ //
+ LLUrlEntrySecondlifeURL url;
+
+ testRegex("match urls with protocol", url,
+ "this url should match http://lindenlab.com/products/second-life",
+ "http://lindenlab.com/products/second-life");
+
+ testRegex("match urls with protocol", url,
+ "search something https://marketplace.secondlife.com/products/search on marketplace and test the https",
+ "https://marketplace.secondlife.com/products/search");
+
+ testRegex("match HTTPS urls with port", url,
+ "let's specify some port https://secondlife.com:888/status",
+ "https://secondlife.com:888/status");
+
+ testRegex("don't match HTTP urls with port", url,
+ "let's specify some port for HTTP http://secondlife.com:888/status",
+ "");
+
+ testRegex("don't match urls w/o protocol", url,
+ "looks like an url something www.marketplace.secondlife.com/products but no https prefix",
+ "");
+
+ testRegex("but with a protocol www is fine", url,
+ "so let's add a protocol https://www.marketplace.secondlife.com:8888/products",
+ "https://www.marketplace.secondlife.com:8888/products");
+
+ testRegex("don't match urls w/o protocol", url,
+ "and even no www something secondlife.com/status",
+ "");
+ }
+
+ template<> template<>
+ void object::test<15>()
+ {
+ //
+ // test LLUrlEntrySimpleSecondlifeURL - http://*.secondlife.com and http://*lindenlab.com urls
+ //
+
+ LLUrlEntrySimpleSecondlifeURL url;
+
+ testRegex("match urls with a protocol", url,
+ "this url should match http://lindenlab.com",
+ "http://lindenlab.com");
+
+ testRegex("match urls with a protocol", url,
+ "search something https://marketplace.secondlife.com on marketplace and test the https",
+ "https://marketplace.secondlife.com");
+
+ testRegex("don't match urls w/o protocol", url,
+ "looks like an url something www.marketplace.secondlife.com but no https prefix",
+ "");
+
+ testRegex("but with a protocol www is fine", url,
+ "so let's add a protocol http://www.marketplace.secondlife.com",
+ "http://www.marketplace.secondlife.com");
+
+ testRegex("don't match urls w/o protocol", url,
+ "and even no www something lindenlab.com",
+ "");
+ }
+
+ template<> template<>
+ void object::test<16>()
+ {
+ //
+ // test LLUrlEntryIPv6
+ //
+ LLUrlEntryIPv6 url;
+
+ // Regex tests.
+ testRegex("match urls with a protocol", url,
+ "this url should match http://[::1]",
+ "http://[::1]");
+
+ testRegex("match urls with a protocol and query", url,
+ "this url should match http://[::1]/file.mp3",
+ "http://[::1]/file.mp3");
+
+ testRegex("match urls with a protocol", url,
+ "this url should match http://[2001:0db8:11a3:09d7:1f34:8a2e:07a0:765d]",
+ "http://[2001:0db8:11a3:09d7:1f34:8a2e:07a0:765d]");
+
+ testRegex("match urls with port", url,
+ "let's specify some port http://[2001:0db8:11a3:09d7:1f34:8a2e:07a0:765d]:8080",
+ "http://[2001:0db8:11a3:09d7:1f34:8a2e:07a0:765d]:8080");
+
+ testRegex("don't match urls w/o protocol", url,
+ "looks like an url something [2001:0db8:11a3:09d7:1f34:8a2e:07a0:765d] but no https prefix",
+ "");
+
+ testRegex("don't match incorrect urls", url,
+ "http://[ 2001:0db8:11a3:09d7:1f34:8a2e:07a0:765d ]",
+ "");
+ }
+}
diff --git a/indra/llui/tests/llurlmatch_test.cpp b/indra/llui/tests/llurlmatch_test.cpp
index 843886eb69..d03efbc1c9 100644
--- a/indra/llui/tests/llurlmatch_test.cpp
+++ b/indra/llui/tests/llurlmatch_test.cpp
@@ -6,21 +6,21 @@
* $LicenseInfo:firstyear=2009&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2010, Linden Research, Inc.
- *
+ *
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
- *
+ *
* This library 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
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
+ *
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
@@ -34,7 +34,7 @@
// link seams
LLUIColor::LLUIColor()
- : mColorPtr(NULL)
+ : mColorPtr(NULL)
{}
LLStyle::Params::Params()
@@ -52,228 +52,228 @@ LLUIImage::~LLUIImage()
//virtual
S32 LLUIImage::getWidth() const
{
- return 0;
+ return 0;
}
//virtual
S32 LLUIImage::getHeight() const
{
- return 0;
+ return 0;
}
namespace LLInitParam
{
- ParamValue<LLUIColor>::ParamValue(const LLUIColor& color)
- : super_t(color)
- {}
-
- void ParamValue<LLUIColor>::updateValueFromBlock()
- {}
-
- void ParamValue<LLUIColor>::updateBlockFromValue(bool)
- {}
-
- bool ParamCompare<const LLFontGL*, false>::equals(const LLFontGL* a, const LLFontGL* b)
- {
- return false;
- }
-
-
- ParamValue<const LLFontGL*>::ParamValue(const LLFontGL* fontp)
- : super_t(fontp)
- {}
-
- void ParamValue<const LLFontGL*>::updateValueFromBlock()
- {}
-
- void ParamValue<const LLFontGL*>::updateBlockFromValue(bool)
- {}
-
- void TypeValues<LLFontGL::HAlign>::declareValues()
- {}
-
- void TypeValues<LLFontGL::VAlign>::declareValues()
- {}
-
- void TypeValues<LLFontGL::ShadowType>::declareValues()
- {}
-
- void ParamValue<LLUIImage*>::updateValueFromBlock()
- {}
-
- void ParamValue<LLUIImage*>::updateBlockFromValue(bool)
- {}
-
- bool ParamCompare<LLUIImage*, false>::equals(
- LLUIImage* const &a,
- LLUIImage* const &b)
- {
- return false;
- }
-
- bool ParamCompare<LLUIColor, false>::equals(const LLUIColor &a, const LLUIColor &b)
- {
- return false;
- }
+ ParamValue<LLUIColor>::ParamValue(const LLUIColor& color)
+ : super_t(color)
+ {}
+
+ void ParamValue<LLUIColor>::updateValueFromBlock()
+ {}
+
+ void ParamValue<LLUIColor>::updateBlockFromValue(bool)
+ {}
+
+ bool ParamCompare<const LLFontGL*, false>::equals(const LLFontGL* a, const LLFontGL* b)
+ {
+ return false;
+ }
+
+
+ ParamValue<const LLFontGL*>::ParamValue(const LLFontGL* fontp)
+ : super_t(fontp)
+ {}
+
+ void ParamValue<const LLFontGL*>::updateValueFromBlock()
+ {}
+
+ void ParamValue<const LLFontGL*>::updateBlockFromValue(bool)
+ {}
+
+ void TypeValues<LLFontGL::HAlign>::declareValues()
+ {}
+
+ void TypeValues<LLFontGL::VAlign>::declareValues()
+ {}
+
+ void TypeValues<LLFontGL::ShadowType>::declareValues()
+ {}
+
+ void ParamValue<LLUIImage*>::updateValueFromBlock()
+ {}
+
+ void ParamValue<LLUIImage*>::updateBlockFromValue(bool)
+ {}
+
+ bool ParamCompare<LLUIImage*, false>::equals(
+ LLUIImage* const &a,
+ LLUIImage* const &b)
+ {
+ return false;
+ }
+
+ bool ParamCompare<LLUIColor, false>::equals(const LLUIColor &a, const LLUIColor &b)
+ {
+ return false;
+ }
}
//static
LLFontGL* LLFontGL::getFontDefault()
{
- return NULL;
+ return NULL;
}
namespace tut
{
- struct LLUrlMatchData
- {
- };
+ struct LLUrlMatchData
+ {
+ };
- typedef test_group<LLUrlMatchData> factory;
- typedef factory::object object;
+ typedef test_group<LLUrlMatchData> factory;
+ typedef factory::object object;
}
namespace
{
- tut::factory tf("LLUrlMatch");
+ tut::factory tf("LLUrlMatch");
}
namespace tut
{
- template<> template<>
- void object::test<1>()
- {
- //
- // test the empty() method
- //
- LLUrlMatch match;
- ensure("empty()", match.empty());
-
- match.setValues(0, 1, "http://secondlife.com", "", "Second Life", "", "", LLStyle::Params(), "", "", LLUUID::null);
- ensure("! empty()", ! match.empty());
- }
-
- template<> template<>
- void object::test<2>()
- {
- //
- // test the getStart() method
- //
- LLUrlMatch match;
- ensure_equals("getStart() == 0", match.getStart(), 0);
-
- match.setValues(10, 20, "", "", "", "", "", LLStyle::Params(), "", "", LLUUID::null);
- ensure_equals("getStart() == 10", match.getStart(), 10);
- }
-
- template<> template<>
- void object::test<3>()
- {
- //
- // test the getEnd() method
- //
- LLUrlMatch match;
- ensure_equals("getEnd() == 0", match.getEnd(), 0);
-
- match.setValues(10, 20, "", "", "", "", "", LLStyle::Params(), "", "", LLUUID::null);
- ensure_equals("getEnd() == 20", match.getEnd(), 20);
- }
-
- template<> template<>
- void object::test<4>()
- {
- //
- // test the getUrl() method
- //
- LLUrlMatch match;
- ensure_equals("getUrl() == ''", match.getUrl(), "");
-
- match.setValues(10, 20, "http://slurl.com/", "", "", "", "", LLStyle::Params(), "", "", LLUUID::null);
- ensure_equals("getUrl() == 'http://slurl.com/'", match.getUrl(), "http://slurl.com/");
-
- match.setValues(10, 20, "", "", "", "", "", LLStyle::Params(), "", "", LLUUID::null);
- ensure_equals("getUrl() == '' (2)", match.getUrl(), "");
- }
-
- template<> template<>
- void object::test<5>()
- {
- //
- // test the getLabel() method
- //
- LLUrlMatch match;
- ensure_equals("getLabel() == ''", match.getLabel(), "");
-
- match.setValues(10, 20, "", "Label", "", "", "", LLStyle::Params(), "", "", LLUUID::null);
- ensure_equals("getLabel() == 'Label'", match.getLabel(), "Label");
-
- match.setValues(10, 20, "", "", "", "", "", LLStyle::Params(), "", "", LLUUID::null);
- ensure_equals("getLabel() == '' (2)", match.getLabel(), "");
- }
-
- template<> template<>
- void object::test<6>()
- {
- //
- // test the getTooltip() method
- //
- LLUrlMatch match;
- ensure_equals("getTooltip() == ''", match.getTooltip(), "");
-
- match.setValues(10, 20, "", "", "", "Info", "", LLStyle::Params(), "", "", LLUUID::null);
- ensure_equals("getTooltip() == 'Info'", match.getTooltip(), "Info");
-
- match.setValues(10, 20, "", "", "", "", "", LLStyle::Params(), "", "", LLUUID::null);
- ensure_equals("getTooltip() == '' (2)", match.getTooltip(), "");
- }
-
- template<> template<>
- void object::test<7>()
- {
- //
- // test the getIcon() method
- //
- LLUrlMatch match;
- ensure_equals("getIcon() == ''", match.getIcon(), "");
-
- match.setValues(10, 20, "", "", "", "", "Icon", LLStyle::Params(), "", "", LLUUID::null);
- ensure_equals("getIcon() == 'Icon'", match.getIcon(), "Icon");
-
- match.setValues(10, 20, "", "", "", "", "", LLStyle::Params(), "", "", LLUUID::null);
- ensure_equals("getIcon() == '' (2)", match.getIcon(), "");
- }
-
- template<> template<>
- void object::test<8>()
- {
- //
- // test the getMenuName() method
- //
- LLUrlMatch match;
- ensure("getMenuName() empty", match.getMenuName().empty());
-
- match.setValues(10, 20, "", "", "", "", "Icon", LLStyle::Params(), "xui_file.xml", "", LLUUID::null);
- ensure_equals("getMenuName() == \"xui_file.xml\"", match.getMenuName(), "xui_file.xml");
-
- match.setValues(10, 20, "", "", "", "", "", LLStyle::Params(), "", "", LLUUID::null);
- ensure("getMenuName() empty (2)", match.getMenuName().empty());
- }
-
- template<> template<>
- void object::test<9>()
- {
- //
- // test the getLocation() method
- //
- LLUrlMatch match;
- ensure("getLocation() empty", match.getLocation().empty());
-
- match.setValues(10, 20, "", "", "", "", "Icon", LLStyle::Params(), "xui_file.xml", "Paris", LLUUID::null);
- ensure_equals("getLocation() == \"Paris\"", match.getLocation(), "Paris");
-
- match.setValues(10, 20, "", "", "", "", "", LLStyle::Params(), "", "", LLUUID::null);
- ensure("getLocation() empty (2)", match.getLocation().empty());
- }
+ template<> template<>
+ void object::test<1>()
+ {
+ //
+ // test the empty() method
+ //
+ LLUrlMatch match;
+ ensure("empty()", match.empty());
+
+ match.setValues(0, 1, "http://secondlife.com", "", "Second Life", "", "", LLStyle::Params(), "", "", LLUUID::null);
+ ensure("! empty()", ! match.empty());
+ }
+
+ template<> template<>
+ void object::test<2>()
+ {
+ //
+ // test the getStart() method
+ //
+ LLUrlMatch match;
+ ensure_equals("getStart() == 0", match.getStart(), 0);
+
+ match.setValues(10, 20, "", "", "", "", "", LLStyle::Params(), "", "", LLUUID::null);
+ ensure_equals("getStart() == 10", match.getStart(), 10);
+ }
+
+ template<> template<>
+ void object::test<3>()
+ {
+ //
+ // test the getEnd() method
+ //
+ LLUrlMatch match;
+ ensure_equals("getEnd() == 0", match.getEnd(), 0);
+
+ match.setValues(10, 20, "", "", "", "", "", LLStyle::Params(), "", "", LLUUID::null);
+ ensure_equals("getEnd() == 20", match.getEnd(), 20);
+ }
+
+ template<> template<>
+ void object::test<4>()
+ {
+ //
+ // test the getUrl() method
+ //
+ LLUrlMatch match;
+ ensure_equals("getUrl() == ''", match.getUrl(), "");
+
+ match.setValues(10, 20, "http://slurl.com/", "", "", "", "", LLStyle::Params(), "", "", LLUUID::null);
+ ensure_equals("getUrl() == 'http://slurl.com/'", match.getUrl(), "http://slurl.com/");
+
+ match.setValues(10, 20, "", "", "", "", "", LLStyle::Params(), "", "", LLUUID::null);
+ ensure_equals("getUrl() == '' (2)", match.getUrl(), "");
+ }
+
+ template<> template<>
+ void object::test<5>()
+ {
+ //
+ // test the getLabel() method
+ //
+ LLUrlMatch match;
+ ensure_equals("getLabel() == ''", match.getLabel(), "");
+
+ match.setValues(10, 20, "", "Label", "", "", "", LLStyle::Params(), "", "", LLUUID::null);
+ ensure_equals("getLabel() == 'Label'", match.getLabel(), "Label");
+
+ match.setValues(10, 20, "", "", "", "", "", LLStyle::Params(), "", "", LLUUID::null);
+ ensure_equals("getLabel() == '' (2)", match.getLabel(), "");
+ }
+
+ template<> template<>
+ void object::test<6>()
+ {
+ //
+ // test the getTooltip() method
+ //
+ LLUrlMatch match;
+ ensure_equals("getTooltip() == ''", match.getTooltip(), "");
+
+ match.setValues(10, 20, "", "", "", "Info", "", LLStyle::Params(), "", "", LLUUID::null);
+ ensure_equals("getTooltip() == 'Info'", match.getTooltip(), "Info");
+
+ match.setValues(10, 20, "", "", "", "", "", LLStyle::Params(), "", "", LLUUID::null);
+ ensure_equals("getTooltip() == '' (2)", match.getTooltip(), "");
+ }
+
+ template<> template<>
+ void object::test<7>()
+ {
+ //
+ // test the getIcon() method
+ //
+ LLUrlMatch match;
+ ensure_equals("getIcon() == ''", match.getIcon(), "");
+
+ match.setValues(10, 20, "", "", "", "", "Icon", LLStyle::Params(), "", "", LLUUID::null);
+ ensure_equals("getIcon() == 'Icon'", match.getIcon(), "Icon");
+
+ match.setValues(10, 20, "", "", "", "", "", LLStyle::Params(), "", "", LLUUID::null);
+ ensure_equals("getIcon() == '' (2)", match.getIcon(), "");
+ }
+
+ template<> template<>
+ void object::test<8>()
+ {
+ //
+ // test the getMenuName() method
+ //
+ LLUrlMatch match;
+ ensure("getMenuName() empty", match.getMenuName().empty());
+
+ match.setValues(10, 20, "", "", "", "", "Icon", LLStyle::Params(), "xui_file.xml", "", LLUUID::null);
+ ensure_equals("getMenuName() == \"xui_file.xml\"", match.getMenuName(), "xui_file.xml");
+
+ match.setValues(10, 20, "", "", "", "", "", LLStyle::Params(), "", "", LLUUID::null);
+ ensure("getMenuName() empty (2)", match.getMenuName().empty());
+ }
+
+ template<> template<>
+ void object::test<9>()
+ {
+ //
+ // test the getLocation() method
+ //
+ LLUrlMatch match;
+ ensure("getLocation() empty", match.getLocation().empty());
+
+ match.setValues(10, 20, "", "", "", "", "Icon", LLStyle::Params(), "xui_file.xml", "Paris", LLUUID::null);
+ ensure_equals("getLocation() == \"Paris\"", match.getLocation(), "Paris");
+
+ match.setValues(10, 20, "", "", "", "", "", LLStyle::Params(), "", "", LLUUID::null);
+ ensure("getLocation() empty (2)", match.getLocation().empty());
+ }
}