Skip to content

Commit

Permalink
Add support for using mockito in instrumentation tests.
Browse files Browse the repository at this point in the history
Bug: 638318
Change-Id: I1c3b1fbf83d70faa7c11f41de547e4ae82fbb211
Reviewed-on: https://chromium-review.googlesource.com/1103589
Commit-Queue: John Budorick <jbudorick@chromium.org>
Reviewed-by: agrieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#569464}
  • Loading branch information
jbudorick authored and Commit Bot committed Jun 22, 2018
1 parent dea1981 commit 6c26c23
Show file tree
Hide file tree
Showing 12 changed files with 488 additions and 302 deletions.
6 changes: 3 additions & 3 deletions DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ deps = {
},

'src/third_party/android_tools': {
'url': Var('chromium_git') + '/android_tools.git' + '@' + 'c22a664c39af72dd8f89200220713dcad811300a',
'url': Var('chromium_git') + '/android_tools.git' + '@' + '3545ab5b9883087a54cb9e5337c32617cb2a443d',
'condition': 'checkout_android_native_support',
},

Expand Down Expand Up @@ -503,7 +503,7 @@ deps = {
'packages': [
{
'package': 'chromium/third_party/byte_buddy',
'version': 'version:1.4.17-cr0',
'version': 'version:1.8.8-cr0',
},
],
'condition': 'checkout_android',
Expand Down Expand Up @@ -833,7 +833,7 @@ deps = {
},

'src/third_party/mockito/src': {
'url': Var('chromium_git') + '/external/mockito/mockito.git' + '@' + 'de83ad4598ad4cf5ea53c69a8a8053780b04b850',
'url': Var('chromium_git') + '/external/mockito/mockito.git' + '@' + '04a2a289a4222f80ad20717c25144981210d2eac',
'condition': 'checkout_android',
},

Expand Down
2 changes: 1 addition & 1 deletion build/android/gyp/javac.py
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ def main(argv):
options.processorpath)
# GN already knows of java_files, so listing them just make things worse when
# they change.
depfile_deps = [javac_path] + classpath_inputs + options.java_srcjars
depfile_deps = ([javac_path] + classpath_inputs + options.java_srcjars)
input_paths = depfile_deps + java_files

output_paths = [
Expand Down
10 changes: 7 additions & 3 deletions build/config/android/internal_rules.gni
Original file line number Diff line number Diff line change
Expand Up @@ -2961,9 +2961,13 @@ if (enable_java_templates) {
}
if (defined(invoker.include_java_resources) &&
invoker.include_java_resources) {
# Use original jar_path because _jar_path points to a library without
# resources.
java_resources_jar = invoker.jar_path
if (defined(invoker.jar_path)) {
# Use original jar_path because _jar_path points to a library without
# resources.
java_resources_jar = invoker.jar_path
} else {
java_resources_jar = _final_jar_path
}
}
}
_accumulated_public_deps += [ ":$_build_config_target_name" ]
Expand Down
10 changes: 10 additions & 0 deletions build/secondary/third_party/android_tools/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -286,4 +286,14 @@ if (enable_java_templates) {
proguard_configs =
[ "${target_gen_dir}/google_play_services_basement_java/proguard.txt" ]
}

# The current version of //third_party/byte_buddy relies on an older
# version of dx.
java_prebuilt("dx_25_0_2_java") {
supports_android = true
requires_android = true
no_build_hooks = true
testonly = true
jar_path = "//third_party/android_tools/sdk/build-tools/25.0.2/lib/dx.jar"
}
}
16 changes: 16 additions & 0 deletions third_party/byte_buddy/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,22 @@
import("//build/config/android/rules.gni")

java_prebuilt("byte_buddy_java") {
supports_android = true
testonly = true
jar_path = "lib/byte-buddy.jar"
}

java_prebuilt("byte_buddy_agent_java") {
supports_android = true
testonly = true
jar_path = "lib/byte-buddy-agent.jar"
}

android_java_prebuilt("byte_buddy_android_java") {
testonly = true
deps = [
"//third_party/android_tools:dx_25_0_2_java",
]
proguard_configs = [ "//third_party/byte_buddy/proguard.flags" ]
jar_path = "lib/byte-buddy-android.jar"
}
4 changes: 2 additions & 2 deletions third_party/byte_buddy/README.chromium
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Name: Byte Buddy
URL: http://bytebuddy.net/
Version: 1.4.17
Version: 1.8.8
License: Apache 2.0
License File: NOT_SHIPPED
Security Critical: no
Description:
Byte Buddy is a code generation library for creating Java classes at runtime.

Local Modifications: None
Local Modifications: None
2 changes: 2 additions & 0 deletions third_party/byte_buddy/cipd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@
package: chromium/third_party/byte_buddy
description: byte_buddy Java library
data:
- file: lib/byte-buddy-agent.jar
- file: lib/byte-buddy-android.jar
- file: lib/byte-buddy.jar
9 changes: 9 additions & 0 deletions third_party/byte_buddy/proguard.flags
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright 2018 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.

-dontwarn net.bytebuddy.**

-keep class net.bytebuddy.** {
*;
}
717 changes: 425 additions & 292 deletions third_party/mockito/BUILD.gn

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion third_party/mockito/README.chromium
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Name: Mockito
URL: https://github.com/mockito/mockito
Version: v2.0.99-beta
Version: v2.18.3
License: MIT
License File: NOT_SHIPPED
Security Critical: no
Expand Down
11 changes: 11 additions & 0 deletions third_party/mockito/proguard.flags
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Copyright 2018 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.

-dontwarn org.mockito.**

# Mockito loads some things by reflection. Prevent proguard from
# obfuscating or removing anything to ensure that doesn't break.
-keep class org.mockito.** {
*;
}
1 change: 1 addition & 0 deletions third_party/objenesis/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import("//build/config/android/rules.gni")

java_prebuilt("objenesis_java") {
supports_android = true
testonly = true
jar_path = "lib/objenesis.jar"
}

0 comments on commit 6c26c23

Please sign in to comment.