Closed Bug 811185 Opened 7 years ago Closed 7 years ago

Implement Emulator class for screen orientation for Marionette

Categories

(Testing :: Marionette, defect)

defect
Not set

Tracking

(firefox18 fixed, firefox19 fixed)

RESOLVED FIXED
mozilla19
Tracking Status
firefox18 --- fixed
firefox19 --- fixed

People

(Reporter: whimboo, Assigned: whimboo)

References

Details

Attachments

(1 file, 5 obsolete files)

For Marionette WebAPI Python tests which interact with the emulator we should have a class which helps to create tests for this WebAPI. Orientation can be read and written like:

self.marionette.emulator.screen.orientation = self.marionette.emulator.screen.SO_PORTRAIT_SECONDARY

current = self.marionette.emulator.screen.orientation

Also it has to initialize the sensor correctly given that the emulator isn't doing that.
Blocks: 805005
Attached patch Patch v1 (obsolete) — Splinter Review
Attachment #680922 - Flags: review?(jgriffin)
Attached patch Patch v1.1 (obsolete) — Splinter Review
Missed last qref before.
Attachment #680922 - Attachment is obsolete: true
Attachment #680922 - Flags: review?(jgriffin)
Attachment #680923 - Flags: review?(jgriffin)
Comment on attachment 680923 [details] [diff] [review]
Patch v1.1

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

The test file should either have an MPL license header or a public domain header.

::: testing/marionette/client/marionette/emulator_screen.py
@@ +1,5 @@
> +# This Source Code Form is subject to the terms of the Mozilla Public
> +# License, v. 2.0. If a copy of the MPL was not distributed with this
> +# file, You can obtain one at http://mozilla.org/MPL/2.0/.
> +
> +import re

unused import
Attachment #680923 - Flags: review?(jgriffin) → review+
(In reply to Jonathan Griffin (:jgriffin) from comment #3)
> The test file should either have an MPL license header or a public domain
> header.

I have copied the test_emulator.py which didn't contain the license. So I will add it to both test files.

> > +import re
> 
> unused import

Missed to remove it after the refactoring.

I will upload an updated version of the patch and get it landed.
Attached patch Patch v2 (obsolete) — Splinter Review
Updated patch.
Attachment #680923 - Attachment is obsolete: true
Attachment #681381 - Flags: review+
Backed out for breaking all emulator tests:
https://hg.mozilla.org/integration/mozilla-inbound/rev/83d175cb799d
Whiteboard: [automation-needed-in-aurora]
Ed, are you sure? Where do I see that? I can't recognize anything of that:
https://tbpl.mozilla.org/?tree=Mozilla-Inbound&rev=992f2748681f
{
00:21:40     INFO -  Traceback (most recent call last):
00:21:40     INFO -    File "runreftestb2g.py", line 563, in <module>
00:21:40     INFO -      sys.exit(main())
00:21:40     INFO -    File "runreftestb2g.py", line 483, in main
00:21:40     INFO -      marionette = Marionette(**kwargs)
00:21:40     INFO -    File "/home/cltbld/talos-slave/test/build/venv/lib/python2.6/site-packages/marionette/marionette.py", line 132, in __init__
00:21:40     INFO -      self.emulator.start()
00:21:40     INFO -    File "/home/cltbld/talos-slave/test/build/venv/lib/python2.6/site-packages/marionette/emulator.py", line 364, in start
00:21:40     INFO -      self.screen.initialize()
00:21:40     INFO -    File "/home/cltbld/talos-slave/test/build/venv/lib/python2.6/site-packages/marionette/emulator_screen.py", line 17, in initialize
00:21:40     INFO -      self.orientation = self.SO_PORTRAIT_PRIMARY
00:21:40     INFO -    File "/home/cltbld/talos-slave/test/build/venv/lib/python2.6/site-packages/marionette/emulator_screen.py", line 65, in set_orientation
00:21:40     INFO -      if orientation == SO_PORTRAIT_PRIMARY:
00:21:40     INFO -  NameError: global name 'SO_PORTRAIT_PRIMARY' is not defined
00:21:41    ERROR - Return code: 1
}
Attached patch Patch v2.1 (obsolete) — Splinter Review
Not sure what happened here and why 'self' is missing for each constant in the set_orientation() method.

Just for safety I have triggered a try server run:
https://tbpl.mozilla.org/?tree=Try&rev=66d942ceec26
Attachment #681381 - Attachment is obsolete: true
Attachment #681418 - Flags: review?(jgriffin)
Comment on attachment 681418 [details] [diff] [review]
Patch v2.1

This patch is missing the emulator_screen.py file.
Attachment #681418 - Flags: review?(jgriffin) → review-
Attached patch Patch v3 (obsolete) — Splinter Review
Hopefully all fixed now. As discussed on IRC I moved the screen orientation tests into the existing emulator test file.

Pushed to get tested by try server:
https://tbpl.mozilla.org/?tree=Try&rev=c52a06caa143
Attachment #681418 - Attachment is obsolete: true
Attachment #681563 - Flags: review?(jgriffin)
Comment on attachment 681563 [details] [diff] [review]
Patch v3

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

r+ with the problem below fixed.

::: testing/marionette/client/marionette/tests/unit/test_emulator.py
@@ +46,5 @@
> +        self.assertEqual(self.screen.orientation, self.screen.SO_PORTRAIT_PRIMARY,
> +                         'Orientation has been correctly initialized.')
> +
> +        self.sensor.orientation = self.sensor.SO_PORTRAIT_SECONDARY
> +        self.assertEqual(self.sensor.orientation, self.sensor.SO_PORTRAIT_SECONDARY,

You should be using self.screen here rather than self.sensor, I believe.
Attachment #681563 - Flags: review?(jgriffin) → review+
Attached patch Patch v4Splinter Review
Replaced sensor with screen, and as discussed on IRC also added defaults to the unit-test manifest file, so that it can be run on its own.
Attachment #681563 - Attachment is obsolete: true
Attachment #681648 - Flags: review?(jgriffin)
Comment on attachment 681648 [details] [diff] [review]
Patch v4

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

Looks good.
Attachment #681648 - Flags: review?(jgriffin) → review+
Relanded updated patch:
https://hg.mozilla.org/integration/mozilla-inbound/rev/9992b91433a3
Whiteboard: [automation-needed-in-aurora]
https://hg.mozilla.org/mozilla-central/rev/9992b91433a3
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Target Milestone: --- → mozilla19
You need to log in before you can comment on or make changes to this bug.