Skip to content

Commit 3588e16

Browse files
Chris BrodyRoss Bender
Chris Brody
and
Ross Bender
authored
Test existing WatchKit support (#71)
* add watch app/extension test coverage * updated to test existing WatchKit support * refactor to check watchapp product type in the beginning (and remove some extra test code) Co-authored-by: Ross Bender <[email protected]> Co-Authored-By: Chris Brody <[email protected]>
1 parent 2c9d0e8 commit 3588e16

File tree

2 files changed

+228
-0
lines changed

2 files changed

+228
-0
lines changed

test/addWatchApp.js

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
/**
2+
Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
'License'); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
Unless required by applicable law or agreed to in writing,
11+
software distributed under the License is distributed on an
12+
'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13+
KIND, either express or implied. See the License for the
14+
specific language governing permissions and limitations
15+
under the License.
16+
*/
17+
18+
var fullProject = require('./fixtures/full-project')
19+
fullProjectStr = JSON.stringify(fullProject),
20+
pbx = require('../lib/pbxProject'),
21+
pbxFile = require('../lib/pbxFile'),
22+
proj = new pbx('.');
23+
24+
function cleanHash() {
25+
return JSON.parse(fullProjectStr);
26+
}
27+
28+
var TARGET_NAME = 'TestWatchApp',
29+
TARGET_TYPE = 'watch_app',
30+
TARGET_SUBFOLDER_NAME = 'TestWatchAppFiles';
31+
32+
exports.setUp = function (callback) {
33+
proj.hash = cleanHash();
34+
callback();
35+
}
36+
37+
exports.addWatchApp = {
38+
'should create a new watch app target with the correct product type': function (test) {
39+
var target = proj.addTarget(TARGET_NAME, TARGET_TYPE, TARGET_SUBFOLDER_NAME);
40+
41+
test.ok(typeof target == 'object');
42+
test.ok(target.uuid);
43+
test.ok(target.pbxNativeTarget);
44+
test.ok(target.pbxNativeTarget.isa);
45+
test.ok(target.pbxNativeTarget.name);
46+
test.ok(target.pbxNativeTarget.productName);
47+
test.ok(target.pbxNativeTarget.productReference);
48+
test.ok(target.pbxNativeTarget.productType);
49+
test.ok(target.pbxNativeTarget.buildConfigurationList);
50+
test.ok(target.pbxNativeTarget.buildPhases);
51+
test.ok(target.pbxNativeTarget.buildRules);
52+
test.ok(target.pbxNativeTarget.dependencies);
53+
54+
test.equal(target.pbxNativeTarget.productType, '"com.apple.product-type.application.watchapp"');
55+
56+
test.done();
57+
},
58+
'should create a new watch app target with the correct product type, without needing a subfolder name': function (test) {
59+
var target = proj.addTarget(TARGET_NAME, TARGET_TYPE);
60+
61+
test.ok(typeof target == 'object');
62+
test.ok(target.uuid);
63+
test.ok(target.pbxNativeTarget);
64+
test.ok(target.pbxNativeTarget.isa);
65+
test.ok(target.pbxNativeTarget.name);
66+
test.ok(target.pbxNativeTarget.productName);
67+
test.ok(target.pbxNativeTarget.productReference);
68+
test.ok(target.pbxNativeTarget.productType);
69+
test.ok(target.pbxNativeTarget.buildConfigurationList);
70+
test.ok(target.pbxNativeTarget.buildPhases);
71+
test.ok(target.pbxNativeTarget.buildRules);
72+
test.ok(target.pbxNativeTarget.dependencies);
73+
74+
test.equal(target.pbxNativeTarget.productType, '"com.apple.product-type.application.watchapp"');
75+
76+
test.done();
77+
},
78+
'should create a new watch app target and add source, framework, resource and header files and the corresponding build phases': function (test) {
79+
var target = proj.addTarget(TARGET_NAME, TARGET_TYPE, TARGET_SUBFOLDER_NAME),
80+
options = { 'target' : target.uuid };
81+
82+
var sourceFile = proj.addSourceFile('Plugins/file.m', options),
83+
sourcePhase = proj.addBuildPhase([], 'PBXSourcesBuildPhase', 'Sources', target.uuid),
84+
resourceFile = proj.addResourceFile('assets.bundle', options),
85+
resourcePhase = proj.addBuildPhase([], 'PBXResourcesBuildPhase', 'Resources', target.uuid),
86+
frameworkFile = proj.addFramework('libsqlite3.dylib', options);
87+
frameworkPhase = proj.addBuildPhase([], 'PBXFrameworkBuildPhase', 'Frameworks', target.uuid),
88+
headerFile = proj.addHeaderFile('file.h', options);
89+
90+
test.ok(sourcePhase);
91+
test.ok(resourcePhase);
92+
test.ok(frameworkPhase);
93+
94+
test.equal(sourceFile.constructor, pbxFile);
95+
test.equal(resourceFile.constructor, pbxFile);
96+
test.equal(frameworkFile.constructor, pbxFile);
97+
test.equal(headerFile.constructor, pbxFile);
98+
99+
test.ok(typeof target == 'object');
100+
test.ok(target.uuid);
101+
test.ok(target.pbxNativeTarget);
102+
test.ok(target.pbxNativeTarget.isa);
103+
test.ok(target.pbxNativeTarget.name);
104+
test.ok(target.pbxNativeTarget.productName);
105+
test.ok(target.pbxNativeTarget.productReference);
106+
test.ok(target.pbxNativeTarget.productType);
107+
test.ok(target.pbxNativeTarget.buildConfigurationList);
108+
test.ok(target.pbxNativeTarget.buildPhases);
109+
test.ok(target.pbxNativeTarget.buildRules);
110+
test.ok(target.pbxNativeTarget.dependencies);
111+
112+
test.done();
113+
}
114+
}

test/addWatchExtension.js

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
/**
2+
Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
'License'); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
Unless required by applicable law or agreed to in writing,
11+
software distributed under the License is distributed on an
12+
'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13+
KIND, either express or implied. See the License for the
14+
specific language governing permissions and limitations
15+
under the License.
16+
*/
17+
18+
var fullProject = require('./fixtures/full-project')
19+
fullProjectStr = JSON.stringify(fullProject),
20+
pbx = require('../lib/pbxProject'),
21+
pbxFile = require('../lib/pbxFile'),
22+
proj = new pbx('.');
23+
24+
function cleanHash() {
25+
return JSON.parse(fullProjectStr);
26+
}
27+
28+
var TARGET_NAME = 'TestWatchExtension',
29+
TARGET_TYPE = 'watch_extension',
30+
TARGET_SUBFOLDER_NAME = 'TestWatchExtensionFiles';
31+
32+
exports.setUp = function (callback) {
33+
proj.hash = cleanHash();
34+
callback();
35+
}
36+
37+
exports.addWatchExtension = {
38+
'should create a new watch extension target': function (test) {
39+
var target = proj.addTarget(TARGET_NAME, TARGET_TYPE, TARGET_SUBFOLDER_NAME);
40+
41+
test.ok(typeof target == 'object');
42+
test.ok(target.uuid);
43+
test.ok(target.pbxNativeTarget);
44+
test.ok(target.pbxNativeTarget.isa);
45+
test.ok(target.pbxNativeTarget.name);
46+
test.ok(target.pbxNativeTarget.productName);
47+
test.ok(target.pbxNativeTarget.productReference);
48+
test.ok(target.pbxNativeTarget.productType);
49+
test.ok(target.pbxNativeTarget.buildConfigurationList);
50+
test.ok(target.pbxNativeTarget.buildPhases);
51+
test.ok(target.pbxNativeTarget.buildRules);
52+
test.ok(target.pbxNativeTarget.dependencies);
53+
54+
test.done();
55+
},
56+
'should create a new watch extension target and add source, framework, resource and header files and the corresponding build phases': function (test) {
57+
var target = proj.addTarget(TARGET_NAME, TARGET_TYPE, TARGET_SUBFOLDER_NAME),
58+
options = { 'target' : target.uuid };
59+
60+
var sourceFile = proj.addSourceFile('Plugins/file.m', options),
61+
sourcePhase = proj.addBuildPhase([], 'PBXSourcesBuildPhase', 'Sources', target.uuid),
62+
resourceFile = proj.addResourceFile('assets.bundle', options),
63+
resourcePhase = proj.addBuildPhase([], 'PBXResourcesBuildPhase', 'Resources', target.uuid),
64+
frameworkFile = proj.addFramework('libsqlite3.dylib', options);
65+
frameworkPhase = proj.addBuildPhase([], 'PBXFrameworkBuildPhase', 'Frameworks', target.uuid),
66+
headerFile = proj.addHeaderFile('file.h', options);
67+
68+
test.ok(sourcePhase);
69+
test.ok(resourcePhase);
70+
test.ok(frameworkPhase);
71+
72+
test.equal(sourceFile.constructor, pbxFile);
73+
test.equal(resourceFile.constructor, pbxFile);
74+
test.equal(frameworkFile.constructor, pbxFile);
75+
test.equal(headerFile.constructor, pbxFile);
76+
77+
test.ok(typeof target == 'object');
78+
test.ok(target.uuid);
79+
test.ok(target.pbxNativeTarget);
80+
test.ok(target.pbxNativeTarget.isa);
81+
test.ok(target.pbxNativeTarget.name);
82+
test.ok(target.pbxNativeTarget.productName);
83+
test.ok(target.pbxNativeTarget.productReference);
84+
test.ok(target.pbxNativeTarget.productType);
85+
test.ok(target.pbxNativeTarget.buildConfigurationList);
86+
test.ok(target.pbxNativeTarget.buildPhases);
87+
test.ok(target.pbxNativeTarget.buildRules);
88+
test.ok(target.pbxNativeTarget.dependencies);
89+
90+
test.done();
91+
},
92+
'should not create a new watch extension build phase if no watch app exists': function (test) {
93+
var target = proj.addTarget(TARGET_NAME, TARGET_TYPE);
94+
95+
test.ok(typeof target == 'object');
96+
test.ok(target.uuid);
97+
test.ok(target.pbxNativeTarget);
98+
test.ok(target.pbxNativeTarget.isa);
99+
test.ok(target.pbxNativeTarget.name);
100+
test.ok(target.pbxNativeTarget.productName);
101+
test.ok(target.pbxNativeTarget.productReference);
102+
test.ok(target.pbxNativeTarget.productType);
103+
test.ok(target.pbxNativeTarget.buildConfigurationList);
104+
test.ok(target.pbxNativeTarget.buildPhases);
105+
test.ok(target.pbxNativeTarget.buildRules);
106+
test.ok(target.pbxNativeTarget.dependencies);
107+
108+
var buildPhase = proj.buildPhaseObject('PBXCopyFilesBuildPhase', 'Embed App Extensions', target.uuid)
109+
110+
test.ok(!buildPhase);
111+
112+
test.done();
113+
}
114+
}

0 commit comments

Comments
 (0)