Changes: Added functional tests for WM_CLASS

RevBy: Nimika Keshri
pull/1/head
Dmitry Rozenshtein 14 years ago committed by Alexey Shilov
parent 9280739c51
commit e8a7e61897

@ -19,6 +19,8 @@ usr/bin/fala_gettime_ms
usr/bin/fala_pixelchanged
usr/bin/fala_windowid
usr/bin/fala_focus
usr/bin/fala_windowless
usr/bin/fala_multi-window
usr/bin/xsendevent
usr/share/dbus-1/services/com.nokia.fala_testapp.service
usr/share/dbus-1/services/com.nokia.fala_wl.service

@ -90,3 +90,10 @@ add_subdirectory(common/testapps/xsendevent)
# Sub build: common/testapps/fala_qml_helloworld
add_subdirectory(common/testapps/fala_qml_helloworld)
# Sub build: common/testapps/fala_windowless
add_subdirectory(common/testapps/fala_windowless)
# Sub build: common/testapps/fala_multiwindow
add_subdirectory(common/testapps/fala_multiwindow)

@ -0,0 +1,43 @@
# Set sources
set(SRC main.cpp mainpage.cpp multiwindowcontent.cpp)
# Set moc headers
set(MOC_HDRS mainpage.h multiwindowcontent.h)
qt4_wrap_cpp(MOC_SRC ${MOC_HDRS})
link_libraries(${MEEGOTOUCH_LIBRARIES})
# Use the compiler and linker flags given in meegotouch-boostable.pc
# in the source tree.
execute_process(COMMAND "env"
"PKG_CONFIG_PATH=${CMAKE_SOURCE_DIR}/data/pkgconfig"
"/usr/bin/pkg-config"
"--cflags"
"meegotouch-boostable"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE booster_cxxflags
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND "env"
"PKG_CONFIG_PATH=${CMAKE_SOURCE_DIR}/data/pkgconfig"
"/usr/bin/pkg-config" "--libs"
"meegotouch-boostable"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE booster_libs
OUTPUT_STRIP_TRAILING_WHITESPACE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${booster_cxxflags}")
set(CMAKE_EXE_LINKER_FLAGS ${booster_libs})
# Enable Qt-support
include(${QT_USE_FILE})
# Enable Qt-support
include(${QT_USE_FILE})
set(NAME fala_multi-window)
add_executable(${NAME} ${SRC} ${MOC_SRC})
# Install
install(PROGRAMS ${NAME} DESTINATION /usr/bin)

@ -0,0 +1,12 @@
README
------
Multiwindow test application.
Command to launch application
invoker --type=m /usr/bin/fala_multi-window [-window-not-from-cache]
Application can be started with the switch "-output-level debug" to get information what happens inside it.

@ -0,0 +1,21 @@
TEMPLATE = app
TARGET = fala_multi-window
target.path = /usr/bin
OBJECTS_DIR = ./.obj
MOC_DIR = ./.moc
DEPENDPATH += $$INCLUDEPATH
CONFIG -= app_bundle
CONFIG += meegotouch-boostable
SOURCES += main.cpp \
mainpage.cpp \
multiwindowcontent.cpp
HEADERS += mainpage.h \
multiwindowcontent.h
# Install instructions
INSTALLS += target
DEFINES += HAVE_MCOMPONENTCACHE

@ -0,0 +1,63 @@
/***************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (directui@nokia.com)
**
** This file is part of applifed.
**
** If you have questions regarding the use of this file, please contact
** Nokia at directui@nokia.com.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation
** and appearing in the file LICENSE.LGPL included in the packaging
** of this file.
**
****************************************************************************/
#include "multiwindowcontent.h"
#include <QString>
#include <MApplication>
#ifdef HAVE_MCOMPONENTCACHE
#include <mcomponentcache.h>
#endif
M_EXPORT int main(int argc, char **argv)
{
#ifdef HAVE_MCOMPONENTCACHE
MApplication *app = MComponentCache::mApplication(argc, argv);
bool bWindowNotFromCache = false;
const QString sWindowNotFromCache = "window-not-from-cache";
for (int i = 1; i < argc; i++) {
QString sArg = QString(argv[i]);
if (sArg.contains(sWindowNotFromCache,Qt::CaseInsensitive)) {
bWindowNotFromCache = true;
break;
}
}
if (bWindowNotFromCache) {
MultiWindowContent mwContent(false);
mwContent.createWindows();
mwContent.activateWindow(1);
} else {
MultiWindowContent mwContent(true);
mwContent.createWindows();
mwContent.activateWindow(1);
}
#else
MApplication *app = new MApplication(argc, argv);
MultiWindowContent mwContent(false);
mwContent.createWindows();
mwContent.activateWindow(1);
#endif
return app->exec();
}

@ -0,0 +1,51 @@
/***************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (directui@nokia.com)
**
** This file is part of applifed.
**
** If you have questions regarding the use of this file, please contact
** Nokia at directui@nokia.com.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation
** and appearing in the file LICENSE.LGPL included in the packaging
** of this file.
**
****************************************************************************/
#include <MLayout>
#include <MLabel>
#include <MGridLayoutPolicy>
#include <MDebug>
#include "mainpage.h"
MainPage::MainPage(QString windowName) :
m_windowName(windowName)
{
setTitle(windowName);
m_layout = new MLayout(centralWidget());
m_policy = new MGridLayoutPolicy(m_layout);
m_policy->setSpacing(20.0);
m_label = new MLabel(m_windowName);
m_label->setAlignment(Qt::AlignCenter);
m_policy->addItem(m_label, 0, 0);
}
MainPage::~MainPage()
{
delete m_policy;
m_policy = NULL;
}
void MainPage::createContent()
{}

@ -0,0 +1,46 @@
/***************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (directui@nokia.com)
**
** This file is part of applifed.
**
** If you have questions regarding the use of this file, please contact
** Nokia at directui@nokia.com.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation
** and appearing in the file LICENSE.LGPL included in the packaging
** of this file.
**
****************************************************************************/
#ifndef MAINPAGE_H
#define MAINPAGE_H
#include <MApplicationPage>
#include <QString>
class MLabel;
class MLayout;
class MGridLayoutPolicy;
class MainPage : public MApplicationPage
{
Q_OBJECT
public:
MainPage(QString windowName);
virtual ~MainPage();
virtual void createContent();
private:
QString m_windowName;
MLabel * m_label;
MLayout * m_layout;
MGridLayoutPolicy * m_policy;
};
#endif // MAINPAGE_H

@ -0,0 +1,72 @@
/***************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (directui@nokia.com)
**
** This file is part of applifed.
**
** If you have questions regarding the use of this file, please contact
** Nokia at directui@nokia.com.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation
** and appearing in the file LICENSE.LGPL included in the packaging
** of this file.
**
****************************************************************************/
#include "multiwindowcontent.h"
#include "mainpage.h"
#include <MDebug>
#include <MApplicationWindow>
#ifdef HAVE_MCOMPONENTCACHE
#include <mcomponentcache.h>
#endif
MultiWindowContent::MultiWindowContent(bool windowFromCache):
m_windowFromCache(windowFromCache)
{
}
void MultiWindowContent::createWindows()
{
// Create windows
for (int i = 0; i < NUM_WINDOWS; i++) {
#ifdef HAVE_MCOMPONENTCACHE
m_window[i] = m_windowFromCache? MComponentCache::mApplicationWindow() : new MApplicationWindow;
#else
m_window[i] = new MApplicationWindow;
#endif
m_window[i]->setWindowTitle(QString("Window %1").arg(i + 1));
m_window[i]->setObjectName(QString("Window %1").arg(i + 1));
}
// Create pages
for (int i = 0; i < NUM_WINDOWS; i++)
m_mainPage[i] = new MainPage(QString("Window %1").arg(i + 1));
}
void MultiWindowContent::activateWindow(int index)
{
index--;
if (index >= 0 && index < NUM_WINDOWS) {
// Show the desired window
m_window[index]->show();
m_window[index]->activateWindow();
m_window[index]->raise();
m_mainPage[index]->appear(m_window[index]);
}
}
MultiWindowContent::~MultiWindowContent()
{
}

@ -0,0 +1,44 @@
/***************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (directui@nokia.com)
**
** This file is part of applifed.
**
** If you have questions regarding the use of this file, please contact
** Nokia at directui@nokia.com.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation
** and appearing in the file LICENSE.LGPL included in the packaging
** of this file.
**
****************************************************************************/
#ifndef MULTIWINDOWCONTENT_H
#define MULTIWINDOWCONTENT_H
#include <MApplicationWindow>
#include "mainpage.h"
class MultiWindowContent
{
public:
static const int NUM_WINDOWS = 3;
MultiWindowContent(bool windowFromCache);
virtual ~MultiWindowContent();
void activateWindow(int index);
void createWindows();
private:
MApplicationWindow *m_window[NUM_WINDOWS];
MainPage *m_mainPage[NUM_WINDOWS];
bool m_windowFromCache;
};
#endif // MULTIWINDOWCONTENT_H

@ -78,8 +78,25 @@ Q_DECL_EXPORT int main(int argc, char **argv)
QApplication *app = MDeclarativeCache::qApplication(argc, argv);
timestamp("QApplication from cache");
QDeclarativeView *window = MDeclarativeCache::qDeclarativeView();
QDeclarativeView *window = NULL;
bool bWindowNotFromCache = false;
const QString sWindowNotFromCache = "window-not-from-cache";
for (int i = 1; i < argc; i++) {
QString sArg = QString(argv[i]);
if (sArg.contains(sWindowNotFromCache,Qt::CaseInsensitive)) {
bWindowNotFromCache = true;
break;
}
}
if (bWindowNotFromCache) {
window = new QDeclarativeView();
timestamp("QDeclarativeView NOT from cache");
} else {
window = MDeclarativeCache::qDeclarativeView();
timestamp("QDeclarativeView from cache");
}
timestamp(QString("applicationDirPath: ").append(QApplication::applicationDirPath()));
timestamp(QString("applicationFilePath: ").append(QApplication::applicationFilePath()));

@ -68,7 +68,26 @@ M_EXPORT int main(int argc, char ** argv)
{
#ifdef HAVE_MCOMPONENTCACHE
MApplication *app = MComponentCache::mApplication(argc, argv);
MApplicationWindow *window = MComponentCache::mApplicationWindow();
MApplicationWindow *window = NULL;
bool bWindowNotFromCache = false;
const QString sWindowNotFromCache = "window-not-from-cache";
for (int i = 1; i < argc; i++) {
QString sArg = QString(argv[i]);
if (sArg.contains(sWindowNotFromCache,Qt::CaseInsensitive)) {
bWindowNotFromCache = true;
break;
}
}
if (bWindowNotFromCache) {
window = new MApplicationWindow();
timestamp("MApplicationWindow NOT from cache");
} else {
window = MComponentCache::mApplicationWindow();
timestamp("MApplicationWindow from cache");
}
#else
MApplication *app = new MApplication(argc, argv);
MApplicationWindow *window = new MApplicationWindow;

@ -30,6 +30,22 @@
<step expected_result="0">source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-daemons.py test_app_exits_clean</step>
</case>
<!--<case name="applauncherd__test_launched_app_wm_class_m" type="Functional" description="Test that launched application have correct WM_CLASS Xproperty booster m" timeout="460" level="System" insignificant="true">
<step expected_result="0">source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_launched_app_wm_class_m</step>
</case>-->
<case name="applauncherd__test_launched_app_wm_class_d" type="Functional" description="Test that launched application have correct WM_CLASS Xproperty booster d" timeout="460" level="System" insignificant="true">
<step expected_result="0">source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_launched_app_wm_class_d</step>
</case>
<case name="applauncherd__test_launched_app_wm_class_e" type="Functional" description="Test that launched application have correct WM_CLASS Xproperty booster e" timeout="460" level="System" insignificant="true">
<step expected_result="0">source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_launched_app_wm_class_e</step>
</case>
<case name="applauncherd__test_launched_app_wm_class_q" type="Functional" description="Test that launched application have correct WM_CLASS Xproperty booster q" timeout="460" level="System" insignificant="true">
<step expected_result="0">source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_launched_app_wm_class_q</step>
</case>
<environments>
<scratchbox>true</scratchbox>
<hardware>true</hardware>

@ -41,6 +41,7 @@ import time
import sys
import unittest
import re
import string
from subprocess import Popen
from utils import *
from os.path import basename
@ -836,6 +837,89 @@ class launcher_tests (unittest.TestCase):
self.assert_(SigIgn_wol == SigIgn_wl, "The SigIgn is not same for both apps")
self.assert_(SigCgt_wol == SigCgt_wl, "The SigCgt is not same for both apps")
def test_launched_app_wm_class_m(self):
"""
Test that launched application have correct WM_CLASS Xproperty booster m
"""
#For booster-m MApplicationWindow from MComponentCache
self._test_launched_app_wm_class_helper("m","fala_wl","-faulty","fala_wl",2)
#For booster-m MApplicationWindow NOT from cache. 3 windows (2 for application + 1 is created by cache but not used)
self._test_launched_app_wm_class_helper("m","fala_ft_hello","-window-not-from-cache","fala_ft_hello",3)
#For booster-m multiple MApplicationWindow (3 windows + 1)
self._test_launched_app_wm_class_helper("m","fala_multi-window","","fala_multi-window",4)
#For booster-m multiple MApplicationWindow NOT from cache (3 windows + 1 + 1 created by cache but not used)
self._test_launched_app_wm_class_helper("m","fala_multi-window","-window-not-from-cache","fala_multi-window",5)
def test_launched_app_wm_class_d(self):
"""
Test that launched application have correct WM_CLASS Xproperty booster d
"""
#For booster-d QDeclarativeView from MDeclarativeCache
self._test_launched_app_wm_class_helper("d","fala_qml_helloworld","-faulty","fala_qml_helloworld",2)
#For booster-d QDeclarativeView NOT from cache (2 windows + 1 is created by cache but not used)
self._test_launched_app_wm_class_helper("d","fala_qml_helloworld","-window-not-from-cache","fala_qml_helloworld",3)
def test_launched_app_wm_class_e(self):
"""
Test that launched application have correct WM_CLASS Xproperty booster e
"""
#For booster-e MApplicationWindow from MComponentCache
self._test_launched_app_wm_class_helper("e","fala_wl","-faulty","fala_wl",2)
#For booster-e MApplicationWindow NOT from cache
self._test_launched_app_wm_class_helper("e","fala_ft_hello","-window-not-from-cache","fala_ft_hello",2)
#For booster-e multiple MApplicationWindow (3 windows + 1)
self._test_launched_app_wm_class_helper("e","fala_multi-window","","fala_multi-window",4)
def test_launched_app_wm_class_q(self):
"""
Test that launched application have correct WM_CLASS Xproperty booster q
"""
#For booster-q MApplicationWindow from MComponentCache
self._test_launched_app_wm_class_helper("q","fala_wl","-faulty","fala_wl",2)
#For booster-q MApplicationWindow NOT from cache
self._test_launched_app_wm_class_helper("q","fala_ft_hello","-window-not-from-cache","fala_ft_hello",2)
#For booster-q multiple MApplicationWindow (3 windows + 1)
self._test_launched_app_wm_class_helper("q","fala_multi-window","","fala_multi-window",4)
def _test_launched_app_wm_class_helper(self,btype,test_application,cmd_arguments,window_name,window_count):
run_command = 'invoker --type=%s --no-wait %s %s' %(btype, test_application, cmd_arguments)
p = run_cmd_as_user(run_command)
time.sleep(5)
pid = get_pid(test_application)
self.assert_(pid != None, "Can't start application %s" %test_application)
st, op = commands.getstatusoutput("xwininfo -root -tree| awk '/%s/ {print $1}'" %window_name)
ids = op.split("\n")
xProperties=[]
for wid in ids:
st, op1 = commands.getstatusoutput("xprop -id %s | awk '/WM_CLASS/{print $3$4}'" %wid)
xProperties.append(op1)
kill_process(apppid=pid)
#check that we catch exac number of windows
numwind = len(ids)
self.assert_(window_count == numwind, 'Got wrong number of windows: %s' %numwind)
wm_class_xproperty_string = '"' + test_application + '","' + string.capwords(test_application) + '"'
debug("Looking for '%s'" %wm_class_xproperty_string)
for property in xProperties:
self.assert_(op1 == wm_class_xproperty_string,'Application WM_CLASS 1 is incorrect: %s' %property)
# main
if __name__ == '__main__':
# When run with testrunner, for some reason the PATH doesn't include

Loading…
Cancel
Save