mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
refactor: remove redundant NativeImage::GetBitmap() (#46696)
* refactor: remove redundant NativeImage::GetBitmap() * docs: mark NativeImage.getBitmap() as deprecated * have getBitmap() emit a deprecation warning * docs: update obsolete refefence to getBitmap() * test: update obsolete refefences to getBitmap() --------- Co-authored-by: David Sanders <dsanders11@ucsbalum.com>
This commit is contained in:
@@ -4599,7 +4599,7 @@ describe('BrowserWindow module', () => {
|
||||
|
||||
try {
|
||||
const expectedSize = rect.width * rect.height * 4;
|
||||
expect(image.getBitmap()).to.be.an.instanceOf(Buffer).with.lengthOf(expectedSize);
|
||||
expect(image.toBitmap()).to.be.an.instanceOf(Buffer).with.lengthOf(expectedSize);
|
||||
done();
|
||||
} catch (e) {
|
||||
done(e);
|
||||
|
||||
@@ -4,6 +4,7 @@ import { expect } from 'chai';
|
||||
|
||||
import * as path from 'node:path';
|
||||
|
||||
import { expectDeprecationMessages } from './lib/deprecate-helpers';
|
||||
import { ifdescribe, ifit, itremote, useRemoteContext } from './lib/spec-helpers';
|
||||
|
||||
describe('nativeImage module', () => {
|
||||
@@ -78,15 +79,20 @@ describe('nativeImage module', () => {
|
||||
});
|
||||
|
||||
describe('createEmpty()', () => {
|
||||
it('returns an empty image', () => {
|
||||
it('returns an empty image', async () => {
|
||||
const empty = nativeImage.createEmpty();
|
||||
expect(empty.isEmpty()).to.be.true();
|
||||
expect(empty.getAspectRatio()).to.equal(1);
|
||||
expect(empty.toDataURL()).to.equal('data:image/png;base64,');
|
||||
expect(empty.toDataURL({ scaleFactor: 2.0 })).to.equal('data:image/png;base64,');
|
||||
expect(empty.getSize()).to.deep.equal({ width: 0, height: 0 });
|
||||
expect(empty.getBitmap()).to.be.empty();
|
||||
expect(empty.getBitmap({ scaleFactor: 2.0 })).to.be.empty();
|
||||
await expectDeprecationMessages(
|
||||
() => {
|
||||
expect(empty.getBitmap()).to.be.empty();
|
||||
expect(empty.getBitmap({ scaleFactor: 2.0 })).to.be.empty();
|
||||
},
|
||||
'getBitmap() is deprecated, use toBitmap() instead.'
|
||||
);
|
||||
expect(empty.toBitmap()).to.be.empty();
|
||||
expect(empty.toBitmap({ scaleFactor: 2.0 })).to.be.empty();
|
||||
expect(empty.toJPEG(100)).to.be.empty();
|
||||
|
||||
@@ -1291,7 +1291,7 @@ const win4 = new BrowserWindow({
|
||||
});
|
||||
|
||||
win4.webContents.on('paint', (event, dirty, _image) => {
|
||||
console.log(dirty, _image.getBitmap());
|
||||
console.log(dirty, _image.toBitmap());
|
||||
});
|
||||
|
||||
win4.webContents.on('devtools-open-url', (event, url) => {
|
||||
|
||||
Reference in New Issue
Block a user