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

Commit 34463ce1 authored by Luca Zuccarini's avatar Luca Zuccarini Committed by Android (Google) Code Review
Browse files

Merge changes Icaabbd59,Ic04a5e67 into main

* changes:
  3.5 Update StatusBarNotificationActivityStarter.
  3.4 Update ActivityStarterInternal implementations.
parents 549084ff 5c3f6174
Loading
Loading
Loading
Loading
+84 −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

import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.animation.ActivityTransitionAnimator
import kotlin.test.assertEquals
import kotlin.test.assertNotNull
import kotlin.test.assertNull
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.Mock
import org.mockito.MockitoAnnotations
import org.mockito.kotlin.mock
import org.mockito.kotlin.whenever

@SmallTest
@RunWith(AndroidJUnit4::class)
class ActivityStarterUtilsTest : SysuiTestCase() {
    @Mock private lateinit var controller: ActivityTransitionAnimator.Controller

    @Before
    fun setUp() {
        MockitoAnnotations.openMocks(this)
    }

    @Test
    fun addCookieIfNeeded_addsACookie() {
        // GIVEN a controller with no cookie.
        whenever(controller.transitionCookie).thenReturn(null)

        // WHEN addCookieIfNeeded() is called with the given controller.
        val controllerWithCookie = addCookieIfNeeded(controller)

        // THEN the returned controller has a new cookie.
        assertNotNull(controllerWithCookie)
        assertNotNull(controllerWithCookie.transitionCookie)
        assertEquals(
            ActivityTransitionAnimator.TransitionCookie("$controller"),
            controllerWithCookie.transitionCookie,
        )
    }

    @Test
    fun addCookieIfNeeded_doesNotAddACookie_ifControllerIsNull() {
        // WHEN addCookieIfNeeded() is called with a null controller.
        val controllerWithCookie = addCookieIfNeeded(null)

        // THEN the returned controller is also null.
        assertNull(controllerWithCookie)
    }

    @Test
    fun addCookieIfNeeded_doesNotAddACookie_ifControllerAlreadyHasOne() {
        // GIVEN a controller with a cookie
        val cookie = mock<ActivityTransitionAnimator.TransitionCookie>()
        whenever(controller.transitionCookie).thenReturn(cookie)

        // WHEN addCookieIfNeeded() is called with the given controller.
        val controllerWithCookie = addCookieIfNeeded(controller)

        // THEN the returned controller has the same cookie.
        assertNotNull(controllerWithCookie)
        assertNotNull(controllerWithCookie.transitionCookie)
        assertEquals(controller.transitionCookie, controllerWithCookie.transitionCookie)
    }
}
+337 −1

File changed.

Preview size limit exceeded, changes collapsed.

+122 −45

File changed.

Preview size limit exceeded, changes collapsed.

+118 −0

File added.

Preview size limit exceeded, changes collapsed.

+122 −46

File changed.

Preview size limit exceeded, changes collapsed.

Loading