Changes: Test for QApplication::applicationFilePath and applicationDirPath

RevBy: Pertti Kellomaki
pull/1/head
Nimika Keshri 15 years ago committed by Pertti Kellomäki
parent 9cda284174
commit b7c2db010f

1
debian/changelog vendored

@ -1,5 +1,6 @@
applauncherd (0.30.1) unstable; urgency=low applauncherd (0.30.1) unstable; urgency=low
* Changes: Add test for QApplication::applicationFilePath and applicationDirPath
* Fixes: NB#257654 - QApplication::applicationDirPath() and QApplication::applicationFilePath() return wrong values for d-boosted applications * Fixes: NB#257654 - QApplication::applicationDirPath() and QApplication::applicationFilePath() return wrong values for d-boosted applications
* Changes: New functional tests added to check testability library is loaded by booster-m and booster-d * Changes: New functional tests added to check testability library is loaded by booster-m and booster-d
* Changes: Deprecate MDeclarativeCache::applicationDirPath() and MDeclarativeCache::applicationFilePath(). * Changes: Deprecate MDeclarativeCache::applicationDirPath() and MDeclarativeCache::applicationFilePath().

@ -32,7 +32,9 @@ add_executable(fala_qml ${SRC})
install(PROGRAMS fala_qml DESTINATION /usr/bin/ RENAME fala_qml_wol) install(PROGRAMS fala_qml DESTINATION /usr/bin/ RENAME fala_qml_wol)
install(PROGRAMS fala_qml DESTINATION /usr/bin/ RENAME fala_qml_helloworld) install(PROGRAMS fala_qml DESTINATION /usr/bin/ RENAME fala_qml_helloworld)
install(PROGRAMS fala_qml DESTINATION /usr/bin/ RENAME fala_qml_wl) install(PROGRAMS fala_qml DESTINATION /usr/bin/ RENAME fala_qml_wl)
install(PROGRAMS fala_qml DESTINATION /usr/share/fala_images RENAME fala_qml_helloworld)
install(FILES main.qml DESTINATION /usr/share/fala_qml_helloworld) install(FILES main.qml DESTINATION /usr/share/fala_qml_helloworld)
install(FILES main.qml DESTINATION /usr/share/fala_images)
install(FILES fala_qml_wl.desktop DESTINATION /usr/share/applications) install(FILES fala_qml_wl.desktop DESTINATION /usr/share/applications)
install(FILES fala_qml_wol.desktop DESTINATION /usr/share/applications) install(FILES fala_qml_wol.desktop DESTINATION /usr/share/applications)
install(SCRIPT scripts/create_links.cmake) install(SCRIPT scripts/create_links.cmake)

@ -61,7 +61,16 @@ Q_DECL_EXPORT int main(int argc, char **argv)
QDeclarativeView *window = MDeclarativeCache::qDeclarativeView(); QDeclarativeView *window = MDeclarativeCache::qDeclarativeView();
timestamp("QDeclarativeView from cache"); timestamp("QDeclarativeView from cache");
QString d_path, f_path;
d_path = QString("applicationDirPath: ").append(QApplication::applicationDirPath());
const char * path_d = d_path.toStdString().c_str();
timestamp(path_d);
f_path = QString("applicationFilePath: ").append(QApplication::applicationFilePath());
const char * path_f = f_path.toStdString().c_str();
timestamp(path_f);
window->setWindowTitle("Applauncherd QML testapp"); window->setWindowTitle("Applauncherd QML testapp");
window->setResizeMode(QDeclarativeView::SizeRootObjectToView); window->setResizeMode(QDeclarativeView::SizeRootObjectToView);

@ -28,5 +28,6 @@ set(CMAKE_EXE_LINKER_FLAGS ${booster_libs})
add_executable(fala_hello ${SRC}) add_executable(fala_hello ${SRC})
install(PROGRAMS fala_hello DESTINATION /usr/bin/ RENAME fala_ft_hello) install(PROGRAMS fala_hello DESTINATION /usr/bin/ RENAME fala_ft_hello)
install(PROGRAMS fala_hello DESTINATION /usr/share/fala_images)
install(SCRIPT scripts/create_links.cmake) install(SCRIPT scripts/create_links.cmake)

