cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject [10/11] spec commit: [CB-2213] Added Android-specific test results.
Date Tue, 12 Feb 2013 03:15:58 GMT
[CB-2213] Added Android-specific test results.

Also gave the FileEntry.remove test its own button.


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

Branch: refs/heads/master
Commit: 04f01428a498310ca2c85b4389cdba0ef66c3b4c
Parents: 49efc5d
Author: Max Woghiren <max.woghiren@gmail.com>
Authored: Wed Feb 6 15:41:20 2013 -0500
Committer: Andrew Grieve <agrieve@chromium.org>
Committed: Mon Feb 11 21:22:58 2013 -0500

----------------------------------------------------------------------
 camera/index.html |   94 ++++++++++++++++++++++++++++++-----------------
 1 files changed, 60 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/04f01428/camera/index.html
----------------------------------------------------------------------
diff --git a/camera/index.html b/camera/index.html
index ef8e834..037877f 100644
--- a/camera/index.html
+++ b/camera/index.html
@@ -33,6 +33,7 @@
 <script type="text/javascript" charset="utf-8">
 
     var deviceReady = false;
+    var platformId = cordova.require('cordova/platform').id;
 
     //-------------------------------------------------------------------------
     // Camera
@@ -127,28 +128,20 @@
             checkForExpectedError("FileEntry.setMetadata", undefined, e.code);
         };
 
