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

Commit ca24c392 authored by andrewxu's avatar andrewxu
Browse files

Avoid mock factory in Kosmos.shadeHeaderViewModel

It is meaningless to use a mock factory in Kosmos.shadeHeaderViewModel.
Because test will crash if the mock factory is called to create an
instance.

This CL introduces Kosmos.tintedIconManagerFactory and
Kosmos.batteryMeterViewControllerFactory.

Flag: TEST_ONLY
Bug: 395622173
Change-Id: I41cbc50b4de157895b8bd5bb535a517c84c8f754
parent b1d4e2ef
Loading
Loading
Loading
Loading
+41 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 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.battery

import android.os.Handler
import android.test.mock.MockContentResolver
import com.android.systemui.flags.fake
import com.android.systemui.flags.featureFlagsClassic
import com.android.systemui.kosmos.Kosmos
import com.android.systemui.settings.userTracker
import com.android.systemui.statusbar.policy.batteryController
import com.android.systemui.statusbar.policy.configurationController
import com.android.systemui.tuner.tunerService
import org.mockito.kotlin.mock

val Kosmos.batteryMeterViewControllerFactory: BatteryMeterViewController.Factory by
Kosmos.Fixture {
    BatteryMeterViewController.Factory(
        userTracker,
        configurationController,
        tunerService,
        mock<Handler>(),
        MockContentResolver(),
        featureFlagsClassic.fake,
        batteryController
    )
}
 No newline at end of file
+4 −4
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@
package com.android.systemui.shade.ui.viewmodel

import android.content.applicationContext
import com.android.systemui.battery.BatteryMeterViewController
import com.android.systemui.battery.batteryMeterViewControllerFactory
import com.android.systemui.broadcast.broadcastDispatcher
import com.android.systemui.kosmos.Kosmos
import com.android.systemui.plugins.activityStarter
@@ -28,7 +28,7 @@ import com.android.systemui.shade.domain.interactor.shadeInteractor
import com.android.systemui.shade.domain.interactor.shadeModeInteractor
import com.android.systemui.statusbar.notification.icon.ui.viewbinder.NotificationIconContainerStatusBarViewBinder
import com.android.systemui.statusbar.phone.ui.StatusBarIconController
import com.android.systemui.statusbar.phone.ui.TintedIconManager
import com.android.systemui.statusbar.phone.ui.tintedIconManagerFactory
import com.android.systemui.statusbar.pipeline.mobile.domain.interactor.mobileIconsInteractor
import com.android.systemui.statusbar.pipeline.mobile.ui.viewmodel.mobileIconsViewModel
import org.mockito.kotlin.mock
@@ -45,8 +45,8 @@ val Kosmos.shadeHeaderViewModel: ShadeHeaderViewModel by
            mobileIconsViewModel = mobileIconsViewModel,
            privacyChipInteractor = privacyChipInteractor,
            clockInteractor = shadeHeaderClockInteractor,
            tintedIconManagerFactory = mock<TintedIconManager.Factory>(),
            batteryMeterViewControllerFactory = mock<BatteryMeterViewController.Factory>(),
            tintedIconManagerFactory = tintedIconManagerFactory,
            batteryMeterViewControllerFactory = batteryMeterViewControllerFactory,
            statusBarIconController = mock<StatusBarIconController>(),
            notificationIconContainerStatusBarViewBinder =
                mock<NotificationIconContainerStatusBarViewBinder>(),
+26 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 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.statusbar.connectivity.ui

import com.android.systemui.kosmos.Kosmos
import org.mockito.kotlin.mock

// NOTE: `mobileContextProvider` is a mock instance.
val Kosmos.mobileContextProvider by
Kosmos.Fixture {
    mock<MobileContextProvider>()
}
 No newline at end of file
+25 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 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.statusbar.phone.ui

import com.android.systemui.kosmos.Kosmos
import org.mockito.kotlin.mock

// NOTE: `statusBarIconController` is a mock instance.
val Kosmos.statusBarIconController by Kosmos.Fixture {
    mock<StatusBarIconControllerImpl>()
}
 No newline at end of file
+31 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 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.statusbar.phone.ui

import com.android.systemui.kosmos.Kosmos
import com.android.systemui.statusbar.connectivity.ui.mobileContextProvider
import com.android.systemui.statusbar.pipeline.mobile.ui.mobileUiAdapter
import com.android.systemui.statusbar.pipeline.wifi.ui.wifiUiAdapter

val Kosmos.tintedIconManagerFactory by
Kosmos.Fixture {
    TintedIconManager.Factory(
        wifiUiAdapter,
        mobileUiAdapter,
        mobileContextProvider,
    )
}
 No newline at end of file
Loading