Changes: Added pixelchanged test application into package. Enabled

"application startup time from application grid" -test case

RevBy:Juha Lintula
pull/1/head
Olli Leppanen 15 years ago
parent 56b1716540
commit 077c2b3c54

@ -15,6 +15,7 @@ usr/bin/fala_wl.launch
usr/bin/fala_wol
usr/bin/fala_wol.sh
usr/bin/fala_gettime
usr/bin/fala_pixelchanged
usr/share/dbus-1/services/com.nokia.fala_testapp.service
usr/share/dbus-1/services/com.nokia.fala_wl.service
usr/share/dbus-1/services/com.nokia.fala_wol.service

2
debian/control vendored

@ -2,7 +2,7 @@ Source: applauncherd
Section: admin
Priority: important
Maintainer: Jussi Lind <jussi.lind@nokia.com>
Build-Depends: cmake (>= 2.6.0), debhelper (>= 7), libqt4-dev (>= 4.5.0), libmeegotouch-dev, libcreds2-dev [arm armel], aegis-builder (>= 1.4) [arm armel], libwrt-dev
Build-Depends: cmake (>= 2.6.0), debhelper (>= 7), libqt4-dev (>= 4.5.0), libmeegotouch-dev, libcreds2-dev [arm armel], aegis-builder (>= 1.4) [arm armel], libwrt-dev, libxtst-dev, libxext-dev
Standards-Version: 3.8.0
Package: applauncherd

@ -33,3 +33,6 @@ add_subdirectory(TestApps/fala_status)
# Sub build: TestApps
add_subdirectory(TestApps/fala_gettime)
# Sub build: TestApps
add_subdirectory(TestApps/pixelchanged)

@ -0,0 +1,13 @@
# Set sources
set(SRC main.c)
set(CMAKE_CXX_FLAGS "-O3")
# Link statically to minimize startup time.
set(CMAKE_EXE_LINKER_FLAGS "-lX11 -lXtst")
add_executable(fala_pixelchanged ${SRC})
# Install
install(PROGRAMS fala_pixelchanged DESTINATION /usr/bin/)

