feat: add nativeImage.createThumbnailFromPath API (#24802)

* initial commit, mac implementation

* add documentation

* convert createThumbnailFromPath to async function

* windows impl protoype

* add tests

* added test

* fix

* fix test

* clean up

* update docs

* cleaning up code

* fix test

* retrigger CI

* retrigger CI

* refactor from app to native_image

* windows build

* lint

* lint

* add smart pointers, fix test

* change tests and update docs

* fix test, remove nolint

* add renderer-main process routing to fix tests

* lint

* thanks sam

* thanks sam
This commit is contained in:
George Xu 2020-08-24 09:36:13 -07:00 committed by GitHub
parent b403e64ef2
commit beaf60de0a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 221 additions and 8 deletions

View file

@ -515,6 +515,32 @@ describe('nativeImage module', () => {
});
});
ifdescribe(process.platform !== 'linux')('createThumbnailFromPath(path, size)', () => {
it('throws when invalid size is passed', async () => {
const badSize = { width: -1, height: -1 };
await expect(
nativeImage.createThumbnailFromPath('path', badSize)
).to.eventually.be.rejectedWith('size must not be empty');
});
it('throws when a bad path is passed', async () => {
const badPath = process.platform === 'win32' ? '\\hey\\hi\\hello' : '/hey/hi/hello';
const goodSize = { width: 100, height: 100 };
await expect(
nativeImage.createThumbnailFromPath(badPath, goodSize)
).to.eventually.be.rejected();
});
it('returns native image given valid params', async () => {
const goodPath = path.join(__dirname, 'fixtures', 'assets', 'logo.png');
const goodSize = { width: 100, height: 100 };
const result = await nativeImage.createThumbnailFromPath(goodPath, goodSize);
expect(result.isEmpty()).to.equal(false);
});
});
describe('addRepresentation()', () => {
it('does not add representation when the buffer is too small', () => {
const image = nativeImage.createEmpty();