Merge lp:~macslow/unity8/shellRotation into lp:unity8

Proposed by Michał Sawicz
Status: Merged
Approved by: Michael Zanetti
Approved revision: 1619
Merged at revision: 1805
Proposed branch: lp:~macslow/unity8/shellRotation
Merge into: lp:unity8
Prerequisite: lp:~unity-team/unity8/shellRotation
Diff against target: 445 lines (+353/-7) (has conflicts)
6 files modified
tests/autopilot/unity8/fixture_setup.py (+131/-3)
tests/autopilot/unity8/indicators/tests/test_display_indicator.py (+1/-1)
tests/autopilot/unity8/process_helpers.py (+3/-3)
tests/autopilot/unity8/sensors.py (+93/-0)
tests/autopilot/unity8/shell/emulators/main_window.py (+12/-0)
tests/autopilot/unity8/shell/tests/test_rotation.py (+113/-0)
Text conflict in debian/changelog
To merge this branch: bzr merge lp:~macslow/unity8/shellRotation
Reviewer Review Type Date Requested Status
Michael Zanetti (community) Approve
PS Jenkins bot (community) continuous-integration Needs Fixing
Michał Sawicz Needs Fixing
Leo Arias (community) Approve
Daniel d'Andrada (community) Abstain
Review via email: mp+256493@code.launchpad.net

This proposal supersedes a proposal from 2015-04-09.

Commit message

Implemented autopilot-test and fake-sensors for shell-rotation.

Description of the change

Implemented autopilot-test and fake-sensors for shell-rotation.

* Are there any related MPs required for this MP to build/function as expected? Please list.
Yes.

The branch lp:~dandrader/qtmir/supportedOrientations needs to be merged to lp:qtmir first before this can work properly.

