AbstractScreen implements Screen { @Override public final void render(float delta) { if (!created) { onCreate(gameContext); created = true; } Color backgroundColor = gameContext.getBackgroundColor(); Gdx.gl.glClearColor(backgroundColor.r, backgroundColor.g, backgroundColor.b, backgroundColor.a); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT); onUpdate(delta); gameContext.updateAndRender(delta); } AbstractScreen(T game, ArgumentFactory<AbstractScreen<T, C>, C> contextFactory); T getGame(); @Override final void show(); @Override final void render(float delta); @Override final void resize(int width, int height); @Override void pause(); @Override void resume(); @Override void hide(); ViewportFactory getViewportFactory(); Viewport getViewport(int width, int height, Camera camera); @Override void dispose();  }
@Test public void testRender() { Gdx.gl = mock(GL20.class); BrainGdxGame game = mock(BrainGdxGame.class); final GameContext context = mock(GameContext.class); when(context.getBackgroundColor()).thenReturn(Color.BLACK); final AtomicBoolean onUpdateCalled = new AtomicBoolean(); ArgumentFactory<AbstractScreen<BrainGdxGame, GameContext>, GameContext> contextArgumentFactory = new ArgumentFactory<AbstractScreen<BrainGdxGame, GameContext>, GameContext>() { @Override public GameContext create(AbstractScreen<BrainGdxGame, GameContext> supplier) { return context; } }; AbstractScreen<?, ?> screen = new AbstractScreen<BrainGdxGame, GameContext>(game, contextArgumentFactory) { @Override protected void onCreate(GameContext context) { } @Override protected void onUpdate(float delta) { onUpdateCalled.set(true); } }; screen.show(); screen.render(10f); verify(context).updateAndRender(10f); assertTrue(onUpdateCalled.get()); }