зеркало из https://github.com/mozilla/pluotsorbet.git
remind code to return false
This commit is contained in:
Родитель
55fa5f10d7
Коммит
9e95593950
|
@ -74,6 +74,7 @@ button {
|
|||
<script type="text/javascript" src="libs/jsbn.js" defer></script>
|
||||
<script type="text/javascript" src="libs/jsbn2.js" defer></script>
|
||||
<script type="text/javascript" src="midp/midp.js" defer></script>
|
||||
<script type="text/javascript" src="midp/frameanimator.js" defer></script>
|
||||
<script type="text/javascript" src="midp/fs.js" defer></script>
|
||||
<script type="text/javascript" src="midp/crypto.js" defer></script>
|
||||
<script type="text/javascript" src="midp/gfx.js" defer></script>
|
||||
|
|
|
@ -16,48 +16,18 @@ public class FrameAnimator {
|
|||
protected static int _numRegistered;
|
||||
|
||||
public FrameAnimator() {
|
||||
System.out.println("warning: FrameAnimator() not implemented");
|
||||
init();
|
||||
}
|
||||
|
||||
public boolean register(int x, int y, short maxFps, short maxPps, FrameAnimatorListener listener) {
|
||||
System.out.println("warning: FrameAnimator.register(IISSL...FrameAnimatorListener;)Z not implemented (" +
|
||||
x + ", " + y + ", " + maxFps + ", " + maxPps + ", " + listener + ")");
|
||||
_numRegistered++;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void unregister() {
|
||||
System.out.println("warning: FrameAnimator.unregister()V not implemented");
|
||||
_numRegistered--;
|
||||
}
|
||||
|
||||
public void drag(int x, int y) {
|
||||
System.out.println("warning: FrameAnimator.drag(II)V not implemented (" + x + ", " + y + ")");
|
||||
}
|
||||
|
||||
public void kineticScroll(int speed, int direction, int friction, float angle) {
|
||||
System.out.println("warning: FrameAnimator.kineticScroll(IIIF)V not implemented (" +
|
||||
speed + ", " + direction + ", " + friction + ", " + angle + ")");
|
||||
}
|
||||
|
||||
public void limitedKineticScroll(int speed, int direction, int friction, float angle, int limitUp, int limitDown) {
|
||||
System.out.println("warning: FrameAnimator.limitedKineticScroll(IIIFII)V not implemented (" +
|
||||
speed + ", " + direction + ", " + friction + ", " + angle + ", " + limitUp + ", " +
|
||||
limitDown + ")");
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
System.out.println("warning: FrameAnimator.stop()V not implemented");
|
||||
}
|
||||
|
||||
public boolean isRegistered() {
|
||||
System.out.println("warning: FrameAnimator.isRegistered()Z not implemented");
|
||||
return true;
|
||||
}
|
||||
|
||||
public static int getNumRegisteredFrameAnimators() {
|
||||
System.out.println("warning: FrameAnimator.getNumRegisteredFrameAnimators()I not implemented");
|
||||
return _numRegistered;
|
||||
}
|
||||
private native void init();
|
||||
|
||||
public native boolean register(int x, int y, short maxFps, short maxPps, FrameAnimatorListener listener)
|
||||
throws IllegalStateException, NullPointerException, IllegalArgumentException;
|
||||
public native void unregister() throws IllegalStateException;
|
||||
public native void drag(int x, int y);
|
||||
public native void kineticScroll(int speed, int direction, int friction, float angle);
|
||||
public native void limitedKineticScroll(int speed, int direction, int friction, float angle, int limitUp, int limitDown);
|
||||
public native void stop();
|
||||
public native boolean isRegistered();
|
||||
public native static int getNumRegisteredFrameAnimators();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,102 @@
|
|||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
||||
|
||||
'use strict';
|
||||
|
||||
var FrameAnimator = function() {};
|
||||
|
||||
FrameAnimator.numRegistered = 0;
|
||||
|
||||
FrameAnimator.prototype._isRegistered = false;
|
||||
|
||||
FrameAnimator.prototype.register = function(x, y, maxFps, maxPps, listener) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.maxFps = maxFps;
|
||||
this.maxPps = maxPps;
|
||||
this.listener = listener;
|
||||
this._isRegistered = true;
|
||||
++FrameAnimator.numRegistered;
|
||||
};
|
||||
|
||||
FrameAnimator.prototype.unregister = function() {
|
||||
this.x = null;
|
||||
this.y = null;
|
||||
this.maxFps = null;
|
||||
this.maxPps = null;
|
||||
this.listener = null;
|
||||
this._isRegistered = false;
|
||||
--FrameAnimator.numRegistered;
|
||||
};
|
||||
|
||||
FrameAnimator.prototype.isRegistered = function() {
|
||||
return this._isRegistered;
|
||||
};
|
||||
|
||||
Native["com/nokia/mid/ui/frameanimator/FrameAnimator.init.()V"] = function(ctx, stack) {
|
||||
var _this = stack.pop();
|
||||
_this.nativeObject = new FrameAnimator();
|
||||
};
|
||||
|
||||
Native["com/nokia/mid/ui/frameanimator/FrameAnimator.register.(IISSLcom/nokia/mid/ui/frameanimator/FrameAnimatorListener;)Z"] = function(ctx, stack) {
|
||||
var listener = stack.pop(), maxPps = stack.pop(), maxFps = stack.pop(), y = stack.pop(), x = stack.pop(), _this = stack.pop();
|
||||
|
||||
if (_this.nativeObject.isRegistered()) {
|
||||
ctx.raiseExceptionAndYield("java/lang/IllegalStateException", "FrameAnimator already registered");
|
||||
}
|
||||
|
||||
if (!listener) {
|
||||
ctx.raiseExceptionAndYield("java/lang/NullPointerException", "listener is null");
|
||||
}
|
||||
|
||||
if (x < -65535 || x > 65535 || y < -65535 || y > 65535) {
|
||||
ctx.raiseExceptionAndYield("java/lang/IllegalArgumentException", "coordinate out of bounds");
|
||||
}
|
||||
|
||||
// XXX return false if FrameAnimator.numRegistered >= FRAME_ANIMATOR_MAX_CONCURRENT
|
||||
|
||||
_this.nativeObject.register(x, y, maxFps, maxPps, listener);
|
||||
stack.push(1);
|
||||
};
|
||||
|
||||
Native["com/nokia/mid/ui/frameanimator/FrameAnimator.unregister.()V"] = function(ctx, stack) {
|
||||
var _this = stack.pop();
|
||||
|
||||
if (!_this.nativeObject.isRegistered()) {
|
||||
ctx.raiseExceptionAndYield("java/lang/IllegalStateException", "FrameAnimator not registered");
|
||||
}
|
||||
|
||||
_this.nativeObject.unregister();
|
||||
};
|
||||
|
||||
Native["com/nokia/mid/ui/frameanimator/FrameAnimator.drag.(II)V"] = function(ctx, stack) {
|
||||
var y = stack.pop(), x = stack.pop(), _this = stack.pop();
|
||||
console.warn("FrameAnimator.drag(II)V not implemented (" + x + ", " + y + ")");
|
||||
};
|
||||
|
||||
Native["com/nokia/mid/ui/frameanimator/FrameAnimator.kineticScroll.(IIIF)V"] = function(ctx, stack) {
|
||||
var angle = stack.pop(), friction = stack.pop(), direction = stack.pop(), speed = stack.pop(), _this = stack.pop();
|
||||
console.warn("FrameAnimator.kineticScroll(IIIF)V not implemented (" +
|
||||
speed + ", " + direction + ", " + friction + ", " + angle + ")");
|
||||
};
|
||||
|
||||
Native["com/nokia/mid/ui/frameanimator/FrameAnimator.limitedKineticScroll.(IIIFII)V"] = function(ctx, stack) {
|
||||
var limitDown = stack.pop(), limitUp = stack.pop(), angle = stack.pop(), friction = stack.pop(),
|
||||
direction = stack.pop(), speed = stack.pop(), _this = stack.pop();
|
||||
console.warn("FrameAnimator.limitedKineticScroll(IIIFII)V not implemented (" +
|
||||
speed + ", " + direction + ", " + friction + ", " + angle + ", " + limitUp + ", " + limitDown + ")");
|
||||
};
|
||||
|
||||
Native["com/nokia/mid/ui/frameanimator/FrameAnimator.stop.()V"] = function(ctx, stack) {
|
||||
var _this = stack.pop();
|
||||
console.warn("FrameAnimator.stop()V not implemented");
|
||||
};
|
||||
|
||||
Native["com/nokia/mid/ui/frameanimator/FrameAnimator.isRegistered.()Z"] = function(ctx, stack) {
|
||||
var _this = stack.pop();
|
||||
stack.push(_this.nativeObject.isRegistered() ? 1 : 0);
|
||||
};
|
||||
|
||||
Native["com/nokia/mid/ui/frameanimator/FrameAnimator.getNumRegisteredFrameAnimators.()I"] = function(ctx, stack) {
|
||||
stack.push(FrameAnimator.numRegistered);
|
||||
};
|
|
@ -9,7 +9,7 @@ casper.test.begin("unit tests", 5, function(test) {
|
|||
casper
|
||||
.start("http://localhost:8000/index.html")
|
||||
.waitForText("DONE", function then() {
|
||||
test.assertTextExists("DONE: 4339 pass, 0 fail, 165 known fail, 0 unknown pass", "run unit tests");
|
||||
test.assertTextExists("DONE: 4346 pass, 0 fail, 165 known fail, 0 unknown pass", "run unit tests");
|
||||
}, function onTimeout() {
|
||||
test.fail();
|
||||
}, 30000);
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
package com.nokia.mid.ui.frameanimator;
|
||||
|
||||
import gnu.testlet.TestHarness;
|
||||
import gnu.testlet.Testlet;
|
||||
|
||||
public class TestFrameAnimator implements Testlet, FrameAnimatorListener {
|
||||
public void test(TestHarness th) {
|
||||
FrameAnimator animator = new FrameAnimator();
|
||||
th.check(animator.isRegistered(), false);
|
||||
th.check(FrameAnimator.getNumRegisteredFrameAnimators(), 0);
|
||||
|
||||
try {
|
||||
animator.register(0, 0, (short) 0, (short) 0, null);
|
||||
th.fail("listener is null");
|
||||
} catch (Exception e) {
|
||||
th.check(e.getMessage(), "listener is null");
|
||||
}
|
||||
|
||||
try {
|
||||
animator.register(-65536, 0, (short) 0, (short) 0, listener);
|
||||
th.fail("coordinate out of bounds");
|
||||
} catch (Exception e) {
|
||||
th.check(e.getMessage(), "coordinate out of bounds");
|
||||
}
|
||||
|
||||
try {
|
||||
animator.register(65536, 0, (short) 0, (short) 0, listener);
|
||||
th.fail("coordinate out of bounds");
|
||||
} catch (Exception e) {
|
||||
th.check(e.getMessage(), "coordinate out of bounds");
|
||||
}
|
||||
|
||||
try {
|
||||
animator.register(0, -65536, (short) 0, (short) 0, listener);
|
||||
th.fail("coordinate out of bounds");
|
||||
} catch (Exception e) {
|
||||
th.check(e.getMessage(), "coordinate out of bounds");
|
||||
}
|
||||
|
||||
try {
|
||||
animator.register(0, 65536, (short) 0, (short) 0, listener);
|
||||
th.fail("coordinate out of bounds");
|
||||
} catch (Exception e) {
|
||||
th.check(e.getMessage(), "coordinate out of bounds");
|
||||
}
|
||||
|
||||
animator.register(0, 0, (short) 0, (short) 0, this);
|
||||
th.check(animator.isRegistered(), true);
|
||||
th.check(FrameAnimator.getNumRegisteredFrameAnimators(), 1);
|
||||
|
||||
try {
|
||||
animator.register(0, 0, (short) 0, (short) 0, this);
|
||||
th.fail("FrameAnimator already registered");
|
||||
} catch (Exception e) {
|
||||
th.check(e.getMessage(), "FrameAnimator already registered");
|
||||
}
|
||||
|
||||
animator.unregister();
|
||||
th.check(animator.isRegistered(), false);
|
||||
th.check(FrameAnimator.getNumRegisteredFrameAnimators(), 0);
|
||||
|
||||
try {
|
||||
animator.unregister();
|
||||
th.fail("FrameAnimator not registered");
|
||||
} catch (Exception e) {
|
||||
th.check(e.getMessage(), "FrameAnimator not registered");
|
||||
}
|
||||
}
|
||||
|
||||
public void animate(FrameAnimator animator, int x, int y, short delta, short deltaX, short deltaY, boolean lastFrame) {}
|
||||
}
|
Загрузка…
Ссылка в новой задаче