-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Upgrade to Robolectric 4 #1941
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
Upgrade to Robolectric 4 #1941
Conversation
- Update gradle plugin to 3.6.4, the minimal version without updating to SDK 29. This is necessary for fixing some classloader issues with BouncyCastle when running tests - Update to Robolectric 4.3; also added AndroidX test packages as required - As first step to Robolectric adaptation, removed no longer valid `constants = BuildConfig.class` in tests
- decoupled some library versions to variables - add support for tests against API 28. API 29 requires Java 9, so it's disabled (although stub had been added) - change test runner to AndroidJUnit4 per docs recommended - RuntimeEnvironment.application -> ApplicationProvider.getApplicationContext() (where applicable - GenericCopyUtilTest relies on Theories to run test, can still use old method)
30963f2 to
1b43654
Compare
- moved jcifs.Config.registerSmbURLHandler() from SmbConnectDialog to AppConfig.runInBackground() - encrypt paths in UtilsHandler.renameSMB() as it was stored encrypted in database Tested on Oneplus 2 running AOSPExtended (7.1.2) and LG Nexus 5x running AOSPExtended (9.0).
be93d46 to
3132aa4
Compare
- ColorUtils: Add back missing break statement to prevent unknown icons being colored to default color - NotificationConstants: Fix constant to use per reported by Android Studio - Return of MainActivity test - Remove deprecated API usage in TextEditorActivityTest - Add test cases for CloudSheetFragment, NotificationConstants, SmbUtil, TinyDB, along with some more little util classes
3132aa4 to
97db16f
Compare
- Added test cases for DbViewerTask, WriteFileAbstraction and EditableFileAbstraction - EditableFileAbstraction, schema changed from integer to enum constant
|
Sidenote: if you got In short, add |
|
I am getting this when running the tests: Exception in thread "main" java.lang.NoClassDefFoundError: com/afollestad/materialdialogs/folderselector/FolderChooserDialog$FolderCallback
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:757)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
at java.lang.ClassLoader.loadClass(ClassLoader.java:419)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
at java.lang.ClassLoader.loadClass(ClassLoader.java:352)
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
at java.lang.Class.getMethod0(Class.java:3018)
at java.lang.Class.getMethod(Class.java:1784)
at org.junit.internal.builders.SuiteMethodBuilder.hasSuiteMethod(SuiteMethodBuilder.java:18)
at com.intellij.junit4.JUnit46ClassesRequestBuilder.collectWrappedRunners(JUnit46ClassesRequestBuilder.java:75)
at com.intellij.junit4.JUnit46ClassesRequestBuilder.getClassesRequest(JUnit46ClassesRequestBuilder.java:47)
at com.intellij.junit4.JUnit4TestRunnerUtil.buildRequest(JUnit4TestRunnerUtil.java:90)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:46)
at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:230)
at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:58)
Caused by: java.lang.ClassNotFoundException: com.afollestad.materialdialogs.folderselector.FolderChooserDialog$FolderCallback
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:419)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
at java.lang.ClassLoader.loadClass(ClassLoader.java:352)
... 25 more |
|
Try clean the gradle project first and run again. Otherwise may I know the environment (OS, JDK versions) you're running tests?
|
With the current logic, if there is a broken symlink the block will exit at all, causing incomplete file listings. Adding a try/catch here can keep the loop to stay.
|
Ok, today it works, no idea what happened. |
- moved jcifs.Config.registerSmbURLHandler() from SmbConnectDialog to AppConfig.runInBackground() - encrypt paths in UtilsHandler.renameSMB() as it was stored encrypted in database Tested on Oneplus 2 running AOSPExtended (7.1.2) and LG Nexus 5x running AOSPExtended (9.0).
f034741 to
0b6a61c
Compare
- Log broken symbolic link - Refactor ListFilesOnSshdTest for better codacy compliance. Also changed performVerify() to use awaitility's await() to better match the situation that file listings should not be broken because of broken symlinks
1946: Add translucent theme at amaze startup
With Robolectric 4's support for SDK >= 29 in place, they require the tests must run on JDK 9 or above. Therefore some adaptations must be done to allow this. - add back APIs removed in JDK 9 which are required by Android builds - all Robolectric test cases will have their maxSdk @config settings centralized in robolectric.properties Due to robolectric/robolectric#5456 and developer adaptation to JDK > 8 is still not yet in place, running the test suite within Android Studio is still not possible out-of-the-box, this commit will not enable running with SDK 29 yet; but once everyone's ready it will be just a switch at robolectric.properties above Tested building from command line with JDK 11 (Latest LTS version) and Android Studio, both on Ubuntu Focal x86_64. Reference: https://medium.com/@jack_martynov/adopt-android-build-on-the-jdk11-macos-cc8f05995341
In #1947 there was a `android:screenOrientation="sensor"` declared in the manifest, causing UI to rotate as the device changes its orientation, which is quite annoying. Remove it. Tested on Fairphone 3 running LineageOS 16.0 (9.0), still no white screen at startup even when Amaze uses dark themes.
Fix broken symlinks on SSH server causing incomplete file listings
…d text file creation method within FileUtil and check for intent type = text, basis which a text file will be created on the path the user is currently present.
…d text file creation method within FileUtil and check for intent type = text, basis which a text file will be created on the path the user is currently present.
Fix screen rotation problem after PR #1947 applied
|
This PR still WIP? |
Should have done the parts needed for this PR. Only need you to loosen the grip on codacy, that it cannot detect assertions inside callbacks. |
Fixes for editing SMB connections
|
Got it, will do (: |
Addresses #1961. Previously due to preventing conflict with stock BouncyCastle on Android devices some tweaks were added to CustomSshJConfig. But with full adaptation of BouncyCastle over the stock one it should be safe to remove the tweaks and use stock features as much as possible. Tested on Fairphone 3 running LineageOS 16.0 (9.0), using ED25519 private key to authenticate against OpenSSH server 8.2p1 on Ubuntu 20.04.
Lifting tweaks in CustomSshJConfig to enable advanced crypto features
- use HybridFileParcelable(SmbFile) for jcifs SmbFile in HybridFile.listFiles() and HybridFile.forEachChildrenFile() - use HybridFileParcelable(RemoteResourceInfo) for sshj RemoteResourceInfo in HybridFile.listFiles() and HybridFile.forEachChildrenFile() - Add javadoc for the 2 new HybridFileParcelable constructors - remove duplicated parseSmbPath() and parseSftpPath() from MainActivityHelper
In #1947 there was a `android:screenOrientation="sensor"` declared in the manifest, causing UI to rotate as the device changes its orientation, which is quite annoying. Remove it. Tested on Fairphone 3 running LineageOS 16.0 (9.0), still no white screen at startup even when Amaze uses dark themes.
- moved jcifs.Config.registerSmbURLHandler() from SmbConnectDialog to AppConfig.runInBackground() - encrypt paths in UtilsHandler.renameSMB() as it was stored encrypted in database Tested on Oneplus 2 running AOSPExtended (7.1.2) and LG Nexus 5x running AOSPExtended (9.0).
Addresses #1961. Previously due to preventing conflict with stock BouncyCastle on Android devices some tweaks were added to CustomSshJConfig. But with full adaptation of BouncyCastle over the stock one it should be safe to remove the tweaks and use stock features as much as possible. Tested on Fairphone 3 running LineageOS 16.0 (9.0), using ED25519 private key to authenticate against OpenSSH server 8.2p1 on Ubuntu 20.04.
…d text file creation method within FileUtil and check for intent type = text, basis which a text file will be created on the path the user is currently present.
…d text file creation method within FileUtil and check for intent type = text, basis which a text file will be created on the path the user is currently present.
…d text file creation method within FileUtil and check for intent type = text, basis which a text file will be created on the path the user is currently present.
#1856 Fix for app crashing when using save as option from browser
Fix OTG not loading file lists on Android >= N + refactoring
- Update gradle plugin to 3.6.4, the minimal version without updating to SDK 29. This is necessary for fixing some classloader issues with BouncyCastle when running tests - Update to Robolectric 4.3; also added AndroidX test packages as required - As first step to Robolectric adaptation, removed no longer valid `constants = BuildConfig.class` in tests
- decoupled some library versions to variables - add support for tests against API 28. API 29 requires Java 9, so it's disabled (although stub had been added) - change test runner to AndroidJUnit4 per docs recommended - RuntimeEnvironment.application -> ApplicationProvider.getApplicationContext() (where applicable - GenericCopyUtilTest relies on Theories to run test, can still use old method)
- ColorUtils: Add back missing break statement to prevent unknown icons being colored to default color - NotificationConstants: Fix constant to use per reported by Android Studio - Return of MainActivity test - Remove deprecated API usage in TextEditorActivityTest - Add test cases for CloudSheetFragment, NotificationConstants, SmbUtil, TinyDB, along with some more little util classes
- Added test cases for DbViewerTask, WriteFileAbstraction and EditableFileAbstraction - EditableFileAbstraction, schema changed from integer to enum constant
With Robolectric 4's support for SDK >= 29 in place, they require the tests must run on JDK 9 or above. Therefore some adaptations must be done to allow this. - add back APIs removed in JDK 9 which are required by Android builds - all Robolectric test cases will have their maxSdk @config settings centralized in robolectric.properties Due to robolectric/robolectric#5456 and developer adaptation to JDK > 8 is still not yet in place, running the test suite within Android Studio is still not possible out-of-the-box, this commit will not enable running with SDK 29 yet; but once everyone's ready it will be just a switch at robolectric.properties above Tested building from command line with JDK 11 (Latest LTS version) and Android Studio, both on Ubuntu Focal x86_64. Reference: https://medium.com/@jack_martynov/adopt-android-build-on-the-jdk11-macos-cc8f05995341
…ileManager into TranceLove/feature/1918
PR Info
Issue tracker
Fixes will automatically close the related issue
Fixes #1918
-or-
Addresses #
Release
Addresses release/3.5 or release/3.6
Test cases
Manual testing
If yes,
Build tasks success
Successfully running following tasks on local
./gradlew assembledebug./gradlew spotlessCheckRelated PR
Related to PR #
Additional Info
Summary on changes: