Add a test for webcontents.printerList
.
This commit is contained in:
parent
cba5e96496
commit
dfcc882dcc
2 changed files with 21 additions and 4 deletions
|
@ -1282,10 +1282,10 @@ void WebContents::Print(mate::Arguments* args) {
|
|||
|
||||
std::vector<printing::PrinterBasicInfo> WebContents::GetPrinterList(
|
||||
mate::Arguments* args) {
|
||||
std::vector<printing::PrinterBasicInfo> printerList;
|
||||
auto printBackend = printing::PrintBackend::CreateInstance(nullptr);
|
||||
printBackend->EnumeratePrinters(&printerList);
|
||||
return printerList;
|
||||
std::vector<printing::PrinterBasicInfo> printers;
|
||||
auto print_backend = printing::PrintBackend::CreateInstance(nullptr);
|
||||
print_backend->EnumeratePrinters(&printers);
|
||||
return printers;
|
||||
}
|
||||
|
||||
void WebContents::PrintToPDF(const base::DictionaryValue& setting,
|
||||
|
|
|
@ -1114,6 +1114,23 @@ describe('BrowserWindow module', function () {
|
|||
})
|
||||
})
|
||||
|
||||
it('can get printer list', function (done) {
|
||||
w.destroy()
|
||||
w = new BrowserWindow({
|
||||
show: false,
|
||||
webPreferences: {
|
||||
sandbox: true,
|
||||
preload: preload
|
||||
}
|
||||
})
|
||||
w.loadURL('data:text/html,%3Ch1%3EHello%2C%20World!%3C%2Fh1%3E')
|
||||
w.webContents.once('did-finish-load', function () {
|
||||
const pl = w.webContents.printerList()
|
||||
assert.equal(Array.isArray(pl), true)
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('can print to PDF', function (done) {
|
||||
w.destroy()
|
||||
w = new BrowserWindow({
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue