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

Side by Side Diff: plugins/org.chromium.sdk.tests/src/org/chromium/sdk/internal/v8native/DebugContextImplTest.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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.sdk.internal.v8native; 5 package org.chromium.sdk.internal.v8native;
6 6
7 import static org.junit.Assert.assertNotNull; 7 import static org.junit.Assert.assertNotNull;
8 import static org.junit.Assert.assertNull; 8 import static org.junit.Assert.assertNull;
9 import static org.junit.Assert.fail; 9 import static org.junit.Assert.fail;
10 10
11 import java.util.Collection; 11 import java.util.Collection;
12 import java.util.Collections; 12 import java.util.Collections;
13 import java.util.List; 13 import java.util.List;
14 import java.util.concurrent.CountDownLatch; 14 import java.util.concurrent.CountDownLatch;
15 15
16 import org.chromium.sdk.Breakpoint; 16 import org.chromium.sdk.Breakpoint;
17 import org.chromium.sdk.JsObject; 17 import org.chromium.sdk.JsObject;
18 import org.chromium.sdk.JsScope; 18 import org.chromium.sdk.JsScope;
19 import org.chromium.sdk.JsScope.Declarative;
20 import org.chromium.sdk.JsScope.ObjectBased;
19 import org.chromium.sdk.JsVariable; 21 import org.chromium.sdk.JsVariable;
20 import org.chromium.sdk.DebugContext.StepAction; 22 import org.chromium.sdk.DebugContext.StepAction;
21 import org.chromium.sdk.JavascriptVm.BreakpointCallback; 23 import org.chromium.sdk.JavascriptVm.BreakpointCallback;
22 import org.chromium.sdk.internal.browserfixture.AbstractAttachedTest; 24 import org.chromium.sdk.internal.browserfixture.AbstractAttachedTest;
23 import org.chromium.sdk.internal.transport.FakeConnection; 25 import org.chromium.sdk.internal.transport.FakeConnection;
24 import org.junit.Test; 26 import org.junit.Test;
25 27
26 /** 28 /**
27 * A test for the DebugContextImpl class. 29 * A test for the DebugContextImpl class.
28 */ 30 */
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 63
62 { 64 {
63 CountDownLatch latch = expectSuspend(); 65 CountDownLatch latch = expectSuspend();
64 messageResponder.hitBreakpoints(Collections.singleton(bp[0].getId())); 66 messageResponder.hitBreakpoints(Collections.singleton(bp[0].getId()));
65 latch.await(); 67 latch.await();
66 } 68 }
67 69
68 List<? extends JsScope> variableScopes = 70 List<? extends JsScope> variableScopes =
69 suspendContext.getCallFrames().get(0).getVariableScopes(); 71 suspendContext.getCallFrames().get(0).getVariableScopes();
70 72
71 Collection<? extends JsVariable> variables = variableScopes.get(0).getVariab les(); 73 Collection<? extends JsVariable> variables = getScopeVariables(variableScope s.get(0));
72 74
73 // This call invalidates the debug context for the "lookup" operation that i s invoked 75 // This call invalidates the debug context for the "lookup" operation that i s invoked
74 // inside "ensureProperties". 76 // inside "ensureProperties".
75 suspendContext.continueVm(StepAction.CONTINUE, 1, null); 77 suspendContext.continueVm(StepAction.CONTINUE, 1, null);
76 JsObject jsObject = variables.iterator().next().getValue().asObject(); 78 JsObject jsObject = variables.iterator().next().getValue().asObject();
77 try { 79 try {
78 jsObject.getProperties(); 80 jsObject.getProperties();
79 fail(); 81 fail();
80 } catch (RuntimeException e) { 82 } catch (RuntimeException e) {
81 // this exception is expected 83 // this exception is expected
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 117
116 { 118 {
117 CountDownLatch latch = expectSuspend(); 119 CountDownLatch latch = expectSuspend();
118 messageResponder.hitBreakpoints(Collections.singleton(bp[0].getId())); 120 messageResponder.hitBreakpoints(Collections.singleton(bp[0].getId()));
119 latch.await(); 121 latch.await();
120 } 122 }
121 123
122 List<? extends JsScope> variableScopes = 124 List<? extends JsScope> variableScopes =
123 suspendContext.getCallFrames().get(0).getVariableScopes(); 125 suspendContext.getCallFrames().get(0).getVariableScopes();
124 126
125 Collection<? extends JsVariable> variables = variableScopes.get(0).getVariab les(); 127 Collection<? extends JsVariable> variables = getScopeVariables(variableScope s.get(0));
126 128
127 JsObject jsObject = variables.iterator().next().getValue().asObject(); 129 JsObject jsObject = variables.iterator().next().getValue().asObject();
128 // This call should finish OK 130 // This call should finish OK
129 jsObject.getProperties(); 131 jsObject.getProperties();
130 } 132 }
131 133
132 @Override 134 @Override
133 protected FakeConnection createConnection() { 135 protected FakeConnection createConnection() {
134 return new FakeConnection(messageResponder); 136 return new FakeConnection(messageResponder);
135 } 137 }
138
139 private static Collection<? extends JsVariable> getScopeVariables(JsScope scop e) {
140 return scope.accept(new JsScope.Visitor<Collection<? extends JsVariable>>() {
141 @Override
142 public Collection<? extends JsVariable> visitDeclarative(Declarative decla rativeScope) {
143 return declarativeScope.getVariables();
144 }
145
146 @Override
147 public Collection<? extends JsVariable> visitObject(ObjectBased objectScop e) {
148 return objectScope.getScopeObject().getProperties();
149 }
150
151 });
152 }
136 } 153 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698