RUN integration tests on API 35 in testing pyramid#2272
Conversation
0xnm
left a comment
There was a problem hiding this comment.
lgtm!
as a part of API 35 support, we also need to modify target SDK, build tools version, etc. in the Gradle config and Docker file as well.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #2272 +/- ##
========================================
Coverage 69.98% 69.98%
========================================
Files 731 731
Lines 27204 27212 +8
Branches 4574 4577 +3
========================================
+ Hits 19037 19043 +6
+ Misses 6896 6881 -15
- Partials 1271 1288 +17
|
d3892b5 to
e0c771b
Compare
| ) { | ||
| internal fun generateKey(bitmap: Bitmap) = | ||
| generateKey(bitmap.width, bitmap.height, bitmap.config) | ||
| generateKey(bitmap.width, bitmap.height, bitmap.safeConfig()) |
There was a problem hiding this comment.
So how it was working in the past? we now know, that annotation wasn't correct and Bitmap.getConfig may return null. It should crash runtime, because generateKey doesn't expect null value for the config parameter.
Also do we need safeConfig method? Maybe in some code paths we can handle null returned case without fallback value.
There was a problem hiding this comment.
yes...in case it will return null it will crash. I've never seen this bug reported yet so I suspect this happens quite rarely. I am not sure that this will require a hotfix. @xgouchet @jonathanmos ?
There was a problem hiding this comment.
the reason why I introduce the safeConfig is just to be re - used also in some tests where I had to replace it and maybe for later...looks cleaner this way.
There was a problem hiding this comment.
The getConfig method is annotated NonNull for some reason. I haven't seen any cases of this returning null, but if it can then we do indeed need a safe method.
There was a problem hiding this comment.
There was a problem hiding this comment.
The question was more if we can leave it like this until the next release where the safe method will be in place. You said you did not see any issue so far so I guess this is very rare when it returns null. We could leave it like this without a hotfix.
There was a problem hiding this comment.
Warning
I'm not at all convinced we need a safeCongif here as we lose the information. Any local log or telemetry that could be sent from the generated key will hide the fact that the bitmap configuration was null.
In the current case, I'd prefer to have a generateKey allowing a nullable config instead
There was a problem hiding this comment.
I didn't see any telemetry there, in any case the Config in this case is just a variable in the key generation so with our without it null will have more or less same changes of collisions for 2 elements with Bitmap.config null so I am ok with any approach. @jonathanmos , @0xnm what do you guys think ?
|
|
||
| // some of this memory level are not being triggered after API 34. We still need to keep them for now | ||
| // for lower versions | ||
| @Suppress("DEPRECATION") |
There was a problem hiding this comment.
what is the replacement then? should we use it for newer APIs?
There was a problem hiding this comment.
I think we can leave it like it is and prepare a task to remove those later. The only think that will happen for newer APIs is that those level will never be triggered. I don't see any harm now, maybe to create a task to clean these levels ?
There was a problem hiding this comment.
yes, no harm. My point is just that if something is deprecated, then probably there is a replacement for the newer APIs?
There was a problem hiding this comment.
Nope. no replacement suggested in their docs, I think they simply don't support these levels anymore and only kept few important ones. I think they did not need this granularity anymore.
| fun `M log error W read() { invalid number of blocks }`() { | ||
| // Given | ||
| blocksReturned.removeLast() | ||
| blocksReturned.removeAt(blocksReturned.size - 1) |
There was a problem hiding this comment.
| blocksReturned.removeAt(blocksReturned.size - 1) | |
| blocksReturned.removeAt(blocksReturned.lastIndex) |
| fun `M return onFailure W read() { invalid number of blocks }`() { | ||
| // Given | ||
| blocksReturned.removeLast() | ||
| blocksReturned.removeAt(blocksReturned.size - 1) |
There was a problem hiding this comment.
| blocksReturned.removeAt(blocksReturned.size - 1) | |
| blocksReturned.removeAt(blocksReturned.lastIndex) |
| ) { | ||
| internal fun generateKey(bitmap: Bitmap) = | ||
| generateKey(bitmap.width, bitmap.height, bitmap.config) | ||
| generateKey(bitmap.width, bitmap.height, bitmap.safeConfig()) |
There was a problem hiding this comment.
Warning
I'm not at all convinced we need a safeCongif here as we lose the information. Any local log or telemetry that could be sent from the generated key will hide the fact that the bitmap configuration was null.
In the current case, I'd prefer to have a generateKey allowing a nullable config instead
e0c771b to
bedcb09
Compare
cec0387 to
29219d7
Compare
| return if (config != null) { | ||
| "$width-$height-$config" | ||
| } else { | ||
| "$width-$height-null" | ||
| } |
There was a problem hiding this comment.
Note
the String templating with a nullable variable will give the same result, you don't have to do this
| return if (config != null) { | |
| "$width-$height-$config" | |
| } else { | |
| "$width-$height-null" | |
| } | |
| return "$width-$height-$config" |
There was a problem hiding this comment.
yes just a weird autocomplete
There was a problem hiding this comment.
sorry this comment was for the testing assertion message but for this case I was not aware that having null value in the string format will not actually break so I preferred the safer way. In the end I like it more as it is more explicit regarding what to expect.
| testedCache.getBitmapByProperties(mockBitmap.width, mockBitmap.height, mockConfig) | ||
|
|
||
| // When | ||
| testedCache.put(mockBitmap) | ||
|
|
||
| // Then | ||
| val actualBitmap = testedCache.getBitmapByProperties(mockBitmap.width, mockBitmap.height, mockBitmap.config) | ||
| val actualBitmap = | ||
| testedCache.getBitmapByProperties(mockBitmap.width, mockBitmap.height, mockConfig) |
There was a problem hiding this comment.
Note
Why are those changes necessary ?
There was a problem hiding this comment.
mockBitmap.config returns nullable now and that method expects nonnull so we are using directly the mockConfig with which this mockBitmap is mocked with.
There was a problem hiding this comment.
Why can't we make the getBitmapByProperties() method accept a nullable Config? The only usage of the config is to call the generateKey which this PR modifies to allow a nullable config.
There was a problem hiding this comment.
But why we should change this method if this code if this is not required ? All the methods calling this code are keeping the contract, if we would change this code we would change only for the sake of this test, this is not the same thing as the BitmapPoolHelper#generateKey method which accepts a bitmap and delegates to generateKey method. This method has a different scope and requires in the contract that the config should be NonNull when calling it. I really don't get why do you want to change this.
| val key = testedHelper.generateKey(mockBitmap) | ||
|
|
||
| // Then | ||
| assertThat(key).isEqualTo("$fakeWidth-$fakeHeight-${null}") |
There was a problem hiding this comment.
| assertThat(key).isEqualTo("$fakeWidth-$fakeHeight-${null}") | |
| assertThat(key).isEqualTo("$fakeWidth-$fakeHeight-null") |
29219d7 to
9a1cb71
Compare
9a1cb71 to
478df2e
Compare
What does this PR do?
Updates the latest API version for running our integration tests to API 35.
Motivation
What inspired you to submit this pull request?
Additional Notes
Anything else we should know when reviewing?
Review checklist (to be filled by reviewers)