For testing/reviewer convenience use ppa:unity-team/demo-stuff to get the needed package dependencies in place. In addition to that, wipe your ~/.cache/QML directory on the device before running shell-rotation autopilot-test (see https://bugs.launchpad.net/ubuntu/+source/qtdeclarative-opensource-src/+bug/1444937).

libunity-api-dev >= 7.97 needs to become available before it'll build correctly on Jenkins. Currently this needs to be pulled from ppa:unity-team/demo-stuff, if you want to compile and run this yourself.

* Did you perform an exploratory manual test run of your code change and any related functionality?
Yes.

* Did you make sure that your branch does not contain spurious tags?
Yes.

* If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?
Not applicable.

* If you changed the UI, has there been a design review?
Not applicable.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Michał Sawicz (saviq) wrote : Posted in a previous version of this proposal

I aborted the CI run as it was bound to fail without the dependencies anyway...

lp:~macslow/unity8/shellRotation updated
1601. By Mirco Müller

Make code a bit more tight.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

tests/qmltests/tst_TabletShell.qml has been removed from trunk a while ago but your test is erroneously adding it back again.

review: Needs Fixing
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

> tests/qmltests/tst_TabletShell.qml has been removed from trunk a while ago but
> your test is erroneously adding it back again.

To be clear, tst_TabletShell.qml was merged into tst_Shell.qml.

lp:~macslow/unity8/shellRotation updated
1602. By Mirco Müller

Removed tst_TabletShell.qml added by mistake earlier.

Revision history for this message
Mirco Müller (macslow) wrote :

> > tests/qmltests/tst_TabletShell.qml has been removed from trunk a while ago
> but
> > your test is erroneously adding it back again.
>
> To be clear, tst_TabletShell.qml was merged into tst_Shell.qml.

Fixed in r1602.

Revision history for this message
Daniel d'Andrada (dandrader) wrote :

> > > tests/qmltests/tst_TabletShell.qml has been removed from trunk a while ago
> > but
> > > your test is erroneously adding it back again.
> >
> > To be clear, tst_TabletShell.qml was merged into tst_Shell.qml.
>
> Fixed in r1602.

Thanks.

review: Abstain
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Michał Sawicz (saviq) wrote :

I'm worried about all the code duplication in LaunchUnityWithFakeSensors, think we could refactor some way?

review: Needs Information
Revision history for this message
Leo Arias (elopio) wrote :

> I'm worried about all the code duplication in LaunchUnityWithFakeSensors,
> think we could refactor some way?

yes! Ideally you would write a LaunchUnity fixture, and use it in every test. And you can use it as a base for LaunchUnityWithFakeSensors, overwriting just a couple of things.

Revision history for this message
Leo Arias (elopio) wrote :

Some things to fix are in the inline comments.

Also, for consistency, please change all your " for '.

And the two tests you added are too big. We need to keep the tests short, making one action and doing one assertion at the end. When you repeat actions and have assertion in the middle is a bad small.

You can improve the readability of those two tests and improve defect localization by using scenarios. Put something like this as an attribute of the test case for the first test:

scenarios = [
    ('top up', {'orientation': 1}),
...
    ('left up', {'orientation': 2}),
]

Make a new test case for the second test and use something like:

scenarios = [
    ('top up, angle 0', {'orientation': 1, 'angle': 0}),
...
    ('left up, angle 270', {'orientation': 2, 'angle': 270}),
]

The test will be run as many times as scenarios you have defined.
And the values will be accessible in self.orientation and self.angle.

If you need help with the scenarios, drop into #ubuntu-quality and ping the vanguard.

Thanks for working on this!

review: Needs Fixing
lp:~macslow/unity8/shellRotation updated
1603. By Mirco Müller

Fix some issues from MP-comments... use scenarios as much as possible to make ap-test more compact.

1604. By Mirco Müller

More Python3-ification according to MP-comments.

1605. By Mirco Müller

Forgot import

Revision history for this message
Leo Arias (elopio) wrote :

371+ scenarios = tests._get_device_emulation_scenarios()

This is not needed ^. As you are running the tests only in the phone, the emulation scenarios will be an empty list. By removing that, you no longer need to multiply the scenarios, and the code will look simpler.

Also, your branch is not passing flake8. Saviq fixed all the flake8 in trunk:

https://code.launchpad.net/~saviq/unity8/fix-flake8/+merge/256510

You can use that branch as a prerequisite, and run

python3 -m flake8 .

to make sure you are not adding any errors.

review: Needs Fixing
Revision history for this message
Michał Sawicz (saviq) wrote :

W dniu 21.04.2015 o 17:13, Leo Arias pisze:
> You can use that branch as a prerequisite, and run

This already has a prereq, I'm releasing it soon, just merge trunk once
it's there.

lp:~macslow/unity8/shellRotation updated
1606. By Mirco Müller

flake8-ify shell-rotation ap-test.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
lp:~macslow/unity8/shellRotation updated
1607. By Mirco Müller

Merged with unity8 trunk.

1608. By Mirco Müller

Build-dependency on libunity-api-dev >= 7.97 is wrong 7.96 is sufficient.

1609. By Mirco Müller

Argl

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
lp:~macslow/unity8/shellRotation updated
1610. By Mirco Müller

Removed to lines that must have been added by a bogus branch-merge. The display-indicator ap-tests were never meant to be touched.

1611. By Mirco Müller

Make test skip earlier and save execution-time, if device does not support a certain orientation.

Revision history for this message
Leo Arias (elopio) :
review: Approve
Revision history for this message
Mirco Müller (macslow) wrote :

Just for the record, the re-factor of the LaunchUnity-fixture and re-work of LaunchUnityWithFakeSensors we decided to keep outside of this branch and filed a dedicate bug for this task (see https://bugs.launchpad.net/ubuntu/+source/unity8/+bug/1447206).

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Albert Astals Cid (aacid) wrote :

Text conflict in debian/control
Text conflict in src/ApplicationArguments.h
Conflict adding file src/UnityCommandLineParser.cpp. Moved existing file to src/UnityCommandLineParser.cpp.moved.
Conflict adding file src/UnityCommandLineParser.h. Moved existing file to src/UnityCommandLineParser.h.moved.
Text conflict in src/main.cpp
Text conflict in tests/plugins/Unity/Launcher/CMakeLists.txt
6 conflicts encountered.

Revision history for this message
Mirco Müller (macslow) wrote :

> Text conflict in debian/control
> Text conflict in src/ApplicationArguments.h
> Conflict adding file src/UnityCommandLineParser.cpp. Moved existing file to
> src/UnityCommandLineParser.cpp.moved.
> Conflict adding file src/UnityCommandLineParser.h. Moved existing file to
> src/UnityCommandLineParser.h.moved.
> Text conflict in src/main.cpp
> Text conflict in tests/plugins/Unity/Launcher/CMakeLists.txt
> 6 conflicts encountered.

*sigh* wtf?! Looking into it now... I didn't run into that yesterday.

lp:~macslow/unity8/shellRotation updated
1612. By Mirco Müller

Merge with parent

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

Any reason why it hasn't been top-approved?

Revision history for this message
Mirco Müller (macslow) wrote :

I guess because the needed dependencies for Jenkins are not in place yet, thus nobody wants to top-approve it before Jenkins gives the approved-flag also.

Revision history for this message
Michał Sawicz (saviq) wrote :

Please fix the flake8 issues:

$ python3 -m flake8 tests
tests/autopilot/unity8/fixture_setup.py:43:1: F401 'get_lib_path' imported but unused
tests/autopilot/unity8/fixture_setup.py:43:1: F811 redefinition of unused 'get_binary_path' from line 31
tests/autopilot/unity8/fixture_setup.py:53:1: E302 expected 2 blank lines, found 1
tests/autopilot/unity8/fixture_setup.py:89:80: E501 line too long (83 > 79 characters)
tests/autopilot/unity8/fixture_setup.py:140:80: E501 line too long (80 > 79 characters)
tests/autopilot/unity8/fixture_setup.py:141:80: E501 line too long (87 > 79 characters)
tests/autopilot/unity8/process_helpers.py:110:19: F821 undefined name '_get_unity_pid'
tests/autopilot/unity8/indicators/tests/test_display_indicator.py:19:1: F401 'platform' imported but unused
tests/autopilot/unity8/indicators/tests/test_display_indicator.py:21:1: F401 'process_helpers' imported but unused
tests/autopilot/unity8/indicators/tests/test_display_indicator.py:46:5: E303 too many blank lines (2)

review: Needs Fixing
lp:~macslow/unity8/shellRotation updated
1613. By Mirco Müller

Fix more flake8 errors.

Revision history for this message
Mirco Müller (macslow) wrote :

Done as of r1613.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Michał Sawicz (saviq) wrote :

Trying to run the rotation tests from demo-stuff PPA gets me:
traceback-3: {{{
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/unity8/shell/tests/test_rotation.py", line 86, in test_rotation_with_webbrowser_app
    self.useFixture(unity_with_sensors)
  File "/usr/lib/python3/dist-packages/testtools/testcase.py", line 645, in useFixture
    fixture.setUp()
  File "/usr/lib/python3/dist-packages/unity8/fixture_setup.py", line 75, in setUp
    self._create_sensors()
  File "/usr/lib/python3/dist-packages/unity8/fixture_setup.py", line 152, in _create_sensors
    process_helpers.get_unity_pid())
AttributeError: 'module' object has no attribute 'get_unity_pid'
}}}

And 8 failures.

review: Needs Fixing
lp:~macslow/unity8/shellRotation updated
1614. By Mirco Müller

Made get_unity_pid() available across ap-tests.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Michał Sawicz (saviq) wrote :

$ autopilot3 run -v unity8.shell.tests.test_rotation | grep SKIP
18:10:35.636 INFO testresult:44 - SKIP: unity8.shell.tests.test_rotation.TestRotationWithApp.test_rotation_with_webbrowser_app(top up, angle 0)
18:10:49.504 INFO testresult:44 - SKIP: unity8.shell.tests.test_rotation.TestRotationWithApp.test_rotation_with_webbrowser_app(right up, angle 90)
18:11:03.473 INFO testresult:44 - SKIP: unity8.shell.tests.test_rotation.TestRotationWithApp.test_rotation_with_webbrowser_app(top down, angle 180)
18:11:17.189 INFO testresult:44 - SKIP: unity8.shell.tests.test_rotation.TestRotationWithApp.test_rotation_with_webbrowser_app(left up, angle 270)

review: Needs Fixing
lp:~macslow/unity8/shellRotation updated
1615. By Mirco Müller

This should solve the too early skipping of the rotation ap-test.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Michał Sawicz (saviq) wrote :

Got one failure:

unity8.shell.tests.test_rotation.TestFakeSensor.test_fake_sensor(right up)

08:11:58.733 WARNING testcase:175 - Process manager backend unavailable, application snapshot support disabled.
08:11:58.742 WARNING utilities:263 - WARNING: in file "/usr/lib/python3/dist-packages/unity8/shell/tests/__init__.py", line 140 in setUp
This function is deprecated. Please use 'the Touch class to instantiate a device object' instead.

08:11:58.895 INFO logging:45 - str: Set the value of an initctl environment variable. Arguments ('sensors',). Keyword arguments: {'global_': False}.
08:11:59.095 INFO process_helpers:177 - Starting job unity8 with arguments ('BINARY=/usr/bin/unity8', 'XDG_DATA_DIRS=/usr/share/unity8/mocks/data:/usr/share/ubuntu-touch:/usr/local/share:/usr/share', 'LD_LIBRARY_PATH=/usr/lib/arm-linux-gnueabihf/unity8/qml/mocks/libusermetrics:/usr/lib/arm-linux-gnueabihf/unity8/qml/mocks/LightDM/liblightdm:/vendor/lib:/system/lib', 'QML2_IMPORT_PATH=/usr/lib/arm-linux-gnueabihf/unity8/qml/mocks:/usr/lib/arm-linux-gnueabihf/qt5/imports', 'QT_LOAD_TESTABILITY=1').
08:12:00.433 INFO process_helpers:185 - unity8 start/running, process 17721

08:12:08.997 INFO process_helpers:88 - Greeter unlocked, continuing.
08:12:26.943 INFO process_helpers:233 - Stoping job unity8.
08:12:29.006 INFO process_helpers:241 - unity8 stop/waiting

08:12:29.009 INFO logging:45 - str: Remove an initctl environment variable. Arguments (). Keyword arguments: {'global_': False}.

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/unity8/shell/tests/test_rotation.py", line 67, in test_fake_sensor
    Eventually(Equals(self.orientation), timeout=15))
  File "/usr/lib/python3/dist-packages/testtools/testcase.py", line 423, in assertThat
    raise mismatch_error
