1 /* 2 * Copyright (C) 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package com.android.server.bluetooth.test 17 18 import com.android.server.bluetooth.Log 19 import com.google.common.truth.Truth.assertThat 20 import org.junit.Test 21 import org.junit.runner.RunWith 22 import org.robolectric.RobolectricTestRunner 23 24 private const val TAG: String = "LogTest" 25 26 @RunWith(RobolectricTestRunner::class) 27 class LogTest { 28 @Test log_verbosenull29 fun log_verbose() { 30 Log.v(TAG, "Logging verbose") 31 } 32 33 @Test log_debugnull34 fun log_debug() { 35 Log.d(TAG, "Logging debug") 36 } 37 38 @Test log_infonull39 fun log_info() { 40 Log.i(TAG, "Logging info") 41 } 42 43 @Test log_warningnull44 fun log_warning() { 45 Log.w(TAG, "Logging warning") 46 } 47 48 @Test log_warningThrowablenull49 fun log_warningThrowable() { 50 Log.w(TAG, "Logging warning", RuntimeException("With a Throwable")) 51 } 52 53 @Test log_errornull54 fun log_error() { 55 Log.e(TAG, "Logging error") 56 } 57 58 @Test log_errorThrowablenull59 fun log_errorThrowable() { 60 Log.e(TAG, "Logging error... ", RuntimeException("With a Throwable")) 61 } 62 63 @Test log_timeToStringWithZonenull64 fun log_timeToStringWithZone() { 65 assertThat(Log.timeToStringWithZone(123456789)).isEqualTo("01-02 02:17:36.789") 66 } 67 } 68