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/09/12 02:31:00 UTC

git commit: Test audit and dropped todo based on ML feedback.

Updated Branches:
  refs/heads/cordova-client 8837e000d -> f55d0e862


Test audit and dropped todo based on ML feedback.


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

Branch: refs/heads/cordova-client
Commit: f55d0e8626719a047b2fdd9ac8b081dd8e5f5170
Parents: 8837e00
Author: Fil Maj <ma...@gmail.com>
Authored: Tue Sep 11 17:30:40 2012 -0700
Committer: Fil Maj <ma...@gmail.com>
Committed: Tue Sep 11 17:30:40 2012 -0700

----------------------------------------------------------------------
 README.md             |    3 +-
 spec/build.spec.js    |   84 +++++++++++++++++++++++++++++++++++---------
 spec/platform.spec.js |   52 ++++++++++++++------------
 3 files changed, 97 insertions(+), 42 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/blob/f55d0e86/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index e6be619..27c0ed0 100644
--- a/README.md
+++ b/README.md
@@ -137,6 +137,7 @@ Plugin integration hinges on:
 - installing only supported platforms for the app vs. the plugin (and
   vice-versa)
 - npm package
+- bootstrapping the tests
 - figure out versioning. for now: 2.1.0 minimum
 - properly extracting info from config.xml
 - testing on machines other than Mac OS X
@@ -160,4 +161,4 @@ then other things happened. Those scripts ended up in the mainline projects. The
 
 This new thinking is different. We now think the native project as it were should host its own scripts. Upgrading not a consideration. Maybe it should be. You're thinking of a master global script, which is cool and something I've always wanted, but the version thing needs to be considered. perhaps not an issue between releases if the native project (the target of www) deals with the version itself...
 
-cordova-client internally depends on pluginstall, a tool written by Andrew Lunny to support installing plugins for the iOS and Android platforms [https://github.com/alunny/pluginstall]()
\ No newline at end of file
+cordova-client internally depends on pluginstall, a tool written by Andrew Lunny to support installing plugins for the iOS and Android platforms [https://github.com/alunny/pluginstall]()

http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/blob/f55d0e86/spec/build.spec.js
----------------------------------------------------------------------
diff --git a/spec/build.spec.js b/spec/build.spec.js
index d41e29e..70f1869 100644
--- a/spec/build.spec.js
+++ b/spec/build.spec.js
@@ -6,6 +6,8 @@ var cordova = require('../cordova'),
     fs = require('fs'),
     tempDir = path.join(__dirname, '..', 'temp');
 
+var cwd = process.cwd();
+
 describe('build command', function() {
     beforeEach(function() {
         // Make a temp directory
@@ -14,7 +16,6 @@ describe('build command', function() {
     });
 
     it('should not run inside a Cordova-based project with no added platforms', function() {
-        var cwd = process.cwd();
         this.after(function() {
             process.chdir(cwd);
         });
@@ -25,23 +26,14 @@ describe('build command', function() {
             cordova.build();
         }).toThrow();
     });
-    /*
+    
     it('should run inside a Cordova-based project with at least one added platform', function() {
-        var cwd = process.cwd();
         this.after(function() {
             process.chdir(cwd);
         });
 
         var buildcb = jasmine.createSpy();
-        var cb = jasmine.createSpy().andCallFake(function() {
-            runs(function() {
-                expect(function() {
-                    console.log('running build');
-                    cordova.build(buildcb);
-                }).not.toThrow();
-            });
-            waitsFor(function() { return buildcb.wasCalled; });
-        });
+        var cb = jasmine.createSpy();
 
         runs(function() {
             cordova.create(tempDir);
@@ -49,10 +41,16 @@ describe('build command', function() {
             cordova.platform('add', 'android', cb);
         });
         waitsFor(function() { return cb.wasCalled; }, 'platform add android callback');
+
+        runs(function() {
+            expect(function() {
+                cordova.build(buildcb);
+            }).not.toThrow();
+        });
+        waitsFor(function() { return buildcb.wasCalled; }, 'build call', 20000);
     });
     
     it('should not run outside of a Cordova-based project', function() {
-        var cwd = process.cwd();
         this.after(function() {
             process.chdir(cwd);
         });
@@ -63,14 +61,66 @@ describe('build command', function() {
             cordova.build();
         }).toThrow();
     });
-    it('should shell out to the debug command for each platform', function() {
-        // TODO how to test this?
+    describe('should shell out to the debug command and create a binary', function() {
+        beforeEach(function() {
+            cordova.create(tempDir);
+            process.chdir(tempDir);
+        });
+
+        afterEach(function() {
+            process.chdir(cwd);
+        });
+        it('on Android', function() {
+            var buildcb = jasmine.createSpy();
+            var cb = jasmine.createSpy();
+
+            runs(function() {
+                cordova.platform('add', 'android', cb);
+            });
+            waitsFor(function() { return cb.wasCalled; }, 'platform add android callback');
+
+            runs(function() {
+                cordova.build(buildcb);
+            });
+            waitsFor(function() { return buildcb.wasCalled; }, 'build call', 20000);
+            runs(function() {
+                var binaryPath = path.join(tempDir, 'platforms','android','bin');
+                // Check that "bin" dir of android native proj has at
+                // least one file ennding in ".apk"
+                expect(fs.readdirSync(binaryPath)
+                  .filter(function(e) {
+                    return e.indexOf('.apk', e.length - 4) !== -1;
+                  }).length > 0).toBe(true);
+            });
+        });
+        it('on iOS', function() {
+            var buildcb = jasmine.createSpy();
+            var cb = jasmine.createSpy();
+
+            runs(function() {
+                cordova.platform('add', 'ios', cb);
+            });
+            waitsFor(function() { return cb.wasCalled; }, 'platform add ios callback');
+            runs(function() {
+                cordova.build(buildcb);
+            });
+            waitsFor(function() { return buildcb.wasCalled; }, 'build call', 20000);
+            runs(function() {
+                var binaryPath = path.join(tempDir, 'platforms','ios','build');
+                expect(fs.existsSync(binaryPath)).toBe(true);
+
+                var appPath = path.join(binaryPath,"Hello_Cordova.app");
+                expect(fs.existsSync(appPath)).toBe(true);
+            });
+        });
     });
 
-    describe('should interpolate config.xml', function() {
+    describe('should interpolate config.xml app metadata', function() {
         describe('into Android builds', function() {
+          it('should interpolate app name');
         });
         describe('into iOS builds', function() {
+          it('should interpolate app name');
         });
-    }); */
+    });
 });

http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/blob/f55d0e86/spec/platform.spec.js
----------------------------------------------------------------------
diff --git a/spec/platform.spec.js b/spec/platform.spec.js
index 1529286..2f16d59 100644
--- a/spec/platform.spec.js
+++ b/spec/platform.spec.js
@@ -56,22 +56,22 @@ describe('platform command', function() {
         });
 
         it('should list out added platforms in a project', function() {
-            var cb = jasmine.createSpy().andCallFake(function() {
-                var cbtwo = jasmine.createSpy().andCallFake(function() {
-                    expect(cordova.platform('ls')).toEqual('android\nios');
-                });
-                runs(function() {
-                    expect(cordova.platform('ls')).toEqual('android');
-                    cordova.platform('add', 'ios', cbtwo);
-                });
-                waitsFor(function() { return cbtwo.wasCalled; }, "create callback number two");
-            });
+            var cbtwo = jasmine.createSpy();
+            var cb = jasmine.createSpy();
 
             process.chdir(tempDir);
             runs(function() {
                 cordova.platform('add', 'android', cb);
             });
             waitsFor(function() { return cb.wasCalled; }, "create callback");
+            runs(function() {
+                expect(cordova.platform('ls')).toEqual('android');
+                cordova.platform('add', 'ios', cbtwo);
+            });
+            waitsFor(function() { return cbtwo.wasCalled; }, "create callback number two");
+            runs(function() {
+                expect(cordova.platform('ls')).toEqual('android\nios');
+            });
         });
     });
 
