This repository has been archived by the owner on Aug 11, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ryan Willoughby
committed
Apr 24, 2013
1 parent
1661cc4
commit 7c47973
Showing
12 changed files
with
3,450 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* | ||
* 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. | ||
* | ||
*/ | ||
|
||
describe('Camera (navigator.camera)', function () { | ||
it("should exist", function() { | ||
expect(navigator.camera).toBeDefined(); | ||
}); | ||
|
||
it("should contain a getPicture function", function() { | ||
expect(navigator.camera.getPicture).toBeDefined(); | ||
expect(typeof navigator.camera.getPicture == 'function').toBe(true); | ||
}); | ||
}); | ||
|
||
describe('Camera Constants (window.Camera + navigator.camera)', function () { | ||
it("window.Camera should exist", function() { | ||
expect(window.Camera).toBeDefined(); | ||
}); | ||
|
||
it("should contain three DestinationType constants", function() { | ||
expect(Camera.DestinationType.DATA_URL).toBe(0); | ||
expect(Camera.DestinationType.FILE_URI).toBe(1); | ||
expect(Camera.DestinationType.NATIVE_URI).toBe(2); | ||
expect(navigator.camera.DestinationType.DATA_URL).toBe(0); | ||
expect(navigator.camera.DestinationType.FILE_URI).toBe(1); | ||
expect(navigator.camera.DestinationType.NATIVE_URI).toBe(2); | ||
}); | ||
|
||
it("should contain two EncodingType constants", function() { | ||
expect(Camera.EncodingType.JPEG).toBe(0); | ||
expect(Camera.EncodingType.PNG).toBe(1); | ||
expect(navigator.camera.EncodingType.JPEG).toBe(0); | ||
expect(navigator.camera.EncodingType.PNG).toBe(1); | ||
}); | ||
|
||
it("should contain three MediaType constants", function() { | ||
expect(Camera.MediaType.PICTURE).toBe(0); | ||
expect(Camera.MediaType.VIDEO).toBe(1); | ||
expect(Camera.MediaType.ALLMEDIA).toBe(2); | ||
expect(navigator.camera.MediaType.PICTURE).toBe(0); | ||
expect(navigator.camera.MediaType.VIDEO).toBe(1); | ||
expect(navigator.camera.MediaType.ALLMEDIA).toBe(2); | ||
}); | ||
it("should contain three PictureSourceType constants", function() { | ||
expect(Camera.PictureSourceType.PHOTOLIBRARY).toBe(0); | ||
expect(Camera.PictureSourceType.CAMERA).toBe(1); | ||
expect(Camera.PictureSourceType.SAVEDPHOTOALBUM).toBe(2); | ||
expect(navigator.camera.PictureSourceType.PHOTOLIBRARY).toBe(0); | ||
expect(navigator.camera.PictureSourceType.CAMERA).toBe(1); | ||
expect(navigator.camera.PictureSourceType.SAVEDPHOTOALBUM).toBe(2); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<widget xmlns = "http://www.w3.org/ns/widgets" | ||
xmlns:gap = "http://phonegap.com/ns/1.0" | ||
id = "com.phonegap.barcodescanner-spec" | ||
version = "2.0.0"> | ||
<name>Barcode Scanner Spec</name> | ||
|
||
<description> | ||
Barcode Scanner Spec | ||
</description> | ||
|
||
<author href="http://phonegap.com" email="support@phonegap.com"> | ||
Ryan Willoughby - PhoneGap Team | ||
</author> | ||
|
||
<gap:plugin name="BarcodeScanner"/> | ||
|
||
</widget> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
jasmine.HtmlReporter = function(_doc) { | ||
var self = this; | ||
var doc = _doc || window.document; | ||
|
||
var reporterView; | ||
|
||
var dom = {}; | ||
|
||
// Jasmine Reporter Public Interface | ||
self.logRunningSpecs = false; | ||
|
||
self.reportRunnerStarting = function(runner) { | ||
var specs = runner.specs() || []; | ||
|
||
if (specs.length == 0) { | ||
return; | ||
} | ||
|
||
createReporterDom(runner.env.versionString()); | ||
doc.body.appendChild(dom.reporter); | ||
|
||
reporterView = new jasmine.HtmlReporter.ReporterView(dom); | ||
reporterView.addSpecs(specs, self.specFilter); | ||
}; | ||
|
||
self.reportRunnerResults = function(runner) { | ||
reporterView && reporterView.complete(); | ||
}; | ||
|
||
self.reportSuiteResults = function(suite) { | ||
reporterView.suiteComplete(suite); | ||
}; | ||
|
||
self.reportSpecStarting = function(spec) { | ||
if (self.logRunningSpecs) { | ||
self.log('>> Jasmine Running ' + spec.suite.description + ' ' + spec.description + '...'); | ||
} | ||
}; | ||
|
||
self.reportSpecResults = function(spec) { | ||
reporterView.specComplete(spec); | ||
}; | ||
|
||
self.log = function() { | ||
var console = jasmine.getGlobal().console; | ||
if (console && console.log) { | ||
if (console.log.apply) { | ||
console.log.apply(console, arguments); | ||
} else { | ||
console.log(arguments); // ie fix: console.log.apply doesn't exist on ie | ||
} | ||
} | ||
}; | ||
|
||
self.specFilter = function(spec) { | ||
if (!focusedSpecName()) { | ||
return true; | ||
} | ||
|
||
return spec.getFullName().indexOf(focusedSpecName()) === 0; | ||
}; | ||
|
||
return self; | ||
|
||
function focusedSpecName() { | ||
var specName; | ||
|
||
(function memoizeFocusedSpec() { | ||
if (specName) { | ||
return; | ||
} | ||
|
||
var paramMap = []; | ||
var params = doc.location.search.substring(1).split('&'); | ||
|
||
for (var i = 0; i < params.length; i++) { | ||
var p = params[i].split('='); | ||
paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]); | ||
} | ||
|
||
specName = paramMap.spec; | ||
})(); | ||
|
||
return specName; | ||
} | ||
|
||
function createReporterDom(version) { | ||
dom.reporter = self.createDom('div', { id: 'HTMLReporter', className: 'jasmine_reporter' }, | ||
dom.banner = self.createDom('div', { className: 'banner' }, | ||
self.createDom('span', { className: 'title' }, "Jasmine "), | ||
self.createDom('span', { className: 'version' }, version)), | ||
|
||
dom.symbolSummary = self.createDom('ul', {className: 'symbolSummary'}), | ||
dom.alert = self.createDom('div', {className: 'alert'}), | ||
dom.results = self.createDom('div', {className: 'results'}, | ||
dom.summary = self.createDom('div', { className: 'summary' }), | ||
dom.details = self.createDom('div', { id: 'details' })) | ||
); | ||
} | ||
}; | ||
jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
jasmine.HtmlReporterHelpers = {}; | ||
|
||
jasmine.HtmlReporterHelpers.createDom = function(type, attrs, childrenVarArgs) { | ||
var el = document.createElement(type); | ||
|
||
for (var i = 2; i < arguments.length; i++) { | ||
var child = arguments[i]; | ||
|
||
if (typeof child === 'string') { | ||
el.appendChild(document.createTextNode(child)); | ||
} else { | ||
if (child) { | ||
el.appendChild(child); | ||
} | ||
} | ||
} | ||
|
||
for (var attr in attrs) { | ||
if (attr == "className") { | ||
el[attr] = attrs[attr]; | ||
} else { | ||
el.setAttribute(attr, attrs[attr]); | ||
} | ||
} | ||
|
||
return el; | ||
}; | ||
|
||
jasmine.HtmlReporterHelpers.getSpecStatus = function(child) { | ||
var results = child.results(); | ||
var status = results.passed() ? 'passed' : 'failed'; | ||
if (results.skipped) { | ||
status = 'skipped'; | ||
} | ||
|
||
return status; | ||
}; | ||
|
||
jasmine.HtmlReporterHelpers.appendToSummary = function(child, childElement) { | ||
var parentDiv = this.dom.summary; | ||
var parentSuite = (typeof child.parentSuite == 'undefined') ? 'suite' : 'parentSuite'; | ||
var parent = child[parentSuite]; | ||
|
||
if (parent) { | ||
if (typeof this.views.suites[parent.id] == 'undefined') { | ||
this.views.suites[parent.id] = new jasmine.HtmlReporter.SuiteView(parent, this.dom, this.views); | ||
} | ||
parentDiv = this.views.suites[parent.id].element; | ||
} | ||
|
||
parentDiv.appendChild(childElement); | ||
}; | ||
|
||
|
||
jasmine.HtmlReporterHelpers.addHelpers = function(ctor) { | ||
for(var fn in jasmine.HtmlReporterHelpers) { | ||
ctor.prototype[fn] = jasmine.HtmlReporterHelpers[fn]; | ||
} | ||
}; | ||
|
Oops, something went wrong.