diff --git a/debian/applauncherd-testapps.install b/debian/applauncherd-testapps.install index fd6d1b3..cd3a132 100644 --- a/debian/applauncherd-testapps.install +++ b/debian/applauncherd-testapps.install @@ -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 diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 3a61720..0550c62 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -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) + diff --git a/tests/common/testapps/fala_multiwindow/CMakeLists.txt b/tests/common/testapps/fala_multiwindow/CMakeLists.txt new file mode 100644 index 0000000..11e2c09 --- /dev/null +++ b/tests/common/testapps/fala_multiwindow/CMakeLists.txt @@ -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) + diff --git a/tests/common/testapps/fala_multiwindow/README b/tests/common/testapps/fala_multiwindow/README new file mode 100644 index 0000000..532bfd3 --- /dev/null +++ b/tests/common/testapps/fala_multiwindow/README @@ -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. + + diff --git a/tests/common/testapps/fala_multiwindow/fala_multiwindow.pro b/tests/common/testapps/fala_multiwindow/fala_multiwindow.pro new file mode 100644 index 0000000..a5fa84b --- /dev/null +++ b/tests/common/testapps/fala_multiwindow/fala_multiwindow.pro @@ -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 diff --git a/tests/common/testapps/fala_multiwindow/main.cpp b/tests/common/testapps/fala_multiwindow/main.cpp new file mode 100644 index 0000000..8e9bf66 --- /dev/null +++ b/tests/common/testapps/fala_multiwindow/main.cpp @@ -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 +#include + +#ifdef HAVE_MCOMPONENTCACHE +#include +#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(); +} diff --git a/tests/common/testapps/fala_multiwindow/mainpage.cpp b/tests/common/testapps/fala_multiwindow/mainpage.cpp new file mode 100644 index 0000000..82349e9 --- /dev/null +++ b/tests/common/testapps/fala_multiwindow/mainpage.cpp @@ -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 +#include +#include +#include + +#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() +{} + + diff --git a/tests/common/testapps/fala_multiwindow/mainpage.h b/tests/common/testapps/fala_multiwindow/mainpage.h new file mode 100644 index 0000000..5ec398a --- /dev/null +++ b/tests/common/testapps/fala_multiwindow/mainpage.h @@ -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 +#include + +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 diff --git a/tests/common/testapps/fala_multiwindow/multiwindowcontent.cpp b/tests/common/testapps/fala_multiwindow/multiwindowcontent.cpp new file mode 100644 index 0000000..d96a9f6 --- /dev/null +++ b/tests/common/testapps/fala_multiwindow/multiwindowcontent.cpp @@ -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 +#include + +#ifdef HAVE_MCOMPONENTCACHE +#include +#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() +{ +} + diff --git a/tests/common/testapps/fala_multiwindow/multiwindowcontent.h b/tests/common/testapps/fala_multiwindow/multiwindowcontent.h new file mode 100644 index 0000000..b42d101 --- /dev/null +++ b/tests/common/testapps/fala_multiwindow/multiwindowcontent.h @@ -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 + +#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 diff --git a/tests/common/testapps/fala_qml_helloworld/main.cpp b/tests/common/testapps/fala_qml_helloworld/main.cpp index 89cef91..3df6643 100644 --- a/tests/common/testapps/fala_qml_helloworld/main.cpp +++ b/tests/common/testapps/fala_qml_helloworld/main.cpp @@ -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(); - timestamp("QDeclarativeView from cache"); + 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())); diff --git a/tests/common/testapps/helloworld/helloworld.cpp b/tests/common/testapps/helloworld/helloworld.cpp index bbcef9f..74d1bc1 100644 --- a/tests/common/testapps/helloworld/helloworld.cpp +++ b/tests/common/testapps/helloworld/helloworld.cpp @@ -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; diff --git a/tests/harmattan/red-tests/tests.xml b/tests/harmattan/red-tests/tests.xml index 624cc57..3956a1e 100644 --- a/tests/harmattan/red-tests/tests.xml +++ b/tests/harmattan/red-tests/tests.xml @@ -30,6 +30,22 @@ source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-daemons.py test_app_exits_clean + + + + source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_launched_app_wm_class_d + + + + source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_launched_app_wm_class_e + + + + source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-func-launcher.py test_launched_app_wm_class_q + + true true diff --git a/tests/harmattan/testscripts/test-func-launcher.py b/tests/harmattan/testscripts/test-func-launcher.py index 621f0d6..0a36c5f 100644 --- a/tests/harmattan/testscripts/test-func-launcher.py +++ b/tests/harmattan/testscripts/test-func-launcher.py @@ -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