initial commit

This commit is contained in:
mikhail "synzr" 2025-12-25 01:37:49 +05:00
commit 9d20827c46
2469 changed files with 470994 additions and 0 deletions

24
qa/guitest/guitest.cpp Normal file
View file

@ -0,0 +1,24 @@
#include <QApplication>
#include <QDebug>
#include <iostream>
#include "guitestmanager.h"
int main(int argc, char** argv)
{
if (argc < 2) {
std::cerr << "Usage: " << argv[0] << " <test>" << std::endl << std::endl;
std::cerr << "The following tests are available: " << std::endl;
foreach(QString test, GUITestManager::instance()->getTestNames()) {
std::cerr << " " << (std::string) test << std::endl;
}
return -1;
}
QApplication a(argc, argv);
if (GUITestManager::instance()->runTest(argv[1])) {
return a.exec();
}
return 0;
}

15
qa/guitest/guitest.h Normal file
View file

@ -0,0 +1,15 @@
#ifndef GUITEST_H
#define GUITEST_H
#include <QList>
#include <QString>
class GUITest
{
public:
virtual ~GUITest() { }
virtual bool run() = 0;
virtual QString name() = 0;
};
#endif

19
qa/guitest/guitest.pro Normal file
View file

@ -0,0 +1,19 @@
CONFIG -= app_bundle
MOC_DIR = ../../src/.moc
OBJECTS_DIR = ../../src/.obj
UI_DIR = ../../src/.ui
CONFIG += pep
DEFINES += QT_STATICPLUGIN
include(../../conf.pri)
include(../../src/src.pri)
SOURCES += \
guitest.cpp \
guitestmanager.cpp
include(../../src/privacy/guitest/guitest.pri)
QMAKE_CLEAN += ${QMAKE_TARGET}

View file

@ -0,0 +1,43 @@
#include <QDebug>
#include "guitestmanager.h"
GUITestManager::GUITestManager()
{
}
GUITestManager* GUITestManager::instance()
{
if (!instance_) {
instance_ = new GUITestManager();
}
return instance_;
}
void GUITestManager::registerTest(GUITest* test)
{
tests_ += test;
}
bool GUITestManager::runTest(const QString& name)
{
foreach(GUITest* test, tests_) {
if (test->name() == name) {
return test->run();
}
}
qWarning() << "Test not found: " << name;
return false;
}
QStringList GUITestManager::getTestNames() const
{
QStringList test_names;
foreach(GUITest* test, tests_) {
test_names += test->name();
}
return test_names;
}
GUITestManager* GUITestManager::instance_ = NULL;

View file

@ -0,0 +1,24 @@
#ifndef GUITESTMANAGER_H
#define GUITESTMANAGER_H
#include <QStringList>
#include "guitest.h"
class GUITestManager
{
public:
static GUITestManager* instance();
void registerTest(GUITest* test);
bool runTest(const QString& name);
QStringList getTestNames() const;
private:
GUITestManager();
static GUITestManager* instance_;
QList<GUITest*> tests_;
};
#endif

12
qa/oldtest/checkall Normal file
View file

@ -0,0 +1,12 @@
#!/bin/bash
# WARNING! All changes made in this file will be lost!
basedir=`pwd`
do_make() {
if test ! -e Makefile; then qmake; fi
make check
}
cd ../src/tools/iconset/unittest && do_make && cd $basedir && \
cd ../src/widgets/unittest/iconaction && do_make && cd $basedir && \
cd ../src/widgets/unittest/richtext && do_make && cd $basedir && \
cd ../src/unittest/psiiconset && do_make && cd $basedir && \
cd ../src/unittest/psipopup && do_make && cd $basedir

7
qa/oldtest/tests.txt Normal file
View file

@ -0,0 +1,7 @@
# This file contains a relative path to each unittest
# directory on separate line.
../src/tools/iconset/unittest
../src/widgets/unittest/iconaction
../src/widgets/unittest/richtext
../src/unittest/psiiconset
../src/unittest/psipopup

67
qa/oldtest/unittest.pri Normal file
View file

