File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed 
src/test/java/com/google/firebase/ai/type Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -123,6 +123,7 @@ dependencies {
123123  testImplementation(libs.robolectric)
124124  testImplementation(libs.truth)
125125  testImplementation(libs.mockito.core)
126+   testImplementation(libs.mockito.kotlin)
126127
127128  androidTestImplementation(libs.androidx.espresso.core)
128129  androidTestImplementation(libs.androidx.test.junit)
Original file line number Diff line number Diff line change 1+ package  com.google.firebase.ai.type 
2+ 
3+ import  android.content.Context 
4+ import  android.content.pm.PackageManager 
5+ import  com.google.firebase.FirebaseApp 
6+ import  com.google.firebase.ai.util.doBlocking 
7+ import  io.kotest.assertions.throwables.shouldThrow 
8+ import  io.ktor.client.plugins.websocket.testing.* 
9+ import  kotlinx.coroutines.Dispatchers 
10+ import  org.junit.Test 
11+ import  org.mockito.kotlin.* 
12+ 
13+ class  LiveSessionTest  {
14+ 
15+     @Test
16+     fun  `startAudioConversation without permission throws exception`  () =  doBlocking {
17+         val  mockContext =  mock<Context > {
18+             on { checkSelfPermission(android.Manifest .permission.RECORD_AUDIO ) } doReturn PackageManager .PERMISSION_DENIED 
19+         }
20+         val  mockFirebaseApp =  mock<FirebaseApp > {
21+             on { applicationContext } doReturn mockContext
22+         }
23+         val  session =  LiveSession (
24+             session =  EmptyWebSockets .client.session,
25+             blockingDispatcher =  Dispatchers .IO ,
26+             firebaseApp =  mockFirebaseApp
27+         )
28+ 
29+         shouldThrow<PermissionMissingException > {
30+             session.startAudioConversation()
31+         }
32+     }
33+ }
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments