New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[TIMOB-25231] Android: List encrypted assets #10031
Conversation
Notes:
|
@garymathews, I have one minor nitpick. I think the The rest of the code looks fine. 👍 |
I would assume we should have some way of being able to unit test this. It may require changes to the test suite code itself to handle adding assets to encrypt into the test project, but then we should be able to add a test to the Ti.Filesystem.File suite to ensure the listing contains the encrypted assets. |
For your info, our mocha test suite uses the This will currently fail to find "addon" JS files for Android builds... unless you do a LiveView build. Gary's fix resolves this issue. |
I wrote up a quick unit test for you. This should replace the it('#directoryListing()', function () {
var rootDir = Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory),
rootPath,
filesFound = {};
should(rootDir.exists()).be.true;
should(rootDir.getDirectoryListing).be.a.Function;
should(rootDir.getDirectoryListing()).be.an.Array;
// Traverse entire Resources directory tree looking for files/directories in "filesFound".
rootPath = rootDir.nativePath;
filesFound[rootPath + 'app.js'] = false;
filesFound[rootPath + 'ti.ui.webview.test.html'] = false;
filesFound[rootPath + 'fixtures/'] = false; // Subdirectory containing only JS files.
filesFound[rootPath + 'fixtures/empty-double.js'] = false;
filesFound[rootPath + 'txtFiles/'] = false; // Subdirectory containing only assets.
filesFound[rootPath + 'txtFiles/text.txt'] = false;
function searchFileTree(file) {
if (file) {
var fileList = file.getDirectoryListing();
if (fileList) {
for (var index = 0; index < fileList.length; index++) {
var nextFile = Ti.Filesystem.getFile(file.nativePath, fileList[index]);
if (nextFile) {
var absolutePath = nextFile.nativePath;
if (absolutePath in filesFound) {
filesFound[absolutePath] = true;
}
searchFileTree(nextFile);
}
}
}
}
}
searchFileTree(rootDir);
for (var key in filesFound) {
Ti.API.info('Checking if found file: ' + key);
should(filesFound[key]).be.true;
}
}); Note that we need to double check the trailing slash |
Hmm... we must be doing a Edit: We're not doing a |
Android emulator builds do not encrypt JS assets, so writing a mocha test won't be testing the changes I made to include encrypted JS assets in the listing. |
Generated by 🚫 dangerJS |
FR Passed. The encrypted files are listed as expected on a device & emulator. Studio Ver: 5.1.0.201804230827 |
@jquick-axway , Is CR done for this PR? |
The only discrepancy we have left is with the Although, perhaps this is not a major issue. If you do the below, then all platforms will properly append the file to the directory path and inject a slash if needed. var file = Ti.Filesystem.getFile(directory.nativePath, 'MyFile.txt'); |
d4a5900
to
5c44d77
Compare
FR Passed. All the encrypted assets are listed as expected for device builds.
Studio Ver: 5.1.0.201804230827 |
getDirectoryListing()
TEST CASE BY @jquick-axway
JIRA Ticket