Fixed
Status Update
Comments
il...@google.com <il...@google.com> #2
Project: platform/frameworks/support
Branch: androidx-master-dev
commit b90079595f33f58fece04026a97faa0d243acdb1
Author: Yuichi Araki <yaraki@google.com>
Date: Wed Sep 18 16:55:49 2019
Change the way to detect mismatch between POJO and query
This fixes cursor mismatch warnings with expandProjection.
Bug: 140759491
Test: QueryMethodProcessorTest
Change-Id: I7659002e5e0d1ef60fc1af2a625c0c36da0664d8
M room/compiler/src/main/kotlin/androidx/room/processor/QueryMethodProcessor.kt
M room/compiler/src/main/kotlin/androidx/room/solver/TypeAdapterStore.kt
M room/compiler/src/main/kotlin/androidx/room/solver/query/result/PojoRowAdapter.kt
M room/compiler/src/test/kotlin/androidx/room/processor/QueryMethodProcessorTest.kt
M room/compiler/src/test/kotlin/androidx/room/testing/TestProcessor.kt
https://android-review.googlesource.com/1123258
https://goto.google.com/android-sha1/b90079595f33f58fece04026a97faa0d243acdb1
Branch: androidx-master-dev
commit b90079595f33f58fece04026a97faa0d243acdb1
Author: Yuichi Araki <yaraki@google.com>
Date: Wed Sep 18 16:55:49 2019
Change the way to detect mismatch between POJO and query
This fixes cursor mismatch warnings with expandProjection.
Bug: 140759491
Test: QueryMethodProcessorTest
Change-Id: I7659002e5e0d1ef60fc1af2a625c0c36da0664d8
M room/compiler/src/main/kotlin/androidx/room/processor/QueryMethodProcessor.kt
M room/compiler/src/main/kotlin/androidx/room/solver/TypeAdapterStore.kt
M room/compiler/src/main/kotlin/androidx/room/solver/query/result/PojoRowAdapter.kt
M room/compiler/src/test/kotlin/androidx/room/processor/QueryMethodProcessorTest.kt
M room/compiler/src/test/kotlin/androidx/room/testing/TestProcessor.kt
[Deleted User] <[Deleted User]> #3
[Deleted User] <[Deleted User]> #4
Project: platform/frameworks/support
Branch: androidx-master-dev
commit bdde5a1a970ddc9007b28de4aa29d60ffa588f08
Author: Yigit Boyar <yboyar@google.com>
Date: Thu Apr 16 16:47:05 2020
Re-factor how errors are dismissed when query is re-written
This CL changes how we handle errors/warnings if query is
re-written.
There was a bug in expandProjection where we would report warnings
for things that Room already fixes automatically ( b/140759491 ).
The solution to that problem (I7659002e5e0d1ef60fc1af2a625c0c36da0664d8)
solved it by deferring validating of columns until after re-write
decision is made. Unfortunately, this required changing PojoRowAdapter
to have a dummy mapping until it is validating, make it hard to use
as it does have a non-null mapping which is not useful.
This CL partially reverts that change and instead rely on the log
deferring logic we have in Context. This way, we don't need to break
the stability of PojoRowAdapter while still having the ability to
drop warnings that room fixes. This will also play nicer when we
have different query re-writing options that can use more information
about the query results.
Bug: 153387066
Bug: 140759491
Test: existing tests pass
Change-Id: I2ec967c763d33d7a3ff02c1a13c6953b460d1e5f
M room/compiler/src/main/kotlin/androidx/room/log/RLog.kt
M room/compiler/src/main/kotlin/androidx/room/processor/QueryMethodProcessor.kt
M room/compiler/src/main/kotlin/androidx/room/solver/TypeAdapterStore.kt
M room/compiler/src/main/kotlin/androidx/room/solver/query/result/PojoRowAdapter.kt
https://android-review.googlesource.com/1288456
Branch: androidx-master-dev
commit bdde5a1a970ddc9007b28de4aa29d60ffa588f08
Author: Yigit Boyar <yboyar@google.com>
Date: Thu Apr 16 16:47:05 2020
Re-factor how errors are dismissed when query is re-written
This CL changes how we handle errors/warnings if query is
re-written.
There was a bug in expandProjection where we would report warnings
for things that Room already fixes automatically (
The solution to that problem (I7659002e5e0d1ef60fc1af2a625c0c36da0664d8)
solved it by deferring validating of columns until after re-write
decision is made. Unfortunately, this required changing PojoRowAdapter
to have a dummy mapping until it is validating, make it hard to use
as it does have a non-null mapping which is not useful.
This CL partially reverts that change and instead rely on the log
deferring logic we have in Context. This way, we don't need to break
the stability of PojoRowAdapter while still having the ability to
drop warnings that room fixes. This will also play nicer when we
have different query re-writing options that can use more information
about the query results.
Bug: 153387066
Bug: 140759491
Test: existing tests pass
Change-Id: I2ec967c763d33d7a3ff02c1a13c6953b460d1e5f
M room/compiler/src/main/kotlin/androidx/room/log/RLog.kt
M room/compiler/src/main/kotlin/androidx/room/processor/QueryMethodProcessor.kt
M room/compiler/src/main/kotlin/androidx/room/solver/TypeAdapterStore.kt
M room/compiler/src/main/kotlin/androidx/room/solver/query/result/PojoRowAdapter.kt
il...@google.com <il...@google.com> #5
Switching to Kotlin Safe Args fixed the issue, so seems like the same issue, just on the Directions side (vs the other which is on the Args side).
ap...@google.com <ap...@google.com> #6
Project: platform/frameworks/support
Branch: androidx-master-dev
commit 2180ea57914af961d4f2bb43802b42ae0d1802e0
Author: Jeremy Woods <jbwoods@google.com>
Date: Fri Oct 04 16:02:03 2019
Generate default values for Directions safe_args in Java
Currently the safe args generation for java code does not contain
default Direction args values. The default directions arg values are
provided by the Kotlin safe args generation and we should be as
uniform as possible across both languages.
Test: ./gradlew --rerun-tasks navigation:navigation-safe-args-gradle-plugin:test
Change-Id: I07b67d9c86dafff608df49a609796a71a9b3315a
navigation:navigation-safe-args-generator:test
BUG: 141099045
M navigation/navigation-safe-args-generator/src/main/kotlin/androidx/navigation/safe/args/generator/java/JavaNavWriter.kt
M navigation/navigation-safe-args-generator/src/main/kotlin/androidx/navigation/safe/args/generator/java/JavaTypes.kt
M navigation/navigation-safe-args-generator/src/tests/test-data/expected/java_nav_writer_test/MainFragmentArgs.java
M navigation/navigation-safe-args-generator/src/tests/test-data/expected/java_nav_writer_test/MainFragmentDirections.java
M navigation/navigation-safe-args-generator/src/tests/test-data/expected/java_nav_writer_test/Next.java
M navigation/navigation-safe-args-generator/src/tests/test-data/expected/java_nav_writer_test/SanitizedMainFragmentDirections.java
M navigation/navigation-safe-args-generator/src/tests/test-data/expected/nav_generator_test/java/nested_overridden_action/SettingsDirections.java
M navigation/navigation-safe-args-generator/src/tests/test-data/expected/nav_generator_test/java/nested_same_action/SettingsDirections.java
M navigation/navigation-safe-args-generator/src/tests/test-data/expected/nav_generator_test/java/nested_same_action/SettingsFragmentDirections.java
https://android-review.googlesource.com/1133433
https://goto.google.com/android-sha1/2180ea57914af961d4f2bb43802b42ae0d1802e0
Branch: androidx-master-dev
commit 2180ea57914af961d4f2bb43802b42ae0d1802e0
Author: Jeremy Woods <jbwoods@google.com>
Date: Fri Oct 04 16:02:03 2019
Generate default values for Directions safe_args in Java
Currently the safe args generation for java code does not contain
default Direction args values. The default directions arg values are
provided by the Kotlin safe args generation and we should be as
uniform as possible across both languages.
Test: ./gradlew --rerun-tasks navigation:navigation-safe-args-gradle-plugin:test
Change-Id: I07b67d9c86dafff608df49a609796a71a9b3315a
navigation:navigation-safe-args-generator:test
BUG: 141099045
M navigation/navigation-safe-args-generator/src/main/kotlin/androidx/navigation/safe/args/generator/java/JavaNavWriter.kt
M navigation/navigation-safe-args-generator/src/main/kotlin/androidx/navigation/safe/args/generator/java/JavaTypes.kt
M navigation/navigation-safe-args-generator/src/tests/test-data/expected/java_nav_writer_test/MainFragmentArgs.java
M navigation/navigation-safe-args-generator/src/tests/test-data/expected/java_nav_writer_test/MainFragmentDirections.java
M navigation/navigation-safe-args-generator/src/tests/test-data/expected/java_nav_writer_test/Next.java
M navigation/navigation-safe-args-generator/src/tests/test-data/expected/java_nav_writer_test/SanitizedMainFragmentDirections.java
M navigation/navigation-safe-args-generator/src/tests/test-data/expected/nav_generator_test/java/nested_overridden_action/SettingsDirections.java
M navigation/navigation-safe-args-generator/src/tests/test-data/expected/nav_generator_test/java/nested_same_action/SettingsDirections.java
M navigation/navigation-safe-args-generator/src/tests/test-data/expected/nav_generator_test/java/nested_same_action/SettingsFragmentDirections.java
jb...@google.com <jb...@google.com> #7
This has been fixed internally and will be available in the Navigation 2.2.0-beta01 release.
ra...@gmail.com <ra...@gmail.com> #8
Using '2.2.0-rc02'. Putting null as a default value for a string, returns a string "@null" when getting that parameter from navArgs
<argument
android:name="deepLinkToken"
android:defaultValue="@null"
app:argType="string"
app:nullable="true" />
And:
val args by navArgs<FragmentArgs>()
args.deepLinkToken // returns "@null"
<argument
android:name="deepLinkToken"
android:defaultValue="@null"
app:argType="string"
app:nullable="true" />
And:
val args by navArgs<FragmentArgs>()
args.deepLinkToken // returns "@null"
jb...@google.com <jb...@google.com> #9
Re #8 - please file a separate bugs with a project that reproduce your separate issue. If the issue you are mentioning is covered by https://issuetracker.google.com/issues/141613546 , feel free to +1.
Description
Version used: 2.0.0
Devices/Android versions reproduced on: during development; any IDE
SDK: Java
Summary:
I can't unit test any production code that tries navigating to an auto-generated Action class that has a default value. It seems (in version 2.0.0) that the default values are set by the NavController instead of baked into the auto-generated class. The result is that I get some NullPointerExceptions when trying to unit test navigation.
To reproduce:
1. In nav graph xml, add an argument having a default value to an action
<fragment
android:id="@id/screen1_fragment"
android:name="com.yourapp.yourpackage.Screen1Fragment"
<action
android:id="@+id/action_screen1_to_screen2"
app:destination="@id/screen2_fragment"
<argument
android:name="myBoolean"
app:argType="boolean"
android:defaultValue="false" />
</action>
</fragment>
2. In prod code, navigate using this action without overriding the default
NavController.navigate(Screen1FragmentDirections.actionScreen1ToScreen2());
3. In a unit test, try to verify that the screen1-to-screen2 navigation was invoked
verify(NavController).navigate(Screen1FragmentDirections.actionScreen1ToScreen2());
Expected: Unit test passes with flying colors
Actual: NullPointerException is thrown when the verify() does an equals() comparison. The auto-generated class does not contain default values, and so ActionScreen1ToScreen2.getMyBoolean() method attempts to cast a null value into a boolean, like so:
public boolean getMyBoolean() {
return (boolean) arguments.get("myBoolean");
}
Seems like a testability issue. If there's something I'm missing please let me know.
Related Issues (but not the same):
* SafeArg Builder classes doesn't contain the default values (