Skip to content

Commit

Permalink
Updated Roku Unit Test Framework to v2.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
juliomalves committed Feb 16, 2019
1 parent 24c3eb4 commit 2cfa712
Show file tree
Hide file tree
Showing 6 changed files with 1,360 additions and 739 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
APPNAME = roku-libs
VERSION ?= 0.3.0
DEVICEIP ?= 192.168.1.1
DEVICEIP ?= 192.168.1.2
USER ?= rokudev
USERPASS ?= password
ZIPEXCLUDE = -x \*.pkg -x keys\* -x LICENSE\* -x \*.md -x \*/.\* -x .\* -x build\* -x package\*
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,22 +86,22 @@ Below are some examples showing its different capabilities.
#### Request with 2s timeout and 3 retries
```javascript
request = HttpRequest()
request.open("https://echo.getpostman.com/delay/5").setTimeout(2000).setRetries(3)
request.open("https://postman-echo.com/delay/5").setTimeout(2000).setRetries(3)
response = request.send()
```

#### POST request with 'application/json' Content-Type
```javascript
request = HttpRequest()
request.open("https://echo.getpostman.com/post", "POST")
request.open("https://postman-echo.com/post", "POST")
request.setRequestHeaders({"Content-Type": "application/json"})
response = request.send({user: "johndoe", password: "12345"})
```

#### Abort on-going request
```javascript
request = HttpRequest()
request.open("https://echo.getpostman.com/delay/5")
request.open("https://postman-echo.com/delay/5")
request.send()
request.abort()
```
Expand Down
10 changes: 5 additions & 5 deletions source/libs/http-request.brs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ function HttpRequest() as Object
_http: invalid
_isAborted: false

_isUrlSecure: function(url as String) as Boolean
return left(url, 5) = "https"
_isProtocolSecure: function(url as String) as Boolean
return left(url, 6) = "https:"
end function

_createHttpRequest: function() as Object
Expand All @@ -43,8 +43,8 @@ function HttpRequest() as Object
request.setHeaders(m._requestHeaders)
if m._method <> invalid then request.setRequest(m._method)

'Checks if URL is secured, and adds appropriate parameters if needed
if m._isUrlSecure(m._url) then
'Checks if URL protocol is secured, and adds appropriate parameters if needed
if m._isProtocolSecure(m._url) then
request.setCertificatesFile("common:/certs/ca-bundle.crt")
request.addHeader("X-Roku-Reserved-Dev-Id", "")
request.initClientCertificates()
Expand Down Expand Up @@ -118,7 +118,7 @@ function HttpRequest() as Object
end if

m._http.asyncCancel()
timeout = timeout * 2
timeout *= 2
sleep(m._interval)
end if

Expand Down
7 changes: 7 additions & 0 deletions source/main.brs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ sub main(args as Dynamic)

if args.RunTests <> invalid and type(TestRunner) = "Function" then
runner = TestRunner()
runner.setFunctions([
TestSuite__GoogleAnalytics,
TestSuite__HttpRequest,
TestSuite__Array,
TestSuite__Math
TestSuite__String
])
runner.logger.PrintStatistic = customPrintStatistic
runner.run()
end if
Expand Down
Loading

0 comments on commit 2cfa712

Please sign in to comment.