Closed Bug 935509 Opened 11 years ago Closed 8 years ago

[WAP push] Refactor the code to increase consistency and simplify testing

Categories

(Firefox OS Graveyard :: Gaia::Wappush, defect)

ARM
Gonk (Firefox OS)
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: gsvelto, Unassigned)

References

Details

The WapPushManager object has accumulated a fair amount of different styles and quirks during its development and its structure makes it hard to write unit-tests for it as some important pieces (e.g. sending notifications) are deeply embedded within other functions.

To improve the situation we should do:

- Convert the WapPushManager, WhiteList and possibly the ActivityPicker and LinkActionHandler to match the style used for other singletons. I.e. from

var Foo = {
  _baz: null,
  bar: function foo_bar() { return this._baz; },
  ...
}

to

(function(exports) {
  var baz = null;
  function foo_bar() { return baz; }

  var Foo = {
    bar: foo_bar
  };

  exports.Foo = Foo;
})(this);

as this provides better encapsulation and information hiding for the private variables/functions used within the singleton.

- Split the onWapPushReceived() function and move out of it the code to send notifications.

- Extract the bits required to obtain the application object as they're duplicated and make testing more complicated due to the requirement of calling the mock's mTriggerLastRequestSuccess() function.
I think you also need a bug about splitting the MessageDB object in 2 parts: one generic with fairly basic operations and one containing the complex logic.
Blocks: 939808
(In reply to Julien Wajsberg [:julienw] from comment #1)
> I think you also need a bug about splitting the MessageDB object in 2 parts:
> one generic with fairly basic operations and one containing the complex
> logic.

I've opened bug 939808 not to forget this part :-)
Component: Gaia → Gaia::Wappush
No longer blocks: sms-refactoring
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.