darwin.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  1. 'use strict'
  2. const config = require('./config.json')
  3. const exec = require('mz/child_process').exec
  4. const fs = require('fs-extra')
  5. const mac = require('../mac')
  6. const packager = require('..')
  7. const path = require('path')
  8. const plist = require('plist')
  9. const test = require('ava')
  10. const util = require('./_util')
  11. const darwinOpts = {
  12. name: 'darwinTest',
  13. dir: util.fixtureSubdir('basic'),
  14. electronVersion: config.version,
  15. arch: 'x64',
  16. platform: 'darwin'
  17. }
  18. const el0374Opts = Object.assign({}, darwinOpts, {
  19. name: 'el0374Test',
  20. dir: util.fixtureSubdir('el-0374'),
  21. electronVersion: '0.37.4'
  22. })
  23. function testWrapper (testName, extraOpts, testFunction/*, ...extraArgs */) {
  24. const extraArgs = Array.prototype.slice.call(arguments, 3)
  25. util.packagerTest(testName, (t, baseOpts) => {
  26. const opts = Object.assign({}, baseOpts, extraOpts)
  27. return testFunction.apply(null, [t, opts].concat(extraArgs))
  28. })
  29. }
  30. function darwinTest (testName, testFunction/*, ...extraArgs */) {
  31. const extraArgs = Array.prototype.slice.call(arguments, 2)
  32. return testWrapper.apply(null, [testName, darwinOpts, testFunction].concat(extraArgs))
  33. }
  34. function electron0374Test (testName, testFunction) {
  35. const extraArgs = Array.prototype.slice.call(arguments, 2)
  36. return testWrapper.apply(null, [testName, el0374Opts, testFunction].concat(extraArgs))
  37. }
  38. function getHelperExecutablePath (helperName) {
  39. return path.join(`${helperName}.app`, 'Contents', 'MacOS', helperName)
  40. }
  41. function parseInfoPlist (t, opts, basePath) {
  42. const plistPath = path.join(basePath, `${opts.name}.app`, 'Contents', 'Info.plist')
  43. return fs.stat(plistPath)
  44. .then(stats => {
  45. t.true(stats.isFile(), 'The expected Info.plist file should exist')
  46. return fs.readFile(plistPath, 'utf8')
  47. }).then(file => plist.parse(file))
  48. }
  49. function packageAndParseInfoPlist (t, opts) {
  50. return packager(opts)
  51. .then(paths => parseInfoPlist(t, opts, paths[0]))
  52. }
  53. function helperAppPathsTest (t, baseOpts, extraOpts, expectedName) {
  54. const opts = Object.assign(baseOpts, extraOpts)
  55. let frameworksPath
  56. if (!expectedName) {
  57. expectedName = opts.name
  58. }
  59. return packager(opts)
  60. .then(paths => {
  61. frameworksPath = path.join(paths[0], `${expectedName}.app`, 'Contents', 'Frameworks')
  62. // main Helper.app is already tested in basic test suite; test its executable and the other helpers
  63. return fs.stat(path.join(frameworksPath, getHelperExecutablePath(`${expectedName} Helper`)))
  64. }).then(stats => {
  65. t.true(stats.isFile(), 'The Helper.app executable should reflect sanitized opts.name')
  66. return fs.stat(path.join(frameworksPath, `${expectedName} Helper EH.app`))
  67. }).then(stats => {
  68. t.true(stats.isDirectory(), 'The Helper EH.app should reflect sanitized opts.name')
  69. return fs.stat(path.join(frameworksPath, getHelperExecutablePath(`${expectedName} Helper EH`)))
  70. }).then(stats => {
  71. t.true(stats.isFile(), 'The Helper EH.app executable should reflect sanitized opts.name')
  72. return fs.stat(path.join(frameworksPath, `${expectedName} Helper NP.app`))
  73. }).then(stats => {
  74. t.true(stats.isDirectory(), 'The Helper NP.app should reflect sanitized opts.name')
  75. return fs.stat(path.join(frameworksPath, getHelperExecutablePath(`${expectedName} Helper NP`)))
  76. }).then(stats => t.true(stats.isFile(), 'The Helper NP.app executable should reflect sanitized opts.name'))
  77. }
  78. function iconTest (t, opts, icon, iconPath) {
  79. opts.icon = icon
  80. let resourcesPath
  81. return util.packageAndEnsureResourcesPath(t, opts)
  82. .then(generatedResourcesPath => {
  83. resourcesPath = generatedResourcesPath
  84. const outputPath = resourcesPath.replace(`${path.sep}${util.generateResourcesPath(opts)}`, '')
  85. return parseInfoPlist(t, opts, outputPath)
  86. }).then(obj => {
  87. return util.areFilesEqual(iconPath, path.join(resourcesPath, obj.CFBundleIconFile))
  88. }).then(equal => t.true(equal, 'installed icon file should be identical to the specified icon file'))
  89. }
  90. function extendInfoTest (t, baseOpts, extraPathOrParams) {
  91. const opts = Object.assign({}, baseOpts, {
  92. appBundleId: 'com.electron.extratest',
  93. appCategoryType: 'public.app-category.music',
  94. buildVersion: '3.2.1',
  95. extendInfo: extraPathOrParams
  96. })
  97. return packageAndParseInfoPlist(t, opts)
  98. .then(obj => {
  99. t.is(obj.TestKeyString, 'String data', 'TestKeyString should come from extendInfo')
  100. t.is(obj.TestKeyInt, 12345, 'TestKeyInt should come from extendInfo')
  101. t.is(obj.TestKeyBool, true, 'TestKeyBool should come from extendInfo')
  102. t.deepEqual(obj.TestKeyArray, ['public.content', 'public.data'], 'TestKeyArray should come from extendInfo')
  103. t.deepEqual(obj.TestKeyDict, { Number: 98765, CFBundleVersion: '0.0.0' }, 'TestKeyDict should come from extendInfo')
  104. t.is(obj.CFBundleVersion, opts.buildVersion, 'CFBundleVersion should reflect buildVersion argument')
  105. t.is(obj.CFBundleIdentifier, 'com.electron.extratest', 'CFBundleIdentifier should reflect appBundleId argument')
  106. t.is(obj.LSApplicationCategoryType, 'public.app-category.music', 'LSApplicationCategoryType should reflect appCategoryType argument')
  107. return t.is(obj.CFBundlePackageType, 'APPL', 'CFBundlePackageType should be Electron default')
  108. })
  109. }
  110. function binaryNameTest (t, baseOpts, extraOpts, expectedExecutableName, expectedAppName) {
  111. const opts = Object.assign({}, baseOpts, extraOpts)
  112. const appName = expectedAppName || expectedExecutableName || opts.name
  113. const executableName = expectedExecutableName || opts.name
  114. let binaryPath
  115. return packager(opts)
  116. .then(paths => {
  117. binaryPath = path.join(paths[0], `${appName}.app`, 'Contents', 'MacOS')
  118. return fs.stat(path.join(binaryPath, executableName))
  119. }).then(stats => t.true(stats.isFile(), 'The binary should reflect a sanitized opts.name'))
  120. }
  121. function appVersionTest (t, opts, appVersion, buildVersion) {
  122. opts.appVersion = appVersion
  123. opts.buildVersion = buildVersion || appVersion
  124. return packageAndParseInfoPlist(t, opts)
  125. .then(obj => {
  126. t.is(obj.CFBundleVersion, '' + opts.buildVersion, 'CFBundleVersion should reflect buildVersion')
  127. t.is(obj.CFBundleShortVersionString, '' + opts.appVersion, 'CFBundleShortVersionString should reflect appVersion')
  128. t.is(typeof obj.CFBundleVersion, 'string', 'CFBundleVersion should be a string')
  129. return t.is(typeof obj.CFBundleShortVersionString, 'string', 'CFBundleShortVersionString should be a string')
  130. })
  131. }
  132. function appBundleTest (t, opts, appBundleId) {
  133. if (appBundleId) {
  134. opts.appBundleId = appBundleId
  135. }
  136. const defaultBundleName = `com.electron.${opts.name.toLowerCase()}`
  137. const appBundleIdentifier = mac.filterCFBundleIdentifier(opts.appBundleId || defaultBundleName)
  138. return packageAndParseInfoPlist(t, opts)
  139. .then(obj => {
  140. t.is(obj.CFBundleDisplayName, opts.name, 'CFBundleDisplayName should reflect opts.name')
  141. t.is(obj.CFBundleName, opts.name, 'CFBundleName should reflect opts.name')
  142. t.is(obj.CFBundleIdentifier, appBundleIdentifier, 'CFBundleName should reflect opts.appBundleId or fallback to default')
  143. t.is(typeof obj.CFBundleDisplayName, 'string', 'CFBundleDisplayName should be a string')
  144. t.is(typeof obj.CFBundleName, 'string', 'CFBundleName should be a string')
  145. t.is(typeof obj.CFBundleIdentifier, 'string', 'CFBundleIdentifier should be a string')
  146. return t.is(/^[a-zA-Z0-9-.]*$/.test(obj.CFBundleIdentifier), true, 'CFBundleIdentifier should allow only alphanumeric (A-Z,a-z,0-9), hyphen (-), and period (.)')
  147. })
  148. }
  149. function appHelpersBundleTest (t, opts, helperBundleId, appBundleId) {
  150. let tempPath, plistPath
  151. if (helperBundleId) {
  152. opts.helperBundleId = helperBundleId
  153. }
  154. if (appBundleId) {
  155. opts.appBundleId = appBundleId
  156. }
  157. const defaultBundleName = `com.electron.${opts.name.toLowerCase()}`
  158. const appBundleIdentifier = mac.filterCFBundleIdentifier(opts.appBundleId || defaultBundleName)
  159. const helperBundleIdentifier = mac.filterCFBundleIdentifier(opts.helperBundleId || appBundleIdentifier + '.helper')
  160. return packager(opts)
  161. .then(paths => {
  162. tempPath = paths[0]
  163. plistPath = path.join(tempPath, opts.name + '.app', 'Contents', 'Frameworks', opts.name + ' Helper.app', 'Contents', 'Info.plist')
  164. return fs.stat(plistPath)
  165. }).then(stats => {
  166. t.true(stats.isFile(), 'The expected Info.plist file should exist in helper app')
  167. return fs.readFile(plistPath, 'utf8')
  168. }).then(file => {
  169. const obj = plist.parse(file)
  170. t.is(obj.CFBundleName, opts.name, 'CFBundleName should reflect opts.name in helper app')
  171. t.is(obj.CFBundleIdentifier, helperBundleIdentifier, 'CFBundleIdentifier should reflect opts.helperBundleId, opts.appBundleId or fallback to default in helper app')
  172. t.is(typeof obj.CFBundleName, 'string', 'CFBundleName should be a string in helper app')
  173. t.is(typeof obj.CFBundleIdentifier, 'string', 'CFBundleIdentifier should be a string in helper app')
  174. t.is(/^[a-zA-Z0-9-.]*$/.test(obj.CFBundleIdentifier), true, 'CFBundleIdentifier should allow only alphanumeric (A-Z,a-z,0-9), hyphen (-), and period (.)')
  175. // check helper EH
  176. plistPath = path.join(tempPath, opts.name + '.app', 'Contents', 'Frameworks', opts.name + ' Helper EH.app', 'Contents', 'Info.plist')
  177. return fs.stat(plistPath)
  178. }).then(stats => {
  179. t.true(stats.isFile(), 'The expected Info.plist file should exist in helper EH app')
  180. return fs.readFile(plistPath, 'utf8')
  181. }).then(file => {
  182. const obj = plist.parse(file)
  183. t.is(obj.CFBundleName, opts.name + ' Helper EH', 'CFBundleName should reflect opts.name in helper EH app')
  184. t.is(obj.CFBundleDisplayName, opts.name + ' Helper EH', 'CFBundleDisplayName should reflect opts.name in helper EH app')
  185. t.is(obj.CFBundleExecutable, opts.name + ' Helper EH', 'CFBundleExecutable should reflect opts.name in helper EH app')
  186. t.is(obj.CFBundleIdentifier, helperBundleIdentifier + '.EH', 'CFBundleName should reflect opts.helperBundleId, opts.appBundleId or fallback to default in helper EH app')
  187. t.is(typeof obj.CFBundleName, 'string', 'CFBundleName should be a string in helper EH app')
  188. t.is(typeof obj.CFBundleDisplayName, 'string', 'CFBundleDisplayName should be a string in helper EH app')
  189. t.is(typeof obj.CFBundleExecutable, 'string', 'CFBundleExecutable should be a string in helper EH app')
  190. t.is(typeof obj.CFBundleIdentifier, 'string', 'CFBundleIdentifier should be a string in helper EH app')
  191. t.is(/^[a-zA-Z0-9-.]*$/.test(obj.CFBundleIdentifier), true, 'CFBundleIdentifier should allow only alphanumeric (A-Z,a-z,0-9), hyphen (-), and period (.)')
  192. // check helper NP
  193. plistPath = path.join(tempPath, opts.name + '.app', 'Contents', 'Frameworks', opts.name + ' Helper NP.app', 'Contents', 'Info.plist')
  194. return fs.stat(plistPath)
  195. }).then(stats => {
  196. t.true(stats.isFile(), 'The expected Info.plist file should exist in helper NP app')
  197. return fs.readFile(plistPath, 'utf8')
  198. }).then(file => {
  199. const obj = plist.parse(file)
  200. t.is(obj.CFBundleName, opts.name + ' Helper NP', 'CFBundleName should reflect opts.name in helper NP app')
  201. t.is(obj.CFBundleDisplayName, opts.name + ' Helper NP', 'CFBundleDisplayName should reflect opts.name in helper NP app')
  202. t.is(obj.CFBundleExecutable, opts.name + ' Helper NP', 'CFBundleExecutable should reflect opts.name in helper NP app')
  203. t.is(obj.CFBundleIdentifier, helperBundleIdentifier + '.NP', 'CFBundleName should reflect opts.helperBundleId, opts.appBundleId or fallback to default in helper NP app')
  204. t.is(typeof obj.CFBundleName, 'string', 'CFBundleName should be a string in helper NP app')
  205. t.is(typeof obj.CFBundleDisplayName, 'string', 'CFBundleDisplayName should be a string in helper NP app')
  206. t.is(typeof obj.CFBundleExecutable, 'string', 'CFBundleExecutable should be a string in helper NP app')
  207. t.is(typeof obj.CFBundleIdentifier, 'string', 'CFBundleIdentifier should be a string in helper NP app')
  208. return t.is(/^[a-zA-Z0-9-.]*$/.test(obj.CFBundleIdentifier), true, 'CFBundleIdentifier should allow only alphanumeric (A-Z,a-z,0-9), hyphen (-), and period (.)')
  209. })
  210. }
  211. if (!(process.env.CI && process.platform === 'win32')) {
  212. darwinTest('helper app paths test', helperAppPathsTest)
  213. darwinTest('helper app paths test with app name needing sanitization', helperAppPathsTest, {name: '@username/package-name'}, '@username-package-name')
  214. const iconBase = path.join(__dirname, 'fixtures', 'monochrome')
  215. const icnsPath = `${iconBase}.icns`
  216. darwinTest('icon test: .icns specified', iconTest, icnsPath, icnsPath)
  217. // This test exists because the .icns file basename changed as of 0.37.4
  218. electron0374Test('icon test: Electron 0.37.4, .icns specified', iconTest, icnsPath, icnsPath)
  219. darwinTest('icon test: .ico specified (should replace with .icns)', iconTest, `${iconBase}.ico`, icnsPath)
  220. darwinTest('icon test: basename only (should add .icns)', iconTest, iconBase, icnsPath)
  221. const extraInfoPath = path.join(__dirname, 'fixtures', 'extrainfo.plist')
  222. const extraInfoParams = plist.parse(fs.readFileSync(extraInfoPath).toString())
  223. darwinTest('extendInfo by filename test', extendInfoTest, extraInfoPath)
  224. darwinTest('extendInfo by params test', extendInfoTest, extraInfoParams)
  225. darwinTest('protocol/protocol-name argument test', (t, opts) => {
  226. opts.protocols = [
  227. {
  228. name: 'Foo',
  229. schemes: ['foo']
  230. },
  231. {
  232. name: 'Bar',
  233. schemes: ['bar', 'baz']
  234. }
  235. ]
  236. return packageAndParseInfoPlist(t, opts)
  237. .then(obj =>
  238. t.deepEqual(obj.CFBundleURLTypes, [{
  239. CFBundleURLName: 'Foo',
  240. CFBundleURLSchemes: ['foo']
  241. }, {
  242. CFBundleURLName: 'Bar',
  243. CFBundleURLSchemes: ['bar', 'baz']
  244. }], 'CFBundleURLTypes did not contain specified protocol schemes and names')
  245. )
  246. })
  247. test('osxSign argument test: default args', t => {
  248. const args = true
  249. const signOpts = mac.createSignOpts(args, 'darwin', 'out', 'version')
  250. t.deepEqual(signOpts, {identity: null, app: 'out', platform: 'darwin', version: 'version'})
  251. })
  252. test('osxSign argument test: identity=true sets autodiscovery mode', t => {
  253. const args = {identity: true}
  254. const signOpts = mac.createSignOpts(args, 'darwin', 'out', 'version')
  255. t.deepEqual(signOpts, {identity: null, app: 'out', platform: 'darwin', version: 'version'})
  256. })
  257. test('osxSign argument test: entitlements passed to electron-osx-sign', t => {
  258. const args = {entitlements: 'path-to-entitlements'}
  259. const signOpts = mac.createSignOpts(args, 'darwin', 'out', 'version')
  260. t.deepEqual(signOpts, {app: 'out', platform: 'darwin', version: 'version', entitlements: args.entitlements})
  261. })
  262. test('osxSign argument test: app not overwritten', t => {
  263. const args = {app: 'some-other-path'}
  264. const signOpts = mac.createSignOpts(args, 'darwin', 'out', 'version')
  265. t.deepEqual(signOpts, {app: 'out', platform: 'darwin', version: 'version'})
  266. })
  267. test('osxSign argument test: platform not overwritten', t => {
  268. const args = {platform: 'mas'}
  269. const signOpts = mac.createSignOpts(args, 'darwin', 'out', 'version')
  270. t.deepEqual(signOpts, {app: 'out', platform: 'darwin', version: 'version'})
  271. })
  272. test('osxSign argument test: binaries not set', t => {
  273. const args = {binaries: ['binary1', 'binary2']}
  274. const signOpts = mac.createSignOpts(args, 'darwin', 'out', 'version')
  275. t.deepEqual(signOpts, {app: 'out', platform: 'darwin', version: 'version'})
  276. })
  277. darwinTest('codesign test', (t, opts) => {
  278. opts.osxSign = {identity: 'Developer CodeCert'}
  279. let appPath
  280. return packager(opts)
  281. .then(paths => {
  282. appPath = path.join(paths[0], opts.name + '.app')
  283. return fs.stat(appPath)
  284. }).then(stats => {
  285. t.true(stats.isDirectory(), 'The expected .app directory should exist')
  286. return exec(`codesign -v ${appPath}`)
  287. }).then(
  288. (stdout, stderr) => t.pass('codesign should verify successfully'),
  289. err => {
  290. const notFound = err && err.code === 127
  291. if (notFound) {
  292. console.log('codesign not installed; skipped')
  293. } else {
  294. throw err
  295. }
  296. }
  297. )
  298. })
  299. darwinTest('binary naming test', binaryNameTest)
  300. darwinTest('sanitized binary naming test', binaryNameTest, {name: '@username/package-name'}, '@username-package-name')
  301. darwinTest('executableName test', binaryNameTest, {executableName: 'app-name', name: 'MyAppName'}, 'app-name', 'MyAppName')
  302. darwinTest('CFBundleName is the sanitized app name and CFBundleDisplayName is the non-sanitized app name', (t, opts) => {
  303. const appBundleIdentifier = 'com.electron.username-package-name'
  304. const expectedSanitizedName = '@username-package-name'
  305. let plistPath
  306. opts.name = '@username/package-name'
  307. return packager(opts)
  308. .then(paths => {
  309. plistPath = path.join(paths[0], `${expectedSanitizedName}.app`, 'Contents', 'Info.plist')
  310. return fs.stat(plistPath)
  311. }).then(stats => {
  312. t.true(stats.isFile(), 'The expected Info.plist file should exist')
  313. return fs.readFile(plistPath, 'utf8')
  314. }).then(file => {
  315. const obj = plist.parse(file)
  316. t.is(typeof obj.CFBundleDisplayName, 'string', 'CFBundleDisplayName should be a string')
  317. t.is(obj.CFBundleDisplayName, opts.name, 'CFBundleDisplayName should reflect opts.name')
  318. t.is(typeof obj.CFBundleName, 'string', 'CFBundleName should be a string')
  319. t.is(obj.CFBundleName, expectedSanitizedName, 'CFBundleName should reflect a sanitized opts.name')
  320. t.is(typeof obj.CFBundleIdentifier, 'string', 'CFBundleIdentifier should be a string')
  321. t.is(/^[a-zA-Z0-9-.]*$/.test(obj.CFBundleIdentifier), true, 'CFBundleIdentifier should allow only alphanumeric (A-Z,a-z,0-9), hyphen (-), and period (.)')
  322. return t.is(obj.CFBundleIdentifier, appBundleIdentifier, 'CFBundleIdentifier should reflect the sanitized opts.name')
  323. })
  324. })
  325. darwinTest('app and build version test', appVersionTest, '1.1.0', '1.1.0.1234')
  326. darwinTest('app version test', appVersionTest, '1.1.0')
  327. darwinTest('app and build version integer test', appVersionTest, 12, 1234)
  328. darwinTest('infer app version from package.json test', (t, opts) =>
  329. packageAndParseInfoPlist(t, opts)
  330. .then(obj => {
  331. t.is(obj.CFBundleVersion, '4.99.101', 'CFBundleVersion should reflect package.json version')
  332. return t.is(obj.CFBundleShortVersionString, '4.99.101', 'CFBundleShortVersionString should reflect package.json version')
  333. })
  334. )
  335. darwinTest('app categoryType test', (t, opts) => {
  336. const appCategoryType = 'public.app-category.developer-tools'
  337. opts.appCategoryType = appCategoryType
  338. return packageAndParseInfoPlist(t, opts)
  339. .then(obj => t.is(obj.LSApplicationCategoryType, appCategoryType, 'LSApplicationCategoryType should reflect opts.appCategoryType'))
  340. })
  341. darwinTest('app bundle test', appBundleTest, 'com.electron.basetest')
  342. darwinTest('app bundle (w/ special characters) test', appBundleTest, 'com.electron."bãśè tëßt!@#$%^&*()?\'')
  343. darwinTest('app bundle app-bundle-id fallback test', appBundleTest)
  344. darwinTest('app bundle framework symlink test', (t, opts) => {
  345. let frameworkPath
  346. return packager(opts)
  347. .then(paths => {
  348. frameworkPath = path.join(paths[0], `${opts.name}.app`, 'Contents', 'Frameworks', 'Electron Framework.framework')
  349. return fs.stat(frameworkPath)
  350. }).then(stats => {
  351. t.true(stats.isDirectory(), 'Expected Electron Framework.framework to be a directory')
  352. return fs.lstat(path.join(frameworkPath, 'Electron Framework'))
  353. }).then(stats => {
  354. t.true(stats.isSymbolicLink(), 'Expected Electron Framework.framework/Electron Framework to be a symlink')
  355. return fs.lstat(path.join(frameworkPath, 'Versions', 'Current'))
  356. }).then(stats => t.true(stats.isSymbolicLink(), 'Expected Electron Framework.framework/Versions/Current to be a symlink'))
  357. })
  358. darwinTest('app helpers bundle test', appHelpersBundleTest, 'com.electron.basetest.helper')
  359. darwinTest('app helpers bundle (w/ special characters) test', appHelpersBundleTest, 'com.electron."bãśè tëßt!@#$%^&*()?\'.hęłpėr')
  360. darwinTest('app helpers bundle helper-bundle-id fallback to app-bundle-id test', appHelpersBundleTest, null, 'com.electron.basetest')
  361. darwinTest('app helpers bundle helper-bundle-id fallback to app-bundle-id (w/ special characters) test', appHelpersBundleTest, null, 'com.electron."bãśè tëßt!!@#$%^&*()?\'')
  362. darwinTest('app helpers bundle helper-bundle-id & app-bundle-id fallback test', appHelpersBundleTest)
  363. darwinTest('appCopyright/NSHumanReadableCopyright test', (t, baseOpts) => {
  364. const copyright = 'Copyright © 2003–2015 Organization. All rights reserved.'
  365. const opts = Object.assign({}, baseOpts, {appCopyright: copyright})
  366. return packageAndParseInfoPlist(t, opts)
  367. .then(info => t.is(info.NSHumanReadableCopyright, copyright, 'NSHumanReadableCopyright should reflect opts.appCopyright'))
  368. })
  369. darwinTest('app named Electron packaged successfully', (t, baseOpts) => {
  370. const opts = Object.assign({}, baseOpts, {name: 'Electron'})
  371. let appPath
  372. return packager(opts)
  373. .then(paths => {
  374. appPath = path.join(paths[0], 'Electron.app')
  375. return fs.stat(appPath)
  376. }).then(stats => {
  377. t.true(stats.isDirectory(), 'The Electron.app folder exists')
  378. return fs.stat(path.join(appPath, 'Contents', 'MacOS', 'Electron'))
  379. }).then(stats => t.true(stats.isFile(), 'The Electron.app/Contents/MacOS/Electron binary exists'))
  380. })
  381. }