|
Added
Link Here
|
| 1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2011 EclipseSource and others. |
| 3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* which accompanies this distribution, and is available at |
| 6 |
* http://www.eclipse.org/legal/epl-v10.html |
| 7 |
* |
| 8 |
* Contributors: |
| 9 |
* EclipseSource - initial API and implementation |
| 10 |
******************************************************************************/ |
| 11 |
|
| 12 |
qx.Class.define( "org.eclipse.rwt.test.tests.ObjectManagerTest", { |
| 13 |
|
| 14 |
extend : qx.core.Object, |
| 15 |
|
| 16 |
members : { |
| 17 |
|
| 18 |
testAdd : function() { |
| 19 |
var manager = org.eclipse.rwt.protocol.ObjectManager; |
| 20 |
var obj = {}; |
| 21 |
|
| 22 |
manager.add( "myId", obj, "myType" ); |
| 23 |
|
| 24 |
assertIdentical( obj, manager.getObject( "myId" ) ); |
| 25 |
assertEquals( "myType", manager.getType( "myId" ) ); |
| 26 |
this._clearObjectManager(); |
| 27 |
}, |
| 28 |
|
| 29 |
testRemove : function() { |
| 30 |
var manager = org.eclipse.rwt.protocol.ObjectManager; |
| 31 |
var obj = {}; |
| 32 |
manager.add( "myId", obj, "myType" ); |
| 33 |
|
| 34 |
manager.remove( "myId" ); |
| 35 |
|
| 36 |
assertIdentical( undefined, manager.getObject( "myId" ) ); |
| 37 |
assertIdentical( undefined, manager.getType( "myId" ) ); |
| 38 |
this._clearObjectManager(); |
| 39 |
}, |
| 40 |
|
| 41 |
testApplyObjectIdIsCalled : function() { |
| 42 |
var manager = org.eclipse.rwt.protocol.ObjectManager; |
| 43 |
var log = ""; |
| 44 |
var obj = { |
| 45 |
applyObjectId : function( id ) { |
| 46 |
log += id; |
| 47 |
} |
| 48 |
}; |
| 49 |
|
| 50 |
manager.add( "myId", obj, "myType" ); |
| 51 |
|
| 52 |
assertEquals( "myId", log ); |
| 53 |
this._clearObjectManager(); |
| 54 |
}, |
| 55 |
|
| 56 |
_clearObjectManager: function() { |
| 57 |
var manager = org.eclipse.rwt.protocol.ObjectManager; |
| 58 |
manager._map = {}; |
| 59 |
manager._callbacks = {}; |
| 60 |
} |
| 61 |
} |
| 62 |
|
| 63 |
} ); |