Return-Path: X-Original-To: apmail-cordova-commits-archive@www.apache.org Delivered-To: apmail-cordova-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A1E87CB87 for ; Thu, 13 Jun 2013 18:21:32 +0000 (UTC) Received: (qmail 57620 invoked by uid 500); 13 Jun 2013 18:21:28 -0000 Delivered-To: apmail-cordova-commits-archive@cordova.apache.org Received: (qmail 57564 invoked by uid 500); 13 Jun 2013 18:21:28 -0000 Mailing-List: contact commits-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cordova.apache.org Delivered-To: mailing list commits@cordova.apache.org Received: (qmail 56380 invoked by uid 99); 13 Jun 2013 18:21:27 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 13 Jun 2013 18:21:27 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 0C2218A4E66; Thu, 13 Jun 2013 18:21:27 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: filmaj@apache.org To: commits@cordova.apache.org Date: Thu, 13 Jun 2013 18:22:36 -0000 Message-Id: <9bbf389e73954f62adabb8ce85bf8c68@git.apache.org> In-Reply-To: <437c04f0ec1b446b93fcdeac865562cf@git.apache.org> References: <437c04f0ec1b446b93fcdeac865562cf@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [73/78] most of the way with android parser specs, fix in platform http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/c04ca9d4/spec/platform-script/android/android_parser.spec.js ---------------------------------------------------------------------- diff --git a/spec/platform-script/android/android_parser.spec.js b/spec/platform-script/android/android_parser.spec.js deleted file mode 100644 index 4759a2c..0000000 --- a/spec/platform-script/android/android_parser.spec.js +++ /dev/null @@ -1,244 +0,0 @@ - -/** - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. -*/ -var android_parser = require('../../../src/metadata/android_parser'), - config_parser = require('../../../src/config_parser'), - util = require('../../../src/util'), - path = require('path'), - shell = require('shelljs'), - fs = require('fs'), - et = require('elementtree'), - cordova = require('../../../cordova'), - projects_path = path.join(__dirname, '..', '..', 'fixtures', 'projects'), - android_path = path.join(projects_path, 'native', 'android_fixture'), - project_path = path.join(projects_path, 'cordova'), - android_project_path = path.join(project_path, 'platforms', 'android'); - -var www_config = util.projectConfig(project_path); -var original_www_config = fs.readFileSync(www_config, 'utf-8'); - -describe('android project parser', function() { - it('should throw an exception with a path that is not a native android project', function() { - expect(function() { - var project = new android_parser(process.cwd()); - }).toThrow(); - }); - it('should accept a proper native android project path as construction parameter', function() { - expect(function() { - var project = new android_parser(android_path); - expect(project).toBeDefined(); - }).not.toThrow(); - }); - - describe('update_from_config method', function() { - var project, config; - - var android_strings = path.join(android_path, 'res', 'values', 'strings.xml'); - var android_manifest = path.join(android_path, 'AndroidManifest.xml'); - var android_config = path.join(android_path, 'res', 'xml', 'config.xml'); - - var original_strings = fs.readFileSync(android_strings, 'utf-8'); - var original_manifest = fs.readFileSync(android_manifest, 'utf-8'); - var original_android_config = fs.readFileSync(android_config, 'utf-8'); - - beforeEach(function() { - project = new android_parser(android_path); - config = new config_parser(www_config); - }); - afterEach(function() { - fs.writeFileSync(android_strings, original_strings, 'utf-8'); - fs.writeFileSync(android_manifest, original_manifest, 'utf-8'); - fs.writeFileSync(www_config, original_www_config, 'utf-8'); - fs.writeFileSync(android_config, original_android_config, 'utf-8'); - }); - it('should throw an exception if a non config_parser object is passed into it', function() { - expect(function() { - project.update_from_config({}); - }).toThrow(); - }); - it('should update the application name properly', function() { - config.name('bond. james bond.'); - project.update_from_config(config); - - var strings = new et.ElementTree(et.XML(fs.readFileSync(android_strings, 'utf-8'))); - var app_name = strings.find('string[@name="app_name"]').text; - - expect(app_name).toBe('bond. james bond.'); - }); - it('should update the application package name properly', function() { - var javs = path.join(android_path, 'src', 'ca', 'filmaj', 'dewd', 'cordovaExample.java'); - var orig_javs = path.join(android_path, 'src', 'org', 'apache', 'cordova', 'cordovaExample', 'cordovaExample.java'); - var orig_contents = fs.readFileSync(orig_javs, 'utf-8'); - this.after(function() { - fs.writeFileSync(orig_javs, orig_contents, 'utf-8'); - shell.rm('-rf', path.join(android_path, 'src', 'ca')); - }); - config.packageName('ca.filmaj.dewd'); - project.update_from_config(config); - - var manifest = new et.ElementTree(et.XML(fs.readFileSync(android_manifest, 'utf-8'))); - expect(manifest.getroot().attrib.package).toEqual('ca.filmaj.dewd'); - - expect(fs.existsSync(javs)).toBe(true); - expect(fs.readFileSync(javs, 'utf-8')).toMatch(/package ca.filmaj.dewd/i); - }); - it('should update the application version properly', function() { - config.version('2.0.1'); - project.update_from_config(config); - - var manifest = new et.ElementTree(et.XML(fs.readFileSync(android_manifest, 'utf-8'))); - expect(manifest.getroot().attrib["android:versionName"]).toEqual('2.0.1'); - }); - it('should handle unsupported "-" in the application package name', function() { - var javs = path.join(android_path, 'src', 'ca', 'filmaj', 'the_dewd', 'cordovaExample.java'); - var orig_javs = path.join(android_path, 'src', 'org', 'apache', 'cordova', 'cordovaExample', 'cordovaExample.java'); - var orig_contents = fs.readFileSync(orig_javs, 'utf-8'); - this.after(function() { - fs.writeFileSync(orig_javs, orig_contents, 'utf-8'); - shell.rm('-rf', path.join(android_path, 'src', 'ca')); - }); - config.packageName('ca.filmaj.the-dewd'); - project.update_from_config(config); - - var manifest = new et.ElementTree(et.XML(fs.readFileSync(android_manifest, 'utf-8'))); - expect(manifest.getroot().attrib.package).toEqual('ca.filmaj.the_dewd'); - - expect(fs.existsSync(javs)).toBe(true); - expect(fs.readFileSync(javs, 'utf-8')).toMatch(/package ca.filmaj.the_dewd/i); - }); - it('should update the whitelist properly', function() { - config.access.remove('*'); - config.access.add('http://apache.org'); - config.access.add('http://github.com'); - project.update_from_config(config); - - var native_config = new et.ElementTree(et.XML(fs.readFileSync(android_config, 'utf-8'))); - var as = native_config.findall('access'); - expect(as.length).toEqual(2); - expect(as[0].attrib.origin).toEqual('http://apache.org'); - expect(as[1].attrib.origin).toEqual('http://github.com'); - }); - describe('preferences', function() { - it('should not change default project preferences and copy over additional project preferences to platform-level config.xml', function() { - config.preference.add({name:'henrik',value:'sedin'}); - project.update_from_config(config); - - var native_config = new et.ElementTree(et.XML(fs.readFileSync(android_config, 'utf-8'))); - var ps = native_config.findall('preference'); - expect(ps.length).toEqual(7); - expect(ps[0].attrib.name).toEqual('useBrowserHistory'); - expect(ps[0].attrib.value).toEqual('true'); - expect(ps[6].attrib.name).toEqual('henrik'); - expect(ps[6].attrib.value).toEqual('sedin'); - }); - it('should override a default project preference if applicable', function() { - config.preference.add({name:'useBrowserHistory',value:'false'}); - project.update_from_config(config); - - var native_config = new et.ElementTree(et.XML(fs.readFileSync(android_config, 'utf-8'))); - var ps = native_config.findall('preference'); - expect(ps.length).toEqual(6); - expect(ps[0].attrib.name).toEqual('useBrowserHistory'); - expect(ps[0].attrib.value).toEqual('false'); - }); - }); - }); - - describe('cross-platform project level methods', function() { - var parser, config; - var android_strings = path.join(android_project_path, 'res', 'values', 'strings.xml'); - var android_manifest = path.join(android_project_path, 'AndroidManifest.xml'); - var android_config = path.join(android_project_path, 'res', 'xml', 'config.xml'); - - var original_strings = fs.readFileSync(android_strings, 'utf-8'); - var original_manifest = fs.readFileSync(android_manifest, 'utf-8'); - var original_android_config = fs.readFileSync(android_config, 'utf-8'); - - beforeEach(function() { - parser = new android_parser(android_project_path); - config = new config_parser(www_config); - }); - afterEach(function() { - fs.writeFileSync(android_strings, original_strings, 'utf-8'); - fs.writeFileSync(android_manifest, original_manifest, 'utf-8'); - fs.writeFileSync(www_config, original_www_config, 'utf-8'); - fs.writeFileSync(android_config, original_android_config, 'utf-8'); - }); - describe('update_www method', function() { - it('should update all www assets', function() { - var newFile = path.join(util.projectWww(project_path), 'somescript.js'); - this.after(function() { - shell.rm('-f', newFile); - }); - fs.writeFileSync(newFile, 'alert("sup");', 'utf-8'); - parser.update_www(); - expect(fs.existsSync(path.join(android_project_path, 'assets', 'www', 'somescript.js'))).toBe(true); - }); - it('should write out android js to cordova.js', function() { - parser.update_www(); - expect(fs.readFileSync(path.join(android_project_path, 'assets', 'www', 'cordova.js'),'utf-8')).toBe(fs.readFileSync(path.join(util.libDirectory, 'cordova-android', 'framework', 'assets', 'www', 'cordova.js'), 'utf-8')); - }); - }); - - describe('update_overrides method',function() { - var mergesPath = path.join(util.appDir(project_path), 'merges', 'android'); - var newFile = path.join(mergesPath, 'merge.js'); - beforeEach(function() { - shell.mkdir('-p', mergesPath); - fs.writeFileSync(newFile, 'alert("sup");', 'utf-8'); - }); - afterEach(function() { - shell.rm('-rf', mergesPath); - }); - it('should copy a new file from merges into www', function() { - parser.update_overrides(); - expect(fs.existsSync(path.join(android_project_path, 'assets', 'www', 'merge.js'))).toBe(true); - }); - - it('should copy a file from merges over a file in www', function() { - var newFileWWW = path.join(util.projectWww(project_path), 'merge.js'); - fs.writeFileSync(newFileWWW, 'var foo=1;', 'utf-8'); - this.after(function() { - shell.rm('-rf', newFileWWW); - }); - parser.update_overrides(); - expect(fs.existsSync(path.join(android_project_path, 'assets', 'www', 'merge.js'))).toBe(true); - expect(fs.readFileSync(path.join(android_project_path, 'assets', 'www', 'merge.js'),'utf-8')).toEqual('alert("sup");'); - }); - }); - - describe('update_project method', function() { - it('should invoke update_www', function() { - var spyWww = spyOn(parser, 'update_www'); - parser.update_project(config); - expect(spyWww).toHaveBeenCalled(); - }); - it('should invoke update_from_config', function() { - var spyConfig = spyOn(parser, 'update_from_config'); - parser.update_project(config); - expect(spyConfig).toHaveBeenCalled(); - }); - it('should call out to util.deleteSvnFolders', function() { - var spy = spyOn(util, 'deleteSvnFolders'); - parser.update_project(config); - expect(spy).toHaveBeenCalled(); - }); - }); - }); -}); http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/c04ca9d4/spec/platform-script/blackberry/blackberry.spec.js ---------------------------------------------------------------------- diff --git a/spec/platform-script/blackberry/blackberry.spec.js b/spec/platform-script/blackberry/blackberry.spec.js deleted file mode 100644 index bb59973..0000000 --- a/spec/platform-script/blackberry/blackberry.spec.js +++ /dev/null @@ -1,107 +0,0 @@ -var cordova = require('../../../cordova'), - shell = require('shelljs'), - path = require('path'), - fs = require('fs'), - blackberry_parser = require('../../../src/metadata/blackberry_parser'), - tempDir = path.join(__dirname, '..', '..', '..', 'temp'), - fixtures = path.join(__dirname, '..', '..', 'fixtures'), - cordova_project = path.join(fixtures, 'projects', 'cordova'); - -var cwd = process.cwd(); - -describe('Test:', function() { - - afterEach(function() { - process.chdir(cwd); - }); - - describe('\'platform add blackberry\'', function() { - var sh, cr; - var fake_reqs_check = function() { - expect(cr.mostRecentCall.args).toBeDefined(); - cr.mostRecentCall.args[0](false); - }; - var fake_create = function(a_path) { - shell.mkdir('-p', path.join(a_path, 'www')); - fs.writeFileSync(path.join(a_path, 'project.json'), 'hi', 'utf-8'); - shell.cp('-rf', path.join(cordova_project, 'platforms', 'blackberry', 'www', 'config.xml'), path.join(a_path, 'www')); - sh.mostRecentCall.args[2](0, ''); - }; - beforeEach(function() { - sh = spyOn(shell, 'exec'); - cr = spyOn(blackberry_parser, 'check_requirements'); - shell.rm('-rf', tempDir); - cordova.create(tempDir); - process.chdir(tempDir); - }); - afterEach(function() { - process.chdir(cwd); - }); - it('should check requirements when adding', function() { - cordova.platform('add', 'blackberry'); - expect(blackberry_parser.check_requirements).toHaveBeenCalled(); - }); - it('should shell out to blackberry bin/create', function() { - cordova.platform('add', 'blackberry'); - fake_reqs_check(); - var shell_cmd = sh.mostRecentCall.args[0]; - var create_cmd = path.join('blackberry', 'bin', 'create'); - expect(shell_cmd).toContain(create_cmd); - }); - it('should call blackberry_parser\'s update_project', function() { - spyOn(blackberry_parser.prototype, 'update_project'); - cordova.platform('add', 'blackberry'); - fake_reqs_check(); - fake_create(path.join(tempDir, 'platforms', 'blackberry')); - expect(blackberry_parser.prototype.update_project).toHaveBeenCalled(); - }); - }); - - describe('\'emulate blackberry\'', function() { - beforeEach(function() { - process.chdir(tempDir); - spyOn(blackberry_parser.prototype, 'get_cordova_config').andReturn({ - signing_password:'pwd' - }); - }); - afterEach(function() { - process.chdir(cwd); - }); - shell.rm('-rf', tempDir); - cordova.create(tempDir); - shell.cp('-rf', path.join(cordova_project, 'platforms', 'blackberry'), path.join(tempDir, 'platforms')); - it('should shell out to run command with a specific target', function() { - var proj_spy = spyOn(blackberry_parser.prototype, 'update_project'); - spyOn(blackberry_parser.prototype, 'get_all_targets').andReturn([{name:'fakesim',type:'simulator'}]); - var s = spyOn(require('shelljs'), 'exec'); - cordova.emulate('blackberry'); - proj_spy.mostRecentCall.args[1](); // update_project fake - expect(s).toHaveBeenCalled(); - var emulate_cmd = 'cordova.run" --target=fakesim -k pwd$'; - expect(s.mostRecentCall.args[0]).toMatch(emulate_cmd); - }); - it('should call blackberry_parser\'s update_project', function() { - spyOn(require('shelljs'), 'exec'); - spyOn(blackberry_parser.prototype, 'update_project'); - cordova.emulate('blackberry'); - expect(blackberry_parser.prototype.update_project).toHaveBeenCalled(); - }); - }); - - describe('\'compile blackberry\'', function() { - beforeEach(function() { - process.chdir(tempDir); - }); - afterEach(function() { - process.chdir(cwd); - }); - shell.rm('-rf', tempDir); - cordova.create(tempDir); - shell.cp('-rf', path.join(cordova_project, 'platforms', 'blackberry'), path.join(tempDir, 'platforms')); - it('should shell out to build command', function() { - var s = spyOn(require('shelljs'), 'exec').andReturn({code:0}); - cordova.compile('blackberry'); - expect(s.mostRecentCall.args[0]).toMatch(/blackberry.cordova.build"$/gi); - }); - }); -}); http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/c04ca9d4/spec/platform-script/blackberry/blackberry_parser.spec.js ---------------------------------------------------------------------- diff --git a/spec/platform-script/blackberry/blackberry_parser.spec.js b/spec/platform-script/blackberry/blackberry_parser.spec.js deleted file mode 100644 index ec836e4..0000000 --- a/spec/platform-script/blackberry/blackberry_parser.spec.js +++ /dev/null @@ -1,248 +0,0 @@ -/** - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. -*/ -var blackberry_parser = require('../../../src/metadata/blackberry_parser'), - config_parser = require('../../../src/config_parser'), - path = require('path'), - util = require('../../../src/util'), - et = require('elementtree'), - shell = require('shelljs'), - cordova = require('../../../cordova'), - fs = require('fs'), - projects_path = path.join(__dirname, '..', '..', 'fixtures', 'projects'), - blackberry_path = path.join(projects_path, 'native', 'blackberry_fixture'), - project_path = path.join(projects_path, 'cordova'), - blackberry_project_path = path.join(project_path, 'platforms', 'blackberry'); - -var www_config = util.projectConfig(project_path); -var original_www_config = fs.readFileSync(www_config, 'utf-8'); - -describe('blackberry project parser', function() { - beforeEach(function() { - spyOn(process.stdout, 'write'); // silence console output - }); - - it('should throw an exception with a path that is not a native blackberry project', function() { - expect(function() { - var project = new blackberry_parser(process.cwd()); - }).toThrow(); - }); - it('should accept a proper native blackberry project path as construction parameter', function() { - var project; - expect(function() { - project = new blackberry_parser(blackberry_path); - }).not.toThrow(); - expect(project).toBeDefined(); - }); - - describe('update_from_config method', function() { - var project, config; - - var blackberry_config = path.join(blackberry_path, 'www', 'config.xml'); - var original_blackberry_config = fs.readFileSync(blackberry_config, 'utf-8'); - - beforeEach(function() { - project = new blackberry_parser(blackberry_path); - config = new config_parser(www_config); - }); - afterEach(function() { - fs.writeFileSync(blackberry_config, original_blackberry_config, 'utf-8'); - fs.writeFileSync(www_config, original_www_config, 'utf-8'); - }); - it('should throw an exception if a non config_parser object is passed into it', function() { - expect(function() { - project.update_from_config({}); - }).toThrow(); - }); - it('should update the application name properly', function() { - config.name('bond. james bond.'); - project.update_from_config(config); - - var bb_cfg = new config_parser(blackberry_config); - - expect(bb_cfg.name()).toBe('bond. james bond.'); - }); - it('should update the application package name properly', function() { - config.packageName('sofa.king.awesome'); - project.update_from_config(config); - - var bb_cfg = new config_parser(blackberry_config); - expect(bb_cfg.packageName()).toBe('sofa.king.awesome'); - }); - describe('whitelist', function() { - it('should update the whitelist when using access elements with origin attribute', function() { - config.access.remove('*'); - config.access.add('http://blackberry.com'); - config.access.add('http://rim.com'); - project.update_from_config(config); - - var bb_cfg = new et.ElementTree(et.XML(fs.readFileSync(blackberry_config, 'utf-8'))); - var as = bb_cfg.getroot().findall('access'); - expect(as.length).toEqual(2); - expect(as[0].attrib.uri).toEqual('http://blackberry.com'); - expect(as[1].attrib.uri).toEqual('http://rim.com'); - }); - it('should update the whitelist when using access elements with uri attributes', function() { - fs.writeFileSync(www_config, fs.readFileSync(www_config, 'utf-8').replace(/origin="\*/,'uri="http://rim.com'), 'utf-8'); - config = new config_parser(www_config); - project.update_from_config(config); - - var bb_cfg = new et.ElementTree(et.XML(fs.readFileSync(blackberry_config, 'utf-8'))); - var as = bb_cfg.getroot().findall('access'); - expect(as.length).toEqual(1); - expect(as[0].attrib.uri).toEqual('http://rim.com'); - }); - }); - }); - - describe('cross-platform project level methods', function() { - var parser, config; - - var blackberry_config = path.join(blackberry_project_path, 'www', 'config.xml'); - var original_blackberry_config = fs.readFileSync(blackberry_config, 'utf-8'); - - beforeEach(function() { - parser = new blackberry_parser(blackberry_project_path); - config = new config_parser(www_config); - }); - afterEach(function() { - fs.writeFileSync(blackberry_config, original_blackberry_config, 'utf-8'); - fs.writeFileSync(www_config, original_www_config, 'utf-8'); - }); - - describe('update_www method', function() { - it('should update all www assets', function() { - var newFile = path.join(util.projectWww(project_path), 'somescript.js'); - this.after(function() { - shell.rm('-f', newFile); - }); - fs.writeFileSync(newFile, 'alert("sup");', 'utf-8'); - parser.update_www(); - expect(fs.existsSync(path.join(blackberry_project_path, 'www', 'somescript.js'))).toBe(true); - }); - it('should not overwrite the blackberry-specific config.xml', function() { - var www_cfg = fs.readFileSync(util.projectConfig(project_path), 'utf-8'); - parser.update_www(); - var bb_cfg = fs.readFileSync(blackberry_config, 'utf-8'); - expect(bb_cfg).not.toBe(www_cfg); - }); - }); - - describe('update_overrides method',function() { - var mergesPath = path.join(util.appDir(project_path), 'merges', 'blackberry'); - var newFile = path.join(mergesPath, 'merge.js'); - beforeEach(function() { - shell.mkdir('-p', mergesPath); - fs.writeFileSync(newFile, 'alert("sup");', 'utf-8'); - }); - afterEach(function() { - shell.rm('-rf', mergesPath); - }); - - it('should copy a new file from merges into www', function() { - parser.update_overrides(); - expect(fs.existsSync(path.join(blackberry_project_path, 'www', 'merge.js'))).toBe(true); - }); - - it('should copy a file from merges over a file in www', function() { - var newFileWWW = path.join(util.projectWww(project_path), 'merge.js'); - fs.writeFileSync(newFileWWW, 'var foo=1;', 'utf-8'); - this.after(function() { - shell.rm('-rf', newFileWWW); - }); - parser.update_overrides(); - expect(fs.existsSync(path.join(blackberry_project_path, 'www', 'merge.js'))).toBe(true); - expect(fs.readFileSync(path.join(blackberry_project_path, 'www', 'merge.js'),'utf-8')).toEqual('alert("sup");'); - }); - }); - - describe('update_project method', function() { - var cordova_config_path = path.join(project_path, '.cordova', 'config.json'); - var original_config_json = fs.readFileSync(cordova_config_path, 'utf-8'); - - describe('with stubbed out config for BlackBerry SDKs', function() { - beforeEach(function() { - fs.writeFileSync(cordova_config_path, JSON.stringify({ - blackberry:{ - qnx:{ - } - } - }), 'utf-8'); - }); - afterEach(function() { - fs.writeFileSync(cordova_config_path, original_config_json, 'utf-8'); - }); - it('should invoke update_www', function() { - var spyWww = spyOn(parser, 'update_www'); - parser.update_project(config); - expect(spyWww).toHaveBeenCalled(); - }); - it('should invoke update_from_config', function() { - var spyConfig = spyOn(parser, 'update_from_config'); - parser.update_project(config); - expect(spyConfig).toHaveBeenCalled(); - }); - it('should not invoke get_blackberry_environment', function() { - var spyEnv = spyOn(parser, 'get_blackberry_environment'); - parser.update_project(config); - expect(spyEnv).not.toHaveBeenCalled(); - }); - it('should write out project properties', function(done) { - var spyProps = spyOn(parser, 'write_blackberry_environment'); - parser.update_project(config, function() { - expect(spyProps).toHaveBeenCalled(); - done(); - }); - }); - it('should call out to util.deleteSvnFolders', function(done) { - var spy = spyOn(util, 'deleteSvnFolders'); - parser.update_project(config, function() { - expect(spy).toHaveBeenCalled(); - done(); - }); - }); - }); - describe('with empty BlackBerry SDKs in config', function() { - afterEach(function() { - fs.writeFileSync(cordova_config_path, original_config_json, 'utf-8'); - }); - it('should invoke get_blackberry_environment', function() { - var spyEnv = spyOn(parser, 'get_blackberry_environment'); - var promptSpy = spyOn(require('prompt'), 'get'); - parser.update_project(config); - expect(spyEnv).toHaveBeenCalled(); - }); - it('should write out project properties', function(done) { - var spyProps = spyOn(parser, 'write_blackberry_environment'); - var promptSpy = spyOn(require('prompt'), 'get'); - parser.update_project(config, function() { - expect(spyProps).toHaveBeenCalled(); - done(); - }); - promptSpy.mostRecentCall.args[1](null, {}); - }); - }); - }); - }); - - describe('write_project_properties method', function() { - }); - - describe('get_blackberry_environment method', function() { - }); -}); http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/c04ca9d4/spec/platform-script/ios/ios.spec.js ---------------------------------------------------------------------- diff --git a/spec/platform-script/ios/ios.spec.js b/spec/platform-script/ios/ios.spec.js deleted file mode 100644 index 2723b83..0000000 --- a/spec/platform-script/ios/ios.spec.js +++ /dev/null @@ -1,90 +0,0 @@ -var cordova = require('../../../cordova'), - shell = require('shelljs'), - path = require('path'), - fs = require('fs'), - ios_parser = require('../../../src/metadata/ios_parser'), - tempDir = path.join(__dirname, '..', '..', '..', 'temp'), - fixtures = path.join(__dirname, '..', '..', 'fixtures'), - cordova_project = path.join(fixtures, 'projects', 'cordova'); - -var cwd = process.cwd(); - -describe('Test:', function() { - afterEach(function() { - process.chdir(cwd); - }); - - describe('\'platform add ios\'', function() { - var sh, cr; - var fake_reqs_check = function() { - cr.mostRecentCall.args[0](false); - }; - var fake_create = function(a_path) { - shell.mkdir('-p', a_path); - fs.writeFileSync(path.join(a_path, 'poo.xcodeproj'), 'hi', 'utf-8'); - shell.mkdir('-p', path.join(a_path, 'poo')); - shell.cp(path.join(cordova_project, 'www', 'config.xml'), path.join(a_path, 'poo', 'config.xml')); - sh.mostRecentCall.args[2](0, ''); - }; - beforeEach(function() { - sh = spyOn(shell, 'exec'); - cr = spyOn(ios_parser, 'check_requirements'); - shell.rm('-rf', tempDir); - cordova.create(tempDir); - process.chdir(tempDir); - }); - afterEach(function() { - process.chdir(cwd); - }); - it('should shell out to ios /bin/create', function() { - cordova.platform('add', 'ios'); - fake_reqs_check(); - var shell_cmd = sh.mostRecentCall.args[0]; - var create_cmd = path.join('ios', 'bin', 'create'); - expect(shell_cmd).toContain(create_cmd); - }); - it('should call ios_parser\'s update_project', function() { - spyOn(ios_parser.prototype, 'update_project'); - cordova.platform('add', 'ios'); - fake_reqs_check(); - fake_create(path.join(tempDir, 'platforms', 'ios')); - expect(ios_parser.prototype.update_project).toHaveBeenCalled(); - }); - }); - - describe('\'emulate ios\'', function() { - beforeEach(function() { - process.chdir(tempDir); - }); - afterEach(function() { - process.chdir(cwd); - }); - shell.rm('-rf', tempDir); - cordova.create(tempDir); - shell.cp('-rf', path.join(cordova_project, 'platforms', 'ios'), path.join(tempDir, 'platforms')); - it('should call ios_parser\'s update_project', function() { - spyOn(require('shelljs'), 'exec'); - spyOn(ios_parser.prototype, 'update_project'); - cordova.emulate('ios'); - expect(ios_parser.prototype.update_project).toHaveBeenCalled(); - }); - }); - - describe('\'compile ios\'', function() { - beforeEach(function() { - process.chdir(tempDir); - }); - afterEach(function() { - process.chdir(cwd); - }); - shell.rm('-rf', tempDir); - cordova.create(tempDir); - shell.cp('-rf', path.join(cordova_project, 'platforms', 'ios'), path.join(tempDir, 'platforms')); - it('should shell out to build command', function() { - var build_cmd = path.join('ios', 'cordova', 'build'); - var s = spyOn(require('shelljs'), 'exec').andReturn({code:0}); - cordova.compile('ios'); - expect(s.mostRecentCall.args[0]).toContain(build_cmd); - }); - }); -}); http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/c04ca9d4/spec/platform-script/ios/ios_parser.spec.js ---------------------------------------------------------------------- diff --git a/spec/platform-script/ios/ios_parser.spec.js b/spec/platform-script/ios/ios_parser.spec.js deleted file mode 100644 index 25f7833..0000000 --- a/spec/platform-script/ios/ios_parser.spec.js +++ /dev/null @@ -1,227 +0,0 @@ -/** - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. - */ - -var ios_parser = require('../../../src/metadata/ios_parser'), - config_parser = require('../../../src/config_parser'), - cordova = require('../../../cordova'), - util = require('../../../src/util'), - path = require('path'), - shell = require('shelljs'), - fs = require('fs'), - os = require('os'), - et = require('elementtree'), - projects_path = path.join(__dirname, '..', '..', 'fixtures', 'projects') - ios_path = path.join(projects_path, 'native', 'ios_fixture'), - project_path = path.join(projects_path, 'cordova'), - ios_project_path = path.join(project_path, 'platforms', 'ios'); - -var www_config = util.projectConfig(project_path); -var original_www_config = fs.readFileSync(www_config, 'utf-8'); - -describe('ios project parser', function () { - it('should throw an exception with a path that is not a native ios project', function () { - expect(function () { - var project = new ios_parser(process.cwd()); - }).toThrow(); - }); - it('should accept a proper native ios project path as construction parameter', function () { - var project; - expect(function () { - project = new ios_parser(ios_path); - }).not.toThrow(); - expect(project).toBeDefined(); - }); - - describe('update_from_config method', function () { - var project, config; - - var ios_plist = path.join(ios_path, 'cordovaExample', 'cordovaExample-Info.plist'), - ios_pbx = path.join(ios_path, 'cordovaExample.xcodeproj', 'project.pbxproj'), - ios_config_xml = path.join(ios_path, 'cordovaExample', 'config.xml'); - - var original_pbx = fs.readFileSync(ios_pbx, 'utf-8'); - var original_plist = fs.readFileSync(ios_plist, 'utf-8'); - var original_ios_config = fs.readFileSync(ios_config_xml, 'utf-8'); - - beforeEach(function () { - project = new ios_parser(ios_path); - config = new config_parser(www_config); - }); - afterEach(function () { - fs.writeFileSync(ios_pbx, original_pbx, 'utf-8'); - fs.writeFileSync(ios_config_xml, original_ios_config, 'utf-8'); - fs.writeFileSync(ios_plist, original_plist, 'utf-8'); - fs.writeFileSync(www_config, original_www_config, 'utf-8'); - }); - it('should throw an exception if a non config_parser object is passed into it', function () { - expect(function () { - project.update_from_config({}); - }).toThrow(); - }); - it('should update the application name properly', function (done) { - config.name('bond. james bond.'); - project.update_from_config(config, function () { - var pbx_contents = fs.readFileSync(ios_pbx, 'utf-8'); - expect(pbx_contents.match(/PRODUCT_NAME\s*=\s*"bond. james bond."/)[0]).toBe('PRODUCT_NAME = "bond. james bond."'); - done(); - }); - }); - it('should update the application package name (bundle identifier) properly', function (done) { - config.packageName('ca.filmaj.dewd'); - project.update_from_config(config, function () { - var plist_contents = fs.readFileSync(ios_plist, 'utf-8'); - expect(plist_contents).toMatch(/ca.filmaj.dewd/); - done(); - }); - }); - it('should update the application version (CFBundleVersion) properly', function (done) { - config.version('2.0.1'); - project.update_from_config(config, function () { - var plist_contents = fs.readFileSync(ios_plist, 'utf-8'); - expect(plist_contents).toMatch(/2.0.1/); - done(); - }); - }); - it('should update the whitelist in the project config.xml', function (done) { - project.update_from_config(config, function () { - var config_contents = fs.readFileSync(ios_config_xml, 'utf-8'); - expect(config_contents).toMatch(//); - done(); - }); - }); - describe('preferences', function () { - it('should not change default project preferences and copy over additional project preferences to platform-level config.xml', function (done) { - config.preference.add({name:'henrik', value:'sedin'}); - project.update_from_config(config, function () { - var native_config = new et.ElementTree(et.XML(fs.readFileSync(ios_config_xml, 'utf-8'))); - var ps = native_config.findall('preference'); - expect(ps.length).toEqual(17); - expect(ps[0].attrib.name).toEqual('KeyboardDisplayRequiresUserAction'); - expect(ps[0].attrib.value).toEqual('true'); - expect(ps[16].attrib.name).toEqual('henrik'); - expect(ps[16].attrib.value).toEqual('sedin'); - done(); - }); - }); - it('should override a default project preference if applicable', function (done) { - config.preference.add({name:'UIWebViewBounce', value:'false'}); - project.update_from_config(config, function () { - var native_config = new et.ElementTree(et.XML(fs.readFileSync(ios_config_xml, 'utf-8'))); - var ps = native_config.findall('preference'); - expect(ps.length).toEqual(16); - expect(ps[2].attrib.name).toEqual('UIWebViewBounce'); - expect(ps[2].attrib.value).toEqual('false'); - done(); - }); - }); - }); - }); - - describe('cross-platform project level methods', function () { - var parser, config; - var ios_plist = path.join(ios_project_path, 'cordovaExample', 'cordovaExample-Info.plist'), - ios_pbx = path.join(ios_project_path, 'cordovaExample.xcodeproj', 'project.pbxproj'), - ios_config_xml = path.join(ios_project_path, 'cordovaExample', 'config.xml'); - - var original_pbx = fs.readFileSync(ios_pbx, 'utf-8'); - var original_plist = fs.readFileSync(ios_plist, 'utf-8'); - var original_ios_config = fs.readFileSync(ios_config_xml, 'utf-8'); - - beforeEach(function () { - parser = new ios_parser(ios_project_path); - config = new config_parser(www_config); - }); - afterEach(function () { - fs.writeFileSync(ios_pbx, original_pbx, 'utf-8'); - fs.writeFileSync(ios_config_xml, original_ios_config, 'utf-8'); - fs.writeFileSync(ios_plist, original_plist, 'utf-8'); - fs.writeFileSync(www_config, original_www_config, 'utf-8'); - }); - - describe('update_www method', function () { - it('should update all www assets', function () { - var newFile = path.join(util.projectWww(project_path), 'somescript.js'); - this.after(function () { - shell.rm('-f', newFile); - }); - fs.writeFileSync(newFile, 'alert("sup");', 'utf-8'); - parser.update_www(); - expect(fs.existsSync(path.join(ios_project_path, 'www', 'somescript.js'))).toBe(true); - }); - it('should write out ios js to cordova.js', function () { - parser.update_www(); - expect(fs.readFileSync(path.join(ios_project_path, 'www', 'cordova.js'), 'utf-8')).toBe(fs.readFileSync(path.join(util.libDirectory, 'cordova-ios', 'CordovaLib', 'cordova.js'), 'utf-8')); - }); - }); - - describe('update_overrides method', function () { - var mergesPath = path.join(util.appDir(project_path), 'merges', 'ios'); - var newFile = path.join(mergesPath, 'merge.js'); - beforeEach(function() { - shell.mkdir('-p', mergesPath); - fs.writeFileSync(newFile, 'alert("sup");', 'utf-8'); - }); - afterEach(function() { - shell.rm('-rf', mergesPath); - }); - - it('should copy a new file from merges into www', function () { - parser.update_overrides(); - expect(fs.existsSync(path.join(ios_project_path, 'www', 'merge.js'))).toBe(true); - }); - - it('should copy a file from merges over a file in www', function () { - var newFileWWW = path.join(util.projectWww(project_path), 'merge.js'); - fs.writeFileSync(newFileWWW, 'var foo=1;', 'utf-8'); - this.after(function () { - shell.rm('-rf', newFileWWW); - }); - - parser.update_overrides(); - expect(fs.existsSync(path.join(ios_project_path, 'www', 'merge.js'))).toBe(true); - expect(fs.readFileSync(path.join(ios_project_path, 'www', 'merge.js'), 'utf-8')).toEqual('alert("sup");'); - }); - }); - - describe('update_project method', function () { - it('should invoke update_www', function (done) { - var spyWww = spyOn(parser, 'update_www'); - parser.update_project(config, function () { - expect(spyWww).toHaveBeenCalled(); - done(); - }); - }); - it('should invoke update_from_config', function (done) { - var spyConfig = spyOn(parser, 'update_from_config').andCallThrough(); - parser.update_project(config, function () { - expect(spyConfig).toHaveBeenCalled(); - done(); - }); - }); - it('should call out to util.deleteSvnFolders', function(done) { - var spy = spyOn(util, 'deleteSvnFolders'); - var spyConfig = spyOn(parser, 'update_from_config').andCallThrough(); - parser.update_project(config, function () { - expect(spy).toHaveBeenCalled(); - done(); - }); - }); - }); - }); -}); http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/c04ca9d4/spec/platform-script/wp7/wp7.spec.js ---------------------------------------------------------------------- diff --git a/spec/platform-script/wp7/wp7.spec.js b/spec/platform-script/wp7/wp7.spec.js deleted file mode 100644 index 6b7f3b4..0000000 --- a/spec/platform-script/wp7/wp7.spec.js +++ /dev/null @@ -1,99 +0,0 @@ -var cordova = require('../../../cordova'), - shell = require('shelljs'), - path = require('path'), - fs = require('fs'), - wp7_parser = require('../../../src/metadata/wp7_parser'), - tempDir = path.join(__dirname, '..', '..', '..', 'temp'), - fixtures = path.join(__dirname, '..', '..', 'fixtures'), - cordova_project = path.join(fixtures, 'projects', 'cordova'); - -var cwd = process.cwd(); - -describe('Test:', function() { - afterEach(function() { - process.chdir(cwd); - }); - - describe('\'platform add wp7\'', function() { - var sh, cr; - var fake_reqs_check = function() { - expect(cr.mostRecentCall.args).toBeDefined(); - cr.mostRecentCall.args[0](false); - }; - var fake_create = function(a_path) { - shell.mkdir('-p', a_path); - fs.writeFileSync(path.join(a_path, 'wp7Project.csproj'), 'hi', 'utf-8'); - fs.writeFileSync(path.join(a_path, 'wp7Project.sln'), 'hi', 'utf-8'); - sh.mostRecentCall.args[2](0, ''); - }; - beforeEach(function() { - sh = spyOn(shell, 'exec'); - cr = spyOn(wp7_parser, 'check_requirements'); - shell.rm('-rf', tempDir); - cordova.create(tempDir); - process.chdir(tempDir); - }); - afterEach(function() { - process.chdir(cwd); - }); - it('should shell out to wp7 /bin/create', function() { - cordova.platform('add', 'wp7'); - fake_reqs_check(); - var shell_cmd = sh.mostRecentCall.args[0]; - var create_cmd = path.join('wp7', 'bin', 'create'); - expect(shell_cmd).toContain(create_cmd); - }); - it('should call wp7_parser\'s update_project', function() { - spyOn(wp7_parser.prototype, 'update_project'); - cordova.platform('add', 'wp7'); - fake_reqs_check(); - fake_create(path.join(tempDir, 'platforms', 'wp7')); - expect(wp7_parser.prototype.update_project).toHaveBeenCalled(); - }); - }); - - describe('\'emulate wp7\'', function() { - beforeEach(function() { - process.chdir(tempDir); - }); - afterEach(function() { - process.chdir(cwd); - }); - shell.rm('-rf', tempDir); - cordova.create(tempDir); - shell.cp('-rf', path.join(cordova_project, 'platforms', 'wp7'), path.join(tempDir, 'platforms')); - it('should shell out to run command on wp7', function() { - var proj_spy = spyOn(wp7_parser.prototype, 'update_project'); - var s = spyOn(require('shelljs'), 'exec'); - cordova.emulate('wp7'); - proj_spy.mostRecentCall.args[1](); // update_project fake - expect(s).toHaveBeenCalled(); - var emulate_cmd = path.join('wp7', 'cordova', 'run'); - expect(s.mostRecentCall.args[0]).toContain(emulate_cmd); - }); - it('should call wp7_parser\'s update_project', function() { - spyOn(require('shelljs'), 'exec'); - spyOn(wp7_parser.prototype, 'update_project'); - cordova.emulate('wp7'); - expect(wp7_parser.prototype.update_project).toHaveBeenCalled(); - }); - }); - - describe('\'compile wp7\'', function() { - beforeEach(function() { - process.chdir(tempDir); - }); - afterEach(function() { - process.chdir(cwd); - }); - shell.rm('-rf', tempDir); - cordova.create(tempDir); - shell.cp('-rf', path.join(cordova_project, 'platforms', 'wp7'), path.join(tempDir, 'platforms')); - it('should shell out to build command', function() { - var build_cmd = path.join('wp7', 'cordova', 'build'); - var s = spyOn(require('shelljs'), 'exec').andReturn({code:0}); - cordova.compile('wp7'); - expect(s.mostRecentCall.args[0]).toContain(build_cmd); - }); - }); -}); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/c04ca9d4/spec/platform-script/wp7/wp7_parser.spec.js ---------------------------------------------------------------------- diff --git a/spec/platform-script/wp7/wp7_parser.spec.js b/spec/platform-script/wp7/wp7_parser.spec.js deleted file mode 100644 index 61111a1..0000000 --- a/spec/platform-script/wp7/wp7_parser.spec.js +++ /dev/null @@ -1,247 +0,0 @@ - -/** - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. -*/ -var wp7_parser = require('../../../src/metadata/wp7_parser'), - config_parser = require('../../../src/config_parser'), - util = require('../../../src/util'), - path = require('path'), - shell = require('shelljs'), - fs = require('fs'), - os = require('os'), - et = require('elementtree'), - cordova = require('../../../cordova'), - projects_path = path.join(__dirname, '..', '..', 'fixtures', 'projects'), - wp7_path = path.join(projects_path, 'native', 'wp7_fixture'), - project_path = path.join(projects_path, 'cordova'), - wp7_project_path = path.join(project_path, 'platforms', 'wp7'); - -var www_config = util.projectConfig(project_path); -var original_www_config = fs.readFileSync(www_config, 'utf-8'); - -describe('wp7 project parser', function() { - it('should throw an exception with a path that is not a native wp7 project', function() { - expect(function() { - var project = new wp7_parser(process.cwd()); - }).toThrow(); - }); - it('should accept a proper native wp7 project path as construction parameter', function() { - expect(function() { - var project = new wp7_parser(wp7_path); - expect(project).toBeDefined(); - }).not.toThrow(); - }); - - describe('update_from_config method', function() { - var config; - var project = new wp7_parser(wp7_path); - - var manifest_path = path.join(wp7_path, 'Properties', 'WMAppManifest.xml'); - var csproj_path = project.csproj_path; - var sln_path = project.sln_path; - var app_xaml_path = path.join(wp7_path, 'App.xaml'); - var app_cs_path = path.join(wp7_path, 'App.xaml.cs'); - var main_xaml_path = path.join(wp7_path, 'MainPage.xaml'); - var main_cs_path = path.join(wp7_path, 'MainPage.xaml.cs'); - - - var original_manifest = fs.readFileSync(manifest_path, 'utf-8'); - var original_csproj = fs.readFileSync(csproj_path, 'utf-8'); - var original_sln = fs.readFileSync(sln_path, 'utf-8'); - var original_app_xaml = fs.readFileSync(app_xaml_path, 'utf-8'); - var original_app_cs = fs.readFileSync(app_cs_path, 'utf-8'); - var original_main_xaml = fs.readFileSync(main_xaml_path, 'utf-8'); - var original_main_cs = fs.readFileSync(main_cs_path, 'utf-8'); - - beforeEach(function() { - project = new wp7_parser(wp7_path); - config = new config_parser(www_config); - }); - afterEach(function() { - fs.writeFileSync(manifest_path, original_manifest, 'utf-8'); - // csproj file changes name if app changes name - fs.unlinkSync(project.csproj_path); - fs.unlinkSync(project.sln_path); - fs.writeFileSync(csproj_path, original_csproj, 'utf-8'); - fs.writeFileSync(sln_path, original_sln, 'utf-8'); - fs.writeFileSync(app_xaml_path, original_app_xaml, 'utf-8'); - fs.writeFileSync(app_cs_path, original_app_cs, 'utf-8'); - fs.writeFileSync(main_xaml_path, original_main_xaml, 'utf-8'); - fs.writeFileSync(main_cs_path, original_main_cs, 'utf-8'); - }); - it('should throw an exception if a non config_parser object is passed into it', function() { - expect(function() { - project.update_from_config({}); - }).toThrow(); - }); - it('should update the application name properly', function() { - var test_name = 'bond. james bond.'; - config.name(test_name); - project.update_from_config(config); - var raw_manifest = fs.readFileSync(manifest_path, 'utf-8'); - //Strip three bytes that windows adds (http://www.multiasking.com/2012/11/851) - var cleaned_manifest = raw_manifest.replace('\ufeff', ''); - var manifest = new et.ElementTree(et.XML(cleaned_manifest)); - var app_name = manifest.find('.//App[@Title]')['attrib']['Title']; - expect(app_name).toBe(test_name); - - //check for the proper name of csproj and solution files - test_name = test_name.replace(/(\.\s|\s\.|\s+|\.+)/g, '_'); //make it a ligitamate name - expect(project.csproj_path).toContain(test_name); - expect(project.sln_path).toContain(test_name); - }); - it('should update the application package name properly', function() { - var test_package = 'ca.filmaj.dewd' - config.packageName(test_package); - project.update_from_config(config); - - // check csproj file (use regex instead of elementtree?) - var raw_csproj = fs.readFileSync(project.csproj_path, 'utf-8'); - var cleaned_csproj = raw_csproj.replace(/^\uFEFF/i, ''); - var csproj = new et.ElementTree(et.XML(cleaned_csproj)); - expect(csproj.find('.//RootNamespace').text).toEqual(test_package); - expect(csproj.find('.//AssemblyName').text).toEqual(test_package); - expect(csproj.find('.//XapFilename').text).toEqual(test_package + '.xap'); - expect(csproj.find('.//SilverlightAppEntry').text).toEqual(test_package + '.App'); - - // check app.xaml (use regex instead of elementtree?) - var new_app_xaml = fs.readFileSync(app_xaml_path, 'utf-8'); - var cleaned_app_xaml = new_app_xaml.replace(/^\uFEFF/i, ''); - var app_xaml = new et.ElementTree(et.XML(cleaned_app_xaml)); - expect(app_xaml._root.attrib['x:Class']).toEqual(test_package + '.App'); - - // check app.xaml.cs - var new_app_cs = fs.readFileSync(app_cs_path, 'utf-8'); - expect(new_app_cs).toContain('namespace ' + test_package); - - // check MainPage.xaml (use regex instead of elementtree?) - var new_main_xaml = fs.readFileSync(main_xaml_path, 'utf-8'); - var cleaned_main_xaml = new_main_xaml.replace(/^\uFEFF/i, ''); - var main_xaml = new et.ElementTree(et.XML(cleaned_main_xaml)); - expect(main_xaml._root.attrib['x:Class']).toEqual(test_package + '.MainPage'); - - //check MainPage.xaml.cs - var new_main_cs = fs.readFileSync(main_cs_path, 'utf-8'); - expect(new_main_cs).toContain('namespace ' + test_package); - }); - xdescribe('preferences', function() { - it('should not change default project preferences and copy over additional project preferences to platform-level config.xml', function() { - /*config.preference.add({name:'henrik',value:'sedin'}); - project.update_from_config(config); - - var native_config = new et.ElementTree(et.XML(fs.readFileSync(android_config, 'utf-8'))); - var ps = native_config.findall('preference'); - expect(ps.length).toEqual(7); - expect(ps[0].attrib.name).toEqual('useBrowserHistory'); - expect(ps[0].attrib.value).toEqual('true'); - expect(ps[6].attrib.name).toEqual('henrik'); - expect(ps[6].attrib.value).toEqual('sedin');*/ - - // TODO : figure out if this is supported - //expect(true).toBe(false); - }); - it('should override a default project preference if applicable', function() { - /*config.preference.add({name:'useBrowserHistory',value:'false'}); - project.update_from_config(config); - - var native_config = new et.ElementTree(et.XML(fs.readFileSync(android_config, 'utf-8'))); - var ps = native_config.findall('preference'); - expect(ps.length).toEqual(6); - expect(ps[0].attrib.name).toEqual('useBrowserHistory'); - expect(ps[0].attrib.value).toEqual('false');*/ - - // TODO : figure out if this is supported - //expect(true).toBe(false); - }); - }); - }); - - describe('cross-platform project level methods', function() { - var parser, config; - - beforeEach(function() { - parser = new wp7_parser(wp7_project_path); - config = new config_parser(www_config); - }); - afterEach(function() { - }); - describe('update_www method', function() { - it('should update all www assets', function() { - var newFile = path.join(util.projectWww(project_path), 'somescript.js'); - this.after(function() { - shell.rm('-f', newFile); - }); - fs.writeFileSync(newFile, 'alert("sup");', 'utf-8'); - parser.update_www(); - expect(fs.existsSync(path.join(wp7_project_path, 'www', 'somescript.js'))).toBe(true); - }); - it('should write out windows-phone js to cordova.js', function() { - parser.update_www(); - expect(fs.readFileSync(path.join(wp7_project_path, 'www', 'cordova.js'),'utf-8')).toEqual(fs.readFileSync(path.join(util.libDirectory, 'cordova-wp7', 'templates', 'standalone', 'www', 'cordova.js'), 'utf-8')); - }); - }); - - xdescribe('update_overrides method',function() { - /*var mergesPath = path.join(util.appDir(project_path), 'merges', 'android'); - var newFile = path.join(mergesPath, 'merge.js'); - beforeEach(function() { - shell.mkdir('-p', mergesPath); - fs.writeFileSync(newFile, 'alert("sup");', 'utf-8'); - }); - afterEach(function() { - shell.rm('-rf', mergesPath); - }); - it('should copy a new file from merges into www', function() { - parser.update_overrides(); - expect(fs.existsSync(path.join(wp7_project_path, 'assets', 'www', 'merge.js'))).toBe(true); - }); - - it('should copy a file from merges over a file in www', function() { - var newFileWWW = path.join(util.projectWww(project_path), 'merge.js'); - fs.writeFileSync(newFileWWW, 'var foo=1;', 'utf-8'); - this.after(function() { - shell.rm('-rf', newFileWWW); - }); - parser.update_overrides(); - expect(fs.existsSync(path.join(wp7_project_path, 'assets', 'www', 'merge.js'))).toBe(true); - expect(fs.readFileSync(path.join(wp7_project_path, 'assets', 'www', 'merge.js'),'utf-8')).toEqual('alert("sup");'); - });*/ - - // TODO : figure out if this is supported - //expect(true).toBe(false); - }); - - describe('update_project method', function() { - it('should invoke update_www', function() { - var spyWww = spyOn(parser, 'update_www'); - parser.update_project(config); - expect(spyWww).toHaveBeenCalled(); - }); - it('should invoke update_from_config', function() { - var spyConfig = spyOn(parser, 'update_from_config'); - parser.update_project(config); - expect(spyConfig).toHaveBeenCalled(); - }); - it('should call out to util.deleteSvnFolders', function() { - var spy = spyOn(util, 'deleteSvnFolders'); - parser.update_project(config); - expect(spy).toHaveBeenCalled(); - }); - }); - }); -}); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/c04ca9d4/spec/platform-script/wp8/wp8.spec.js ---------------------------------------------------------------------- diff --git a/spec/platform-script/wp8/wp8.spec.js b/spec/platform-script/wp8/wp8.spec.js deleted file mode 100644 index 998094c..0000000 --- a/spec/platform-script/wp8/wp8.spec.js +++ /dev/null @@ -1,99 +0,0 @@ -var cordova = require('../../../cordova'), - shell = require('shelljs'), - path = require('path'), - fs = require('fs'), - wp8_parser = require('../../../src/metadata/wp8_parser'), - tempDir = path.join(__dirname, '..', '..', '..', 'temp'), - fixtures = path.join(__dirname, '..', '..', 'fixtures'), - cordova_project = path.join(fixtures, 'projects', 'cordova'); - -var cwd = process.cwd(); - -describe('Test:', function() { - afterEach(function() { - process.chdir(cwd); - }); - - describe('\'platform add wp8\'', function() { - var sh, cr; - var fake_reqs_check = function() { - expect(cr.mostRecentCall.args).toBeDefined(); - cr.mostRecentCall.args[0](false); - }; - var fake_create = function(a_path) { - shell.mkdir('-p', a_path); - fs.writeFileSync(path.join(a_path, 'wp7Project.csproj'), 'hi', 'utf-8'); - fs.writeFileSync(path.join(a_path, 'wp7Project.sln'), 'hi', 'utf-8'); - sh.mostRecentCall.args[2](0, ''); - }; - beforeEach(function() { - sh = spyOn(shell, 'exec'); - cr = spyOn(wp8_parser, 'check_requirements'); - shell.rm('-rf', tempDir); - cordova.create(tempDir); - process.chdir(tempDir); - }); - afterEach(function() { - process.chdir(cwd); - }); - it('should shell out to wp8 /bin/create', function() { - cordova.platform('add', 'wp8'); - fake_reqs_check(); - var shell_cmd = sh.mostRecentCall.args[0]; - var create_cmd = path.join('wp8', 'bin', 'create'); - expect(shell_cmd).toContain(create_cmd); - }); - it('should call wp8_parser\'s update_project', function() { - spyOn(wp8_parser.prototype, 'update_project'); - cordova.platform('add', 'wp8'); - fake_reqs_check(); - fake_create(path.join(tempDir, 'platforms', 'wp8')); - expect(wp8_parser.prototype.update_project).toHaveBeenCalled(); - }); - }); - - describe('\'emulate wp8\'', function() { - beforeEach(function() { - process.chdir(tempDir); - }); - afterEach(function() { - process.chdir(cwd); - }); - shell.rm('-rf', tempDir); - cordova.create(tempDir); - shell.cp('-rf', path.join(cordova_project, 'platforms', 'wp8'), path.join(tempDir, 'platforms')); - it('should shell out to run command on wp8', function() { - var proj_spy = spyOn(wp8_parser.prototype, 'update_project'); - var s = spyOn(require('shelljs'), 'exec'); - cordova.emulate('wp8'); - proj_spy.mostRecentCall.args[1](); // update_project fake - expect(s).toHaveBeenCalled(); - var emulate_cmd = path.join('wp8', 'cordova', 'run'); - expect(s.mostRecentCall.args[0]).toContain(emulate_cmd); - }); - it('should call wp8_parser\'s update_project', function() { - spyOn(require('shelljs'), 'exec'); - spyOn(wp8_parser.prototype, 'update_project'); - cordova.emulate('wp8'); - expect(wp8_parser.prototype.update_project).toHaveBeenCalled(); - }); - }); - - describe('\'compile wp8\'', function() { - beforeEach(function() { - process.chdir(tempDir); - }); - afterEach(function() { - process.chdir(cwd); - }); - shell.rm('-rf', tempDir); - cordova.create(tempDir); - shell.cp('-rf', path.join(cordova_project, 'platforms', 'wp8'), path.join(tempDir, 'platforms')); - it('should shell out to build command', function() { - var build_cmd = path.join('wp8', 'cordova', 'build'); - var s = spyOn(require('shelljs'), 'exec').andReturn({code:0}); - cordova.compile('wp8'); - expect(s.mostRecentCall.args[0]).toContain(build_cmd); - }); - }); -}); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/c04ca9d4/spec/platform-script/wp8/wp8_parser.spec.js ---------------------------------------------------------------------- diff --git a/spec/platform-script/wp8/wp8_parser.spec.js b/spec/platform-script/wp8/wp8_parser.spec.js deleted file mode 100644 index 9f1f2d4..0000000 --- a/spec/platform-script/wp8/wp8_parser.spec.js +++ /dev/null @@ -1,247 +0,0 @@ - -/** - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. -*/ -var wp8_parser = require('../../../src/metadata/wp8_parser'), - config_parser = require('../../../src/config_parser'), - util = require('../../../src/util'), - path = require('path'), - shell = require('shelljs'), - fs = require('fs'), - os = require('os'), - et = require('elementtree'), - cordova = require('../../../cordova'), - projects_path = path.join(__dirname, '..', '..', 'fixtures', 'projects'), - wp8_path = path.join(projects_path, 'native', 'wp8_fixture'), - project_path = path.join(projects_path, 'cordova'), - wp8_project_path = path.join(project_path, 'platforms', 'wp8'); - -var www_config = util.projectConfig(project_path); -var original_www_config = fs.readFileSync(www_config, 'utf-8'); - -describe('wp8 project parser', function() { - it('should throw an exception with a path that is not a native wp8 project', function() { - expect(function() { - var project = new wp8_parser(process.cwd()); - }).toThrow(); - }); - it('should accept a proper native wp8 project path as construction parameter', function() { - expect(function() { - var project = new wp8_parser(wp8_path); - expect(project).toBeDefined(); - }).not.toThrow(); - }); - - describe('update_from_config method', function() { - var config; - var project = new wp8_parser(wp8_path); - - var manifest_path = path.join(wp8_path, 'Properties', 'WMAppManifest.xml'); - var csproj_path = project.csproj_path; - var sln_path = project.sln_path; - var app_xaml_path = path.join(wp8_path, 'App.xaml'); - var app_cs_path = path.join(wp8_path, 'App.xaml.cs'); - var main_xaml_path = path.join(wp8_path, 'MainPage.xaml'); - var main_cs_path = path.join(wp8_path, 'MainPage.xaml.cs'); - - - var original_manifest = fs.readFileSync(manifest_path, 'utf-8'); - var original_csproj = fs.readFileSync(csproj_path, 'utf-8'); - var original_sln = fs.readFileSync(sln_path, 'utf-8'); - var original_app_xaml = fs.readFileSync(app_xaml_path, 'utf-8'); - var original_app_cs = fs.readFileSync(app_cs_path, 'utf-8'); - var original_main_xaml = fs.readFileSync(main_xaml_path, 'utf-8'); - var original_main_cs = fs.readFileSync(main_cs_path, 'utf-8'); - - beforeEach(function() { - project = new wp8_parser(wp8_path); - config = new config_parser(www_config); - }); - afterEach(function() { - fs.writeFileSync(manifest_path, original_manifest, 'utf-8'); - // csproj file changes name if app changes name - fs.unlinkSync(project.csproj_path); - fs.unlinkSync(project.sln_path); - fs.writeFileSync(csproj_path, original_csproj, 'utf-8'); - fs.writeFileSync(sln_path, original_sln, 'utf-8'); - fs.writeFileSync(app_xaml_path, original_app_xaml, 'utf-8'); - fs.writeFileSync(app_cs_path, original_app_cs, 'utf-8'); - fs.writeFileSync(main_xaml_path, original_main_xaml, 'utf-8'); - fs.writeFileSync(main_cs_path, original_main_cs, 'utf-8'); - }); - it('should throw an exception if a non config_parser object is passed into it', function() { - expect(function() { - project.update_from_config({}); - }).toThrow(); - }); - it('should update the application name properly', function() { - var test_name = 'bond. james bond.'; - config.name(test_name); - project.update_from_config(config); - var raw_manifest = fs.readFileSync(manifest_path, 'utf-8'); - //Strip three bytes that windows adds (http://www.multiasking.com/2012/11/851) - var cleaned_manifest = raw_manifest.replace('\ufeff', ''); - var manifest = new et.ElementTree(et.XML(cleaned_manifest)); - var app_name = manifest.find('.//App[@Title]')['attrib']['Title']; - expect(app_name).toBe(test_name); - - //check for the proper name of csproj and solution files - test_name = test_name.replace(/(\.\s|\s\.|\s+|\.+)/g, '_'); //make it a ligitamate name - expect(project.csproj_path).toContain(test_name); - expect(project.sln_path).toContain(test_name); - }); - it('should update the application package name properly', function() { - var test_package = 'ca.filmaj.dewd' - config.packageName(test_package); - project.update_from_config(config); - - // check csproj file (use regex instead of elementtree?) - var raw_csproj = fs.readFileSync(project.csproj_path, 'utf-8'); - var cleaned_csproj = raw_csproj.replace(/^\uFEFF/i, ''); - var csproj = new et.ElementTree(et.XML(cleaned_csproj)); - expect(csproj.find('.//RootNamespace').text).toEqual(test_package); - expect(csproj.find('.//AssemblyName').text).toEqual(test_package); - expect(csproj.find('.//XapFilename').text).toEqual(test_package + '.xap'); - expect(csproj.find('.//SilverlightAppEntry').text).toEqual(test_package + '.App'); - - // check app.xaml (use regex instead of elementtree?) - var new_app_xaml = fs.readFileSync(app_xaml_path, 'utf-8'); - var cleaned_app_xaml = new_app_xaml.replace(/^\uFEFF/i, ''); - var app_xaml = new et.ElementTree(et.XML(cleaned_app_xaml)); - expect(app_xaml._root.attrib['x:Class']).toEqual(test_package + '.App'); - - // check app.xaml.cs - var new_app_cs = fs.readFileSync(app_cs_path, 'utf-8'); - expect(new_app_cs).toContain('namespace ' + test_package); - - // check MainPage.xaml (use regex instead of elementtree?) - var new_main_xaml = fs.readFileSync(main_xaml_path, 'utf-8'); - var cleaned_main_xaml = new_main_xaml.replace(/^\uFEFF/i, ''); - var main_xaml = new et.ElementTree(et.XML(cleaned_main_xaml)); - expect(main_xaml._root.attrib['x:Class']).toEqual(test_package + '.MainPage'); - - //check MainPage.xaml.cs - var new_main_cs = fs.readFileSync(main_cs_path, 'utf-8'); - expect(new_main_cs).toContain('namespace ' + test_package); - }); - xdescribe('preferences', function() { - it('should not change default project preferences and copy over additional project preferences to platform-level config.xml', function() { - /*config.preference.add({name:'henrik',value:'sedin'}); - project.update_from_config(config); - - var native_config = new et.ElementTree(et.XML(fs.readFileSync(android_config, 'utf-8'))); - var ps = native_config.findall('preference'); - expect(ps.length).toEqual(7); - expect(ps[0].attrib.name).toEqual('useBrowserHistory'); - expect(ps[0].attrib.value).toEqual('true'); - expect(ps[6].attrib.name).toEqual('henrik'); - expect(ps[6].attrib.value).toEqual('sedin');*/ - - // TODO : figure out if this is supported - //expect(true).toBe(false); - }); - it('should override a default project preference if applicable', function() { - /*config.preference.add({name:'useBrowserHistory',value:'false'}); - project.update_from_config(config); - - var native_config = new et.ElementTree(et.XML(fs.readFileSync(android_config, 'utf-8'))); - var ps = native_config.findall('preference'); - expect(ps.length).toEqual(6); - expect(ps[0].attrib.name).toEqual('useBrowserHistory'); - expect(ps[0].attrib.value).toEqual('false');*/ - - // TODO : figure out if this is supported - //expect(true).toBe(false); - }); - }); - }); - - describe('cross-platform project level methods', function() { - var parser, config; - - beforeEach(function() { - parser = new wp8_parser(wp8_project_path); - config = new config_parser(www_config); - }); - afterEach(function() { - }); - describe('update_www method', function() { - it('should update all www assets', function() { - var newFile = path.join(util.projectWww(project_path), 'somescript.js'); - this.after(function() { - shell.rm('-f', newFile); - }); - fs.writeFileSync(newFile, 'alert("sup");', 'utf-8'); - parser.update_www(); - expect(fs.existsSync(path.join(wp8_project_path, 'www', 'somescript.js'))).toBe(true); - }); - it('should write out windows-phone js to cordova.js', function() { - parser.update_www(); - expect(fs.readFileSync(path.join(wp8_project_path, 'www', 'cordova.js'),'utf-8')).toEqual(fs.readFileSync(path.join(util.libDirectory, 'cordova-wp8', 'templates', 'standalone', 'www', 'cordova.js'), 'utf-8')); - }); - }); - - xdescribe('update_overrides method',function() { - /*var mergesPath = path.join(util.appDir(project_path), 'merges', 'android'); - var newFile = path.join(mergesPath, 'merge.js'); - beforeEach(function() { - shell.mkdir('-p', mergesPath); - fs.writeFileSync(newFile, 'alert("sup");', 'utf-8'); - }); - afterEach(function() { - shell.rm('-rf', mergesPath); - }); - it('should copy a new file from merges into www', function() { - parser.update_overrides(); - expect(fs.existsSync(path.join(wp8_project_path, 'assets', 'www', 'merge.js'))).toBe(true); - }); - - it('should copy a file from merges over a file in www', function() { - var newFileWWW = path.join(util.projectWww(project_path), 'merge.js'); - fs.writeFileSync(newFileWWW, 'var foo=1;', 'utf-8'); - this.after(function() { - shell.rm('-rf', newFileWWW); - }); - parser.update_overrides(); - expect(fs.existsSync(path.join(wp8_project_path, 'assets', 'www', 'merge.js'))).toBe(true); - expect(fs.readFileSync(path.join(wp8_project_path, 'assets', 'www', 'merge.js'),'utf-8')).toEqual('alert("sup");'); - });*/ - - // TODO : figure out if this is supported - //expect(true).toBe(false); - }); - - describe('update_project method', function() { - it('should invoke update_www', function() { - var spyWww = spyOn(parser, 'update_www'); - parser.update_project(config); - expect(spyWww).toHaveBeenCalled(); - }); - it('should invoke update_from_config', function() { - var spyConfig = spyOn(parser, 'update_from_config'); - parser.update_project(config); - expect(spyConfig).toHaveBeenCalled(); - }); - it('should call out to util.deleteSvnFolders', function() { - var spy = spyOn(util, 'deleteSvnFolders'); - parser.update_project(config); - expect(spy).toHaveBeenCalled(); - }); - }); - }); -}); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/c04ca9d4/src/metadata/android_parser.js ---------------------------------------------------------------------- diff --git a/src/metadata/android_parser.js b/src/metadata/android_parser.js index c109b1a..d71473e 100644 --- a/src/metadata/android_parser.js +++ b/src/metadata/android_parser.js @@ -177,7 +177,6 @@ module.exports.prototype = { // update the overrides folder into the www folder update_staging:function() { - var projectRoot = util.isCordova(this.path); if (fs.existsSync(this.staging_dir())) { var staging = path.join(this.staging_dir(), '*'); shell.cp('-rf', staging, this.www_dir()); http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/c04ca9d4/src/platform.js ---------------------------------------------------------------------- diff --git a/src/platform.js b/src/platform.js index da783fb..66cc528 100644 --- a/src/platform.js +++ b/src/platform.js @@ -240,7 +240,7 @@ function call_into_create(target, projectRoot, cfg, id, version, callback, end) createOverrides(projectRoot, target); end(); //platform add is done by now. // Install all currently installed plugins into this new platform. - var plugins = cordova_util.findPlugins(projectRoot); + var plugins = cordova_util.findPlugins(path.join(projectRoot, 'plugins')); plugins && plugins.forEach(function(plugin) { events.emit('log', 'Installing plugin "' + plugin + '" following successful platform add of ' + target); plugman.install(target, output, path.basename(plugin), pluginsDir, { www_dir: parser.staging_dir() });