testtools.matchers._impl.MismatchError: After 15.0 seconds test on OrientedShell.physicalOrientation failed: 8 != dbus.Int32(2, variant_level=1)

review: Needs Fixing
Revision history for this message
Michał Sawicz (saviq) wrote :

The above happens about 50% of runs on krillin. Trying mako now.

Revision history for this message
Mirco Müller (macslow) wrote :

Hm... trying to reproduce it too.

Revision history for this message
Michał Sawicz (saviq) wrote :

Same on mako, roughly 50% fail.

Revision history for this message
Mirco Müller (macslow) wrote :
Download full text (3.2 KiB)

On my mako (using image 191) even with ~/.cache/QML wiped, the rotation tests now fail all the time with the usual...

Tests running...
Exception in thread Thread-2:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/psutil/_pslinux.py", line 694, in wrapper
    return fun(self, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/psutil/_pslinux.py", line 844, in create_time
    f = open("/proc/%s/stat" % self.pid, 'rb')
FileNotFoundError: [Errno 2] No such file or directory: '/proc/7492/stat'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/psutil/__init__.py", line 322, in _init
    self.create_time()
  File "/usr/lib/python3/dist-packages/psutil/__init__.py", line 576, in create_time
    self._create_time = self._proc.create_time()
  File "/usr/lib/python3/dist-packages/psutil/_pslinux.py", line 704, in wrapper
    raise NoSuchProcess(self.pid, self._name)
psutil.NoSuchProcess: process no longer exists (pid=7492)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.4/threading.py", line 920, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.4/threading.py", line 868, in run
    self._target(*self._args, **self._kwargs)
  File "/home/phablet/src/unity8-shellRotation/tests/autopilot/unity8/fixture_setup.py", line 141, in _restart_unity_with_testability
    *args)
  File "/home/phablet/src/unity8-shellRotation/tests/autopilot/unity8/process_helpers.py", line 148, in restart_unity_with_testability
    return restart_unity(*args)
  File "/home/phablet/src/unity8-shellRotation/tests/autopilot/unity8/process_helpers.py", line 165, in restart_unity
    return _get_unity_proxy_object(pid)
  File "/home/phablet/src/unity8-shellRotation/tests/autopilot/unity8/process_helpers.py", line 274, in _get_unity_proxy_object
    emulator_base=emulators.UnityEmulatorBase,
  File "/usr/lib/python3/dist-packages/autopilot/introspection/_search.py", line 171, in get_proxy_object_for_existing_process
    process
  File "/usr/lib/python3/dist-packages/autopilot/introspection/_search.py", line 318, in _find_matching_connections
    in connections
  File "/usr/lib/python3/dist-packages/autopilot/introspection/_search.py", line 319, in <listcomp>
    if connection_matcher((bus, c))
  File "/usr/lib/python3/dist-packages/autopilot/introspection/_search.py", line 292, in _filter_runner
    for f in filter_list
  File "/usr/lib/python3/dist-packages/autopilot/introspection/_search.py", line 292, in <genexpr>
    for f in filter_list
  File "/usr/lib/python3/dist-packages/autopilot/introspection/_search.py", line 758, in matches
    eligible_pids = [pid] + _get_child_pids(pid)
  File "/usr/lib/python3/dist-packages/autopilot/introspection/_search.py", line 660, in __call__
    p.pid for p in psutil.Process(pid).get_children(recursive=True)
  File "/usr/lib/python3/dist-packages/psutil/__init__.py", line 296, in __init__
    self._init(pid)
  File "/usr/lib/python3/dist-packages/psutil/__init__.py", line 331, in _init
    raise NoSuchProcess(pid, None, msg)
