Closed Bug 840493 Opened 11 years ago Closed 6 years ago

[gallery] Fix & restore unit tests

Categories

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

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: jugglinmike, Unassigned)

References

Details

(Whiteboard: [qa-])

User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.56 Safari/537.17

Steps to reproduce:

Ran the unit test suite


Actual results:

The Gallery application's tests failed


Expected results:

The Gallery application's tests should have passed.
Blocks: 838993
Note: the failing tests were disabled in Bug 838993, this bug is to enable them
back.
Summary: [gallery] Fix failing unit tests → [gallery] Fix & restore unit tests
The DeviceStorage tests seem inappropriate for this application. At :vingletun's suggestion, I've reached out to :dougt (who worked on the code for DeviceStorage) for input on if the project already has coverage for this functionality.

:djf has also weighed in on this:

> I suspect that dougt has written equivalent tests that are already part
> of gecko.  I wrote those gallery tests when we were just figuring out
> unit tests for gaia.
we test device storage in gecko as part of the mochitests.  This test looks useless:

 https://github.com/mozilla-b2g/gaia/blob/b87c794d72f5a8cffc2235f0e8ddfe3d6491b5b0/apps/gallery/test/unit/DeviceStorage_test.js

We should remove device storage unit tests from gaia if they are just testing basic functionality covered by the test suit in gecko.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Assignee: nobody → mike
I'm wondering how I should approach the mediadb_test.js file[1]. It probably doesn't belong in the calendar application's test suite, but I would like to fix it before moving it. Some background:

Apparently, `navigator.getDeviceStorage` originally returned `null` in desktop environments. In such cases, these tests would not run.[2] They now run because `navigator.getDeviceStorage` returns a valid DeviceStorage object.

1) It seems like we might want to mock the `DeviceStorage` interface (similar to what we are working on in Bug 844900). Then we could test the MediaDB interface across platforms (and not worry about testing B2G APIs). Does this sound like the correct approach?

2) The tests reference a `mediadbtests` directory which I cannot find (even at the commit where the tests were first implemented)[3]. Is this directory created by B2G?

[1] https://github.com/mozilla-b2g/gaia/blob/bcea26f1c5f816cc38f267200e2e8082a03e5117/apps/gallery/test/unit/mediadb_test.js
[2] https://github.com/mozilla-b2g/gaia/blob/bcea26f1c5f816cc38f267200e2e8082a03e5117/apps/gallery/test/unit/mediadb_test.js#L4-L9
[3] https://github.com/mozilla-b2g/gaia/blob/bcea26f1c5f816cc38f267200e2e8082a03e5117/apps/gallery/test/unit/mediadb_test.js#L11
Flags: needinfo?(dflanagan)
(In reply to Mike Pennisi [:jugglinmike] from comment #4)
> I'm wondering how I should approach the mediadb_test.js file[1]. It probably
> doesn't belong in the calendar application's test suite, but I would like to
> fix it before moving it. Some background:

You mean the gallery appliation, right?  Gallery was the first app to use the library which is why it is there. But if we've got a spot for testing shared code now, it would be great to move it.

> 
> Apparently, `navigator.getDeviceStorage` originally returned `null` in
> desktop environments. In such cases, these tests would not run.[2] They now
> run because `navigator.getDeviceStorage` returns a valid DeviceStorage
> object.

That's not a problem, is it?

> 1) It seems like we might want to mock the `DeviceStorage` interface
> (similar to what we are working on in Bug 844900). Then we could test the
> MediaDB interface across platforms (and not worry about testing B2G APIs).
> Does this sound like the correct approach?

I don't have a lot of experience with writing tests, so I'm not qualified to say what is correct. IIRC, this test uses a lot of device storage features (to create the test files, e.g.) so there is a lot to mock.

> 2) The tests reference a `mediadbtests` directory which I cannot find (even
> at the commit where the tests were first implemented)[3]. Is this directory
> created by B2G?

The device storage addNamed() function creates directories as needed, so the directory gets created in the course of running the test, I think.

I hope that helps. I wrote that test, ran it, and promptly forgot all about it. There have been API additions since I wrote the test. It is possible that I changed things in mediadb that broke the test. So if you see tests that are not passing, feel free to ask me: it is possible that mediadb is behaving as expected but the tests are out of date.
Flags: needinfo?(dflanagan)
Whiteboard: [qa-]
I returned to this ticket yesterday and began researching apparent issues with the Device Storage API. According to a related wiki page[1], the API is available on the desktop only when an explicit setting is enabled. Additionally, I came across the Firefox-OS-Runtime repo[2], description as follows:

> A Firefox plugin which has several API mocks for rapid development on FFOS.

I spoke with kgrandon (repo owner), julienw, and janjongboom on IRC this morning. Kevin is currently working to incorporate the Firefox-OS-Runtime repo into Gaia. Once this is complete, re-enabling these tests may be as simple as removing the comment markers. The latest estimate for completion of that work is within the week.

[1] https://wiki.mozilla.org/WebAPI#Planned_for_initial_release_of_B2G_.28aka_Basecamp.29
[2] https://github.com/KevinGrandon/Firefox-OS-Runtime
Depends on: 847566
URL: 860344
URL: 860344
Depends on: 860344
Stepping off of this bug to focus on higher-priority Messaging work
Assignee: mike → nobody
Firefox OS is not being worked on
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.