@Test
public void testDoNotRemoveUsed() throws Exception {

  // Make a shader job with a simple fragment shader that declares (but does not use)
  // a uniform.  We don't want the metadata for this uniform to get removed; the declaration
  // of the uniform would have to actually disappear first.
  final String emptyShader = "uniform float unused; void main() { }";
  final PipelineInfo pipelineInfo = new PipelineInfo();
  pipelineInfo.addUniform("unused", BasicType.FLOAT, Optional.empty(),
      Collections.singletonList(10.0));
  final ShaderJob shaderJob = new GlslShaderJob(Optional.empty(),
      pipelineInfo, ParseHelper.parse(emptyShader));
  // Check that initially there is indeed one uniform in the pipeline state.
  assertEquals(1, shaderJob.getPipelineInfo().getNumUniforms());
  // There should be no opportunities to remove a piece of unused pipeline state.
  List<RemoveRedundantUniformMetadataReductionOpportunity> ops =
      RemoveRedundantUniformMetadataReductionOpportunities
      .findOpportunities(shaderJob,
          new ReducerContext(false, ShadingLanguageVersion.ESSL_100, new RandomWrapper(0),
              new IdGenerator()));
  assertEquals(0, ops.size());
}