66import { ColorThemeData } from 'vs/workbench/services/themes/common/colorThemeData' ;
77import * as assert from 'assert' ;
88import { ITokenColorCustomizations } from 'vs/workbench/services/themes/common/workbenchThemeService' ;
9- import { TokenStyle , TokenStyleBits } from 'vs/platform/theme/common/tokenStyleRegistry' ;
9+ import { TokenStyle , TokenStyleBits , comments , variables , types , functions , keywords , numbers , strings } from 'vs/platform/theme/common/tokenStyleRegistry' ;
1010import { Color } from 'vs/base/common/color' ;
1111import { isString } from 'vs/base/common/types' ;
12+ import { FileService } from 'vs/platform/files/common/fileService' ;
13+ import { NullLogService } from 'vs/platform/log/common/log' ;
14+ import { DiskFileSystemProvider } from 'vs/platform/files/node/diskFileSystemProvider' ;
15+ import { Schemas } from 'vs/base/common/network' ;
16+ import { URI } from 'vs/base/common/uri' ;
17+ import { getPathFromAmdModule } from 'vs/base/common/amd' ;
1218
1319function ts ( foreground : string | undefined , styleFlags : number | undefined ) : TokenStyle {
1420 const foregroundColor = isString ( foreground ) ? Color . fromHex ( foreground ) : undefined ;
@@ -24,14 +30,45 @@ function assertTokenStyle(expected: TokenStyle | undefined | null, actual: Token
2430}
2531
2632
33+
2734suite ( 'Themes - TokenStyleResolving' , ( ) => {
35+ const fileService = new FileService ( new NullLogService ( ) ) ;
36+ const diskFileSystemProvider = new DiskFileSystemProvider ( new NullLogService ( ) ) ;
37+ fileService . registerProvider ( Schemas . file , diskFileSystemProvider ) ;
38+
39+
40+ test ( 'color defaults - monokai' , async ( ) => {
41+ const themeData = ColorThemeData . createUnloadedTheme ( 'foo' ) ;
42+ const themeLocation = getPathFromAmdModule ( require , '../../../../../../../extensions/theme-monokai/themes/monokai-color-theme.json' ) ;
43+ themeData . location = URI . file ( themeLocation ) ;
44+ await themeData . ensureLoaded ( fileService ) ;
45+
46+ assert . equal ( themeData . isLoaded , true ) ;
47+
48+ let tokenStyle ;
2849
29- // const fileService = new FileService(new NullLogService());
30- // const diskFileSystemProvider = new DiskFileSystemProvider(new NullLogService());
31- // fileService.registerProvider(Schemas.file, diskFileSystemProvider);
50+ tokenStyle = themeData . getTokenStyle ( comments ) ;
51+ assertTokenStyle ( tokenStyle , ts ( '#75715E' , 0 ) ) ;
3252
53+ tokenStyle = themeData . getTokenStyle ( variables ) ;
54+ assertTokenStyle ( tokenStyle , ts ( '#F8F8F2' , 0 ) ) ;
3355
56+ tokenStyle = themeData . getTokenStyle ( types ) ;
57+ assertTokenStyle ( tokenStyle , ts ( '#A6E22E' , TokenStyleBits . UNDERLINE ) ) ;
3458
59+ tokenStyle = themeData . getTokenStyle ( functions ) ;
60+ assertTokenStyle ( tokenStyle , ts ( '#A6E22E' , 0 ) ) ;
61+
62+ tokenStyle = themeData . getTokenStyle ( strings ) ;
63+ assertTokenStyle ( tokenStyle , ts ( '#E6DB74' , 0 ) ) ;
64+
65+ tokenStyle = themeData . getTokenStyle ( numbers ) ;
66+ assertTokenStyle ( tokenStyle , ts ( '#AE81FF' , 0 ) ) ;
67+
68+ tokenStyle = themeData . getTokenStyle ( keywords ) ;
69+ assertTokenStyle ( tokenStyle , ts ( '#F92672' , 0 ) ) ;
70+
71+ } ) ;
3572
3673 test ( 'resolve resource' , async ( ) => {
3774 const themeData = ColorThemeData . createLoadedEmptyTheme ( 'test' , 'test' ) ;
0 commit comments