Skip to content

Commit df74a20

Browse files
chore: Bump to 2.12, sbt 0.13.13, ScalaTest 3.0.1 add Browser Test infrastructure.
1 parent f9bc6ac commit df74a20

15 files changed

+260
-46
lines changed

.travis.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#https://docs.travis-ci.com/user/languages/scala
2+
language: scala
3+
before_install:
4+
# Initilize xvfb for headless testing
5+
- export DISPLAY=:99.0
6+
- sh -e /etc/init.d/xvfb start
7+
#- sleep 3 # give xvfb some time to start
8+
9+
script:
10+
- sbt ++$TRAVIS_SCALA_VERSION firefox:test
11+
12+
# Trick to avoid unnecessary cache updates
13+
- find $HOME/.sbt -name "*.lock" | xargs rm
14+
15+
scala:
16+
- 2.12.0
17+
18+
#jdk:
19+
# - oraclejdk8
20+
21+
sudo: false
22+
23+
cache:
24+
directories:
25+
- $HOME/.ivy2
26+
- $HOME/.m2/repository
27+
- $HOME/.sbt
28+
29+
#env:
30+
#- CI=travis
31+
32+
addons:
33+
firefox: "46.0.1"

Licence.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2016-10-01 Simple Game
2+
©2016 by F.W. van den Berg Licensed under the EUPL-1.1
3+
4+
This Software is provided to You under the terms of the European Union Public License (the "EUPL") version 1.1
5+
or – as soon they will be approved by the European Commission - subsequent versions of the EUPL (the "Licence")
6+
as published by the European Union. Any use of this Software, other than as authorized under this License is
7+
strictly prohibited (to the extent such use is covered by a right of the copyright holder of this Software).
8+
9+
This Software is provided under the License on an "AS IS" basis and without warranties of any kind concerning
10+
the Software, including without limitation merchantability, fitness for a particular purpose, absence of defects
11+
or errors, accuracy, and non-infringement of intellectual property rights other than copyright. This disclaimer
12+
of warranty is an essential part of the License and a condition for the grant of any rights to this Software.

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
<a href="http://www.w3.org/html/logo/">
2+
<img src="https://www.w3.org/html/logo/badge/html5-badge-h-css3-graphics-semantics.png" width="99" height="32" alt="HTML5 Powered with CSS3 / Styling, Graphics, 3D &amp; Effects, and Semantics" title="HTML5 Powered with CSS3 / Styling, Graphics, 3D &amp; Effects, and Semantics"></a>[![Scala.js](https://img.shields.io/badge/scala.js-0.6.10%2B-blue.svg?style=flat)](https://www.scala-js.org)
3+
[![Build Status](https://travis-ci.org/amsterdam-scala/Sjs-Full-Window-HTML5-Canvas.svg?branch=master)](https://travis-ci.org/amsterdam-scala/Sjs-Full-Window-HTML5-Canvas)
4+
15
Scala Full Window HTML Canvas
26
=============================
37
To create a resizeable full window HTML Canvas Scala.js application
@@ -9,10 +13,6 @@ To create a resizeable full window HTML Canvas Scala.js application
913

1014
master
1115

16+
Incorporated Technology
1217

13-
14-
15-
Incorporated Technology
16-
17-
Lincences: EUPL V.1.1
18-
18+
Licence: EUPL V.1.1

build.sbt

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,48 @@
1-
name := "FullWindowHtml5Canvas"
2-
version := "0.0"
3-
description := "Simple HTML5 Canvas game ported to Scala.js."
4-
organization := "nl.amsscala"
5-
organizationName := "Amsterdam.scala Meetup Group"
6-
organizationHomepage := Some(url("http://www.meetup.com/amsterdam-scala/"))
7-
homepage := Some(url("http://github.com/amsterdam-scala/Sjs-Full-Window-HTML5-Canvas"))
8-
startYear := Some(2016)
9-
licenses += "EUPL v.1.1" -> url("http://joinup.ec.europa.eu/community/eupl/og_page/european-union-public-licence-eupl-v11")
10-
1+
lazy val commonSettings = Seq(
2+
name := "FullWindowHtml5Canvas",
3+
version := "0.0",
4+
description := "Simple HTML5 Canvas game ported to Scala.js.",
5+
organization := "nl.amsscala",
6+
organizationName := "Amsterdam.scala Meetup Group",
7+
organizationHomepage := Some(url("http://www.meetup.com/amsterdam-scala/")),
8+
homepage := Some(url("http://github.com/amsterdam-scala/Sjs-Full-Window-HTML5-Canvas")),
9+
startYear := Some(2016),
10+
licenses += "EUPL-1.1" -> url("http://joinup.ec.europa.eu/community/eupl/og_page/european-union-public-licence-eupl-v11")
11+
)
1112
// KEEP THIS normalizedName CONSTANTLY THE SAME, otherwise the outputted JS filename will be changed.
1213
normalizedName := "main"
1314

1415
// ** Scala dependencies **
15-
scalaVersion in ThisBuild := "2.11.8"
16+
scalaVersion in ThisBuild := "2.12.0"
17+
scalacOptions in ThisBuild ++= Seq("-unchecked", "-deprecation")
18+
scalacOptions in (Compile,doc) ++=
19+
Seq("-doc-root-content", baseDirectory.value + "/src/main/scala-2.12/root-doc.md", "-groups", "-implicits")
1620

17-
resolvers += Resolver.sonatypeRepo("snapshots")
21+
// resolvers += Resolver.sonatypeRepo("snapshots")
1822
libraryDependencies ++= Seq(
19-
"be.doeraene" %%% "scalajs-jquery" % "0.9.0",
20-
"com.github.cquiroz" %%% "scala-java-locales" % "0.3.0+29",
21-
"com.github.karasiq" %%% "scalajs-bootstrap" % "1.1.1",
22-
"com.lihaoyi" %%% "scalatags" % "0.6.0",
23-
"com.lihaoyi" %%% "upickle" % "0.4.1",
24-
"io.github.soc" %%% "scala-java-time" % "2.0.0-M2",
25-
"io.surfkit" %%% "scalajs-google-maps"% "0.1-SNAPSHOT",
23+
"be.doeraene" %%% "scalajs-jquery" % "0.9.1",
24+
"com.github.cquiroz" %%% "scala-java-locales" % "0.3.1-cldr30",
25+
//"com.github.karasiq" %%% "scalajs-bootstrap" % "1.1.2",
26+
"com.lihaoyi" %%% "scalatags" % "0.6.2",
27+
"com.lihaoyi" %%% "upickle" % "0.4.4",
28+
"io.github.soc" %%% "scala-java-time" % "2.0.0-M5",
29+
// "io.surfkit" %%% "scalajs-google-maps"% "0.1-SNAPSHOT",
2630
"org.scala-js" %%% "scalajs-dom" % "0.9.1",
27-
"org.scalatest" %% "scalatest" % "3.0.0" % "test")
31+
"org.scalatest" %% "scalatest" % "3.0.1" % "test")
2832

29-
scalacOptions in (Compile,doc) ++= Seq("-doc-root-content", baseDirectory.value+"/src/main/scala-2.11/root-doc.md",
33+
scalacOptions in (Compile,doc) ++= Seq("-doc-root-content", baseDirectory.value + "/src/main/scala-2.12/root-doc.md",
3034
"-groups", "-implicits")
3135

3236
// ** Scala.js configuration **
33-
// lazy val root = (project in file(".")).
34-
enablePlugins(ScalaJSPlugin)
3537

36-
// Necessary for testing
37-
jsDependencies += RuntimeDOM
38-
scalaJSUseRhino in Global := false
39-
jsEnv := PhantomJSEnv(autoExit = false).value
38+
lazy val root: Project = (project in file(".")).enablePlugins(ScalaJSPlugin).settings(commonSettings: _*).
39+
configure(InBrowserTesting.js)
40+
41+
// jsEnv in Test := new org.scalajs.jsenv.selenium.SeleniumJSEnv(org.scalajs.jsenv.selenium.Chrome())
42+
43+
// Firefox works only with FireFox 46.0.1-, and since 48.0 GeckoDriver (aka Marionette)
44+
// (https://ftp.mozilla.org/pub/firefox/releases/46.0.1/win64-EME-free/en-US/Firefox%20Setup%2046.0.1.exe)
45+
// jsEnv in Test := new org.scalajs.jsenv.selenium.SeleniumJSEnv(org.scalajs.jsenv.selenium.Firefox())
4046

4147
// If true, a launcher script src="../[normalizedName]-launcher.js will be generated
4248
// that always calls the main def indicated by the used JSApp trait.
@@ -52,19 +58,13 @@ skip in packageJSDependencies := false // All JavaScript dependencies to be conc
5258
// ScalaTest settings //
5359
// testOptions in Test += Tests.Argument(TestFrameworks.ScalaTest, "-oF")
5460

55-
// Workbench settings **
61+
// Li Haoyi's Workbench settings **
5662
if (sys.env.isDefinedAt("CI")) {
57-
println("Workbench disabled ", sys.env.getOrElse("CI", "?"))
63+
println("[Info] Li Haoyi's workbench disabled ", sys.env.getOrElse("CI", "?"))
5864
Seq.empty
59-
} else {
60-
println("Workbench enabled")
61-
workbenchSettings
62-
}
65+
} else enablePlugins(WorkbenchPlugin)
6366

6467
if (sys.env.isDefinedAt("CI")) normalizedName := normalizedName.value // Dummy
6568
else // Update without refreshing the page every time fastOptJS completes
66-
updateBrowsers <<= updateBrowsers.triggeredBy(fastOptJS in Compile)
69+
refreshBrowsers <<= refreshBrowsers.triggeredBy(fastOptJS in Compile)
6770

68-
if (sys.env.isDefinedAt("CI")) normalizedName := normalizedName.value
69-
else // Workbench has to know how to restart your application.
70-
bootSnippet := "Main().main(document.getElementById('canvas'));"

project/InBrowserTesting.scala

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
import org.scalajs.jsenv.selenium.{Chrome, Firefox, SeleniumJSEnv}
2+
import org.scalajs.sbtplugin.ScalaJSPlugin.autoImport._
3+
import org.scalajs.sbtplugin.ScalaJSPluginInternal._
4+
import org.scalajs.sbtplugin.cross.CrossProject
5+
import sbt.Keys._
6+
import sbt.{Configuration, Defaults, Project, TaskKey, Test, config, inConfig}
7+
8+
object InBrowserTesting {
9+
10+
lazy val testAll = TaskKey[Unit]("test-all", "Run tests in all test platforms.")
11+
12+
val ConfigFirefox = config("firefox")
13+
val ConfigChrome = config("chrome")
14+
15+
def cross: CrossProject => CrossProject =
16+
_.jvmConfigure(jvm).jsConfigure(js)
17+
18+
def js: Project => Project =
19+
_.configure(
20+
browserConfig(ConfigFirefox, new SeleniumJSEnv(Firefox())),
21+
browserConfig(ConfigChrome, new SeleniumJSEnv(Chrome())))
22+
.settings(
23+
testAll := {
24+
// (test in Test).value // No jvm test available
25+
(test in ConfigFirefox).value
26+
(test in ConfigChrome).value
27+
})
28+
29+
private def browserConfig(cfg: Configuration, env: SeleniumJSEnv): Project => Project =
30+
_.settings(
31+
inConfig(cfg)(
32+
Defaults.testSettings ++
33+
scalaJSTestSettings ++
34+
Seq(
35+
36+
// Scala.JS public settings
37+
checkScalaJSSemantics := (checkScalaJSSemantics in Test).value,
38+
emitSourceMaps := (emitSourceMaps in Test).value,
39+
fastOptJS := (fastOptJS in Test).value,
40+
fullOptJS := (fullOptJS in Test).value,
41+
jsDependencies := (jsDependencies in Test).value,
42+
jsDependencyFilter := (jsDependencyFilter in Test).value,
43+
jsDependencyManifest := (jsDependencyManifest in Test).value,
44+
jsDependencyManifests := (jsDependencyManifests in Test).value,
45+
jsManifestFilter := (jsManifestFilter in Test).value,
46+
// loadedJSEnv := (loadedJSEnv in Test).value,
47+
packageJSDependencies := (packageJSDependencies in Test).value,
48+
packageMinifiedJSDependencies := (packageMinifiedJSDependencies in Test).value,
49+
packageScalaJSLauncher := (packageScalaJSLauncher in Test).value,
50+
persistLauncher := (persistLauncher in Test).value,
51+
relativeSourceMaps := (relativeSourceMaps in Test).value,
52+
resolvedJSDependencies := (resolvedJSDependencies in Test).value,
53+
// resolvedJSEnv := (resolvedJSEnv in Test).value,
54+
// scalaJSConsole := (scalaJSConsole in Test).value,
55+
scalaJSIR := (scalaJSIR in Test).value,
56+
scalaJSLauncher := (scalaJSLauncher in Test).value,
57+
scalaJSLinkedFile := (scalaJSLinkedFile in Test).value,
58+
scalaJSNativeLibraries := (scalaJSNativeLibraries in Test).value,
59+
scalaJSOptimizerOptions := (scalaJSOptimizerOptions in Test).value,
60+
scalaJSOutputMode := (scalaJSOutputMode in Test).value,
61+
scalaJSOutputWrapper := (scalaJSOutputWrapper in Test).value,
62+
scalajsp := (scalajsp in Test).value,
63+
scalaJSSemantics := (scalaJSSemantics in Test).value,
64+
scalaJSStage := (scalaJSStage in Test).value,
65+
66+
// Scala.JS internal settings
67+
scalaJSClearCacheStats := (scalaJSClearCacheStats in Test).value,
68+
scalaJSEnsureUnforked := (scalaJSEnsureUnforked in Test).value,
69+
scalaJSIRCacheHolder := (scalaJSIRCacheHolder in Test).value,
70+
scalaJSIRCache := (scalaJSIRCache in Test).value,
71+
scalaJSLinker := (scalaJSLinker in Test).value,
72+
scalaJSRequestsDOM := (scalaJSRequestsDOM in Test).value,
73+
sjsirFilesOnClasspath := (sjsirFilesOnClasspath in Test).value,
74+
usesScalaJSLinkerTag := (usesScalaJSLinkerTag in Test).value,
75+
76+
// SBT test settings
77+
definedTestNames := (definedTestNames in Test).value,
78+
definedTests := (definedTests in Test).value,
79+
// executeTests := (executeTests in Test).value,
80+
// loadedTestFrameworks := (loadedTestFrameworks in Test).value,
81+
// testExecution := (testExecution in Test).value,
82+
// testFilter := (testFilter in Test).value,
83+
testForkedParallel := (testForkedParallel in Test).value,
84+
// testFrameworks := (testFrameworks in Test).value,
85+
testGrouping := (testGrouping in Test).value,
86+
// testListeners := (testListeners in Test).value,
87+
// testLoader := (testLoader in Test).value,
88+
// testOnly := (testOnly in Test).value,
89+
testOptions := (testOptions in Test).value,
90+
// testQuick := (testQuick in Test).value,
91+
testResultLogger := (testResultLogger in Test).value,
92+
// test := (test in Test).value,
93+
94+
// In-browser settings
95+
jsEnv := env,
96+
requiresDOM := true,
97+
scalaJSUseRhino := false)))
98+
99+
def jvm: Project => Project =
100+
_.settings(
101+
testAll := (test in Test).value)
102+
}

project/build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version=0.13.12
1+
sbt.version=0.13.13

project/plugins.sbt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.11")
1+
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.13")
22
addSbtPlugin("com.lihaoyi" % "workbench" % "latest.integration")
3+
libraryDependencies += "org.scala-js" %% "scalajs-env-selenium" % "0.1.3"

src/main/resources/css/main.css

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,69 @@
11
html, body {
22
width: 100%;
33
height: 100%;
4-
margin: 0px;
4+
margin: 0 0;
55
}
66

77
canvas {
88
display: block;
99
}
10+
11+
.ribbon {
12+
top: 3.2em;
13+
right: -3.7em;
14+
-webkit-transform: rotate(45deg);
15+
-moz-transform: rotate(45deg);
16+
-ms-transform: rotate(45deg);
17+
-o-transform: rotate(45deg);
18+
transform: rotate(45deg);
19+
color:#fff;
20+
display: block;
21+
padding: .6em 3.5em;
22+
position: fixed;
23+
text-align: center;
24+
text-decoration: none;
25+
-webkit-user-select: none;
26+
-moz-user-select: none;
27+
-ms-user-select: none;
28+
-o-user-select: none;
29+
user-select: none;
30+
}
31+
32+
.bg-navy {
33+
background-color: #001f3f; }
34+
35+
.bg-blue {
36+
background-color: #0074d9; }
37+
38+
.bg-teal {
39+
background-color: #39cccc; }
40+
41+
.bg-olive {
42+
background-color: #3d9970; }
43+
44+
.bg-green {
45+
background-color: #218F2E; }
46+
47+
.bg-yellow {
48+
background-color: #ffdc00; }
49+
50+
.bg-orange {
51+
background-color: #ff851b; }
52+
53+
.bg-red {
54+
background-color: #ff4136; }
55+
56+
.bg-fuchsia {
57+
background-color: #f012be; }
58+
59+
.bg-purple {
60+
background-color: #b10dc9; }
61+
62+
.bg-maroon {
63+
background-color: #85144b; }
64+
65+
.bg-gray {
66+
background-color: #aaaaaa; }
67+
68+
.bg-black {
69+
background-color: #111111; }

src/main/resources/index-dev.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
<![endif]-->
3333

3434
<!-- Add your site or application content here -->
35+
<a href="index-dev.html" class="ribbon bg-red">Under development</a>
3536
<div>
3637
<canvas id="canvas main">Your browser doesn't support the HTML5 CANVAS tag.</canvas>
3738
</div>

src/main/resources/index.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@
2929
<![endif]-->
3030

3131
<!-- Add your site or application content here -->
32+
<a href="https://github.com/amsterdam-scala/Sjs-Full-Window-HTML5-Canvas/"><img
33+
style="position: absolute; top: 0; right: 0; border: 0;"
34+
src="https://camo.githubusercontent.com/652c5b9acfaddf3a9c326fa6bde407b87f7be0f4/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6f72616e67655f6666373630302e706e67"
35+
alt="Fork me on GitHub"
36+
data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_orange_ff7600.png"></a>
3237
<div>
3338
<canvas id="canvas main">Your browser doesn't support the HTML5 CANVAS tag.</canvas>
3439
</div>

0 commit comments

Comments
 (0)