You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by fi...@apache.org on 2012/04/18 23:49:53 UTC

[32/37] spec commit: converted capture tests

converted capture tests


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-mobile-spec/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-mobile-spec/commit/a364bd0b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-mobile-spec/tree/a364bd0b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-mobile-spec/diff/a364bd0b

Branch: refs/heads/master
Commit: a364bd0b183ff78e17b601377028307dfbbc0761
Parents: db171ea
Author: Gord Tanner <gt...@gmail.com>
Authored: Mon Apr 2 22:57:23 2012 -0400
Committer: Fil Maj <ma...@gmail.com>
Committed: Mon Apr 16 16:05:14 2012 -0700

----------------------------------------------------------------------
 autotest/pages/capture.html     |   46 ++++++++++
 autotest/tests/capture.tests.js |  158 +++++++++++++++++-----------------
 2 files changed, 124 insertions(+), 80 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-mobile-spec/blob/a364bd0b/autotest/pages/capture.html
----------------------------------------------------------------------
diff --git a/autotest/pages/capture.html b/autotest/pages/capture.html
index 1f871a0..050e2af 100644
--- a/autotest/pages/capture.html
+++ b/autotest/pages/capture.html
@@ -1,5 +1,6 @@
 <!DOCTYPE html>
 <html>
+<<<<<<< HEAD
   <head>
     <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
     <meta name="viewport" content="width=device-width, height=device-height, user-scalable=yes, initial-scale=1.0;" />
@@ -48,6 +49,51 @@
             <!-- Populated by tests -->
         </div>
     </body>
+=======
+<head>
+  <title>Cordova: Capture API Specs</title>
+
+  <!-- Load jasmine -->
+  <link href="../jasmine.css" rel="stylesheet"/>
+  <script type="text/javascript" src="../jasmine.js"></script>
+  <script type="text/javascript" src="../html/HtmlReporterHelpers.js"></script>
+  <script type="text/javascript" src="../html/HtmlReporter.js"></script>
+  <script type="text/javascript" src="../html/ReporterView.js"></script>
+  <script type="text/javascript" src="../html/SpecView.js"></script>
+  <script type="text/javascript" src="../html/SuiteView.js"></script>
+  <script type="text/javascript" src="../html/TrivialReporter.js"></script>
+
+  <!-- Source -->
+  <script type="text/javascript" src="../../phonegap.js"></script>
+
+  <!-- Load Test Runner -->
+  <script type="text/javascript" src="../test-runner.js"></script>
+
+  <!-- Tests -->
+  <script type="text/javascript" src="../tests/capture.tests.js"></script>
+
+  <script type="text/javascript">
+    document.addEventListener('deviceready', function () {
+      var jasmineEnv = jasmine.getEnv();
+      jasmineEnv.updateInterval = 1000;
+
+      var htmlReporter = new jasmine.HtmlReporter();
+
+      jasmineEnv.addReporter(htmlReporter);
+
+      jasmineEnv.specFilter = function(spec) {
+        return htmlReporter.specFilter(spec);
+      };
+
+      jasmineEnv.execute();
+    }, false);
+  </script>
+</head>
+
+<body>
+  <a href="javascript:" class="backBtn" onclick="backHome();">Back</a>
+</body>
+>>>>>>> converted capture tests
 </html>
 
 

