]> git.parisson.com Git - pdf.js.git/commitdiff
Add sample manifests. Also make a browser path argument, so you can just specify...
authorRob Sayre <sayrer@gmail.com>
Thu, 23 Jun 2011 20:47:43 +0000 (13:47 -0700)
committerRob Sayre <sayrer@gmail.com>
Thu, 23 Jun 2011 20:47:43 +0000 (13:47 -0700)
test/browser_manifest.json [deleted file]
test/resources/browser_manifests/browser_manifest.json.mac [new file with mode: 0644]
test/test.py

diff --git a/test/browser_manifest.json b/test/browser_manifest.json
deleted file mode 100644 (file)
index a396b01..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-[
-   {
-    "name":"firefox5",
-    "path":"/Applications/Firefox.app",
-    "type":"firefox"
-   },
-   {
-    "name":"firefox6",
-    "path":"/Users/sayrer/firefoxen/Aurora.app",
-    "type":"firefox"
-   }
-]
\ No newline at end of file
diff --git a/test/resources/browser_manifests/browser_manifest.json.mac b/test/resources/browser_manifests/browser_manifest.json.mac
new file mode 100644 (file)
index 0000000..1aad32d
--- /dev/null
@@ -0,0 +1,10 @@
+[
+   {
+    "name":"firefox5",
+    "path":"/Applications/Firefox.app",
+   },
+   {
+    "name":"firefox6",
+    "path":"/Users/sayrer/firefoxen/Aurora.app",
+   }
+]
\ No newline at end of file
index 5a869530e748b6acf3e9b8d3b0fe0e92ffb19289..d7a0fa67474dbd5c29172b39cfa15f8d072dff35 100644 (file)
@@ -11,7 +11,6 @@ DOC_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__),".."))
 
 ANAL = True
 DEFAULT_MANIFEST_FILE = 'test_manifest.json'
-DEFAULT_BROWSER_MANIFEST_FILE = 'browser_manifest.json'
 EQLOG_FILE = 'eq.log'
 REFDIR = 'ref'
 TMPDIR = 'tmp'
@@ -24,10 +23,11 @@ class TestOptions(OptionParser):
                         help="Run the script in master mode.", default=False)
         self.add_option("--manifestFile", action="store", type="string", dest="manifestFile",
                         help="A JSON file in the form of test_manifest.json (the default).")
+        self.add_option("-b", "--browser", action="store", type="string", dest="browser",
+                        help="The path to a single browser (right now, only Firefox is supported).")
         self.add_option("--browserManifestFile", action="store", type="string",
                         dest="browserManifestFile",
-                        help="A JSON file in the form of browser_manifest.json (the default).",
-                        default=DEFAULT_BROWSER_MANIFEST_FILE)
+                        help="A JSON file in the form of those found in resources/browser_manifests")
         self.set_usage(USAGE_EXAMPLE)
 
     def verifyOptions(self, options):
@@ -35,6 +35,8 @@ class TestOptions(OptionParser):
             self.error("--masterMode and --manifestFile must not be specified at the same time.")
         if not options.manifestFile:
             options.manifestFile = DEFAULT_MANIFEST_FILE
+        if options.browser and options.browserManifestFile:
+            print "Warning: ignoring browser argument since manifest file was also supplied"
         return options
         
 def prompt(question):
@@ -136,16 +138,15 @@ class BrowserCommand():
     def __init__(self, browserRecord):
         self.name = browserRecord["name"]
         self.path = browserRecord["path"]
-        self.type = browserRecord["type"]
 
-        if platform.system() == "Darwin" and self.path.endswith(".app"):
+        if platform.system() == "Darwin" and (self.path.endswith(".app") or self.path.endswith(".app/")):
             self._fixupMacPath()
 
         if not os.path.exists(self.path):
             throw("Path to browser '%s' does not exist." % self.path)
 
     def _fixupMacPath(self):
-        self.path = self.path + "/Contents/MacOS/firefox-bin"
+        self.path = os.path.join(self.path, "Contents", "MacOS", "firefox-bin")
 
     def setup(self):
         self.tempDir = tempfile.mkdtemp()
@@ -158,7 +159,7 @@ class BrowserCommand():
         shutil.rmtree(self.tempDir)
 
     def start(self, url):
-        cmds = [self.path, "-no-remote", "-profile", self.profileDir, url]
+        cmds = [self.path, "-foreground", "-no-remote", "-profile", self.profileDir, url]
         subprocess.call(cmds)
 
 def makeBrowserCommands(browserManifestFile):
@@ -179,8 +180,14 @@ def setUp(options):
 
     assert not os.path.isdir(TMPDIR)
 
-    testBrowsers = makeBrowserCommands(options.browserManifestFile)
-
+    testBrowsers = []
+    if options.browserManifestFile:
+        testBrowsers = makeBrowserCommands(options.browserManifestFile)
+    elif options.browser:
+        testBrowsers = [BrowserCommand({"path":options.browser, "name":"firefox"})] 
+    else:
+        print "No test browsers found. Use --browserManifest or --browser args."
+              
     with open(options.manifestFile) as mf:
         manifestList = json.load(mf)