Commit adf1afd4 authored by Szu-Yu Chen [:aknow]'s avatar Szu-Yu Chen [:aknow]
Browse files

Bug 919414 - Part 2: Modify tests. r=hsinyi

parent 7ea50a9f
Loading
Loading
Loading
Loading
+4 −26
Original line number Diff line number Diff line
@@ -4,10 +4,7 @@
MARIONETTE_TIMEOUT = 60000;
MARIONETTE_HEAD_JS = 'head.js';

SpecialPowers.addPermission("telephony", true, document);

let telephony = window.navigator.mozTelephony;
let conference = telephony.conferenceGroup;
let conference;
let outNumber = "5555551111";
let inNumber = "5555552222";
let inNumber2 = "5555553333";
@@ -43,25 +40,6 @@ function checkState(telephonyActive, telephonyCalls, conferenceState,
  }
}

function verifyInitialState() {
  log("Verifying initial state.");
  ok(telephony);
  ok(conference);

  emulator.run("gsm clear", function(result) {
    log("Clear up calls from a previous test if any.");
    is(result[0], "OK");

    // No more calls in the list; give time for emulator to catch up.
    waitFor(function next() {
      checkState(null, [], '', []);
      dial();
    }, function isDone() {
      return (telephony.calls.length === 0);
    });
  });
}

