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
87 lines
2.4 KiB
Plaintext
87 lines
2.4 KiB
Plaintext
// Copyright (C) 2022 The Android Open Source Project
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
package {
|
|
// See: http://go/android-license-faq
|
|
// A large-scale-change added 'default_applicable_licenses' to import
|
|
// all of the 'license_kinds' from "frameworks_base_packages_SystemUI_license"
|
|
// to get the below license kinds:
|
|
// SPDX-license-identifier-Apache-2.0
|
|
default_applicable_licenses: ["frameworks_base_packages_SystemUI_license"],
|
|
}
|
|
|
|
android_library {
|
|
name: "SystemUIComposeGalleryLib",
|
|
manifest: "AndroidManifest.xml",
|
|
|
|
srcs: [
|
|
"src/**/*.kt",
|
|
":SystemUI-tests-utils",
|
|
],
|
|
|
|
resource_dirs: [
|
|
"res",
|
|
],
|
|
|
|
static_libs: [
|
|
"SystemUI-core",
|
|
"SystemUIComposeCore",
|
|
"SystemUIComposeFeatures",
|
|
|
|
"androidx.compose.runtime_runtime",
|
|
"androidx.compose.material3_material3",
|
|
"androidx.compose.material_material-icons-extended",
|
|
"androidx.activity_activity-compose",
|
|
"androidx.navigation_navigation-compose",
|
|
|
|
"androidx.appcompat_appcompat",
|
|
|
|
// TODO(b/240431193): Remove the dependencies and depend on
|
|
// SystemUI-test-utils directly.
|
|
"androidx.test.runner",
|
|
"mockito-target-extended-minus-junit4",
|
|
"testables",
|
|
"truth-prebuilt",
|
|
"androidx.test.uiautomator",
|
|
"kotlinx_coroutines_test",
|
|
],
|
|
|
|
libs: [
|
|
"android.test.mock",
|
|
],
|
|
|
|
kotlincflags: ["-Xjvm-default=all"],
|
|
}
|
|
|
|
android_app {
|
|
name: "SystemUIComposeGallery",
|
|
defaults: ["platform_app_defaults"],
|
|
manifest: "app/AndroidManifest.xml",
|
|
|
|
static_libs: [
|
|
"SystemUIComposeGalleryLib",
|
|
],
|
|
|
|
platform_apis: true,
|
|
system_ext_specific: true,
|
|
certificate: "platform",
|
|
privileged: true,
|
|
|
|
optimize: {
|
|
proguard_flags_files: ["proguard-rules.pro"],
|
|
},
|
|
|
|
dxflags: ["--multi-dex"],
|
|
}
|