Commit Graph

16 Commits

Author SHA1 Message Date
Ale Nijamkin
2c912c9e68 Merge "UI screenshot diff test for user switcher." into tm-qpr-dev 2022-09-09 22:36:45 +00:00
Marcello Galhardo
0ae95adba6 Merge "Improve AmbientState test coverage" into tm-qpr-dev 2022-09-09 09:31:30 +00:00
Alejandro Nijamkin
6c8603d9a1 UI screenshot diff test for user switcher.
Using the new, modern architecture user switcher UI, we implement a UI
screenshot diff test for it. This is a prerequisite for the next step,
where we replace the XML file and view-binder code with a Jetpack
Compose implementation.

Bug: 243843440
Test: N/A this CL is a test
Change-Id: I2831129f44702007be64133a3edcd418e30bd4c1
2022-09-08 13:20:45 -07:00
Marcello Galhardo
faeaa31049 Improve AmbientState test coverage
AmbientState is a critical state holder for system holder but does not contains unit tests. The tests here are extracted from the attempt to convert AmbientState to Kotlin, and introduce a basic unit test coverage that we can build upon to increase changes confidence. Because AmbientState is a simple state holder, the tests are mostly checking property modifications.

We did not include test for any property that does not contain a custom getter or setter.

Test: atest ~/tm-qpr-dev/frameworks/base/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/AmbientStateTest.kt

Fixes: 242754590

Change-Id: Ieb95b9845ee044ae293a3934b9a688c879c64249
2022-09-08 14:34:14 +00:00
Steve Elliott
6597c29a89 Add captureMany { } mockito test utility
Bug: 241121499
Test: atest SystemUITests
Change-Id: I5cea416923549d433dd4e58183a45a0f60223b6a
2022-09-06 13:42:27 +00:00
Mark Renouf
170ca42562 Adds listener support to FakeFeatureFlags
Implements addListener/removeListener with extensive tests.
Does not attempt to simulate 'requestNoRestart' option.

Bug: 244205755
Test: atest FakeFeatureFlagsTest
Change-Id: Ida5911279853744b23c6b139848e99bebc7e6cb2
2022-08-29 20:06:12 +00:00
Beverly Tai
c443da0fa1 Merge "Add falsing protection to the pulsing state" into tm-qpr-dev 2022-08-26 18:18:32 +00:00
Beverly
0ad8657ad7 Add falsing protection to the pulsing state
Prox-gate the tap and double tap to wake gestures
from pulsing/AoD2.

Enable FalsingCollector logs:
  adb shell setprop log.tag.FalsingCollector DEBUG

Test: manually trigger quickpickup (or receive a notification on AoD),
  cover the prox sensor, and then tap the screen - see device won't wake up
Test: atest NotificationShadeWindowViewControllerTest BrightLineFalsingManagerTest PulsingGestureListenerTest
Fixes: 242125976
Change-Id: I520df509b7804d765807477968257c94f55ef634
2022-08-26 12:33:22 +00:00
Jordan Demeulenaere
6fb22d4b16 Implementation of the FooterActions following the MAD (1/3)
This CL provides most of the implementation of the QS FooterActions
following the modern Android architecture. In particular, this CL
includes:
 - repositories in the data layer.
 - an interactor in the domain layer.
 - a view model in the ui layer.

The ViewBinder is added in ag/19674347, given that it comes together
with changes to the existing XML files.

Note that after this CL, the new implementation will still not be used
as it won't be wired yet. This is done in ag/19674347.

The highest value of the tests is in FooterActionsViewModelTest, which
focuses on testing the *state* (view model) of the footer actions using
the *real implementation* of the repositories, interactor and viewModel
all together. To do so, I implemented a FooterActionsUtils class that
allows to *easily* create real implementations of those repositories,
interactor and view model, without requiring the caller to provide any
parameter. I believe that this is even better than introducing new
fakes, and it should hopefully lead us towards using more and more of
the real implementations in our tests, and less and less of fakes/mocks,
making the tests much more useful. Of course, I still had to use fake &
mocks for the classes I'm calling to and for which instantiating the
actual object is too painful. As you can see, there are no test files
for the repositories: given that we already use the real implementations
in the ViewModel tests, they are defacto already tested.

