-
Notifications
You must be signed in to change notification settings - Fork 2
/
ContentProviderTest.cpp
89 lines (70 loc) · 4.91 KB
/
ContentProviderTest.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#include <boost/test/unit_test.hpp>
#include "v8datamodel/ContentProvider.h"
#include "util/Statistics.h"
DYNAMIC_FASTFLAG(UrlReconstructToAssetGame)
using namespace RBX;
class TestProvider
{
public:
static void testContentIdAssetUrlReconstruction(std::string raw_url, const std::string& expected_sanitized_url, bool expected_result)
{
ContentId id = ContentId::fromUrl(raw_url);
BOOST_CHECK_MESSAGE(id.reconstructAssetUrl(GetBaseURL()) == expected_result, raw_url);
if (expected_result)
BOOST_CHECK_EQUAL(expected_sanitized_url, id.toString());
}
};
#if RBX_PLATFORM_IOS
virtual void onHeartbeat(const Heartbeat& event)
{
}
#endif
BOOST_AUTO_TEST_SUITE( ContentProvider )
BOOST_AUTO_TEST_CASE( UrlReconstruction)
{
::SetBaseURL("http://www.roblox.com");
std::string host = "http://www.roblox.com";
if (DFFlag::UrlReconstructToAssetGame)
host = "https://assetgame.roblox.com";
TestProvider::testContentIdAssetUrlReconstruction("http://www.roblox.com/asset/?id=123", host + "/asset/?id=123", true);
TestProvider::testContentIdAssetUrlReconstruction("http://www.roblox.com/thumbs/asset.ashx?id=123", host + "/thumbs/asset.ashx?id=123", true);
TestProvider::testContentIdAssetUrlReconstruction("http://www.roblox.com/thumbs/avatar.ashx?id=123", host + "/thumbs/avatar.ashx?id=123", true);
TestProvider::testContentIdAssetUrlReconstruction(
"http://www.roblox.com/Game/Tools/ThumbnailAsset.ashx?fmt=png&wd=75&ht=75&aid=56450668",
host + "/Game/Tools/ThumbnailAsset.ashx?fmt=png&wd=75&ht=75&aid=56450668", true);
TestProvider::testContentIdAssetUrlReconstruction("http://www.roblox.com/asset/?id=123", host + "/asset/?id=123", true);
TestProvider::testContentIdAssetUrlReconstruction("http://www.roblox.com/asset/?id=123&version=1", host + "/asset/?id=123&version=1", true);
TestProvider::testContentIdAssetUrlReconstruction("http://www.roblox.com/ /asset/ ?id=123", host + "/asset/?id=123", true);
TestProvider::testContentIdAssetUrlReconstruction("http://www.roblox.com/asset/?id=123 ", host + "/asset/?id=123", true);
TestProvider::testContentIdAssetUrlReconstruction("http://www.roblox.com/asset /?id=1 23", host + "/asset/?id=123", true);
TestProvider::testContentIdAssetUrlReconstruction("http://www.roblox.com/asset////?id=123", host + "/asset/?id=123", true);
TestProvider::testContentIdAssetUrlReconstruction("http://www.roblox.com///asset/?id=123", host + "/asset/?id=123", true);
TestProvider::testContentIdAssetUrlReconstruction("http://www.roblox.com////asset////?id=123", host + "/asset/?id=123", true);
TestProvider::testContentIdAssetUrlReconstruction("http://www.roblox.com//asset/?id=123", host + "/asset/?id=123", true);
TestProvider::testContentIdAssetUrlReconstruction("http://www.roblox.com/asset/blah/../?id=123 ", host + "/asset/?id=123", true);
TestProvider::testContentIdAssetUrlReconstruction("http://www.roblox.com/asset/../asset/?id=1234", host + "/asset/?id=1234", true);
TestProvider::testContentIdAssetUrlReconstruction("http://www.roblox.com/asset/../?id=123 ", "", false);
TestProvider::testContentIdAssetUrlReconstruction("http://www.roblox.com/blah/?id=123&version=1", "", false);
TestProvider::testContentIdAssetUrlReconstruction("http://www.roblox.com/asset/id=123&version=1", "", false);
TestProvider::testContentIdAssetUrlReconstruction("http://www.roblox.com/?id=123", "", false);
TestProvider::testContentIdAssetUrlReconstruction("http://www.roblox.com", "", false);
TestProvider::testContentIdAssetUrlReconstruction(
"http://www.roblox.com/asset/../Bloxxer-Cap-item?id=51353039"
"&__EVENTTARGET=&__EVENTARGUMENT=&ctl00%24cphRoblox"
"%24ProceedWithTicketsPurchaseButton=Buy%20now!",
"", false);
TestProvider::testContentIdAssetUrlReconstruction("http://www.notroblox.com/asset/?id=123", host + "/asset/?id=123", true);
::SetBaseURL("http://www.gametest1.robloxlabs.com");
host = "http://www.gametest1.robloxlabs.com";
if (DFFlag::UrlReconstructToAssetGame)
host = "https://assetgame.gametest1.robloxlabs.com";
TestProvider::testContentIdAssetUrlReconstruction("http://www.gametest1.robloxlabs.com/asset/?id=123", host + "/asset/?id=123", true);
TestProvider::testContentIdAssetUrlReconstruction("http://www.gametest1.robloxlabs.com/thumbs/asset.ashx?id=123", host + "/thumbs/asset.ashx?id=123", true);
TestProvider::testContentIdAssetUrlReconstruction("http://www.gametest1.robloxlabs.com/thumbs/avatar.ashx?id=123", host + "/thumbs/avatar.ashx?id=123", true);
// Non-http ids
TestProvider::testContentIdAssetUrlReconstruction("rbxasset://fonts/character3.rbxm", "rbxasset://fonts/character3.rbxm", true);
TestProvider::testContentIdAssetUrlReconstruction("rbxgameasset://fonts/character3.rbxm", "rbxgameasset://fonts/character3.rbxm", true);
//TestProvider::testContentIdAssetUrlReconstruction("/asset/?id=11911558", "", false);
//TestProvider::testContentIdAssetUrlReconstruction("/Asset/?id=180435571&serverplaceid=0&clientinsert=1", "", false);
}
BOOST_AUTO_TEST_SUITE_END()