original_docstring: Writes the service decorder unit tests.
docstring: Writes the service decorder unit tests.
docstring_tokens: Writes the service decorder unit tests .
code: def WriteServiceUnitTests(self, filename):
      """Writes the service decorder unit tests."""
      num_tests = len(self.functions)
      FUNCTIONS_PER_FILE = 98  # hard code this so it doesn't change.
      count = 0
      for test_num in range(0, num_tests, FUNCTIONS_PER_FILE):
        count += 1
        name = filename % count
        file = CHeaderWriter(
            name,
            "// It is included by gles2_cmd_decoder_unittest_%d.cc\n" % count)
        test_name = 'GLES2DecoderTest%d' % count
        end = test_num + FUNCTIONS_PER_FILE
        if end > num_tests:
          end = num_tests
        for idx in range(test_num, end):
          func = self.functions[idx]
  
          # Do any filtering of the functions here, so that the functions
          # will not move between the numbered files if filtering properties
          # are changed.
          if func.GetInfo('extension_flag'):
            continue
  
          if True:
          #gen_cmd = func.GetInfo('gen_cmd')
          #if gen_cmd == True or gen_cmd == None:
            if func.GetInfo('unit_test') == False:
              file.Write("// TODO(gman): %s\n" % func.name)
            else:
              func.WriteServiceUnitTest(file, {
                'test_name': test_name
              })
        file.Close()
        self.generated_cpp_filenames.append(file.filename)
      file = CHeaderWriter(
          filename % 0,
          "// It is included by gles2_cmd_decoder_unittest_base.cc\n")
      file.Write(
  """void GLES2DecoderTestBase::SetupInitCapabilitiesExpectations() {
  """)
      for capability in _CAPABILITY_FLAGS:
        file.Write("  ExpectEnableDisable(GL_%s, %s);\n" %
                   (capability['name'].upper(),
                    ('false', 'true')['default' in capability]))
      file.Write("""}
  
  void GLES2DecoderTestBase::SetupInitStateExpectations() {
  """)
  
      # We need to sort the keys so the expectations match
      for state_name in sorted(_STATES.keys()):
        state = _STATES[state_name]
        if state['type'] == 'FrontBack':
          num_states = len(state['states'])
          for ndx, group in enumerate(Grouper(num_states / 2, state['states'])):
            args = []
            for item in group:
              if 'expected' in item:
                args.append(item['expected'])
              else:
                args.append(item['default'])
            file.Write(
                "  EXPECT_CALL(*gl_, %s(%s, %s))\n" %
                (state['func'], ('GL_FRONT', 'GL_BACK')[ndx], ", ".join(args)))
            file.Write("      .Times(1)\n")
            file.Write("      .RetiresOnSaturation();\n")
        elif state['type'] == 'NamedParameter':
          for item in state['states']:
            if 'extension_flag' in item:
              file.Write("  if (group_->feature_info()->feature_flags().%s) {\n" %
                         item['extension_flag'])
              file.Write("  ")
            expect_value = item['default']
            if isinstance(expect_value, list):
              # TODO: Currently we do not check array values.
              expect_value = "_"
  
            file.Write(
                "  EXPECT_CALL(*gl_, %s(%s, %s))\n" %
                (state['func'],
                 (item['enum_set']
                             if 'enum_set' in item else item['enum']),
                 expect_value))
            file.Write("      .Times(1)\n")
            file.Write("      .RetiresOnSaturation();\n")
            if 'extension_flag' in item:
              file.Write("  }\n")
        else:
          if 'extension_flag' in state:
            file.Write("  if (group_->feature_info()->feature_flags().%s) {\n" %
                       state['extension_flag'])
            file.Write("  ")
          args = []
          for item in state['states']:
            if 'expected' in item:
              args.append(item['expected'])
            else:
              args.append(item['default'])
          # TODO: Currently we do not check array values.
          args = ["_" if isinstance(arg, list) else arg for arg in args]
          file.Write("  EXPECT_CALL(*gl_, %s(%s))\n" %
                     (state['func'], ", ".join(args)))
          file.Write("      .Times(1)\n")
          file.Write("      .RetiresOnSaturation();\n")
          if 'extension_flag' in state:
            file.Write("  }\n")
      file.Write("""}
  """)
      file.Close()
      self.generated_cpp_filenames.append(file.filename)
