diff -Nru autopilot-gtk-1.3daily13.05.09ubuntu.unity.next/debian/changelog autopilot-gtk-1.3daily13.05.24ubuntu.unity.next/debian/changelog --- autopilot-gtk-1.3daily13.05.09ubuntu.unity.next/debian/changelog 2013-05-09 00:00:58.000000000 +0000 +++ autopilot-gtk-1.3daily13.05.24ubuntu.unity.next/debian/changelog 2013-05-24 00:01:41.000000000 +0000 @@ -1,3 +1,28 @@ +autopilot-gtk (1.3daily13.05.24ubuntu.unity.next-0ubuntu1) raring; urgency=low + + [ Thomi Richards ] + * This change fixes an issue with queries that look for gtk windows + matching a particular property value. A set of 2 tests has been + added to verify the queries that were otherwise failing with a void + return set. + + [ Allan LeSage ] + * This change fixes an issue with queries that look for gtk windows + matching a particular property value. A set of 2 tests has been + added to verify the queries that were otherwise failing with a void + return set. + + [ David Barth ] + * This change fixes an issue with queries that look for gtk windows + matching a particular property value. A set of 2 tests has been + added to verify the queries that were otherwise failing with a void + return set. + + [ Ubuntu daily release ] + * Automatic snapshot from revision 41 (ubuntu-unity/next) + + -- Ubuntu daily release Fri, 24 May 2013 00:01:41 +0000 + autopilot-gtk (1.3daily13.05.09ubuntu.unity.next-0ubuntu1) raring; urgency=low * Automatic snapshot from revision 39 (ubuntu-unity/next) diff -Nru autopilot-gtk-1.3daily13.05.09ubuntu.unity.next/lib/GtkNode.cpp autopilot-gtk-1.3daily13.05.24ubuntu.unity.next/lib/GtkNode.cpp --- autopilot-gtk-1.3daily13.05.09ubuntu.unity.next/lib/GtkNode.cpp 2013-05-09 00:00:43.000000000 +0000 +++ autopilot-gtk-1.3daily13.05.24ubuntu.unity.next/lib/GtkNode.cpp 2013-05-24 00:01:24.000000000 +0000 @@ -19,8 +19,8 @@ #include #include +#include -#include #include "GtkNode.h" #include "Variant.h" @@ -180,27 +180,51 @@ bool GtkNode::MatchProperty(const std::string& name, const std::string& value) const { - //g_debug("attempting to match a node's property"); - // yes we're transforming to strings and comparing there + + // g_debug("attempting to match a node's property"); + if (name == "id") { - // FIXME: b/c intptr_t makes casting tricky, or just cast to long? return value == std::to_string(GetObjectId()); + } else { GObjectClass* klass = G_OBJECT_GET_CLASS(object_); GParamSpec* pspec = g_object_class_find_property(klass, name.c_str()); - // if we found the property and it can be expressed as a string - if (pspec && g_value_type_transformable(pspec->value_type, - G_TYPE_STRING)) { + if (pspec == NULL) + return false; + + g_debug("Matching a property of type (%s).", g_type_name(G_PARAM_SPEC_VALUE_TYPE(pspec))); + + if (pspec && G_PARAM_SPEC_VALUE_TYPE(pspec) == G_TYPE_INT) { GValue dest_value = G_VALUE_INIT; - g_value_init(&dest_value, G_TYPE_STRING); + g_value_init(&dest_value, G_TYPE_INT); g_object_get_property(object_, name.c_str(), &dest_value); - const char* cstr = g_value_get_string(&dest_value); + + const gint cint = g_value_get_int(&dest_value); g_value_unset(&dest_value); - if (!cstr) - { + std::stringstream out; + out << cint; + std::string dest_string(out.str()); + return dest_string == value; + + } else if (pspec && G_PARAM_SPEC_VALUE_TYPE(pspec) == G_TYPE_DOUBLE) { + GValue dest_value = G_VALUE_INIT; + g_value_init(&dest_value, G_TYPE_DOUBLE); + g_object_get_property(object_, name.c_str(), &dest_value); + + const gdouble cdbl = g_value_get_double(&dest_value); + g_value_unset(&dest_value); + std::stringstream out; + out << cdbl; + std::string dest_string(out.str()); + return dest_string == value; + + } else if (pspec && G_PARAM_SPEC_VALUE_TYPE(pspec) == G_TYPE_STRING) { + gchar *strval = NULL; + g_object_get(object_, name.c_str(), &strval, NULL); + if (strval == NULL) return false; - } - std::string dest_string(cstr); + + std::string dest_string(strval); return dest_string == value; } return false; diff -Nru autopilot-gtk-1.3daily13.05.09ubuntu.unity.next/tests/autopilot/tests/test_matching_properties.py autopilot-gtk-1.3daily13.05.24ubuntu.unity.next/tests/autopilot/tests/test_matching_properties.py --- autopilot-gtk-1.3daily13.05.09ubuntu.unity.next/tests/autopilot/tests/test_matching_properties.py 1970-01-01 00:00:00.000000000 +0000 +++ autopilot-gtk-1.3daily13.05.24ubuntu.unity.next/tests/autopilot/tests/test_matching_properties.py 2013-05-24 00:01:24.000000000 +0000 @@ -0,0 +1,32 @@ + + +from autopilot.testcase import AutopilotTestCase +from testtools.matchers import NotEquals + + + +class PropertyMatchingTest(AutopilotTestCase): + + def setUp(self): + super(PropertyMatchingTest, self).setUp() + self.app = self.launch_test_application('gedit') + + def test_integer_matches(self): + """Test property matching for integers. + + Find an opaque GtkWindow in Gedit. + """ + + opaque_window = self.app.select_many('GtkWindow', opacity=1) + self.assertThat(opaque_window, NotEquals(None)) + + + def test_string_matches(self): + """Match a string property. + + Find an GtkImageMenuItem named 'BookmarkOpen' in Gedit. + """ + + bookmark_open_item = self.app.select_single('GtkImageMenuItem', + name='BookmarkOpen') + self.assertThat(bookmark_open_item, NotEquals(None)) diff -Nru autopilot-gtk-1.3daily13.05.09ubuntu.unity.next/tests/test-matching.sh autopilot-gtk-1.3daily13.05.24ubuntu.unity.next/tests/test-matching.sh --- autopilot-gtk-1.3daily13.05.09ubuntu.unity.next/tests/test-matching.sh 1970-01-01 00:00:00.000000000 +0000 +++ autopilot-gtk-1.3daily13.05.24ubuntu.unity.next/tests/test-matching.sh 2013-05-24 00:01:24.000000000 +0000 @@ -0,0 +1,25 @@ +#!/bin/bash +# + +# gedit --gtk-module `pwd`/lib/libautopilot.so & +# GEDIT_PID=$! +# sleep 2 + +EMPTY_SET='[Argument: a(sv) {}]' +RES=1 + +RET=`qdbus --literal org.gnome.gedit /com/canonical/Autopilot/Introspection com.canonical.Autopilot.Introspection.GetState '/Root//GtkWindow[opacity=1]'` +if [ "$RET" == "$EMPTY_SET" ]; then + echo "FAIL" + RES=0 +fi + +RET=`qdbus --literal org.gnome.gedit /com/canonical/Autopilot/Introspection com.canonical.Autopilot.Introspection.GetState '/Root//GtkWindow/GtkMenu/GtkImageMenuItem[name=BookmarkOpen]'` +if [ "$RET" == "$EMPTY_SET" ]; then + echo "FAIL" + RES=0 +fi + + +# kill $GEDIT_PID +exit $RES