@ -0,0 +1,67 @@
# helpers to reduce the size of unittest projects
unittest {
TEMPLATE = app
CONFIG += qtestlib console debug qt
CONFIG -= app_bundle
}
windows {
# otherwise we would get 'unresolved external _WinMainCRTStartup'
# when compiling with MSVC
MOC_DIR = _moc
OBJECTS_DIR = _obj
UI_DIR = _ui
RCC_DIR = _rcc
}
!windows {
MOC_DIR = .moc
OBJECTS_DIR = .obj
UI_DIR = .ui
RCC_DIR = .rcc
}
mac:app_bundle {
EXEC_TARGET = $${TARGET}.app/Contents/MacOS/$${TARGET}
}
else {
EXEC_TARGET = $$TARGET
}
# run target (TODO: Make it work on Windows too)
QMAKE_EXTRA_TARGETS += run
run.depends = $$EXEC_TARGET
run.commands = DISABLE_BREAKPAD=true YACHATDATADIR=~/.yachat-test ./$$EXEC_TARGET
unix {
# gdb target
QMAKE_EXTRA_TARGETS += gdb
gdb.depends = $$EXEC_TARGET
mac {
QT_FRAMEWORK_VERSION = 4
QT_FRAMEWORKS = QtCore QtXml QtNetwork QtGui QtSql Qt3Support
FRAMEWORK = \$(QTDIR)/lib/\$\${f}.framework/Versions/$$QT_FRAMEWORK_VERSION/\$\${f}
gdb.commands += \
for f in $$QT_FRAMEWORKS; do \
install_name_tool -id "$$FRAMEWORK" "$$FRAMEWORK""_debug"; \
install_name_tool -change "$$FRAMEWORK" "$$FRAMEWORK""_debug" "./$$EXEC_TARGET"; \
done;
}
# gdb.commands += echo "set env-vars YACHATDATADIR=\$(HOME)/.yachat-test DISABLE_BREAKPAD=true" > /tmp/lldb-commands;
# gdb.commands += /Xcode4/usr/bin/lldb -f ./$$EXEC_TARGET -s /tmp/lldb-commands
gdb.commands += DISABLE_BREAKPAD=true YACHATDATADIR=~/.yachat-test gdb ./$$EXEC_TARGET
mac {
gdb.commands += ; \
for f in $$QT_FRAMEWORKS; do \
install_name_tool -id "$$FRAMEWORK""_debug" "$$FRAMEWORK""_debug"; \
install_name_tool -change "$$FRAMEWORK""_debug" "$$FRAMEWORK" "./$$EXEC_TARGET"; \
done;
}
}
mac {
# xcode target
QMAKE_EXTRA_TARGETS += xcode
xcode.depends = Makefile
xcode.commands = ${QMAKE} -spec macx-xcode -o $$TARGET
}

12
qa/oldtest/unittest.pro Normal file
View file

@ -0,0 +1,12 @@
# WARNING! All changes made in this file will be lost!
TEMPLATE = subdirs
SUBDIRS += \
../src/tools/iconset/unittest \
../src/widgets/unittest/iconaction \
../src/widgets/unittest/richtext \
../src/unittest/psiiconset \
../src/unittest/psipopup
QMAKE_EXTRA_TARGETS += check
check.commands = sh ./checkall

32
qa/oldtest/update.rb Normal file
View file

