@Test
public void testDoNotRemoveUsedMultipleShaders() throws Exception {

  // A shader job with a vertex shader and fragment shader that each use a different
  // uniform (but that do not use a uniform in common).  Neither uniform should be removed
  // from the pipeline state.
  final String minimalVertexShader = "uniform float used_in_vertex_only; void main() { "
      + "used_in_vertex_only; }";
  final String minimalFragmentShader = "uniform float used_in_fragment_only; void main() { "
      + "used_in_fragment_only; }";
  final PipelineInfo pipelineInfo = new PipelineInfo();
  pipelineInfo.addUniform("used_in_vertex_only", BasicType.FLOAT, Optional.empty(),
      Collections.singletonList(10.0));
  pipelineInfo.addUniform("used_in_fragment_only", BasicType.FLOAT, Optional.empty(),
      Collections.singletonList(20.0));
  final ShaderJob shaderJob = new GlslShaderJob(Optional.empty(),
      pipelineInfo, ParseHelper.parse(minimalVertexShader, ShaderKind.VERTEX),
      ParseHelper.parse(minimalFragmentShader, ShaderKind.FRAGMENT));
  // Check that initially there are indeed two uniforms in the pipeline state.
  assertEquals(2, shaderJob.getPipelineInfo().getNumUniforms());
  // There should be no opportunities to remove a piece of unused pipeline state, since both
  // uniforms are referenced.
  List<RemoveRedundantUniformMetadataReductionOpportunity> ops =
      RemoveRedundantUniformMetadataReductionOpportunities
          .findOpportunities(shaderJob,
              new ReducerContext(false, ShadingLanguageVersion.ESSL_100, new RandomWrapper(0),
              new IdGenerator()));
  assertEquals(0, ops.size());
}