summaryrefslogtreecommitdiff
path: root/java/tests
AgeCommit message (Collapse)Author
2023-11-28Splits tests Mark Renouf
This splits the monolithic 'tests' target into multiple types based on classification. See the corresponding README.md for descriptions. The target 'IntentResolverUnitTests' is replaced by: IntentResolver-tests-unit IntentResolver-tests-activity IntentResolver-tests-integration IntentResolver-tests-shared To run everything, use: atest IntentResolver-tests-* To run TreeHugger presubmits: atest --test-mapping pacakges/modules/IntentResolver Equivalently for postsubmit: atest --test-mapping pacakges/modules/IntentResolver:postsubmit Bug: 300157408 Test: atest IntentResolver-tests-* Change-Id: I9d499284f070a4bfa3e7c1b7c3bbfaa8adb3379b
2023-11-27Merge "Splits list controller into interfaces" into main Govinda Wasserman
2023-11-22Splits list controller into interfaces Govinda Wasserman
Each interface has a single concern, allowing for list controllers to be built by composition. New list controllers are not currently in use, but will be in a future change once resolver comparators and list adapters get updated. Test: atest com.android.intentresolver.v2.listcontroller BUG: 302113519 Change-Id: Ie1d24571c07d1408aa80f8a86311d0fee5e78255
2023-11-15Rename UserDataSource to UserRepository mrenouf
Adds requestState to allow modification of user profile state, including availability (quiet mode). Test: UserRepositoryImplTest Change-Id: Ic38f24475c73390841ee599c48d965117981faa0
2023-11-15Merge "Moves targetIntent logic and WorkProfileAvailability into ↵ Treehugger Robot
ActivityLogic" into main
2023-11-14Moves targetIntent logic and WorkProfileAvailability into ActivityLogic Govinda Wasserman
Test: atest com.android.intentresolver.v2 BUG: 302113519 Change-Id: I590c10264220e5d328cad057215e5c4d8b120a4a
2023-11-13Fix type issues with Kotlin and Context.getSystemService Mark Renouf
``` import androidx.core.content.getSystemService val userManager: UserManager = lazy { context.systemService()!! } ``` Types are inferred as expected, (returns T?) Change-Id: I7ad3531397d6afea25f25bb27c9f29d31a470ca2
2023-11-13Unify annotations packages, fix missing nullability info Mark Renouf
Automated cleanups: use androidx.annotation.* consistently across the codebase. corrects missing nullability annotations method parameters, constructors and and overridden methods return values. Test: atest IntentResolverUnitTests Bug: 300157408 Change-Id: Id48b7ce3e70400bd8ff5d51dabc77e8e04bbfc5c
2023-11-10Adds UserDataSource Mark Renouf
An abstraction of users and profiles, packaged up into an injectable interface. UserDataSource val users: Flow<Map<UserHandle, User>> fun isAvailable(@UserIdInt userId: Int): Flow<Boolean> Along with an interface and implementation this change introduces a data model, [User] to abstract from platform internal types. Bug: 309960444 Test: atest FakeUserManagerTest UserDataSourceImplTest Change-Id: I46681e5f5b40c0720f4b99c1bb13d05ab5da4211
2023-11-03Merge changes If064e760,Idb7a269c into main Govinda Wasserman
* changes: Moves AnnotatedUserHandles to ActivityLogic Moves theme and profile switch message to ActivityLogic
2023-11-01Moves AnnotatedUserHandles to ActivityLogic Govinda Wasserman
Also creates test activity logic for wrapper activities to be compatible with the ActivityLogic structure. Test: atest com.android.intentresolver.v2 BUG: 302113519 Change-Id: If064e76015e90fa98d9e41fb3c8f38b93ccae789
2023-11-01Adds a MockSettings default arg and a throwing default Answer mrenouf
Allows configuring a mock with different default settings while still using a fluent Kotlin friendly syntax. Also adds THROWS_EXCEPTION, which can be used as a default answer within MockSettings: mock<Context>(withSettings().defaultAnswer(THROWS_EXCEPTION) Change-Id: I8aadc5da5aaaff865a7a163dd76ea047b61fd2d6
2023-10-26Use CoroutineScope as a depenency instead of Lifecycle Andrey Epin
In content preview classes, Lifecycele was used as coroutine provider. This change makes CoroutineScope as a depenedency for all those classes. Test: atest IntentResolverUnitTests Change-Id: I2d9f07a54d9bb5b56b20c19a821e4626c86da472
2023-10-19Address test flakyness Andrey Epin
The tests sill remains undeterministic (we'd need some structural changes in the app before we'd be able to change that) so the change just increases timeouts. launchActivityWithTimeout method is removed, the test timeout is used instead as an equal but more simple solution. Bug: 304822572 Test: atest IntentResolverUnitTests Change-Id: Ibd91f1c02f17fe49040182dd589bc9abb3d5308f
2023-10-16Merge "Replace array of strings with a class" into main Andrey Yepin
2023-10-11Replace array of strings with a class Andrey Epin
Bug: 285314844 Test: presubmits, funtionalityf smoke tests Change-Id: Ic2226af153850c6855c08ca20063fcc65c8b958e
2023-10-10Adjust Android.bp formatting to match upstream cleanups. Krzysztof Kosiński
Bug: 255714762 Test: presubmit Change-Id: I98872680c2294353022f09ea5cd01cc048f04e12
2023-10-10Merge "Inject ComponentNames for image editor and nearby share" into main Mark Renouf
2023-10-10Inject ComponentNames for image editor and nearby share Mark Renouf
Adds a SecureSettings fake Adds test coverage for new modules Removes another overload from ChooserActivityWrapper Uses @BindValue in tests to alter the configured editor component Test: atest --test-mapping packages/modules/IntentResolver Bug: 300157408 Bug: 302113519 Change-Id: Ie7d5fe12ad0d8e7fd074154641de35fe89d50ce6
2023-10-09Fix ChooserActionFactoryTest Andrey Epin
Fix: 297551329 Test: atest IntentResolverUnitTests:ChooserActionFactoryTest Change-Id: I0241f840a3add9c433b312f440d5b12e9129ad30
2023-10-05`showEmptyState()` -> EmptyStateUiHelper Joshua Trask
As part of ongoing work to pull low-level empty state responsibilities out of the pager adapter, this CL generally replicates the change prototyped in ag/24516421/5..7, in smaller incremental steps to "show the work." As originally described in that CL: "... moves most of the low-level logic of `showEmptyState()` into the UI helper. (...) also has the UI helper take responsibility for setting the visibility of the main "list view" in sync (opposite of) the empty state visibility." As presented in this CL, the "incremental steps" per-snapshot are: 1. Extract most of the implementation directly to the new method at `EmptyStateUiHelper.showEmptyState()`. The general functionality is covered by existing integration tests (e.g., commenting-out the new method body causes `UnbundledChooserActivityWorkProfileTest` to fail). New `EmptyStateUiHelper` unit tests cover finer points of the empty-state "button" conditions, and I've added a TODO comment at one place legacy behavior seemingly may not align with the original developer intent. 2. Also make the UI helper responsible for propagating empty-state visibility changes back to the main list view (hiding the main list when we show an empty state, and restoring it when the empty state is hidden). 3. Look up all the sub-views during `EmptyStateUiHelper` construction so we don't have to keep repeating their View IDs throughout. 4. Tighten visibility on `EmptyStateUiHelper.resetViewVisibilities()` now that it's a private `showEmptyState()` implementation detail (updated to package-protected/visible-for-testing). Also move the method to the end of the class (after all the public methods). Bug: 302311217 Test: IntentResolverUnitTests Change-Id: Iac0cf3d62e2c3bf22afa6a2796ae4e731b706c02
2023-10-05"Bottom padding overrides" -> EmptyStateUiHelper Joshua Trask
As part of ongoing work to pull low-level empty state responsibilities out of the pager adapter, this CL generally replicates the change prototyped in ag/24516421/4..5, in smaller incremental steps to "show the work." As originally described in that CL: "... moves ownership/usage of the 'container bottom padding override supplier' over to the UI helper; this PagerAdapter dependency is really only used in empty-state logic, so it can be handed over to the extracted component *instead of* retaining it as an ivar in the PagerAdapter." As presented in this CL, the "incremental steps" per-snapshot are: 1. Move `getActiveEmptyStateView()` from `ChooserActivity` to `MultiProfilePagerAdapter`, and expose it in favor of the broader `getEmptyStateView()` method that `ChooserActivity` previously used to implement the lower-level logic. 2. Remove `MultiProfilePagerAdapter.setupContainerPadding()` parameters since they're just derived from a combination of a single hard-coded (resource) symbol, and a concern that already belonged to the pager-adapter (`getActiveEmptyStateView()`). Switch tests to using one of our real layouts so that we can find an empty-state container with the expected View ID. Also update method visibility to show `setupContainerPadding()` isn't intended to be overridden in the more-modern "generic pager" design, and update Javadoc accordingly. 3. Inline `ChooserMultiProfilePagerAdapter.setupContainerPadding()` as part of its `setEmptyStateBottomOffset()`, since the latter method is never called anywhere else (and both concerns already belonged to the specialized pager-adapter). 4. Refactor the internal `setupContainerPadding()` to operate on profile descriptors instead of container Views. This is based on the observation that both callers of `setupContainerPadding()` were passing containers that they had to query from the descriptor's empty-state view anyways, and the lookup used the same View ID in both cases. This change encapsulates those shared concerns at a higher level of abstraction. 5. Move the implementation logic of `setupContainerPadding()` into the descriptor inner-class; given the override-supplier, the rest of the operation can be implemented just using the info available to the descriptor. 6. Move ownership of the override-supplier into the descriptor (to be shared among all descriptor instances). The outer pager-adapter had no remaining need to reference the supplier, and we can easily confirm that this results in `setupContainerPadding()` calls for each descriptor instance using the same supplier instance they would've used before. 7. Moves implementation logic (including [shared] ownership of the override-supplier) from the descriptor down to the empty-state helper which now encapsulates the entire `setupContainerPadding()` operation with zero args. This may require *slightly* more of a leap-of-faith than the other "steps," but note the extensive test coverage: the existing `MultiProfilePagerAdapterTest` covers this exact functionality as integrated into a broader config; parallel unit tests are newly-added in `EmptyStateUiHelper`; and even our "broad-scope" integration tests exercise empty-state logic to _some_ degree. 8. Inlines some client usages to simplify scaffolding that we don't really need after the earlier refactoring changes. Bug: 302311217 Test: IntentResolverUnitTests Change-Id: Icc460ede5b8a0314d5c807dd884e6e2b7044bee9
2023-10-04`v2` boilerplate for ongoing empty-state work. Joshua Trask
Just cutting over to our new experiment infrastructure before I continue porting over the changes that were originally prototyped in ag/24516421. Bug: 302311217 Test: IntentResolverUnitTests Change-Id: Ied1843bee2be6ffb42ba4f539f6168a9d07a77d9
2023-10-03Hard fork of the ChoserActivity and ResolverActivity Govinda Wasserman
The forked versions are flag guarded by the ChooserSelector. Test: atest com.android.intentresolver Test: adb shell pm resolve-activity -a android.intent.action.CHOOSER Test: Observe that the action resolves to .ChooserActivity Test: adb shell device_config put intentresolver \ com.android.intentresolver.flags.modular_framework true Test: Reboot device Test: adb shell pm resolve-activity -a android.intent.action.CHOOSER Test: Observe that the action resolves to .v2.ChooserActivity BUG: 302113519 Change-Id: I59584ed4649fca754826b17055a41be45a32f326
2023-09-29Merge "Introduce EmptyStateUiHelper (& initial tests)" into main Joshua Trask
2023-09-29Introduce EmptyStateUiHelper (& initial tests) Joshua Trask
Based on prototype work in ag/24516421, this CL introduces a new component to handle the empty-state UI implementation details that had previously been implemented in `MultiProfilePagerAdapter`, since those details significantly clutter the implementation of that adapter's other responsibilities. As in ag/24516421 patchset #4, this just sets up the boilerplate and kicks off with some "low-hanging-fruit" operations. Follow-up CLs will continue migrating these responsibilities as in ag/24516421 (except with more incremental testing). Bug: 302311217 Test: IntentResolverUnitTests, CtsSharesheetDeviceTest Change-Id: Ie9bb7f4e97836321521c3cf13c77cafc97b1a461
2023-09-29A workaround for ChooserActivity memory leak Andrey Epin
Add ScopedAppTargetListCallback class to wrap AppPredictor callbacks that breaks the callback reference chain when the specified scope gets closed. Bug: 290971946 Test: Launch Chooser multiple times in a row, collect heapdump with a forced garbage collection, verify that: * there are no ChooserActivity objects in the dump; * there are multiple ScopedAppTargetListCallback instances in the dump with AppPredictor$CallbackWrapper in their GC root path. Test: manual functionality smoke tests: activity configuration changes, pinning targets (all triggers content reloading). Test: unit tests Change-Id: I5099eb7527098a90b3e00bb848eb41e2bc7d14d6
2023-09-27Merge "Add unit tests for initial intents in Resolver and Chooser adapters" ↵ Treehugger Robot
into main
2023-09-27Merge "Begin extracting `emptystate` module." into main Treehugger Robot
2023-09-27Add unit tests for initial intents in Resolver and Chooser adapters Andrey Epin
Plus some trivial changes to improve code readability Test: atest IntentResolverUnitTests:ResolverListAdapterTest Test: atest IntentResolverUnitTests:ChooserListAdapterDataTest Change-Id: Id32460fb3ea1d8a706e48361c9baa8cce67fd46f
2023-09-27Begin extracting `emptystate` module. Joshua Trask
This CL just contains the initial code-moves to group relevant classes (including some inner classes/interfaces that are being pulled out of `MultiProfilePagerAdapter`), without any other anticipated fixes or reorganization. This corresponds to snapshots 1-3 of the prototype ag/24516421 (to be followed with the other work that was started in that CL). Bug: 302311217 Test: IntentResolverUnitTests, CtsSharesheetDeviceTest Change-Id: If82a761193f6ff0605c5a46c106f7c95699350c0
2023-09-26Merge "ResolverListAdapter: Switch `Handler`->`Executor`" into main Joshua Trask
2023-09-26Merge "Merge the `MultiProfilePagerAdapter` base classes" into main Joshua Trask
2023-09-26Merge the `MultiProfilePagerAdapter` base classes Joshua Trask
That is, this CL consolidates `GenericMultiProfilePagerAdapter` up into the base `AbstractMultiProfilePagerAdapter` (and renames to drop the prefixes). This advances an in-progress refactoring to simplify these classes (as in an earlier `GenericMultiProfilePagerAdapter` TODO comment when that class was first introduced). This prepares for other upcoming work in the base class (especially in service of "private space" support) since the responsibilities were unclear and arbitrarily split between these two bases, which had no other direct clients/subclasses (i.e., this CL is exactly equivalent to the earlier code, but removes a class from the hierarchy). I've also started a little bit of cleanup around method visibility but left much of that work out-of-scope for now. Test: IntentResolverUnitTests / CtsSharesheetDeviceTest Change-Id: I073e0bec5764ea16736af585af0bc9f744089d03
2023-09-26ResolverListAdapter: Switch `Handler`->`Executor` Joshua Trask
With the new `mDestroyed` bookkeeping in ag/24854314, we no longer need the richer (but less-testable/etc) API of a `Handler`. In the first snapshot, this retains the ad-hoc flow control mechanisms that direct the `testPostListReadyAtEndOfRebuild_` tests to show the direct before-and-after equivalence against the `Handler` model. All the existing tests still pass on the new code. The second snapshot removes those ad-hoc mechanisms because the tests now have complete control of the execution via `TestExecutor`. Bug: (general code cleanup) Test: `IntentResolverUnitTests` / `CtsSharesheetDeviceTest` Change-Id: I3063d45aedec47a81bf9bc7f76c26873de1383af
2023-09-25Merge "For consistency, stop throttling "list ready" CBs." into main Treehugger Robot
2023-09-25For consistency, stop throttling "list ready" CBs. Joshua Trask
This change is best understood through the newly-introduced `testPostListReadyAtEndOfRebuild_` tests: 1. The `synchronous` and `stages` variants pass both before and after this change, to show the expected "normal" behavior. 2. The `queued` variant exercises the hypothetical bug that motivated this change; it only passes once the legacy "throttling" condition is removed in this CL. 3. The `skippedIfStillQueuedOnDestroy` variant covers a side-effect of the fix. The original implementation had logic for this "skipping" condition (and presumably would've passed this new test as-written), but because the fix relaxes the invariant where we can have only a single "active" callback instance at a time, I also had to introduce the new `mDestroyed` condition to effect the same high-level "cancellation" behavior. (This also addresses a minor theoretical bug where the "destroy" could race against our internal two-stage asynchronous flow, such that we'd end up posting the follow-up callback to the handler after we'd supposedly already been destroyed. I didn't think it was important to test for this bug separately from the other coverage of the `mDestroyed` condition.) -- This CL removes a "throttling" condition that was unneeded, but which could cause a hypothetical bug (reproducible in tests). The original condition prevented list-ready messages if we'd already had one posted in the queue (but not yet processed); however, there was no check that the messages had the same parameters to indicate "partial" vs. "complete" progress. Since the legacy mechanism favored the earlier messages, we could end up dropping the one-off "completion" message where our listener actually does work -- i.e., if we had to drop messages, this is exactly the one we would want *not* to drop. I believe this "throttling" mechanism was likely an optimization to support the legacy `ChooserTargetService` design; the simplified newer design requests fewer callbacks and so the throttling should rarely come into play (but presents a bigger risk whenever it might). Even in the older design, I suspect there would've been a risk of the same "dropped completion" bug. And, of course, it's nice to "simplify" by removing this condition, even if it *weren't* strictly harmful. Update: the second snapshot removes the old "callback removal" on destroy, since the new `mDestroyed` condition gives effectively the same behavior. Technically that's the only reason we depended on `Handler` and we could now switch to using an `Executor` or etc -- but I definitely want to keep that update to a separate CL. Bug: as described above Test: IntentResolverUnitTests, CtsSharesheetDeviceTest Change-Id: Ifda9dc9a8ac8512d241e15fe52f24c3dea5bd9e7
2023-09-22Merge "Unit tests for GenericMultiProfilePagerAdapter" into main Treehugger Robot
2023-09-22Unit tests for GenericMultiProfilePagerAdapter Joshua Trask
This only covers the most salient functionality since many of the implementation details are already in line to be extracted to separate components anyways. The tests are being provided in advance of a refactoring CL to merge this up into the ("Abstract" pager) base in ag/24512960. Bug: 286249609 Test: (this is the test) Change-Id: I753e2d80639865a3c66a94b5e0a08e4be88654b3
2023-09-21Merge "Load app target labels explicitly" into main Treehugger Robot
2023-09-20Merge "Make preview scrollable under a feature flag." into main Andrey Epin
2023-09-20Merge "Add headline view argument to content preview UI" into main Andrey Epin
2023-09-19Make preview scrollable under a feature flag. Andrey Epin
Base feature implementation controlled by a flag. A few issues are known and will be addressed separately. Known issues: * No (dis)appearance animation for the A-Z targets divider bar. Bug: 287102904 Test: Enabled the flag programmatically and test the new functionality. Manually test for possible regressions with the unset flag. Test: atest com.android.intentresolver.contentpreview Test: atest IntentResolverUnitTests:UnbundledChooserActivityTest Change-Id: I8273cf365a1e00b1acff4030086f1a044ad7531f
2023-09-18Load app target labels explicitly Andrey Epin
DisplayResolveInfo#getDisplayLabel contains a logic to load the label if it is missing and the majority of app targets in Chooser are loaded this way. This CL: * removes label loading logic from DisplayResolveInfo; * adds explicit label loading with TargetDataLoader, where it's needed; * wrap some of the view related code blocks from ChooserListAdapter#onBindView into ViewHoder methods to reduce branching in the method and make it easier to read. The legacy DisplayResolveInfo lable-loading logic is effectively replaced with LoadLabelTaks's logic, the one that is used by resolver. Bug: 289264582 Test: manual testing: labes loading, targets groupping, targets pinning. Change-Id: I86814b5a4c67bf117fb1ea28c1d9980b5cf28ef5
2023-09-18Add ResolverListAdapter unit tests Andrey Epin
Replace AsyncTask usage with an background executor and posting on a main thread hanler to facilitate testing. Tests are mostly around targets resolution logic in the adapter. Test: atest IntentResolverUnitTests:ResolverListAdapterTest Change-Id: I7af047226aa718ca3052aa4284d1e9d2a4c43ded
2023-09-16Add headline view argument to content preview UI Andrey Epin
"Sticky" headline is one of the requirements of the scrollable preview feature. Currently headling row is included in every preview type we have and to be "sticky" it should be moved out of all of them. This change is a preparation work that makes all of the preview UI controllers aware of a possible external headline row (but no actual external headline view is used). Bug: 287102904 Test: manual testing of all preivew types checking that there are no regressions Test: atest com.android.intentresolver.contentpreview Change-Id: Ib6110aaa82246e3354fdce18f431ab1c116e7b73
2023-09-14Merge "Switch activities to AnnotatedUserHandles fully" into main Joshua Trask
2023-09-14Merge "Injects EventLog, provides FakeEventLog within tests" into main Mark Renouf
2023-09-14Merge changes I13fbf290,I7440a6bb into main Mark Renouf
* changes: Switches to HiltTestApplication in tests. Extract an interface for EventLog, rename implementation
2023-09-14Injects EventLog, provides FakeEventLog within tests Mark Renouf
Using Hilt we are able to declaratively replace modules within integration tests. This is the first such instance within IntentResolver. Scope: An InstanceIdSequence in @Singleton scope provides a new InstanceId value to each EventLog created. EventLog is @ActivityScoped or one-per-activity instance. This matches the existing behavior. By adding [TestEventLogModule], all integration tests are now using a FakeEventLog by default (migrated away from 'override data' scheme). Bug: 299610743 Bug: 300157408 Test: atest IntentResolverUnitTests Change-Id: I33d6f4d1241a890ab88b631859652117ce20f7be