55
66import assert from 'assert' ;
77import { Color } from '../../../../../../base/common/color.js' ;
8+ import { toDisposable } from '../../../../../../base/common/lifecycle.js' ;
89import { ensureNoDisposablesAreLeakedInTestSuite } from '../../../../../../base/test/common/utils.js' ;
910import { ColorScheme } from '../../../../../../platform/theme/common/theme.js' ;
1011import { IColorTheme } from '../../../../../../platform/theme/common/themeService.js' ;
1112import { chatDictationActiveMicGlow , chatVoiceGlowBaseColor , chatVoiceSpeakingGlow } from '../../../common/widget/chatColors.js' ;
1213import { resolveDictationMicAccent } from '../../../browser/speechToText/dictationMicGlow.js' ;
1314import { isGlowingVoiceState , GlowThemeKind , resolveVoiceGlowColors , resolveVoiceRimAccent , VOICE_GLOW_SPEAKING_HUE_SHIFT } from '../../../browser/voiceClient/voiceGlow.js' ;
15+ import { createVoiceGlowController } from '../../../browser/voiceClient/voiceGlowController.js' ;
1416
1517suite ( 'VoiceGlow' , ( ) => {
16- ensureNoDisposablesAreLeakedInTestSuite ( ) ;
18+ const disposables = ensureNoDisposablesAreLeakedInTestSuite ( ) ;
1719
1820 test ( 'only the talking states glow' , ( ) => {
1921 const states = [ 'idle' , 'listening' , 'speaking' , 'processing' , 'error' ] as const ;
@@ -23,6 +25,27 @@ suite('VoiceGlow', () => {
2325 ) ;
2426 } ) ;
2527
28+ test ( 'renders in an auxiliary owner document' , ( ) => {
29+ const iframe = document . createElement ( 'iframe' ) ;
30+ document . body . appendChild ( iframe ) ;
31+ disposables . add ( toDisposable ( ( ) => iframe . remove ( ) ) ) ;
32+
33+ const target = iframe . contentDocument ! . createElement ( 'div' ) ;
34+ iframe . contentDocument ! . body . appendChild ( target ) ;
35+ const controller = disposables . add ( createVoiceGlowController ( target ) ) ;
36+ controller . render ( 'listening' , 0.5 , false ) ;
37+
38+ assert . deepStrictEqual ( {
39+ active : target . classList . contains ( 'voice-active' ) ,
40+ listening : target . classList . contains ( 'voice-listening' ) ,
41+ slots : target . querySelectorAll ( '.voice-glow-slot' ) . length ,
42+ } , {
43+ active : true ,
44+ listening : true ,
45+ slots : 2 ,
46+ } ) ;
47+ } ) ;
48+
2649 test ( 'derives the speaking accent from the theme base color' , ( ) => {
2750 const base = Color . fromHex ( '#58A6FF' ) ;
2851 const colors = resolveVoiceGlowColors ( { getColor : id => id === chatVoiceGlowBaseColor ? base : undefined } ) ;
0 commit comments