diff --git a/test-apps/display-performance-test-app/README.md b/test-apps/display-performance-test-app/README.md index 134804020250..21daa2619d60 100644 --- a/test-apps/display-performance-test-app/README.md +++ b/test-apps/display-performance-test-app/README.md @@ -10,6 +10,7 @@ * Run the command "npm run test:chrome" to run the backend and automatically bring up a Google Chrome browser window to start the test. This will also automatically kill **ALL** Google Chrome browser windows once the test has completed. * Run the command "npm run test:edge" to run the backend and automatically bring up an Edge browser window to start the test. This will also automatically kill **ALL** Edge browser windows once the test has completed. * Run the command "npm run test:firefox" to run the backend and automatically bring up a FireFox browser window to start the test. This will also automatically kill **ALL** FireFox browser windows once the test has completed. +* Run the command "npm run test:safari" to run the backend and automatically bring up a Safari browser window to start the test. This will also automatically kill **ALL** Safari browser windows once the test has completed. ## Options available for a performance test run: diff --git a/test-apps/display-performance-test-app/package.json b/test-apps/display-performance-test-app/package.json index 43d2354ae35d..24c6397095c8 100644 --- a/test-apps/display-performance-test-app/package.json +++ b/test-apps/display-performance-test-app/package.json @@ -27,6 +27,7 @@ "test:chrome": "node ./lib/common/npmCommands.js chrome", "test:edge": "node ./lib/common/npmCommands.js edge", "test:firefox": "node ./lib/common/npmCommands.js firefox", + "test:safari": "node ./lib/common/npmCommands.js safari", "build:mobile-backend": "tsc 1>&2 && webpack --config ./node_modules/@bentley/webpack-tools/mobile/backend.config.js --env.outdir=./lib/mobile --env.entry=./lib/backend/MobileMain.js --env.bundlename=main ", "test": "", "cover": "" diff --git a/test-apps/display-performance-test-app/src/backend/DisplayPerfRpcImpl.ts b/test-apps/display-performance-test-app/src/backend/DisplayPerfRpcImpl.ts index 36a4dd753754..048c8dfd229f 100644 --- a/test-apps/display-performance-test-app/src/backend/DisplayPerfRpcImpl.ts +++ b/test-apps/display-performance-test-app/src/backend/DisplayPerfRpcImpl.ts @@ -30,7 +30,7 @@ export default class DisplayPerfRpcImpl extends DisplayPerfRpcInterface { } let argOutputPath: string | undefined; process.argv.forEach((arg, index) => { - if (index >= 2 && arg !== "chrome" && arg !== "edge" && arg !== "firefox" && arg !== "headless" && arg.split(".").pop() !== "json") { + if (index >= 2 && arg !== "chrome" && arg !== "edge" && arg !== "firefox" && arg !== "safari" && arg !== "headless" && arg.split(".").pop() !== "json") { while (arg.endsWith("\\") || arg.endsWith("\/")) arg = arg.slice(0, -1); argOutputPath = `"argOutputPath": "${arg}",`; diff --git a/test-apps/display-performance-test-app/src/backend/WebMain.ts b/test-apps/display-performance-test-app/src/backend/WebMain.ts index 0f7bb9181410..f6457aea95f0 100644 --- a/test-apps/display-performance-test-app/src/backend/WebMain.ts +++ b/test-apps/display-performance-test-app/src/backend/WebMain.ts @@ -54,7 +54,7 @@ function startWebServer() { process.argv.forEach((arg) => { if (arg.split(".").pop() === "json") DisplayPerfRpcInterface.jsonFilePath = arg; - else if (arg === "chrome" || arg === "edge" || arg === "firefox") + else if (arg === "chrome" || arg === "edge" || arg === "firefox" || arg === "safari") browser = arg; else if (arg === "headless") chromeFlags.push("--headless"); @@ -99,13 +99,29 @@ function startWebServer() { // --------------------------------------------- // Start the browser, if given a specific one // --------------------------------------------- - if (browser === "chrome") - chromeLauncher.launch({ // eslint-disable-line @typescript-eslint/no-floating-promises - startingUrl: "http://localhost:3000", - chromeFlags, - }).then((val) => { DisplayPerfRpcInterface.chrome = val; }); - else if (browser === "firefox") - child_process.execSync("start firefox http://localhost:3000"); - else if (browser === "edge") - child_process.execSync("start microsoft-edge:http://localhost:3000"); + switch (browser) { + case "chrome": + if (process.platform === "darwin") { // Ie, if running on Mac + child_process.execSync("open -a \"Google Chrome\" http://localhost:3000"); + } else { + chromeLauncher.launch({ // eslint-disable-line @typescript-eslint/no-floating-promises + startingUrl: "http://localhost:3000", + chromeFlags, + }).then((val) => { DisplayPerfRpcInterface.chrome = val; }); + } + break; + case "edge": + child_process.execSync("start microsoft-edge:http://localhost:3000"); + break; + case "safari": + child_process.execSync("open -a Safari http://localhost:3000"); + break; + case "firefox": + if (process.platform === "darwin") { // Ie, if running on Mac + child_process.execSync("open -a firefox http://localhost:3000"); + } else { + child_process.execSync("start firefox http://localhost:3000"); + } + break; + } })(); diff --git a/test-apps/display-performance-test-app/src/common/npmCommands.ts b/test-apps/display-performance-test-app/src/common/npmCommands.ts index ce9dac0fb311..f571ba4640f9 100644 --- a/test-apps/display-performance-test-app/src/common/npmCommands.ts +++ b/test-apps/display-performance-test-app/src/common/npmCommands.ts @@ -13,12 +13,28 @@ let browser = ""; for (let i = 2; i < process.argv.length; i++) { const curArg = process.argv[i]; args += `${curArg} `; - if (curArg === "chrome" || curArg === "edge" || curArg === "firefox") + if (curArg === "chrome" || curArg === "edge" || curArg === "firefox" || curArg === "safari") browser = curArg; } execSync(`npm run start:web ${args}`, { stdio: [0, 1, 2] }); -if (browser === "edge") - execSync("taskkill /f /im MicrosoftEdge.exe /t >nul"); -else if (browser === "firefox") - execSync("taskkill /f /im firefox.exe /t >nul"); +switch (browser) { + case "chrome": + if (process.platform === "darwin") { // Ie, if running on Mac + execSync("killall \"Google Chrome\""); + } + break; + case "edge": + execSync("taskkill /f /im msedge.exe /t >nul"); + break; + case "safari": + execSync("killall Safari"); + break; + case "firefox": + if (process.platform === "darwin") { // Ie, if running on Mac + execSync("killall firefox"); + } else { + execSync("taskkill /f /im firefox.exe /t >nul"); + } + break; +}