psutil.NoS...

Read more...

Revision history for this message
Mirco Müller (macslow) wrote :

Since using the scenarios, I have to remove /etc/profile.d/qml_qv4_jit_cache.sh to avoid the environment-variable $QV4_ENABLE_JIT_CACHE being defined (just setting it to 0 didn't work). Otherwise I'm constantly running into above unity8-failures.

So far only once test_fake_sensor(right up) failed for me too. But I've no idea why it should. Apart from that I seen the shell-rotation ap-test pass many times and occasionally hang.

No clue as of now what caused the assertion-failure for 'right_up' or the autopilot-test itself hang.

Revision history for this message
Mirco Müller (macslow) wrote :

unity8 does not crash (no files created in /var/crash) and entries in ~/.cache/upstart/unity8.log also do not point out any issue (no difference between all tests passing or 'right_up' failing).

Revision history for this message
Mirco Müller (macslow) wrote :

After cleaning tons of logging-noise from a succeeded and failed ap-test-run of ~/.cache/upstart/unity8.log the major difference I could find was...

succeeded run:
 * qtmir.sensor: Screen::customEvent - new orientation 8 handled

failed run:
 * qtmir.sensor: Screen::customEvent - new orientation 2 handled

So for the failing "right_up" (orientation: 8) case, it seems the orientation isn't touched at all or stuck at 2. Why/how that's happening I don't know yet.

lp:~macslow/unity8/shellRotation updated
1616. By Mirco Müller

To make the faked 'right-up'-orientation be recognized more consistently by qtubuntu-sensors, more granularity steps were needed.

Revision history for this message
Mirco Müller (macslow) wrote :

While the last commit (r1616) does indeed greatly improve the reliability of the faked "right up"-orientation, we still suffer from the hiccups due to the cached qml. One has to really unset $QV4_ENABLE_JIT_CACHE before running the shell-rotation ap-tests. Just assigning a value of 0 to that environment variable won't be enough.

Revision history for this message
Mirco Müller (macslow) wrote :

Seriously... WTF?!?!?!

I got this from ~/.cache/upstart/unity8.log...

"TestSensor WARNING: Requested sensor accelerometer not yet created, blocking thread until create event received"

... after another test-run (after 26 successful ones) of test_fake_sensor. How fucked up is this stuff? Why does it work fine 100 times... I commit my changes... just for the fun try another run and this happens and the ap-test just hangs.

Revision history for this message
Leo Arias (elopio) wrote :

Isn't that how it's supposed to work?

As I understood it, we restart unity, and it gets stuck until in the other thread we:

146+ fifo.write('create accel 0 1000 0.1\n')

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Albert Astals Cid (aacid) wrote :

Text conflict in qml/Stages/PhoneStage.qml
Text conflict in qml/Stages/TabletStage.qml
Text conflict in tests/autopilot/unity8/fixture_setup.py
3 conflicts encountered.

Revision history for this message
Mirco Müller (macslow) wrote :

> Isn't that how it's supposed to work?
>
> As I understood it, we restart unity, and it gets stuck until in the other
> thread we:
>
> 146+ fifo.write('create accel 0 1000 0.1\n')

You tell me... I've no idea what "fifo.write('create accel 0 1000 0.1\n')" really means.

Revision history for this message
Mirco Müller (macslow) wrote :

> Text conflict in qml/Stages/PhoneStage.qml
> Text conflict in qml/Stages/TabletStage.qml
That's coming from ~unity-team/unity8/shellRotation merged with unity8 trunk. I'll wait for Daniel to sort that out there.

> Text conflict in tests/autopilot/unity8/fixture_setup.py
Fixing that one now.

lp:~macslow/unity8/shellRotation updated
1617. By Mirco Müller

Merged with parent branch again and fixed conflicts.

Revision history for this message
Mirco Müller (macslow) wrote :

Last set of test-runs gave me 100% success-rate. I did sets of 30, 40 and 50 runs in a row. I really think we are good with this one in terms of ap-test-reliability.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Leo Arias (elopio) wrote :

Hey Mirco, mzanetti told be that we should unset the cache variable before launching unity.
You can do it with:
http://paste.ubuntu.com/11082250/

It would be nice to add a comment before that line about why we are disabling the cache, which is not yet fully clear to me.

A pass rate of 100 in 50 test runs seems pretty decent.

lp:~macslow/unity8/shellRotation updated
1618. By Mirco Müller

Make sure to unset QV4_ENABLE_JIT_CACHE environment-variable for autopilot-test runs, due to LP: #1444937.

Revision history for this message
Mirco Müller (macslow) wrote :

Updated the branch to unset $QV4_ENABLE_JIT_CACHE for now with a FIXME-remark referencing LP: #1444937.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
lp:~macslow/unity8/shellRotation updated
1619. By Mirco Müller

Revert changes from r1618 since the qml-cache-related issue can't be reproduced on other setups.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Albert Astals Cid (aacid) wrote :

Text conflict in qml/Stages/PhoneStage.qml
Text conflict in qml/Stages/TabletStage.qml
2 conflicts encountered.

Revision history for this message
Michael Zanetti (mzanetti) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/autopilot/unity8/fixture_setup.py'
2--- tests/autopilot/unity8/fixture_setup.py 2015-05-05 14:46:49 +0000
3+++ tests/autopilot/unity8/fixture_setup.py 2015-05-13 11:15:59 +0000
4@@ -17,19 +17,147 @@
5 # along with this program. If not, see <http://www.gnu.org/licenses/>.
6 #
7
8+import os
9+import subprocess
10+import threading
11 import fixtures
12 import logging
13-import os
14-import subprocess
15
16 import ubuntuuitoolkit
17 from autopilot import introspection
18+from autopilot.matchers import Eventually
19+from testtools.matchers import Equals
20+from ubuntuuitoolkit import fixture_setup
21
22 from unity8 import (
23 get_binary_path,
24+ sensors,
25 process_helpers
26 )
27
28+from unity8.shell import emulators
29+
30+from unity8.shell.emulators import (
31+ main_window as main_window_emulator
32+)
33+
34+from unity8 import (
35+ get_mocks_library_path,
36+ get_default_extra_mock_libraries,
37+ get_data_dirs
38+)
39+
40+logger = logging.getLogger(__name__)
41+
42+
43+class LaunchUnityWithFakeSensors(fixtures.Fixture):
44+
45+ """Fixture to launch Unity8 with an injectable sensors backend.
46+
47+ :ivar unity_proxy: The Autopilot proxy object for the Unity shell.
48+
49+ """
50+
51+ unity_proxy = None
52+ main_win = None
53+
54+ def setUp(self):
55+ """Restart Unity8 with testability and create sensors."""
56+ super().setUp()
57+ self.useFixture(
58+ fixture_setup.InitctlEnvironmentVariable(
59+ UBUNTU_PLATFORM_API_TEST_OVERRIDE='sensors'))
60+
61+ self.addCleanup(process_helpers.stop_job, 'unity8')
62+ restart_thread = threading.Thread(
63+ target=self._restart_unity_with_testability)
64+ restart_thread.start()
65+
66+ self._create_sensors()
67+
68+ restart_thread.join()
69+ self.fake_sensors = sensors.FakePlatformSensors()
70+
71+ def _get_lightdm_mock_path(self):
72+ lib_path = get_mocks_library_path()
73+ lightdm_mock_path = os.path.abspath(
74+ os.path.join(lib_path, "LightDM", "liblightdm")
75+ )
76+
77+ if not os.path.exists(lightdm_mock_path):
78+ raise RuntimeError(
79+ "LightDM mock does not exist at path {}.".
80+ format(lightdm_mock_path)
81+ )
82+ return lightdm_mock_path
83+
84+ def _get_qml_import_path_with_mock(self):
85+ """Return the QML2_IMPORT_PATH value with the mock path prepended."""
86+ qml_import_path = [get_mocks_library_path()]
87+ if os.getenv('QML2_IMPORT_PATH') is not None:
88+ qml_import_path.append(os.getenv('QML2_IMPORT_PATH'))
89+
90+ qml_import_path = ':'.join(qml_import_path)
91+ return qml_import_path
92+
93+ def _restart_unity_with_testability(self):
94+ _environment = {}
95+
96+ data_dirs = get_data_dirs(True)
97+ if data_dirs is not None:
98+ _environment['XDG_DATA_DIRS'] = data_dirs
99+
100+ _environment['QML2_IMPORT_PATH'] = (
101+ self._get_qml_import_path_with_mock()
102+ )
103+
104+ new_ld_library_path = [
105+ get_default_extra_mock_libraries(),
106+ self._get_lightdm_mock_path()
107+ ]
108+ if os.getenv('LD_LIBRARY_PATH') is not None:
109+ new_ld_library_path.append(os.getenv('LD_LIBRARY_PATH'))
110+ new_ld_library_path = ':'.join(new_ld_library_path)
111+ _environment['LD_LIBRARY_PATH'] = new_ld_library_path
112+
113+ # FIXME: we shouldn't be doing this
114+ # $MIR_SOCKET, fallback to $XDG_RUNTIME_DIR/mir_socket and
115+ # /tmp/mir_socket as last resort
116+ try:
117+ os.unlink(
118+ os.getenv('MIR_SOCKET',
119+ os.path.join(os.getenv('XDG_RUNTIME_DIR', "/tmp"),
120+ "mir_socket")))
121+ except OSError:
122+ pass
123+ try:
124+ os.unlink("/tmp/mir_socket")
125+ except OSError:
126+ pass
127+
128+ binary_arg = "BINARY=%s" % get_binary_path()
129+ env_args = ["%s=%s" % (k, v) for k, v in _environment.items()]
130+ args = [binary_arg] + env_args
131+ self.unity_proxy = process_helpers.restart_unity_with_testability(
132+ *args)
133+ self.main_win = self.unity_proxy.select_single(
134+ main_window_emulator.QQuickView)
135+
136+ def _create_sensors(self):
137+ # Wait for unity to start running.
138+ Eventually(Equals(True)).match(
139+ lambda: process_helpers.is_job_running('unity8'))
140+
141+ # Wait for the sensors fifo file to be created.
142+ fifo_path = '/tmp/sensor-fifo-{0}'.format(
143+ process_helpers.get_unity_pid())
144+ Eventually(Equals(True)).match(
145+ lambda: os.path.exists(fifo_path))
146+
147+ with open(fifo_path, 'w') as fifo:
148+ fifo.write('create accel 0 1000 0.1\n')
149+ fifo.write('create light 0 10 1\n')
150+ fifo.write('create proximity\n')
151
152 logger = logging.getLogger(__name__)
153
154@@ -188,7 +316,7 @@
155 self.ensure_not_running = ensure_not_running
156
157 def setUp(self):
158- super(LaunchMockIndicatorService, self).setUp()
159+ super().setUp()
160 if self.ensure_not_running:
161 self.ensure_service_not_running()
162 self.addCleanup(self.stop_service)
163
164=== modified file 'tests/autopilot/unity8/indicators/tests/test_display_indicator.py'
165--- tests/autopilot/unity8/indicators/tests/test_display_indicator.py 2015-03-20 11:31:40 +0000
166+++ tests/autopilot/unity8/indicators/tests/test_display_indicator.py 2015-05-13 11:15:59 +0000
167@@ -18,7 +18,7 @@
168
169 from unity8 import (
170 fixture_setup,
171- indicators,
172+ indicators
173 )
174 from unity8.indicators import tests
175
176
177=== modified file 'tests/autopilot/unity8/process_helpers.py'
178--- tests/autopilot/unity8/process_helpers.py 2015-04-28 15:20:13 +0000
179+++ tests/autopilot/unity8/process_helpers.py 2015-05-13 11:15:59 +0000
180@@ -58,7 +58,7 @@
181 """
182 if unity_proxy_obj is None:
183 try:
184- pid = _get_unity_pid()
185+ pid = get_unity_pid()
186 unity = _get_unity_proxy_object(pid)
187 main_window = unity.select_single(main_window_emulator.QQuickView)
188 except ProcessSearchError as e:
189@@ -108,7 +108,7 @@
190 """
191 if unity_proxy_obj is None:
192 try:
193- pid = _get_unity_pid()
194+ pid = get_unity_pid()
195 unity = _get_unity_proxy_object(pid)
196 main_window = unity.select_single(main_window_emulator.QQuickView)
197 except ProcessSearchError as e:
198@@ -262,7 +262,7 @@
199 raise CannotAccessUnity(str(error))
200
201
202-def _get_unity_pid():
203+def get_unity_pid():
204 try:
205 return get_job_pid('unity8')
206 except JobError as error:
207
208=== added file 'tests/autopilot/unity8/sensors.py'
209--- tests/autopilot/unity8/sensors.py 1970-01-01 00:00:00 +0000
210+++ tests/autopilot/unity8/sensors.py 2015-05-13 11:15:59 +0000
211@@ -0,0 +1,93 @@
212+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
213+#
214+# Unity Autopilot Test Suite
215+# Copyright (C) 2015 Canonical
216+#
217+# This program is free software: you can redistribute it and/or modify
218+# it under the terms of the GNU General Public License as published by
219+# the Free Software Foundation, either version 3 of the License, or
220+# (at your option) any later version.
221+#
222+# This program is distributed in the hope that it will be useful,
223+# but WITHOUT ANY WARRANTY; without even the implied warranty of
224+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
225+# GNU General Public License for more details.
226+#
227+# You should have received a copy of the GNU General Public License
228+# along with this program. If not, see <http://www.gnu.org/licenses/>.
229+#
230+
231+"""Control module for event injection to the fake/test platform sensors."""
232+
233+from unity8 import process_helpers
234+
235+
236+class FakePlatformSensors:
237+
238+ def __init__(self, pid=None):
239+ self.pid = pid or process_helpers.get_unity_pid()
240+
241+ def set_orientation(self, action):
242+ if action == 'top_up':
243+ with open("/tmp/sensor-fifo-{0}".format(self.pid), "w") as fifo:
244+ fifo.write("70 accel -10.050858 -0.598550 0.756568\n")
245+ fifo.write("70 accel -9.797073 -0.555455 1.019930\n")
246+ fifo.write("70 accel -10.141838 -0.770933 0.632069\n")
247+ fifo.write("70 accel -12.057199 -1.259350 1.690306\n")
248+ fifo.write("70 accel -19.282900 -3.926491 3.098097\n")
249+ fifo.write("70 accel -14.480132 -14.269443 1.216254\n")
250+ fifo.write("70 accel 16.419436 4.242526 -7.714118\n")
251+ fifo.write("70 accel 5.583278 8.279149 -1.848324\n")
252+ fifo.write("70 accel 1.422156 8.547300 0.416591\n")
253+ fifo.write("70 accel 4.357447 9.988609 -0.110133\n")
254+ fifo.write("70 accel 0.699107 9.840169 0.756568\n")
255+ fifo.write("70 accel 1.364695 9.844957 -0.287304\n")
256+ fifo.flush()
257+ elif action == 'top_down':
258+ with open("/tmp/sensor-fifo-{0}".format(self.pid), "w") as fifo:
259+ fifo.write("70 accel -10.050858 -0.598550 0.756568\n")
260+ fifo.write("70 accel 9.538500 -0.603339 1.292869\n")
261+ fifo.write("70 accel 9.485827 -0.636858 1.422156\n")
262+ fifo.write("70 accel 9.677363 -0.402226 1.374272\n")
263+ fifo.write("70 accel 9.303867 -0.507571 1.283292\n")
264+ fifo.write("70 accel 8.604761 -1.015141 1.436521\n")
265+ fifo.write("70 accel 7.580042 -2.001553 0.521936\n")
266+ fifo.write("70 accel 7.503428 -4.247314 0.502782\n")
267+ fifo.write("70 accel 7.067683 -7.240066 0.842759\n")
268+ fifo.write("70 accel 6.488286 -9.873688 -0.541090\n")
269+ fifo.write("70 accel 6.229713 -9.241618 -1.048660\n")
270+ fifo.write("70 accel 4.046201 -9.198523 -0.057461\n")
271+ fifo.write("70 accel 2.398990 -9.629479 0.957681\n")
272+ fifo.write("70 accel 1.632846 -9.361329 -0.311246\n")
273+ fifo.write("70 accel -0.181959 -9.696517 -0.301669\n")
274+ fifo.flush()
275+ elif action == 'left_up':
276+ with open("/tmp/sensor-fifo-{0}".format(self.pid), "w") as fifo:
277+ fifo.write("70 accel -10.050858 -0.598550 0.756568\n")
278+ fifo.write("70 accel 0.196325 9.878476 0.948104\n")
279+ fifo.write("70 accel 0.258574 9.955091 1.091756\n")
280+ fifo.write("70 accel 0.287304 10.041282 1.134852\n")
281+ fifo.write("70 accel 1.537078 10.553641 1.561020\n")
282+ fifo.write("70 accel 8.130709 10.093954 2.561796\n")
283+ fifo.write("70 accel -0.229843 5.348647 1.723825\n")
284+ fifo.write("70 accel -9.916783 0.488417 -3.418920\n")
285+ fifo.write("70 accel -13.417107 -0.416591 -2.360683\n")
286+ fifo.write("70 accel -13.872005 -2.049437 -0.574608\n")
287+ fifo.flush()
288+ elif action == 'right_up':
289+ with open("/tmp/sensor-fifo-{0}".format(self.pid), "w") as fifo:
290+ fifo.write("70 accel -10.050858 -0.598550 0.756568\n")
291+ fifo.write("70 accel -4.550858 -0.598550 0.856568\n")
292+ fifo.write("70 accel -0.799663 9.988609 1.197101\n")
293+ fifo.write("70 accel -0.861913 9.864111 1.066701\n")
294+ fifo.write("70 accel -0.861913 9.864111 0.866701\n")
295+ fifo.write("70 accel -1.776498 9.830592 1.273715\n")
296+ fifo.write("70 accel -2.376498 9.830592 1.273715\n")
297+ fifo.write("70 accel -13.158532 2.217031 1.091756\n")
298+ fifo.write("70 accel 5.056554 1.067814 0.799663\n")
299+ fifo.write("70 accel 5.056554 1.767814 0.799663\n")
300+ fifo.write("70 accel 14.882358 2.896984 1.221043\n")
301+ fifo.write("70 accel 9.466674 -0.363919 -1.029507\n")
302+ fifo.write("70 accel 11.253524 -0.186748 -0.311246\n")
303+ fifo.write("70 accel 12.253524 -0.186748 -0.311246\n")
304+ fifo.flush()
305
306=== modified file 'tests/autopilot/unity8/shell/emulators/main_window.py'
307--- tests/autopilot/unity8/shell/emulators/main_window.py 2015-04-28 15:20:13 +0000
308+++ tests/autopilot/unity8/shell/emulators/main_window.py 2015-05-13 11:15:59 +0000
309@@ -169,6 +169,18 @@
310 objectName='pinPadButton{}'.format(button_id)
311 )
312
313+ def get_shell_orientation_angle(self):
314+ return self._get_shell().orientationAngle
315+
316+ def get_shell_orientation(self):
317+ return self._get_shell().orientation
318+
319+ def get_shell_primary_orientation(self):
320+ return self._get_shell().primaryOrientation
321+
322+ def get_shell_native_orientation(self):
323+ return self._get_shell().nativeOrientation
324+
325 @autopilot_logging.log_action(logger.info)
326 def wait_for_notification(self):
327 """Wait for a notification dialog to appear.
328
329=== added file 'tests/autopilot/unity8/shell/tests/test_rotation.py'
330--- tests/autopilot/unity8/shell/tests/test_rotation.py 1970-01-01 00:00:00 +0000
331+++ tests/autopilot/unity8/shell/tests/test_rotation.py 2015-05-13 11:15:59 +0000
332@@ -0,0 +1,113 @@
333+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
334+#
335+# Unity Autopilot Test Suite
336+# Copyright (C) 2015 Canonical
337+#
338+# This program is free software: you can redistribute it and/or modify
339+# it under the terms of the GNU General Public License as published by
340+# the Free Software Foundation, either version 3 of the License, or
341+# (at your option) any later version.
342+#
343+# This program is distributed in the hope that it will be useful,
344+# but WITHOUT ANY WARRANTY; without even the implied warranty of
345+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
346+# GNU General Public License for more details.
347+#
348+# You should have received a copy of the GNU General Public License
349+# along with this program. If not, see <http://www.gnu.org/licenses/>.
350+#
351+
352+"""Tests for shell-rotation"""
353+
354+from autopilot.platform import model
355+from unity8 import (
356+ fixture_setup,
357+ process_helpers
358+)
359+from unity8.shell import tests
360+import logging
361+from testtools.matchers import Equals
362+from autopilot.matchers import Eventually
363+
364+logger = logging.getLogger(__name__)
365+
366+
367+class RotationBase(tests.UnityTestCase):
368+ """Base class for all shell-rotation tests that provides helper methods."""
369+
370+ def setUp(self):
371+ if model() == 'Desktop':
372+ self.skipTest('Test cannot be run on the desktop.')
373+ super().setUp()
374+ self._qml_mock_enabled = False
375+ self._data_dirs_mock_enabled = False
376+
377+ def _assert_change_of_orientation_and_angle(self):
378+ self.assertThat(self.shell_proxy.orientation,
379+ Eventually(Equals(self.orientation)))
380+ self.assertThat(self.shell_proxy.orientationAngle,
381+ Eventually(Equals(self.angle)))
382+
383+
384+class TestFakeSensor(RotationBase):
385+ scenarios = [('top up', {'action': 'top_up', 'orientation': 1}),
386+ ('right up', {'action': 'right_up', 'orientation': 8}),
387+ ('top down', {'action': 'top_down', 'orientation': 4}),
388+ ('left up', {'action': 'left_up', 'orientation': 2})]
389+
390+ def test_fake_sensor(self):
391+ unity_with_sensors = fixture_setup.LaunchUnityWithFakeSensors()
392+ self.useFixture(unity_with_sensors)
393+ process_helpers.unlock_unity(unity_with_sensors.unity_proxy)
394+ fake_sensors = unity_with_sensors.fake_sensors
395+ o_proxy = unity_with_sensors.main_win.select_single('OrientedShell')
396+
397+ fake_sensors.set_orientation(self.action)
398+ self.assertThat(o_proxy.physicalOrientation,
399+ Eventually(Equals(self.orientation), timeout=15))
400+
401+
402+class TestRotationWithApp(RotationBase):
403+ scenarios = [
404+ ('top up, angle 0',
405+ {'action': 'top_up', 'orientation': 1, 'angle': 0}),
406+ ('right up, angle 90',
407+ {'action': 'right_up', 'orientation': 8, 'angle': 90}),
408+ ('top down, angle 180',
409+ {'action': 'top_down', 'orientation': 4, 'angle': 180}),
410+ ('left up, angle 270',
411+ {'action': 'left_up', 'orientation': 2, 'angle': 270})]
412+
413+ def test_rotation_with_webbrowser_app(self):
414+ """Do an orientation-change and verify that an app and the shell
415+ adapted correctly"""
416+
417+ unity_with_sensors = fixture_setup.LaunchUnityWithFakeSensors()
418+ self.useFixture(unity_with_sensors)
419+ process_helpers.unlock_unity(unity_with_sensors.unity_proxy)
420+ fake_sensors = unity_with_sensors.fake_sensors
421+ o_proxy = unity_with_sensors.main_win.select_single('OrientedShell')
422+ self.shell_proxy = unity_with_sensors.main_win.select_single('Shell')
423+
424+ # launch an application
425+ self.launch_upstart_application('webbrowser-app')
426+ unity_with_sensors.main_win.show_dash_from_launcher()
427+ unity_with_sensors.main_win.launch_application('webbrowser-app')
428+
429+ # skip test early, if device doesn't support a certain orientation
430+ if not (self.shell_proxy.orientation & o_proxy.supportedOrientations):
431+ self.skipTest('unsupported orientation ' + self.action)
432+
433+ self.assertThat(
434+ unity_with_sensors.main_win.get_current_focused_app_id(),
435+ Eventually(Equals('webbrowser-app')))
436+
437+ # get default orientation and angle
438+ self.orientation = self.shell_proxy.orientation
439+ self.angle = self.shell_proxy.orientationAngle
440+
441+ # check if fake sensors affect orientation and angle
442+ fake_sensors.set_orientation(self.action)
443+ self.assertThat(o_proxy.physicalOrientation,
444+ Eventually(Equals(self.orientation), timeout=15))
445+ self._assert_change_of_orientation_and_angle()

Subscribers

People subscribed via source and target branches