@ -24,14 +24,38 @@
#include <MExport> #include <MExport>
#include <MButton> #include <MButton>
#include <MLabel> #include <MLabel>
#include <QString>
#include <MSlider> #include <MSlider>
#include <MLayout> #include <MLayout>
#include <MLinearLayoutPolicy> #include <MLinearLayoutPolicy>
#include <QFile>
#include <sys/time.h>
#ifdef HAVE_MCOMPONENTCACHE #ifdef HAVE_MCOMPONENTCACHE
#include <mcomponentcache.h> #include <mcomponentcache.h>
#endif #endif
QString log_file = "/tmp/fala_hello.log";
void FANGORNLOG(const char *s)
{
QFile f(log_file);
f.open(QIODevice::Append);
f.write(s, qstrlen(s));
f.write("\n", 1);
f.close();
}
void timestamp(const char *s)
{
timeval tim;
char msg[80];
gettimeofday(&tim, NULL);
snprintf(msg, 80, "%d%03d %s",
static_cast<int>(tim.tv_sec), static_cast<int>(tim.tv_usec)/1000, s);
FANGORNLOG(msg);
}
M_EXPORT int main(int argc, char ** argv) M_EXPORT int main(int argc, char ** argv)
{ {
#ifdef HAVE_MCOMPONENTCACHE #ifdef HAVE_MCOMPONENTCACHE
@ -42,6 +66,14 @@ M_EXPORT int main(int argc, char ** argv)
MApplicationWindow *window = new MApplicationWindow; MApplicationWindow *window = new MApplicationWindow;
#endif #endif
QString d_path, f_path;
d_path = QString("applicationDirPath: ").append(QApplication::applicationDirPath());
const char * path_d = d_path.toStdString().c_str();
timestamp(path_d);
f_path = QString("applicationFilePath: ").append(QApplication::applicationFilePath());
const char * path_f = f_path.toStdString().c_str();
timestamp(path_f);
MApplicationPage *mainPage = new MApplicationPage; MApplicationPage *mainPage = new MApplicationPage;
mainPage->setTitle("Hello World! (Now supports Launcher)"); mainPage->setTitle("Hello World! (Now supports Launcher)");
mainPage->centralWidget()->setObjectName("centralWidget"); mainPage->centralWidget()->setObjectName("centralWidget");

@ -104,7 +104,19 @@
<case name="applauncherd__test_single_instance_window_raise_with_script" type="Functional" description="Test basic single instance functionality and window raising using script" timeout="360" level="System" insignificant="true"> <case name="applauncherd__test_single_instance_window_raise_with_script" type="Functional" description="Test basic single instance functionality and window raising using script" timeout="360" level="System" insignificant="true">
<step expected_result="0">source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-single-instance.py test_single_instance_window_raise_with_script</step> <step expected_result="0">source /tmp/session_bus_address.user; DISPLAY=:0 `pyversions -d` /usr/share/applauncherd-testscripts/test-single-instance.py test_single_instance_window_raise_with_script</step>
</case> </case>
<case name="applauncherd__test_dirPath_filePath_m" type="Functional" description="Test that correct file path and dir path is passed by booster m" timeout="360" 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_dirPath_filePath_m</step>
</case>
<case name="applauncherd__test_dirPath_filePath_d" type="Functional" description="Test that correct file path and dir path is passed by booster d" timeout="360" 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_dirPath_filePath_d</step>
</case>
<case name="applauncherd__test_dirPath_filePath_q" type="Functional" description="Test that correct file path and dir path is passed by booster q" timeout="360" 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_dirPath_filePath_q</step>
</case>
<case name="applauncherd__test_dirPath_filePath_e" type="Functional" description="Test that correct file path and dir path is passed by booster e" timeout="360" 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_dirPath_filePath_e</step>
</case>
<environments> <environments>
<scratchbox>true</scratchbox> <scratchbox>true</scratchbox>
<hardware>true</hardware> <hardware>true</hardware>

@ -1086,6 +1086,37 @@ class launcher_tests (unittest.TestCase):
time.sleep(2) time.sleep(2)
def test_dirPath_filePath_m(self):
self._test_dirPath_filePath('m', "/usr/share/fala_images", "fala_hello")
def test_dirPath_filePath_d(self):
self._test_dirPath_filePath('d', "/usr/share/fala_images", "fala_qml_helloworld")
def test_dirPath_filePath_q(self):
self._test_dirPath_filePath('q', "/usr/share/fala_images", "fala_hello")
def test_dirPath_filePath_e(self):
self._test_dirPath_filePath('e')
def _test_dirPath_filePath(self, btype, path, testapp):
"""
Test that correct file path and dir path is passed
"""
if os.path.isfile("/tmp/%s.log" % testapp):
os.system("rm /tmp/%s.log" % testapp)
if get_pid(testapp)!= None:
kill_process(testapp)
p = run_cmd_as_user('invoker --type=%s %s/%s' % (btype, path, testapp))
time.sleep(4)
pid = get_pid(testapp)
self.assert_(pid != None, "The application was not launched")
debug("get filePath and dirPath from log file")
st, op = commands.getstatusoutput("grep Path /tmp/%s.log | tail -2" % testapp)
dirpath = op.split("\n")[0].split(" ")[2]
self.assert_(dirpath == path, "Wrong dirPath: %s" % dirpath)
filepath = op.split("\n")[1].split(" ")[2]
self.assert_(filepath == "%s/%s" % (path, testapp), "Wrong filePath: %s" % filepath)
kill_process(apppid=pid)
# main # main
if __name__ == '__main__': if __name__ == '__main__':

Loading…
Cancel
Save