@ -0,0 +1,197 @@
/*
*XGetImage(Display *display, Drawable d, int x, int y, unsigned
int width, unsigned int height, unsigned long plane_mask, int
format);
*/
#include <X11/Xlib.h>
#include <X11/Xos.h>
#include <X11/Xfuncs.h>
#include <X11/Xutil.h>
#include <X11/keysym.h>
#include <X11/XKBlib.h>
#include <X11/Xproto.h>
#include <X11/extensions/XTest.h>
#include <X11/extensions/record.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <sys/time.h>
struct timeval prevstamp;
char output_filename[1024];
void timestamp(char *msg)
{
struct timeval tim;
FILE *output_file;
char txtbuffer[80];
gettimeofday(&tim, NULL);
snprintf(txtbuffer, 80, "%d%03d ms %s\n",
(int)tim.tv_sec, (int)tim.tv_usec/1000,
msg);
if (output_filename[0] == '\0') {
printf("%s", txtbuffer);
} else {
if (output_file = fopen(output_filename, "a+")) {
fprintf(output_file, "%s", txtbuffer);
fclose(output_file);
} else {
fprintf(stderr, "pixelchanged: cannot open file '%s' for appending\n", output_filename);
exit(2);
}
}
}
enum {
SCHEDULER_EVENT_NONE = 0,
SCHEDULER_EVENT_BUTTON,
SCHEDULER_EVENT_KEY,
SCHEDULER_EVENT_MOTION
};
XDevice* XPointerDevice = NULL;
/**
* Simulates user input event.
*
* @param dpy[in] the display connection.
* @param event[in] the event to simulate.
* @return
*/
void
scheduler_fake_event(Display* dpy, int event_type, int event_param1, int event_param2) {
static int xPos = 0;
static int yPos = 0;
switch (event_type) {
case SCHEDULER_EVENT_BUTTON: {
int axis[2] = {xPos, yPos};
XTestFakeDeviceButtonEvent(dpy, XPointerDevice, event_param1, event_param2, axis, 2, CurrentTime);
break;
}
case SCHEDULER_EVENT_KEY:
XTestFakeDeviceKeyEvent(dpy, XPointerDevice, event_param1, event_param2, NULL, 0, CurrentTime );
break;
case SCHEDULER_EVENT_MOTION:
xPos = event_param1;
yPos = event_param2;
{
int axis[2] = {xPos, yPos};
XTestFakeDeviceMotionEvent(dpy, XPointerDevice, False, 0, axis, 2, CurrentTime);
break;
}
}
}
/**
* 'Fakes' a mouse click, returning time sent.
*/
void
fake_event(Display *dpy, int x, int y)
{
if (XPointerDevice) {
scheduler_fake_event(dpy, SCHEDULER_EVENT_MOTION, x, y);
scheduler_fake_event(dpy, SCHEDULER_EVENT_BUTTON, Button1, True);
usleep(5000);
scheduler_fake_event(dpy, SCHEDULER_EVENT_BUTTON, Button1, False);
timestamp("Button1 released");
}
}
int main(int argc, char **argv) {
Display *dpy;
int screen = 0;
Window rootw;
XEvent event;
char *DISPLAY = NULL;
XDeviceInfo *devInfo;
char *deviceName;
char txtbuffer[80];
int click_x = -1;
int click_y = -1;
unsigned long pixel_value = 0;
int pixel_value_defined = False;
int pixel_x = 423; /* track pixel in the middle of dali display by default */
int pixel_y = 240;
int quit_when_found = 0;
int count = 0;
int i = 0;
int arg = 1;
output_filename[0] = '\0';
while (arg < argc) {
if (0 == strcmp("-c", argv[arg])) {
sscanf(argv[++arg], "%ux%u", &click_x, &click_y);
} else if (0 == strcmp("-p", argv[arg])) {
sscanf(argv[++arg], "%lx", &pixel_value);
pixel_value_defined = True;
} else if (0 == strcmp("-t", argv[arg])) { /* tracked pixel coordinates */
sscanf(argv[++arg], "%ux%u", &pixel_x, &pixel_y);
} else if (0 == strcmp("-f", argv[arg])) {
sscanf(argv[++arg], "%s", output_filename);
} else if (0 == strcmp("-q", argv[arg])) {
quit_when_found = 1;
}
++arg;
}
DISPLAY = (char*)getenv("DISPLAY");
if (DISPLAY == NULL) {
printf("Cannot open display. DISPLAY variable not set.\n", argv[0]);
exit(1);
}
dpy = XOpenDisplay(DISPLAY);
screen = XDefaultScreen(dpy);
rootw = RootWindow(dpy, screen);
/* find out where's the mouse */
/* open input device required for XTestFakeDeviceXXX functions */
if (!(devInfo = XListInputDevices(dpy, &count)) || !count) {
fprintf(stderr, "Cannot input list devices\n");
return 1;
}
for (i = 0; i < count; i++) {
if ( devInfo[i].use == IsXExtensionPointer) {
XPointerDevice = XOpenDevice(dpy, devInfo[i].id);
break;
}
}
XImage *image;
unsigned long pixel = 0;
unsigned long previous_pixel;
image = XGetImage(dpy, rootw, pixel_x, pixel_y, 1, 1, AllPlanes, ZPixmap);
previous_pixel = XGetPixel(image, 0, 0);
if (click_x > -1)
fake_event(dpy, click_x, click_y);
while (1) {
usleep(50000); /* sleep 50 ms */
image = XGetImage(dpy, rootw, pixel_x, pixel_y, 1, 1, AllPlanes, ZPixmap);
pixel = XGetPixel(image, 0, 0);
if (
(!pixel_value_defined && pixel != previous_pixel)
|| (pixel_value_defined && pixel == pixel_value) ) {
snprintf(txtbuffer, 80, "pixel changed to value 0x%lx", pixel);
timestamp(txtbuffer);
previous_pixel = pixel;
if (quit_when_found) return 0;
}
}
}

@ -65,17 +65,30 @@ int main(int argc, char **argv) {
#ifdef HAVE_MCOMPONENTCACHE
MApplication* app = MComponentCache::mApplication(argc, argv);
timestamp("app from cache");
MApplicationWindow* w = MComponentCache::mApplicationWindow();
timestamp("win from cache");
#else
MApplication* app = new MApplication(argc, argv);
timestamp("app created without cache");
MApplicationWindow* w = new MApplicationWindow;
timestamp("win created without cache");
#endif
MyApplicationPage p;
timestamp("page created");
MApplication::setPrestartMode(M::LazyShutdown);
p.setTitle("Applauncherd testapp");
w->show();
p.appear();
timestamp("page.appear() called");
w->show();
timestamp("w->show() called");
return app->exec();
}