http://git-wip-us.apache.org/repos/asf/incubator-cordova-mobile-spec/blob/a364bd0b/autotest/tests/capture.tests.js
----------------------------------------------------------------------
diff --git a/autotest/tests/capture.tests.js b/autotest/tests/capture.tests.js
index 594d7d1..bffced8 100644
--- a/autotest/tests/capture.tests.js
+++ b/autotest/tests/capture.tests.js
@@ -1,97 +1,95 @@
-Tests.prototype.CaptureTests = function() {  
-    module('Capture (navigator.device.capture)');
-    test("should exist", function() {
-        expect(2);
-        ok(navigator.device !== null, "navigator.device should not be null.");
-        ok(navigator.device.capture !== null, "navigator.device.capture should not be null.");
+describe('Capture (navigator.device.capture)', function () {
+    it("should exist", function() {
+        expect(navigator.device).toBeDefined();
+        expect(navigator.device.capture).toBeDefined();
     });
-    test("should have the correct properties ", function() {
-        expect(3);
-        ok(typeof navigator.device.capture.supportedAudioModes != 'undefined' && navigator.device.capture.supportedAudioModes !== null , "there should be a supported audio modes property");
-        ok(typeof navigator.device.capture.supportedImageModes != 'undefined' && navigator.device.capture.supportedImageModes !== null , "there should be a supported image modes property");
-        ok(typeof navigator.device.capture.supportedVideoModes != 'undefined' && navigator.device.capture.supportedVideoModes !== null , "there should be a supported video modes property");
-    });
-    test("should contain a captureAudio function", function() {
-        expect(2);
-        ok(typeof navigator.device.capture.captureAudio != 'undefined' && navigator.device.capture.captureAudio !== null, "navigator.device.capture.captureAudio should not be null.");
-        ok(typeof navigator.device.capture.captureAudio == 'function', "navigator.device.capture.captureAudio should be a function.");
+
+    it("should have the correct properties ", function() {
+        expect(navigator.device.capture.supportedAudioModes).toBeDefined();
+        expect(navigator.device.capture.supportedImageModes).toBeDefined();
+        expect(navigator.device.capture.supportedVideoModes).toBeDefined();
     });
-    test("should contain a captureImage function", function() {
-        expect(2);
-        ok(typeof navigator.device.capture.captureImage != 'undefined' && navigator.device.capture.captureImage !== null, "navigator.device.capture.captureImage should not be null.");
-        ok(typeof navigator.device.capture.captureImage == 'function', "navigator.device.capture.captureImage should be a function.");
+
+    it("should contain a captureAudio function", function() {
+        expect(navigator.device.capture.captureAudio).toBeDefined();
+        expect(typeof navigator.device.capture.captureAudio == 'function').toBe(true);
     });
-    test("should contain a captureVideo function", function() {
-        expect(2);
-        ok(typeof navigator.device.capture.captureVideo != 'undefined' && navigator.device.capture.captureVideo !== null, "navigator.device.capture.captureVideo should not be null.");
-        ok(typeof navigator.device.capture.captureVideo == 'function', "navigator.device.capture.captureVideo should be a function.");
+
+    it("should contain a captureImage function", function() {
+        expect(navigator.device.capture.captureImage).toBeDefined();
+        expect(typeof navigator.device.capture.captureImage == 'function').toBe(true);
     });
 
-    module('CaptureAudioOptions');
-    test("CaptureAudioOptions constructor should exist", function() {
-        expect(4);
-        var options = new CaptureAudioOptions();
-        ok(options !== null, "CaptureAudioOptions object should not be null.");
-        ok(typeof options.limit !== 'undefined', "CaptureAudioOptions object should have a 'limit' property.");
-        ok(typeof options.duration !== 'undefined', "CaptureAudioOptions object should have a 'duration' property.");
-        ok(typeof options.mode !== 'undefined', "CaptureAudioOptions object should have a 'mode' property.");
+    it("should contain a captureVideo function", function() {
+        expect(navigator.device.capture.captureVideo).toBeDefined();
+        expect(typeof navigator.device.capture.captureVideo == 'function').toBe(true);
     });
 
-    module('CaptureImageOptions');
-    test("CaptureImageOptions constructor should exist", function() {
-        expect(3);
-        var options = new CaptureImageOptions();
-        ok(options !== null, "CaptureImageOptions object should not be null.");
-        ok(typeof options.limit !== 'undefined', "CaptureImageOptions object should have a 'limit' property.");
-        ok(typeof options.mode !== 'undefined', "CaptureImageOptions object should have a 'mode' property.");
+    describe('CaptureAudioOptions', function () {
+        it("CaptureAudioOptions constructor should exist", function() {
+            var options = new CaptureAudioOptions();
+            expect(options).toBeDefined();
+            expect(options.limit).toBeDefined();
+            expect(options.duration).toBeDefined();
+            expect(options.mode).toBeDefined();
+        });
     });
 
-    module('CaptureVideoOptions');
-    test("CaptureVideoOptions constructor should exist", function() {
-        expect(4);
-        var options = new CaptureVideoOptions();
-        ok(options !== null, "CaptureVideoOptions object should not be null.");
-        ok(typeof options.limit !== 'undefined', "CaptureVideoOptions object should have a 'limit' property.");
-        ok(typeof options.duration !== 'undefined', "CaptureVideoOptions object should have a 'duration' property.");
-        ok(typeof options.mode !== 'undefined', "CaptureVideoOptions object should have a 'mode' property.");
+    describe('CaptureImageOptions', function () {
+        it("CaptureImageOptions constructor should exist", function() {
+            var options = new CaptureImageOptions();
+            expect(options).toBeDefined();
+            expect(options.limit).toBeDefined();
+            expect(options.mode).toBeDefined();
+        });
     });
 
-    module('CaptureError interface');
-    test("CaptureError constants should be defined", function() {
-        expect(4);
-        equal(CaptureError.CAPTURE_INTERNAL_ERR, 0, "CaptureError.CAPTURE_INTERNAL_ERR should be defined");
-        equal(CaptureError.CAPTURE_APPLICATION_BUSY, 1, "CaptureError.CAPTURE_APPLICATION_BUSY should be defined");
-        equal(CaptureError.CAPTURE_INVALID_ARGUMENT, 2, "CaptureError.CAPTURE_INVALID_ARGUMENT should be defined");
-        equal(CaptureError.CAPTURE_NO_MEDIA_FILES, 3, "CaptureError.CAPTURE_NO_MEDIA_FILES should be defined");
+    describe('CaptureVideoOptions', function () {
+        it("CaptureVideoOptions constructor should exist", function() {
+            var options = new CaptureVideoOptions();
+            expect(options).toBeDefined();
+            expect(options.limit).toBeDefined();
+            expect(options.duration).toBeDefined();
+            expect(options.mode).toBeDefined();
+        });
     });
-    test("CaptureError properties should exist", function() {
-        expect(2);
-        var error = new CaptureError();
-        ok(error !== null, "CaptureError object should not be null.");
-        ok(typeof error.code !== 'undefined', "CaptureError object should have a 'code' property.");
+
+    describe('CaptureError interface', function () {
+        it("CaptureError constants should be defined", function() {
+            expect(CaptureError.CAPTURE_INTERNAL_ERR).toBe(0);
+            expect(CaptureError.CAPTURE_APPLICATION_BUSY).toBe(1);
+            expect(CaptureError.CAPTURE_INVALID_ARGUMENT).toBe(2);
+            expect(CaptureError.CAPTURE_NO_MEDIA_FILES).toBe(3);
+        });
+
+        it("CaptureError properties should exist", function() {
+            var error = new CaptureError();
+            expect(error).toBeDefined();
+            expect(error.code).toBeDefined();
+        });
     });
 
-    module('MediaFileData');
-    test("MediaFileData constructor should exist", function() {
-        expect(6);
-        var fileData = new MediaFileData();
-        ok(fileData !== null, "MediaFileData object should not be null.");
-        ok(typeof fileData.bitrate !== 'undefined', "MediaFileData object should have a 'bitrate' property.");
-        ok(typeof fileData.codecs !== 'undefined', "MediaFileData object should have a 'codecs' property.");
-        ok(typeof fileData.duration !== 'undefined', "MediaFileData object should have a 'duration' property.");
-        ok(typeof fileData.height !== 'undefined', "MediaFileData object should have a 'height' property.");
-        ok(typeof fileData.width !== 'undefined', "MediaFileData object should have a 'width' property.");
+    describe('MediaFileData', function () {
+        it("MediaFileData constructor should exist", function() {
+            var fileData = new MediaFileData();
+            expect(fileData).toBeDefined();
+            expect(fileData.bitrate).toBeDefined();
+            expect(fileData.codecs).toBeDefined();
+            expect(fileData.duration).toBeDefined();
+            expect(fileData.height).toBeDefined();
+            expect(fileData.width).toBeDefined();
+        });
     });
 
-    module('MediaFile');
-    test("MediaFile constructor should exist", function() {
-        expect(6);
-        var fileData = new MediaFile();
-        ok(fileData !== null, "MediaFile object should not be null.");
-        ok(typeof fileData.name !== 'undefined', "MediaFile object should have a 'name' property.");
-        ok(typeof fileData.fullPath !== 'undefined', "MediaFile object should have a 'fullPath' property.");
-        ok(typeof fileData.type !== 'undefined', "MediaFile object should have a 'type' property.");
-        ok(typeof fileData.lastModifiedDate !== 'undefined', "MediaFile object should have a 'lastModifiedDate' property.");
-        ok(typeof fileData.size !== 'undefined', "MediaFile object should have a 'size' property.");
+    describe('MediaFile', function () {
+        it("MediaFile constructor should exist", function() {
+            var fileData = new MediaFile();
+            expect(fileData).toBeDefined();
+            expect(fileData.name).toBeDefined();
+            expect(fileData.fullPath).toBeDefined();
+            expect(fileData.type).toBeDefined();
+            expect(fileData.lastModifiedDate).toBeDefined();
+            expect(fileData.size).toBeDefined();
+        });
     });
-};
+});