Closed Bug 1034522 Opened 6 years ago Closed 4 years ago

B2G Emulator: Add console command - sim status

Categories

(Firefox OS Graveyard :: Emulator, defect)

x86_64
Linux
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED INCOMPLETE

People

(Reporter: aknow, Assigned: aknow)

References

Details

Attachments

(2 files, 2 obsolete files)

Add a console command to alter sim status. It could be used for testing empty sim as following steps:
1. send emulator console command "sim status absent"
2. turn radio off and on
See Also: → 935407
Attachment #8450870 - Flags: review?(vyang)
Depends on: 935407
Comment on attachment 8450870 [details] [review]
platform_external_qemu: PR #106

Looks good to me, but I need test cases to see how this works actually before placing a review comment.
ni myself to work on test case.
Flags: needinfo?(szchen)
Attached patch card state test (obsolete) — Splinter Review
I modify the card state test to show an example of using this console command.
Attachment #8455999 - Flags: feedback?(vyang)
Flags: needinfo?(szchen)
Comment on attachment 8455999 [details] [diff] [review]
card state test

Review of attachment 8455999 [details] [diff] [review]:
-----------------------------------------------------------------

::: dom/icc/tests/marionette/test_icc_card_state.js
@@ +29,5 @@
>  /* Test cardstatechange event by switching radio off */
>  taskHelper.push(function testCardStateChange() {
>    // Turn off radio.
> +  setRadioEnabled(false, function() {
> +    icc.addEventListener("cardstatechange", function oncardstatechange() {

You may lose this event because that addEventListener is not necessarily installed before 'cardstatechange' has ever been emitted.

Basiscally when you do:

  <some request that emits 'event-foo'>();
  yet_another_async_op(function callback() {
    <register_event_foo>();
    ...
  });

That can result in intermittent failure on try server/emulator.
Attachment #8455999 - Flags: feedback?(vyang) → feedback-
Attached patch #2 card state test (obsolete) — Splinter Review
Attachment #8455999 - Attachment is obsolete: true
Attachment #8456051 - Flags: feedback?(vyang)
Comment on attachment 8456051 [details] [diff] [review]
#2 card state test

Review of attachment 8456051 [details] [diff] [review]:
-----------------------------------------------------------------

Can you have something like:

  function setRadioAndWaitForNamedEvent(aEnable, aEventName, aCallback) {
    setRadioEnabled(false);
    icc.addEventListener(aEventName, function onevent() {
      if (aCallback()) {
        icc.removeEventListener(aEventName, onevent);
      }
    });
  }

  // In that |testCardStateChange()| you have:
  setRadioAndWaitForNamedEvent(false, "cardstatechange" function() {
    if (icc.cardState !== null) {
      return false;
    }

    setRadioAndWaitForNamedEvent(true, "iccdetected", function() {
      window.setTimeout(() => taskHelper.runNext(), 0);

      // Unregister "iccdetected".
      return true;
    });

    // Unregister "cardstatechange".
    return true;
  });

  // In |testRemoveCard()| you have:
  function emulatorChangeSimStatus(aCardStatus, aCallback) {
    setRadioAndWaitForNamedEvent(false, "cardstatechange", function() {
      if (icc.cardState !== null) {
        return false;
      }

      emulatorHelper.sendCommand("sim status " + status, aCallback);

      // Unregister "cardstatechange".
      return true;
    }
  }

  emulatorChangeSimStatus("absent", function() {
    setRadioAndWaitForNamedEvent(true, "cardstatechange", function() {
      if (icc.cardState === null) {
        return false;
      }

      emulatorChangeSimStatus("ready", function() {
        setRadioAndWaitForNamedEvent(true, "iccdetected", function() {
          window.setTimeout(() => taskHelper.runNext(), 0);

          // Unregister "iccdetected".
          return true;
        });
      });

      // Unregister "cardstatechange".
      return true;
    });
  });

::: dom/icc/tests/marionette/test_icc_card_state.js
@@ +5,3 @@
>  MARIONETTE_HEAD_JS = "icc_header.js";
>  
> +connection = navigator.mozMobileConnections[0];

nit: let connection = ...

@@ +81,5 @@
> +      })
> +    }, function() {
> +      let duration = Date.now() - startTime;
> +      // Make sure that the card state is still null after 5s.
> +      return duration >= 5000 && icc.cardState === null;

We'd probably avoid timeouts whenever possible.
Attachment #8456051 - Flags: feedback?(vyang) → feedback-
Attachment #8456051 - Attachment is obsolete: true
Attachment #8458411 - Flags: review?(vyang)
Attachment #8458411 - Flags: review?(vyang) → review+
Attachment #8450870 - Flags: review?(vyang) → review+
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.