| /* |
| * |
| * Copyright 2013 Anis Kadri |
| * |
| * Licensed 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 fs = require('fs') |
| , path = require('path') |
| , plist = require('plist') |
| , xcode = require('xcode') |
| , osenv = require('osenv') |
| , shell = require('shelljs') |
| , et = require('elementtree') |
| , www = require(path.join(__dirname, '..', 'platforms', 'www')) |
| |
| , test_dir = path.join(osenv.tmpdir(), 'test_plugman') |
| , test_project_dir = path.join(test_dir, 'projects', 'www-only') |
| , test_plugin_dir = path.join(test_dir, 'plugins', 'ChildBrowser') |
| , xml_path = path.join(test_dir, 'plugins', 'ChildBrowser', 'plugin.xml') |
| , xml_text, plugin_et |
| |
| //, assetsDir = path.resolve(config.projectPath, 'www') |
| , srcDir = path.resolve(test_project_dir, 'SampleApp/Plugins'); |
| |
| |
| exports.setUp = function(callback) { |
| shell.mkdir('-p', test_dir); |
| |
| // copy the ios test project to a temp directory |
| shell.cp('-r', path.join(__dirname, 'projects'), test_dir); |
| |
| // copy the ios test plugin to a temp directory |
| shell.cp('-r', path.join(__dirname, 'plugins'), test_dir); |
| |
| // parse the plugin.xml into an elementtree object |
| xml_text = fs.readFileSync(xml_path, 'utf-8') |
| plugin_et = new et.ElementTree(et.XML(xml_text)); |
| |
| callback(); |
| } |
| |
| exports.tearDown = function(callback) { |
| // remove the temp files (projects and plugins) |
| shell.rm('-rf', test_dir); |
| callback(); |
| } |
| |
| |
| exports['should move the js file'] = function (test) { |
| var jsPath = path.join(test_dir, 'projects', 'www-only', 'childbrowser.js'); |
| |
| // run the platform-specific function |
| www.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et); |
| test.ok(fs.existsSync(jsPath)); |
| test.done(); |
| } |
| |
| exports['should move the directory'] = function (test) { |
| // run the platform-specific function |
| www.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et); |
| |
| var assetPath = path.resolve(test_project_dir, "childbrowser/") |
| var assets = fs.statSync(assetPath); |
| test.ok(assets.isDirectory()); |
| test.ok(fs.statSync(assetPath + '/image.jpg')); |
| test.done(); |
| } |