예제 #1
0
  def testOutput(self):
    definition = EnumDefinition(original_enum_name='ClassName',
                                enum_package='some.package',
                                entries=[('E1', 1), ('E2', '2 << 2')],
                                comments=[('E2', 'This is a comment.'),
                                          ('E1', 'This is a multiple line '
                                                 'comment that is really long. '
                                                 'This is a multiple line '
                                                 'comment that is really '
                                                 'really long.')])
    output = GenerateOutput('path/to/file', definition)
    expected = """
// Copyright %d The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// This file is autogenerated by
//     %s
// From
//     path/to/file

package some.package;

import android.support.annotation.IntDef;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

public class ClassName {
  @IntDef({
      E1, E2
  })
  @Retention(RetentionPolicy.SOURCE)
  public @interface ClassNameEnum {}
  /**
   * %s
   * really really long.
   */
  public static final int E1 = 1;
  /**
   * This is a comment.
   */
  public static final int E2 = 2 << 2;
}
"""
    long_comment = ('This is a multiple line comment that is really long. '
                    'This is a multiple line comment that is')
    self.assertEqual(
            expected % (date.today().year, GetScriptName(), long_comment),
            output)
예제 #2
0
    def testOutput(self):
        definition = EnumDefinition(original_enum_name='ClassName',
                                    enum_package='some.package',
                                    entries=[('E1', 1), ('E2', '2 << 2')])
        output = GenerateOutput('path/to/file', definition)
        expected = """
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// This file is autogenerated by
//     %s
// From
//     path/to/file

package some.package;

public class ClassName {
  public static final int E1 = 1;
  public static final int E2 = 2 << 2;
}
"""
        self.assertEqual(expected % GetScriptName(), output)