1796
|
|
|
Daniel van Vugt |
12 years ago
|
|
|
1795
|
|
|
Andrea Azzarone |
12 years ago
|
|
|
1794
|
|
|
Alex Launi |
12 years ago
|
|
|
1793
|
|
|
Andrea Azzarone |
12 years ago
|
|
|
1792
|
|
|
Andrea Azzarone |
12 years ago
|
|
|
1791
|
|
|
Christopher James Ha... |
12 years ago
|
|
|
1790
|
|
|
Daniel van Vugt |
12 years ago
|
|
|
1789
|
|
|
Mirco Müller |
12 years ago
|
|
|
1788
|
|
|
Daniel van Vugt |
12 years ago
|
|
|
1787
|
|
|
Daniel van Vugt |
12 years ago
|
|
|
1786
|
|
|
Marco Trevisan (Trev... |
12 years ago
|
|
|
1785
|
|
|
Thomi Richards |
12 years ago
|
|
|
1784
|
|
|
Thomi Richards |
12 years ago
|
|
|
1783
|
|
|
Sam Spilsbury |
12 years ago
|
|
|
1782
|
|
|
Mirco Müller |
12 years ago
|
|
|
1781
|
|
|
Marco Trevisan (Trev... |
12 years ago
|
|
|
1780
|
|
|
Marco Trevisan (Trev... |
12 years ago
|
|
|
1779
|
|
|
Marco Trevisan (Trev... |
12 years ago
|
|
|
1778
|
|
|
Andrea Azzarone |
12 years ago
|
|
|
1777
|
|
This branch adds XPath-like query capabilities to the DBus debug interface. This allows autopilot tests to specify precise queries to retrieve only the part of the state tree they wish to inspect. We don't support the full XPath syntax (far from it!), a brief description of the syntax supported is given below:
== XPath Syntax ==
"", "/", and "/Unity" all select the root node of the tree. This is exactly the same as if you had not specified a piece name in the old code (so old autopilot tests will continue to work without change).
Absolute paths start with a forward-slash ("/") and may specify a full path to a node. For example, to get the SearchBar node, a test might specify: "/Unity/DashController/DashView/SearchBar".
Tests may also specify relative paths. For example, to get the SearchBar node, no matter where it is in the introspection tree, a test can use the query string "//SearchBar". Note that this can (and often does) return multiple results (for e.g.- a query of "//LauncherIcon" returns all the launcher icons in the introspection tree).
You can also specify children of a relative query, for example "//Launcher/LauncherIcon" returns all the LauncherIcon nodes that are direct children of the Launcher node - this may return different results to the query "//LauncherIcon" if LauncherIcon nodes are added to the introspection tree somewhere else.
Finally, you can restrict which items are returned by querying a node's properties. For example, to get all the launchers that are hidden, tests can use the query "//Launcher[hidden=True]". Just like previous examples, you can select child nodes this way as well: "//Launcher[hidden=true]/LauncherIcon" does what you'd expect. Currently you can inspect all string, boolean, and integer properties. CUrrently you cannot restrict based on more than one property at once: the following DOES NOT WORK: "//Launcher[hidden=True,otherproperty=foo]".
== Performance ==
I've run tests by querying the DBus interface with different queries and measuring the performance. See the following table:
Old method (current code): 24 mS (average) query = "" New method (proposed code): 22 mS (average) query = "" New method (proposed code): 21 mS (average) query = "/Unity" New method (proposed code): 2mS (average) query = "/Unity/DashController/DashView/SearchBar" *
New Method (proposed code): 2mS (average) query = "//SearchBar" * New Method (proposed code): 33mS (average) query = "//Launcher[hidden=True]" **
Notes: * This result indicates to me that most of the work is in actually sending data over DBus, rather than collecting & processing which nodes to send. ** property inspection is slow since the Introspectable::AddProperties method needs to be called twice - once to check if the property is there, and check it's value, and again when the actual introspection happens.
== Tests ==
There's a set of tests that ensure that the XPath stuff works as expected.
== Points of interest / controversial stuff ==
* I've had to change the scope of Introspectable::AddProperties so I can access an introspectable's properties. The alternatives to this are: 1) call Introspect() instead - this is too slow, since it introspects the object and all children, recursively. 2) use friend classes - this is just plain bad.
* I've kept all the code in DebugDBusInterface.cpp - there's an argument for moving the XPathQueryPart class into a separate file, but it's only ever going to be used here.
* This is my first serious code for unity, so I welcome any feedback you have, but be gentle!
. Fixes: . Appoved by Sam Spilsbury.
|
Thomi Richards |
12 years ago
|
|
|