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

Commit 45de4fd9 authored by William Escande's avatar William Escande Committed by Gerrit Code Review
Browse files

Merge changes Ib20e35aa,Idd08f2f4 into main

* changes:
  SystemServer: Nit change in the test logging
  SystemServer: Add test for the unified Logs
parents 8fa9997b 889976d4
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -163,6 +163,7 @@ android_robolectric_test {
        "src/AdapterState.kt",
        "src/AdapterStateTest.kt",
        "src/Log.kt",
        "src/LogTest.kt",
        "src/RadioModeListener.kt",
        "src/RadioModeListenerTest.kt",
        "src/airplane/ModeListener.kt",
+7 −1
Original line number Diff line number Diff line
@@ -13,9 +13,11 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.android.server.bluetooth
package com.android.server.bluetooth.test

import android.bluetooth.BluetoothAdapter.STATE_OFF
import com.android.server.bluetooth.BluetoothAdapterState
import com.android.server.bluetooth.Log
import com.google.common.truth.Truth.assertThat
import kotlin.time.Duration.Companion.days
import kotlinx.coroutines.CoroutineStart
@@ -24,7 +26,9 @@ import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.test.runTest
import kotlinx.coroutines.yield
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.rules.TestName
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner

@@ -33,9 +37,11 @@ import org.robolectric.RobolectricTestRunner
class BluetoothAdapterStateTest {

    lateinit var mState: BluetoothAdapterState
    @JvmField @Rule val testName = TestName()

    @Before
    fun setUp() {
        Log.i("BluetoothAdapterStateTest", "\t--> setup of " + testName.getMethodName())
        mState = BluetoothAdapterState()
    }

service/src/LogTest.kt

0 → 100644
+56 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 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.server.bluetooth.test

import com.android.server.bluetooth.Log
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner

private const val TAG: String = "LogTest"

@RunWith(RobolectricTestRunner::class)
class LogTest {
    @Test
    fun log_verbose() {
        Log.v(TAG, "Logging verbose")
    }

    @Test
    fun log_debug() {
        Log.d(TAG, "Logging debug")
    }

    @Test
    fun log_info() {
        Log.i(TAG, "Logging info")
    }

    @Test
    fun log_warning() {
        Log.w(TAG, "Logging warning")
    }

    @Test
    fun log_error() {
        Log.e(TAG, "Logging error")
    }

    @Test
    fun log_errorThrowable() {
        Log.e(TAG, "Logging error… ", RuntimeException("With a Throwable"))
    }
}
+5 −0
Original line number Diff line number Diff line
@@ -20,10 +20,13 @@ import android.content.Context
import android.os.Looper
import android.provider.Settings
import androidx.test.core.app.ApplicationProvider
import com.android.server.bluetooth.Log
import com.android.server.bluetooth.initializeRadioModeListener
import com.google.common.truth.Truth.assertThat
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.rules.TestName
import org.junit.runner.RunWith
import org.mockito.Mockito.times
import org.robolectric.RobolectricTestRunner
@@ -57,6 +60,7 @@ internal fun enableMode(resolver: ContentResolver, looper: Looper, modeKey: Stri
class RadioModeListenerTest {
    private val resolver: ContentResolver =
        ApplicationProvider.getApplicationContext<Context>().getContentResolver()
    @JvmField @Rule val testName = TestName()

    private val looper: Looper = Looper.getMainLooper()

@@ -64,6 +68,7 @@ class RadioModeListenerTest {

    @Before
    public fun setup() {
        Log.i("RadioModeListenerTest", "\t--> setup of " + testName.getMethodName())
        mode = ArrayList()
    }

+1 −2
Original line number Diff line number Diff line
@@ -71,8 +71,7 @@ class ModeListenerTest {

    @Before
    public fun setup() {
        Log.i("AirplaneModeListenerTest", "-------------------------------------------------------")
        Log.i("AirplaneModeListenerTest", "--> Start of test: " + testName.getMethodName())
        Log.i("AirplaneModeListenerTest", "\t--> setup of " + testName.getMethodName())

        // Most test will expect the system to be sensitive + off
        enableSensitive()
Loading