1
1
const { app, ipcMain, BrowserWindow} = require ( 'electron' )
2
- const libnut = require ( "../.." ) ;
3
2
const path = require ( 'path' ) ;
4
-
5
- const POS_X = 50 ;
6
- const POS_Y = 100 ;
7
- const WIDTH = 800 ;
8
- const HEIGTH = 600 ;
9
-
10
- function test ( description , assertion ) {
11
- console . log ( `${ description } : ${ assertion } ` ) ;
12
- if ( ! assertion ) {
13
- app . exit ( 1 ) ;
14
- }
15
- }
3
+ const { POS_X , POS_Y , WIDTH , HEIGTH } = require ( "./constants" ) ;
16
4
17
5
function createWindow ( ) {
18
6
const mainWindow = new BrowserWindow ( {
@@ -25,23 +13,6 @@ function createWindow() {
25
13
} ) ;
26
14
mainWindow . loadFile ( path . join ( __dirname , "index.html" ) ) ;
27
15
mainWindow . setPosition ( POS_X , POS_Y ) ;
28
-
29
- setTimeout ( ( ) => {
30
- const windowNames = libnut . getWindows ( ) . map (
31
- handle => libnut . getWindowTitle ( handle )
32
- ) ;
33
- test ( "list windows" , windowNames . includes ( "libnut window test" ) ) ;
34
-
35
- const activeWindow = libnut . getActiveWindow ( ) ;
36
- const activeWindowRect = libnut . getWindowRect ( activeWindow ) ;
37
- const activeWindowTitle = libnut . getWindowTitle ( activeWindow ) ;
38
- test ( "title" , activeWindowTitle === "libnut window test" ) ;
39
- test ( "posX" , activeWindowRect . x === POS_X ) ;
40
- test ( "posY" , activeWindowRect . y === POS_Y ) ;
41
- test ( "width" , activeWindowRect . width === WIDTH ) ;
42
- test ( "height" , activeWindowRect . height === HEIGTH ) ;
43
- app . quit ( ) ;
44
- } , 5000 ) ;
45
16
}
46
17
47
18
ipcMain . on ( "main" , ( event , args ) => {
0 commit comments