[QA] Add content provider to handle settings in QA variant#4776
[QA] Add content provider to handle settings in QA variant#4776
Conversation
9144fc1 to
40c93c5
Compare
| android:exported="true" /> | ||
| </application> | ||
|
|
||
| </manifest> No newline at end of file |
There was a problem hiding this comment.
No newline at end of file
| ): Bundle { | ||
|
|
||
| val prefs = context!!.getSharedPreferences(prefsName, Context.MODE_PRIVATE) | ||
| if (method == "set_boolean") { |
There was a problem hiding this comment.
Would it be possible to create a variable for set_boolean (similar to prefsName)?
There was a problem hiding this comment.
yep, since the name of the method is static, i'll add it as a companion string, and same for the prefs_name. What do you think?
There was a problem hiding this comment.
Nice! 💯 Is prefsName also a static value? We could move both values to the companion object
| prefs.edit { | ||
| putBoolean(arg!!, extras!!.getBoolean("value")) | ||
| } | ||
| } |
There was a problem hiding this comment.
What would happen if context, arg or extras were null? Would it be possible to use a safe calls (?.) for these arguments? 🤔
There was a problem hiding this comment.
it shouldn't, or the call to the provider will fail. Anyway, let's do some control over its nullability
| override fun update( | ||
| uri: Uri, values: ContentValues?, | ||
| selection: String?, selectionArgs: Array<out String>? | ||
| ): Int = 0 |
There was a problem hiding this comment.
I would write this method on a single line for clarity (just my personal opinion) 🙌🏻
There was a problem hiding this comment.
sure, no problem 👍
f817712 to
2319fd5
Compare
Summary
Adds a
ContentProviderto the qa variant that allows to handle the shared preferences with testing purposes.The
ContentProvideroverrides thecallfunction that receives three parameters:method: name of the method that will execute the action. In this case, only one methodset_booleansince it's intended (for the moment) for boolean preferencesarg: the name of the preferenceextras: value of the preference (in this case,trueorfalse)How it works
adbcommand, the content provider is called with the proper argumentsF. ex:
to enable the
show_disabled_spacespreference:to disable the
show_hidden_filespreference:Security
In order to assure that this implementation is only available in the qa variant, the following checks have been performed:
1. Check that
Manifestis OKFirstly, a
Manifestfor every variant is generated:Then, inspect them:
Result: 81: android:name="com.owncloud.android.test.TestPreferencesProvider"
That means, the qa manifest contains the
TestPreferencesProviderclass.Let's check in the original:
That returns no results, so the original manifest does not contain the
TestPreferencesProviderclass2. Check if the compilings contain the TestPreferencesProvider class
Execute the following commands
./gradlew clean-> clean up directory./gradlew :owncloudApp:compileOriginalReleaseKotlin-> compile the originalRelease variantfind owncloudApp/build/tmp/kotlin-classes/originalRelease -iname '*TestPreferencesProvider*'-> tries to find theTestPreferencesProviderinside of it. It shouldn't find anything../gradlew clean-> clean up again./gradlew :owncloudApp:compileQaReleaseKotlin-> compile the qaRelease variantfind owncloudApp/build/tmp/kotlin-classes/qaRelease -iname '*TestPreferencesProvider*'-> it should returnowncloudApp/build/tmp/kotlin-classes/qaRelease/com/owncloud/android/test/TestPreferencesProvider.class3. Check the presence of TestPreferencesProvider in the artifacts
Build a signed apk with both
originalandqavariant, and execute over both of them:(set the right apk name in the command fot every case)
That command list the code files inside the apk. The
TestPreferencesProviderclass should be listed only in the apk that was built with the qa variant.Those checks show that the
originalXXXvariants will never include theTestPreferencesProviderand the qaManifest.(open to other ideas)
App:
ReleaseNotesViewModel.ktcreating a newReleaseNote()with String resources (if required)QA