@ -29,8 +29,9 @@ class TC_PerformanceTests < Test::Unit::TestCase
COUNT = 3
APP_WITH_LAUNCHER = 'fala_wl'
APP_WITHOUT_LAUNCHER = 'fala_wol'
PIXELCHANGED_BINARY= '/usr/bin/fala_pixelchanged'
TEST_SCRIPT_LOCATION = '/usr/share/applauncherd-testscripts'
PIXELCHANGED_LOG = '/tmp/pixelchanged.log'
PIXELCHANGED_LOG = '/tmp/fala_pixelchanged.log'
@start_time = 0
@end_time = 0
@pos = 0
@ -39,6 +40,8 @@ class TC_PerformanceTests < Test::Unit::TestCase
# method called before any test case
def setup
@sut = TDriver.sut(:Id=> 'sut_qt_maemo')
if $path.include?("scratchbox")
puts "Inside SB, Do Nothing to unlock"
else
@ -46,20 +49,25 @@ class TC_PerformanceTests < Test::Unit::TestCase
# restart duihome so that qttasserver notices it
# NOTE: Remove the cludge after duihome -> meegotouchhome renaming is complete
# if not system("/sbin/initctl restart xsession/duihome")
# system("/sbin/initctl restart xsession/mthome")
# end
if not system("/sbin/initctl restart xsession/duihome")
system("/sbin/initctl restart xsession/mthome")
end
system("initctl stop xsession/sysuid")
sleep (5)
end
@sut = TDriver.sut(:Id=> 'sut_qt_maemo')
system("initctl stop xsession/applifed")
end
end
# method called after any test case for cleanup purposes
def teardown
puts "exit from teardown"
system("initctl start xsession/sysuid")
system("initctl start xsession/applifed")
end
def open_Apps(appName)
@ -67,6 +75,13 @@ class TC_PerformanceTests < Test::Unit::TestCase
if FileTest.exists?(PIXELCHANGED_LOG)
system "rm #{PIXELCHANGED_LOG}"
end
appOnTop = @sut.application()
while appOnTop.attribute('objectName') != 'meegotouchhome'
fullName = appOnTop.attribute('FullName')
puts "Now killing #{fullName} from the top"
system "pkill #{fullName}"
appOnTop = @sut.application()
end
#Open the Application from the application grid
begin
@ -88,8 +103,8 @@ class TC_PerformanceTests < Test::Unit::TestCase
@pos = "#{xpos}x#{ypos}"
puts @pos
system "#{TEST_SCRIPT_LOCATION}/pixelchanged -c #{@pos} -f #{PIXELCHANGED_LOG} -q"
sleep (2)
system "#{PIXELCHANGED_BINARY} -c #{@pos} -f #{PIXELCHANGED_LOG} -q"
sleep (4)
system "pkill #{appName}"
else

@ -24,12 +24,12 @@
</get>
</set>
<!--set name="test-applicationGrid" description="applauncherd application startup time from application grid" feature="AF DUI Booster for Launcher daemon" requirement="300195">
<set name="test-applicationGrid" description="applauncherd application startup time from application grid" feature="AF DUI Booster for Launcher daemon" requirement="300195">
<pre_steps>
<step>/usr/bin/waitloadavg.rb -l 1.0 -p 1.0 -t 120</step>
</pre_steps>
<case name="Perf-Test" type="Performance" description="Measure launcher performance" timeout="360" level="System" insignificant="true">
<case name="Perf-Test" type="Performance" description="Measure startup time of the application using launcher" timeout="360" level="System" insignificant="true">
<step expected_result="0">source /tmp/session_bus_address.user; DISPLAY=:0 /usr/share/applauncherd-testscripts/test-perf.rb name test_performance &gt; /tmp/launcher_perf_new.txt</step>
</case>
<environments>
@ -40,7 +40,7 @@
<get>
<file>/tmp/launcher_perf_new.txt</file>
</get>
</set-->
</set>
</suite>
</testdefinition>

Loading…
Cancel
Save