summaryrefslogtreecommitdiff
diff options
authorChristopher Lee <chris.lee@canonical.com>2012-06-26 23:36:10 -0400
committerTarmac <>2012-06-26 23:36:10 -0400
commitb3c06003409e340d2b8cf2a6175f81dc1de55182 (patch)
treeb899ec201847d99c101f6112ac574b9bd34e4e69
parent210aeafa0374fe85b6ac18ec7527d93356d92358 (diff)
parentbb023c2f6aeb6960bb64d87d40955ee7cb1b16cb (diff)
Added introspection for HudButtons (hud query results). Fixes: . Approved by jenkins, Thomi Richards.
(bzr r2444)
-rw-r--r--hud/HudButton.cpp5
-rw-r--r--hud/HudView.cpp13
-rw-r--r--hud/HudView.h5
-rw-r--r--tests/autopilot/unity/emulators/hud.py20
4 files changed, 40 insertions, 3 deletions
diff --git a/hud/HudButton.cpp b/hud/HudButton.cpp
index 138407f30..64ae06dfa 100644
--- a/hud/HudButton.cpp
+++ b/hud/HudButton.cpp
@@ -105,7 +105,7 @@ void HudButton::RedrawTheme(nux::Geometry const& geom, cairo_t* cr, nux::ButtonV
bool HudButton::AcceptKeyNavFocus()
{
- // The button will not receive the keyboard focus. The keyboard focus is always to remain with the
+ // The button will not receive the keyboard focus. The keyboard focus is always to remain with the
// text entry in the hud.
return false;
}
@@ -209,7 +209,8 @@ std::string HudButton::GetName() const
void HudButton::AddProperties(GVariantBuilder* builder)
{
variant::BuilderWrapper(builder)
- .add("label", label());
+ .add("label", label())
+ .add("focused", fake_focused());
}
} // namespace hud
diff --git a/hud/HudView.cpp b/hud/HudView.cpp
index f2d425c4b..921c7713c 100644
--- a/hud/HudView.cpp
+++ b/hud/HudView.cpp
@@ -27,6 +27,8 @@
#include <Nux/HLayout.h>
#include <Nux/VLayout.h>
+#include "unity-shared/Introspectable.h"
+
#include "unity-shared/UBusMessages.h"
#include "unity-shared/DashStyle.h"
@@ -502,6 +504,17 @@ void View::AddProperties(GVariantBuilder* builder)
.add("num_buttons", num_buttons);
}
+debug::Introspectable::IntrospectableList const& View::GetIntrospectableChildren()
+{
+ introspectable_children_.clear();
+ for (auto button: buttons_)
+ {
+ introspectable_children_.push_front(button.GetPointer());
+ }
+
+ return introspectable_children_;
+}
+
bool View::InspectKeyEvent(unsigned int eventType,
unsigned int key_sym,
const char* character)
diff --git a/hud/HudView.h b/hud/HudView.h
index ca1e1a6f4..32a35a818 100644
--- a/hud/HudView.h
+++ b/hud/HudView.h
@@ -61,7 +61,7 @@ public:
void AboutToHide();
void SetWindowGeometry(nux::Geometry const& absolute_geo, nux::Geometry const& geo);
-
+
protected:
virtual Area* FindKeyFocusArea(unsigned int event_type,
unsigned long x11_key_code,
@@ -71,6 +71,8 @@ protected:
void OnSearchChanged(std::string const& search_string);
virtual long PostLayoutManagement(long LayoutResult);
+ IntrospectableList introspectable_children_;
+
private:
void OnMouseButtonDown(int x, int y, unsigned long button, unsigned long key);
void OnKeyDown (unsigned long event_type, unsigned long event_keysym,
@@ -87,6 +89,7 @@ private:
std::string GetName() const;
void AddProperties(GVariantBuilder* builder);
+ IntrospectableList const& GetIntrospectableChildren();
private:
UBusManager ubus;
diff --git a/tests/autopilot/unity/emulators/hud.py b/tests/autopilot/unity/emulators/hud.py
index e0c7d7656..cb73a5450 100644
--- a/tests/autopilot/unity/emulators/hud.py
+++ b/tests/autopilot/unity/emulators/hud.py
@@ -11,6 +11,8 @@ from __future__ import absolute_import
from autopilot.introspection.unity import UnityIntrospectionObject
from autopilot.keybindings import KeybindingsHelper
+from HTMLParser import HTMLParser
+import re
from unity.emulators.dash import SearchBar
from unity.emulators.icons import HudEmbeddedIcon, HudLauncherIcon
@@ -106,6 +108,11 @@ class Hud(KeybindingsHelper):
return 0
@property
+ def hud_buttons(self):
+ """Returns a list of current HUD buttons."""
+ return self.view.hud_buttons
+
+ @property
def num_buttons(self):
view = self.controller.get_hud_view()
if view:
@@ -123,6 +130,10 @@ class HudView(UnityIntrospectionObject):
return self.get_children_by_type(SearchBar)[0]
@property
+ def hud_buttons(self):
+ return self.get_children_by_type(HudButton)
+
+ @property
def geometry(self):
return (self.x, self.y, self.width, self.height)
@@ -133,3 +144,12 @@ class HudController(UnityIntrospectionObject):
def get_hud_view(self):
views = self.get_children_by_type(HudView)
return views[0] if views else None
+
+class HudButton(UnityIntrospectionObject):
+ """Proxy object for the hud buttons."""
+
+ @property
+ def label_no_formatting(self):
+ """Returns the label text with the formatting removed."""
+ htmlparser = HTMLParser()
+ return htmlparser.unescape(re.sub("<[^>]*>", "", self.label))