Symbian 测试框架调研笔记

symbian没有合适的自动测试框架。不是java的东西就是麻烦。

摘自Nokia wiki, RWindow::Construct

Construct ( const RWindowTreeNode &, TUint32 )

IMPORT_C TInt Construct ( const RWindowTreeNode & parent,
TUint32 aHandle
)

Completes the construction of the window handle.

This method should be called after the RWindow() constructor, before any other functions are performed on the window. It creates a window in the window server corresponding to the RWindow object. The window is initialised to inherit the size and extent of its parent window, given by the first parameter. If its parent is a group window then it will be full screen.

This function always causes a flush of the window server buffer.

 

Parameter Description
parent The window’s parent.
aHandle Client handle for the window. This is an integer value chosen by the client that must be unique within the current server session. The usual way of doing this is to cast the address of the object that owns the window to a TUint32; this allows event handlers which are given a window handle to obtain a reference to the window an event is intended for. For example, CCoeControl uses this technique when it constructs a window. Note that in GUI applications, every window is created and owned by a control. Therefore it is rare for 3rd party code to ever need to call a window’s Construct() function directly.

Returns: KErrNone if successful, otherwise one of the system-wide error codes.

这里的解释很重要,The usual way of doing this is to cast the address of the object that owns the window to a TUint32; this allows event handlers which are given a window handle to obtain a reference to the window an event is intended for. For example, CCoeControl uses this technique when it constructs a window. Note that in GUI applications, every window is created and owned by a control. 也就是说,RWindow的handle可以立即强转为一个CCoeControl*,并且就是构造他的控件对象。

摘自Nokia wiki, RWindowTreeNode::ClientHandle()

ClientHandle ( )

IMPORT_C TUint32 ClientHandle ( ) const

Gets the window’s client handle

The return value is the client’s integer handle that was passed as an argument to the window’s Construct() function: see RWindow::Construct() for a description of the client handle.

This function always causes a flush of the window server buffer.

 

See also: RWindow::Construct()

Returns: Handle ID for the window.

也就是说,通过这个函数可以获取到对应的控件指针。

摘自Nokia wiki, RWindowTreeNode::Child()

Child ( )

IMPORT_C TUint32 Child ( ) const

Gets the first child of the node.

This function always causes a flush of the window server buffer.

 

Returns: The client handle of the child node that currently has ordinal position 0. This is 0 if there isn’t a child.

获取TreeNode的孩子节点。使用NextSibling继续向下遍历。

注意到RWindowGroup也是继承自RWindowTreeNode的。一个测试思路就是,获取到当前WindowGroup,然后遍历整棵树,获取每个节点对应的CCoeControl。暂时不知道Symbian系统上能不能做Dynamic Cast。理论上来说配合RTTI可以了解到每个节点的类型,并对特定的类型调用特定的方法进一步处理。不过跨进程做这种事情恐怕还是有问题。不知能不能把测试程序作为一个dll植入被测程序去运行。这就可以实现Android上Hierarchy Viewer的功能了。

简单记录以作备忘。哪位兄弟知道成熟的symbian测试框架也请不吝赐教。