B2G/gecko/toolkit/components/places/tests/queries/test_querySerialization.js
/**
 * This drives the test runs.  See the comment at the top of this file.
 *
 * @param aHowManyLo
 *        the size of the switch subsets to start with
 * @param aHowManyHi
 *        the size of the switch subsets to end with (inclusive)
 */
This drives the test runs.  See the comment at the top of this file.
@param aHowManyLo
the size of the switch subsets to start with
@param aHowManyHi
the size of the switch subsets to end with (inclusive)
This drives the test runs . See the comment at the top of this file . @param aHowManyLo the size of the switch subsets to start with @param aHowManyHi the size of the switch subsets to end with ( inclusive )
function runQuerySequences(aHowManyLo, aHowManyHi)
{
  var allSwitches = querySwitches.concat(queryOptionSwitches);
  var prevQueries = [];
  var prevOpts = [];
  for (let howMany = aHowManyLo; howMany <= aHowManyHi; howMany++) {
    let numIters = 0;
    print("CHOOSING " + howMany + " SWITCHES");
    choose(allSwitches, howMany, function (chosenSwitches) {
      print(numIters);
      numIters++;
      var runs = chosenSwitches.map(function (s) {
        if (s.desc)
          print("  " + s.desc);
        return s.runs;
      });
       ...,
      cartProd(runs, function (runSet) {
        var query = PlacesUtils.history.getNewQuery();
        var opts = PlacesUtils.history.getNewQueryOptions();
        for (let i = 0; i < runSet.length; i++) {
          runSet[i](query, opts);
        }
        serializeDeserialize([query], opts);
        prevQueries.push(query);
        prevOpts.push(opts);
        if (prevQueries.length >= NUM_MULTIPLE_QUERIES) {
          for (let i = 0; i < prevOpts.length; i++) {
            serializeDeserialize(prevQueries, prevOpts[i]);
          }
          prevQueries.shift();
          prevOpts.shift();
        }
      });
    });
  }
  print("\n");
}
function runQuerySequences ( aHowManyLo , aHowManyHi ) { var allSwitches = querySwitches . concat ( queryOptionSwitches ) ; var prevQueries = [ ] ; var prevOpts = [ ] ; for ( let howMany = aHowManyLo ; howMany <= aHowManyHi ; howMany ++ ) { let numIters = 0 ; print ( "CHOOSING " + howMany + " SWITCHES" ) ; choose ( allSwitches , howMany , function ( chosenSwitches ) { print ( numIters ) ; numIters ++ ; var runs = chosenSwitches . map ( function ( s ) { if ( s . desc ) print ( "  " + s . desc ) ; return s . runs ; } ) ; cartProd ( runs , function ( runSet ) { var query = PlacesUtils . history . getNewQuery ( ) ; var opts = PlacesUtils . history . getNewQueryOptions ( ) ; for ( let i = 0 ; i < runSet . length ; i ++ ) { runSet [ i ] ( query , opts ) ; } serializeDeserialize ( [ query ] , opts ) ; prevQueries . push ( query ) ; prevOpts . push ( opts ) ; if ( prevQueries . length >= NUM_MULTIPLE_QUERIES ) { for ( let i = 0 ; i < prevOpts . length ; i ++ ) { serializeDeserialize ( prevQueries , prevOpts [ i ] ) ; } prevQueries . shift ( ) ; prevOpts . shift ( ) ; } } ) ; } ) ; } print ( "\n" ) ; }
This drives the test runs.
This drives the test runs .
// Choose aHowManyLo switches up to aHowManyHi switches. // Choose all subsets of size howMany from allSwitches. // Collect the runs. // runs = [ [runs from switch 1], ..., [runs from switch howMany] ] // cartProd(runs) => [ //   [switch 1 run 1, switch 2 run 1, ..., switch howMany run 1 ], //   ..., //   [switch 1 run 1, switch 2 run 1, ..., switch howMany run N ], //   ..., ..., //   [switch 1 run N, switch 2 run N, ..., switch howMany run 1 ], //   ..., //   [switch 1 run N, switch 2 run N, ..., switch howMany run N ], // ] // Create a new query, apply the switches in runSet, and test it. // Test the previous NUM_MULTIPLE_QUERIES queries together. // We can serialize multiple nsINavHistoryQuery objects together but // only one nsINavHistoryQueryOptions object with them.  So, test each // of the previous NUM_MULTIPLE_QUERIES nsINavHistoryQueryOptions.