function dial() {
  log("Making an outgoing call.");
  outgoingCall = telephony.dial(outNumber);
@@ -701,11 +679,11 @@ function hangUpLastCall() {
}

function cleanUp() {
  SpecialPowers.removePermission("telephony", document);
  finish();
}

// Start the test
startTest(function() {
  verifyInitialState();
  conference = telephony.conferenceGroup;
  ok(conference);
  dial();
});
+1 −36
Original line number Diff line number Diff line
@@ -4,44 +4,9 @@
MARIONETTE_TIMEOUT = 60000;
MARIONETTE_HEAD_JS = 'head.js';

SpecialPowers.addPermission("telephony", true, document);

let telephony = window.navigator.mozTelephony;
let outNumber = "5555551111";
let outgoingCall;

function getExistingCalls() {
  emulator.run("gsm list", function(result) {
    log("Initial call list: " + result);
    if (result[0] == "OK") {
      dial();
    } else {
      cancelExistingCalls(result);
    }
  });
}

function cancelExistingCalls(callList) {
  if (callList.length && callList[0] != "OK") {
    // Existing calls remain; get rid of the next one in the list
    nextCall = callList.shift().split(/\s+/)[2].trim();
    log("Cancelling existing call '" + nextCall +"'");
    emulator.run("gsm cancel " + nextCall, function(result) {
      if (result[0] == "OK") {
        cancelExistingCalls(callList);
      } else {
        log("Failed to cancel existing call");
        cleanUp();
      }
    });
  } else {
    // No more calls in the list; give time for emulator to catch up
    waitFor(dial, function() {
      return (telephony.calls.length === 0);
    });
  }
}

function dial() {
  log("Make an outgoing call.");
  outgoingCall = telephony.dial(outNumber);
@@ -75,5 +40,5 @@ function cleanUp(){
}

startTest(function() {
  getExistingCalls();
  dial();
});
+1 −25
Original line number Diff line number Diff line
@@ -4,33 +4,10 @@
MARIONETTE_TIMEOUT = 60000;
MARIONETTE_HEAD_JS = 'head.js';

SpecialPowers.addPermission("telephony", true, document);

let telephony = window.navigator.mozTelephony;
let number = "911";
let outgoing;
let calls;

function verifyInitialState() {
  log("Verifying initial state.");
  ok(telephony);
  is(telephony.active, null);
  ok(telephony.calls);
  is(telephony.calls.length, 0);
  calls = telephony.calls;

  emulator.run("gsm list", function(result) {
    log("Initial call list: " + result);
    is(result[0], "OK");
    if (result[0] == "OK") {
      dial();
    } else {
      log("Call exists from a previous test, failing out.");
      cleanUp();
    }
  });
}

function dial() {
  log("Make an emergency call.");

@@ -103,10 +80,9 @@ function hangUp() {
}

function cleanUp() {
  SpecialPowers.removePermission("telephony", document);
  finish();
}

startTest(function() {
  verifyInitialState();
  dial();
});
+1 −25
Original line number Diff line number Diff line
@@ -4,33 +4,10 @@
MARIONETTE_TIMEOUT = 60000;
MARIONETTE_HEAD_JS = 'head.js';

SpecialPowers.addPermission("telephony", true, document);

let telephony = window.navigator.mozTelephony;
let number = "not a valid emergency number";
let outgoing;
let calls;

function verifyInitialState() {
  log("Verifying initial state.");
  ok(telephony);
  is(telephony.active, null);
  ok(telephony.calls);
  is(telephony.calls.length, 0);
  calls = telephony.calls;

  emulator.run("gsm list", function(result) {
    log("Initial call list: " + result);
    is(result[0], "OK");
    if (result[0] == "OK") {
      dial();
    } else {
      log("Call exists from a previous test, failing out.");
      cleanUp();
    }
  });
}

function dial() {
  log("Make an outgoing call to an invalid number.");

@@ -62,10 +39,9 @@ function dial() {
}

function cleanUp() {
  SpecialPowers.removePermission("telephony", document);
  finish();
}

startTest(function() {
  verifyInitialState();
  dial();
});
+5 −59
Original line number Diff line number Diff line
@@ -4,9 +4,6 @@
MARIONETTE_TIMEOUT = 60000;
MARIONETTE_HEAD_JS = 'head.js';

SpecialPowers.addPermission("telephony", true, document);

let telephony = window.navigator.mozTelephony;
let number;
let emergency;
let outgoing;
@@ -19,60 +16,6 @@ let expectedResults = [
  ["777", false],
];

function getExistingCalls() {
  emulator.run("gsm list", function(result) {
    log("Initial call list: " + result);
    if (result[0] == "OK") {
      verifyInitialState(false);
    } else {
      cancelExistingCalls(result);
    }
  });
}

function cancelExistingCalls(callList) {
  if (callList.length && callList[0] != "OK") {
    // Existing calls remain; get rid of the next one in the list
    nextCall = callList.shift().split(/\s+/)[2].trim();
    log("Cancelling existing call '" + nextCall +"'");
    emulator.run("gsm cancel " + nextCall, function(result) {
      if (result[0] == "OK") {
        cancelExistingCalls(callList);
      } else {
        log("Failed to cancel existing call");
        cleanUp();
      }
    });
  } else {
    // No more calls in the list; give time for emulator to catch up
    waitFor(verifyInitialState, function() {
      return (telephony.calls.length === 0);
    });
  }
}

function verifyInitialState(confirmNoCalls = true) {
  log("Verifying initial state.");
  ok(telephony);
  is(telephony.active, null);
  ok(telephony.calls);
  is(telephony.calls.length, 0);
  if (confirmNoCalls) {
    emulator.run("gsm list", function(result) {
    log("Initial call list: " + result);
      is(result[0], "OK");
      if (result[0] == "OK") {
        dial();
      } else {
        log("Call exists from a previous test, failing out.");
        cleanUp();
      }
    });
  } else {
    dial();
  }
}

function createGoldenCallListResult0(number, state) {
  //  "outbound to  xxxxxxxxxx : ringing"
  let padPattern = "          ";
@@ -154,7 +97,6 @@ function hangUp() {
}

function cleanUp() {
  SpecialPowers.removePermission("telephony", document);
  finish();
}

@@ -165,8 +107,12 @@ function verifyNextEmergencyLabel() {
    log("Running test case: " + testCase + "/" + expectedResults.length);
    number = expectedResults[testCase][0];
    emergency = expectedResults[testCase][1];
    getExistingCalls();
    testCase++;

    // No more calls in the list; give time for emulator to catch up
    waitFor(dial, function() {
      return (telephony.calls.length === 0);
    });
  }
}

Loading