code_tokens: def WriteServiceUnitTests ( self , filename ) : num_tests = len ( self . functions ) FUNCTIONS_PER_FILE = 98 count = 0 for test_num in range ( 0 , num_tests , FUNCTIONS_PER_FILE ) : count += 1 name = filename % count file = CHeaderWriter ( name , "// It is included by gles2_cmd_decoder_unittest_%d.cc\n" % count ) test_name = 'GLES2DecoderTest%d' % count end = test_num + FUNCTIONS_PER_FILE if end > num_tests : end = num_tests for idx in range ( test_num , end ) : func = self . functions [ idx ] if func . GetInfo ( 'extension_flag' ) : continue if True : if func . GetInfo ( 'unit_test' ) == False : file . Write ( "// TODO(gman): %s\n" % func . name ) else : func . WriteServiceUnitTest ( file , { 'test_name' : test_name } ) file . Close ( ) self . generated_cpp_filenames . append ( file . filename ) file = CHeaderWriter ( filename % 0 , "// It is included by gles2_cmd_decoder_unittest_base.cc\n" ) file . Write ( """void GLES2DecoderTestBase::SetupInitCapabilitiesExpectations() {
  """ ) for capability in _CAPABILITY_FLAGS : file . Write ( "  ExpectEnableDisable(GL_%s, %s);\n" % ( capability [ 'name' ] . upper ( ) , ( 'false' , 'true' ) [ 'default' in capability ] ) ) file . Write ( """}
  
  void GLES2DecoderTestBase::SetupInitStateExpectations() {
  """ ) for state_name in sorted ( _STATES . keys ( ) ) : state = _STATES [ state_name ] if state [ 'type' ] == 'FrontBack' : num_states = len ( state [ 'states' ] ) for ndx , group in enumerate ( Grouper ( num_states / 2 , state [ 'states' ] ) ) : args = [ ] for item in group : if 'expected' in item : args . append ( item [ 'expected' ] ) else : args . append ( item [ 'default' ] ) file . Write ( "  EXPECT_CALL(*gl_, %s(%s, %s))\n" % ( state [ 'func' ] , ( 'GL_FRONT' , 'GL_BACK' ) [ ndx ] , ", " . join ( args ) ) ) file . Write ( "      .Times(1)\n" ) file . Write ( "      .RetiresOnSaturation();\n" ) elif state [ 'type' ] == 'NamedParameter' : for item in state [ 'states' ] : if 'extension_flag' in item : file . Write ( "  if (group_->feature_info()->feature_flags().%s) {\n" % item [ 'extension_flag' ] ) file . Write ( "  " ) expect_value = item [ 'default' ] if isinstance ( expect_value , list ) : expect_value = "_" file . Write ( "  EXPECT_CALL(*gl_, %s(%s, %s))\n" % ( state [ 'func' ] , ( item [ 'enum_set' ] if 'enum_set' in item else item [ 'enum' ] ) , expect_value ) ) file . Write ( "      .Times(1)\n" ) file . Write ( "      .RetiresOnSaturation();\n" ) if 'extension_flag' in item : file . Write ( "  }\n" ) else : if 'extension_flag' in state : file . Write ( "  if (group_->feature_info()->feature_flags().%s) {\n" % state [ 'extension_flag' ] ) file . Write ( "  " ) args = [ ] for item in state [ 'states' ] : if 'expected' in item : args . append ( item [ 'expected' ] ) else : args . append ( item [ 'default' ] ) args = [ "_" if isinstance ( arg , list ) else arg for arg in args ] file . Write ( "  EXPECT_CALL(*gl_, %s(%s))\n" % ( state [ 'func' ] , ", " . join ( args ) ) ) file . Write ( "      .Times(1)\n" ) file . Write ( "      .RetiresOnSaturation();\n" ) if 'extension_flag' in state : file . Write ( "  }\n" ) file . Write ( """}
  """ ) file . Close ( ) self . generated_cpp_filenames . append ( file . filename )
short_docstring: Writes the service decorder unit tests.
short_docstring_tokens: Writes the service decorder unit tests .
comment: """Writes the service decorder unit tests."""$SEP$# hard code this so it doesn't change.$SEP$# Do any filtering of the functions here, so that the functions$SEP$# will not move between the numbered files if filtering properties$SEP$# are changed.$SEP$#gen_cmd = func.GetInfo('gen_cmd')$SEP$#if gen_cmd == True or gen_cmd == None:$SEP$# We need to sort the keys so the expectations match$SEP$# TODO: Currently we do not check array values.$SEP$# TODO: Currently we do not check array values.