Skip to content

Commit

Permalink
ci: up
Browse files Browse the repository at this point in the history
  • Loading branch information
waitingsong committed Jun 24, 2024
1 parent 8af736f commit fa0f5ed
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 4 deletions.
41 changes: 40 additions & 1 deletion packages/win32-def/test/21.loader-multiple-choice.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
import { load } from '##/lib/loader/loader.js'

import { type Win32Fns, defWin32, defWinspool, WinspoolFns } from './api.helper.js'
import { multipleChoiceMapperList } from './mapper/EnumPrintersW.mapper.js'
import { multipleChoiceMapperList, multipleChoiceMapperSet } from './mapper/EnumPrintersW.mapper.js'


describe(fileShortPath(import.meta.url), () => {
Expand Down Expand Up @@ -56,6 +56,45 @@ describe(fileShortPath(import.meta.url), () => {
assert(printerInfo.Flags === 8388608)
})

it('using fnName+Map (before)', async () => {
const lib = load<WinspoolFns>({
dll: 'winspool.drv',
// @ts-expect-error
dllFuncs: defWinspool,
// multipleChoiceMapperList: multipleChoiceMapperList, // using lib.updateMultipleChoiceMapper() method instead
})
lib.updateMultipleChoiceMapper({
fnName: 'EnumPrintersW',
mapperSet: multipleChoiceMapperSet,
})

const expectName = 'Microsoft Print to PDF'

const level = 1
const flags = PrinterEnumFlags.PRINTER_ENUM_LOCAL
const name = ''
const cbBuf = 4096
assert(cbBuf > 2, 'cbBuf must be > 2')
const pcbNeeded = Buffer.alloc(4)
const pcReturned = Buffer.alloc(4)
const printerInfo = {} as PRINTER_INFO_1_Type

const ret = await lib.EnumPrintersW_Async(
flags,
name,
level,
printerInfo,
cbBuf,
pcbNeeded,
pcReturned,
)
assert(ret, 'EnumPrintersW(PRINTER_INFO_1) failed')
assert(printerInfo.pName === expectName)
assert(printerInfo.pDescription.includes(expectName))
assert(printerInfo.pComment === '')
assert(printerInfo.Flags === 8388608)
})

it('multi params Level=1', async () => {
const lib = load<WinspoolFns>({
dll: 'winspool.drv',
Expand Down
6 changes: 3 additions & 3 deletions packages/win32-def/test/mapper/EnumPrintersW.mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const EnumPrintersW_mapper: MultipleChoiceMapper<Params, DefParamsInput>
}

export const multipleChoiceMapperList: MultipleChoiceMapperList = new Map()
const set: MultipleChoiceMapperSet = new Set()
multipleChoiceMapperList.set(fnName, set)
set.add(EnumPrintersW_mapper)
export const multipleChoiceMapperSet: MultipleChoiceMapperSet = new Set()
multipleChoiceMapperList.set(fnName, multipleChoiceMapperSet)
multipleChoiceMapperSet.add(EnumPrintersW_mapper)

0 comments on commit fa0f5ed

Please sign in to comment.