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
=== modified file 'tests/autopilot/unity8/fixture_setup.py'
--- tests/autopilot/unity8/fixture_setup.py 2015-05-05 14:46:49 +0000
+++ tests/autopilot/unity8/fixture_setup.py 2015-05-13 11:15:59 +0000
@@ -17,19 +17,147 @@
17# along with this program. If not, see <http://www.gnu.org/licenses/>.17# along with this program. If not, see <http://www.gnu.org/licenses/>.
18#18#
1919
20import os
21import subprocess
22import threading
20import fixtures23import fixtures
21import logging24import logging
22import os
23import subprocess
2425
25import ubuntuuitoolkit26import ubuntuuitoolkit
26from autopilot import introspection27from autopilot import introspection
28from autopilot.matchers import Eventually
29from testtools.matchers import Equals
30from ubuntuuitoolkit import fixture_setup
2731
28from unity8 import (32from unity8 import (
29 get_binary_path,33 get_binary_path,
34 sensors,
30 process_helpers35 process_helpers
31)36)
3237
38from unity8.shell import emulators
39
40from unity8.shell.emulators import (
41 main_window as main_window_emulator
42)
43
44from unity8 import (
45 get_mocks_library_path,
46 get_default_extra_mock_libraries,
47 get_data_dirs
48)
49
50logger = logging.getLogger(__name__)
51
52
53class LaunchUnityWithFakeSensors(fixtures.Fixture):
54
55 """Fixture to launch Unity8 with an injectable sensors backend.
56
57 :ivar unity_proxy: The Autopilot proxy object for the Unity shell.
58
59 """
60
61 unity_proxy = None
62 main_win = None
63
64 def setUp(self):
65 """Restart Unity8 with testability and create sensors."""
66 super().setUp()
67 self.useFixture(
68 fixture_setup.InitctlEnvironmentVariable(
69 UBUNTU_PLATFORM_API_TEST_OVERRIDE='sensors'))
70
71 self.addCleanup(process_helpers.stop_job, 'unity8')
72 restart_thread = threading.Thread(
73 target=self._restart_unity_with_testability)
74 restart_thread.start()
75
76 self._create_sensors()
77
78 restart_thread.join()
79 self.fake_sensors = sensors.FakePlatformSensors()
80
81 def _get_lightdm_mock_path(self):
82 lib_path = get_mocks_library_path()
83 lightdm_mock_path = os.path.abspath(
84 os.path.join(lib_path, "LightDM", "liblightdm")
85 )
86
87 if not os.path.exists(lightdm_mock_path):
88 raise RuntimeError(
89 "LightDM mock does not exist at path {}.".
90 format(lightdm_mock_path)
91 )
92 return lightdm_mock_path
93
94 def _get_qml_import_path_with_mock(self):
95 """Return the QML2_IMPORT_PATH value with the mock path prepended."""
96 qml_import_path = [get_mocks_library_path()]
97 if os.getenv('QML2_IMPORT_PATH') is not None:
98 qml_import_path.append(os.getenv('QML2_IMPORT_PATH'))
99
100 qml_import_path = ':'.join(qml_import_path)
101 return qml_import_path
102
103 def _restart_unity_with_testability(self):
104 _environment = {}
105
106 data_dirs = get_data_dirs(True)
107 if data_dirs is not None:
108 _environment['XDG_DATA_DIRS'] = data_dirs
109
110 _environment['QML2_IMPORT_PATH'] = (
111 self._get_qml_import_path_with_mock()
112 )
113
114 new_ld_library_path = [
115 get_default_extra_mock_libraries(),
116 self._get_lightdm_mock_path()
117 ]
118 if os.getenv('LD_LIBRARY_PATH') is not None:
119 new_ld_library_path.append(os.getenv('LD_LIBRARY_PATH'))
120 new_ld_library_path = ':'.join(new_ld_library_path)
121 _environment['LD_LIBRARY_PATH'] = new_ld_library_path
122
123 # FIXME: we shouldn't be doing this
124 # $MIR_SOCKET, fallback to $XDG_RUNTIME_DIR/mir_socket and
125 # /tmp/mir_socket as last resort
126 try:
127 os.unlink(
128 os.getenv('MIR_SOCKET',
129 os.path.join(os.getenv('XDG_RUNTIME_DIR', "/tmp"),
130 "mir_socket")))
131 except OSError:
132 pass
133 try:
134 os.unlink("/tmp/mir_socket")
135 except OSError:
136 pass
137
138 binary_arg = "BINARY=%s" % get_binary_path()
139 env_args = ["%s=%s" % (k, v) for k, v in _environment.items()]
140 args = [binary_arg] + env_args
141 self.unity_proxy = process_helpers.restart_unity_with_testability(
142 *args)
143 self.main_win = self.unity_proxy.select_single(
144 main_window_emulator.QQuickView)
145
146 def _create_sensors(self):
147 # Wait for unity to start running.
148 Eventually(Equals(True)).match(
149 lambda: process_helpers.is_job_running('unity8'))
150
151 # Wait for the sensors fifo file to be created.
152 fifo_path = '/tmp/sensor-fifo-{0}'.format(
153 process_helpers.get_unity_pid())
154 Eventually(Equals(True)).match(
155 lambda: os.path.exists(fifo_path))
156
157 with open(fifo_path, 'w') as fifo:
158 fifo.write('create accel 0 1000 0.1\n')
159 fifo.write('create light 0 10 1\n')
160 fifo.write('create proximity\n')
33161
34logger = logging.getLogger(__name__)162logger = logging.getLogger(__name__)
35163
@@ -188,7 +316,7 @@
188 self.ensure_not_running = ensure_not_running316 self.ensure_not_running = ensure_not_running
189317
190 def setUp(self):318 def setUp(self):
191 super(LaunchMockIndicatorService, self).setUp()319 super().setUp()
192 if self.ensure_not_running:320 if self.ensure_not_running:
193 self.ensure_service_not_running()321 self.ensure_service_not_running()
194 self.addCleanup(self.stop_service)322 self.addCleanup(self.stop_service)
195323
=== modified file 'tests/autopilot/unity8/indicators/tests/test_display_indicator.py'
--- tests/autopilot/unity8/indicators/tests/test_display_indicator.py 2015-03-20 11:31:40 +0000
+++ tests/autopilot/unity8/indicators/tests/test_display_indicator.py 2015-05-13 11:15:59 +0000
@@ -18,7 +18,7 @@
1818
19from unity8 import (19from unity8 import (
20 fixture_setup,20 fixture_setup,
21 indicators,21 indicators
22)22)
23from unity8.indicators import tests23from unity8.indicators import tests
2424
2525
=== modified file 'tests/autopilot/unity8/process_helpers.py'
--- tests/autopilot/unity8/process_helpers.py 2015-04-28 15:20:13 +0000
+++ tests/autopilot/unity8/process_helpers.py 2015-05-13 11:15:59 +0000
@@ -58,7 +58,7 @@
58 """58 """
59 if unity_proxy_obj is None:59 if unity_proxy_obj is None:
60 try:60 try:
61 pid = _get_unity_pid()61 pid = get_unity_pid()
62 unity = _get_unity_proxy_object(pid)62 unity = _get_unity_proxy_object(pid)
63 main_window = unity.select_single(main_window_emulator.QQuickView)63 main_window = unity.select_single(main_window_emulator.QQuickView)
64 except ProcessSearchError as e:64 except ProcessSearchError as e:
@@ -108,7 +108,7 @@
108 """108 """
109 if unity_proxy_obj is None:109 if unity_proxy_obj is None:
110 try:110 try:
111 pid = _get_unity_pid()111 pid = get_unity_pid()
112 unity = _get_unity_proxy_object(pid)112 unity = _get_unity_proxy_object(pid)
113 main_window = unity.select_single(main_window_emulator.QQuickView)113 main_window = unity.select_single(main_window_emulator.QQuickView)
114 except ProcessSearchError as e:114 except ProcessSearchError as e:
@@ -262,7 +262,7 @@
262 raise CannotAccessUnity(str(error))262 raise CannotAccessUnity(str(error))
263263
264264
265def _get_unity_pid():265def get_unity_pid():
266 try:266 try:
267 return get_job_pid('unity8')267 return get_job_pid('unity8')
268 except JobError as error:268 except JobError as error:
269269
=== added file 'tests/autopilot/unity8/sensors.py'
--- tests/autopilot/unity8/sensors.py 1970-01-01 00:00:00 +0000
+++ tests/autopilot/unity8/sensors.py 2015-05-13 11:15:59 +0000
@@ -0,0 +1,93 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2#
3# Unity Autopilot Test Suite
4# Copyright (C) 2015 Canonical
5#
6# This program is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation, either version 3 of the License, or
9# (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program. If not, see <http://www.gnu.org/licenses/>.
18#
19
20"""Control module for event injection to the fake/test platform sensors."""
21
22from unity8 import process_helpers
23
24
25class FakePlatformSensors:
26
27 def __init__(self, pid=None):
28 self.pid = pid or process_helpers.get_unity_pid()
29
30 def set_orientation(self, action):
31 if action == 'top_up':
32 with open("/tmp/sensor-fifo-{0}".format(self.pid), "w") as fifo:
33 fifo.write("70 accel -10.050858 -0.598550 0.756568\n")
34 fifo.write("70 accel -9.797073 -0.555455 1.019930\n")
35 fifo.write("70 accel -10.141838 -0.770933 0.632069\n")
36 fifo.write("70 accel -12.057199 -1.259350 1.690306\n")
37 fifo.write("70 accel -19.282900 -3.926491 3.098097\n")
38 fifo.write("70 accel -14.480132 -14.269443 1.216254\n")
39 fifo.write("70 accel 16.419436 4.242526 -7.714118\n")
40 fifo.write("70 accel 5.583278 8.279149 -1.848324\n")
41 fifo.write("70 accel 1.422156 8.547300 0.416591\n")
42 fifo.write("70 accel 4.357447 9.988609 -0.110133\n")
43 fifo.write("70 accel 0.699107 9.840169 0.756568\n")
44 fifo.write("70 accel 1.364695 9.844957 -0.287304\n")
45 fifo.flush()
46 elif action == 'top_down':
47 with open("/tmp/sensor-fifo-{0}".format(self.pid), "w") as fifo:
48 fifo.write("70 accel -10.050858 -0.598550 0.756568\n")
49 fifo.write("70 accel 9.538500 -0.603339 1.292869\n")
50 fifo.write("70 accel 9.485827 -0.636858 1.422156\n")
51 fifo.write("70 accel 9.677363 -0.402226 1.374272\n")
52 fifo.write("70 accel 9.303867 -0.507571 1.283292\n")
53 fifo.write("70 accel 8.604761 -1.015141 1.436521\n")
54 fifo.write("70 accel 7.580042 -2.001553 0.521936\n")
55 fifo.write("70 accel 7.503428 -4.247314 0.502782\n")
56 fifo.write("70 accel 7.067683 -7.240066 0.842759\n")
57 fifo.write("70 accel 6.488286 -9.873688 -0.541090\n")
58 fifo.write("70 accel 6.229713 -9.241618 -1.048660\n")
59 fifo.write("70 accel 4.046201 -9.198523 -0.057461\n")
60 fifo.write("70 accel 2.398990 -9.629479 0.957681\n")
61 fifo.write("70 accel 1.632846 -9.361329 -0.311246\n")
62 fifo.write("70 accel -0.181959 -9.696517 -0.301669\n")
63 fifo.flush()
64 elif action == 'left_up':
65 with open("/tmp/sensor-fifo-{0}".format(self.pid), "w") as fifo:
66 fifo.write("70 accel -10.050858 -0.598550 0.756568\n")
67 fifo.write("70 accel 0.196325 9.878476 0.948104\n")
68 fifo.write("70 accel 0.258574 9.955091 1.091756\n")
69 fifo.write("70 accel 0.287304 10.041282 1.134852\n")
70 fifo.write("70 accel 1.537078 10.553641 1.561020\n")
71 fifo.write("70 accel 8.130709 10.093954 2.561796\n")
72 fifo.write("70 accel -0.229843 5.348647 1.723825\n")
73 fifo.write("70 accel -9.916783 0.488417 -3.418920\n")
74 fifo.write("70 accel -13.417107 -0.416591 -2.360683\n")
75 fifo.write("70 accel -13.872005 -2.049437 -0.574608\n")
76 fifo.flush()
77 elif action == 'right_up':
78 with open("/tmp/sensor-fifo-{0}".format(self.pid), "w") as fifo:
79 fifo.write("70 accel -10.050858 -0.598550 0.756568\n")
80 fifo.write("70 accel -4.550858 -0.598550 0.856568\n")
81 fifo.write("70 accel -0.799663 9.988609 1.197101\n")
82 fifo.write("70 accel -0.861913 9.864111 1.066701\n")
83 fifo.write("70 accel -0.861913 9.864111 0.866701\n")
84 fifo.write("70 accel -1.776498 9.830592 1.273715\n")
85 fifo.write("70 accel -2.376498 9.830592 1.273715\n")
86 fifo.write("70 accel -13.158532 2.217031 1.091756\n")
87 fifo.write("70 accel 5.056554 1.067814 0.799663\n")
88 fifo.write("70 accel 5.056554 1.767814 0.799663\n")
89 fifo.write("70 accel 14.882358 2.896984 1.221043\n")
90 fifo.write("70 accel 9.466674 -0.363919 -1.029507\n")
91 fifo.write("70 accel 11.253524 -0.186748 -0.311246\n")
92 fifo.write("70 accel 12.253524 -0.186748 -0.311246\n")
93 fifo.flush()
094
=== modified file 'tests/autopilot/unity8/shell/emulators/main_window.py'
--- tests/autopilot/unity8/shell/emulators/main_window.py 2015-04-28 15:20:13 +0000
+++ tests/autopilot/unity8/shell/emulators/main_window.py 2015-05-13 11:15:59 +0000
@@ -169,6 +169,18 @@
169 objectName='pinPadButton{}'.format(button_id)169 objectName='pinPadButton{}'.format(button_id)
170 )170 )
171171
172 def get_shell_orientation_angle(self):
173 return self._get_shell().orientationAngle
174
175 def get_shell_orientation(self):
176 return self._get_shell().orientation
177
178 def get_shell_primary_orientation(self):
179 return self._get_shell().primaryOrientation
180
181 def get_shell_native_orientation(self):
182 return self._get_shell().nativeOrientation
183
172 @autopilot_logging.log_action(logger.info)184 @autopilot_logging.log_action(logger.info)
173 def wait_for_notification(self):185 def wait_for_notification(self):
174 """Wait for a notification dialog to appear.186 """Wait for a notification dialog to appear.
175187
=== added file 'tests/autopilot/unity8/shell/tests/test_rotation.py'
--- tests/autopilot/unity8/shell/tests/test_rotation.py 1970-01-01 00:00:00 +0000
+++ tests/autopilot/unity8/shell/tests/test_rotation.py 2015-05-13 11:15:59 +0000
@@ -0,0 +1,113 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2#
3# Unity Autopilot Test Suite
4# Copyright (C) 2015 Canonical
5#
6# This program is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation, either version 3 of the License, or
9# (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program. If not, see <http://www.gnu.org/licenses/>.
18#
19
20"""Tests for shell-rotation"""
21
22from autopilot.platform import model
23from unity8 import (
24 fixture_setup,
25 process_helpers
26)
27from unity8.shell import tests
28import logging
29from testtools.matchers import Equals
30from autopilot.matchers import Eventually
31
32logger = logging.getLogger(__name__)
33
34
35class RotationBase(tests.UnityTestCase):
36 """Base class for all shell-rotation tests that provides helper methods."""
37
38 def setUp(self):
39 if model() == 'Desktop':
40 self.skipTest('Test cannot be run on the desktop.')
41 super().setUp()
42 self._qml_mock_enabled = False
43 self._data_dirs_mock_enabled = False
44
45 def _assert_change_of_orientation_and_angle(self):
46 self.assertThat(self.shell_proxy.orientation,
47 Eventually(Equals(self.orientation)))
48 self.assertThat(self.shell_proxy.orientationAngle,
49 Eventually(Equals(self.angle)))
50
51
52class TestFakeSensor(RotationBase):
53 scenarios = [('top up', {'action': 'top_up', 'orientation': 1}),
54 ('right up', {'action': 'right_up', 'orientation': 8}),
55 ('top down', {'action': 'top_down', 'orientation': 4}),
56 ('left up', {'action': 'left_up', 'orientation': 2})]
57
58 def test_fake_sensor(self):
59 unity_with_sensors = fixture_setup.LaunchUnityWithFakeSensors()
60 self.useFixture(unity_with_sensors)
61 process_helpers.unlock_unity(unity_with_sensors.unity_proxy)
62 fake_sensors = unity_with_sensors.fake_sensors
63 o_proxy = unity_with_sensors.main_win.select_single('OrientedShell')
64
65 fake_sensors.set_orientation(self.action)
66 self.assertThat(o_proxy.physicalOrientation,
67 Eventually(Equals(self.orientation), timeout=15))
68
69
70class TestRotationWithApp(RotationBase):
71 scenarios = [
72 ('top up, angle 0',
73 {'action': 'top_up', 'orientation': 1, 'angle': 0}),
74 ('right up, angle 90',
75 {'action': 'right_up', 'orientation': 8, 'angle': 90}),
76 ('top down, angle 180',
77 {'action': 'top_down', 'orientation': 4, 'angle': 180}),
78 ('left up, angle 270',
79 {'action': 'left_up', 'orientation': 2, 'angle': 270})]
80
81 def test_rotation_with_webbrowser_app(self):
82 """Do an orientation-change and verify that an app and the shell
83 adapted correctly"""
84
85 unity_with_sensors = fixture_setup.LaunchUnityWithFakeSensors()
86 self.useFixture(unity_with_sensors)
87 process_helpers.unlock_unity(unity_with_sensors.unity_proxy)
88 fake_sensors = unity_with_sensors.fake_sensors
89 o_proxy = unity_with_sensors.main_win.select_single('OrientedShell')
90 self.shell_proxy = unity_with_sensors.main_win.select_single('Shell')
91
92 # launch an application
93 self.launch_upstart_application('webbrowser-app')
94 unity_with_sensors.main_win.show_dash_from_launcher()
95 unity_with_sensors.main_win.launch_application('webbrowser-app')
96
97 # skip test early, if device doesn't support a certain orientation
98 if not (self.shell_proxy.orientation & o_proxy.supportedOrientations):
99 self.skipTest('unsupported orientation ' + self.action)
100
101 self.assertThat(
102 unity_with_sensors.main_win.get_current_focused_app_id(),
103 Eventually(Equals('webbrowser-app')))
104
105 # get default orientation and angle
106 self.orientation = self.shell_proxy.orientation
107 self.angle = self.shell_proxy.orientationAngle
108
109 # check if fake sensors affect orientation and angle
110 fake_sensors.set_orientation(self.action)
111 self.assertThat(o_proxy.physicalOrientation,
112 Eventually(Equals(self.orientation), timeout=15))
113 self._assert_change_of_orientation_and_angle()

Subscribers

People subscribed via source and target branches