@ -0,0 +1,32 @@
#! /usr/bin/env ruby
# This script is used to update auto-generated
# files named 'checkall' and 'unittest.pro'.
# get list of path names
tests = File.new('tests.txt').readlines.find_all { |i| i =~ /^[^#]/ }.collect { |i| i.chomp }
# this string is used to indicate the file is auto-generated
WARNING = "WARNING! All changes made in this file will be lost!"
# generate 'checkall' script
File::open('checkall', 'w') do |f|
f << "#!/bin/bash\n"
f << "# #{WARNING}\n"
f << "basedir=`pwd`\n"
f << "do_make() {\n"
f << " if test ! -e Makefile; then qmake; fi\n"
f << " make check\n"
f << "}\n"
f << tests.collect { |dir| "cd #{dir} && do_make && cd $basedir" }.join(" && \\\n") + "\n"
end
# generate project file
File::open('unittest.pro', 'w') do |f|
f << "# #{WARNING}\n"
f << "TEMPLATE = subdirs\n\n"
f << "SUBDIRS += \\\n"
f << tests.collect { |dir| "\t#{dir}" }.join(" \\\n") + "\n"
f << "\n"
f << "QMAKE_EXTRA_TARGETS += check\n"
f << "check.commands = sh ./checkall\n"
end

25
qa/unittest/unittest.cpp Normal file
View file

@ -0,0 +1,25 @@
#include <QCoreApplication>
#include <cppunit/ui/text/TestRunner.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <cppunit/XmlOutputter.h>
#include <cppunit/TextTestResult.h>
int main(int argc, char* argv[])
{
QCoreApplication a(argc, argv);
CppUnit::TestFactoryRegistry& registry = CppUnit::TestFactoryRegistry::getRegistry();
CppUnit::TextUi::TestRunner runner;
runner.addTest( registry.makeTest() );
if (argc >= 2) {
if (!strcmp(argv[1],"--xml")) {
runner.setOutputter(new CppUnit::XmlOutputter(&runner.result(), std::cout));
}
}
if (argc >= 2 && !strcmp(argv[1],"--xml")) {
runner.setOutputter(new CppUnit::XmlOutputter(&runner.result(), std::cout));
}
return (runner.run("") ? 0 : 1);
}

24
qa/unittest/unittest.pro Normal file
View file

@ -0,0 +1,24 @@
CONFIG -= app_bundle
MOC_DIR = ../../src/.moc
OBJECTS_DIR = ../../src/.obj
UI_DIR = ../../src/.ui
CONFIG += pep
DEFINES += QT_STATICPLUGIN
include(../../conf.pri)
include(../../src/src.pri)
SOURCES += \
unittest.cpp \
unittestutil.cpp
include(../../src/capabilities/unittest/unittest.pri)
include(../../src/privacy/unittest/unittest.pri)
include(../../src/utilities/unittest/unittest.pri)
QMAKE_EXTRA_TARGETS = check
check.commands = make && ./unittest
QMAKE_CLEAN += ${QMAKE_TARGET}

View file

@ -0,0 +1,13 @@
#include <QDebug>
#include "unittestutil.h"
QDomElement UnitTestUtil::createElement(const QString& text)
{
QDomDocument doc;
if (!doc.setContent(text)) {
qWarning() << "Unable to parse element: " << text;
return QDomElement();
}
return doc.documentElement();
}

View file

@ -0,0 +1,11 @@
#ifndef UNITTESTUTIL_H
#define UNITTESTUTIL_H
#include <QDomElement>
namespace UnitTestUtil
{
QDomElement createElement(const QString&);
};
#endif

26
qa/valgrind/valgrind.pri Normal file
View file

@ -0,0 +1,26 @@
unix {
mac:app_bundle {
EXEC_TARGET = $${TARGET}.app/Contents/MacOS/$${TARGET}
}
else {
EXEC_TARGET = $$TARGET
}
VALGRIND_SUPPRESSIONS = $$system(for x in $$PWD/suppressions/*.supp; do echo "--suppressions=$x"; done)
# valgrind target (only shows valgrind output)
VALGRIND_OPTIONS = -q --num-callers=40 --leak-check=full --show-reachable=yes $$VALGRIND_SUPPRESSIONS
QMAKE_EXTRA_TARGETS += valgrind
valgrind.depends = $$EXEC_TARGET
valgrind.commands = YACHATDATADIR=~/.yachat-test valgrind $$VALGRIND_OPTIONS ./$$EXEC_TARGET | grep -E '==\\d+=='
# valgrind_supp target (generate suppressions)
QMAKE_EXTRA_TARGETS += valgrind_supp
valgrind_supp.depends = $$EXEC_TARGET
valgrind_supp.commands = YACHATDATADIR=~/.yachat-test valgrind $$VALGRIND_OPTIONS --gen-suppressions=all ./$$EXEC_TARGET
# callgrind profiling
QMAKE_EXTRA_TARGETS += callgrind
callgrind.depends = $$EXEC_TARGET
callgrind.commands = YACHATDATADIR=~/.yachat-test valgrind --tool=callgrind --dump-instr=yes --collect-jumps=yes ./$$EXEC_TARGET
}