• Aiden Benner's avatar
    JNI: Add flags to enable/disable/require mocks in GEN_JNI · d0d0a00b
    Aiden Benner authored
    Adds the REQUIRE_MOCKS flag to GEN_JNI. If both the REQUIRE_MOCKS and
    TESTING_ENABLED flags are set, calls to native implementations must
    have had a mock instance set first through TEST_HOOKS,
    otherwise an UnsupportedOperationException will be thrown.
    
    If only TESTING_ENABLED is set, calls to the native implementation
    will use a test mock if it is provided, and otherwise fallback to the
    native implementation. This is used for instrumentation tests that
    may want to mock out some native implementations but not all.
    
    In the annotation processor version of GEN_JNI both these flags are
    mutable and so they can be set by a JNI test rule for unit tests.
    
    Instrumentation tests that want to mock a native implementation
    can pass flags to JNI registration generator to set the corresponding
    GEN_JNI flags.
    
    Bug: 898261
    Change-Id: I6a90e91a29368df692d458f35c9ea92f8898064b
    Reviewed-on: https://chromium-review.googlesource.com/c/1344554
    Commit-Queue: Aiden Benner <abenner@google.com>
    Reviewed-by: default avatarEric Stevenson <estevenson@chromium.org>
    Reviewed-by: default avataragrieve <agrieve@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#610263}
    d0d0a00b
HashedSampleForAnnotationProcessorGenJni.golden 2.89 KB