Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,18 @@ jobs:
node-version: '18.12.1'
- name: Install ubuntu deps
if: contains(matrix.os, 'ubuntu-20.04')
run: sudo apt install mesa-common-dev libglu1-mesa-dev libegl1 libopengl-dev
run: sudo apt install mesa-common-dev libglu1-mesa-dev libegl1 libopengl-dev libxcb-icccm4 libxcb-shape0 libxkbcommon-x11-0 libxcb-xkb1 libxcb-cursor0 libxcb-keysyms1
- name: Install deps
run: npm install
- name: Build nodegui
run: npm run build
env:
CMAKE_BUILD_PARALLEL_LEVEL: 8
- name: Run ubuntu tests
if: contains(matrix.os, 'ubuntu-20.04')
run: xvfb-run npm run test
- name: Run tests
if: ${{ !contains(matrix.os, 'ubuntu-20.04') }}
run: npm run test
- name: Run linters for cpp
run: npm run lint:cpp
Expand Down
8 changes: 7 additions & 1 deletion src/lib/QtGui/QWindow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export class QWindow extends QObject<QWindowSignals> {
// TODO: void setMaximumWidth(int w)
// TODO: void setMinimumHeight(int h)
// TODO: void setMinimumWidth(int w)
// TODO: void setTitle(const QString &)
// TODO: void setVisible(bool visible)
// TODO: void setWidth(int arg)
// TODO: void setX(int arg)
Expand Down Expand Up @@ -68,13 +67,20 @@ export class QWindow extends QObject<QWindowSignals> {
setVisibility(visibility: Visibility): void {
return this.native.setVisibility(visibility);
}
title(): string {
return this.native.windowTitle();
}
setTitle(title: string): void {
return this.native.setWindowTitle(title);
}
}
wrapperCache.registerWrapper('QWindowWrap', QWindow);

export interface QWindowSignals extends QObjectSignals {
screenChanged: (screen: QScreen) => void;
visibilityChanged: (visibility: Visibility) => void;
windowStateChanged: (windowState: WindowState) => void;
windowTitleChanged: (title: string) => void;
}

registerNativeWrapFunction('QWindowWrap', (native: any) => {
Expand Down
27 changes: 27 additions & 0 deletions src/lib/QtGui/__tests__/QWindow.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { QWidget } from '../../..';
import { QWindow } from '../QWindow';

describe('QWindow', () => {
it('initialize', () => {
const widget = new QWidget();
const window = new QWindow(widget.native);
expect(window).toBeTruthy();
});
it('setTitle', () => {
const widget = new QWidget();
const window = new QWindow(widget.native);
const expectedTitle = 'Test window';
window.setTitle(expectedTitle);
expect(window.title()).toEqual(expectedTitle);
});
it('check if windowTitleChanged signal is working for window', () => {
const widget = new QWidget();
const window = new QWindow(widget.native);
const mock = jest.fn();
window.addEventListener('windowTitleChanged', mock);
const expectedTitle = 'Test window';
window.setTitle(expectedTitle);
expect(mock).toBeCalledTimes(1);
expect(mock.mock.calls[0][0]).toEqual(expectedTitle);
});
});
6 changes: 0 additions & 6 deletions src/lib/core/__test__/WrapperCache.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import { QObject } from '../../QtCore/QObject';
import { QApplication } from '../../QtGui/QApplication';
import { CacheTestQObject } from './CacheTestQObject';
import { wrapperCache } from '../WrapperCache';

describe('WrapperCache using CacheTestQObject', () => {
const qApp = QApplication.instance();
qApp.setQuitOnLastWindowClosed(true);

it('Cached foo', () => {
wrapperCache._flush();
const a = new CacheTestQObject();
Expand Down Expand Up @@ -92,6 +88,4 @@ describe('WrapperCache using CacheTestQObject', () => {
expect(allKids[0]).toEqual(kid1);
expect(allKids[1]).toEqual(kid2);
});

qApp.quit();
});