Fixed
Status Update
Comments
il...@google.com <il...@google.com>
jd...@gmail.com <jd...@gmail.com> #2
Project: platform/frameworks/support
Branch: androidx-master-dev
commit c60f33e229e31ab328ef6b59dab63b264954831c
Author: Alexandre Elias <aelias@google.com>
Date: Fri Jul 10 16:23:09 2020
Semantics no-op cleanups
Partly in response to lmr's broad code review, I did a pass of
superficial API/implementation cleanup. The main changes are:
- I changed each Boolean SemanticsProperty where false is equivalent to
not being present to take "Unit" instead. This is conceptually
clearer: it avoids questions like "can I cancel out a semantics from a
merged child by setting it to false?" Because "property = Unit" looks
weird, I also changed the style of these to "property()".
- I moved the Semantics id generator closer to where it's used, in
SemanticsModifierCore. I made it internal and an AtomicInt.
(Note that integer ids are heavily used in the Android
AccessibilityNodeInfo APIs so I can't simply remove them entirely.)
- I deleted dead code. Some examples include SemanticsHintOverrides,
a public API not connected to anything, and SemanticsPropertyKey
merge() open method which is never called. (In both cases I have
a different plan in mind for accessibility.)
Fixes: 145951226
Fixes: 145955412
Test: existing tests
Relnote: "Single-value semantics properties now use a calling style.
For example, 'semantics { hidden = true }' is now written as:
'semantics { hidden() }'."
Change-Id: Ic1afd12ea22c926babc9662f1804d80b33aa0cfc
M ui/integration-tests/benchmark/src/androidTest/java/androidx/ui/benchmark/test/LayoutNodeModifierBenchmark.kt
M ui/ui-core/api/0.1.0-dev15.txt
M ui/ui-core/api/current.txt
M ui/ui-core/api/public_plus_experimental_0.1.0-dev15.txt
M ui/ui-core/api/public_plus_experimental_current.txt
M ui/ui-core/api/restricted_0.1.0-dev15.txt
M ui/ui-core/api/restricted_current.txt
M ui/ui-core/src/androidAndroidTest/kotlin/androidx/ui/graphics/vector/VectorTest.kt
M ui/ui-core/src/androidAndroidTest/kotlin/androidx/ui/semantics/SemanticsTests.kt
M ui/ui-core/src/androidMain/kotlin/androidx/ui/core/AndroidActuals.kt
M ui/ui-core/src/androidMain/kotlin/androidx/ui/core/AndroidComposeView.kt
M ui/ui-core/src/androidMain/kotlin/androidx/ui/core/AndroidComposeViewAccessibilityDelegateCompat.kt
M ui/ui-core/src/androidMain/kotlin/androidx/ui/core/AndroidPopup.kt
M ui/ui-core/src/commonMain/kotlin/androidx/ui/core/Expect.kt
M ui/ui-core/src/commonMain/kotlin/androidx/ui/core/semantics/SemanticsConfiguration.kt
D ui/ui-core/src/commonMain/kotlin/androidx/ui/core/semantics/SemanticsHintOverrides.kt
M ui/ui-core/src/commonMain/kotlin/androidx/ui/core/semantics/SemanticsModifier.kt
M ui/ui-core/src/commonMain/kotlin/androidx/ui/core/semantics/SemanticsNode.kt
M ui/ui-core/src/commonMain/kotlin/androidx/ui/core/semantics/SemanticsOwner.kt
M ui/ui-core/src/commonMain/kotlin/androidx/ui/core/semantics/SemanticsWrapper.kt
M ui/ui-core/src/commonMain/kotlin/androidx/ui/semantics/SemanticsProperties.kt
M ui/ui-foundation/api/0.1.0-dev15.txt
M ui/ui-foundation/api/current.txt
M ui/ui-foundation/api/public_plus_experimental_0.1.0-dev15.txt
M ui/ui-foundation/api/public_plus_experimental_current.txt
M ui/ui-foundation/api/restricted_0.1.0-dev15.txt
M ui/ui-foundation/api/restricted_current.txt
M ui/ui-foundation/src/main/java/androidx/ui/foundation/Clickable.kt
M ui/ui-foundation/src/main/java/androidx/ui/foundation/Dialog.kt
M ui/ui-foundation/src/main/java/androidx/ui/foundation/Scroller.kt
M ui/ui-foundation/src/main/java/androidx/ui/foundation/selection/Selectable.kt
M ui/ui-foundation/src/main/java/androidx/ui/foundation/selection/Toggleable.kt
M ui/ui-foundation/src/main/java/androidx/ui/foundation/semantics/FoundationSemanticsProperties.kt
M ui/ui-material/src/androidTest/java/androidx/ui/material/ButtonTest.kt
M ui/ui-material/src/androidTest/java/androidx/ui/material/CardTest.kt
M ui/ui-material/src/androidTest/java/androidx/ui/material/CheckboxScreenshotTest.kt
M ui/ui-material/src/androidTest/java/androidx/ui/material/RadioButtonScreenshotTest.kt
M ui/ui-material/src/androidTest/java/androidx/ui/material/ScaffoldTest.kt
M ui/ui-material/src/androidTest/java/androidx/ui/material/SnackbarTest.kt
M ui/ui-material/src/androidTest/java/androidx/ui/material/SurfaceTest.kt
M ui/ui-material/src/androidTest/java/androidx/ui/material/ripple/RippleIndicationTest.kt
M ui/ui-material/src/androidTest/java/androidx/ui/material/textfield/TextFieldScreenshotTest.kt
M ui/ui-material/src/main/java/androidx/ui/material/AppBar.kt
M ui/ui-material/src/main/java/androidx/ui/material/TextFieldImpl.kt
M ui/ui-test/src/androidTest/java/androidx/ui/test/AssertsTest.kt
M ui/ui-test/src/androidTest/java/androidx/ui/test/CallSemanticsActionTest.kt
M ui/ui-test/src/androidTest/java/androidx/ui/test/ErrorMessagesTest.kt
M ui/ui-test/src/androidTest/java/androidx/ui/test/FindersTest.kt
M ui/ui-test/src/androidTest/java/androidx/ui/test/PrintToStringTest.kt
M ui/ui-test/src/androidTest/java/androidx/ui/test/ScrollToTest.kt
M ui/ui-test/src/androidTest/java/androidx/ui/test/TextActionsTest.kt
M ui/ui-test/src/main/java/androidx/ui/test/Actions.kt
M ui/ui-test/src/main/java/androidx/ui/test/Filters.kt
M ui/ui-text/api/0.1.0-dev15.txt
M ui/ui-text/api/current.txt
M ui/ui-text/api/public_plus_experimental_0.1.0-dev15.txt
M ui/ui-text/api/public_plus_experimental_current.txt
M ui/ui-text/api/restricted_0.1.0-dev15.txt
M ui/ui-text/api/restricted_current.txt
M ui/ui-text/src/commonMain/kotlin/androidx/ui/text/CoreTextField.kt
M ui/ui-text/src/commonMain/kotlin/androidx/ui/text/TextSemanticsProperties.kt
https://android-review.googlesource.com/1360099
Branch: androidx-master-dev
commit c60f33e229e31ab328ef6b59dab63b264954831c
Author: Alexandre Elias <aelias@google.com>
Date: Fri Jul 10 16:23:09 2020
Semantics no-op cleanups
Partly in response to lmr's broad code review, I did a pass of
superficial API/implementation cleanup. The main changes are:
- I changed each Boolean SemanticsProperty where false is equivalent to
not being present to take "Unit" instead. This is conceptually
clearer: it avoids questions like "can I cancel out a semantics from a
merged child by setting it to false?" Because "property = Unit" looks
weird, I also changed the style of these to "property()".
- I moved the Semantics id generator closer to where it's used, in
SemanticsModifierCore. I made it internal and an AtomicInt.
(Note that integer ids are heavily used in the Android
AccessibilityNodeInfo APIs so I can't simply remove them entirely.)
- I deleted dead code. Some examples include SemanticsHintOverrides,
a public API not connected to anything, and SemanticsPropertyKey
merge() open method which is never called. (In both cases I have
a different plan in mind for accessibility.)
Fixes: 145951226
Fixes: 145955412
Test: existing tests
Relnote: "Single-value semantics properties now use a calling style.
For example, 'semantics { hidden = true }' is now written as:
'semantics { hidden() }'."
Change-Id: Ic1afd12ea22c926babc9662f1804d80b33aa0cfc
M ui/integration-tests/benchmark/src/androidTest/java/androidx/ui/benchmark/test/LayoutNodeModifierBenchmark.kt
M ui/ui-core/api/0.1.0-dev15.txt
M ui/ui-core/api/current.txt
M ui/ui-core/api/public_plus_experimental_0.1.0-dev15.txt
M ui/ui-core/api/public_plus_experimental_current.txt
M ui/ui-core/api/restricted_0.1.0-dev15.txt
M ui/ui-core/api/restricted_current.txt
M ui/ui-core/src/androidAndroidTest/kotlin/androidx/ui/graphics/vector/VectorTest.kt
M ui/ui-core/src/androidAndroidTest/kotlin/androidx/ui/semantics/SemanticsTests.kt
M ui/ui-core/src/androidMain/kotlin/androidx/ui/core/AndroidActuals.kt
M ui/ui-core/src/androidMain/kotlin/androidx/ui/core/AndroidComposeView.kt
M ui/ui-core/src/androidMain/kotlin/androidx/ui/core/AndroidComposeViewAccessibilityDelegateCompat.kt
M ui/ui-core/src/androidMain/kotlin/androidx/ui/core/AndroidPopup.kt
M ui/ui-core/src/commonMain/kotlin/androidx/ui/core/Expect.kt
M ui/ui-core/src/commonMain/kotlin/androidx/ui/core/semantics/SemanticsConfiguration.kt
D ui/ui-core/src/commonMain/kotlin/androidx/ui/core/semantics/SemanticsHintOverrides.kt
M ui/ui-core/src/commonMain/kotlin/androidx/ui/core/semantics/SemanticsModifier.kt
M ui/ui-core/src/commonMain/kotlin/androidx/ui/core/semantics/SemanticsNode.kt
M ui/ui-core/src/commonMain/kotlin/androidx/ui/core/semantics/SemanticsOwner.kt
M ui/ui-core/src/commonMain/kotlin/androidx/ui/core/semantics/SemanticsWrapper.kt
M ui/ui-core/src/commonMain/kotlin/androidx/ui/semantics/SemanticsProperties.kt
M ui/ui-foundation/api/0.1.0-dev15.txt
M ui/ui-foundation/api/current.txt
M ui/ui-foundation/api/public_plus_experimental_0.1.0-dev15.txt
M ui/ui-foundation/api/public_plus_experimental_current.txt
M ui/ui-foundation/api/restricted_0.1.0-dev15.txt
M ui/ui-foundation/api/restricted_current.txt
M ui/ui-foundation/src/main/java/androidx/ui/foundation/Clickable.kt
M ui/ui-foundation/src/main/java/androidx/ui/foundation/Dialog.kt
M ui/ui-foundation/src/main/java/androidx/ui/foundation/Scroller.kt
M ui/ui-foundation/src/main/java/androidx/ui/foundation/selection/Selectable.kt
M ui/ui-foundation/src/main/java/androidx/ui/foundation/selection/Toggleable.kt
M ui/ui-foundation/src/main/java/androidx/ui/foundation/semantics/FoundationSemanticsProperties.kt
M ui/ui-material/src/androidTest/java/androidx/ui/material/ButtonTest.kt
M ui/ui-material/src/androidTest/java/androidx/ui/material/CardTest.kt
M ui/ui-material/src/androidTest/java/androidx/ui/material/CheckboxScreenshotTest.kt
M ui/ui-material/src/androidTest/java/androidx/ui/material/RadioButtonScreenshotTest.kt
M ui/ui-material/src/androidTest/java/androidx/ui/material/ScaffoldTest.kt
M ui/ui-material/src/androidTest/java/androidx/ui/material/SnackbarTest.kt
M ui/ui-material/src/androidTest/java/androidx/ui/material/SurfaceTest.kt
M ui/ui-material/src/androidTest/java/androidx/ui/material/ripple/RippleIndicationTest.kt
M ui/ui-material/src/androidTest/java/androidx/ui/material/textfield/TextFieldScreenshotTest.kt
M ui/ui-material/src/main/java/androidx/ui/material/AppBar.kt
M ui/ui-material/src/main/java/androidx/ui/material/TextFieldImpl.kt
M ui/ui-test/src/androidTest/java/androidx/ui/test/AssertsTest.kt
M ui/ui-test/src/androidTest/java/androidx/ui/test/CallSemanticsActionTest.kt
M ui/ui-test/src/androidTest/java/androidx/ui/test/ErrorMessagesTest.kt
M ui/ui-test/src/androidTest/java/androidx/ui/test/FindersTest.kt
M ui/ui-test/src/androidTest/java/androidx/ui/test/PrintToStringTest.kt
M ui/ui-test/src/androidTest/java/androidx/ui/test/ScrollToTest.kt
M ui/ui-test/src/androidTest/java/androidx/ui/test/TextActionsTest.kt
M ui/ui-test/src/main/java/androidx/ui/test/Actions.kt
M ui/ui-test/src/main/java/androidx/ui/test/Filters.kt
M ui/ui-text/api/0.1.0-dev15.txt
M ui/ui-text/api/current.txt
M ui/ui-text/api/public_plus_experimental_0.1.0-dev15.txt
M ui/ui-text/api/public_plus_experimental_current.txt
M ui/ui-text/api/restricted_0.1.0-dev15.txt
M ui/ui-text/api/restricted_current.txt
M ui/ui-text/src/commonMain/kotlin/androidx/ui/text/CoreTextField.kt
M ui/ui-text/src/commonMain/kotlin/androidx/ui/text/TextSemanticsProperties.kt
hu...@google.com <hu...@google.com> #3
Hi Jorge,
Thanks for reporting the issue. Yes, the problem is EmptyActivity (which is used by FragmentScenario internally) extends FragmentActivity and FragmentActivity doesn't have ActionBar.
I'm going to update EmptyActivity to extend AppCompatActivity instead. As for the workaround solution, could you create EmptyActivity extending AppCompatActivity in your APK and use ActivityScenario, then run your Fragment in it?
Thanks for reporting the issue. Yes, the problem is EmptyActivity (which is used by FragmentScenario internally) extends FragmentActivity and FragmentActivity doesn't have ActionBar.
I'm going to update EmptyActivity to extend AppCompatActivity instead. As for the workaround solution, could you create EmptyActivity extending AppCompatActivity in your APK and use ActivityScenario, then run your Fragment in it?
ap...@google.com <ap...@google.com> #5
Project: platform/frameworks/support
Branch: androidx-master-dev
commit 97820f9e3b80de2ba10ad3dd520d8f146f0e394c
Author: Yuki Hamada <hummer@google.com>
Date: Thu Jan 24 13:33:55 2019
Use android:Theme.WithActionBar for EmptyFragmentActivity.
Before this CL, FragmentScenarioEmptyFragmentActivityTheme inherits android:Theme which doesn't have ActionBar so options menu which testing Fragment adds cannot be tested. This CL changes the parent theme to android:Theme.WithActionBar to support options menu.
Change-Id: I35e80d3b302ea600e5e76f6f0640934b806259e5
Test: :fragment-testing:connectedAndroidTest
Fixes: 121126668
M fragment/testing/build.gradle
M fragment/testing/src/androidTest/java/androidx/fragment/app/testing/FragmentScenarioTest.kt
A fragment/testing/src/androidTest/java/androidx/fragment/app/testing/OptionsMenuFragment.kt
A fragment/testing/src/androidTest/res/menu/example_menu.xml
M fragment/testing/src/main/res/values/styles.xml
https://android-review.googlesource.com/885195
https://goto.google.com/android-sha1/97820f9e3b80de2ba10ad3dd520d8f146f0e394c
Branch: androidx-master-dev
commit 97820f9e3b80de2ba10ad3dd520d8f146f0e394c
Author: Yuki Hamada <hummer@google.com>
Date: Thu Jan 24 13:33:55 2019
Use android:Theme.WithActionBar for EmptyFragmentActivity.
Before this CL, FragmentScenarioEmptyFragmentActivityTheme inherits android:Theme which doesn't have ActionBar so options menu which testing Fragment adds cannot be tested. This CL changes the parent theme to android:Theme.WithActionBar to support options menu.
Change-Id: I35e80d3b302ea600e5e76f6f0640934b806259e5
Test: :fragment-testing:connectedAndroidTest
Fixes: 121126668
M fragment/testing/build.gradle
M fragment/testing/src/androidTest/java/androidx/fragment/app/testing/FragmentScenarioTest.kt
A fragment/testing/src/androidTest/java/androidx/fragment/app/testing/OptionsMenuFragment.kt
A fragment/testing/src/androidTest/res/menu/example_menu.xml
M fragment/testing/src/main/res/values/styles.xml
jd...@gmail.com <jd...@gmail.com> #6
Hi all,
Sorry for my very late reply, but I was traveling and very busy.
I have just run the test again, and it still doesn't work.
As far as I understand, with the change that was introduced, I only had to update the dependencies and rerun the test as it was. Please correct me if I am wrong. These are my (relevant) dependencies:
- androidx.fragment and fragment-testing: 1.1.0-alpha05
- androidx.test.runner: 1.1.1
- androidx.test.core: 1.1.0
- androidx.test.ext.junit: 1.1.0
- org.robolectric: 4.2.1
Am I missing anything here? Thank you!
Best regards,
Jorge
Sorry for my very late reply, but I was traveling and very busy.
I have just run the test again, and it still doesn't work.
As far as I understand, with the change that was introduced, I only had to update the dependencies and rerun the test as it was. Please correct me if I am wrong. These are my (relevant) dependencies:
- androidx.fragment and fragment-testing: 1.1.0-alpha05
- androidx.test.runner: 1.1.1
- androidx.test.core: 1.1.0
- androidx.test.ext.junit: 1.1.0
- org.robolectric: 4.2.1
Am I missing anything here? Thank you!
Best regards,
Jorge
jd...@gmail.com <jd...@gmail.com> #7
Hi again,
The generated error is: "androidx.test.espresso.NoMatchingViewException: No views in hierarchy found matching: with id: com.canonicalexamples.realprogrammers:id/menu_item_save".
Running the application displays that button. However, the (partial) hierarchy shown in the log is:
"+---->ActionMenuView{id=-1, visibility=VISIBLE, width=56, height=48, has-focus=false, has-focusable=true, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, layout-params=android.view.ViewGroup$LayoutParams@340d8ce3, tag=null, root-is-layout-requested=false, has-input-connection=false, x=264.0, y=0.0, child-count=1}
|
+----->OverflowMenuButton{id=-1, desc=More options, visibility=VISIBLE, width=56, height=48, has-focus=false, has-focusable=true, has-window-focus=true, is-clickable=true, is-enabled=true, is-focused=false, is-focusable=true, is-layout-requested=false, is-selected=false, layout-params=android.widget.ActionMenuView$LayoutParams@1c10a9c8, tag=null, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0}
|
+--->ActionBarContextView{id=16908677, res-name=action_context_bar, visibility=GONE, width=0, height=0, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=true, is-selected=false, layout-params=android.widget.FrameLayout$LayoutParams@c883991, tag=null, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=0}
|
+-->ActionBarContainer{id=16909335, res-name=split_action_bar, visibility=GONE, width=0, height=0, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=true, is-selected=false, layout-params=com.android.internal.widget.ActionBarOverlayLayout$LayoutParams@820620, tag=null, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=0} "
Best regards,
Jorge
The generated error is: "androidx.test.espresso.NoMatchingViewException: No views in hierarchy found matching: with id: com.canonicalexamples.realprogrammers:id/menu_item_save".
Running the application displays that button. However, the (partial) hierarchy shown in the log is:
"+---->ActionMenuView{id=-1, visibility=VISIBLE, width=56, height=48, has-focus=false, has-focusable=true, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, layout-params=android.view.ViewGroup$LayoutParams@340d8ce3, tag=null, root-is-layout-requested=false, has-input-connection=false, x=264.0, y=0.0, child-count=1}
|
+----->OverflowMenuButton{id=-1, desc=More options, visibility=VISIBLE, width=56, height=48, has-focus=false, has-focusable=true, has-window-focus=true, is-clickable=true, is-enabled=true, is-focused=false, is-focusable=true, is-layout-requested=false, is-selected=false, layout-params=android.widget.ActionMenuView$LayoutParams@1c10a9c8, tag=null, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0}
|
+--->ActionBarContextView{id=16908677, res-name=action_context_bar, visibility=GONE, width=0, height=0, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=true, is-selected=false, layout-params=android.widget.FrameLayout$LayoutParams@c883991, tag=null, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=0}
|
+-->ActionBarContainer{id=16909335, res-name=split_action_bar, visibility=GONE, width=0, height=0, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=true, is-selected=false, layout-params=com.android.internal.widget.ActionBarOverlayLayout$LayoutParams@820620, tag=null, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=0} "
Best regards,
Jorge
Description
Version used: 1.1.0-alpha02
Devices/Android versions reproduced on: emulator
I am trying to test that a menu option is enabled or disabled when needed using Robolectric 4.0.2. The test will be something like:
@Test
fun enableSaveButton() {
sut.onFragment {
// TODO: trigger onCreateOptionsMenu(menu: Menu, inflater: MenuInflater)
openActionBarOverflowOrOptionsMenu(ApplicationProvider.getApplicationContext())
it.enableSaveButton(false)
}
onView(withId(R.id.menu_item_save)).check(matches(not(isEnabled())))
}
The fragment is launched and reaches the resumed state, but in the lamda that "onFragment" executes, onCreateMenuOptions() has NOT been executed yet becaues that is how the fragment lifecycle works (
I have also tried using Espresso's "openActionBarOverflowOrOptionsMenu(ApplicationProvider.getApplicationContext())" unsuccessfully.