@@ -93,29 +93,31 @@ describe('platform command', function() {
 
         describe('android', function() {
             it('should add a basic android project', function() {
-                var cb = jasmine.createSpy().andCallFake(function() {
-                    expect(fs.existsSync(path.join(tempDir, 'platforms', 'android', 'AndroidManifest.xml'))).toBe(true);
-                });
+                var cb = jasmine.createSpy();
 
                 process.chdir(tempDir);
                 runs(function() {
                     cordova.platform('add', 'android', cb);
                 });
                 waitsFor(function() { return cb.wasCalled; }, "platform add android callback");
+                runs(function() {
+                    expect(fs.existsSync(path.join(tempDir, 'platforms', 'android', 'AndroidManifest.xml'))).toBe(true);
+                });
             });
         });
 
         describe('ios', function() {
             it('should add a basic ios project', function() {
-                var cb = jasmine.createSpy().andCallFake(function() {
-                    expect(fs.existsSync(path.join(tempDir, 'platforms', 'ios', 'www'))).toBe(true);
-                });
+                var cb = jasmine.createSpy();
 
                 process.chdir(tempDir);
                 runs(function() {
                     cordova.platform('add', 'ios', cb);
                 });
                 waitsFor(function() { return cb.wasCalled; }, "platform add ios callback");
+                runs(function() {
+                    expect(fs.existsSync(path.join(tempDir, 'platforms', 'ios', 'www'))).toBe(true);
+                });
             });
         });
     });
@@ -130,20 +132,22 @@ describe('platform command', function() {
         });
 
         it('should remove a supported and added platform', function() {
-            var cb = jasmine.createSpy().andCallFake(function() {
-                cordova.platform('remove', 'android');
-                expect(cordova.platform('ls')).toEqual('ios');
-            });
-            var cbone = jasmine.createSpy().andCallFake(function() {
-                cordova.platform('add', 'android', cb);
-                waitsFor(function() { return cb.wasCalled; }, "android create callback");
-            });
+            var cb = jasmine.createSpy();
+            var cbone = jasmine.createSpy();
 
             process.chdir(tempDir);
             runs(function() {
                 cordova.platform('add', 'ios', cbone);
             });
             waitsFor(function() { return cbone.wasCalled; }, "ios create callback");
+            runs(function() {
+                cordova.platform('add', 'android', cb);
+            });
+            waitsFor(function() { return cb.wasCalled; }, "android create callback");
+            runs(function() {
+                cordova.platform('remove', 'android');
+                expect(cordova.platform('ls')).toEqual('ios');
+            });
         });
     });
 });