Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2658)

Unified Diff: utils/org.chromium.sdk.tests.system/src/org/chromium/sdk/tests/system/Main.java

Issue 12316003: Fix tests compilation (Closed) Base URL: https://chromedevtools.googlecode.com/svn/trunk
Patch Set: format Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « plugins/org.chromium.sdk/src/org/chromium/sdk/internal/v8native/ScriptManager.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils/org.chromium.sdk.tests.system/src/org/chromium/sdk/tests/system/Main.java
diff --git a/utils/org.chromium.sdk.tests.system/src/org/chromium/sdk/tests/system/Main.java b/utils/org.chromium.sdk.tests.system/src/org/chromium/sdk/tests/system/Main.java
index e15c6c58b4ecbd9773ecb8fc8f7a8ee3ff42ab15..01e65899fac828f3d31a26c9525869c1c9ba6c98 100644
--- a/utils/org.chromium.sdk.tests.system/src/org/chromium/sdk/tests/system/Main.java
+++ b/utils/org.chromium.sdk.tests.system/src/org/chromium/sdk/tests/system/Main.java
@@ -21,8 +21,11 @@ import org.chromium.sdk.ConnectionLogger.Factory;
import org.chromium.sdk.DebugContext;
import org.chromium.sdk.JavascriptVm;
import org.chromium.sdk.JsEvaluateContext;
+import org.chromium.sdk.JsEvaluateContext.ResultOrException;
import org.chromium.sdk.JsObject;
import org.chromium.sdk.JsScope;
+import org.chromium.sdk.JsScope.Declarative;
+import org.chromium.sdk.JsScope.ObjectBased;
import org.chromium.sdk.JsValue;
import org.chromium.sdk.JsVariable;
import org.chromium.sdk.RelayOk;
@@ -108,7 +111,7 @@ public class Main {
{
// Check cache dropping.
JsObject root = evaluateSync(context.getGlobalEvaluateContext(),
- "(debug_value_1 = {a:2})").getValue().asObject();
+ "(debug_value_1 = {a:2})").asObject();
if (root == null) {
throw new RuntimeException();
}
@@ -130,9 +133,8 @@ public class Main {
{
// Check literals.
for (LiteralTestCase literal : TEST_LITERALS) {
- JsVariable resultVar = evaluateSync(context.getGlobalEvaluateContext(),
+ JsValue resultValue = evaluateSync(context.getGlobalEvaluateContext(),
literal.javaScriptExpression);
- JsValue resultValue = resultVar.getValue();
if (resultValue.getType() != literal.expectedType) {
throw new SmokeException("Unexpected type of '" + literal.javaScriptExpression +
"': " + resultValue.getType());
@@ -298,7 +300,18 @@ public class Main {
}
private static JsVariable getVariable(JsScope scope, String name) throws SmokeException {
- for (JsVariable var : scope.getVariables()) {
+ Collection<? extends JsVariable> variables = scope.accept(
+ new JsScope.Visitor<Collection<? extends JsVariable>>() {
+ @Override
+ public Collection<? extends JsVariable> visitDeclarative(Declarative declarativeScope) {
+ return declarativeScope.getVariables();
+ }
+ @Override
+ public Collection<? extends JsVariable> visitObject(ObjectBased objectScope) {
+ return objectScope.getScopeObject().getProperties();
+ }
+ });
+ for (JsVariable var : variables) {
if (name.equals(var.getName())) {
return var;
}
@@ -310,18 +323,33 @@ public class Main {
* Calls fibonacci expression in context for stack frame and checks the result value.
*/
private static void checkExpression(CallFrame frame) throws SmokeException {
- final ValueHolder<JsVariable> variableHolder = new ValueHolder<JsVariable>();
+ final ValueHolder<JsValue> variableHolder = new ValueHolder<JsValue>();
JsEvaluateContext.EvaluateCallback callback = new JsEvaluateContext.EvaluateCallback() {
- public void failure(String errorMessage) {
- variableHolder.setException(new Exception(errorMessage));
+ @Override
+ public void success(ResultOrException result) {
+ result.accept(new ResultOrException.Visitor<Void>() {
+ @Override
+ public Void visitResult(JsValue value) {
+ variableHolder.setValue(value);
+ return null;
+ }
+
+ @Override
+ public Void visitException(JsValue exception) {
+ variableHolder.setException(
+ new Exception("Caught exception: " + exception.getValueString()));
+ return null;
+ }
+ });
}
- public void success(JsVariable variable) {
- variableHolder.setValue(variable);
+
+ @Override public void failure(Exception cause) {
+ variableHolder.setException(new Exception(cause));
}
};
frame.getEvaluateContext().evaluateSync(FIBONACCI_EXPRESSION, null, callback);
- JsVariable variable = variableHolder.get();
- String resString = variable.getValue().getValueString();
+ JsValue value = variableHolder.get();
+ String resString = value.getValueString();
if (!"24".equals(resString)) {
throw new SmokeException("Wrong expression value");
}
@@ -528,26 +556,40 @@ public class Main {
}
static class EvalCallbackImpl implements JsEvaluateContext.EvaluateCallback {
- JsVariable variable = null;
- String failure = null;
- @Override
- public void success(JsVariable variable) {
- this.variable = variable;
- }
+ JsValue value = null;
+ Exception failure = null;
- @Override
- public void failure(String errorMessage) {
- this.failure = errorMessage;
- }
- JsVariable get() {
+ JsValue get() {
if (failure != null) {
throw new RuntimeException("Failed to evaluate: " + failure);
}
- return variable;
+ return value;
+ }
+
+ @Override
+ public void success(ResultOrException result) {
+ result.accept(new ResultOrException.Visitor<Void>() {
+ @Override
+ public Void visitResult(JsValue value) {
+ EvalCallbackImpl.this.value = value;
+ return null;
+ }
+
+ @Override
+ public Void visitException(JsValue exception) {
+ failure = new Exception("JavaScript exception: " + exception.getValueString());
+ return null;
+ }
+ });
+ }
+
+ @Override
+ public void failure(Exception cause) {
+ this.failure = cause;
}
}
- private static JsVariable evaluateSync(JsEvaluateContext evaluateContext, String expression) {
+ private static JsValue evaluateSync(JsEvaluateContext evaluateContext, String expression) {
EvalCallbackImpl callbackImpl = new EvalCallbackImpl();
evaluateContext.evaluateSync(expression, null, callbackImpl);
return callbackImpl.get();
« no previous file with comments | « plugins/org.chromium.sdk/src/org/chromium/sdk/internal/v8native/ScriptManager.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698