@Test public void testCustomSimpleName() throws Exception { class CustomTypeNamedEntity extends AbstractEntity { private final String typeName; CustomTypeNamedEntity(Entity parent, String typeName) { super(parent); this.typeName = typeName; } @Override protected String getEntityTypeName() { return typeName; } } CustomTypeNamedEntity entity2 = new CustomTypeNamedEntity(app, "a.b.with space"); Entities.manage(entity2); assertEquals(entity2.getEntityType().getSimpleName(), "with_space"); CustomTypeNamedEntity entity3 = new CustomTypeNamedEntity(app, "a.b.with$dollar"); Entities.manage(entity3); assertEquals(entity3.getEntityType().getSimpleName(), "with_dollar"); CustomTypeNamedEntity entity4 = new CustomTypeNamedEntity(app, "a.nothingafterdot."); Entities.manage(entity4); assertEquals(entity4.getEntityType().getSimpleName(), "a.nothingafterdot."); }
@AfterMethod(alwaysRun = true) @Override public void tearDown() throws Exception { super.tearDown(); if (newApp != null) Entities.destroyAll(newApp.getManagementContext()); if (newManagementContext != null) Entities.destroyAll(newManagementContext); if (mementoDir != null) RebindTestUtils.deleteMementoDir(mementoDir); }
@Test public void addEntities() throws Exception { String[][] array = {{"foo", "100"}, {"bar", "101"}}; Entities e = new Entities(); e.addEntities(array); assertEquals("foo", e.getEntityName(100)); assertEquals("bar", e.getEntityName(101)); assertEquals(100, e.getEntityValue("foo")); assertEquals(101, e.getEntityValue("bar")); }
@BeforeMethod public void setUpTestEntity() throws Exception { app = ApplicationBuilder.newManagedApp(TestApplication.class); entity = new AbstractEntity(app) {}; Entities.startManagement(entity); listener = new EntitySubscriptionTest.RecordingSensorEventListener(); app.getSubscriptionContext().subscribe(entity, SENSOR_ADDED, listener); app.getSubscriptionContext().subscribe(entity, SENSOR_REMOVED, listener); }
@Test public void entityMap() { Entities map = new Entities(); map.addEntity("foo", 1); assertEquals(1, map.getEntityValue("foo")); assertEquals("foo", map.getEntityName(1)); // 查找表将被更新 map.addEntity("bar", 2); map.addEntity("baz", 3); assertEquals(3, map.getEntityValue("baz")); assertEquals("baz", map.getEntityName(3)); }
@Test public void testGetCandidateSolutions() { Vector v1 = Vector.of(1.0, 2.0, 3.0); Vector v2 = Vector.of(4.0, 5.0, 6.0); Particle p1 = new StandardParticle(); Particle p2 = new StandardParticle(); p1.setCandidateSolution(v1); p2.setCandidateSolution(v2); List<Vector> list = Entities.<Vector>getCandidateSolutions(Arrays.asList(p1, p2)); assertEquals(v1, list.get(0)); assertEquals(v2, list.get(1)); }
@Test public void testAddAndRemoveChildrenEmitsEvent() { entity = app.createAndManageChild(EntitySpec.create(TestEntity.class)); assertCollectionEquals(app.getChildren(), ImmutableList.of(entity)); assertEqualsEventually(added, ImmutableList.of(entity)); entity2 = app.createAndManageChild(EntitySpec.create(TestEntity.class)); assertCollectionEquals(app.getChildren(), ImmutableList.of(entity, entity2)); assertEqualsEventually(added, ImmutableList.of(entity, entity2)); entity.removeChild(entity); assertCollectionEquals(app.getChildren(), ImmutableList.of(entity2)); assertEqualsEventually(removed, ImmutableList.of(entity)); Entities.unmanage(entity2); assertCollectionEquals(app.getChildren(), ImmutableList.of()); assertEqualsEventually(removed, ImmutableList.of(entity, entity2)); }
/** R_BeginFrame */ public final void BeginFrame(float camera_separation) { GlConfig.gl_state.camera_separation = camera_separation; /* * * change modes if necessary */ if (GlConfig.gl_mode.modified || GlConfig.vid_fullscreen.modified) { // FIXME: only restart if CDS is required ConsoleVariable ref; ref = ConsoleVariables.Get("vid_ref", "lwjgl", 0); ref.modified = true; } if (GlConfig.gl_log.modified) { // GlBase.GLimp_EnableLogging((GlState.gl_log.value != 0.0f)); GlConfig.gl_log.modified = false; } if (GlConfig.gl_log.value != 0.0f) { // GlBase.GLimp_LogNewFrame(); } /* * * update 3Dfx gamma -- it is expected that a user will do a vid_restart* * after tweaking this value */ if (GlConfig.vid_gamma.modified) { GlConfig.vid_gamma.modified = false; } /* * * go into 2D mode */ GlState.gl.glViewport(0, 0, GlState.vid.width, GlState.vid.height); GlState.gl.glMatrixMode(Gl1Context.GL_PROJECTION); GlState.gl.glLoadIdentity(); GlState.gl.glOrtho(0, GlState.vid.width, GlState.vid.height, 0, -99999, 99999); GlState.gl.glMatrixMode(Gl1Context.GL_MODELVIEW); GlState.gl.glLoadIdentity(); GlState.gl.glDisable(Gl1Context.GL_DEPTH_TEST); GlState.gl.glDisable(Gl1Context.GL_CULL_FACE); GlState.gl.glDisable(Gl1Context.GL_BLEND); // gl.glEnable(GLAdapter.GL_ALPHA_TEST); GlState.gl.glColor4f(1, 1, 1, 1); /* * * draw buffer stuff */ if (GlConfig.gl_drawbuffer.modified) { GlConfig.gl_drawbuffer.modified = false; if (GlState.camera_separation == 0 || !GlState.stereo_enabled) { if (GlConfig.gl_drawbuffer.string.equalsIgnoreCase("GL_FRONT")) GlState.gl.glDrawBuffer(Gl1Context.GL_FRONT); else GlState.gl.glDrawBuffer(Gl1Context.GL_BACK); } } /* * * texturemode stuff */ if (GlConfig.gl_texturemode.modified) { Images.GL_TextureMode(GlConfig.gl_texturemode.string); GlConfig.gl_texturemode.modified = false; } if (GlConfig.gl_texturealphamode.modified) { Images.GL_TextureAlphaMode(GlConfig.gl_texturealphamode.string); GlConfig.gl_texturealphamode.modified = false; } if (GlConfig.gl_texturesolidmode.modified) { Images.GL_TextureSolidMode(GlConfig.gl_texturesolidmode.string); GlConfig.gl_texturesolidmode.modified = false; } /* * * swapinterval stuff */ Misc.GL_UpdateSwapInterval(); // // clear screen if desired // Entities.R_Clear(); }
/** * @see * com.googlecode.gwtquake.shared.client.Renderer#RenderFrame(com.googlecode.gwtquake.shared.client.RendererState) */ public final void RenderFrame(RendererState fd) { Entities.R_RenderFrame(fd); }
@Before public void init() { entities = new Entities(); entities.addEntity("foo", 161); entities.addEntity("bar", 162); }
@AfterMethod(alwaysRun = true) public void tearDown() throws Exception { if (app != null) Entities.destroyAll(app.getManagementContext()); if (tempDataDir != null) Os.deleteRecursively(tempDataDir); }
@AfterMethod(alwaysRun = true) public void tearDown() { if (app != null) Entities.destroyAll(app.getManagementContext()); }
/** * Fills the specified entities instance with HTML 40 entities. * * @param entities the instance to be filled. */ static void fillWithHtml40Entities(Entities entities) { entities.addEntities(BASIC_ARRAY); entities.addEntities(ISO8859_1_ARRAY); entities.addEntities(HTML40_ARRAY); }
static { FAST_XS = new Entities(); FAST_XS.addEntities(BASIC_ARRAY); }
static { HTML32 = new Entities(); HTML32.addEntities(BASIC_ARRAY); HTML32.addEntities(ISO8859_1_ARRAY); }
static { XML = new Entities(); XML.addEntities(BASIC_ARRAY); XML.addEntities(APOS_ARRAY); }