Skip to content

Commit

Permalink
[Android] Changes for unit tests
Browse files Browse the repository at this point in the history
Now we will have separate suite for java unit tests to run. In addition, tests will be run on x64 emulators like they started doing in the upstream.
  • Loading branch information
samartnik committed Sep 13, 2024
1 parent 86ff9ad commit 9b3a19a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
13 changes: 5 additions & 8 deletions build/commands/lib/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ const getTestsToRun = (config, suite) => {
if (suite === 'brave_unit_tests') {
if (config.targetOS !== 'android') {
testsToRun.push('brave_installer_unittests')
} else {
testsToRun.push('bin/run_brave_public_test_apk')
}
} else if (suite === 'brave_java_unit_tests') {
testsToRun = ['bin/run_brave_java_unit_tests']
}
return testsToRun
}
Expand Down Expand Up @@ -71,14 +71,11 @@ const buildTests = async (suite, buildConfig = config.defaultBuildConfig, option
let testSuites = [
'brave_unit_tests',
'brave_browser_tests',
'brave_java_unit_tests',
'brave_network_audit_tests',
]
if (testSuites.includes(suite)) {
config.buildTargets = ['brave/test:' + suite]
if (suite === 'brave_unit_tests' && config.targetOS === 'android') {
// We need to build the APK for the java tests as well.
config.buildTargets.push('brave/test:brave_public_test_apk')
}
} else {
config.buildTargets = [suite]
}
Expand Down Expand Up @@ -168,8 +165,8 @@ const runTests = (passthroughArgs, suite, buildConfig, options) => {
}
if (config.targetOS === 'android') {
assert(
config.targetArch === 'x86' || options.manual_android_test_device,
'Only x86 build can be run automatically. For other builds please run test device manually and specify manual_android_test_device flag.')
config.targetArch === 'x86' || config.targetArch === 'x64' || options.manual_android_test_device,
'Only x86 and x64 builds can be run automatically. For other builds please run test device manually and specify manual_android_test_device flag.')
}
if (config.targetOS === 'android' && !options.manual_android_test_device) {
// Specify emulator to run tests on
Expand Down
2 changes: 1 addition & 1 deletion build/commands/scripts/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ program
.option('--target_environment <target_environment>', 'target environment (device, catalyst, simulator)')
.option('--run_disabled_tests', 'run disabled tests')
.option('--manual_android_test_device', 'indicates that Android test device is run manually')
.option('--android_test_emulator_name <emulator_name', 'set name of the Android emulator for tests', 'android_30_google_atd_x86')
.option('--android_test_emulator_name <emulator_name', 'set name of the Android emulator for tests', 'android_33_google_apis_x64')
.option('--use_remoteexec [arg]', 'whether to use RBE for building', JSON.parse)
.option('--offline', 'use offline mode for RBE')
.arguments('[build_config]')
Expand Down
3 changes: 2 additions & 1 deletion test/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@ test("brave_unit_tests") {
"//chrome/android:chrome_apk_paks",
"//chrome/test/android:chrome_java_test_support_common",
"//components/gcm_driver/instance_id/android:instance_id_driver_test_support_java",
"//components/sync/android:explicit_passphrase_platform_client_stub_java",
]
if (enable_brave_vpn || enable_ai_chat) {
deps += [ "//brave/components/brave_mobile_subscription/renderer/android:unit_tests" ]
Expand Down Expand Up @@ -1234,7 +1235,7 @@ if (is_android) {
]
}

chrome_public_test_apk_tmpl("brave_public_test_apk") {
chrome_public_test_apk_tmpl("brave_java_unit_tests") {
apk_name = "BravePublicTest"
android_manifest = brave_public_test_apk_manifest
android_manifest_dep = ":brave_public_test_apk_manifest"
Expand Down

0 comments on commit 9b3a19a

Please sign in to comment.