Merge lp:~townsend/unity/fix-xpathselect-sorting into lp:unity

Proposed by Christopher Townsend
Status: Merged
Approved by: Stephen M. Webb
Approved revision: no longer in the source branch.
Merged at revision: 3611
Proposed branch: lp:~townsend/unity/fix-xpathselect-sorting
Merge into: lp:unity
Diff against target: 114 lines (+20/-1)
6 files modified
launcher/AbstractLauncherIcon.h (+2/-0)
launcher/LauncherIcon.cpp (+7/-0)
launcher/LauncherIcon.h (+3/-0)
launcher/MockLauncherIcon.h (+3/-0)
launcher/SwitcherModel.cpp (+3/-0)
tests/autopilot/unity/emulators/switcher.py (+2/-1)
To merge this branch: bzr merge lp:~townsend/unity/fix-xpathselect-sorting
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Brandon Schaefer (community) Approve
Review via email: mp+198586@code.launchpad.net

Commit message

Due to a change in xpathselect1.4, this fixes a sorting issue of Switcher icons for AP tests.

Description of the change

= Issue =
XPathSelect1.4 now sorts introspection lists by it's id. For some of the Switcher AP tests, this broke some tests due to its assumption that lists will be preserved in the order they were created, but this is a bad assumption.

= Fix =
Add an order member variable the the LauncherIcon class so any derived classes that want to preserve the introspection order can do so. The AP Switcher emulator can now sort based on this order, so the icons will be in the order that are presented in the Switcher.

There are at least 8 tests that fail due to this. An example AP test that failed before is unity.tests.test_switcher.SwitcherTests.test_label_matches_application_name.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

LGTM

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Francis Ginther (fginther) wrote :

Autoland failed to a change in internal ssh keys. This has been fixed, re-approving.

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) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'launcher/AbstractLauncherIcon.h'
2--- launcher/AbstractLauncherIcon.h 2013-10-21 23:16:49 +0000
3+++ launcher/AbstractLauncherIcon.h 2013-12-11 15:22:59 +0000
4@@ -167,6 +167,8 @@
5
6 virtual int SortPriority() = 0;
7
8+ virtual void SetOrder(int order) = 0;
9+
10 virtual WindowList Windows() = 0;
11
12 virtual std::vector<Window> WindowsForMonitor(int monitor) = 0;
13
14=== modified file 'launcher/LauncherIcon.cpp'
15--- launcher/LauncherIcon.cpp 2013-11-27 20:36:01 +0000
16+++ launcher/LauncherIcon.cpp 2013-12-11 15:22:59 +0000
17@@ -71,6 +71,7 @@
18 , _present_urgency(0)
19 , _progress(0.0f)
20 , _sort_priority(DefaultPriority(type))
21+ , _order(0)
22 , _last_monitor(0)
23 , _background_color(nux::color::White)
24 , _glow_color(nux::color::White)
25@@ -176,6 +177,7 @@
26 .add("tooltip_text", tooltip_text())
27 .add("sort_priority", _sort_priority)
28 .add("shortcut", _shortcut)
29+ .add("order", _order)
30 .add("monitors_active", static_cast<GVariant*>(glib::Variant::FromVector(monitors_active)))
31 .add("monitors_visibility", static_cast<GVariant*>(glib::Variant::FromVector(monitors_visible)))
32 .add("monitors_urgent", static_cast<GVariant*>(glib::Variant::FromVector(monitors_urgent)))
33@@ -819,6 +821,11 @@
34 return _sort_priority;
35 }
36
37+void LauncherIcon::SetOrder(int order)
38+{
39+ _order = order;
40+}
41+
42 LauncherIcon::IconType
43 LauncherIcon::GetIconType() const
44 {
45
46=== modified file 'launcher/LauncherIcon.h'
47--- launcher/LauncherIcon.h 2013-11-14 00:17:19 +0000
48+++ launcher/LauncherIcon.h 2013-12-11 15:22:59 +0000
49@@ -94,6 +94,8 @@
50
51 int SortPriority();
52
53+ void SetOrder(int order);
54+
55 virtual WindowList Windows() { return WindowList(); }
56
57 virtual std::vector<Window> WindowsOnViewport() { return std::vector<Window> (); }
58@@ -326,6 +328,7 @@
59 float _present_urgency;
60 float _progress;
61 int _sort_priority;
62+ int _order;
63 int _last_monitor;
64 nux::Color _background_color;
65 nux::Color _glow_color;
66
67=== modified file 'launcher/MockLauncherIcon.h'
68--- launcher/MockLauncherIcon.h 2013-11-14 00:17:19 +0000
69+++ launcher/MockLauncherIcon.h 2013-12-11 15:22:59 +0000
70@@ -146,6 +146,8 @@
71
72 void SetSortPriority(int priority) { sort_priority_ = priority; }
73
74+ void SetOrder(int order) { order_ = order; }
75+
76 bool OpenQuicklist(bool select_first_item = false, int monitor = -1)
77 {
78 return false;
79@@ -417,6 +419,7 @@
80 nux::BaseTexture* icon_;
81 IconType type_;
82 int sort_priority_;
83+ int order_;
84 std::vector<std::bitset<std::size_t(Quirk::LAST)>> quirks_;
85 std::vector<std::vector<float>> quirk_progress_;
86 std::map<int, nux::Point3> center_;
87
88=== modified file 'launcher/SwitcherModel.cpp'
89--- launcher/SwitcherModel.cpp 2013-09-19 17:38:51 +0000
90+++ launcher/SwitcherModel.cpp 2013-12-11 15:22:59 +0000
91@@ -42,9 +42,12 @@
92 // When using Webapps, there are more than one active icon, so let's just pick
93 // up the first one found which is the web browser.
94 bool found = false;
95+ int order = 0;
96
97 for (auto const& application : applications_)
98 {
99+ application->SetOrder(++order);
100+
101 AddChild(application.GetPointer());
102 if (application->GetQuirk(AbstractLauncherIcon::Quirk::ACTIVE) && !found)
103 {
104
105=== modified file 'tests/autopilot/unity/emulators/switcher.py'
106--- tests/autopilot/unity/emulators/switcher.py 2013-09-27 17:31:37 +0000
107+++ tests/autopilot/unity/emulators/switcher.py 2013-12-11 15:22:59 +0000
108@@ -291,4 +291,5 @@
109
110 @property
111 def icons(self):
112- return self.get_children_by_type(SimpleLauncherIcon)
113+ icons = self.get_children_by_type(SimpleLauncherIcon)
114+ return sorted(icons, key=lambda icon: icon.order)