Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 41e20bfc authored by Fabián Kozynski's avatar Fabián Kozynski
Browse files

Fix NewQSTileFactoryKosmos

This Kosmos required a new factory to be defined. When the flag is on,
if this is not defined, it will crash.

Define one using non-mocks when possible.

Test: atest NoLowNumberOfTilesTest
Bug: 332924537
Flag: ACONFIG com.android.systemui.qs_new_tiles DEVELOPMENT
Change-Id: Id68ce7b1b94b5c14edba78d569ab3af59283a11f
parent eab7a6d5
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -35,7 +35,6 @@ import com.android.systemui.plugins.qs.QSFactory
import com.android.systemui.qs.footer.domain.interactor.FooterActionsInteractorImpl
import com.android.systemui.qs.footer.foregroundServicesRepository
import com.android.systemui.qs.footer.ui.viewmodel.FooterActionsViewModel
import com.android.systemui.qs.tiles.di.NewQSTileFactory
import com.android.systemui.security.data.repository.securityRepository
import com.android.systemui.settings.userTracker
import com.android.systemui.statusbar.policy.deviceProvisionedController
@@ -49,7 +48,6 @@ val Kosmos.qsEventLogger: QsEventLoggerFake by Fixture {
    QsEventLoggerFake(uiEventLoggerFake, instanceIdSequenceFake)
}

var Kosmos.newQSTileFactory by Fixture<NewQSTileFactory>()
var Kosmos.qsTileFactory by Fixture<QSFactory>()

val Kosmos.fgsManagerController by Fixture { FakeFgsManagerController() }
+1 −1
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@ import com.android.systemui.kosmos.applicationCoroutineScope
import com.android.systemui.kosmos.testDispatcher
import com.android.systemui.qs.external.customTileStatePersister
import com.android.systemui.qs.external.tileLifecycleManagerFactory
import com.android.systemui.qs.newQSTileFactory
import com.android.systemui.qs.pipeline.data.repository.customTileAddedRepository
import com.android.systemui.qs.pipeline.data.repository.installedTilesRepository
import com.android.systemui.qs.pipeline.data.repository.minimumTilesRepository
@@ -29,6 +28,7 @@ import com.android.systemui.qs.pipeline.data.repository.tileSpecRepository
import com.android.systemui.qs.pipeline.shared.logging.qsLogger
import com.android.systemui.qs.pipeline.shared.pipelineFlagsRepository
import com.android.systemui.qs.qsTileFactory
import com.android.systemui.qs.tiles.di.newQSTileFactory
import com.android.systemui.settings.userTracker
import com.android.systemui.user.data.repository.userRepository

+38 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 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 com.android.systemui.qs.tiles.di

import com.android.systemui.kosmos.Kosmos
import com.android.systemui.qs.tiles.viewmodel.QSTileViewModel
import com.android.systemui.qs.tiles.viewmodel.qSTileConfigProvider
import com.android.systemui.qs.tiles.viewmodel.qsTileViewModelAdaperFactory
import com.android.systemui.util.mockito.mock
import javax.inject.Provider
import org.mockito.Mockito

var Kosmos.newFactoryTileMap by Kosmos.Fixture { emptyMap<String, Provider<QSTileViewModel>>() }

val Kosmos.newQSTileFactory by
    Kosmos.Fixture {
        NewQSTileFactory(
            qSTileConfigProvider,
            qsTileViewModelAdaperFactory,
            newFactoryTileMap,
            mock(Mockito.withSettings().defaultAnswer(Mockito.RETURNS_MOCKS)),
            mock(Mockito.withSettings().defaultAnswer(Mockito.RETURNS_MOCKS)),
        )
    }
+22 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 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 com.android.systemui.qs.tiles.viewmodel

import com.android.systemui.kosmos.Kosmos

val Kosmos.fakeQSTileConfigProvider by Kosmos.Fixture { FakeQSTileConfigProvider() }
var Kosmos.qSTileConfigProvider: QSTileConfigProvider by Kosmos.Fixture { fakeQSTileConfigProvider }
+34 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 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 com.android.systemui.qs.tiles.viewmodel

import com.android.systemui.kosmos.Kosmos
import com.android.systemui.kosmos.applicationCoroutineScope
import com.android.systemui.util.mockito.mock

val Kosmos.qsTileViewModelAdaperFactory by
    Kosmos.Fixture {
        object : QSTileViewModelAdapter.Factory {
            override fun create(qsTileViewModel: QSTileViewModel): QSTileViewModelAdapter {
                return QSTileViewModelAdapter(
                    applicationCoroutineScope,
                    mock(),
                    qsTileViewModel,
                )
            }
        }
    }