Skip to content

Commit

Permalink
Work with released version of Java-Websocket.
Browse files Browse the repository at this point in the history
Add script to order pizza.
  • Loading branch information
watsonmw committed Jul 14, 2016
1 parent cdb7de3 commit d0da6fa
Show file tree
Hide file tree
Showing 27 changed files with 49 additions and 680 deletions.
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

39 changes: 18 additions & 21 deletions BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,24 @@

## Build

git clone --recursive git://git@watsonmw.com/home/git/pizzascript.git

The "--recursive" is need to download the vendor submodule(s).

cd pizzascript
git clone git://git@watsonmw.com/home/git/pizzascript.git
cd pizzascript

To build the script editor package:

gradle script-editor:distZip
gradle script-editor:distZip

This will save a zip file to:

script-editor/build/distributions/script-editor-0.2.zip
script-editor/build/distributions/script-editor-0.2.zip

To build a flat dir:

gradle pizzascript-editor:install
gradle pizzascript-editor:install

This will package run scripts and all dependent Jars to the following directory:

pizzascript-editor/build/install/script-editor
pizzascript-editor/build/install/script-editor


## Release Packaging
Expand All @@ -36,31 +33,31 @@ Release mode requires NodeJS & Gulp to minify the JS files (NodeJS is also neede
Install NodeJS 0.12+:

On OSX:
brew install nodejs
brew install nodejs

On Debian (replace \_ with just the underscore):
curl -sL https://deb.nodesource.com/setup\_0.12 | sudo bash -
sudo apt-get install nodejs
curl -sL https://deb.nodesource.com/setup\_0.12 | sudo bash -
sudo apt-get install nodejs

Install Gulp as follows (sudo is necessary):

npm install --global gulp
npm install --save-dev gulp
npm install gulp-uglify gulp-concat gulp-replace event-stream --save-dev
npm install --global gulp
npm install --save-dev gulp
npm install gulp-uglify gulp-concat gulp-replace event-stream --save-dev

To generate a release build:

gradle clean script-editor:distZip -Prelease
gradle clean script-editor:distZip -Prelease

Build docs:

npm install jsdoc3
npm install https://github.com/hegemonic/baseline/tarball/master
gradle docs
npm install jsdoc3
npm install https://github.com/hegemonic/baseline/tarball/master
gradle docs

## Run

Run script-editor and this will bring up an interactive JavaScript console.

>> b = pizza.open("www.google.com");
>> b.verifyText("Search")
b = pizza.open("www.google.com");
b.verifyText("Search")
2 changes: 1 addition & 1 deletion LICENSE.BSD
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ modification, are permitted provided that the following conditions are met:
3. All advertising materials mentioning features or use of this software
must display the following acknowledgement:
This product includes software developed by the LoadTestGo, Inc
4. Neither the name 'LoadTestGo', the name 'automate', nor the names of
4. Neither the name 'LoadTestGo', the name 'PizzaScript', nor the names of
its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

Expand Down
9 changes: 2 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import org.apache.tools.ant.taskdefs.condition.Os

subprojects {
apply plugin: 'java'
apply plugin: 'idea'
Expand All @@ -8,9 +6,6 @@ subprojects {
sourceCompatibility = 1.8
targetCompatibility = 1.8

String javaHome = System.properties.'java.home';
options.bootClasspath = javaHome + "/lib/rt.jar:" + javaHome + "/lib/jce.jar"

// Make sure warnings are on
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
}
Expand Down Expand Up @@ -66,13 +61,13 @@ project(':script-engine') {
dependencies {
compile project(':script-api')
compile project(':util')
compile project(':java-websocket')
compile "org.mozilla:rhino:$rhinoVersion"
compile 'commons-io:commons-io:2.4'
compile 'javax.servlet:javax.servlet-api:3.1.0'
compile "com.fasterxml.jackson.core:jackson-databind:$jacksonVersion"
compile 'org.json:json:20140107'
compile 'com.google.collections:google-collections:1.0'
compile 'org.java-websocket:Java-WebSocket:1.3.0'
}

if (project.hasProperty("release")) {
Expand All @@ -89,7 +84,7 @@ project(':script-engine') {

project(':script-editor') {
apply plugin: 'application'
mainClassName = "com.loadtestgo.script.editor.ScriptEditor"
mainClassName = "com.loadtestgo.script.editor.PizzaScript"
configurations.all {
resolutionStrategy {
failOnVersionConflict()
Expand Down
13 changes: 7 additions & 6 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ var replace = require('gulp-replace');
gulp.task('enginejs', function() {
var tasks = [];

var src = 'script-engine/src/main/resources/chrome/extension/pizza/'
var src = 'script-engine/src/main/resources/chrome/extension/pizza/';
var dest = 'script-engine/build/resources/main/chrome/extension/pizza/';
var i, r;

var copyDirect = ['config.js', 'namespace.js', 'content.js'];
for (var i = 0; i < copyDirect.length; ++i) {
for (i = 0; i < copyDirect.length; ++i) {
copyDirect[i] = src + copyDirect[i];
}

Expand Down Expand Up @@ -44,8 +45,8 @@ gulp.task('enginejs', function() {
return r;
}

for (var i = 0; i < l.length; ++i) {
var r = l[i];
for (i = 0; i < l.length; ++i) {
r = l[i];
r = cleanString(r);
if (r != "namespace.js" && r != "config.js") {
r = src + r;
Expand All @@ -64,8 +65,8 @@ gulp.task('enginejs', function() {
l = f.split(",");

files = [];
for (var i = 0; i < l.length; ++i) {
var r = l[i];
for (i = 0; i < l.length; ++i) {
r = l[i];
r = cleanString(r);
files.push(src + r);
}
Expand Down
15 changes: 2 additions & 13 deletions script-editor/src/dist/readme.txt
Original file line number Diff line number Diff line change
@@ -1,24 +1,13 @@
License
-------

Copyright (c) 2015 Mark Watson (watsonmw@gmail.com)

Not available for use without permission.

No implied warranty.


Requirements
------------

+ Java 8
+ Chrome 40+ (*)

Only tested on OSX, YMMV.

* Works with Stable and Release channels for the most part, but the block* and redirect*
functions are only supported on the Dev Channel right now.


Setup
-----

Expand All @@ -27,6 +16,7 @@ generally find it. Failing this you can set the path to Chrome (and other setti
in the settings.ini file. See the settings.ini file included with this download for
details.


Running
-------

Expand All @@ -47,7 +37,6 @@ Run the interactive console:
> bin/script-editor -console



Example Scripts
--------------

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.net.Inet4Address;
import java.net.InetAddress;
import java.util.ArrayList;
import java.io.IOException;

/**
* The main EngineContext that is shared between multiple browsers all
Expand Down Expand Up @@ -45,7 +46,7 @@ public synchronized void cleanup() {
if (webSocketServer != null) {
webSocketServer.stop(3000);
}
} catch (InterruptedException e) {
} catch (InterruptedException|IOException e) {
Logger.error(e, "while cleaning up");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -987,7 +987,9 @@ pizza.main.commands = function() {

function formatWasThrownException(response) {
var t;
if (response.exceptionDetails) {
if (response.result.value) {
return response.result.value;
} else if (response.exceptionDetails) {
t = response.exceptionDetails.text;
var uncaught = "Uncaught ";
if (t.indexOf(uncaught) == 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ public void start() throws IOException {
pageRegistry.registerClass(WeirdUrls.class, "/urls");
pageRegistry.registerClass(Redirects.class, "/redirect");
pageRegistry.registerClass(Timeouts.class, "/timeouts");
pageRegistry.registerClass(TestApi.class, "/test-api");
pageRegistry.registerClass(WebRtcApi.class, "/webrtc-api");
pageRegistry.registerClass(Posts.class, "/post");
pageRegistry.registerClass(Headers.class, "/headers");
Expand Down
14 changes: 14 additions & 0 deletions script/pizza.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
var b = pizza.open("https://themenustar.com/webspace/menus.php?code=newyorkerpizzeria.mobile-webview.com");
b.click("a:contains(CRAFT PIZZA)");

css = "h4:contains(Large San Diego Craft Pizza)";
b.waitForVisible(css);

b.click(css);
css = "#option_36576";
b.waitForVisible(css);
b.click(css);

b.click("#option_36600");
b.click("#option_36580");
b.click("button:contains(Add To Cart)");
4 changes: 0 additions & 4 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,3 @@ include "script-engine"
include "script-tester"
include "util"
include "view-metrics"

// Vendor libs
include ':java-websocket'
project(':java-websocket').projectDir = new File(rootProject.projectDir, 'vendor/Java-WebSocket')
62 changes: 0 additions & 62 deletions util/src/main/java/com/loadtestgo/util/DoubleArray.java

This file was deleted.

62 changes: 0 additions & 62 deletions util/src/main/java/com/loadtestgo/util/FloatArray.java

This file was deleted.

Loading

0 comments on commit d0da6fa

Please sign in to comment.