Skip to content

Config file structure

jxp edited this page Mar 16, 2012 · 8 revisions

The json config file used by phonegap desktop is a simple three level hierarchy.
Section

Element

Data

Additional files (e.g. for plugins) can be merged in to the in-memory object easily.

There are some initial config settings at the start of the file;

arraySequence

true/false: Determines whether data in arrays will be returned with each element in sequence, otherwise a random element will be chosen.
This setting can be overridden in each section.

exceptionThreshold

decimal 0-1: if a random number number is less than this value an exception will be generated. Set to 0 if you want no errors to be triggered by the PhoneGap api. Set to 1 if you want to test all your error handlers. This setting can be overridden in each section.

startupDelay

integer: number of milliseconds after startup to trigger the deviceready event. Defaults to 200

currentFile

string: path to an additional config file to load at startup. This setting is intended for situations where different sets of test data are regularly needed. Each set can be defined in separate files and easily switched as needed.

Examples

  1. Simple config where test data is defined in a separate file
{  
  "internal":{  
    "arraySequence":true,  
    "exceptionThreshold":0,  
    "startupDelay" : 200,  
    "currentFile": "android-test-data.json"  
  }  
}  
  1. Define base settings. accelerometer data will be returned in random order, camera functions will cause errors 3 times out of 10
{  
  "internal":{  
    "arraySequence":true,  
    "exceptionThreshold":0,  
    "startupDelay" : 200  
  },  
  "accelerometer":{  
    "arraySequence": false,  
    ...  
  },  
  "camera":{  
    "exceptionThreshold": 0.3,  
    ...  
  },  
  ...