GUI Inspection from Source Code Analysis João Carlos Silva 1,2 João Saraiva 1 José Creissac 1 1 Departamento de Informática/CCTC Universidade do Minho 2 Departamento de Tecnologia Instituto Politécnico do Cávado e do Ave Portugal Fourth International Workshop on Foundations and Techniques for Open Source Software Certification (OpenCert 2010) Setember 17-18, 2010
GUI Model-based Analysis Models guide the development process Models help in the maintenance and evolution of software Objectives: Static analysis of interactive applications from source code Usability and implementation quality GUI maintenance and evolution Approach: Extraction of GUI layer (event-based toolkits) Automatic extraction of behavioral models
Paper Goal Motivation On going work: Models extraction from source code GUI behavior representation Integration of testing techniques Language-independent tool
The GUISurfer Architecture Language dependent Parser/Grammar Language independent Source code GUI Business Data Abstract Syntax Tree Code slicing GUI Layer GUI Reasoning GUI Maintenance GUI Evolution Usability Implementation Quality
Reverse Engineering of GUI source code Generic approach easily re-targetable: Look for widgets: user input, user selection, user action, output to user Traversal of the AST to detect GUI subtrees Based on program dependency graph Pre-defined set of generic traversal functions GUI components constructors
GUISurfer - Configurable tools GUISurfer is composed by three tools: FileParser: Parse a particular source code file. Generate the abstract syntax tree AstAnalyser: Slice an abstract syntax tree. Entry point and list of widgets as parameters Graph: Generates several metadata files and models with events, conditions, actions and states (Set of fragments of the AST)
An Interactive Agenda - Java/Swing - WxHaskell
Flow Between Windows
Window Internal Behavior Windows behavior: Login window MainForm Window Find window ContactEditor Window
Graph Theory Applied to State Machine Reasonning States machines as graphs: States are vertices, events are edges Refactoring: We can compute an equivalent machine with the minimum number of states Dead code elimination: Detect if all states are reachable from the initial one Test case generation: Chinese Postman algorithm checking every event through properties Traveling salesman checking every state through properties Center of a graph: main window at a central point
Graph Operators: Intersection, Union and Difference Intersection of two different versions
GUI Metrics Motivation Use of Graph-Tool for the manipulation and statistical analysis of graphs; Shortest distance between vertices; Pagerank; Betweeness; Cyclomatic complexity;
Pagerank Algorithm
Betweenness Algorithm 0.102564102564 0.121794871795 1.01.0 16.8241758242 18.8021978022 14.8461538462 0.0448717948718 5.61538461538 5.61538461538 1.65934065934 0.108974358974 0.0833333333333 20.7802197802 25.3956043956 12.2087912088 1.65934065934 0.166666666667 0.455128205128 5.61538461538 5.61538461538 1.01.01.01.0 12.2087912088 17.4835164835 0.0448717948718 1.01.01.0 0.0 9.57142857143 0.0769230769231 24.7362637363 8.91208791209 1.0 2.31868131868 15.5054945055 0.0 0.128205128205 0.173076923077 0.0 20.7802197802
GUI Test Cases Generation Coverage criteria: event coverage: set of event-sequences considering all possible events; state coverage: each state reached at least once; length-n-event-sequence coverage: set of event-sequences which contains all event-sequences of length equal to n; Chinese Postman Tour; Travelling Salesman Problem;
Case Study Motivation Java/Swing application: Healthcare management system source code from Planet-Source-Code.com 66 classes; 29 windows forms (included message box); patients and doctors management; bills of patients display;
Windows Form Example: Add Patient
Case Study: Results...
Use of QuickCheck: a haskell library tool for testing haskell programs automatically. haskell specification of the GUI Properties definition QuickCheck tests the properties in a large number of randomly generated cases GUISurfer back-end extension: generalizing the approach to new languages and toolkits (GWT, JavaScript)
Conclusions and Future Work Able to derive user interface models of interactive computing system Support for Java, WxHaskell and GWT available Plan to extend our implementation to handle more complex user interfaces Development of a web portal
GUI Inspection from Source Code Analysis João Carlos Silva 1,2 João Saraiva 1 José Creissac 1 1 Departamento de Informática/CCTC Universidade do Minho 2 Departamento de Tecnologia Instituto Politécnico do Cávado e do Ave Portugal Fourth International Workshop on Foundations and Techniques for Open Source Software Certification (OpenCert 2010) Setember 17-18, 2010