Skip to content

Commit

Permalink
[Android] Reland: Convert ContentShellTest.apk to isolate.
Browse files Browse the repository at this point in the history
This is a reland of https://codereview.chromium.org/878163004/.

https://codereview.chromium.org/902053006/ passes isolate files to the test
runner for bots that have not been converted to recipes.

BUG=400499
TBR=maruel@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#315843}
  • Loading branch information
jbudorick authored and Commit bot committed Feb 11, 2015
1 parent 5f96ac2 commit ca44323
Show file tree
Hide file tree
Showing 20 changed files with 54 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,41 @@ public class UrlUtils {

/**
* Construct the full path of a test data file.
* @param path Pathname relative to external/chrome/testing/data
* @param path Pathname relative to external/chrome/test/data
*/
public static String getTestFilePath(String path) {
// TODO(jbudorick): Remove DATA_DIR once everything has been isolated. crbug/400499
return PathUtils.getExternalStorageDirectory() + DATA_DIR + path;
}

// TODO(jbudorick): Remove this function once everything has been isolated and switched back
// to getTestFilePath. crbug/400499
/**
* Construct the full path of a test data file.
* @param path Pathname relative to external/
*/
public static String getIsolatedTestFilePath(String path) {
return PathUtils.getExternalStorageDirectory() + "/" + path;
}

/**
* Construct a suitable URL for loading a test data file.
* @param path Pathname relative to external/chrome/testing/data
* @param path Pathname relative to external/chrome/test/data
*/
public static String getTestFileUrl(String path) {
return "file://" + getTestFilePath(path);
}

// TODO(jbudorick): Remove this function once everything has been isolated and switched back
// to getTestFileUrl. crbug/400499
/**
* Construct a suitable URL for loading a test data file.
* @param path Pathname relative to external/
*/
public static String getIsolatedTestFileUrl(String path) {
return "file://" + getIsolatedTestFilePath(path);
}

/**
* Construct a data:text/html URI for loading from an inline HTML.
* @param html An unencoded HTML
Expand All @@ -41,8 +62,7 @@ public static String encodeHtmlDataUri(String html) {
// ' '->'+' needs to be undone and replaced with ' '->'%20'
// to match the Data URI requirements.
String encoded =
"data:text/html;utf-8," +
java.net.URLEncoder.encode(html, "UTF-8");
"data:text/html;utf-8," + java.net.URLEncoder.encode(html, "UTF-8");
encoded = encoded.replace("+", "%20");
return encoded;
} catch (java.io.UnsupportedEncodingException e) {
Expand Down
8 changes: 4 additions & 4 deletions build/android/pylib/instrumentation/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,15 @@ def Setup(test_options, devices):
if test_options.test_data:
device_utils.DeviceUtils.parallel(devices).pMap(
_PushDataDeps, test_options)
else:

if test_options.isolate_file_path:
base_setup.GenerateDepsDirUsingIsolate(test_options.test_apk,
test_options.isolate_file_path,
ISOLATE_FILE_PATHS,
DEPS_EXCLUSION_LIST)
def push_data_deps_to_device_dir(device):
device_dir = os.path.join(device.GetExternalStoragePath(),
DEVICE_DATA_DIR)
base_setup.PushDataDeps(device, device_dir, test_options)
base_setup.PushDataDeps(device, device.GetExternalStoragePath(),
test_options)
device_utils.DeviceUtils.parallel(devices).pMap(
push_data_deps_to_device_dir)

Expand Down
2 changes: 1 addition & 1 deletion content/content_shell_test_apk.isolate
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
['OS=="android"', {
'variables': {
'files': [
'<(DEPTH)/content/test/data/android/device_files/',
'<(DEPTH)/content/test/data/android/',
'<(DEPTH)/net/data/ssl/certificates/crit-codeSigning-chain.pem',
'<(DEPTH)/net/data/ssl/certificates/eku-test-root.pem',
'<(DEPTH)/net/data/ssl/certificates/invalid_key_usage_cert.der',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ private boolean isExpectedGeoIntent(String intentUrl, String expectedContent) {
@MediumTest
@Feature({"ContentDetection", "TabContents"})
public void testMultipleAddressesInText() throws Throwable {
startActivityWithTestUrl("content/content_detection/geo_address_multiple.html");
startActivityWithTestUrl(
"content/test/data/android/content_detection/geo_address_multiple.html");
assertWaitForPageScaleFactorMatch(1.0f);

assertTrue(isExpectedGeoIntent(scrollAndTapExpectingIntent("test1"),
Expand All @@ -37,7 +38,8 @@ public void testMultipleAddressesInText() throws Throwable {
@MediumTest
@Feature({"ContentDetection", "TabContents"})
public void testSplitAddresses() throws Throwable {
startActivityWithTestUrl("content/content_detection/geo_address_split.html");
startActivityWithTestUrl(
"content/test/data/android/content_detection/geo_address_split.html");
assertWaitForPageScaleFactorMatch(1.0f);

assertTrue(isExpectedGeoIntent(scrollAndTapExpectingIntent("test1"),
Expand All @@ -56,7 +58,8 @@ public void testSplitAddresses() throws Throwable {
@MediumTest
@Feature({"ContentDetection", "TabContents"})
public void testAddressLimits() throws Throwable {
startActivityWithTestUrl("content/content_detection/geo_address_limits.html");
startActivityWithTestUrl(
"content/test/data/android/content_detection/geo_address_limits.html");
assertWaitForPageScaleFactorMatch(1.0f);

assertTrue(isExpectedGeoIntent(scrollAndTapExpectingIntent("test1"),
Expand All @@ -75,7 +78,8 @@ public void testAddressLimits() throws Throwable {
@MediumTest
@Feature({"ContentDetection", "TabContents"})
public void testRealAddresses() throws Throwable {
startActivityWithTestUrl("content/content_detection/geo_address_real.html");
startActivityWithTestUrl(
"content/test/data/android/content_detection/geo_address_real.html");
assertWaitForPageScaleFactorMatch(1.0f);

assertTrue(isExpectedGeoIntent(scrollAndTapExpectingIntent("test1"),
Expand All @@ -94,7 +98,8 @@ public void testRealAddresses() throws Throwable {
@MediumTest
@Feature({"ContentDetection", "TabContents"})
public void testSpecialChars() throws Throwable {
startActivityWithTestUrl("content/content_detection/geo_address_special_chars.html");
startActivityWithTestUrl(
"content/test/data/android/content_detection/geo_address_special_chars.html");
assertWaitForPageScaleFactorMatch(1.0f);

assertTrue(isExpectedGeoIntent(scrollAndTapExpectingIntent("test1"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,34 +16,37 @@ public class ClickListenerTest extends ContentDetectionTestBase {
@MediumTest
@Feature({"ContentDetection", "TabContents"})
public void testClickContentOnLink() throws Throwable {
startActivityWithTestUrl("content/content_detection/click_listeners.html");
startActivityWithTestUrl(
"content/test/data/android/content_detection/click_listeners.html");
assertWaitForPageScaleFactorMatch(1.0f);

// Clicks on addresses in links should change the url.
scrollAndTapNavigatingOut("linktest");
assertTrue(isCurrentTestUrl("content/content_detection/empty.html"));
assertTrue(isCurrentTestUrl("content/test/data/android/content_detection/empty.html"));
}

@MediumTest
@Feature({"ContentDetection", "TabContents"})
public void testClickContentOnJSListener1() throws Throwable {
startActivityWithTestUrl("content/content_detection/click_listeners.html");
startActivityWithTestUrl(
"content/test/data/android/content_detection/click_listeners.html");
assertWaitForPageScaleFactorMatch(1.0f);

// Clicks on addresses in elements listening to click events should be
// processed normally without address detection.
scrollAndTapNavigatingOut("clicktest1");
assertTrue(isCurrentTestUrl("content/content_detection/empty.html"));
assertTrue(isCurrentTestUrl("content/test/data/android/content_detection/empty.html"));
}

@MediumTest
@Feature({"ContentDetection", "TabContents"})
public void testClickContentOnJSListener2() throws Throwable {
startActivityWithTestUrl("content/content_detection/click_listeners.html");
startActivityWithTestUrl(
"content/test/data/android/content_detection/click_listeners.html");
assertWaitForPageScaleFactorMatch(1.0f);

// Same as previous test, but using addEventListener instead of onclick.
scrollAndTapNavigatingOut("clicktest2");
assertTrue(isCurrentTestUrl("content/content_detection/empty.html"));
assertTrue(isCurrentTestUrl("content/test/data/android/content_detection/empty.html"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ protected String urlForContent(String content) {
* @return true if the test url is the current one, false otherwise.
*/
protected boolean isCurrentTestUrl(String testUrl) {
return UrlUtils.getTestFileUrl(testUrl).equals(getContentViewCore()
return UrlUtils.getIsolatedTestFileUrl(testUrl).equals(getContentViewCore()
.getWebContents().getUrl());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ protected void setUp() throws Exception {
LocationProviderFactory.setLocationProviderImpl(mMockLocationProvider);

try {
startActivityWithTestUrl("content/geolocation.html");
startActivityWithTestUrl("content/test/data/android/geolocation.html");
} catch (Throwable t) {
fail();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ private boolean isExpectedEmailIntent(String intentUrl, String expectedContent)
@MediumTest
@Feature({"ContentDetection", "TabContents"})
public void testValidEmailAddresses() throws Throwable {
startActivityWithTestUrl("content/content_detection/email.html");
startActivityWithTestUrl("content/test/data/android/content_detection/email.html");
assertWaitForPageScaleFactorMatch(1.0f);

// valid_1: i.want.a.pony@chromium.org.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,11 @@ protected ContentShellActivity launchContentShellWithUrl(String url) {
* @param url Test url to load.
*/
protected void startActivityWithTestUrl(String url) throws Throwable {
launchContentShellWithUrl(UrlUtils.getTestFileUrl(url));
launchContentShellWithUrl(UrlUtils.getIsolatedTestFileUrl(url));
assertNotNull(getActivity());
assertTrue(waitForActiveShellToBeDoneLoading());
assertEquals(UrlUtils.getTestFileUrl(url), getContentViewCore().getWebContents().getUrl());
assertEquals(UrlUtils.getIsolatedTestFileUrl(url),
getContentViewCore().getWebContents().getUrl());
}

/**
Expand Down
File renamed without changes.

0 comments on commit ca44323

Please sign in to comment.