I still added some tests on *interactions* (not *state*) in
FooterActionsInteractorTest. Even though I believe those tests don't
provide much value (they are merely a copy/paste of the implementation),
I preferred keeping the same coverage as the current tests (some of
which are going to be removed in ag/19674347).

Note that the business logic contained in this CL was mostly copy/pasted
from the current implementation, as I wanted to make sure that this is
going to be a pure refactoring that does not change the logic of this
feature. Still, I left some TODOs in the code for potential
improvements.

Bug: 242040009
Test: atest FooterActionsViewModelTest
Test: atest FooterActionsInteractorTest
Change-Id: Ia0bdf9824e098ad6604709f5db87576437b0a904
2022-08-25 16:24:00 +02:00
Jordan Demeulenaere
e496b54c21 Add some fakes to SystemUI-test-utils
This CL adds fake implementations for:
 - FgsManagerController
 - UserTracker
 - SecurityController
 - UserInfoController

It also adds a wrapper around a mocked UserSwitcherController to make it
easier to mock in tests while still handling callbacks.

Those fakes are going to be used to test the new implementation of the
QSFooterActions, which are going to be refactored using the modern
Android architecture. See ag/19678215 to see how they are used.

Bug: 242040009
Test: atest FgsManagerControllerTest
Test: atest FooterActionsViewModelTest
Test: atest FooterActionsInteractorTest
Change-Id: I0a3ef36de81c1bd48f33d4d234a4ee903bf40fc6
2022-08-25 11:41:04 +02:00
Govinda Wasserman
461c9d5ca7 Adds allValues accessor to KotlinArgumentCaptor
Test: Tested locally
BUG: 241286279
Change-Id: Iec3a65064cd2c331048e68477980f2c68fd5d64d
2022-08-16 15:30:51 -04:00
Fabian Kozynski
a96f8dd380 Merge changes I966312e0,Ie443f626 into tm-qpr-dev
* changes:
  Properly store CustomTile added/removed
  Add a FakeSharedPreferences for testing
2022-08-10 13:36:22 +00:00
Jordan Demeulenaere
382622fb5b Do not animate dialogs into activites when locked (1/n)
This CL ensures that we don't try to animate a dialog into an Activity
if the device is currently locked.

Test: atest DialogLaunchAnimatorTest
Bug: 240572073
Change-Id: I5adf650cf9f42781803dce1bebe14b2a78f43fff
2022-08-08 11:12:15 +02:00
Fabian Kozynski
c869403b45 Add a FakeSharedPreferences for testing
* apply and commit both act in the same way, applying the contents of
   the Editor synchronously
 * data is stored in memory in the instance
 * listeners are dispatched synchronously on the same thread that calls
   apply/commit
Test: atest FakeSharedPreferencesTest
Bug: 180126509

Change-Id: Ie443f6269a9aa6d699631d8524bfa9fe6b3474e4
2022-08-04 10:55:21 -04:00
Govinda Wasserman
dd63d1e128 Move Kotlin test helpers into shared directory
Test: Tested locally
BUG: 241286279
FIX: 241286279
Change-Id: I111bd143030a7a3b6dd6e1e0d8df4d9889588b64
2022-08-03 16:53:23 -04:00
Jordan Demeulenaere
f7fed3c20b Move SystemUI test utils to SystemUI/tests/utils/ (1/2)
This CL moves all the SystemUI-test-utils files to a separate
SystemUI/tests/utils/ directory. This paves the way towards making this
filegroup a reusable library instead.

The files have been move using a small bash script [1].

[1] https://paste.googleplex.com/5565628199993344

Bug: 240431193
Test: m SystemUI-tests SystemUIGoogleTests SystemUIGoogleScreenshotTests ArcSystemUI-test
Change-Id: I43ff578be211f1ef3f9c5bffd5c65771ef1492dc
2022-07-29 12:50:27 +02:00