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
=== modified file 'launcher/AbstractLauncherIcon.h'
--- launcher/AbstractLauncherIcon.h 2013-10-21 23:16:49 +0000
+++ launcher/AbstractLauncherIcon.h 2013-12-11 15:22:59 +0000
@@ -167,6 +167,8 @@
167167
168 virtual int SortPriority() = 0;168 virtual int SortPriority() = 0;
169169
170 virtual void SetOrder(int order) = 0;
171
170 virtual WindowList Windows() = 0;172 virtual WindowList Windows() = 0;
171173
172 virtual std::vector<Window> WindowsForMonitor(int monitor) = 0;174 virtual std::vector<Window> WindowsForMonitor(int monitor) = 0;
173175
=== modified file 'launcher/LauncherIcon.cpp'
--- launcher/LauncherIcon.cpp 2013-11-27 20:36:01 +0000
+++ launcher/LauncherIcon.cpp 2013-12-11 15:22:59 +0000
@@ -71,6 +71,7 @@
71 , _present_urgency(0)71 , _present_urgency(0)
72 , _progress(0.0f)72 , _progress(0.0f)
73 , _sort_priority(DefaultPriority(type))73 , _sort_priority(DefaultPriority(type))
74 , _order(0)
74 , _last_monitor(0)75 , _last_monitor(0)
75 , _background_color(nux::color::White)76 , _background_color(nux::color::White)
76 , _glow_color(nux::color::White)77 , _glow_color(nux::color::White)
@@ -176,6 +177,7 @@
176 .add("tooltip_text", tooltip_text())177 .add("tooltip_text", tooltip_text())
177 .add("sort_priority", _sort_priority)178 .add("sort_priority", _sort_priority)
178 .add("shortcut", _shortcut)179 .add("shortcut", _shortcut)
180 .add("order", _order)
179 .add("monitors_active", static_cast<GVariant*>(glib::Variant::FromVector(monitors_active)))181 .add("monitors_active", static_cast<GVariant*>(glib::Variant::FromVector(monitors_active)))
180 .add("monitors_visibility", static_cast<GVariant*>(glib::Variant::FromVector(monitors_visible)))182 .add("monitors_visibility", static_cast<GVariant*>(glib::Variant::FromVector(monitors_visible)))
181 .add("monitors_urgent", static_cast<GVariant*>(glib::Variant::FromVector(monitors_urgent)))183 .add("monitors_urgent", static_cast<GVariant*>(glib::Variant::FromVector(monitors_urgent)))
@@ -819,6 +821,11 @@
819 return _sort_priority;821 return _sort_priority;
820}822}
821823
824void LauncherIcon::SetOrder(int order)
825{
826 _order = order;
827}
828
822LauncherIcon::IconType829LauncherIcon::IconType
823LauncherIcon::GetIconType() const830LauncherIcon::GetIconType() const
824{831{
825832
=== modified file 'launcher/LauncherIcon.h'
--- launcher/LauncherIcon.h 2013-11-14 00:17:19 +0000
+++ launcher/LauncherIcon.h 2013-12-11 15:22:59 +0000
@@ -94,6 +94,8 @@
9494
95 int SortPriority();95 int SortPriority();
9696
97 void SetOrder(int order);
98
97 virtual WindowList Windows() { return WindowList(); }99 virtual WindowList Windows() { return WindowList(); }
98100
99 virtual std::vector<Window> WindowsOnViewport() { return std::vector<Window> (); }101 virtual std::vector<Window> WindowsOnViewport() { return std::vector<Window> (); }
@@ -326,6 +328,7 @@
326 float _present_urgency;328 float _present_urgency;
327 float _progress;329 float _progress;
328 int _sort_priority;330 int _sort_priority;
331 int _order;
329 int _last_monitor;332 int _last_monitor;
330 nux::Color _background_color;333 nux::Color _background_color;
331 nux::Color _glow_color;334 nux::Color _glow_color;
332335
=== modified file 'launcher/MockLauncherIcon.h'
--- launcher/MockLauncherIcon.h 2013-11-14 00:17:19 +0000
+++ launcher/MockLauncherIcon.h 2013-12-11 15:22:59 +0000
@@ -146,6 +146,8 @@
146146
147 void SetSortPriority(int priority) { sort_priority_ = priority; }147 void SetSortPriority(int priority) { sort_priority_ = priority; }
148148
149 void SetOrder(int order) { order_ = order; }
150
149 bool OpenQuicklist(bool select_first_item = false, int monitor = -1)151 bool OpenQuicklist(bool select_first_item = false, int monitor = -1)
150 {152 {
151 return false;153 return false;
@@ -417,6 +419,7 @@
417 nux::BaseTexture* icon_;419 nux::BaseTexture* icon_;
418 IconType type_;420 IconType type_;
419 int sort_priority_;421 int sort_priority_;
422 int order_;
420 std::vector<std::bitset<std::size_t(Quirk::LAST)>> quirks_;423 std::vector<std::bitset<std::size_t(Quirk::LAST)>> quirks_;
421 std::vector<std::vector<float>> quirk_progress_;424 std::vector<std::vector<float>> quirk_progress_;
422 std::map<int, nux::Point3> center_;425 std::map<int, nux::Point3> center_;
423426
=== modified file 'launcher/SwitcherModel.cpp'
--- launcher/SwitcherModel.cpp 2013-09-19 17:38:51 +0000
+++ launcher/SwitcherModel.cpp 2013-12-11 15:22:59 +0000
@@ -42,9 +42,12 @@
42 // When using Webapps, there are more than one active icon, so let's just pick42 // When using Webapps, there are more than one active icon, so let's just pick
43 // up the first one found which is the web browser.43 // up the first one found which is the web browser.
44 bool found = false;44 bool found = false;
45 int order = 0;
4546
46 for (auto const& application : applications_)47 for (auto const& application : applications_)
47 {48 {
49 application->SetOrder(++order);
50
48 AddChild(application.GetPointer());51 AddChild(application.GetPointer());
49 if (application->GetQuirk(AbstractLauncherIcon::Quirk::ACTIVE) && !found)52 if (application->GetQuirk(AbstractLauncherIcon::Quirk::ACTIVE) && !found)
50 {53 {
5154
=== modified file 'tests/autopilot/unity/emulators/switcher.py'
--- tests/autopilot/unity/emulators/switcher.py 2013-09-27 17:31:37 +0000
+++ tests/autopilot/unity/emulators/switcher.py 2013-12-11 15:22:59 +0000
@@ -291,4 +291,5 @@
291291
292 @property292 @property
293 def icons(self):293 def icons(self):
294 return self.get_children_by_type(SimpleLauncherIcon)294 icons = self.get_children_by_type(SimpleLauncherIcon)
295 return sorted(icons, key=lambda icon: icon.order)