mirror of
https://github.com/kusti8/proton-native.git
synced 2026-05-15 14:15:50 -06:00
* Add initial test structure and some tests for Window * Start on rewriting registerComponent * Add View support * Add flexbox support, still need to test more * Add styling and better props management * Add nested text support * Fix text measurement and qt hogging layout styles * Font size must be in px, so convert if it isn't * Add stylesheet * Various changes, start adding tests * Try out travis CI * Remove xwd package * Install qt5 * Install correct moc * Add g++ 5 * Add xwd and imagemagick * Yoga layout doesn't support v12 right now * Add touchablewithoutfeedback * Add opacity. Need to investigate seg fault * Fix build errors, unsupport trusty * Force xenial version * Add touchablehighlight. Start button * Add support for image require * Start on image * Add image resizing and TextInput * Fix button view * Quit loop when all windows closed * Fix require not working with jest * Fix quit deleting still in use pointers * Disable caching * Depend on stable node-qt-napi * Copy docs, start examples * Many bug fixes, get cat example to work * Fix percent issue and start more documentation * Start docs * Finish docs * Fix App appendChild with comments * Abstract QT bindings * Add calculator example; try to get devtools working * Update react-devtools * Add hot reloading support * Add hot reloading to examples, fix reloading bugs * Update documentation on v2 * Add more examples to v2 changes * Change readme for v2 * Remove packaging until it works * Add prepack instead * Use node-qt-napi up * 2.0.1 * Convert everything to typescript * Add note on TS * Update readme with new images * Add comparison to others in docs * Add packaging instructions * Fix windows packaging * Create FUNDING.yml * Update v2_changes.md * Create LICENSE * Add wx backend option * Add more wx components * Add wx backend notes * Add note on mac wxwidgets libuv bug * Add note on Macs with libuv bug * Use npx by default * Bump version for wx backend * V2 small code improvements (#240) * slightly improved import * better type defs * merged append and insert as they pretty same * Run prettier * Add issue templates (#241) * About page typo (#216) * Update quickstart.md (#223) * Update README.md (#229) * Create FUNDING.yml * Add issue templates * Update README.md Co-authored-by: Yevhen Hraivoronskyi <evhenious@gmail.com>
285 lines
6.8 KiB
JavaScript
285 lines
6.8 KiB
JavaScript
import React, { Component } from 'react';
|
|
import { App, Window, AppRegistry } from '../../src';
|
|
import qt from 'node-qt-napi';
|
|
jest.unmock('node-qt-napi');
|
|
const { toMatchImageSnapshot } = require('jest-image-snapshot');
|
|
import { compareSnapshot, clearShown } from '../index';
|
|
import { updateExpression } from '@babel/types';
|
|
|
|
describe('Window', () => {
|
|
beforeAll(() => {
|
|
expect.extend({ toMatchImageSnapshot });
|
|
});
|
|
beforeEach(() => {
|
|
jest.useFakeTimers();
|
|
});
|
|
afterEach(() => {
|
|
clearShown();
|
|
});
|
|
test('Basic window', () => {
|
|
class Test extends Component {
|
|
render() {
|
|
return (
|
|
<App>
|
|
<Window style={{ height: 500, width: 500 }} />
|
|
</App>
|
|
);
|
|
}
|
|
}
|
|
AppRegistry.registerComponent('Tests', <Test />);
|
|
compareSnapshot();
|
|
});
|
|
test('Window size', () => {
|
|
class Test extends Component {
|
|
render() {
|
|
return (
|
|
<App>
|
|
<Window style={{ height: 500, width: 1000 }} />
|
|
</App>
|
|
);
|
|
}
|
|
}
|
|
AppRegistry.registerComponent('Tests', <Test />);
|
|
compareSnapshot();
|
|
});
|
|
test('Window size percent', () => {
|
|
class Test extends Component {
|
|
render() {
|
|
return (
|
|
<App>
|
|
<Window style={{ height: '100%', width: '50%' }} />
|
|
</App>
|
|
);
|
|
}
|
|
}
|
|
AppRegistry.registerComponent('Tests', <Test />);
|
|
compareSnapshot();
|
|
});
|
|
test('Window styling', () => {
|
|
class Test extends Component {
|
|
render() {
|
|
return (
|
|
<App>
|
|
<Window
|
|
style={{
|
|
height: '100%',
|
|
width: '50%',
|
|
backgroundColor: 'red',
|
|
border: '10px dashed blue',
|
|
}}
|
|
/>
|
|
</App>
|
|
);
|
|
}
|
|
}
|
|
AppRegistry.registerComponent('Tests', <Test />);
|
|
compareSnapshot();
|
|
});
|
|
test('Window handlers', () => {
|
|
const fn = jest.fn();
|
|
class Test extends Component {
|
|
render() {
|
|
return (
|
|
<App>
|
|
<Window
|
|
style={{
|
|
height: '100%',
|
|
width: '100%',
|
|
backgroundColor: 'red',
|
|
border: '10px dashed blue',
|
|
}}
|
|
onResize={size => fn(size)}
|
|
/>
|
|
</App>
|
|
);
|
|
}
|
|
}
|
|
AppRegistry.registerComponent('Tests', <Test />);
|
|
expect(fn).toHaveBeenCalledWith({ w: 1280, h: 720 });
|
|
});
|
|
test('Window removal state', () => {
|
|
const stateChange = {
|
|
callback: () => {},
|
|
};
|
|
class Test extends Component {
|
|
state = {
|
|
shown: true,
|
|
};
|
|
componentDidMount() {
|
|
stateChange.callback = () => {
|
|
this.setState({ shown: false });
|
|
};
|
|
}
|
|
render() {
|
|
return (
|
|
<App>
|
|
<Window
|
|
style={{
|
|
height: '100%',
|
|
width: '50%',
|
|
backgroundColor: 'red',
|
|
border: '10px dashed blue',
|
|
}}
|
|
/>
|
|
{this.state.shown && (
|
|
<Window
|
|
style={{
|
|
height: '50%',
|
|
width: '100%',
|
|
backgroundColor: 'blue',
|
|
border: '10px dashed red',
|
|
}}
|
|
/>
|
|
)}
|
|
</App>
|
|
);
|
|
}
|
|
}
|
|
const component = <Test />;
|
|
AppRegistry.registerComponent('Tests', component);
|
|
compareSnapshot();
|
|
stateChange.callback();
|
|
compareSnapshot();
|
|
});
|
|
test('Window add state', () => {
|
|
const stateChange = {
|
|
callback: () => {},
|
|
};
|
|
class Test extends Component {
|
|
state = {
|
|
shown: false,
|
|
};
|
|
componentDidMount() {
|
|
stateChange.callback = () => {
|
|
this.setState({ shown: true });
|
|
};
|
|
}
|
|
render() {
|
|
return (
|
|
<App>
|
|
<Window
|
|
style={{
|
|
height: '100%',
|
|
width: '50%',
|
|
backgroundColor: 'red',
|
|
border: '10px dashed blue',
|
|
}}
|
|
/>
|
|
{this.state.shown && (
|
|
<Window
|
|
style={{
|
|
height: '50%',
|
|
width: '100%',
|
|
backgroundColor: 'blue',
|
|
border: '10px dashed red',
|
|
}}
|
|
/>
|
|
)}
|
|
</App>
|
|
);
|
|
}
|
|
}
|
|
const component = <Test />;
|
|
AppRegistry.registerComponent('Tests', component);
|
|
compareSnapshot();
|
|
stateChange.callback();
|
|
compareSnapshot();
|
|
});
|
|
test('Window insert state', () => {
|
|
const stateChange = {
|
|
callback: () => {},
|
|
};
|
|
class Test extends Component {
|
|
state = {
|
|
shown: false,
|
|
};
|
|
componentDidMount() {
|
|
stateChange.callback = () => {
|
|
this.setState({ shown: true });
|
|
};
|
|
}
|
|
render() {
|
|
return (
|
|
<App>
|
|
<Window
|
|
style={{
|
|
height: '100%',
|
|
width: '50%',
|
|
backgroundColor: 'red',
|
|
border: '10px dashed blue',
|
|
}}
|
|
/>
|
|
{this.state.shown && (
|
|
<Window
|
|
style={{
|
|
height: '10%',
|
|
width: '10%',
|
|
backgroundColor: 'blue',
|
|
border: '10px dashed red',
|
|
}}
|
|
/>
|
|
)}
|
|
<Window
|
|
style={{
|
|
height: '25%',
|
|
width: '75%',
|
|
backgroundColor: 'orange',
|
|
border: '10px dashed blue',
|
|
}}
|
|
/>
|
|
</App>
|
|
);
|
|
}
|
|
}
|
|
const component = <Test />;
|
|
AppRegistry.registerComponent('Tests', component);
|
|
compareSnapshot();
|
|
stateChange.callback();
|
|
compareSnapshot();
|
|
});
|
|
test('Window update state', () => {
|
|
const stateChange = {
|
|
callback: () => {},
|
|
};
|
|
class Test extends Component {
|
|
state = {
|
|
style: {
|
|
backgroundColor: 'white',
|
|
height: '20%',
|
|
width: '20%',
|
|
},
|
|
};
|
|
componentDidMount() {
|
|
stateChange.callback = () => {
|
|
this.setState({
|
|
style: {
|
|
backgroundColor: 'green',
|
|
height: '50%',
|
|
width: '50%',
|
|
},
|
|
});
|
|
};
|
|
}
|
|
render() {
|
|
return (
|
|
<App>
|
|
<Window
|
|
style={{
|
|
height: '100%',
|
|
width: '50%',
|
|
backgroundColor: 'red',
|
|
border: '10px dashed blue',
|
|
}}
|
|
/>
|
|
<Window style={this.state.style} />
|
|
</App>
|
|
);
|
|
}
|
|
}
|
|
const component = <Test />;
|
|
AppRegistry.registerComponent('Tests', component);
|
|
compareSnapshot();
|
|
stateChange.callback();
|
|
compareSnapshot();
|
|
});
|
|
});
|