-        var onFileEntryRemoved = function() {
-            handleUnexpectedSuccess("FileEntry.remove");
-        };
-
-        var onFileEntryRemoveError = function(e) {
-            checkForExpectedError("FileEntry.remove", FileError.INVALID_MODIFICATION_ERR,
e.code);
-        };
-
         var onParentReceived = function() {
-            handleUnexpectedSuccess("FileEntry.getParent");
+            if (platformId == 'ios') {
+                handleUnexpectedSuccess("FileEntry.getParent");
+            } else if (platformId == 'android') {
+                document.getElementById('camera_status').innerHTML += "FileEntry.getParent
<b>success</b><br />"
+            }
         };
 
         var onGetParentError = function(e) {
-            checkForExpectedError("FileEntry.getParent", FileError.NOT_READABLE_ERR, e.code);
-        };
-
-        var onFileReadAsText = function(evt) {
-            handleUnexpectedSuccess("FileReader.readAsText");
-        };
-
-        var onFileReadAsTextError = function(evt) {
-            checkForExpectedError("FileReader.readAsText", FileError.NOT_READABLE_ERR, e.code);
+            if (platformId == 'ios') {
+                checkForExpectedError("FileEntry.getParent", FileError.NOT_READABLE_ERR,
e.code);
+            } else if (platformId == 'android') {
+                handleUnexpectedError("FileEntry.getParent", e.code);
+            }
         };
 
         var onFileReadAsDataURL = function(evt) {
@@ -164,11 +157,6 @@
             document.getElementById('camera_status').innerHTML += "; type = " + file.type
+ "; size = " + file.size + "; date = " + file.lastModifiedDate + "<br />";
 
             // Test File API here.
-            var textReader = new FileReader();
-            textReader.onload = onFileReadAsText;
-            textReader.onerror = onFileReadAsTextError;
-            textReader.readAsText(file);
-
             var dataUrlReader = new FileReader();
             dataUrlReader.onload = onFileReadAsDataURL;
             dataUrlReader.onerror = function(evt) {
@@ -189,7 +177,6 @@
                 // Test FileEntry API here.
                 fileEntry.getMetadata(onMetadataReceived, onGetMetadataError);
                 fileEntry.setMetadata(onMetadataSet, onSetMetadataError, { "com.apple.MobileBackup":
1 });
-                fileEntry.remove(onFileEntryRemoved, onFileEntryRemoveError);
                 fileEntry.getParent(onParentReceived, onGetParentError);
                 fileEntry.file(onFileReceived, onGetFileError);
             },
@@ -199,20 +186,28 @@
     };
 
     function copyImageUsingNativeUri() {
-        var onFileMoved = function(fileEntry) {
-            handleUnexpectedSuccess("FileEntry.moveTo");
+        var onFileCopied = function(fileEntry) {
+            document.getElementById('camera_status').innerHTML += "FileEntry.copyTo <b>success</b><br
/>";
         };
 
-        var onFileMoveError = function(e) {
-            checkForExpectedError("FileEntry.moveTo", FileError.INVALID_MODIFICATION_ERR,
e.code);
+        var onFileCopyError = function(e) {
+            handleUnexpectedError("FileEntry.copyTo", e.code);
         };
 
-        var onFileCopied = function(fileEntry) {
-            document.getElementById('camera_status').innerHTML += "FileEntry.copyTo <b>success</b>:
file copied to " + fileEntry.fullPath + "<br />";
+        var onFileMoved = function(fileEntry) {
+            if (platformId == 'ios') {
+                handleUnexpectedSuccess("FileEntry.moveTo");
+            } else if (platformId == 'android') {
+                document.getElementById('camera_status').innerHTML += "FileEntry.moveTo <b>success</b><br
/>";
+            }
         };
 
-        var onFileCopyError = function(e) {
-            handleUnexpectedError("FileEntry.copyTo", e.code);
+        var onFileMoveError = function(e) {
+            if (platformId == 'ios') {
+                checkForExpectedError("FileEntry.moveTo", FileError.INVALID_MODIFICATION_ERR,
e.code);
+            } else if (platformId == 'android') {
+                handleUnexpectedError("FileEntry.moveTo", e.code);
+            }
         };
 
         var onFileSystemReceived = function(fileSystem) {
@@ -222,8 +217,8 @@
                     var destDirEntry = fileSystem.root;
 
                     // Test FileEntry API here.
-                    fileEntry.moveTo(destDirEntry, 'moved_file.png', onFileMoved, onFileMoveError);
                     fileEntry.copyTo(destDirEntry, 'copied_file.png', onFileCopied, onFileCopyError);
+                    fileEntry.moveTo(destDirEntry, 'moved_file.png', onFileMoved, onFileMoveError);
                 },
                 onGetPictureError,
                 { destinationType: Camera.DestinationType.NATIVE_URI,
@@ -327,6 +322,36 @@
               sourceType: Camera.PictureSourceType.PHOTOLIBRARY });
     };
 
+    function removeImageUsingNativeUri() {
+        var onFileEntryRemoved = function() {
+            if (platformId == 'ios') {
+                handleUnexpectedSuccess("FileEntry.remove");
+            } else if (platformId == 'android') {
+                document.getElementById('camera_status').innerHTML += "FileEntry.remove <b>success</b><br
/>"
+            }
+        };
+
+        var onFileEntryRemoveError = function(e) {
+            if (platformId == 'ios') {
+                checkForExpectedError("FileEntry.remove", FileError.INVALID_MODIFICATION_ERR,
e.code);
+            } else if (platformId == 'android') {
+                handleUnexpectedError("FileEntry.remove", e.code);
+            }
+        };
+
+        clearStatus();
+        navigator.camera.getPicture(
+            function(data) {
+                var fileEntry = new FileEntry('image_name.png', data);
+
+                // Test FileEntry API here.
+                fileEntry.remove(onFileEntryRemoved, onFileEntryRemoveError);
+            },
+            onGetPictureError,
+            { destinationType: Camera.DestinationType.NATIVE_URI,
+              sourceType: Camera.PictureSourceType.PHOTOLIBRARY });
+    };
+
     function testNativeFile(inputEl) {
         // iOS 6 likes to dead-lock in the onchange context if you
         // do any alerts or try to remote-debug.
@@ -377,7 +402,7 @@
     };
 
     function handleUnexpectedSuccess(methodName) {
-        document.getElementById('camera_status').innerHTML += "" + methodName + " <b>failure</b>
(remove succeeded when it should fail).<br />";
+        document.getElementById('camera_status').innerHTML += "" + methodName + " <b>failure</b>
(succeeded when it should fail).<br />";
     };
 
     function checkForExpectedError(methodName, expectedErrorCode, actualErrorCode) {
@@ -427,6 +452,7 @@
     <div class="btn large" onclick="writeImageUsingNativeUri();">Write Image</div>
     <div class="btn large" onclick="uploadImageUsingNativeUri();">Upload Image</div>
     <div class="btn large" onclick="displayImageUsingNativeUri();">Display Image</div>
+    <div class="btn large" onclick="removeImageUsingNativeUri();">Remove Image</div>
     <h3>input type=file</h3>
     <input type="file" onchange="testNativeFile(this)">
     <h3>capture=camera</h3>


Mime
View raw message