inst/unitTests/test_BrowserVizDemo2.R

library(RUnit)
library(BrowserVizDemo2)
#--------------------------------------------------------------------------------
PORT.RANGE <- 8000:8020
#--------------------------------------------------------------------------------
runTests <- function()
{
  testConstructor();
  testWindowTitle()
  testPlot()
  
} # runTests
#--------------------------------------------------------------------------------
testConstructor <- function()
{
   print("--- testConstructor")
   app <- BrowserVizDemo2(PORT.RANGE, quiet=FALSE);
   checkTrue(ready(app))
   checkTrue(port(app) %in% PORT.RANGE)
   closeWebSocket(app)
   
} # testConstructor
#--------------------------------------------------------------------------------
testWindowTitle <- function()
{
   print("--- testWindowTitle")
   app <- BrowserVizDemo2(PORT.RANGE)
   checkTrue(ready(app))
   checkEquals(getBrowserWindowTitle(app), "BrowserVizDemo2")
   setBrowserWindowTitle(app, "new title");
   checkEquals(getBrowserWindowTitle(app), "new title")
   closeWebSocket(app)

} # testWindowTitle
#--------------------------------------------------------------------------------
testPlot <- function()
{
   print("--- testPlot")
   app <- BrowserVizDemo2(PORT.RANGE)
   checkTrue(ready(app))

   title <- "simple xy plot test";
   setBrowserWindowTitle(app, title)
   checkEquals(getBrowserWindowTitle(app), title)

   checkEquals(getSelection(app), list())

   plot(app, 1:10, (1:10)^2)

     # without direct manipulation of the plotted surface byt the user, there
     # will still be no selections

   checkEquals(getSelection(app), list())
   closeWebSocket(app)

} # testPlot
#--------------------------------------------------------------------------------
demo <- function()
{
   print("--- testPlot")
   app <- BrowserVizDemo2(PORT.RANGE)
   checkTrue(ready(app))

   title <- "simple xy plot test";
   setBrowserWindowTitle(app, title)
   checkEquals(getBrowserWindowTitle(app), title)

   checkEquals(getSelection(app), list())

   plot(app, 1:10, (1:10)^3 - 15)

     # without direct manipulation of the plotted surface by the user, there
     # will still be no selections

   checkEquals(getSelection(app), list())

   app
   
} # demo
#--------------------------------------------------------------------------------
lgatto/BrowserVizDemo2 documentation built on May 21, 2019, 5:12 a.m.