Commit 24b4b89d authored by mef's avatar mef Committed by Commit bot

Use proguard.cfg in release build of Cronet Sample apk.

Update proguard.cfg to reflect that @UsedByReflection was moved to base/.
Add --release option to cr_cronet.py tool.

Notes:
- Chromium debug build does not apply proguard at all.
- Chromium instrumentation test does not allow custom proguard config (but it uses proguard config from instrumented app, which is nice).

BUG=390267

Review URL: https://codereview.chromium.org/512953002

Cr-Commit-Position: refs/heads/master@{#294671}
parent 4788e092
...@@ -350,12 +350,18 @@ ...@@ -350,12 +350,18 @@
'type': 'none', 'type': 'none',
'dependencies': [ 'dependencies': [
'cronet', 'cronet',
'cronet_stub',
], ],
'variables': { 'variables': {
'apk_name': 'CronetSample', 'apk_name': 'CronetSample',
'java_in_dir': 'cronet/android/sample', 'java_in_dir': 'cronet/android/sample',
'resource_dir': 'cronet/android/sample/res', 'resource_dir': 'cronet/android/sample/res',
'native_lib_target': 'libcronet', 'native_lib_target': 'libcronet',
'proguard_enabled': 'true',
'proguard_flags_paths': [
'cronet/android/proguard.cfg',
'cronet/android/sample/javatests/proguard.cfg',
],
}, },
'includes': [ '../build/java_apk.gypi' ], 'includes': [ '../build/java_apk.gypi' ],
}, },
...@@ -376,13 +382,11 @@ ...@@ -376,13 +382,11 @@
'target_name': 'cronet_sample_test_apk', 'target_name': 'cronet_sample_test_apk',
'type': 'none', 'type': 'none',
'dependencies': [ 'dependencies': [
'cronet',
'cronet_sample_apk_java', 'cronet_sample_apk_java',
'cronet_stub',
'../base/base.gyp:base_java', '../base/base.gyp:base_java',
'../base/base.gyp:base_javatests',
'../base/base.gyp:base_java_test_support', '../base/base.gyp:base_java_test_support',
# TODO(mef): Figure out why some tests are failing.
#'../net/net.gyp:net_javatests',
#'../net/net.gyp:net_java_test_support',
], ],
'variables': { 'variables': {
'apk_name': 'CronetSampleTest', 'apk_name': 'CronetSampleTest',
......
...@@ -18,10 +18,10 @@ ...@@ -18,10 +18,10 @@
-keepattributes *Annotation* -keepattributes *Annotation*
# Keep methods used by reflection and native code # Keep methods used by reflection and native code
-keep class org.chromium.net.UsedBy* -keep class org.chromium.base.UsedBy*
-keep @org.chromium.net.UsedBy* class * -keep @org.chromium.base.UsedBy* class *
-keepclassmembers class * { -keepclassmembers class * {
@org.chromium.net.UsedBy* *; @org.chromium.base.UsedBy* *;
} }
# Suppress unnecessary warnings. # Suppress unnecessary warnings.
......
# Proguard settings for CronetSampleTestApk.
-keep class org.chromium.cronet_sample_apk.CronetSampleActivity {
*;
}
...@@ -8,18 +8,19 @@ import android.content.ComponentName; ...@@ -8,18 +8,19 @@ import android.content.ComponentName;
import android.content.Intent; import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.test.ActivityInstrumentationTestCase2; import android.test.ActivityInstrumentationTestCase2;
import android.test.suitebuilder.annotation.SmallTest;
import android.text.TextUtils; import android.text.TextUtils;
import static org.chromium.base.test.util.ScalableTimeout.scaleTimeout; import static org.chromium.base.test.util.ScalableTimeout.scaleTimeout;
import org.chromium.base.test.util.UrlUtils; import org.chromium.base.test.util.Feature;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
/** /**
* Base test class for all CronetSample based tests. * Base test class for all CronetSample based tests.
*/ */
public class CronetSampleTestBase extends public class CronetSampleTest extends
ActivityInstrumentationTestCase2<CronetSampleActivity> { ActivityInstrumentationTestCase2<CronetSampleActivity> {
/** /**
...@@ -31,10 +32,25 @@ public class CronetSampleTestBase extends ...@@ -31,10 +32,25 @@ public class CronetSampleTestBase extends
protected static final long protected static final long
WAIT_PAGE_LOADING_TIMEOUT_SECONDS = scaleTimeout(15); WAIT_PAGE_LOADING_TIMEOUT_SECONDS = scaleTimeout(15);
public CronetSampleTestBase() { // URL used for base tests.
private static final String URL = "http://127.0.0.1:8000";
public CronetSampleTest() {
super(CronetSampleActivity.class); super(CronetSampleActivity.class);
} }
@SmallTest
@Feature({"Cronet"})
public void testLoadUrl() throws Exception {
CronetSampleActivity activity = launchCronetSampleWithUrl(URL);
// Make sure the activity was created as expected.
assertNotNull(activity);
// Make sure that the URL is set as expected.
assertEquals(URL, activity.getUrl());
assertEquals(200, activity.getHttpStatusCode());
}
/** /**
* Starts the CronetSample activity and loads the given URL. The URL can be * Starts the CronetSample activity and loads the given URL. The URL can be
* null, in which case will default to * null, in which case will default to
...@@ -67,39 +83,6 @@ public class CronetSampleTestBase extends ...@@ -67,39 +83,6 @@ public class CronetSampleTestBase extends
return getActivity(); return getActivity();
} }
// TODO(cjhopman): These functions are inconsistent with
// launchCronetSample***. Should be startCronetSample*** and should use the
// url exactly without the getTestFileUrl call. Possibly these two ways of
// starting the activity (launch* and start*) should be merged into one.
/**
* Starts the content shell activity with the provided test url. The url is
* synchronously loaded.
*
* @param url Test url to load.
*/
protected void startActivityWithTestUrl(String url) throws Throwable {
launchCronetSampleWithUrl(UrlUtils.getTestFileUrl(url));
assertNotNull(getActivity());
assertTrue(waitForActiveShellToBeDoneLoading());
assertEquals(UrlUtils.getTestFileUrl(url), getActivity().getUrl());
}
/**
* Starts the content shell activity with the provided test url and optional
* command line arguments to append. The url is synchronously loaded.
*
* @param url Test url to load.
* @param commandLineArgs Optional command line args to append when
* launching the activity.
*/
protected void startActivityWithTestUrlAndCommandLineArgs(String url,
String[] commandLineArgs) throws Throwable {
launchCronetSampleWithUrlAndCommandLineArgs(
UrlUtils.getTestFileUrl(url), commandLineArgs);
assertNotNull(getActivity());
assertTrue(waitForActiveShellToBeDoneLoading());
}
/** /**
* Waits for the Active shell to finish loading. This times out after * Waits for the Active shell to finish loading. This times out after
* WAIT_FOR_ACTIVE_SHELL_LOADING_TIMEOUT milliseconds and it shouldn't be * WAIT_FOR_ACTIVE_SHELL_LOADING_TIMEOUT milliseconds and it shouldn't be
......
...@@ -18,31 +18,41 @@ def run(command): ...@@ -18,31 +18,41 @@ def run(command):
def main(): def main():
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument('command', parser.add_argument('command',
choices=['init', choices=['gyp',
'sync', 'sync',
'build', 'build',
'install', 'install',
'proguard',
'test', 'test',
'debug']) 'debug'])
parser.add_argument('-r', '--release', action='store_true',
help='use release configuration')
options = parser.parse_args() options = parser.parse_args()
print options print options
print options.command
gyp_defines = 'GYP_DEFINES="OS=android enable_websockets=0 '+ \ gyp_defines = 'GYP_DEFINES="OS=android enable_websockets=0 '+ \
'disable_file_support=1 disable_ftp_support=1 '+ \ 'disable_file_support=1 disable_ftp_support=1 '+ \
'use_icu_alternatives_on_android=1" ' 'use_icu_alternatives_on_android=1" '
out_dir = 'out/Debug'
release_arg = ''
if options.release:
out_dir = 'out/Release'
release_arg = ' --release'
if (options.command=='init'): if (options.command=='gyp'):
return run (gyp_defines + ' gclient runhooks') return run (gyp_defines + ' gclient runhooks')
if (options.command=='sync'): if (options.command=='sync'):
return run ('git pull --rebase && ' + gyp_defines + ' gclient sync') return run ('git pull --rebase && ' + gyp_defines + ' gclient sync')
if (options.command=='build'): if (options.command=='build'):
return run ('ninja -C out/Debug cronet_sample_test_apk') return run ('ninja -C ' + out_dir + ' cronet_sample_test_apk')
if (options.command=='install'): if (options.command=='install'):
return run ('build/android/adb_install_apk.py --apk=CronetSample.apk') return run ('build/android/adb_install_apk.py ' + release_arg + \
' --apk=CronetSample.apk')
if (options.command=='proguard'):
return run ('ninja -C out/Release cronet_sample_proguard_apk')
if (options.command=='test'): if (options.command=='test'):
return run ('build/android/test_runner.py instrumentation '+ \ return run ('build/android/test_runner.py instrumentation '+ \
'--test-apk=CronetSampleTest') release_arg + ' --test-apk=CronetSampleTest')
parser.print_help() parser.print_help()
return 1 return 1
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment