Advance Wayland and KDE package bring-up

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
2026-04-14 10:51:06 +01:00
parent 51f3c21121
commit cf12defd28
15214 changed files with 20594243 additions and 269 deletions
@@ -0,0 +1,2 @@
#clang-tidy
b425532c16b4554e2962d7cd01f463174d4c52ea
@@ -0,0 +1,29 @@
# Ignore the following files
*~
*.[oa]
*.diff
*.kate-swp
*.kdev4
.kdev_include_paths
*.kdevelop.pcs
*.moc
*.moc.cpp
*.orig
*.user
.*.swp
.swp.*
Doxyfile
Makefile
avail
random_seed
/build*/
/.vscode/
CMakeLists.txt.user*
*.unc-backup*
.cmake/
/.clang-format
/compile_commands.json
.clangd
.idea
/cmake-build*
.cache
@@ -0,0 +1,13 @@
# SPDX-FileCopyrightText: 2020 Volker Krause <vkrause@kde.org>
# SPDX-License-Identifier: CC0-1.0
include:
- project: sysadmin/ci-utilities
file:
- /gitlab-templates/linux-qt6.yml
- /gitlab-templates/linux-qt6-static.yml
- /gitlab-templates/alpine-qt6.yml
- /gitlab-templates/android-qt6.yml
- /gitlab-templates/freebsd-qt6.yml
- /gitlab-templates/windows-qt6.yml
- /gitlab-templates/alpine-qt6.yml
@@ -0,0 +1,8 @@
Dependencies:
- 'on': ['@all']
'require':
'frameworks/extra-cmake-modules': '@same'
Options:
test-before-installing: True
require-passing-tests-on: [ 'Linux', 'FreeBSD', 'Windows' ]
@@ -0,0 +1,113 @@
cmake_minimum_required(VERSION 3.16)
set(KF_VERSION "6.10.0") # handled by release scripts
project(KWidgetsAddons VERSION ${KF_VERSION})
include(FeatureSummary)
find_package(ECM 6.10.0 NO_MODULE)
set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://commits.kde.org/extra-cmake-modules")
feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES)
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH})
include(KDEInstallDirs)
include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE)
include(KDECMakeSettings)
include(KDEGitCommitHooks)
include(ECMDeprecationSettings)
set(REQUIRED_QT_VERSION 6.6.0)
find_package(Qt6 ${REQUIRED_QT_VERSION} CONFIG REQUIRED Widgets)
# For the Python bindings
find_package(Python3 3.10 COMPONENTS Interpreter Development)
find_package(Shiboken6)
find_package(PySide6)
include(ECMGenerateExportHeader)
include(CMakePackageConfigHelpers)
include(ECMSetupVersion)
include(ECMGenerateHeaders)
include(ECMAddQch)
include(ECMPoQmTools)
include(ECMQtDeclareLoggingCategory)
include(CMakeDependentOption)
set(kwidgetsaddons_version_header "${CMAKE_CURRENT_BINARY_DIR}/src/kwidgetsaddons_version.h")
ecm_setup_version(PROJECT VARIABLE_PREFIX KWIDGETSADDONS
VERSION_HEADER "${kwidgetsaddons_version_header}"
PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/KF6WidgetsAddonsConfigVersion.cmake"
SOVERSION 6)
set(EXCLUDE_DEPRECATED_BEFORE_AND_AT 0 CACHE STRING "Control the range of deprecated API excluded from the build [default=0].")
option(BUILD_QCH "Build API documentation in QCH format (for e.g. Qt Assistant, Qt Creator & KDevelop)" OFF)
add_feature_info(QCH ${BUILD_QCH} "API documentation in QCH format (for e.g. Qt Assistant, Qt Creator & KDevelop)")
cmake_dependent_option(BUILD_DESIGNERPLUGIN "Build plugin for Qt Designer" ON "NOT CMAKE_CROSSCOMPILING" OFF)
add_feature_info(DESIGNERPLUGIN ${BUILD_DESIGNERPLUGIN} "Build plugin for Qt Designer")
cmake_dependent_option(BUILD_PYTHON_BINDINGS "Generate Python Bindings" ON "TARGET Shiboken6::libshiboken AND TARGET PySide6::pyside6" OFF)
add_feature_info(PYTHON_BINDINGS ${BUILD_PYTHON_BINDINGS} "Python bindings")
# FreeBSD CI is missing required packages
if (CMAKE_SYSTEM_NAME MATCHES FreeBSD)
set(BUILD_PYTHON_BINDINGS OFF)
endif()
#ecm_install_po_files_as_qm(poqm)
configure_file(test-config.h.in ${CMAKE_CURRENT_BINARY_DIR}/test-config.h)
ecm_set_disabled_deprecation_versions(
QT 6.8
)
add_subdirectory(src)
if (BUILD_TESTING)
add_subdirectory(autotests)
add_subdirectory(tests)
add_subdirectory(examples)
endif()
# create a Config.cmake and a ConfigVersion.cmake file and install them
set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/KF6WidgetsAddons")
if (BUILD_QCH)
ecm_install_qch_export(
TARGETS KF6WidgetsAddons_QCH
FILE KF6WidgetsAddonsQchTargets.cmake
DESTINATION "${CMAKECONFIG_INSTALL_DIR}"
COMPONENT Devel
)
set(PACKAGE_INCLUDE_QCHTARGETS "include(\"\${CMAKE_CURRENT_LIST_DIR}/KF6WidgetsAddonsQchTargets.cmake\")")
endif()
configure_package_config_file("${CMAKE_CURRENT_SOURCE_DIR}/KF6WidgetsAddonsConfig.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/KF6WidgetsAddonsConfig.cmake"
INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR}
)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/KF6WidgetsAddonsConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/KF6WidgetsAddonsConfigVersion.cmake"
DESTINATION "${CMAKECONFIG_INSTALL_DIR}"
COMPONENT Devel )
install(EXPORT KF6WidgetsAddonsTargets DESTINATION "${CMAKECONFIG_INSTALL_DIR}" FILE KF6WidgetsAddonsTargets.cmake NAMESPACE KF6:: )
install(FILES
${kwidgetsaddons_version_header}
DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF}/KWidgetsAddons COMPONENT Devel
)
include(ECMFeatureSummary)
ecm_feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)
kde_configure_git_pre_commit_hook(CHECKS CLANG_FORMAT)
if (BUILD_PYTHON_BINDINGS)
include(ECMGeneratePythonBindings)
add_subdirectory(python)
endif()
@@ -0,0 +1,8 @@
@PACKAGE_INIT@
include(CMakeFindDependencyMacro)
find_dependency(Qt6Widgets @REQUIRED_QT_VERSION@)
include("${CMAKE_CURRENT_LIST_DIR}/KF6WidgetsAddonsTargets.cmake")
@PACKAGE_INCLUDE_QCHTARGETS@
@@ -0,0 +1,9 @@
Copyright (c) <year> <owner>
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,121 @@
Creative Commons Legal Code
CC0 1.0 Universal
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
HEREUNDER.
Statement of Purpose
The laws of most jurisdictions throughout the world automatically confer
exclusive Copyright and Related Rights (defined below) upon the creator
and subsequent owner(s) (each and all, an "owner") of an original work of
authorship and/or a database (each, a "Work").
Certain owners wish to permanently relinquish those rights to a Work for
the purpose of contributing to a commons of creative, cultural and
scientific works ("Commons") that the public can reliably and without fear
of later claims of infringement build upon, modify, incorporate in other
works, reuse and redistribute as freely as possible in any form whatsoever
and for any purposes, including without limitation commercial purposes.
These owners may contribute to the Commons to promote the ideal of a free
culture and the further production of creative, cultural and scientific
works, or to gain reputation or greater distribution for their Work in
part through the use and efforts of others.
For these and/or other purposes and motivations, and without any
expectation of additional consideration or compensation, the person
associating CC0 with a Work (the "Affirmer"), to the extent that he or she
is an owner of Copyright and Related Rights in the Work, voluntarily
elects to apply CC0 to the Work and publicly distribute the Work under its
terms, with knowledge of his or her Copyright and Related Rights in the
Work and the meaning and intended legal effect of CC0 on those rights.
1. Copyright and Related Rights. A Work made available under CC0 may be
protected by copyright and related or neighboring rights ("Copyright and
Related Rights"). Copyright and Related Rights include, but are not
limited to, the following:
i. the right to reproduce, adapt, distribute, perform, display,
communicate, and translate a Work;
ii. moral rights retained by the original author(s) and/or performer(s);
iii. publicity and privacy rights pertaining to a person's image or
likeness depicted in a Work;
iv. rights protecting against unfair competition in regards to a Work,
subject to the limitations in paragraph 4(a), below;
v. rights protecting the extraction, dissemination, use and reuse of data
in a Work;
vi. database rights (such as those arising under Directive 96/9/EC of the
European Parliament and of the Council of 11 March 1996 on the legal
protection of databases, and under any national implementation
thereof, including any amended or successor version of such
directive); and
vii. other similar, equivalent or corresponding rights throughout the
world based on applicable law or treaty, and any national
implementations thereof.
2. Waiver. To the greatest extent permitted by, but not in contravention
of, applicable law, Affirmer hereby overtly, fully, permanently,
irrevocably and unconditionally waives, abandons, and surrenders all of
Affirmer's Copyright and Related Rights and associated claims and causes
of action, whether now known or unknown (including existing as well as
future claims and causes of action), in the Work (i) in all territories
worldwide, (ii) for the maximum duration provided by applicable law or
treaty (including future time extensions), (iii) in any current or future
medium and for any number of copies, and (iv) for any purpose whatsoever,
including without limitation commercial, advertising or promotional
purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
member of the public at large and to the detriment of Affirmer's heirs and
successors, fully intending that such Waiver shall not be subject to
revocation, rescission, cancellation, termination, or any other legal or
equitable action to disrupt the quiet enjoyment of the Work by the public
as contemplated by Affirmer's express Statement of Purpose.
3. Public License Fallback. Should any part of the Waiver for any reason
be judged legally invalid or ineffective under applicable law, then the
Waiver shall be preserved to the maximum extent permitted taking into
account Affirmer's express Statement of Purpose. In addition, to the
extent the Waiver is so judged Affirmer hereby grants to each affected
person a royalty-free, non transferable, non sublicensable, non exclusive,
irrevocable and unconditional license to exercise Affirmer's Copyright and
Related Rights in the Work (i) in all territories worldwide, (ii) for the
maximum duration provided by applicable law or treaty (including future
time extensions), (iii) in any current or future medium and for any number
of copies, and (iv) for any purpose whatsoever, including without
limitation commercial, advertising or promotional purposes (the
"License"). The License shall be deemed effective as of the date CC0 was
applied by Affirmer to the Work. Should any part of the License for any
reason be judged legally invalid or ineffective under applicable law, such
partial invalidity or ineffectiveness shall not invalidate the remainder
of the License, and in such case Affirmer hereby affirms that he or she
will not (i) exercise any of his or her remaining Copyright and Related
Rights in the Work or (ii) assert any associated claims and causes of
action with respect to the Work, in either case contrary to Affirmer's
express Statement of Purpose.
4. Limitations and Disclaimers.
a. No trademark or patent rights held by Affirmer are waived, abandoned,
surrendered, licensed or otherwise affected by this document.
b. Affirmer offers the Work as-is and makes no representations or
warranties of any kind concerning the Work, express, implied,
statutory or otherwise, including without limitation warranties of
title, merchantability, fitness for a particular purpose, non
infringement, or the absence of latent or other defects, accuracy, or
the present or absence of errors, whether or not discoverable, all to
the greatest extent permissible under applicable law.
c. Affirmer disclaims responsibility for clearing rights of other persons
that may apply to the Work or any use thereof, including without
limitation any person's Copyright and Related Rights in the Work.
Further, Affirmer disclaims responsibility for obtaining any necessary
consents, permissions or other rights required for any use of the
Work.
d. Affirmer understands and acknowledges that Creative Commons is not a
party to this document and has no duty or obligation with respect to
this CC0 or use of the Work.
@@ -0,0 +1,319 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
Everyone is permitted to copy and distribute verbatim copies of this license
document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your freedom to share
and change it. By contrast, the GNU General Public License is intended to
guarantee your freedom to share and change free software--to make sure the
software is free for all its users. This General Public License applies to
most of the Free Software Foundation's software and to any other program whose
authors commit to using it. (Some other Free Software Foundation software
is covered by the GNU Lesser General Public License instead.) You can apply
it to your programs, too.
When we speak of free software, we are referring to freedom, not price. Our
General Public Licenses are designed to make sure that you have the freedom
to distribute copies of free software (and charge for this service if you
wish), that you receive source code or can get it if you want it, that you
can change the software or use pieces of it in new free programs; and that
you know you can do these things.
To protect your rights, we need to make restrictions that forbid anyone to
deny you these rights or to ask you to surrender the rights. These restrictions
translate to certain responsibilities for you if you distribute copies of
the software, or if you modify it.
For example, if you distribute copies of such a program, whether gratis or
for a fee, you must give the recipients all the rights that you have. You
must make sure that they, too, receive or can get the source code. And you
must show them these terms so they know their rights.
We protect your rights with two steps: (1) copyright the software, and (2)
offer you this license which gives you legal permission to copy, distribute
and/or modify the software.
Also, for each author's protection and ours, we want to make certain that
everyone understands that there is no warranty for this free software. If
the software is modified by someone else and passed on, we want its recipients
to know that what they have is not the original, so that any problems introduced
by others will not reflect on the original authors' reputations.
Finally, any free program is threatened constantly by software patents. We
wish to avoid the danger that redistributors of a free program will individually
obtain patent licenses, in effect making the program proprietary. To prevent
this, we have made it clear that any patent must be licensed for everyone's
free use or not licensed at all.
The precise terms and conditions for copying, distribution and modification
follow.
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains a notice
placed by the copyright holder saying it may be distributed under the terms
of this General Public License. The "Program", below, refers to any such program
or work, and a "work based on the Program" means either the Program or any
derivative work under copyright law: that is to say, a work containing the
Program or a portion of it, either verbatim or with modifications and/or translated
into another language. (Hereinafter, translation is included without limitation
in the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not covered
by this License; they are outside its scope. The act of running the Program
is not restricted, and the output from the Program is covered only if its
contents constitute a work based on the Program (independent of having been
made by running the Program). Whether that is true depends on what the Program
does.
1. You may copy and distribute verbatim copies of the Program's source code
as you receive it, in any medium, provided that you conspicuously and appropriately
publish on each copy an appropriate copyright notice and disclaimer of warranty;
keep intact all the notices that refer to this License and to the absence
of any warranty; and give any other recipients of the Program a copy of this
License along with the Program.
You may charge a fee for the physical act of transferring a copy, and you
may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion of it,
thus forming a work based on the Program, and copy and distribute such modifications
or work under the terms of Section 1 above, provided that you also meet all
of these conditions:
a) You must cause the modified files to carry prominent notices stating that
you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in whole or
in part contains or is derived from the Program or any part thereof, to be
licensed as a whole at no charge to all third parties under the terms of this
License.
c) If the modified program normally reads commands interactively when run,
you must cause it, when started running for such interactive use in the most
ordinary way, to print or display an announcement including an appropriate
copyright notice and a notice that there is no warranty (or else, saying that
you provide a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this License.
(Exception: if the Program itself is interactive but does not normally print
such an announcement, your work based on the Program is not required to print
an announcement.)
These requirements apply to the modified work as a whole. If identifiable
sections of that work are not derived from the Program, and can be reasonably
considered independent and separate works in themselves, then this License,
and its terms, do not apply to those sections when you distribute them as
separate works. But when you distribute the same sections as part of a whole
which is a work based on the Program, the distribution of the whole must be
on the terms of this License, whose permissions for other licensees extend
to the entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest your
rights to work written entirely by you; rather, the intent is to exercise
the right to control the distribution of derivative or collective works based
on the Program.
In addition, mere aggregation of another work not based on the Program with
the Program (or with a work based on the Program) on a volume of a storage
or distribution medium does not bring the other work under the scope of this
License.
3. You may copy and distribute the Program (or a work based on it, under Section
2) in object code or executable form under the terms of Sections 1 and 2 above
provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable source code,
which must be distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three years, to give
any third party, for a charge no more than your cost of physically performing
source distribution, a complete machine-readable copy of the corresponding
source code, to be distributed under the terms of Sections 1 and 2 above on
a medium customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer to distribute
corresponding source code. (This alternative is allowed only for noncommercial
distribution and only if you received the program in object code or executable
form with such an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for making
modifications to it. For an executable work, complete source code means all
the source code for all modules it contains, plus any associated interface
definition files, plus the scripts used to control compilation and installation
of the executable. However, as a special exception, the source code distributed
need not include anything that is normally distributed (in either source or
binary form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component itself
accompanies the executable.
If distribution of executable or object code is made by offering access to
copy from a designated place, then offering equivalent access to copy the
source code from the same place counts as distribution of the source code,
even though third parties are not compelled to copy the source along with
the object code.
4. You may not copy, modify, sublicense, or distribute the Program except
as expressly provided under this License. Any attempt otherwise to copy, modify,
sublicense or distribute the Program is void, and will automatically terminate
your rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses terminated
so long as such parties remain in full compliance.
5. You are not required to accept this License, since you have not signed
it. However, nothing else grants you permission to modify or distribute the
Program or its derivative works. These actions are prohibited by law if you
do not accept this License. Therefore, by modifying or distributing the Program
(or any work based on the Program), you indicate your acceptance of this License
to do so, and all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the Program),
the recipient automatically receives a license from the original licensor
to copy, distribute or modify the Program subject to these terms and conditions.
You may not impose any further restrictions on the recipients' exercise of
the rights granted herein. You are not responsible for enforcing compliance
by third parties to this License.
7. If, as a consequence of a court judgment or allegation of patent infringement
or for any other reason (not limited to patent issues), conditions are imposed
on you (whether by court order, agreement or otherwise) that contradict the
conditions of this License, they do not excuse you from the conditions of
this License. If you cannot distribute so as to satisfy simultaneously your
obligations under this License and any other pertinent obligations, then as
a consequence you may not distribute the Program at all. For example, if a
patent license would not permit royalty-free redistribution of the Program
by all those who receive copies directly or indirectly through you, then the
only way you could satisfy both it and this License would be to refrain entirely
from distribution of the Program.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply and
the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any patents
or other property right claims or to contest validity of any such claims;
this section has the sole purpose of protecting the integrity of the free
software distribution system, which is implemented by public license practices.
Many people have made generous contributions to the wide range of software
distributed through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing to
distribute software through any other system and a licensee cannot impose
that choice.
This section is intended to make thoroughly clear what is believed to be a
consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in certain
countries either by patents or by copyrighted interfaces, the original copyright
holder who places the Program under this License may add an explicit geographical
distribution limitation excluding those countries, so that distribution is
permitted only in or among countries not thus excluded. In such case, this
License incorporates the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions of
the General Public License from time to time. Such new versions will be similar
in spirit to the present version, but may differ in detail to address new
problems or concerns.
Each version is given a distinguishing version number. If the Program specifies
a version number of this License which applies to it and "any later version",
you have the option of following the terms and conditions either of that version
or of any later version published by the Free Software Foundation. If the
Program does not specify a version number of this License, you may choose
any version ever published by the Free Software Foundation.
10. If you wish to incorporate parts of the Program into other free programs
whose distribution conditions are different, write to the author to ask for
permission. For software which is copyrighted by the Free Software Foundation,
write to the Free Software Foundation; we sometimes make exceptions for this.
Our decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing and reuse
of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR
THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE
STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM
"AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE
OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE
OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA
OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES
OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH
HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest possible
use to the public, the best way to achieve this is to make it free software
which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest to attach
them to the start of each source file to most effectively convey the exclusion
of warranty; and each file should have at least the "copyright" line and a
pointer to where the full notice is found.
<one line to give the program's name and an idea of what it does.>
Copyright (C) <yyyy> <name of author>
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
Street, Fifth Floor, Boston, MA 02110-1301, USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this when
it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author Gnomovision comes
with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software,
and you are welcome to redistribute it under certain conditions; type `show
c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may be
called something other than `show w' and `show c'; they could even be mouse-clicks
or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your school,
if any, to sign a "copyright disclaimer" for the program, if necessary. Here
is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision'
(which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989 Ty Coon, President of Vice This General
Public License does not permit incorporating your program into proprietary
programs. If your program is a subroutine library, you may consider it more
useful to permit linking proprietary applications with the library. If this
is what you want to do, use the GNU Lesser General Public License instead
of this License.
@@ -0,0 +1,446 @@
GNU LIBRARY GENERAL PUBLIC LICENSE
Version 2, June 1991 Copyright (C) 1991 Free Software Foundation, Inc.
51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
Everyone is permitted to copy and distribute verbatim copies of this license
document, but changing it is not allowed.
[This is the first released version of the library GPL. It is numbered 2 because
it goes with version 2 of the ordinary GPL.]
Preamble
The licenses for most software are designed to take away your freedom to share
and change it. By contrast, the GNU General Public Licenses are intended to
guarantee your freedom to share and change free software--to make sure the
software is free for all its users.
This license, the Library General Public License, applies to some specially
designated Free Software Foundation software, and to any other libraries whose
authors decide to use it. You can use it for your libraries, too.
When we speak of free software, we are referring to freedom, not price. Our
General Public Licenses are designed to make sure that you have the freedom
to distribute copies of free software (and charge for this service if you
wish), that you receive source code or can get it if you want it, that you
can change the software or use pieces of it in new free programs; and that
you know you can do these things.
To protect your rights, we need to make restrictions that forbid anyone to
deny you these rights or to ask you to surrender the rights. These restrictions
translate to certain responsibilities for you if you distribute copies of
the library, or if you modify it.
For example, if you distribute copies of the library, whether gratis or for
a fee, you must give the recipients all the rights that we gave you. You must
make sure that they, too, receive or can get the source code. If you link
a program with the library, you must provide complete object files to the
recipients so that they can relink them with the library, after making changes
to the library and recompiling it. And you must show them these terms so they
know their rights.
Our method of protecting your rights has two steps: (1) copyright the library,
and (2) offer you this license which gives you legal permission to copy, distribute
and/or modify the library.
Also, for each distributor's protection, we want to make certain that everyone
understands that there is no warranty for this free library. If the library
is modified by someone else and passed on, we want its recipients to know
that what they have is not the original version, so that any problems introduced
by others will not reflect on the original authors' reputations.
Finally, any free program is threatened constantly by software patents. We
wish to avoid the danger that companies distributing free software will individually
obtain patent licenses, thus in effect transforming the program into proprietary
software. To prevent this, we have made it clear that any patent must be licensed
for everyone's free use or not licensed at all.
Most GNU software, including some libraries, is covered by the ordinary GNU
General Public License, which was designed for utility programs. This license,
the GNU Library General Public License, applies to certain designated libraries.
This license is quite different from the ordinary one; be sure to read it
in full, and don't assume that anything in it is the same as in the ordinary
license.
The reason we have a separate public license for some libraries is that they
blur the distinction we usually make between modifying or adding to a program
and simply using it. Linking a program with a library, without changing the
library, is in some sense simply using the library, and is analogous to running
a utility program or application program. However, in a textual and legal
sense, the linked executable is a combined work, a derivative of the original
library, and the ordinary General Public License treats it as such.
Because of this blurred distinction, using the ordinary General Public License
for libraries did not effectively promote software sharing, because most developers
did not use the libraries. We concluded that weaker conditions might promote
sharing better.
However, unrestricted linking of non-free programs would deprive the users
of those programs of all benefit from the free status of the libraries themselves.
This Library General Public License is intended to permit developers of non-free
programs to use free libraries, while preserving your freedom as a user of
such programs to change the free libraries that are incorporated in them.
(We have not seen how to achieve this as regards changes in header files,
but we have achieved it as regards changes in the actual functions of the
Library.) The hope is that this will lead to faster development of free libraries.
The precise terms and conditions for copying, distribution and modification
follow. Pay close attention to the difference between a "work based on the
library" and a "work that uses the library". The former contains code derived
from the library, while the latter only works together with the library.
Note that it is possible for a library to be covered by the ordinary General
Public License rather than by this special one.
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library which contains a
notice placed by the copyright holder or other authorized party saying it
may be distributed under the terms of this Library General Public License
(also called "this License"). Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data prepared
so as to be conveniently linked with application programs (which use some
of those functions and data) to form executables.
The "Library", below, refers to any such software library or work which has
been distributed under these terms. A "work based on the Library" means either
the Library or any derivative work under copyright law: that is to say, a
work containing the Library or a portion of it, either verbatim or with modifications
and/or translated straightforwardly into another language. (Hereinafter, translation
is included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for making modifications
to it. For a library, complete source code means all the source code for all
modules it contains, plus any associated interface definition files, plus
the scripts used to control compilation and installation of the library.
Activities other than copying, distribution and modification are not covered
by this License; they are outside its scope. The act of running a program
using the Library is not restricted, and output from such a program is covered
only if its contents constitute a work based on the Library (independent of
the use of the Library in a tool for writing it). Whether that is true depends
on what the Library does and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's complete source
code as you receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice and disclaimer
of warranty; keep intact all the notices that refer to this License and to
the absence of any warranty; and distribute a copy of this License along with
the Library.
You may charge a fee for the physical act of transferring a copy, and you
may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Library or any portion of it,
thus forming a work based on the Library, and copy and distribute such modifications
or work under the terms of Section 1 above, provided that you also meet all
of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices stating that
you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no charge to all
third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a table of
data to be supplied by an application program that uses the facility, other
than as an argument passed when the facility is invoked, then you must make
a good faith effort to ensure that, in the event an application does not supply
such function or table, the facility still operates, and performs whatever
part of its purpose remains meaningful.
(For example, a function in a library to compute square roots has a purpose
that is entirely well-defined independent of the application. Therefore, Subsection
2d requires that any application-supplied function or table used by this function
must be optional: if the application does not supply it, the square root function
must still compute square roots.)
These requirements apply to the modified work as a whole. If identifiable
sections of that work are not derived from the Library, and can be reasonably
considered independent and separate works in themselves, then this License,
and its terms, do not apply to those sections when you distribute them as
separate works. But when you distribute the same sections as part of a whole
which is a work based on the Library, the distribution of the whole must be
on the terms of this License, whose permissions for other licensees extend
to the entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest your
rights to work written entirely by you; rather, the intent is to exercise
the right to control the distribution of derivative or collective works based
on the Library.
In addition, mere aggregation of another work not based on the Library with
the Library (or with a work based on the Library) on a volume of a storage
or distribution medium does not bring the other work under the scope of this
License.
3. You may opt to apply the terms of the ordinary GNU General Public License
instead of this License to a given copy of the Library. To do this, you must
alter all the notices that refer to this License, so that they refer to the
ordinary GNU General Public License, version 2, instead of to this License.
(If a newer version than version 2 of the ordinary GNU General Public License
has appeared, then you can specify that version instead if you wish.) Do not
make any other change in these notices.
Once this change is made in a given copy, it is irreversible for that copy,
so the ordinary GNU General Public License applies to all subsequent copies
and derivative works made from that copy.
This option is useful when you wish to copy part of the code of the Library
into a program that is not a library.
4. You may copy and distribute the Library (or a portion or derivative of
it, under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you accompany it with the complete corresponding
machine-readable source code, which must be distributed under the terms of
Sections 1 and 2 above on a medium customarily used for software interchange.
If distribution of object code is made by offering access to copy from a designated
place, then offering equivalent access to copy the source code from the same
place satisfies the requirement to distribute the source code, even though
third parties are not compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the Library, but
is designed to work with the Library by being compiled or linked with it,
is called a "work that uses the Library". Such a work, in isolation, is not
a derivative work of the Library, and therefore falls outside the scope of
this License.
However, linking a "work that uses the Library" with the Library creates an
executable that is a derivative of the Library (because it contains portions
of the Library), rather than a "work that uses the library". The executable
is therefore covered by this License. Section 6 states terms for distribution
of such executables.
When a "work that uses the Library" uses material from a header file that
is part of the Library, the object code for the work may be a derivative work
of the Library even though the source code is not. Whether this is true is
especially significant if the work can be linked without the Library, or if
the work is itself a library. The threshold for this to be true is not precisely
defined by law.
If such an object file uses only numerical parameters, data structure layouts
and accessors, and small macros and small inline functions (ten lines or less
in length), then the use of the object file is unrestricted, regardless of
whether it is legally a derivative work. (Executables containing this object
code plus portions of the Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may distribute
the object code for the work under the terms of Section 6. Any executables
containing that work also fall under Section 6, whether or not they are linked
directly with the Library itself.
6. As an exception to the Sections above, you may also compile or link a "work
that uses the Library" with the Library to produce a work containing portions
of the Library, and distribute that work under terms of your choice, provided
that the terms permit modification of the work for the customer's own use
and reverse engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the Library
is used in it and that the Library and its use are covered by this License.
You must supply a copy of this License. If the work during execution displays
copyright notices, you must include the copyright notice for the Library among
them, as well as a reference directing the user to the copy of this License.
Also, you must do one of these things:
a) Accompany the work with the complete corresponding machine-readable source
code for the Library including whatever changes were used in the work (which
must be distributed under Sections 1 and 2 above); and, if the work is an
executable linked with the Library, with the complete machine-readable "work
that uses the Library", as object code and/or source code, so that the user
can modify the Library and then relink to produce a modified executable containing
the modified Library. (It is understood that the user who changes the contents
of definitions files in the Library will not necessarily be able to recompile
the application to use the modified definitions.)
b) Accompany the work with a written offer, valid for at least three years,
to give the same user the materials specified in Subsection 6a, above, for
a charge no more than the cost of performing this distribution.
c) If distribution of the work is made by offering access to copy from a designated
place, offer equivalent access to copy the above specified materials from
the same place.
d) Verify that the user has already received a copy of these materials or
that you have already sent this user a copy.
For an executable, the required form of the "work that uses the Library" must
include any data and utility programs needed for reproducing the executable
from it. However, as a special exception, the source code distributed need
not include anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the operating
system on which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license restrictions of
other proprietary libraries that do not normally accompany the operating system.
Such a contradiction means you cannot use both them and the Library together
in an executable that you distribute.
7. You may place library facilities that are a work based on the Library side-by-side
in a single library together with other library facilities not covered by
this License, and distribute such a combined library, provided that the separate
distribution of the work based on the Library and of the other library facilities
is otherwise permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work based on the
Library, uncombined with any other library facilities. This must be distributed
under the terms of the Sections above.
b) Give prominent notice with the combined library of the fact that part of
it is a work based on the Library, and explaining where to find the accompanying
uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute the Library
except as expressly provided under this License. Any attempt otherwise to
copy, modify, sublicense, link with, or distribute the Library is void, and
will automatically terminate your rights under this License. However, parties
who have received copies, or rights, from you under this License will not
have their licenses terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not signed
it. However, nothing else grants you permission to modify or distribute the
Library or its derivative works. These actions are prohibited by law if you
do not accept this License. Therefore, by modifying or distributing the Library
(or any work based on the Library), you indicate your acceptance of this License
to do so, and all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the Library),
the recipient automatically receives a license from the original licensor
to copy, distribute, link with or modify the Library subject to these terms
and conditions. You may not impose any further restrictions on the recipients'
exercise of the rights granted herein. You are not responsible for enforcing
compliance by third parties to this License.
11. If, as a consequence of a court judgment or allegation of patent infringement
or for any other reason (not limited to patent issues), conditions are imposed
on you (whether by court order, agreement or otherwise) that contradict the
conditions of this License, they do not excuse you from the conditions of
this License. If you cannot distribute so as to satisfy simultaneously your
obligations under this License and any other pertinent obligations, then as
a consequence you may not distribute the Library at all. For example, if a
patent license would not permit royalty-free redistribution of the Library
by all those who receive copies directly or indirectly through you, then the
only way you could satisfy both it and this License would be to refrain entirely
from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any patents
or other property right claims or to contest validity of any such claims;
this section has the sole purpose of protecting the integrity of the free
software distribution system which is implemented by public license practices.
Many people have made generous contributions to the wide range of software
distributed through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing to
distribute software through any other system and a licensee cannot impose
that choice.
This section is intended to make thoroughly clear what is believed to be a
consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in certain
countries either by patents or by copyrighted interfaces, the original copyright
holder who places the Library under this License may add an explicit geographical
distribution limitation excluding those countries, so that distribution is
permitted only in or among countries not thus excluded. In such case, this
License incorporates the limitation as if written in the body of this License.
13. The Free Software Foundation may publish revised and/or new versions of
the Library General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to address
new problems or concerns.
Each version is given a distinguishing version number. If the Library specifies
a version number of this License which applies to it and "any later version",
you have the option of following the terms and conditions either of that version
or of any later version published by the Free Software Foundation. If the
Library does not specify a license version number, you may choose any version
ever published by the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free programs
whose distribution conditions are incompatible with these, write to the author
to ask for permission. For software which is copyrighted by the Free Software
Foundation, write to the Free Software Foundation; we sometimes make exceptions
for this. Our decision will be guided by the two goals of preserving the free
status of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR
THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE
STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY
"AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE
OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE
THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE
OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA
OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES
OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH
HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest possible
use to the public, we recommend making it free software that everyone can
redistribute and change. You can do so by permitting redistribution under
these terms (or, alternatively, under the terms of the ordinary General Public
License).
To apply these terms, attach the following notices to the library. It is safest
to attach them to the start of each source file to most effectively convey
the exclusion of warranty; and each file should have at least the "copyright"
line and a pointer to where the full notice is found.
one line to give the library's name and an idea of what it does.
Copyright (C) year name of author
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Library General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your option)
any later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
details.
You should have received a copy of the GNU Library General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your school,
if any, to sign a "copyright disclaimer" for the library, if necessary. Here
is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in
the library `Frob' (a library for tweaking knobs) written
by James Random Hacker.
signature of Ty Coon, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!
@@ -0,0 +1,446 @@
GNU LIBRARY GENERAL PUBLIC LICENSE
Version 2, June 1991 Copyright (C) 1991 Free Software Foundation, Inc.
51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
Everyone is permitted to copy and distribute verbatim copies of this license
document, but changing it is not allowed.
[This is the first released version of the library GPL. It is numbered 2 because
it goes with version 2 of the ordinary GPL.]
Preamble
The licenses for most software are designed to take away your freedom to share
and change it. By contrast, the GNU General Public Licenses are intended to
guarantee your freedom to share and change free software--to make sure the
software is free for all its users.
This license, the Library General Public License, applies to some specially
designated Free Software Foundation software, and to any other libraries whose
authors decide to use it. You can use it for your libraries, too.
When we speak of free software, we are referring to freedom, not price. Our
General Public Licenses are designed to make sure that you have the freedom
to distribute copies of free software (and charge for this service if you
wish), that you receive source code or can get it if you want it, that you
can change the software or use pieces of it in new free programs; and that
you know you can do these things.
To protect your rights, we need to make restrictions that forbid anyone to
deny you these rights or to ask you to surrender the rights. These restrictions
translate to certain responsibilities for you if you distribute copies of
the library, or if you modify it.
For example, if you distribute copies of the library, whether gratis or for
a fee, you must give the recipients all the rights that we gave you. You must
make sure that they, too, receive or can get the source code. If you link
a program with the library, you must provide complete object files to the
recipients so that they can relink them with the library, after making changes
to the library and recompiling it. And you must show them these terms so they
know their rights.
Our method of protecting your rights has two steps: (1) copyright the library,
and (2) offer you this license which gives you legal permission to copy, distribute
and/or modify the library.
Also, for each distributor's protection, we want to make certain that everyone
understands that there is no warranty for this free library. If the library
is modified by someone else and passed on, we want its recipients to know
that what they have is not the original version, so that any problems introduced
by others will not reflect on the original authors' reputations.
Finally, any free program is threatened constantly by software patents. We
wish to avoid the danger that companies distributing free software will individually
obtain patent licenses, thus in effect transforming the program into proprietary
software. To prevent this, we have made it clear that any patent must be licensed
for everyone's free use or not licensed at all.
Most GNU software, including some libraries, is covered by the ordinary GNU
General Public License, which was designed for utility programs. This license,
the GNU Library General Public License, applies to certain designated libraries.
This license is quite different from the ordinary one; be sure to read it
in full, and don't assume that anything in it is the same as in the ordinary
license.
The reason we have a separate public license for some libraries is that they
blur the distinction we usually make between modifying or adding to a program
and simply using it. Linking a program with a library, without changing the
library, is in some sense simply using the library, and is analogous to running
a utility program or application program. However, in a textual and legal
sense, the linked executable is a combined work, a derivative of the original
library, and the ordinary General Public License treats it as such.
Because of this blurred distinction, using the ordinary General Public License
for libraries did not effectively promote software sharing, because most developers
did not use the libraries. We concluded that weaker conditions might promote
sharing better.
However, unrestricted linking of non-free programs would deprive the users
of those programs of all benefit from the free status of the libraries themselves.
This Library General Public License is intended to permit developers of non-free
programs to use free libraries, while preserving your freedom as a user of
such programs to change the free libraries that are incorporated in them.
(We have not seen how to achieve this as regards changes in header files,
but we have achieved it as regards changes in the actual functions of the
Library.) The hope is that this will lead to faster development of free libraries.
The precise terms and conditions for copying, distribution and modification
follow. Pay close attention to the difference between a "work based on the
library" and a "work that uses the library". The former contains code derived
from the library, while the latter only works together with the library.
Note that it is possible for a library to be covered by the ordinary General
Public License rather than by this special one.
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library which contains a
notice placed by the copyright holder or other authorized party saying it
may be distributed under the terms of this Library General Public License
(also called "this License"). Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data prepared
so as to be conveniently linked with application programs (which use some
of those functions and data) to form executables.
The "Library", below, refers to any such software library or work which has
been distributed under these terms. A "work based on the Library" means either
the Library or any derivative work under copyright law: that is to say, a
work containing the Library or a portion of it, either verbatim or with modifications
and/or translated straightforwardly into another language. (Hereinafter, translation
is included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for making modifications
to it. For a library, complete source code means all the source code for all
modules it contains, plus any associated interface definition files, plus
the scripts used to control compilation and installation of the library.
Activities other than copying, distribution and modification are not covered
by this License; they are outside its scope. The act of running a program
using the Library is not restricted, and output from such a program is covered
only if its contents constitute a work based on the Library (independent of
the use of the Library in a tool for writing it). Whether that is true depends
on what the Library does and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's complete source
code as you receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice and disclaimer
of warranty; keep intact all the notices that refer to this License and to
the absence of any warranty; and distribute a copy of this License along with
the Library.
You may charge a fee for the physical act of transferring a copy, and you
may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Library or any portion of it,
thus forming a work based on the Library, and copy and distribute such modifications
or work under the terms of Section 1 above, provided that you also meet all
of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices stating that
you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no charge to all
third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a table of
data to be supplied by an application program that uses the facility, other
than as an argument passed when the facility is invoked, then you must make
a good faith effort to ensure that, in the event an application does not supply
such function or table, the facility still operates, and performs whatever
part of its purpose remains meaningful.
(For example, a function in a library to compute square roots has a purpose
that is entirely well-defined independent of the application. Therefore, Subsection
2d requires that any application-supplied function or table used by this function
must be optional: if the application does not supply it, the square root function
must still compute square roots.)
These requirements apply to the modified work as a whole. If identifiable
sections of that work are not derived from the Library, and can be reasonably
considered independent and separate works in themselves, then this License,
and its terms, do not apply to those sections when you distribute them as
separate works. But when you distribute the same sections as part of a whole
which is a work based on the Library, the distribution of the whole must be
on the terms of this License, whose permissions for other licensees extend
to the entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest your
rights to work written entirely by you; rather, the intent is to exercise
the right to control the distribution of derivative or collective works based
on the Library.
In addition, mere aggregation of another work not based on the Library with
the Library (or with a work based on the Library) on a volume of a storage
or distribution medium does not bring the other work under the scope of this
License.
3. You may opt to apply the terms of the ordinary GNU General Public License
instead of this License to a given copy of the Library. To do this, you must
alter all the notices that refer to this License, so that they refer to the
ordinary GNU General Public License, version 2, instead of to this License.
(If a newer version than version 2 of the ordinary GNU General Public License
has appeared, then you can specify that version instead if you wish.) Do not
make any other change in these notices.
Once this change is made in a given copy, it is irreversible for that copy,
so the ordinary GNU General Public License applies to all subsequent copies
and derivative works made from that copy.
This option is useful when you wish to copy part of the code of the Library
into a program that is not a library.
4. You may copy and distribute the Library (or a portion or derivative of
it, under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you accompany it with the complete corresponding
machine-readable source code, which must be distributed under the terms of
Sections 1 and 2 above on a medium customarily used for software interchange.
If distribution of object code is made by offering access to copy from a designated
place, then offering equivalent access to copy the source code from the same
place satisfies the requirement to distribute the source code, even though
third parties are not compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the Library, but
is designed to work with the Library by being compiled or linked with it,
is called a "work that uses the Library". Such a work, in isolation, is not
a derivative work of the Library, and therefore falls outside the scope of
this License.
However, linking a "work that uses the Library" with the Library creates an
executable that is a derivative of the Library (because it contains portions
of the Library), rather than a "work that uses the library". The executable
is therefore covered by this License. Section 6 states terms for distribution
of such executables.
When a "work that uses the Library" uses material from a header file that
is part of the Library, the object code for the work may be a derivative work
of the Library even though the source code is not. Whether this is true is
especially significant if the work can be linked without the Library, or if
the work is itself a library. The threshold for this to be true is not precisely
defined by law.
If such an object file uses only numerical parameters, data structure layouts
and accessors, and small macros and small inline functions (ten lines or less
in length), then the use of the object file is unrestricted, regardless of
whether it is legally a derivative work. (Executables containing this object
code plus portions of the Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may distribute
the object code for the work under the terms of Section 6. Any executables
containing that work also fall under Section 6, whether or not they are linked
directly with the Library itself.
6. As an exception to the Sections above, you may also compile or link a "work
that uses the Library" with the Library to produce a work containing portions
of the Library, and distribute that work under terms of your choice, provided
that the terms permit modification of the work for the customer's own use
and reverse engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the Library
is used in it and that the Library and its use are covered by this License.
You must supply a copy of this License. If the work during execution displays
copyright notices, you must include the copyright notice for the Library among
them, as well as a reference directing the user to the copy of this License.
Also, you must do one of these things:
a) Accompany the work with the complete corresponding machine-readable source
code for the Library including whatever changes were used in the work (which
must be distributed under Sections 1 and 2 above); and, if the work is an
executable linked with the Library, with the complete machine-readable "work
that uses the Library", as object code and/or source code, so that the user
can modify the Library and then relink to produce a modified executable containing
the modified Library. (It is understood that the user who changes the contents
of definitions files in the Library will not necessarily be able to recompile
the application to use the modified definitions.)
b) Accompany the work with a written offer, valid for at least three years,
to give the same user the materials specified in Subsection 6a, above, for
a charge no more than the cost of performing this distribution.
c) If distribution of the work is made by offering access to copy from a designated
place, offer equivalent access to copy the above specified materials from
the same place.
d) Verify that the user has already received a copy of these materials or
that you have already sent this user a copy.
For an executable, the required form of the "work that uses the Library" must
include any data and utility programs needed for reproducing the executable
from it. However, as a special exception, the source code distributed need
not include anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the operating
system on which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license restrictions of
other proprietary libraries that do not normally accompany the operating system.
Such a contradiction means you cannot use both them and the Library together
in an executable that you distribute.
7. You may place library facilities that are a work based on the Library side-by-side
in a single library together with other library facilities not covered by
this License, and distribute such a combined library, provided that the separate
distribution of the work based on the Library and of the other library facilities
is otherwise permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work based on the
Library, uncombined with any other library facilities. This must be distributed
under the terms of the Sections above.
b) Give prominent notice with the combined library of the fact that part of
it is a work based on the Library, and explaining where to find the accompanying
uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute the Library
except as expressly provided under this License. Any attempt otherwise to
copy, modify, sublicense, link with, or distribute the Library is void, and
will automatically terminate your rights under this License. However, parties
who have received copies, or rights, from you under this License will not
have their licenses terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not signed
it. However, nothing else grants you permission to modify or distribute the
Library or its derivative works. These actions are prohibited by law if you
do not accept this License. Therefore, by modifying or distributing the Library
(or any work based on the Library), you indicate your acceptance of this License
to do so, and all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the Library),
the recipient automatically receives a license from the original licensor
to copy, distribute, link with or modify the Library subject to these terms
and conditions. You may not impose any further restrictions on the recipients'
exercise of the rights granted herein. You are not responsible for enforcing
compliance by third parties to this License.
11. If, as a consequence of a court judgment or allegation of patent infringement
or for any other reason (not limited to patent issues), conditions are imposed
on you (whether by court order, agreement or otherwise) that contradict the
conditions of this License, they do not excuse you from the conditions of
this License. If you cannot distribute so as to satisfy simultaneously your
obligations under this License and any other pertinent obligations, then as
a consequence you may not distribute the Library at all. For example, if a
patent license would not permit royalty-free redistribution of the Library
by all those who receive copies directly or indirectly through you, then the
only way you could satisfy both it and this License would be to refrain entirely
from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any patents
or other property right claims or to contest validity of any such claims;
this section has the sole purpose of protecting the integrity of the free
software distribution system which is implemented by public license practices.
Many people have made generous contributions to the wide range of software
distributed through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing to
distribute software through any other system and a licensee cannot impose
that choice.
This section is intended to make thoroughly clear what is believed to be a
consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in certain
countries either by patents or by copyrighted interfaces, the original copyright
holder who places the Library under this License may add an explicit geographical
distribution limitation excluding those countries, so that distribution is
permitted only in or among countries not thus excluded. In such case, this
License incorporates the limitation as if written in the body of this License.
13. The Free Software Foundation may publish revised and/or new versions of
the Library General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to address
new problems or concerns.
Each version is given a distinguishing version number. If the Library specifies
a version number of this License which applies to it and "any later version",
you have the option of following the terms and conditions either of that version
or of any later version published by the Free Software Foundation. If the
Library does not specify a license version number, you may choose any version
ever published by the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free programs
whose distribution conditions are incompatible with these, write to the author
to ask for permission. For software which is copyrighted by the Free Software
Foundation, write to the Free Software Foundation; we sometimes make exceptions
for this. Our decision will be guided by the two goals of preserving the free
status of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR
THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE
STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY
"AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE
OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE
THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE
OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA
OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES
OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH
HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest possible
use to the public, we recommend making it free software that everyone can
redistribute and change. You can do so by permitting redistribution under
these terms (or, alternatively, under the terms of the ordinary General Public
License).
To apply these terms, attach the following notices to the library. It is safest
to attach them to the start of each source file to most effectively convey
the exclusion of warranty; and each file should have at least the "copyright"
line and a pointer to where the full notice is found.
one line to give the library's name and an idea of what it does.
Copyright (C) year name of author
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Library General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your option)
any later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
details.
You should have received a copy of the GNU Library General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your school,
if any, to sign a "copyright disclaimer" for the library, if necessary. Here
is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in
the library `Frob' (a library for tweaking knobs) written
by James Random Hacker.
signature of Ty Coon, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!
@@ -0,0 +1,467 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies of this license
document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts as the
successor of the GNU Library Public License, version 2, hence the version
number 2.1.]
Preamble
The licenses for most software are designed to take away your freedom to share
and change it. By contrast, the GNU General Public Licenses are intended to
guarantee your freedom to share and change free software--to make sure the
software is free for all its users.
This license, the Lesser General Public License, applies to some specially
designated software packages--typically libraries--of the Free Software Foundation
and other authors who decide to use it. You can use it too, but we suggest
you first think carefully about whether this license or the ordinary General
Public License is the better strategy to use in any particular case, based
on the explanations below.
When we speak of free software, we are referring to freedom of use, not price.
Our General Public Licenses are designed to make sure that you have the freedom
to distribute copies of free software (and charge for this service if you
wish); that you receive source code or can get it if you want it; that you
can change the software and use pieces of it in new free programs; and that
you are informed that you can do these things.
To protect your rights, we need to make restrictions that forbid distributors
to deny you these rights or to ask you to surrender these rights. These restrictions
translate to certain responsibilities for you if you distribute copies of
the library or if you modify it.
For example, if you distribute copies of the library, whether gratis or for
a fee, you must give the recipients all the rights that we gave you. You must
make sure that they, too, receive or can get the source code. If you link
other code with the library, you must provide complete object files to the
recipients, so that they can relink them with the library after making changes
to the library and recompiling it. And you must show them these terms so they
know their rights.
We protect your rights with a two-step method: (1) we copyright the library,
and (2) we offer you this license, which gives you legal permission to copy,
distribute and/or modify the library.
To protect each distributor, we want to make it very clear that there is no
warranty for the free library. Also, if the library is modified by someone
else and passed on, the recipients should know that what they have is not
the original version, so that the original author's reputation will not be
affected by problems that might be introduced by others.
Finally, software patents pose a constant threat to the existence of any free
program. We wish to make sure that a company cannot effectively restrict the
users of a free program by obtaining a restrictive license from a patent holder.
Therefore, we insist that any patent license obtained for a version of the
library must be consistent with the full freedom of use specified in this
license.
Most GNU software, including some libraries, is covered by the ordinary GNU
General Public License. This license, the GNU Lesser General Public License,
applies to certain designated libraries, and is quite different from the ordinary
General Public License. We use this license for certain libraries in order
to permit linking those libraries into non-free programs.
When a program is linked with a library, whether statically or using a shared
library, the combination of the two is legally speaking a combined work, a
derivative of the original library. The ordinary General Public License therefore
permits such linking only if the entire combination fits its criteria of freedom.
The Lesser General Public License permits more lax criteria for linking other
code with the library.
We call this license the "Lesser" General Public License because it does Less
to protect the user's freedom than the ordinary General Public License. It
also provides other free software developers Less of an advantage over competing
non-free programs. These disadvantages are the reason we use the ordinary
General Public License for many libraries. However, the Lesser license provides
advantages in certain special circumstances.
For example, on rare occasions, there may be a special need to encourage the
widest possible use of a certain library, so that it becomes a de-facto standard.
To achieve this, non-free programs must be allowed to use the library. A more
frequent case is that a free library does the same job as widely used non-free
libraries. In this case, there is little to gain by limiting the free library
to free software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free programs
enables a greater number of people to use a large body of free software. For
example, permission to use the GNU C Library in non-free programs enables
many more people to use the whole GNU operating system, as well as its variant,
the GNU/Linux operating system.
Although the Lesser General Public License is Less protective of the users'
freedom, it does ensure that the user of a program that is linked with the
Library has the freedom and the wherewithal to run that program using a modified
version of the Library.
The precise terms and conditions for copying, distribution and modification
follow. Pay close attention to the difference between a "work based on the
library" and a "work that uses the library". The former contains code derived
from the library, whereas the latter must be combined with the library in
order to run.
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other program
which contains a notice placed by the copyright holder or other authorized
party saying it may be distributed under the terms of this Lesser General
Public License (also called "this License"). Each licensee is addressed as
"you".
A "library" means a collection of software functions and/or data prepared
so as to be conveniently linked with application programs (which use some
of those functions and data) to form executables.
The "Library", below, refers to any such software library or work which has
been distributed under these terms. A "work based on the Library" means either
the Library or any derivative work under copyright law: that is to say, a
work containing the Library or a portion of it, either verbatim or with modifications
and/or translated straightforwardly into another language. (Hereinafter, translation
is included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for making modifications
to it. For a library, complete source code means all the source code for all
modules it contains, plus any associated interface definition files, plus
the scripts used to control compilation and installation of the library.
Activities other than copying, distribution and modification are not covered
by this License; they are outside its scope. The act of running a program
using the Library is not restricted, and output from such a program is covered
only if its contents constitute a work based on the Library (independent of
the use of the Library in a tool for writing it). Whether that is true depends
on what the Library does and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's complete source
code as you receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice and disclaimer
of warranty; keep intact all the notices that refer to this License and to
the absence of any warranty; and distribute a copy of this License along with
the Library.
You may charge a fee for the physical act of transferring a copy, and you
may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Library or any portion of it,
thus forming a work based on the Library, and copy and distribute such modifications
or work under the terms of Section 1 above, provided that you also meet all
of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices stating that
you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no charge to all
third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a table of
data to be supplied by an application program that uses the facility, other
than as an argument passed when the facility is invoked, then you must make
a good faith effort to ensure that, in the event an application does not supply
such function or table, the facility still operates, and performs whatever
part of its purpose remains meaningful.
(For example, a function in a library to compute square roots has a purpose
that is entirely well-defined independent of the application. Therefore, Subsection
2d requires that any application-supplied function or table used by this function
must be optional: if the application does not supply it, the square root function
must still compute square roots.)
These requirements apply to the modified work as a whole. If identifiable
sections of that work are not derived from the Library, and can be reasonably
considered independent and separate works in themselves, then this License,
and its terms, do not apply to those sections when you distribute them as
separate works. But when you distribute the same sections as part of a whole
which is a work based on the Library, the distribution of the whole must be
on the terms of this License, whose permissions for other licensees extend
to the entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest your
rights to work written entirely by you; rather, the intent is to exercise
the right to control the distribution of derivative or collective works based
on the Library.
In addition, mere aggregation of another work not based on the Library with
the Library (or with a work based on the Library) on a volume of a storage
or distribution medium does not bring the other work under the scope of this
License.
3. You may opt to apply the terms of the ordinary GNU General Public License
instead of this License to a given copy of the Library. To do this, you must
alter all the notices that refer to this License, so that they refer to the
ordinary GNU General Public License, version 2, instead of to this License.
(If a newer version than version 2 of the ordinary GNU General Public License
has appeared, then you can specify that version instead if you wish.) Do not
make any other change in these notices.
Once this change is made in a given copy, it is irreversible for that copy,
so the ordinary GNU General Public License applies to all subsequent copies
and derivative works made from that copy.
This option is useful when you wish to copy part of the code of the Library
into a program that is not a library.
4. You may copy and distribute the Library (or a portion or derivative of
it, under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you accompany it with the complete corresponding
machine-readable source code, which must be distributed under the terms of
Sections 1 and 2 above on a medium customarily used for software interchange.
If distribution of object code is made by offering access to copy from a designated
place, then offering equivalent access to copy the source code from the same
place satisfies the requirement to distribute the source code, even though
third parties are not compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the Library, but
is designed to work with the Library by being compiled or linked with it,
is called a "work that uses the Library". Such a work, in isolation, is not
a derivative work of the Library, and therefore falls outside the scope of
this License.
However, linking a "work that uses the Library" with the Library creates an
executable that is a derivative of the Library (because it contains portions
of the Library), rather than a "work that uses the library". The executable
is therefore covered by this License. Section 6 states terms for distribution
of such executables.
When a "work that uses the Library" uses material from a header file that
is part of the Library, the object code for the work may be a derivative work
of the Library even though the source code is not. Whether this is true is
especially significant if the work can be linked without the Library, or if
the work is itself a library. The threshold for this to be true is not precisely
defined by law.
If such an object file uses only numerical parameters, data structure layouts
and accessors, and small macros and small inline functions (ten lines or less
in length), then the use of the object file is unrestricted, regardless of
whether it is legally a derivative work. (Executables containing this object
code plus portions of the Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may distribute
the object code for the work under the terms of Section 6. Any executables
containing that work also fall under Section 6, whether or not they are linked
directly with the Library itself.
6. As an exception to the Sections above, you may also combine or link a "work
that uses the Library" with the Library to produce a work containing portions
of the Library, and distribute that work under terms of your choice, provided
that the terms permit modification of the work for the customer's own use
and reverse engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the Library
is used in it and that the Library and its use are covered by this License.
You must supply a copy of this License. If the work during execution displays
copyright notices, you must include the copyright notice for the Library among
them, as well as a reference directing the user to the copy of this License.
Also, you must do one of these things:
a) Accompany the work with the complete corresponding machine-readable source
code for the Library including whatever changes were used in the work (which
must be distributed under Sections 1 and 2 above); and, if the work is an
executable linked with the Library, with the complete machine-readable "work
that uses the Library", as object code and/or source code, so that the user
can modify the Library and then relink to produce a modified executable containing
the modified Library. (It is understood that the user who changes the contents
of definitions files in the Library will not necessarily be able to recompile
the application to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the Library. A
suitable mechanism is one that (1) uses at run time a copy of the library
already present on the user's computer system, rather than copying library
functions into the executable, and (2) will operate properly with a modified
version of the library, if the user installs one, as long as the modified
version is interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at least three years,
to give the same user the materials specified in Subsection 6a, above, for
a charge no more than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy from a designated
place, offer equivalent access to copy the above specified materials from
the same place.
e) Verify that the user has already received a copy of these materials or
that you have already sent this user a copy.
For an executable, the required form of the "work that uses the Library" must
include any data and utility programs needed for reproducing the executable
from it. However, as a special exception, the materials to be distributed
need not include anything that is normally distributed (in either source or
binary form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component itself
accompanies the executable.
It may happen that this requirement contradicts the license restrictions of
other proprietary libraries that do not normally accompany the operating system.
Such a contradiction means you cannot use both them and the Library together
in an executable that you distribute.
7. You may place library facilities that are a work based on the Library side-by-side
in a single library together with other library facilities not covered by
this License, and distribute such a combined library, provided that the separate
distribution of the work based on the Library and of the other library facilities
is otherwise permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work based on the
Library, uncombined with any other library facilities. This must be distributed
under the terms of the Sections above.
b) Give prominent notice with the combined library of the fact that part of
it is a work based on the Library, and explaining where to find the accompanying
uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute the Library
except as expressly provided under this License. Any attempt otherwise to
copy, modify, sublicense, link with, or distribute the Library is void, and
will automatically terminate your rights under this License. However, parties
who have received copies, or rights, from you under this License will not
have their licenses terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not signed
it. However, nothing else grants you permission to modify or distribute the
Library or its derivative works. These actions are prohibited by law if you
do not accept this License. Therefore, by modifying or distributing the Library
(or any work based on the Library), you indicate your acceptance of this License
to do so, and all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the Library),
the recipient automatically receives a license from the original licensor
to copy, distribute, link with or modify the Library subject to these terms
and conditions. You may not impose any further restrictions on the recipients'
exercise of the rights granted herein. You are not responsible for enforcing
compliance by third parties with this License.
11. If, as a consequence of a court judgment or allegation of patent infringement
or for any other reason (not limited to patent issues), conditions are imposed
on you (whether by court order, agreement or otherwise) that contradict the
conditions of this License, they do not excuse you from the conditions of
this License. If you cannot distribute so as to satisfy simultaneously your
obligations under this License and any other pertinent obligations, then as
a consequence you may not distribute the Library at all. For example, if a
patent license would not permit royalty-free redistribution of the Library
by all those who receive copies directly or indirectly through you, then the
only way you could satisfy both it and this License would be to refrain entirely
from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any patents
or other property right claims or to contest validity of any such claims;
this section has the sole purpose of protecting the integrity of the free
software distribution system which is implemented by public license practices.
Many people have made generous contributions to the wide range of software
distributed through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing to
distribute software through any other system and a licensee cannot impose
that choice.
This section is intended to make thoroughly clear what is believed to be a
consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in certain
countries either by patents or by copyrighted interfaces, the original copyright
holder who places the Library under this License may add an explicit geographical
distribution limitation excluding those countries, so that distribution is
permitted only in or among countries not thus excluded. In such case, this
License incorporates the limitation as if written in the body of this License.
13. The Free Software Foundation may publish revised and/or new versions of
the Lesser General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to address
new problems or concerns.
Each version is given a distinguishing version number. If the Library specifies
a version number of this License which applies to it and "any later version",
you have the option of following the terms and conditions either of that version
or of any later version published by the Free Software Foundation. If the
Library does not specify a license version number, you may choose any version
ever published by the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free programs
whose distribution conditions are incompatible with these, write to the author
to ask for permission. For software which is copyrighted by the Free Software
Foundation, write to the Free Software Foundation; we sometimes make exceptions
for this. Our decision will be guided by the two goals of preserving the free
status of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR
THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE
STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY
"AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE
OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE
THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE
OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA
OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES
OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH
HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest possible
use to the public, we recommend making it free software that everyone can
redistribute and change. You can do so by permitting redistribution under
these terms (or, alternatively, under the terms of the ordinary General Public
License).
To apply these terms, attach the following notices to the library. It is safest
to attach them to the start of each source file to most effectively convey
the exclusion of warranty; and each file should have at least the "copyright"
line and a pointer to where the full notice is found.
< one line to give the library's name and an idea of what it does. >
Copyright (C) < year > < name of author >
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free
Software Foundation; either version 2.1 of the License, or (at your option)
any later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
You should have received a copy of the GNU Lesser General Public License along
with this library; if not, write to the Free Software Foundation, Inc., 51
Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information
on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your school,
if any, to sign a "copyright disclaimer" for the library, if necessary. Here
is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in
the library `Frob' (a library for tweaking knobs) written
by James Random Hacker.
< signature of Ty Coon > , 1 April 1990
Ty Coon, President of Vice
That's all there is to it!
@@ -0,0 +1,468 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies of this license
document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts as the
successor of the GNU Library Public License, version 2, hence the version
number 2.1.]
Preamble
The licenses for most software are designed to take away your freedom to share
and change it. By contrast, the GNU General Public Licenses are intended to
guarantee your freedom to share and change free software--to make sure the
software is free for all its users.
This license, the Lesser General Public License, applies to some specially
designated software packages--typically libraries--of the Free Software Foundation
and other authors who decide to use it. You can use it too, but we suggest
you first think carefully about whether this license or the ordinary General
Public License is the better strategy to use in any particular case, based
on the explanations below.
When we speak of free software, we are referring to freedom of use, not price.
Our General Public Licenses are designed to make sure that you have the freedom
to distribute copies of free software (and charge for this service if you
wish); that you receive source code or can get it if you want it; that you
can change the software and use pieces of it in new free programs; and that
you are informed that you can do these things.
To protect your rights, we need to make restrictions that forbid distributors
to deny you these rights or to ask you to surrender these rights. These restrictions
translate to certain responsibilities for you if you distribute copies of
the library or if you modify it.
For example, if you distribute copies of the library, whether gratis or for
a fee, you must give the recipients all the rights that we gave you. You must
make sure that they, too, receive or can get the source code. If you link
other code with the library, you must provide complete object files to the
recipients, so that they can relink them with the library after making changes
to the library and recompiling it. And you must show them these terms so they
know their rights.
We protect your rights with a two-step method: (1) we copyright the library,
and (2) we offer you this license, which gives you legal permission to copy,
distribute and/or modify the library.
To protect each distributor, we want to make it very clear that there is no
warranty for the free library. Also, if the library is modified by someone
else and passed on, the recipients should know that what they have is not
the original version, so that the original author's reputation will not be
affected by problems that might be introduced by others.
Finally, software patents pose a constant threat to the existence of any free
program. We wish to make sure that a company cannot effectively restrict the
users of a free program by obtaining a restrictive license from a patent holder.
Therefore, we insist that any patent license obtained for a version of the
library must be consistent with the full freedom of use specified in this
license.
Most GNU software, including some libraries, is covered by the ordinary GNU
General Public License. This license, the GNU Lesser General Public License,
applies to certain designated libraries, and is quite different from the ordinary
General Public License. We use this license for certain libraries in order
to permit linking those libraries into non-free programs.
When a program is linked with a library, whether statically or using a shared
library, the combination of the two is legally speaking a combined work, a
derivative of the original library. The ordinary General Public License therefore
permits such linking only if the entire combination fits its criteria of freedom.
The Lesser General Public License permits more lax criteria for linking other
code with the library.
We call this license the "Lesser" General Public License because it does Less
to protect the user's freedom than the ordinary General Public License. It
also provides other free software developers Less of an advantage over competing
non-free programs. These disadvantages are the reason we use the ordinary
General Public License for many libraries. However, the Lesser license provides
advantages in certain special circumstances.
For example, on rare occasions, there may be a special need to encourage the
widest possible use of a certain library, so that it becomes a de-facto standard.
To achieve this, non-free programs must be allowed to use the library. A more
frequent case is that a free library does the same job as widely used non-free
libraries. In this case, there is little to gain by limiting the free library
to free software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free programs
enables a greater number of people to use a large body of free software. For
example, permission to use the GNU C Library in non-free programs enables
many more people to use the whole GNU operating system, as well as its variant,
the GNU/Linux operating system.
Although the Lesser General Public License is Less protective of the users'
freedom, it does ensure that the user of a program that is linked with the
Library has the freedom and the wherewithal to run that program using a modified
version of the Library.
The precise terms and conditions for copying, distribution and modification
follow. Pay close attention to the difference between a "work based on the
library" and a "work that uses the library". The former contains code derived
from the library, whereas the latter must be combined with the library in
order to run.
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other program
which contains a notice placed by the copyright holder or other authorized
party saying it may be distributed under the terms of this Lesser General
Public License (also called "this License"). Each licensee is addressed as
"you".
A "library" means a collection of software functions and/or data prepared
so as to be conveniently linked with application programs (which use some
of those functions and data) to form executables.
The "Library", below, refers to any such software library or work which has
been distributed under these terms. A "work based on the Library" means either
the Library or any derivative work under copyright law: that is to say, a
work containing the Library or a portion of it, either verbatim or with modifications
and/or translated straightforwardly into another language. (Hereinafter, translation
is included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for making modifications
to it. For a library, complete source code means all the source code for all
modules it contains, plus any associated interface definition files, plus
the scripts used to control compilation and installation of the library.
Activities other than copying, distribution and modification are not covered
by this License; they are outside its scope. The act of running a program
using the Library is not restricted, and output from such a program is covered
only if its contents constitute a work based on the Library (independent of
the use of the Library in a tool for writing it). Whether that is true depends
on what the Library does and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's complete source
code as you receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice and disclaimer
of warranty; keep intact all the notices that refer to this License and to
the absence of any warranty; and distribute a copy of this License along with
the Library.
You may charge a fee for the physical act of transferring a copy, and you
may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Library or any portion of it,
thus forming a work based on the Library, and copy and distribute such modifications
or work under the terms of Section 1 above, provided that you also meet all
of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices stating that
you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no charge to all
third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a table of
data to be supplied by an application program that uses the facility, other
than as an argument passed when the facility is invoked, then you must make
a good faith effort to ensure that, in the event an application does not supply
such function or table, the facility still operates, and performs whatever
part of its purpose remains meaningful.
(For example, a function in a library to compute square roots has a purpose
that is entirely well-defined independent of the application. Therefore, Subsection
2d requires that any application-supplied function or table used by this function
must be optional: if the application does not supply it, the square root function
must still compute square roots.)
These requirements apply to the modified work as a whole. If identifiable
sections of that work are not derived from the Library, and can be reasonably
considered independent and separate works in themselves, then this License,
and its terms, do not apply to those sections when you distribute them as
separate works. But when you distribute the same sections as part of a whole
which is a work based on the Library, the distribution of the whole must be
on the terms of this License, whose permissions for other licensees extend
to the entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest your
rights to work written entirely by you; rather, the intent is to exercise
the right to control the distribution of derivative or collective works based
on the Library.
In addition, mere aggregation of another work not based on the Library with
the Library (or with a work based on the Library) on a volume of a storage
or distribution medium does not bring the other work under the scope of this
License.
3. You may opt to apply the terms of the ordinary GNU General Public License
instead of this License to a given copy of the Library. To do this, you must
alter all the notices that refer to this License, so that they refer to the
ordinary GNU General Public License, version 2, instead of to this License.
(If a newer version than version 2 of the ordinary GNU General Public License
has appeared, then you can specify that version instead if you wish.) Do not
make any other change in these notices.
Once this change is made in a given copy, it is irreversible for that copy,
so the ordinary GNU General Public License applies to all subsequent copies
and derivative works made from that copy.
This option is useful when you wish to copy part of the code of the Library
into a program that is not a library.
4. You may copy and distribute the Library (or a portion or derivative of
it, under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you accompany it with the complete corresponding
machine-readable source code, which must be distributed under the terms of
Sections 1 and 2 above on a medium customarily used for software interchange.
If distribution of object code is made by offering access to copy from a designated
place, then offering equivalent access to copy the source code from the same
place satisfies the requirement to distribute the source code, even though
third parties are not compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the Library, but
is designed to work with the Library by being compiled or linked with it,
is called a "work that uses the Library". Such a work, in isolation, is not
a derivative work of the Library, and therefore falls outside the scope of
this License.
However, linking a "work that uses the Library" with the Library creates an
executable that is a derivative of the Library (because it contains portions
of the Library), rather than a "work that uses the library". The executable
is therefore covered by this License. Section 6 states terms for distribution
of such executables.
When a "work that uses the Library" uses material from a header file that
is part of the Library, the object code for the work may be a derivative work
of the Library even though the source code is not. Whether this is true is
especially significant if the work can be linked without the Library, or if
the work is itself a library. The threshold for this to be true is not precisely
defined by law.
If such an object file uses only numerical parameters, data structure layouts
and accessors, and small macros and small inline functions (ten lines or less
in length), then the use of the object file is unrestricted, regardless of
whether it is legally a derivative work. (Executables containing this object
code plus portions of the Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may distribute
the object code for the work under the terms of Section 6. Any executables
containing that work also fall under Section 6, whether or not they are linked
directly with the Library itself.
6. As an exception to the Sections above, you may also combine or link a "work
that uses the Library" with the Library to produce a work containing portions
of the Library, and distribute that work under terms of your choice, provided
that the terms permit modification of the work for the customer's own use
and reverse engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the Library
is used in it and that the Library and its use are covered by this License.
You must supply a copy of this License. If the work during execution displays
copyright notices, you must include the copyright notice for the Library among
them, as well as a reference directing the user to the copy of this License.
Also, you must do one of these things:
a) Accompany the work with the complete corresponding machine-readable source
code for the Library including whatever changes were used in the work (which
must be distributed under Sections 1 and 2 above); and, if the work is an
executable linked with the Library, with the complete machine-readable "work
that uses the Library", as object code and/or source code, so that the user
can modify the Library and then relink to produce a modified executable containing
the modified Library. (It is understood that the user who changes the contents
of definitions files in the Library will not necessarily be able to recompile
the application to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the Library. A
suitable mechanism is one that (1) uses at run time a copy of the library
already present on the user's computer system, rather than copying library
functions into the executable, and (2) will operate properly with a modified
version of the library, if the user installs one, as long as the modified
version is interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at least three years,
to give the same user the materials specified in Subsection 6a, above, for
a charge no more than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy from a designated
place, offer equivalent access to copy the above specified materials from
the same place.
e) Verify that the user has already received a copy of these materials or
that you have already sent this user a copy.
For an executable, the required form of the "work that uses the Library" must
include any data and utility programs needed for reproducing the executable
from it. However, as a special exception, the materials to be distributed
need not include anything that is normally distributed (in either source or
binary form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component itself
accompanies the executable.
It may happen that this requirement contradicts the license restrictions of
other proprietary libraries that do not normally accompany the operating system.
Such a contradiction means you cannot use both them and the Library together
in an executable that you distribute.
7. You may place library facilities that are a work based on the Library side-by-side
in a single library together with other library facilities not covered by
this License, and distribute such a combined library, provided that the separate
distribution of the work based on the Library and of the other library facilities
is otherwise permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work based on the
Library, uncombined with any other library facilities. This must be distributed
under the terms of the Sections above.
b) Give prominent notice with the combined library of the fact that part of
it is a work based on the Library, and explaining where to find the accompanying
uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute the Library
except as expressly provided under this License. Any attempt otherwise to
copy, modify, sublicense, link with, or distribute the Library is void, and
will automatically terminate your rights under this License. However, parties
who have received copies, or rights, from you under this License will not
have their licenses terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not signed
it. However, nothing else grants you permission to modify or distribute the
Library or its derivative works. These actions are prohibited by law if you
do not accept this License. Therefore, by modifying or distributing the Library
(or any work based on the Library), you indicate your acceptance of this License
to do so, and all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the Library),
the recipient automatically receives a license from the original licensor
to copy, distribute, link with or modify the Library subject to these terms
and conditions. You may not impose any further restrictions on the recipients'
exercise of the rights granted herein. You are not responsible for enforcing
compliance by third parties with this License.
11. If, as a consequence of a court judgment or allegation of patent infringement
or for any other reason (not limited to patent issues), conditions are imposed
on you (whether by court order, agreement or otherwise) that contradict the
conditions of this License, they do not excuse you from the conditions of
this License. If you cannot distribute so as to satisfy simultaneously your
obligations under this License and any other pertinent obligations, then as
a consequence you may not distribute the Library at all. For example, if a
patent license would not permit royalty-free redistribution of the Library
by all those who receive copies directly or indirectly through you, then the
only way you could satisfy both it and this License would be to refrain entirely
from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any patents
or other property right claims or to contest validity of any such claims;
this section has the sole purpose of protecting the integrity of the free
software distribution system which is implemented by public license practices.
Many people have made generous contributions to the wide range of software
distributed through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing to
distribute software through any other system and a licensee cannot impose
that choice.
This section is intended to make thoroughly clear what is believed to be a
consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in certain
countries either by patents or by copyrighted interfaces, the original copyright
holder who places the Library under this License may add an explicit geographical
distribution limitation excluding those countries, so that distribution is
permitted only in or among countries not thus excluded. In such case, this
License incorporates the limitation as if written in the body of this License.
13. The Free Software Foundation may publish revised and/or new versions of
the Lesser General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to address
new problems or concerns.
Each version is given a distinguishing version number. If the Library specifies
a version number of this License which applies to it and "any later version",
you have the option of following the terms and conditions either of that version
or of any later version published by the Free Software Foundation. If the
Library does not specify a license version number, you may choose any version
ever published by the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free programs
whose distribution conditions are incompatible with these, write to the author
to ask for permission. For software which is copyrighted by the Free Software
Foundation, write to the Free Software Foundation; we sometimes make exceptions
for this. Our decision will be guided by the two goals of preserving the free
status of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR
THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE
STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY
"AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE
OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE
THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE
OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA
OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES
OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH
HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest possible
use to the public, we recommend making it free software that everyone can
redistribute and change. You can do so by permitting redistribution under
these terms (or, alternatively, under the terms of the ordinary General Public
License).
To apply these terms, attach the following notices to the library. It is safest
to attach them to the start of each source file to most effectively convey
the exclusion of warranty; and each file should have at least the "copyright"
line and a pointer to where the full notice is found.
<one line to give the library's name and an idea of what it does.>
Copyright (C) <year> <name of author>
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free
Software Foundation; either version 2.1 of the License, or (at your option)
any later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
You should have received a copy of the GNU Lesser General Public License along
with this library; if not, write to the Free Software Foundation, Inc., 51
Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your school,
if any, to sign a "copyright disclaimer" for the library, if necessary. Here
is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in
the library `Frob' (a library for tweaking knobs) written
by James Random Hacker.
< signature of Ty Coon > , 1 April 1990
Ty Coon, President of Vice
That's all there is to it!
@@ -0,0 +1,163 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies of this license
document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates the terms
and conditions of version 3 of the GNU General Public License, supplemented
by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser General
Public License, and the "GNU GPL" refers to version 3 of the GNU General Public
License.
"The Library" refers to a covered work governed by this License, other than
an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided by the
Library, but which is not otherwise based on the Library. Defining a subclass
of a class defined by the Library is deemed a mode of using an interface provided
by the Library.
A "Combined Work" is a work produced by combining or linking an Application
with the Library. The particular version of the Library with which the Combined
Work was made is also called the "Linked Version".
The "Minimal Corresponding Source" for a Combined Work means the Corresponding
Source for the Combined Work, excluding any source code for portions of the
Combined Work that, considered in isolation, are based on the Application,
and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the object
code and/or source code for the Application, including any data and utility
programs needed for reproducing the Combined Work from the Application, but
excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License without
being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a facility
refers to a function or data to be supplied by an Application that uses the
facility (other than as an argument passed when the facility is invoked),
then you may convey a copy of the modified version:
a) under this License, provided that you make a good faith effort to ensure
that, in the event an Application does not supply the function or data, the
facility still operates, and performs whatever part of its purpose remains
meaningful, or
b) under the GNU GPL, with none of the additional permissions of this License
applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from a header
file that is part of the Library. You may convey such object code under terms
of your choice, provided that, if the incorporated material is not limited
to numerical parameters, data structure layouts and accessors, or small macros,
inline functions and templates (ten or fewer lines in length), you do both
of the following:
a) Give prominent notice with each copy of the object code that the Library
is used in it and that the Library and its use are covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that, taken together,
effectively do not restrict modification of the portions of the Library contained
in the Combined Work and reverse engineering for debugging such modifications,
if you also do each of the following:
a) Give prominent notice with each copy of the Combined Work that the Library
is used in it and that the Library and its use are covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during execution, include
the copyright notice for the Library among these notices, as well as a reference
directing the user to the copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this License,
and the Corresponding Application Code in a form suitable for, and under terms
that permit, the user to recombine or relink the Application with a modified
version of the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying Corresponding Source.
1) Use a suitable shared library mechanism for linking with the Library. A
suitable mechanism is one that (a) uses at run time a copy of the Library
already present on the user's computer system, and (b) will operate properly
with a modified version of the Library that is interface-compatible with the
Linked Version.
e) Provide Installation Information, but only if you would otherwise be required
to provide such information under section 6 of the GNU GPL, and only to the
extent that such information is necessary to install and execute a modified
version of the Combined Work produced by recombining or relinking the Application
with a modified version of the Linked Version. (If you use option 4d0, the
Installation Information must accompany the Minimal Corresponding Source and
Corresponding Application Code. If you use option 4d1, you must provide the
Installation Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the Library side
by side in a single library together with other library facilities that are
not Applications and are not covered by this License, and convey such a combined
library under terms of your choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based on the
Library, uncombined with any other library facilities, conveyed under the
terms of this License.
b) Give prominent notice with the combined library that part of it is a work
based on the Library, and explaining where to find the accompanying uncombined
form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions of the
GNU Lesser General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to address
new problems or concerns.
Each version is given a distinguishing version number. If the Library as you
received it specifies that a certain numbered version of the GNU Lesser General
Public License "or any later version" applies to it, you have the option of
following the terms and conditions either of that published version or of
any later version published by the Free Software Foundation. If the Library
as you received it does not specify a version number of the GNU Lesser General
Public License, you may choose any version of the GNU Lesser General Public
License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide whether
future versions of the GNU Lesser General Public License shall apply, that
proxy's public statement of acceptance of any version is permanent authorization
for you to choose that version for the Library.
@@ -0,0 +1,163 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies of this license
document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates the terms
and conditions of version 3 of the GNU General Public License, supplemented
by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser General
Public License, and the "GNU GPL" refers to version 3 of the GNU General Public
License.
"The Library" refers to a covered work governed by this License, other than
an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided by the
Library, but which is not otherwise based on the Library. Defining a subclass
of a class defined by the Library is deemed a mode of using an interface provided
by the Library.
A "Combined Work" is a work produced by combining or linking an Application
with the Library. The particular version of the Library with which the Combined
Work was made is also called the "Linked Version".
The "Minimal Corresponding Source" for a Combined Work means the Corresponding
Source for the Combined Work, excluding any source code for portions of the
Combined Work that, considered in isolation, are based on the Application,
and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the object
code and/or source code for the Application, including any data and utility
programs needed for reproducing the Combined Work from the Application, but
excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License without
being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a facility
refers to a function or data to be supplied by an Application that uses the
facility (other than as an argument passed when the facility is invoked),
then you may convey a copy of the modified version:
a) under this License, provided that you make a good faith effort to ensure
that, in the event an Application does not supply the function or data, the
facility still operates, and performs whatever part of its purpose remains
meaningful, or
b) under the GNU GPL, with none of the additional permissions of this License
applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from a header
file that is part of the Library. You may convey such object code under terms
of your choice, provided that, if the incorporated material is not limited
to numerical parameters, data structure layouts and accessors, or small macros,
inline functions and templates (ten or fewer lines in length), you do both
of the following:
a) Give prominent notice with each copy of the object code that the Library
is used in it and that the Library and its use are covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that, taken together,
effectively do not restrict modification of the portions of the Library contained
in the Combined Work and reverse engineering for debugging such modifications,
if you also do each of the following:
a) Give prominent notice with each copy of the Combined Work that the Library
is used in it and that the Library and its use are covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during execution, include
the copyright notice for the Library among these notices, as well as a reference
directing the user to the copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this License,
and the Corresponding Application Code in a form suitable for, and under terms
that permit, the user to recombine or relink the Application with a modified
version of the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying Corresponding Source.
1) Use a suitable shared library mechanism for linking with the Library. A
suitable mechanism is one that (a) uses at run time a copy of the Library
already present on the user's computer system, and (b) will operate properly
with a modified version of the Library that is interface-compatible with the
Linked Version.
e) Provide Installation Information, but only if you would otherwise be required
to provide such information under section 6 of the GNU GPL, and only to the
extent that such information is necessary to install and execute a modified
version of the Combined Work produced by recombining or relinking the Application
with a modified version of the Linked Version. (If you use option 4d0, the
Installation Information must accompany the Minimal Corresponding Source and
Corresponding Application Code. If you use option 4d1, you must provide the
Installation Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the Library side
by side in a single library together with other library facilities that are
not Applications and are not covered by this License, and convey such a combined
library under terms of your choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based on the
Library, uncombined with any other library facilities, conveyed under the
terms of this License.
b) Give prominent notice with the combined library that part of it is a work
based on the Library, and explaining where to find the accompanying uncombined
form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions of the
GNU Lesser General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to address
new problems or concerns.
Each version is given a distinguishing version number. If the Library as you
received it specifies that a certain numbered version of the GNU Lesser General
Public License "or any later version" applies to it, you have the option of
following the terms and conditions either of that published version or of
any later version published by the Free Software Foundation. If the Library
as you received it does not specify a version number of the GNU Lesser General
Public License, you may choose any version of the GNU Lesser General Public
License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide whether
future versions of the GNU Lesser General Public License shall apply, that
proxy's public statement of acceptance of any version is permanent authorization
for you to choose that version for the Library.
@@ -0,0 +1,12 @@
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the license or (at your option) any later version
that is accepted by the membership of KDE e.V. (or its successor
approved by the membership of KDE e.V.), which shall act as a
proxy as defined in Section 6 of version 3 of the license.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
@@ -0,0 +1,14 @@
# KWidgetsAddons
Large set of desktop widgets
## Introduction
This repository contains add-on widgets and classes for applications
that use the Qt Widgets module. If you are porting applications from
KDE Platform 4 "kdeui" library, you will find many of its classes here.
Provided are action classes that can be added to toolbars or menus,
a wide range of widgets for selecting characters, fonts, colors,
actions, dates and times, or MIME types, as well as platform-aware
dialogs for configuration pages, message boxes, and password requests.
@@ -0,0 +1,43 @@
include(ECMAddTests)
find_package(Qt6 ${REQUIRED_QT_VERSION} CONFIG REQUIRED Test)
ecm_add_tests(
kacceleratormanagertest.cpp
kcharselect_unittest.cpp
kcollapsiblegroupbox_test.cpp
kcolorbuttontest.cpp
kdatecomboboxtest.cpp
kdatepickerautotest.cpp
kdatepickerpopupautotest.cpp
kdatetimeedittest.cpp
kdualactiontest.cpp
kpixmapsequencewidgettest.cpp
knewpasswordwidgettest.cpp
kselectaction_unittest.cpp
ksqueezedtextlabelautotest.cpp
ktimecomboboxtest.cpp
ktooltipwidgettest.cpp
kmessagewidgetautotest.cpp
kpagedialogautotest.cpp
kpassworddialogautotest.cpp
kpasswordlineedittest.cpp
ksplittercollapserbuttontest.cpp
kmultitabbartest.cpp
ktwofingertaptest.cpp
ktwofingerswipetest.cpp
klineediteventhandlertest.cpp
LINK_LIBRARIES Qt6::Test KF6::WidgetsAddons
)
set (CMAKE_AUTOUIC TRUE)
ecm_add_test(
kcolumnresizertest.cpp
kcolumnresizertest-forms.ui
kcolumnresizertest-grids.ui
kcolumnresizertest-grid-and-form.ui
TEST_NAME kcolumnresizertest
NAME_PREFIX "kwidgetsaddons-"
LINK_LIBRARIES Qt6::Test KF6::WidgetsAddons
)
@@ -0,0 +1,130 @@
/*
This file is part of the KDE libraries
SPDX-FileCopyrightText: 2017 David Faure <faure@kde.org>
SPDX-License-Identifier: LGPL-2.1-or-later
*/
#include <functional>
#include <kacceleratormanager.h>
#include <QMenu>
#include <QPushButton>
#include <QTest>
#define QSL QStringLiteral
static QStringList extractActionTexts(QMenu &menu, std::function<QString(const QAction *)> func)
{
menu.aboutToShow(); // signals are now public in Qt5, how convenient :-)
QStringList ret;
bool lastIsSeparator = false;
const auto menuActions = menu.actions();
for (const QAction *action : menuActions) {
if (action->isSeparator()) {
if (!lastIsSeparator) { // Qt gets rid of duplicate separators, so we should too
ret.append(QStringLiteral("separator"));
}
lastIsSeparator = true;
} else {
lastIsSeparator = false;
if (action->menu()) {
ret.append(QStringLiteral("submenu"));
} else {
const QString text = func(action);
ret.append(text);
}
}
}
return ret;
}
class KAcceleratorManagerTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void initTestCase()
{
}
void testActionTexts_data()
{
QTest::addColumn<QStringList>("initialTexts");
QTest::addColumn<QStringList>("expectedTexts");
QTest::newRow("basic") << QStringList{QSL("Open"), QSL("Close"), QSL("Quit")} << QStringList{QSL("&Open"), QSL("&Close"), QSL("&Quit")};
QTest::newRow("same_first") << QStringList{QSL("Open"), QSL("Close"), QSL("Clone"), QSL("Quit")}
<< QStringList{QSL("&Open"), QSL("&Close"), QSL("C&lone"), QSL("&Quit")};
QTest::newRow("cjk") << QStringList{QSL("Open (&O)"), QSL("Close (&C)"), QSL("Clone (&C)"), QSL("Quit (&Q)")}
<< QStringList{QSL("Open (&O)"), QSL("Close (&C)"), QSL("C&lone (C)"), QSL("Quit (&Q)")};
}
void testActionTexts()
{
// GIVEN
QFETCH(QStringList, initialTexts);
QFETCH(QStringList, expectedTexts);
QMenu menu;
for (const QString &text : std::as_const(initialTexts)) {
menu.addAction(text);
}
// WHEN
KAcceleratorManager::manage(&menu);
// THEN
const QStringList texts = extractActionTexts(menu, &QAction::text);
QCOMPARE(texts, expectedTexts);
}
void testExistingActionsShortcutsAreTakenIntoAccount()
{
std::unique_ptr<QWidget> w(new QWidget());
QPushButton *pb = new QPushButton(QSL("Open"), w.get());
KAcceleratorManager::manage(w.get());
QCOMPARE(pb->text(), QSL("&Open"));
delete pb;
pb = new QPushButton(QSL("Open"), w.get());
QAction *a = new QAction();
a->setShortcut(QSL("Alt+O"));
w->addAction(a);
KAcceleratorManager::manage(w.get());
QCOMPARE(pb->text(), QSL("O&pen"));
}
void testActionIconTexts_data()
{
QTest::addColumn<QStringList>("initialTexts");
QTest::addColumn<QStringList>("expectedTexts");
QTest::newRow("basic") << QStringList{QSL("Open"), QSL("Close"), QSL("Quit")} << QStringList{QSL("Open"), QSL("Close"), QSL("Quit")};
QTest::newRow("same_first") << QStringList{QSL("Open"), QSL("Close"), QSL("Clone"), QSL("Quit")}
<< QStringList{QSL("Open"), QSL("Close"), QSL("Clone"), QSL("Quit")};
QTest::newRow("cjk") << QStringList{QSL("Open (&O)"), QSL("Close (&C)"), QSL("Clone (&C)"), QSL("Quit (&Q)")}
<< QStringList{QSL("Open"), QSL("Close"), QSL("Clone"), QSL("Quit")};
}
void testActionIconTexts()
{
// GIVEN
QFETCH(QStringList, initialTexts);
QFETCH(QStringList, expectedTexts);
QMenu menu;
for (const QString &text : std::as_const(initialTexts)) {
menu.addAction(text);
}
// WHEN
KAcceleratorManager::manage(&menu);
// THEN
const QStringList iconTexts = extractActionTexts(menu, &QAction::iconText);
QCOMPARE(iconTexts, expectedTexts);
}
};
QTEST_MAIN(KAcceleratorManagerTest)
#include "kacceleratormanagertest.moc"
@@ -0,0 +1,51 @@
/*
This file is part of the KDE libraries
SPDX-FileCopyrightText: 2019 David Faure <faure@kde.org>
SPDX-License-Identifier: LGPL-2.1-or-later
*/
#include <kcharselect.h>
#include <QComboBox>
#include <QLineEdit>
#include <QTest>
class KCharSelectTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void initTestCase()
{
}
void createInstance()
{
KCharSelect selector(nullptr, nullptr);
QCOMPARE(selector.displayedCodePoints().count(), 128);
QCOMPARE(selector.currentCodePoint(), 0);
}
void changeBlock()
{
KCharSelect selector(nullptr, nullptr);
QComboBox *blockCombo = selector.findChild<QComboBox *>(QStringLiteral("blockCombo"));
QVERIFY(blockCombo);
blockCombo->setCurrentIndex(1);
QCOMPARE(selector.currentCodePoint(), 128);
}
void search2Chars()
{
KCharSelect selector(nullptr, nullptr);
QLineEdit *searchLineEdit = selector.findChild<QLineEdit *>();
QVERIFY(searchLineEdit);
searchLineEdit->setText(QStringLiteral("pi"));
Q_EMIT searchLineEdit->returnPressed();
QVERIFY(selector.displayedChars().contains(QChar(960))); // 960 == π
}
};
QTEST_MAIN(KCharSelectTest)
#include "kcharselect_unittest.moc"
@@ -0,0 +1,97 @@
/*
This file is part of the KDE frameworks
SPDX-FileCopyrightText: 2016 Ragnar Thomsen <rthomsen6@gmail.com>
SPDX-License-Identifier: LGPL-2.1-or-later
*/
#include "kcollapsiblegroupbox_test.h"
#include <KCollapsibleGroupBox>
#include <QCheckBox>
#include <QDialog>
#include <QLabel>
#include <QLineEdit>
#include <QTest>
#include <QVBoxLayout>
QTEST_MAIN(KCollapsibleGroupBoxTest)
void KCollapsibleGroupBoxTest::testDestructorCrash()
{
// The unittest does not crash the first time,
// so we run it twice.
int i = 0;
while (i != 2) {
QDialog *dlg = new QDialog(nullptr);
QVBoxLayout *mainvlayout = new QVBoxLayout(dlg);
KCollapsibleGroupBox *collapsible = new KCollapsibleGroupBox(dlg);
collapsible->setTitle(QStringLiteral("A test KCollapsibleGroupBox"));
QVBoxLayout *collapsiblevlayout = new QVBoxLayout(collapsible);
QLabel *lbl = new QLabel(QStringLiteral("A test label."), collapsible);
collapsiblevlayout->addWidget(lbl);
collapsible->expand();
mainvlayout->addWidget(collapsible);
connect(dlg, &QDialog::finished, dlg, &QObject::deleteLater);
dlg->open();
QVERIFY(collapsible);
// If waiting for less than ~500ms the test crashes every time.
// Not waiting or waiting for more than ~500ms is ok.
// Using qSleep(400) does NOT provoke the crash.
QTest::qWait(400);
dlg->accept();
i++;
}
}
void KCollapsibleGroupBoxTest::testOverrideFocus()
{
KCollapsibleGroupBox collapsible;
QVBoxLayout layout(&collapsible);
QCheckBox checkBox;
QCOMPARE(checkBox.focusPolicy(), Qt::StrongFocus);
layout.addWidget(&checkBox);
// The ChildAdded event is processed asynchronously.
qApp->processEvents();
// Make sure focus policy has been overridden.
collapsible.show();
QVERIFY(checkBox.isVisible());
QCOMPARE(checkBox.focusPolicy(), Qt::NoFocus);
// Make sure focus policy is restored on expand event.
collapsible.expand();
QVERIFY(checkBox.isVisible());
QCOMPARE(checkBox.focusPolicy(), Qt::StrongFocus);
// Make sure focus policy is overridden again on next collapse.
collapsible.collapse();
QVERIFY(checkBox.isVisible());
QCOMPARE(checkBox.focusPolicy(), Qt::NoFocus);
}
void KCollapsibleGroupBoxTest::childShouldGetFocus()
{
KCollapsibleGroupBox collapsible;
auto spinBox = new QLineEdit(&collapsible);
// The ChildAdded event is processed asynchronously.
// This also "simulates" user who manually expands.
qApp->processEvents();
collapsible.expand();
QCOMPARE(spinBox->focusPolicy(), Qt::StrongFocus);
}
#include "moc_kcollapsiblegroupbox_test.cpp"
@@ -0,0 +1,23 @@
/*
This file is part of the KDE frameworks
SPDX-FileCopyrightText: 2016 Ragnar Thomsen <rthomsen6@gmail.com>
SPDX-License-Identifier: LGPL-2.1-or-later
*/
#ifndef KCOLLAPSIBLEGROUPBOXTEST_H
#define KCOLLAPSIBLEGROUPBOXTEST_H
#include <QObject>
class KCollapsibleGroupBoxTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void testDestructorCrash();
void testOverrideFocus();
void childShouldGetFocus();
};
#endif /* KCOLLAPSIBLEGROUPBOXTEST_H */
@@ -0,0 +1,33 @@
/*
SPDX-FileCopyrightText: 2013 Albert Astals Cid <aacid@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include "kcolorbuttontest.h"
#include <QColorDialog>
#include <QTest>
#include <kcolorbutton.h>
#include "windowscheck.h"
QTEST_MAIN(KColorButtonTest)
void KColorButtonTest::testOpenDialog()
{
if (isWindowsCI()) {
QSKIP("GUI Tests on Windows CI are not supported");
}
KColorButton colorButton(Qt::red);
colorButton.show();
QVERIFY(QTest::qWaitForWindowExposed(&colorButton));
QTest::mouseClick(&colorButton, Qt::LeftButton);
QColorDialog *dialog = colorButton.findChild<QColorDialog *>();
QVERIFY(dialog != nullptr);
QVERIFY(QTest::qWaitForWindowExposed(dialog));
QCOMPARE(dialog->currentColor(), QColor(Qt::red));
}
#include "moc_kcolorbuttontest.cpp"
@@ -0,0 +1,20 @@
/*
SPDX-FileCopyrightText: 2013 Albert Astals Cid <aacid@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#ifndef KCOLORBUTTONTEST_H
#define KCOLORBUTTONTEST_H
#include <QObject>
class KColorButtonTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void testOpenDialog();
};
#endif
@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>KColumnResizerTestForms</class>
<widget class="QWidget" name="KColumnResizerTestForms">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>GroupBox</string>
</property>
<layout class="QFormLayout" name="layout1">
<item row="0" column="0">
<widget class="QLabel" name="label1">
<property name="text">
<string>Short:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="widget1"/>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>GroupBox</string>
</property>
<layout class="QFormLayout" name="layout2">
<item row="0" column="0">
<widget class="QLabel" name="label2">
<property name="text">
<string>Some long label:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="widget2"/>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
@@ -0,0 +1,75 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>KColumnResizerTestGridAndForms</class>
<widget class="QWidget" name="KColumnResizerTestGridAndForms">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>GroupBox</string>
</property>
<layout class="QGridLayout" name="layout1">
<item row="0" column="1">
<widget class="QLineEdit" name="widget1"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label1">
<property name="text">
<string>Short:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="checkBox">
<property name="text">
<string>CheckBox</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>PushButton</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>GroupBox</string>
</property>
<layout class="QFormLayout" name="layout2">
<item row="0" column="0">
<widget class="QLabel" name="label2">
<property name="text">
<string>Some long label:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="widget2"/>
</item>
</layout>
</widget>
</item>
</layout>
<zorder>groupBox_2</zorder>
<zorder>groupBox</zorder>
</widget>
<resources/>
<connections/>
</ui>
@@ -0,0 +1,61 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>KColumnResizerTestGrids</class>
<widget class="QWidget" name="KColumnResizerTestGrids">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>GroupBox</string>
</property>
<layout class="QGridLayout" name="layout1">
<item row="0" column="0">
<widget class="QLabel" name="label1">
<property name="text">
<string>Short:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="widget1"/>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>GroupBox</string>
</property>
<layout class="QFormLayout" name="layout2">
<item row="0" column="0">
<widget class="QLabel" name="label2">
<property name="text">
<string>Some long label:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="widget2"/>
</item>
</layout>
</widget>
</item>
</layout>
<zorder>groupBox_2</zorder>
<zorder>groupBox</zorder>
</widget>
<resources/>
<connections/>
</ui>
@@ -0,0 +1,76 @@
/*
This file is part of the KDE frameworks
SPDX-FileCopyrightText: 2014 Aurélien Gâteau <agateau@kde.org>
SPDX-License-Identifier: LGPL-2.1-or-later
*/
#include <kcolumnresizertest.h>
#include <KColumnResizer>
#include "ui_kcolumnresizertest-forms.h"
#include "ui_kcolumnresizertest-grid-and-form.h"
#include "ui_kcolumnresizertest-grids.h"
#include <QTest>
QTEST_MAIN(KColumnResizerTest)
void KColumnResizerTest::test_data()
{
QTest::addColumn<QWidget *>("parent");
QWidget *forms = new QWidget;
Ui::KColumnResizerTestForms().setupUi(forms);
QTest::newRow("forms") << forms;
QWidget *grids = new QWidget;
Ui::KColumnResizerTestGrids().setupUi(grids);
QTest::newRow("grids") << grids;
QWidget *gridAndForm = new QWidget;
Ui::KColumnResizerTestGridAndForms().setupUi(gridAndForm);
QTest::newRow("grid-and-form") << gridAndForm;
}
void KColumnResizerTest::test()
{
// This test checks the x coordinate of the widgets from the column
// immediately after the resized column, rather than checking the width of
// the resized column itself because checking the width of the column cannot
// be done the same way for all layout types.
QFETCH(QWidget *, parent);
QVERIFY(parent);
auto layout1 = parent->findChild<QLayout *>(QStringLiteral("layout1"));
auto layout2 = parent->findChild<QLayout *>(QStringLiteral("layout2"));
auto widget1 = parent->findChild<QWidget *>(QStringLiteral("widget1"));
auto widget2 = parent->findChild<QWidget *>(QStringLiteral("widget2"));
QVERIFY(layout1);
QVERIFY(layout2);
QVERIFY(widget1);
QVERIFY(widget2);
// Show the widget so that geometries are updated
parent->show();
int widget1x = widget1->x();
int widget2x = widget2->x();
QVERIFY(widget1x < widget2x);
auto resizer = new KColumnResizer(parent);
resizer->addWidgetsFromLayout(layout1);
resizer->addWidgetsFromLayout(layout2);
// Wait for resizer to do the work
QCoreApplication::processEvents();
// Now wait for the layout change to propagate
QCoreApplication::processEvents();
QCOMPARE(widget1->x(), widget2x);
QCOMPARE(widget2->x(), widget2x);
delete parent;
}
#include "moc_kcolumnresizertest.cpp"
@@ -0,0 +1,21 @@
/*
This file is part of the KDE frameworks
SPDX-FileCopyrightText: 2014 Aurélien Gâteau <agateau@kde.org>
SPDX-License-Identifier: LGPL-2.1-or-later
*/
#ifndef KCOLUMNRESIZERTEST_H
#define KCOLUMNRESIZERTEST_H
#include <QObject>
class KColumnResizerTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void test_data();
void test();
};
#endif /* KCOLUMNRESIZERTEST_H */
@@ -0,0 +1,253 @@
/*
SPDX-FileCopyrightText: 2011 John Layt <john@layt.net>
SPDX-FileCopyrightText: 2022 g10 Code GmbH
SPDX-FileContributor: Ingo Klöcker <dev@ingo-kloecker.de>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include "kdatecomboboxtest.h"
#include <QDate>
#include "kdatecombobox.h"
#include "kdatepickerpopup.h"
#include <QLineEdit>
#include <QSignalSpy>
#include <QTest>
QTEST_MAIN(KDateComboBoxTest)
#ifndef Q_OS_WIN
void initLocale()
{
setenv("LC_ALL", "en_US.utf-8", 1);
}
Q_CONSTRUCTOR_FUNCTION(initLocale)
#endif
void KDateComboBoxTest::testDefaults()
{
KDateComboBox combo;
QCOMPARE(combo.date(), QDate::currentDate());
// Missing support in QLocale;
// QCOMPARE(m_combo.minimumDate(), KLocale::global()->calendar()->earliestValidDate());
// QCOMPARE(m_combo.maximumDate(), KLocale::global()->calendar()->latestValidDate());
QCOMPARE(combo.isValid(), true);
QCOMPARE(combo.isNull(), false);
QCOMPARE(combo.options(), KDateComboBox::EditDate | KDateComboBox::SelectDate | KDateComboBox::DatePicker | KDateComboBox::DateKeywords);
QCOMPARE(combo.displayFormat(), QLocale::ShortFormat);
}
void KDateComboBoxTest::testValidNull()
{
KDateComboBox combo;
QCOMPARE(combo.isValid(), true);
QCOMPARE(combo.isNull(), false);
combo.setDate(QDate());
QCOMPARE(combo.isValid(), false);
QCOMPARE(combo.isNull(), true);
combo.setDate(QDate(2000, 1, 1));
combo.lineEdit()->setText(QStringLiteral("invalid"));
QCOMPARE(combo.isValid(), false);
QCOMPARE(combo.isNull(), false);
}
void KDateComboBoxTest::testDateRange()
{
KDateComboBox combo;
combo.setDate(QDate(2000, 1, 1));
// Missing support in QLocale;
// QCOMPARE(m_combo.minimumDate(), KLocale::global()->calendar()->earliestValidDate());
// QCOMPARE(m_combo.maximumDate(), KLocale::global()->calendar()->latestValidDate());
QCOMPARE(combo.isValid(), true);
combo.setDateRange(QDate(2001, 1, 1), QDate(2002, 1, 1));
QCOMPARE(combo.minimumDate(), QDate(2001, 1, 1));
QCOMPARE(combo.maximumDate(), QDate(2002, 1, 1));
QCOMPARE(combo.isValid(), false);
combo.setDate(QDate(2003, 1, 1));
QCOMPARE(combo.isValid(), false);
combo.setDate(QDate(2001, 6, 1));
QCOMPARE(combo.isValid(), true);
combo.setDate(QDate(2001, 1, 1));
QCOMPARE(combo.isValid(), true);
combo.setDate(QDate(2002, 1, 1));
QCOMPARE(combo.isValid(), true);
combo.setDate(QDate(2000, 12, 31));
QCOMPARE(combo.isValid(), false);
combo.setDate(QDate(2002, 1, 2));
QCOMPARE(combo.isValid(), false);
combo.setDateRange(QDate(1995, 1, 1), QDate(1990, 1, 1));
QCOMPARE(combo.minimumDate(), QDate(2001, 1, 1));
QCOMPARE(combo.maximumDate(), QDate(2002, 1, 1));
combo.setMinimumDate(QDate(2000, 1, 1));
QCOMPARE(combo.minimumDate(), QDate(2000, 1, 1));
QCOMPARE(combo.maximumDate(), QDate(2002, 1, 1));
combo.setMaximumDate(QDate(2003, 1, 1));
QCOMPARE(combo.minimumDate(), QDate(2000, 1, 1));
QCOMPARE(combo.maximumDate(), QDate(2003, 1, 1));
combo.resetDateRange();
QVERIFY(!combo.minimumDate().isValid());
QVERIFY(!combo.maximumDate().isValid());
// Check functioning when the minimum or maximum date is not already set
combo.setMinimumDate(QDate(2000, 1, 1));
QCOMPARE(combo.minimumDate(), QDate(2000, 1, 1));
QVERIFY(!combo.maximumDate().isValid());
combo.resetMinimumDate();
QVERIFY(!combo.minimumDate().isValid());
QVERIFY(!combo.maximumDate().isValid());
combo.setMaximumDate(QDate(2003, 1, 1));
QVERIFY(!combo.minimumDate().isValid());
QCOMPARE(combo.maximumDate(), QDate(2003, 1, 1));
combo.resetMaximumDate();
QVERIFY(!combo.minimumDate().isValid());
QVERIFY(!combo.maximumDate().isValid());
}
void KDateComboBoxTest::testDateList()
{
KDateComboBox combo;
QMap<QDate, QString> map;
// Test default map
QCOMPARE(combo.dateMap(), map);
// Test basic map
map.clear();
map.insert(QDate(2000, 1, 1), QStringLiteral("New Years Day"));
map.insert(QDate(2000, 1, 2), QString());
map.insert(QDate(2000, 1, 3), QStringLiteral("separator"));
map.insert(QDate(), QStringLiteral("No Date"));
combo.setDateMap(map);
QCOMPARE(combo.dateMap(), map);
}
void KDateComboBoxTest::testOptions()
{
KDateComboBox combo;
auto datePicker = combo.findChild<KDatePickerPopup *>();
QVERIFY(datePicker);
KDateComboBox::Options options = KDateComboBox::EditDate | KDateComboBox::SelectDate | KDateComboBox::DatePicker | KDateComboBox::DateKeywords;
QCOMPARE(combo.options(), options);
QCOMPARE(datePicker->modes(), KDatePickerPopup::DatePicker | KDatePickerPopup::Words);
options = KDateComboBox::EditDate | KDateComboBox::WarnOnInvalid;
combo.setOptions(options);
QCOMPARE(combo.options(), options);
QCOMPARE(datePicker->modes(), 0);
}
void KDateComboBoxTest::testDisplayFormat()
{
KDateComboBox combo;
QLocale::FormatType format = QLocale::ShortFormat;
QCOMPARE(combo.displayFormat(), format);
format = QLocale::NarrowFormat;
combo.setDisplayFormat(format);
QCOMPARE(combo.displayFormat(), format);
}
void KDateComboBoxTest::testSignals()
{
// GIVEN
KDateComboBox combo;
QSignalSpy spyDateEntered(&combo, &KDateComboBox::dateEntered);
QSignalSpy spyDateEdited(&combo, &KDateComboBox::dateEdited);
QSignalSpy spyDateChanged(&combo, &KDateComboBox::dateChanged);
auto clearSpies = [&]() {
spyDateEntered.clear();
spyDateEdited.clear();
spyDateChanged.clear();
};
// WHEN setting a date programmatically
combo.setDate(QDate(2016, 05, 30));
// THEN
QCOMPARE(spyDateEntered.count(), 0);
QCOMPARE(spyDateEdited.count(), 0);
QCOMPARE(spyDateChanged.count(), 1);
clearSpies();
combo.show();
combo.activateWindow();
QVERIFY(QTest::qWaitForWindowActive(&combo));
QCOMPARE(combo.currentText(), QStringLiteral("5/30/2016"));
QCOMPARE(combo.date(), QDate(2016, 5, 30));
// WHEN typing a new day (Home, Del, '4' -> 30 April 2016)
QTest::keyClick(&combo, Qt::Key_Home);
QTest::keyClick(&combo, Qt::Key_Delete);
QTest::keyClick(&combo, Qt::Key_4);
// THEN
QCOMPARE(combo.currentText(), QStringLiteral("4/30/2016"));
QCOMPARE(combo.date(), QDate(2016, 4, 30));
// and losing focus
combo.clearFocus();
// THEN
QCOMPARE(spyDateEdited.count(), 2);
QCOMPARE(spyDateEntered.count(), 1);
QCOMPARE(spyDateChanged.count(), 1);
clearSpies();
// WHEN typing Key_Up
QTest::keyClick(&combo, Qt::Key_Up);
// THEN
QCOMPARE(combo.currentText(), QStringLiteral("5/1/2016"));
QCOMPARE(combo.date(), QDate(2016, 5, 1));
QCOMPARE(spyDateEdited.count(), 0);
QCOMPARE(spyDateEntered.count(), 1);
QCOMPARE(spyDateChanged.count(), 1);
clearSpies();
// WHEN typing a digit ('6' -> 1 june 2016) then Return
QTest::keyClick(&combo, Qt::Key_Home);
QTest::keyClick(&combo, Qt::Key_Delete);
QTest::keyClick(&combo, Qt::Key_6);
QTest::keyClick(&combo, Qt::Key_Return);
// THEN
QCOMPARE(combo.currentText(), QStringLiteral("6/1/2016"));
QCOMPARE(combo.date(), QDate(2016, 6, 1));
QCOMPARE(spyDateEdited.count(), 2);
QCOMPARE(spyDateEntered.count(), 1);
QCOMPARE(spyDateChanged.count(), 1);
clearSpies();
}
void KDateComboBoxTest::testDatePickerIntegration()
{
// GIVEN
KDateComboBox combo;
const QDate minimumDate{2001, 1, 1};
const QDate maximumDate{2106, 1, 1};
combo.setDateRange(minimumDate, maximumDate);
const QDate originalDate{2021, 6, 23};
combo.setDate(originalDate);
// WHEN the date picker emits dateChanged signal with an invalid date
auto datePicker = combo.findChild<KDatePickerPopup *>();
QVERIFY(datePicker);
const QDate dateOutsideTheAllowedRange{1921, 6, 23};
Q_EMIT datePicker->dateChanged(dateOutsideTheAllowedRange);
// THEN the combo still has the original date
QCOMPARE(combo.date(), originalDate);
}
#include "moc_kdatecomboboxtest.cpp"
@@ -0,0 +1,29 @@
/*
SPDX-FileCopyrightText: 2011 John Layt <john@layt.net>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#ifndef KDATECOMBOBOXTEST_H
#define KDATECOMBOBOXTEST_H
#include <QWidget>
class KDateComboBox;
class KDateComboBoxTest : public QWidget
{
Q_OBJECT
private Q_SLOTS:
void testDefaults();
void testValidNull();
void testDateRange();
void testDateList();
void testOptions();
void testDisplayFormat();
void testSignals();
void testDatePickerIntegration();
};
#endif // KDATECOMBOBOXTEST_H
@@ -0,0 +1,107 @@
/*
SPDX-FileCopyrightText: 2022 g10 Code GmbH
SPDX-FileContributor: Ingo Klöcker <dev@ingo-kloecker.de>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include <KDatePicker>
#include <QLineEdit>
#include <QSignalSpy>
#include <QTest>
#ifndef Q_OS_WIN
void initLocale()
{
setenv("LC_ALL", "en_US.utf-8", 1);
}
Q_CONSTRUCTOR_FUNCTION(initLocale)
#endif
class KDatePickerTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void testSubmittingDateInLineEditEmitsOriginalDate()
{
const QDate originalDate{2022, 5, 15};
KDatePicker p{originalDate};
QSignalSpy spyDateEntered(&p, &KDatePicker::dateEntered);
auto lineEdit = p.findChild<QLineEdit *>();
QVERIFY(lineEdit);
QTest::keyClick(lineEdit, Qt::Key_Return);
QCOMPARE(spyDateEntered.count(), 1);
QCOMPARE(spyDateEntered.first().at(0).toDate(), originalDate);
}
void testLineEditShowsDateWith4DigitYear()
{
KDatePicker p;
auto lineEdit = p.findChild<QLineEdit *>();
QVERIFY(lineEdit);
p.setDate(QDate{2022, 5, 15});
QCOMPARE(lineEdit->text(), QStringLiteral("5/15/2022"));
}
void testPickerAcceptsDatesEnteredInMultipleFormats()
{
KDatePicker p;
QSignalSpy spyDateEntered(&p, &KDatePicker::dateEntered);
auto lineEdit = p.findChild<QLineEdit *>();
QVERIFY(lineEdit);
#ifndef Q_OS_WIN
{
// short date format
lineEdit->setText(QStringLiteral("5/15/22"));
QTest::keyClick(lineEdit, Qt::Key_Return);
QCOMPARE(spyDateEntered.count(), 1);
const auto emittedDate = spyDateEntered.first().at(0).toDate();
const QDate expectedDate{2022, 5, 15};
QCOMPARE(emittedDate.day(), expectedDate.day());
QCOMPARE(emittedDate.month(), expectedDate.month());
// we don't expect Qt to guess the correct century of a two digit year
QCOMPARE(emittedDate.year() % 100, expectedDate.year() % 100);
spyDateEntered.clear();
}
#endif
{
// long date format
lineEdit->setText(QStringLiteral("Sunday, May 15, 2022"));
QTest::keyClick(lineEdit, Qt::Key_Return);
QCOMPARE(spyDateEntered.count(), 1);
const auto emittedDate = spyDateEntered.first().at(0).toDate();
const QDate expectedDate{2022, 5, 15};
QCOMPARE(emittedDate, expectedDate);
spyDateEntered.clear();
}
{
// short date format with 4-digit year
lineEdit->setText(QStringLiteral("5/15/2022"));
QTest::keyClick(lineEdit, Qt::Key_Return);
QCOMPARE(spyDateEntered.count(), 1);
const auto emittedDate = spyDateEntered.first().at(0).toDate();
const QDate expectedDate{2022, 5, 15};
QCOMPARE(emittedDate, expectedDate);
spyDateEntered.clear();
}
{
// ISO date format
lineEdit->setText(QStringLiteral("2022-05-15"));
QTest::keyClick(lineEdit, Qt::Key_Return);
QCOMPARE(spyDateEntered.count(), 1);
const auto emittedDate = spyDateEntered.first().at(0).toDate();
const QDate expectedDate{2022, 5, 15};
QCOMPARE(emittedDate, expectedDate);
spyDateEntered.clear();
}
}
};
QTEST_MAIN(KDatePickerTest)
#include "kdatepickerautotest.moc"
@@ -0,0 +1,118 @@
/*
SPDX-FileCopyrightText: 2022 Volker Krause <vkrause@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include <KDatePickerPopup>
#include <QSignalSpy>
#include <QTest>
class KDatePickerPopupTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void testWordActions()
{
KDatePickerPopup p(KDatePickerPopup::DatePicker | KDatePickerPopup::Words | KDatePickerPopup::NoDate);
// picker, 9 words, no date, 2 separators
p.popup(QPoint());
QCOMPARE(p.actions().count(), 13);
p.hide();
p.popup(QPoint());
QCOMPARE(p.actions().count(), 13);
QCOMPARE(p.actions()[2]->data().toDate(), QDate::currentDate().addYears(1));
QCOMPARE(p.actions()[6]->data().toDate(), QDate::currentDate());
QCOMPARE(p.actions()[12]->data().toDate(), QDate());
}
void testModes()
{
KDatePickerPopup p;
QCOMPARE(p.modes(), KDatePickerPopup::DatePicker);
p.popup(QPoint());
QCOMPARE(p.actions().count(), 1); // only the date picker
p.hide();
p.setModes(KDatePickerPopup::NoDate);
p.popup(QPoint());
QCOMPARE(p.actions().count(), 1);
p.hide();
p.setModes(KDatePickerPopup::Words);
p.popup(QPoint());
QCOMPARE(p.actions().count(), 9);
p.hide();
p.setModes(KDatePickerPopup::DatePicker | KDatePickerPopup::NoDate);
p.popup(QPoint());
QCOMPARE(p.actions().count(), 3);
p.hide();
p.setModes(KDatePickerPopup::Words | KDatePickerPopup::NoDate);
p.popup(QPoint());
QCOMPARE(p.actions().count(), 11);
p.hide();
}
void testDateRange()
{
KDatePickerPopup p(KDatePickerPopup::Words);
const auto today = QDate::currentDate();
p.setDateRange(today.addDays(-1), today.addDays(1));
p.popup(QPoint());
QCOMPARE(p.actions().count(), 3);
QCOMPARE(p.actions()[1]->data().toDate(), today);
p.hide();
p.setDateRange(QDate(), today.addDays(1));
p.popup(QPoint());
QCOMPARE(p.actions().count(), 6);
QCOMPARE(p.actions()[1]->data().toDate(), today);
p.hide();
p.setDateRange(today.addDays(-2), {});
p.popup(QPoint());
QCOMPARE(p.actions().count(), 6);
QCOMPARE(p.actions()[4]->data().toDate(), today);
p.hide();
p.setDateRange({}, {});
p.popup(QPoint());
QCOMPARE(p.actions().count(), 9);
p.hide();
}
void testDateMap()
{
KDatePickerPopup p(KDatePickerPopup::Words);
QMap<QDate, QString> m;
m.insert(QDate(1996, 10, 14), QStringLiteral("KDE's birthday"));
m.insert(QDate(1997, 1, 1), QStringLiteral("separator"));
m.insert(QDate(2017, 9, 10), {});
p.setDateMap(m);
p.popup(QPoint());
QCOMPARE(p.actions().count(), 3);
QCOMPARE(p.actions()[0]->data().toDate(), QDate(1996, 10, 14));
QCOMPARE(p.actions()[0]->text(), QStringLiteral("KDE's birthday"));
QCOMPARE(p.actions()[1]->data().toDate(), QDate());
QCOMPARE(p.actions()[1]->isSeparator(), true);
QCOMPARE(p.actions()[2]->data().toDate(), QDate(2017, 9, 10));
QCOMPARE(p.actions()[2]->text().isEmpty(), false);
p.hide();
p.setDateMap({});
p.popup(QPoint());
QCOMPARE(p.actions().count(), 9);
p.hide();
}
};
QTEST_MAIN(KDatePickerPopupTest)
#include "kdatepickerpopupautotest.moc"
@@ -0,0 +1,249 @@
/*
SPDX-FileCopyrightText: 2011 John Layt <john@layt.net>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include "kdatetimeedittest.h"
#include <QAction>
#include <QComboBox>
#include <QDate>
#include <QMenu>
#include "kdatecombobox.h"
#include "kdatetimeedit.h"
#include <QTest>
QTEST_MAIN(KDateTimeEditTest)
void KDateTimeEditTest::testDefaults()
{
m_edit = new KDateTimeEdit(nullptr);
QCOMPARE(m_edit->dateTime(), QDateTime(QDate::currentDate(), QTime(0, 0, 0)));
QCOMPARE(m_edit->date(), QDate::currentDate());
QCOMPARE(m_edit->time(), QTime(0, 0, 0));
// Missing support in QLocale
// QCOMPARE(m_edit->minimumDateTime(), KDateTime(KLocale::global()->calendar()->earliestValidDate(), QTime(0, 0, 0)));
// QCOMPARE(m_edit->maximumDateTime(), KDateTime(KLocale::global()->calendar()->latestValidDate(), QTime(23, 59, 59, 999)));
QCOMPARE(m_edit->isValid(), true);
QCOMPARE(m_edit->isNull(), false);
QCOMPARE(m_edit->options(),
KDateTimeEdit::ShowDate | KDateTimeEdit::EditDate | KDateTimeEdit::SelectDate | KDateTimeEdit::DatePicker | KDateTimeEdit::DateKeywords
| KDateTimeEdit::ShowTime | KDateTimeEdit::EditTime | KDateTimeEdit::SelectTime);
QCOMPARE(m_edit->dateDisplayFormat(), QLocale::ShortFormat);
QCOMPARE(m_edit->timeListInterval(), 15);
QCOMPARE(m_edit->timeDisplayFormat(), QLocale::ShortFormat);
delete m_edit;
}
void KDateTimeEditTest::testValidNull()
{
m_edit = new KDateTimeEdit(nullptr);
QCOMPARE(m_edit->isValid(), true);
QCOMPARE(m_edit->isNull(), false);
m_edit->setDateTime(QDateTime());
QCOMPARE(m_edit->isValid(), false);
QCOMPARE(m_edit->isNull(), true);
delete m_edit;
}
void KDateTimeEditTest::testDateTimeRange()
{
m_edit = new KDateTimeEdit(nullptr);
m_edit->setDateTime(QDateTime(QDate(2000, 1, 1), QTime(12, 0, 0)));
// Missing support in QLocale
// QCOMPARE(m_edit->minimumDateTime(), KDateTime(KLocale::global()->calendar()->earliestValidDate(), QTime(0, 0, 0)));
// QCOMPARE(m_edit->maximumDateTime(), KDateTime(KLocale::global()->calendar()->latestValidDate(), QTime(23, 59, 59, 999)));
QCOMPARE(m_edit->isValid(), true);
m_edit->setDateTimeRange(QDateTime(QDate(2001, 1, 1), QTime(10, 0, 0)), QDateTime(QDate(2002, 1, 1), QTime(20, 0, 0)));
QCOMPARE(m_edit->minimumDateTime(), QDateTime(QDate(2001, 1, 1), QTime(10, 0, 0)));
QCOMPARE(m_edit->maximumDateTime(), QDateTime(QDate(2002, 1, 1), QTime(20, 0, 0)));
QCOMPARE(m_edit->isValid(), false);
m_edit->setDateTime(QDateTime(QDate(2001, 1, 1), QTime(9, 59, 59, 999)));
QCOMPARE(m_edit->isValid(), false);
m_edit->setDateTime(QDateTime(QDate(2001, 1, 1), QTime(10, 0, 0)));
QCOMPARE(m_edit->isValid(), true);
m_edit->setDateTime(QDateTime(QDate(2002, 1, 1), QTime(20, 0, 0, 1)));
QCOMPARE(m_edit->isValid(), false);
m_edit->setDateTime(QDateTime(QDate(2002, 1, 1), QTime(20, 0, 0, 0)));
QCOMPARE(m_edit->isValid(), true);
m_edit->setDateTimeRange(QDateTime(QDate(1995, 1, 1), QTime(10, 0, 0)), QDateTime(QDate(1990, 1, 1), QTime(20, 0, 0)));
QCOMPARE(m_edit->minimumDateTime(), QDateTime(QDate(2001, 1, 1), QTime(10, 0, 0)));
QCOMPARE(m_edit->maximumDateTime(), QDateTime(QDate(2002, 1, 1), QTime(20, 0, 0)));
m_edit->setMinimumDateTime(QDateTime(QDate(2000, 1, 1), QTime(0, 0, 0)));
QCOMPARE(m_edit->minimumDateTime(), QDateTime(QDate(2000, 1, 1), QTime(0, 0, 0)));
QCOMPARE(m_edit->maximumDateTime(), QDateTime(QDate(2002, 1, 1), QTime(20, 0, 0)));
m_edit->setMaximumDateTime(QDateTime(QDate(2003, 1, 1), QTime(0, 0, 0)));
QCOMPARE(m_edit->minimumDateTime(), QDateTime(QDate(2000, 1, 1), QTime(0, 0, 0)));
QCOMPARE(m_edit->maximumDateTime(), QDateTime(QDate(2003, 1, 1), QTime(0, 0, 0)));
delete m_edit;
}
void KDateTimeEditTest::testDateList()
{
m_edit = new KDateTimeEdit(nullptr);
QMap<QDate, QString> map;
// KDateTimeEditTest default map
QCOMPARE(m_edit->dateMap(), map);
// KDateTimeEditTest basic map
map.clear();
map.insert(QDate(2000, 1, 1), QStringLiteral("New Years Day"));
map.insert(QDate(2000, 1, 2), QString());
map.insert(QDate(2000, 1, 3), QStringLiteral("separator"));
map.insert(QDate(), QStringLiteral("No Date"));
m_edit->setDateMap(map);
QCOMPARE(m_edit->dateMap(), map);
delete m_edit;
}
void KDateTimeEditTest::testOptions()
{
m_edit = new KDateTimeEdit(nullptr);
KDateTimeEdit::Options options = KDateTimeEdit::ShowDate | KDateTimeEdit::EditDate | KDateTimeEdit::SelectDate | KDateTimeEdit::DatePicker
| KDateTimeEdit::DateKeywords | KDateTimeEdit::ShowTime | KDateTimeEdit::EditTime | KDateTimeEdit::SelectTime;
QCOMPARE(m_edit->options(), options);
options = KDateTimeEdit::EditDate | KDateTimeEdit::WarnOnInvalid;
m_edit->setOptions(options);
QCOMPARE(m_edit->options(), options);
delete m_edit;
}
void KDateTimeEditTest::testDateDisplayFormat()
{
m_edit = new KDateTimeEdit(nullptr);
QLocale::FormatType format = QLocale::ShortFormat;
QCOMPARE(m_edit->dateDisplayFormat(), format);
format = QLocale::NarrowFormat;
m_edit->setDateDisplayFormat(format);
QCOMPARE(m_edit->dateDisplayFormat(), format);
delete m_edit;
}
void KDateTimeEditTest::testTimeListInterval()
{
m_edit = new KDateTimeEdit();
QCOMPARE(m_edit->timeListInterval(), 15);
m_edit->setTimeListInterval(60);
QCOMPARE(m_edit->timeListInterval(), 60);
delete m_edit;
}
void KDateTimeEditTest::testTimeList()
{
m_edit = new KDateTimeEdit();
QList<QTime> list;
// KDateTimeEditTest default list
QTime thisTime = QTime(0, 0, 0);
for (int i = 0; i < 1440; i = i + 15) {
list << thisTime.addSecs(i * 60);
}
list << QTime(23, 59, 59, 999);
QCOMPARE(m_edit->timeList(), list);
// KDateTimeEditTest basic list
list.clear();
list << QTime(3, 0, 0) << QTime(15, 16, 17);
m_edit->setTimeList(list);
QCOMPARE(m_edit->timeList(), list);
delete m_edit;
}
void KDateTimeEditTest::testTimeDisplayFormat()
{
m_edit = new KDateTimeEdit();
QLocale::FormatType format = QLocale::ShortFormat;
QCOMPARE(m_edit->timeDisplayFormat(), format);
format = QLocale::NarrowFormat;
m_edit->setTimeDisplayFormat(format);
QCOMPARE(m_edit->timeDisplayFormat(), format);
delete m_edit;
}
void KDateTimeEditTest::testCalendarSystem()
{
m_edit = new KDateTimeEdit();
QList<QLocale> calendars;
calendars << QLocale();
QCOMPARE(m_edit->locale(), QLocale());
QCOMPARE(m_edit->calendarLocalesList(), calendars);
m_edit->setLocale(QLocale(QLocale::Hebrew));
QCOMPARE(m_edit->locale(), QLocale(QLocale::Hebrew));
calendars.clear();
calendars.append(QLocale(QLocale::Hebrew));
calendars.append(QLocale(QLocale::Chinese));
m_edit->setCalendarLocalesList(calendars);
QCOMPARE(m_edit->calendarLocalesList(), calendars);
delete m_edit;
}
void KDateTimeEditTest::testTimeSpec()
{
m_edit = new KDateTimeEdit();
QCOMPARE(m_edit->timeZone(), QDateTime::currentDateTime().timeZone());
QList<QTimeZone> zones;
const auto zoneIds = QTimeZone::availableTimeZoneIds();
for (const QByteArray &zoneId : zoneIds) {
zones << QTimeZone(zoneId);
}
QCOMPARE(m_edit->timeZones(), zones);
QTimeZone zone(3600);
m_edit->setTimeZone(zone);
QCOMPARE(m_edit->timeZone(), zone);
zones << zone;
m_edit->setTimeZones(zones);
QCOMPARE(m_edit->timeZones(), zones);
delete m_edit;
}
template<typename T>
static T findVisibleChild(QWidget *parent)
{
const auto children = parent->findChildren<T>();
for (T child : children) {
if (child->isVisible()) {
return child;
}
}
return nullptr;
}
void KDateTimeEditTest::testDateMenu()
{
m_edit = new KDateTimeEdit();
KDateTimeEdit::Options options =
KDateTimeEdit::ShowDate | KDateTimeEdit::EditDate | KDateTimeEdit::SelectDate | KDateTimeEdit::DatePicker | KDateTimeEdit::DateKeywords;
m_edit->setOptions(options);
m_edit->setDate(QDate(2002, 1, 1));
m_edit->show();
QComboBox *combo = findVisibleChild<QComboBox *>(m_edit);
QVERIFY(combo);
combo->showPopup();
QMenu *menu = findVisibleChild<QMenu *>(combo);
QVERIFY(menu);
QAction *nextMonthAction = menu->actions().at(3);
QCOMPARE(nextMonthAction->text(), KDateComboBox::tr("Next Month", "@option next month"));
nextMonthAction->trigger();
QCOMPARE(m_edit->date(), QDate::currentDate().addMonths(1));
}
#include "moc_kdatetimeedittest.cpp"
@@ -0,0 +1,36 @@
/*
SPDX-FileCopyrightText: 2011 John Layt <john@layt.net>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#ifndef KDATETIMEEDITTEST_H
#define KDATETIMEEDITTEST_H
#include <QWidget>
class KDateTimeEdit;
class KDateTimeEditTest : public QWidget
{
Q_OBJECT
private Q_SLOTS:
void testDefaults();
void testValidNull();
void testDateTimeRange();
void testOptions();
void testDateDisplayFormat();
void testDateList();
void testTimeListInterval();
void testTimeList();
void testTimeDisplayFormat();
void testCalendarSystem();
void testTimeSpec();
void testDateMenu();
private:
KDateTimeEdit *m_edit;
};
#endif // KDATECOMBOBOXTEST_H
@@ -0,0 +1,117 @@
/*
This file is part of the KDE libraries
SPDX-FileCopyrightText: 2010 Aurélien Gâteau <agateau@kde.org>
SPDX-License-Identifier: LGPL-2.1-or-later
*/
#include <kdualaction.h>
#include <QSignalSpy>
#include <QTest>
#include "kguiitem.h"
static const QString INACTIVE_TEXT = QStringLiteral("Show Foo");
static const QString ACTIVE_TEXT = QStringLiteral("Hide Foo");
class KDualActionTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void initTestCase()
{
qRegisterMetaType<QAction *>("QAction*");
}
void testSetGuiItem()
{
KDualAction action(nullptr);
action.setInactiveGuiItem(KGuiItem(INACTIVE_TEXT));
action.setActiveGuiItem(KGuiItem(ACTIVE_TEXT));
QCOMPARE(action.inactiveText(), INACTIVE_TEXT);
QCOMPARE(action.activeText(), ACTIVE_TEXT);
QCOMPARE(action.text(), INACTIVE_TEXT);
}
void testSetIconForStates()
{
QIcon icon(QPixmap(16, 16));
QVERIFY(!icon.isNull());
KDualAction action(nullptr);
QVERIFY(action.inactiveIcon().isNull());
QVERIFY(action.activeIcon().isNull());
action.setIconForStates(icon);
QCOMPARE(action.inactiveIcon(), icon);
QCOMPARE(action.activeIcon(), icon);
}
void testSetActive()
{
KDualAction action(INACTIVE_TEXT, ACTIVE_TEXT, nullptr);
QVERIFY(!action.isActive());
QCOMPARE(action.text(), INACTIVE_TEXT);
QSignalSpy activeChangedSpy(&action, &KDualAction::activeChanged);
QSignalSpy activeChangedByUserSpy(&action, &KDualAction::activeChangedByUser);
action.setActive(true);
QVERIFY(action.isActive());
QCOMPARE(action.text(), ACTIVE_TEXT);
QCOMPARE(activeChangedSpy.count(), 1);
QCOMPARE(activeChangedSpy.takeFirst().at(0).toBool(), true);
QCOMPARE(activeChangedByUserSpy.count(), 0);
action.setActive(false);
QVERIFY(!action.isActive());
QCOMPARE(action.text(), INACTIVE_TEXT);
QCOMPARE(activeChangedSpy.count(), 1);
QCOMPARE(activeChangedSpy.takeFirst().at(0).toBool(), false);
QCOMPARE(activeChangedByUserSpy.count(), 0);
}
void testTrigger()
{
KDualAction action(INACTIVE_TEXT, ACTIVE_TEXT, nullptr);
QVERIFY(!action.isActive());
QCOMPARE(action.text(), INACTIVE_TEXT);
QSignalSpy activeChangedSpy(&action, &KDualAction::activeChanged);
QSignalSpy activeChangedByUserSpy(&action, &KDualAction::activeChangedByUser);
action.trigger();
QVERIFY(action.isActive());
QCOMPARE(action.text(), ACTIVE_TEXT);
QCOMPARE(activeChangedSpy.count(), 1);
QCOMPARE(activeChangedSpy.takeFirst().at(0).toBool(), true);
QCOMPARE(activeChangedByUserSpy.count(), 1);
QCOMPARE(activeChangedByUserSpy.takeFirst().at(0).toBool(), true);
action.trigger();
QVERIFY(!action.isActive());
QCOMPARE(action.text(), INACTIVE_TEXT);
QCOMPARE(activeChangedSpy.count(), 1);
QCOMPARE(activeChangedSpy.takeFirst().at(0).toBool(), false);
QCOMPARE(activeChangedByUserSpy.count(), 1);
QCOMPARE(activeChangedByUserSpy.takeFirst().at(0).toBool(), false);
// Turn off autoToggle, nothing should happen
action.setAutoToggle(false);
action.trigger();
QVERIFY(!action.isActive());
QCOMPARE(action.text(), INACTIVE_TEXT);
QCOMPARE(activeChangedSpy.count(), 0);
QCOMPARE(activeChangedByUserSpy.count(), 0);
// Turn on autoToggle, action should change
action.setAutoToggle(true);
action.trigger();
QCOMPARE(action.text(), ACTIVE_TEXT);
QCOMPARE(activeChangedSpy.count(), 1);
QCOMPARE(activeChangedSpy.takeFirst().at(0).toBool(), true);
QCOMPARE(activeChangedByUserSpy.count(), 1);
QCOMPARE(activeChangedByUserSpy.takeFirst().at(0).toBool(), true);
}
};
QTEST_MAIN(KDualActionTest)
#include "kdualactiontest.moc"
@@ -0,0 +1,44 @@
/*
SPDX-FileCopyrightText: 2023 Volker Krause <vkrause@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include "klineediteventhandler.h"
#include <QDialog>
#include <QDialogButtonBox>
#include <QLineEdit>
#include <QObject>
#include <QSignalSpy>
#include <QTest>
class KLineEditEventHandlerTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void testReturnCatching()
{
QDialog dialog;
auto lineEdit = new QLineEdit(&dialog);
auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok, &dialog);
connect(buttonBox, &QDialogButtonBox::accepted, &dialog, &QDialog::accept);
QSignalSpy returnSpy(lineEdit, &QLineEdit::returnPressed);
QSignalSpy dialogSpy(&dialog, &QDialog::accepted);
dialog.show();
QTest::keyPress(lineEdit, Qt::Key_Enter);
QCOMPARE(returnSpy.size(), 1);
QCOMPARE(dialogSpy.size(), 1);
KLineEditEventHandler::catchReturnKey(lineEdit);
dialog.show();
QTest::keyPress(lineEdit, Qt::Key_Enter);
QCOMPARE(returnSpy.size(), 2);
QCOMPARE(dialogSpy.size(), 1);
}
};
QTEST_MAIN(KLineEditEventHandlerTest)
#include "klineediteventhandlertest.moc"
@@ -0,0 +1,249 @@
/*
SPDX-FileCopyrightText: 2014 Dominik Haumann <dhaumann@kde.org>
SPDX-FileCopyrightText: 2017 Friedrich W. H. Kossebau <kossebau@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include "kmessagewidgetautotest.h"
#include <QSignalSpy>
#include <QTest>
#include <kmessagewidget.h>
QTEST_MAIN(KMessageWidgetTest)
// KMessageWidget is currently hardcoded to a 500 ms timeline and default QTimeLine 40 ms update interval
// let's have 7 updates for now, should be save
const int overlappingWaitingTime = 280;
// clang-format off
#define CHECK_FULLY_VISIBLE \
QVERIFY(w.isVisible()); \
QCOMPARE(w.height(), w.sizeHint().height()); \
#define CHECK_FULLY_NOT_VISIBLE \
QCOMPARE(w.height(), 0); \
QVERIFY(!w.isVisible());
// clang-format on
void KMessageWidgetTest::testAnimationSignals()
{
KMessageWidget w(QStringLiteral("Hello world"));
QSignalSpy showSignalsSpy(&w, &KMessageWidget::showAnimationFinished);
QSignalSpy hideSignalsSpy(&w, &KMessageWidget::hideAnimationFinished);
QCOMPARE(showSignalsSpy.count(), 0);
//
// test: showing the message widget should emit showAnimationFinished()
// exactly once after the show animation is finished
//
w.animatedShow();
QTRY_VERIFY(!w.isShowAnimationRunning());
QCOMPARE(showSignalsSpy.count(), 1);
CHECK_FULLY_VISIBLE
//
// test: hiding the message widget should emit hideAnimationFinished()
// exactly once after the show animation is finished
//
w.animatedHide();
QTRY_VERIFY(!w.isHideAnimationRunning());
QCOMPARE(hideSignalsSpy.count(), 1);
CHECK_FULLY_NOT_VISIBLE
}
void KMessageWidgetTest::testShowOnVisible()
{
KMessageWidget w(QStringLiteral("Hello world"));
QSignalSpy showSignalsSpy(&w, &KMessageWidget::showAnimationFinished);
w.show();
CHECK_FULLY_VISIBLE
// test: call show on visible
w.animatedShow();
QTRY_VERIFY(!w.isShowAnimationRunning());
QCOMPARE(showSignalsSpy.count(), 1);
CHECK_FULLY_VISIBLE
}
void KMessageWidgetTest::testHideOnInvisible()
{
KMessageWidget w(QStringLiteral("Hello world"));
QSignalSpy hideSignalsSpy(&w, &KMessageWidget::hideAnimationFinished);
// test: call hide on invisible
w.animatedHide();
QTRY_VERIFY(!w.isHideAnimationRunning());
QCOMPARE(hideSignalsSpy.count(), 1);
QVERIFY(!w.isVisible()); // Not CHECK_FULLY_NOT_VISIBLE because since it was never shown height is not what it would be otherwise
}
void KMessageWidgetTest::testOverlappingShowAndHide_data()
{
QTest::addColumn<bool>("delay");
QTest::newRow("instant") << false;
QTest::newRow("delay") << true;
}
void KMessageWidgetTest::testOverlappingShowAndHide()
{
QFETCH(bool, delay);
KMessageWidget w(QStringLiteral("Hello world"));
QSignalSpy showSignalsSpy(&w, &KMessageWidget::showAnimationFinished);
QSignalSpy hideSignalsSpy(&w, &KMessageWidget::hideAnimationFinished);
// test: call hide while show animation still running
w.animatedShow();
QVERIFY(w.isVisible()); // Not CHECK_FULLY_VISIBLE because we're not waiting for it to finish
if (delay) {
QTest::qWait(overlappingWaitingTime);
}
w.animatedHide();
QVERIFY(!w.isShowAnimationRunning());
QCOMPARE(showSignalsSpy.count(), 1);
QTRY_VERIFY(!w.isHideAnimationRunning());
QCOMPARE(hideSignalsSpy.count(), 1);
CHECK_FULLY_NOT_VISIBLE
}
void KMessageWidgetTest::testOverlappingHideAndShow_data()
{
QTest::addColumn<bool>("delay");
QTest::newRow("instant") << false;
QTest::newRow("delay") << true;
}
void KMessageWidgetTest::testOverlappingHideAndShow()
{
QFETCH(bool, delay);
KMessageWidget w(QStringLiteral("Hello world"));
QSignalSpy showSignalsSpy(&w, &KMessageWidget::showAnimationFinished);
QSignalSpy hideSignalsSpy(&w, &KMessageWidget::hideAnimationFinished);
w.show();
CHECK_FULLY_VISIBLE
// test: call show while hide animation still running
w.animatedHide();
if (delay) {
QTest::qWait(overlappingWaitingTime);
}
w.animatedShow();
QVERIFY(!w.isHideAnimationRunning());
QCOMPARE(hideSignalsSpy.count(), 1);
QTRY_VERIFY(!w.isShowAnimationRunning());
QCOMPARE(showSignalsSpy.count(), 1);
CHECK_FULLY_VISIBLE
}
void KMessageWidgetTest::testOverlappingDoubleShow_data()
{
QTest::addColumn<bool>("delay");
QTest::newRow("instant") << false;
QTest::newRow("delay") << true;
}
void KMessageWidgetTest::testOverlappingDoubleShow()
{
QFETCH(bool, delay);
KMessageWidget w(QStringLiteral("Hello world"));
QSignalSpy showSignalsSpy(&w, &KMessageWidget::showAnimationFinished);
// test: call show while show animation still running
w.animatedShow();
if (delay) {
QTest::qWait(overlappingWaitingTime);
}
w.animatedShow();
QTRY_VERIFY(!w.isShowAnimationRunning());
QCOMPARE(showSignalsSpy.count(), 1);
CHECK_FULLY_VISIBLE
}
void KMessageWidgetTest::testOverlappingDoubleHide_data()
{
QTest::addColumn<bool>("delay");
QTest::newRow("instant") << false;
QTest::newRow("delay") << true;
}
void KMessageWidgetTest::testOverlappingDoubleHide()
{
QFETCH(bool, delay);
KMessageWidget w(QStringLiteral("Hello world"));
QSignalSpy hideSignalsSpy(&w, &KMessageWidget::hideAnimationFinished);
w.show();
// test: call hide while hide animation still running
w.animatedHide();
if (delay) {
QTest::qWait(overlappingWaitingTime);
}
w.animatedHide();
QTRY_VERIFY(!w.isHideAnimationRunning());
QCOMPARE(hideSignalsSpy.count(), 1);
CHECK_FULLY_NOT_VISIBLE
}
void KMessageWidgetTest::testHideWithNotYetShownParent()
{
QWidget parent;
KMessageWidget w(QStringLiteral("Hello world"), &parent);
QSignalSpy hideSignalsSpy(&w, &KMessageWidget::hideAnimationFinished);
// test: call hide while not yet visible
w.animatedHide();
QTRY_VERIFY(!w.isHideAnimationRunning());
parent.show();
QCOMPARE(hideSignalsSpy.count(), 1);
QVERIFY(!w.isVisible()); // Not CHECK_FULLY_NOT_VISIBLE because since it was never shown height is not what it would be otherwise
}
void KMessageWidgetTest::testNonAnimatedShowAfterAnimatedHide()
{
KMessageWidget w(QStringLiteral("Hello world"));
QSignalSpy hideSignalsSpy(&w, &KMessageWidget::hideAnimationFinished);
w.show();
CHECK_FULLY_VISIBLE
w.animatedHide();
QTRY_VERIFY(!w.isHideAnimationRunning());
QCOMPARE(hideSignalsSpy.count(), 1);
CHECK_FULLY_NOT_VISIBLE
w.show();
CHECK_FULLY_VISIBLE
}
void KMessageWidgetTest::testResizeFlickerOnAnimatedShow()
{
KMessageWidget w(QStringLiteral("Hello world"));
w.animatedShow();
QCOMPARE(w.height(), 0);
}
#include "moc_kmessagewidgetautotest.cpp"
@@ -0,0 +1,33 @@
/*
SPDX-FileCopyrightText: 2014 Dominik Haumann <dhaumann@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#ifndef KMESSAGEWIDGETAUTOTEST_H
#define KMESSAGEWIDGETAUTOTEST_H
#include <QObject>
class KMessageWidgetTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void testAnimationSignals();
void testShowOnVisible();
void testHideOnInvisible();
void testOverlappingShowAndHide_data();
void testOverlappingShowAndHide();
void testOverlappingHideAndShow_data();
void testOverlappingHideAndShow();
void testOverlappingDoubleShow_data();
void testOverlappingDoubleShow();
void testOverlappingDoubleHide_data();
void testOverlappingDoubleHide();
void testHideWithNotYetShownParent();
void testNonAnimatedShowAfterAnimatedHide();
void testResizeFlickerOnAnimatedShow();
};
#endif
@@ -0,0 +1,81 @@
/*
* SPDX-FileCopyrightText: 2021 Waqar Ahmed <waqar.17a@gmail.com>
*
* SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include "kmultitabbartest.h"
#include <QSignalSpy>
#include <QTest>
#include <KMultiTabBar>
KMultiTabBarTest::KMultiTabBarTest(QObject *parent)
: QObject(parent)
{
}
void KMultiTabBarTest::testTabsAppendAndRemove()
{
KMultiTabBar tb;
int id1 = 1;
int id2 = 2;
tb.appendTab(QIcon(), id1);
tb.appendTab(QIcon(), id2);
// verify that tabs were appended
QVERIFY(tb.tab(id1));
QVERIFY(tb.tab(id2));
tb.removeTab(id1);
tb.removeTab(id2);
// verify that tabs were removed
QVERIFY(!tb.tab(id1));
QVERIFY(!tb.tab(id2));
}
void KMultiTabBarTest::testTabStyleChanged()
{
KMultiTabBar tb;
QCOMPARE(tb.tabStyle(), KMultiTabBar::VSNET);
tb.setStyle(KMultiTabBar::KDEV3ICON);
QCOMPARE(tb.tabStyle(), KMultiTabBar::KDEV3ICON);
}
void KMultiTabBarTest::testTabRaised()
{
KMultiTabBar tb;
tb.appendTab(QIcon(), /*id : */ 1);
tb.appendTab(QIcon(), /*id : */ 2);
// set id = 1 as active tab
tb.setTab(1, true);
QVERIFY(tb.isTabRaised(1));
QVERIFY(tb.tab(1)->isChecked());
QVERIFY(!tb.isTabRaised(2));
}
void KMultiTabBarTest::shouldEmitClicked()
{
KMultiTabBar tb;
int id1 = 1;
tb.appendTab(QIcon(), id1);
KMultiTabBarTab *tab = tb.tab(id1);
QVERIFY(tab);
QSignalSpy spy(tab, &KMultiTabBarTab::clicked);
QTest::mouseClick(tab, Qt::LeftButton);
QCOMPARE(spy.count(), 1);
}
QTEST_MAIN(KMultiTabBarTest)
#include "moc_kmultitabbartest.cpp"
@@ -0,0 +1,25 @@
/*
* SPDX-FileCopyrightText: 2021 Waqar Ahmed <waqar.17a@gmail.com>
*
* SPDX-License-Identifier: LGPL-2.0-or-later
*/
#ifndef KMULTITABBARTEST_H
#define KMULTITABBARTEST_H
#include <QObject>
class KMultiTabBarTest : public QObject
{
Q_OBJECT
public:
KMultiTabBarTest(QObject *parent = nullptr);
private Q_SLOTS:
void testTabsAppendAndRemove();
void testTabStyleChanged();
void testTabRaised();
void shouldEmitClicked();
};
#endif
@@ -0,0 +1,318 @@
/*
SPDX-FileCopyrightText: 2015 Elvis Angelaccio <elvis.angelaccio@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include "knewpasswordwidgettest.h"
#include <QAction>
#include <QLineEdit>
#include <QTest>
#include <KPasswordLineEdit>
#include <knewpasswordwidget.h>
QTEST_MAIN(KNewPasswordWidgetTest)
void KNewPasswordWidgetTest::testEmptyPasswordAllowed()
{
KNewPasswordWidget pwdWidget;
QVERIFY(pwdWidget.allowEmptyPasswords());
QCOMPARE(pwdWidget.minimumPasswordLength(), 0);
QCOMPARE(pwdWidget.passwordStatus(), KNewPasswordWidget::WeakPassword);
}
void KNewPasswordWidgetTest::testEmptyPasswordNotAllowed()
{
KNewPasswordWidget pwdWidget;
pwdWidget.setAllowEmptyPasswords(false);
QVERIFY(!pwdWidget.allowEmptyPasswords());
QCOMPARE(pwdWidget.minimumPasswordLength(), 1);
QCOMPARE(pwdWidget.passwordStatus(), KNewPasswordWidget::EmptyPasswordNotAllowed);
}
void KNewPasswordWidgetTest::testPasswordTooShort()
{
KNewPasswordWidget pwdWidget;
pwdWidget.setMinimumPasswordLength(5);
auto linePassword = pwdWidget.findChild<KPasswordLineEdit *>(QStringLiteral("linePassword"));
auto lineVerifyPassword = pwdWidget.findChild<QLineEdit *>(QStringLiteral("lineVerifyPassword"));
QVERIFY(linePassword);
QVERIFY(lineVerifyPassword);
const QString password = QStringLiteral("1234");
// We can't use setPassword here as when we call it for security we don't allow to show password. So we need to use setText
linePassword->lineEdit()->setText(password);
lineVerifyPassword->setText(password);
QCOMPARE(pwdWidget.passwordStatus(), KNewPasswordWidget::PasswordTooShort);
}
void KNewPasswordWidgetTest::testPasswordMatch()
{
KNewPasswordWidget pwdWidget;
auto linePassword = pwdWidget.findChild<KPasswordLineEdit *>(QStringLiteral("linePassword"));
auto lineVerifyPassword = pwdWidget.findChild<QLineEdit *>(QStringLiteral("lineVerifyPassword"));
QVERIFY(linePassword);
QVERIFY(lineVerifyPassword);
const QString password = QStringLiteral("1234");
linePassword->lineEdit()->setText(password);
lineVerifyPassword->setText(password);
QVERIFY(pwdWidget.passwordStatus() != KNewPasswordWidget::PasswordNotVerified);
QCOMPARE(pwdWidget.password(), password);
}
void KNewPasswordWidgetTest::testPasswordNotVerified()
{
KNewPasswordWidget pwdWidget;
auto linePassword = pwdWidget.findChild<KPasswordLineEdit *>(QStringLiteral("linePassword"));
QVERIFY(linePassword);
const QString password = QStringLiteral("1234");
linePassword->lineEdit()->setText(password);
QCOMPARE(pwdWidget.passwordStatus(), KNewPasswordWidget::PasswordNotVerified);
}
void KNewPasswordWidgetTest::testWeakPassword()
{
KNewPasswordWidget pwdWidget;
pwdWidget.setPasswordStrengthWarningLevel(30);
auto linePassword = pwdWidget.findChild<KPasswordLineEdit *>(QStringLiteral("linePassword"));
auto lineVerifyPassword = pwdWidget.findChild<QLineEdit *>(QStringLiteral("lineVerifyPassword"));
QVERIFY(linePassword);
QVERIFY(lineVerifyPassword);
const QString password = QStringLiteral("1234");
linePassword->lineEdit()->setText(password);
lineVerifyPassword->setText(password);
QCOMPARE(pwdWidget.passwordStatus(), KNewPasswordWidget::WeakPassword);
}
void KNewPasswordWidgetTest::testStrongPassword()
{
KNewPasswordWidget pwdWidget;
pwdWidget.setPasswordStrengthWarningLevel(99);
auto linePassword = pwdWidget.findChild<KPasswordLineEdit *>(QStringLiteral("linePassword"));
auto lineVerifyPassword = pwdWidget.findChild<QLineEdit *>(QStringLiteral("lineVerifyPassword"));
QVERIFY(linePassword);
QVERIFY(lineVerifyPassword);
const auto password = QStringLiteral("DHlKOJ1GotXWVE_fnqm1"); // generated by KeePass
linePassword->lineEdit()->setText(password);
lineVerifyPassword->setText(password);
QCOMPARE(pwdWidget.passwordStatus(), KNewPasswordWidget::StrongPassword);
}
void KNewPasswordWidgetTest::testReasonablePasswordLength()
{
KNewPasswordWidget pwdWidget;
pwdWidget.setReasonablePasswordLength(10);
QCOMPARE(pwdWidget.reasonablePasswordLength(), 10);
pwdWidget.setReasonablePasswordLength(0);
QCOMPARE(pwdWidget.reasonablePasswordLength(), 1);
pwdWidget.setReasonablePasswordLength(pwdWidget.maximumPasswordLength() + 1);
QCOMPARE(pwdWidget.reasonablePasswordLength(), pwdWidget.maximumPasswordLength());
}
void KNewPasswordWidgetTest::testPasswordStrengthWarningLevel()
{
KNewPasswordWidget pwdWidget;
pwdWidget.setPasswordStrengthWarningLevel(40);
QCOMPARE(pwdWidget.passwordStrengthWarningLevel(), 40);
pwdWidget.setPasswordStrengthWarningLevel(-1);
QCOMPARE(pwdWidget.passwordStrengthWarningLevel(), 0);
pwdWidget.setPasswordStrengthWarningLevel(100);
QCOMPARE(pwdWidget.passwordStrengthWarningLevel(), 99);
}
void KNewPasswordWidgetTest::testNoWarningColorBeforeMismatch()
{
KNewPasswordWidget pwdWidget;
QColor defaultColor = pwdWidget.palette().color(QPalette::Base);
QColor warningColor(Qt::red);
pwdWidget.setBackgroundWarningColor(warningColor);
auto linePassword = pwdWidget.findChild<KPasswordLineEdit *>(QStringLiteral("linePassword"));
auto lineVerifyPassword = pwdWidget.findChild<QLineEdit *>(QStringLiteral("lineVerifyPassword"));
QVERIFY(linePassword);
QVERIFY(lineVerifyPassword);
linePassword->lineEdit()->setText(QStringLiteral("1234"));
QCOMPARE(lineVerifyPassword->palette().color(QPalette::Base), defaultColor);
lineVerifyPassword->setText(QStringLiteral("12"));
QCOMPARE(lineVerifyPassword->palette().color(QPalette::Base), defaultColor);
}
void KNewPasswordWidgetTest::testWarningColorIfMismatch()
{
KNewPasswordWidget pwdWidget;
QColor defaultColor = pwdWidget.palette().color(QPalette::Base);
QColor warningColor(Qt::red);
pwdWidget.setBackgroundWarningColor(warningColor);
auto linePassword = pwdWidget.findChild<KPasswordLineEdit *>(QStringLiteral("linePassword"));
auto lineVerifyPassword = pwdWidget.findChild<QLineEdit *>(QStringLiteral("lineVerifyPassword"));
QVERIFY(linePassword);
QVERIFY(lineVerifyPassword);
linePassword->lineEdit()->setText(QStringLiteral("1234"));
QCOMPARE(lineVerifyPassword->palette().color(QPalette::Base), defaultColor);
lineVerifyPassword->setText(QStringLiteral("122"));
QCOMPARE(lineVerifyPassword->palette().color(QPalette::Base), warningColor);
lineVerifyPassword->setText(QStringLiteral("1224"));
QCOMPARE(lineVerifyPassword->palette().color(QPalette::Base), warningColor);
}
void KNewPasswordWidgetTest::testWarningColorPostMatch()
{
KNewPasswordWidget pwdWidget;
QColor defaultColor = pwdWidget.palette().color(QPalette::Base);
QColor warningColor(Qt::red);
pwdWidget.setBackgroundWarningColor(warningColor);
auto linePassword = pwdWidget.findChild<KPasswordLineEdit *>(QStringLiteral("linePassword"));
auto lineVerifyPassword = pwdWidget.findChild<QLineEdit *>(QStringLiteral("lineVerifyPassword"));
QVERIFY(linePassword);
QVERIFY(lineVerifyPassword);
linePassword->lineEdit()->setText(QStringLiteral("1234"));
lineVerifyPassword->setText(QStringLiteral("1234"));
QCOMPARE(lineVerifyPassword->palette().color(QPalette::Base), defaultColor);
lineVerifyPassword->setText(QStringLiteral("12345"));
QCOMPARE(lineVerifyPassword->palette().color(QPalette::Base), warningColor);
}
void KNewPasswordWidgetTest::disablingWidgetShouldUseDisabledPalette()
{
KNewPasswordWidget pwdWidget;
auto linePassword = pwdWidget.findChild<KPasswordLineEdit *>(QStringLiteral("linePassword"));
auto lineVerifyPassword = pwdWidget.findChild<QLineEdit *>(QStringLiteral("lineVerifyPassword"));
QVERIFY(linePassword && linePassword->isEnabled());
QVERIFY(lineVerifyPassword && lineVerifyPassword->isEnabled());
pwdWidget.setEnabled(false);
QVERIFY(!linePassword->isEnabled());
QVERIFY(!lineVerifyPassword->isEnabled());
QCOMPARE(linePassword->palette(), pwdWidget.palette());
QCOMPARE(lineVerifyPassword->palette(), pwdWidget.palette());
}
void KNewPasswordWidgetTest::disablingParentShouldUseDisabledPalette()
{
auto widget = new QWidget();
widget->setEnabled(false);
auto pwdWidget = new KNewPasswordWidget(widget);
QVERIFY(!pwdWidget->isEnabled());
auto linePassword = pwdWidget->findChild<KPasswordLineEdit *>(QStringLiteral("linePassword"));
auto lineVerifyPassword = pwdWidget->findChild<QLineEdit *>(QStringLiteral("lineVerifyPassword"));
QVERIFY(linePassword && !linePassword->isEnabled());
QVERIFY(lineVerifyPassword && !lineVerifyPassword->isEnabled());
QCOMPARE(linePassword->palette(), widget->palette());
QCOMPARE(lineVerifyPassword->palette(), widget->palette());
delete widget;
}
void KNewPasswordWidgetTest::disablingRevealPasswordShouldHideVisibilityAction()
{
KNewPasswordWidget pwdWidget;
auto linePassword = pwdWidget.findChild<KPasswordLineEdit *>(QStringLiteral("linePassword"));
QVERIFY(linePassword);
auto visibilityAction = linePassword->findChild<QAction *>(QStringLiteral("visibilityAction"));
QVERIFY(visibilityAction && !visibilityAction->isVisible());
linePassword->lineEdit()->setText(QStringLiteral("1234"));
QVERIFY(visibilityAction->isVisible());
QCOMPARE(pwdWidget.revealPasswordMode(), KPassword::RevealMode::OnlyNew);
pwdWidget.setRevealPasswordMode(KPassword::RevealMode::Never);
QVERIFY(!visibilityAction->isVisible());
QCOMPARE(pwdWidget.revealPasswordMode(), KPassword::RevealMode::Never);
pwdWidget.setRevealPasswordMode(KPassword::RevealMode::Always);
QVERIFY(visibilityAction->isVisible());
QCOMPARE(pwdWidget.revealPasswordMode(), KPassword::RevealMode::Always);
}
void KNewPasswordWidgetTest::shouldNotHideVisibilityActionInPlaintextMode()
{
KNewPasswordWidget pwdWidget;
auto linePassword = pwdWidget.findChild<KPasswordLineEdit *>(QStringLiteral("linePassword"));
QVERIFY(linePassword);
auto visibilityAction = linePassword->findChild<QAction *>(QStringLiteral("visibilityAction"));
QVERIFY(visibilityAction && !visibilityAction->isVisible());
linePassword->lineEdit()->setText(QStringLiteral("1234"));
QVERIFY(visibilityAction->isVisible());
visibilityAction->trigger();
linePassword->clear();
QVERIFY(visibilityAction->isVisible());
}
void KNewPasswordWidgetTest::shouldHideVerificationLineEditInPlaintextMode()
{
KNewPasswordWidget pwdWidget;
pwdWidget.show();
auto linePassword = pwdWidget.findChild<KPasswordLineEdit *>(QStringLiteral("linePassword"));
auto lineVerifyPassword = pwdWidget.findChild<QLineEdit *>(QStringLiteral("lineVerifyPassword"));
QVERIFY(linePassword);
QVERIFY(lineVerifyPassword && lineVerifyPassword->isVisible());
auto visibilityAction = linePassword->findChild<QAction *>(QStringLiteral("visibilityAction"));
QVERIFY(visibilityAction);
linePassword->lineEdit()->setText(QStringLiteral("1234"));
visibilityAction->trigger();
QVERIFY(!lineVerifyPassword->isVisible());
}
#include "moc_knewpasswordwidgettest.cpp"
@@ -0,0 +1,37 @@
/*
SPDX-FileCopyrightText: 2015 Elvis Angelaccio <elvis.angelaccio@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#ifndef KNEWPASSWORDWIDGETTEST_H
#define KNEWPASSWORDWIDGETTEST_H
#include <QObject>
class KNewPasswordWidgetTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void testEmptyPasswordAllowed();
void testEmptyPasswordNotAllowed();
void testPasswordTooShort();
void testPasswordMatch();
void testPasswordNotVerified();
void testWeakPassword();
void testStrongPassword();
void testReasonablePasswordLength();
void testPasswordStrengthWarningLevel();
void testNoWarningColorBeforeMismatch();
void testWarningColorIfMismatch();
void testWarningColorPostMatch();
void disablingWidgetShouldUseDisabledPalette();
void disablingParentShouldUseDisabledPalette();
void disablingRevealPasswordShouldHideVisibilityAction();
void shouldNotHideVisibilityActionInPlaintextMode();
void shouldHideVerificationLineEditInPlaintextMode();
};
#endif
@@ -0,0 +1,64 @@
/*
SPDX-FileCopyrightText: 2014 Laurent Montel <montel@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include "kpagedialogautotest.h"
#include <kpagedialog.h>
#include <QDialogButtonBox>
#include <QPushButton>
#include <QTest>
QTEST_MAIN(KPageDialogAutoTest)
KPageDialogAutoTest::KPageDialogAutoTest()
{
}
void KPageDialogAutoTest::shouldHaveDefaultValuesOnCreation()
{
KPageDialog page;
QDialogButtonBox *dialogbuttonbox = page.findChild<QDialogButtonBox *>(QStringLiteral("buttonbox"));
QVERIFY(dialogbuttonbox);
QDialogButtonBox::StandardButtons standardButton = dialogbuttonbox->standardButtons();
QDialogButtonBox::StandardButtons defaultButton = QDialogButtonBox::Ok | QDialogButtonBox::Cancel;
QCOMPARE(standardButton, defaultButton);
}
void KPageDialogAutoTest::shouldAddAnActionButton()
{
KPageDialog page;
QDialogButtonBox *dialogbuttonbox = page.findChild<QDialogButtonBox *>(QStringLiteral("buttonbox"));
QPushButton *actionButton = new QPushButton(QStringLiteral("Action1"));
page.addActionButton(actionButton);
QCOMPARE(dialogbuttonbox->buttons().count(), 3);
QVERIFY(dialogbuttonbox->buttons().contains(actionButton));
}
void KPageDialogAutoTest::shouldAddTwoActionButton()
{
KPageDialog page;
QDialogButtonBox *dialogbuttonbox = page.findChild<QDialogButtonBox *>(QStringLiteral("buttonbox"));
QPushButton *actionButton = new QPushButton(QStringLiteral("Action1"));
page.addActionButton(actionButton);
QPushButton *actionButton2 = new QPushButton(QStringLiteral("Action2"));
page.addActionButton(actionButton2);
QCOMPARE(dialogbuttonbox->buttons().count(), 4);
}
void KPageDialogAutoTest::shouldNotAddTwoSameActionButton()
{
KPageDialog page;
QDialogButtonBox *dialogbuttonbox = page.findChild<QDialogButtonBox *>(QStringLiteral("buttonbox"));
QPushButton *actionButton = new QPushButton(QStringLiteral("Action1"));
page.addActionButton(actionButton);
page.addActionButton(actionButton);
QCOMPARE(dialogbuttonbox->buttons().count(), 3);
}
#include "moc_kpagedialogautotest.cpp"
@@ -0,0 +1,25 @@
/*
SPDX-FileCopyrightText: 2014 Laurent Montel <montel@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#ifndef KPAGEDIALOGAUTOTEST_H
#define KPAGEDIALOGAUTOTEST_H
#include <QObject>
class KPageDialogAutoTest : public QObject
{
Q_OBJECT
public:
KPageDialogAutoTest();
private Q_SLOTS:
void shouldHaveDefaultValuesOnCreation();
void shouldAddAnActionButton();
void shouldAddTwoActionButton();
void shouldNotAddTwoSameActionButton();
};
#endif // KPAGEDIALOGAUTOTEST_H
@@ -0,0 +1,38 @@
/*
SPDX-FileCopyrightText: 2017 Elvis Angelaccio <elvis.angelaccio@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include "kpassworddialogautotest.h"
#include <QAction>
#include <QTest>
#include <KPasswordDialog>
#include <KPasswordLineEdit>
QTEST_MAIN(KPasswordDialogAutotest)
void KPasswordDialogAutotest::shouldNotHideVisibilityActionInPlaintextMode()
{
KPasswordDialog dialog;
auto linePassword = dialog.findChild<KPasswordLineEdit *>(QStringLiteral("passEdit"));
QVERIFY(linePassword);
auto lineEdit = linePassword->lineEdit();
QVERIFY(lineEdit);
auto visibilityAction = lineEdit->findChild<QAction *>(QStringLiteral("visibilityAction"));
QVERIFY(visibilityAction && !visibilityAction->isVisible());
linePassword->lineEdit()->setText(QStringLiteral("1234"));
QVERIFY(visibilityAction->isVisible());
visibilityAction->trigger();
linePassword->clear();
QVERIFY(visibilityAction->isVisible());
}
#include "moc_kpassworddialogautotest.cpp"
@@ -0,0 +1,21 @@
/*
SPDX-FileCopyrightText: 2017 Elvis Angelaccio <elvis.angelaccio@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#ifndef KPASSWORDDIALOGAUTOTEST_H
#define KPASSWORDDIALOGAUTOTEST_H
#include <QObject>
class KPasswordDialogAutotest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void shouldNotHideVisibilityActionInPlaintextMode();
};
#endif
@@ -0,0 +1,125 @@
/*
SPDX-FileCopyrightText: 2017 Montel Laurent <montel@kde.org>
SPDX-License-Identifier: LGPL-2.0-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#include "kpasswordlineedittest.h"
#include "kpasswordlineedit.h"
#include <QAction>
#include <QHBoxLayout>
#include <QLineEdit>
#include <QSignalSpy>
#include <QTest>
#include "windowscheck.h"
PasswordLineEditTest::PasswordLineEditTest(QObject *parent)
: QObject(parent)
{
}
void PasswordLineEditTest::shouldHaveDefaultValue()
{
KPasswordLineEdit lineEdit;
QVERIFY(lineEdit.password().isEmpty());
QHBoxLayout *mainLayout = lineEdit.findChild<QHBoxLayout *>(QStringLiteral("mainlayout"));
QVERIFY(mainLayout);
QCOMPARE(mainLayout->contentsMargins(), QMargins(0, 0, 0, 0));
QLineEdit *edit = lineEdit.findChild<QLineEdit *>(QStringLiteral("passwordlineedit"));
QVERIFY(edit);
QVERIFY(edit->text().isEmpty());
QCOMPARE(edit->echoMode(), QLineEdit::Password);
QVERIFY(lineEdit.toggleEchoModeAction());
QVERIFY(!lineEdit.toggleEchoModeAction()->isVisible());
}
void PasswordLineEditTest::shouldShowTogglePassword()
{
if (isWindowsCI()) {
QSKIP("GUI Tests on Windows CI are not supported");
}
KPasswordLineEdit lineEdit;
lineEdit.show();
QVERIFY(QTest::qWaitForWindowExposed(&lineEdit));
QLineEdit *edit = lineEdit.findChild<QLineEdit *>(QStringLiteral("passwordlineedit"));
edit->setText(QStringLiteral("FOO"));
QVERIFY(lineEdit.toggleEchoModeAction()->isVisible());
edit->clear();
QVERIFY(!lineEdit.toggleEchoModeAction()->isVisible());
}
void PasswordLineEditTest::shouldNotShowToggleWhenSetPassword()
{
if (isWindowsCI()) {
QSKIP("GUI Tests on Windows CI are not supported");
}
KPasswordLineEdit lineEdit;
lineEdit.show();
QVERIFY(QTest::qWaitForWindowExposed(&lineEdit));
lineEdit.setPassword(QStringLiteral("foo"));
QVERIFY(!lineEdit.toggleEchoModeAction()->isVisible());
}
void PasswordLineEditTest::shouldShowRevealPassword()
{
if (isWindowsCI()) {
QSKIP("GUI Tests on Windows CI are not supported");
}
KPasswordLineEdit lineEdit;
lineEdit.show();
QVERIFY(QTest::qWaitForWindowExposed(&lineEdit));
QLineEdit *edit = lineEdit.findChild<QLineEdit *>(QStringLiteral("passwordlineedit"));
edit->setText(QStringLiteral("FOO"));
QVERIFY(lineEdit.toggleEchoModeAction()->isVisible());
lineEdit.setRevealPasswordMode(KPassword::RevealMode::Never);
QVERIFY(!lineEdit.toggleEchoModeAction()->isVisible());
lineEdit.setRevealPasswordMode(KPassword::RevealMode::Always);
QVERIFY(lineEdit.toggleEchoModeAction()->isVisible());
lineEdit.setRevealPasswordMode(KPassword::RevealMode::OnlyNew);
QVERIFY(lineEdit.toggleEchoModeAction()->isVisible());
lineEdit.setPassword(QStringLiteral("FOO2"));
QVERIFY(!lineEdit.toggleEchoModeAction()->isVisible());
edit->clear();
QVERIFY(!lineEdit.toggleEchoModeAction()->isVisible());
}
void PasswordLineEditTest::shouldEmitSignalPasswordChanged()
{
KPasswordLineEdit lineEdit;
lineEdit.show();
QSignalSpy spy(&lineEdit, &KPasswordLineEdit::passwordChanged);
lineEdit.setPassword(QStringLiteral("foo"));
QCOMPARE(spy.count(), 1);
}
void PasswordLineEditTest::testReadOnly()
{
KPasswordLineEdit lineEdit;
lineEdit.show();
lineEdit.setReadOnly(true);
QSignalSpy spy(&lineEdit, &KPasswordLineEdit::passwordChanged);
lineEdit.setPassword(QStringLiteral("foo"));
QCOMPARE(spy.count(), 1);
QTest::keyClick(&lineEdit, Qt::Key_A);
QCOMPARE(spy.count(), 1);
QCOMPARE(lineEdit.password(), QStringLiteral("foo"));
}
QTEST_MAIN(PasswordLineEditTest)
#include "moc_kpasswordlineedittest.cpp"
@@ -0,0 +1,27 @@
/*
SPDX-FileCopyrightText: 2017 Montel Laurent <montel@kde.org>
SPDX-License-Identifier: LGPL-2.0-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#ifndef PASSWORDLINEEDITTEST_H
#define PASSWORDLINEEDITTEST_H
#include <QObject>
class PasswordLineEditTest : public QObject
{
Q_OBJECT
public:
explicit PasswordLineEditTest(QObject *parent = nullptr);
~PasswordLineEditTest() override = default;
private Q_SLOTS:
void shouldHaveDefaultValue();
void shouldShowTogglePassword();
void shouldNotShowToggleWhenSetPassword();
void shouldShowRevealPassword();
void shouldEmitSignalPasswordChanged();
void testReadOnly();
};
#endif
@@ -0,0 +1,33 @@
/*
This file is part of the KDE libraries
SPDX-FileCopyrightText: 2017 David Faure <faure@kde.org>
SPDX-License-Identifier: LGPL-2.1-or-later
*/
#include <KPixmapSequenceWidget>
#include <QTest>
#include "kguiitem.h"
static const QString INACTIVE_TEXT = QStringLiteral("Show Foo");
static const QString ACTIVE_TEXT = QStringLiteral("Hide Foo");
class KPixmapSequenceWidgetTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void initTestCase()
{
}
void testConstructor()
{
KPixmapSequenceWidget w;
}
};
QTEST_MAIN(KPixmapSequenceWidgetTest)
#include "kpixmapsequencewidgettest.moc"
@@ -0,0 +1,352 @@
/*
This file is part of the KDE libraries
SPDX-FileCopyrightText: 2009 Daniel Calviño Sánchez <danxuliu@gmail.com>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include "kselectaction_unittest.h"
#include <QComboBox>
#include <QMainWindow>
#include <QStandardItemModel>
#include <QTest>
#include <kselectaction.h>
#include <qtoolbar.h>
QTEST_MAIN(KSelectAction_UnitTest)
void KSelectAction_UnitTest::testSetToolTipBeforeRequestingComboBoxWidget()
{
KSelectAction selectAction(QStringLiteral("selectAction"), nullptr);
selectAction.setToolBarMode(KSelectAction::ComboBoxMode);
selectAction.setToolTip(QStringLiteral("Test"));
selectAction.setEnabled(false); // also test disabling the action
QWidget parent;
QWidget *widget = selectAction.requestWidget(&parent);
QVERIFY(widget);
QComboBox *comboBox = qobject_cast<QComboBox *>(widget);
QVERIFY(comboBox);
QCOMPARE(comboBox->toolTip(), QStringLiteral("Test"));
QCOMPARE(comboBox->isEnabled(), false);
}
void KSelectAction_UnitTest::testSetToolTipAfterRequestingComboBoxWidget()
{
KSelectAction selectAction(QStringLiteral("selectAction"), nullptr);
selectAction.setToolBarMode(KSelectAction::ComboBoxMode);
QWidget parent;
QWidget *widget = selectAction.requestWidget(&parent);
selectAction.setToolTip(QStringLiteral("Test"));
selectAction.setEnabled(false); // also test disabling the action
QVERIFY(widget);
QComboBox *comboBox = qobject_cast<QComboBox *>(widget);
QVERIFY(comboBox);
QCOMPARE(comboBox->toolTip(), QStringLiteral("Test"));
QCOMPARE(comboBox->isEnabled(), false);
}
void KSelectAction_UnitTest::testSetToolTipBeforeRequestingToolButtonWidget()
{
KSelectAction selectAction(QStringLiteral("selectAction"), nullptr);
selectAction.setToolBarMode(KSelectAction::MenuMode);
selectAction.setToolTip(QStringLiteral("Test"));
QToolBar toolBar;
// Don't use requestWidget, as it needs a releaseWidget when used in MenuMode
//(in ComboBoxMode the widget is released automatically when it is
// destroyed). When the action is added to the QToolBar, it requests and
// releases the widget as needed.
toolBar.addAction(&selectAction);
QWidget *widget = toolBar.widgetForAction(&selectAction);
QVERIFY(widget);
QToolButton *toolButton = qobject_cast<QToolButton *>(widget);
QVERIFY(toolButton);
QCOMPARE(toolButton->toolTip(), QStringLiteral("Test"));
}
void KSelectAction_UnitTest::testSetToolTipAfterRequestingToolButtonWidget()
{
KSelectAction selectAction(QStringLiteral("selectAction"), nullptr);
selectAction.setToolBarMode(KSelectAction::MenuMode);
QToolBar toolBar;
// Don't use requestWidget, as it needs a releaseWidget when used in MenuMode
//(in ComboBoxMode the widget is released automatically when it is
// destroyed). When the action is added to the QToolBar, it requests and
// releases the widget as needed.
toolBar.addAction(&selectAction);
QWidget *widget = toolBar.widgetForAction(&selectAction);
selectAction.setToolTip(QStringLiteral("Test"));
QVERIFY(widget);
QToolButton *toolButton = qobject_cast<QToolButton *>(widget);
QVERIFY(toolButton);
QCOMPARE(toolButton->toolTip(), QStringLiteral("Test"));
}
void KSelectAction_UnitTest::testSetWhatsThisBeforeRequestingComboBoxWidget()
{
KSelectAction selectAction(QStringLiteral("selectAction"), nullptr);
selectAction.setToolBarMode(KSelectAction::ComboBoxMode);
selectAction.setWhatsThis(QStringLiteral("Test"));
QWidget parent;
QWidget *widget = selectAction.requestWidget(&parent);
QVERIFY(widget);
QComboBox *comboBox = qobject_cast<QComboBox *>(widget);
QVERIFY(comboBox);
QCOMPARE(comboBox->whatsThis(), QStringLiteral("Test"));
}
void KSelectAction_UnitTest::testSetWhatsThisAfterRequestingComboBoxWidget()
{
KSelectAction selectAction(QStringLiteral("selectAction"), nullptr);
selectAction.setToolBarMode(KSelectAction::ComboBoxMode);
QWidget parent;
QWidget *widget = selectAction.requestWidget(&parent);
selectAction.setWhatsThis(QStringLiteral("Test"));
QVERIFY(widget);
QComboBox *comboBox = qobject_cast<QComboBox *>(widget);
QVERIFY(comboBox);
QCOMPARE(comboBox->whatsThis(), QStringLiteral("Test"));
}
void KSelectAction_UnitTest::testSetWhatsThisBeforeRequestingToolButtonWidget()
{
KSelectAction selectAction(QStringLiteral("selectAction"), nullptr);
selectAction.setToolBarMode(KSelectAction::MenuMode);
selectAction.setWhatsThis(QStringLiteral("Test"));
QToolBar toolBar;
// Don't use requestWidget, as it needs a releaseWidget when used in MenuMode
//(in ComboBoxMode the widget is released automatically when it is
// destroyed). When the action is added to the QToolBar, it requests and
// releases the widget as needed.
toolBar.addAction(&selectAction);
QWidget *widget = toolBar.widgetForAction(&selectAction);
QVERIFY(widget);
QToolButton *toolButton = qobject_cast<QToolButton *>(widget);
QVERIFY(toolButton);
QCOMPARE(toolButton->whatsThis(), QStringLiteral("Test"));
}
void KSelectAction_UnitTest::testSetWhatsThisAfterRequestingToolButtonWidget()
{
KSelectAction selectAction(QStringLiteral("selectAction"), nullptr);
selectAction.setToolBarMode(KSelectAction::MenuMode);
QToolBar toolBar;
// Don't use requestWidget, as it needs a releaseWidget when used in MenuMode
//(in ComboBoxMode the widget is released automatically when it is
// destroyed). When the action is added to the QToolBar, it requests and
// releases the widget as needed.
toolBar.addAction(&selectAction);
QWidget *widget = toolBar.widgetForAction(&selectAction);
selectAction.setWhatsThis(QStringLiteral("Test"));
QVERIFY(widget);
QToolButton *toolButton = qobject_cast<QToolButton *>(widget);
QVERIFY(toolButton);
QCOMPARE(toolButton->whatsThis(), QStringLiteral("Test"));
}
void KSelectAction_UnitTest::testChildActionStateChangeComboMode()
{
KSelectAction selectAction(QStringLiteral("selectAction"), nullptr);
selectAction.setToolBarMode(KSelectAction::ComboBoxMode);
QWidget parent;
QWidget *widget = selectAction.requestWidget(&parent);
QComboBox *comboBox = qobject_cast<QComboBox *>(widget);
QVERIFY(comboBox);
const QString itemText = QStringLiteral("foo");
QAction *childAction = selectAction.addAction(itemText);
QCOMPARE(comboBox->itemText(0), itemText);
childAction->setEnabled(false);
// There's no API for item-is-enabled, need to go via the internal model like kselectaction does...
QStandardItemModel *model = qobject_cast<QStandardItemModel *>(comboBox->model());
QVERIFY(model);
QVERIFY(!model->item(0)->isEnabled());
// Now remove the action
selectAction.removeAction(childAction);
QCOMPARE(comboBox->count(), 0);
delete childAction;
}
// Bug 436808
void KSelectAction_UnitTest::testCrashComboBoxDestruction()
{
QWidget parentWidget;
QMainWindow mainWindow(&parentWidget);
// Create a KSelectAction in a QWidget
auto *comboSelect = new KSelectAction(QStringLiteral("selectAction"), &mainWindow);
// Add some actions and create some connections to them
for (int i = 0; i < 7; ++i) {
QAction *action = comboSelect->addAction(QStringLiteral("Combo Action %1").arg(i));
connect(action, &QAction::triggered, &mainWindow, []() {
// Empty, just creating a connection to trigger a crash
});
}
comboSelect->setToolBarMode(KSelectAction::ComboBoxMode);
QToolBar *toolBar = mainWindow.addToolBar(QStringLiteral("Test"));
// Add the KSelectAction to a toolbar
toolBar->addAction(comboSelect);
mainWindow.show();
mainWindow.activateWindow();
// Wait for window to show
QVERIFY(QTest::qWaitForWindowActive(&mainWindow));
// When this method finishes and the QWidget is destroyed, and there
// should be no crash in KSelectActionPrivate::comboBoxDeleted()
}
void KSelectAction_UnitTest::testRequestWidgetComboBoxModeWidgetParent()
{
KSelectAction selectAction(QStringLiteral("selectAction"), nullptr);
selectAction.setToolBarMode(KSelectAction::ComboBoxMode);
QToolBar toolBar;
toolBar.addAction(&selectAction);
QWidget *widget = toolBar.widgetForAction(&selectAction);
QVERIFY(widget);
QComboBox *comboBox = qobject_cast<QComboBox *>(widget);
QVERIFY(comboBox);
QVERIFY(!comboBox->isEnabled());
}
void KSelectAction_UnitTest::testRequestWidgetComboBoxModeWidgetParentSeveralActions()
{
KSelectAction selectAction(QStringLiteral("selectAction"), nullptr);
selectAction.setToolBarMode(KSelectAction::ComboBoxMode);
selectAction.addAction(new QAction(QStringLiteral("action1"), &selectAction));
selectAction.addAction(new QAction(QStringLiteral("action2"), &selectAction));
selectAction.addAction(new QAction(QStringLiteral("action3"), &selectAction));
QToolBar toolBar;
toolBar.addAction(&selectAction);
QWidget *widget = toolBar.widgetForAction(&selectAction);
QVERIFY(widget);
QComboBox *comboBox = qobject_cast<QComboBox *>(widget);
QVERIFY(comboBox);
QVERIFY(comboBox->isEnabled());
}
void KSelectAction_UnitTest::testRequestWidgetMenuModeWidgetParent()
{
KSelectAction selectAction(QStringLiteral("selectAction"), nullptr);
selectAction.setToolBarMode(KSelectAction::MenuMode);
QToolBar toolBar;
toolBar.addAction(&selectAction);
QWidget *widget = toolBar.widgetForAction(&selectAction);
QVERIFY(widget);
QToolButton *toolButton = qobject_cast<QToolButton *>(widget);
QVERIFY(toolButton);
QVERIFY(!toolButton->isEnabled());
QVERIFY(toolButton->autoRaise());
QCOMPARE((int)toolButton->focusPolicy(), (int)Qt::NoFocus);
QCOMPARE(toolButton->defaultAction(), (QAction *)&selectAction);
QCOMPARE(toolButton->actions().count(), 1);
QCOMPARE(toolButton->actions().at(0)->text(), QStringLiteral("selectAction"));
}
void KSelectAction_UnitTest::testRequestWidgetMenuModeWidgetParentSeveralActions()
{
KSelectAction selectAction(QStringLiteral("selectAction"), nullptr);
selectAction.setToolBarMode(KSelectAction::MenuMode);
selectAction.addAction(new QAction(QStringLiteral("action1"), &selectAction));
selectAction.addAction(new QAction(QStringLiteral("action2"), &selectAction));
selectAction.addAction(new QAction(QStringLiteral("action3"), &selectAction));
QToolBar toolBar;
toolBar.addAction(&selectAction);
QWidget *widget = toolBar.widgetForAction(&selectAction);
QVERIFY(widget);
QToolButton *toolButton = qobject_cast<QToolButton *>(widget);
QVERIFY(toolButton);
QVERIFY(toolButton->isEnabled());
QVERIFY(toolButton->autoRaise());
QCOMPARE((int)toolButton->focusPolicy(), (int)Qt::NoFocus);
QCOMPARE(toolButton->defaultAction(), (QAction *)&selectAction);
QCOMPARE(toolButton->actions().count(), 4);
QCOMPARE(toolButton->actions().at(0)->text(), QStringLiteral("selectAction"));
QCOMPARE(toolButton->actions().at(1)->text(), QStringLiteral("action1"));
QCOMPARE(toolButton->actions().at(2)->text(), QStringLiteral("action2"));
QCOMPARE(toolButton->actions().at(3)->text(), QStringLiteral("action3"));
}
void KSelectAction_UnitTest::testRequestWidgetMenuModeWidgetParentAddActions()
{
KSelectAction selectAction(QStringLiteral("selectAction"), nullptr);
selectAction.setToolBarMode(KSelectAction::MenuMode);
QToolBar toolBar;
toolBar.addAction(&selectAction);
QWidget *widget = toolBar.widgetForAction(&selectAction);
QVERIFY(widget);
QVERIFY(!widget->isEnabled());
selectAction.addAction(new QAction(QStringLiteral("action1"), &selectAction));
selectAction.addAction(new QAction(QStringLiteral("action2"), &selectAction));
selectAction.addAction(new QAction(QStringLiteral("action3"), &selectAction));
QVERIFY(widget->isEnabled());
QCOMPARE(widget->actions().count(), 4);
QCOMPARE(widget->actions().at(0)->text(), QStringLiteral("selectAction"));
QCOMPARE(widget->actions().at(1)->text(), QStringLiteral("action1"));
QCOMPARE(widget->actions().at(2)->text(), QStringLiteral("action2"));
QCOMPARE(widget->actions().at(3)->text(), QStringLiteral("action3"));
}
void KSelectAction_UnitTest::testRequestWidgetMenuModeWidgetParentRemoveActions()
{
KSelectAction selectAction(QStringLiteral("selectAction"), nullptr);
selectAction.setToolBarMode(KSelectAction::MenuMode);
QToolBar toolBar;
toolBar.addAction(&selectAction);
QWidget *widget = toolBar.widgetForAction(&selectAction);
QVERIFY(widget);
QAction *action1 = new QAction(QStringLiteral("action1"), &selectAction);
selectAction.addAction(action1);
QAction *action2 = new QAction(QStringLiteral("action2"), &selectAction);
selectAction.addAction(action2);
QAction *action3 = new QAction(QStringLiteral("action3"), &selectAction);
selectAction.addAction(action3);
delete selectAction.removeAction(action1);
delete selectAction.removeAction(action2);
delete selectAction.removeAction(action3);
QVERIFY(!widget->isEnabled());
QCOMPARE(widget->actions().count(), 1);
QCOMPARE(widget->actions().at(0)->text(), QStringLiteral("selectAction"));
}
#include "moc_kselectaction_unittest.cpp"
@@ -0,0 +1,45 @@
/*
This file is part of the KDE libraries
SPDX-FileCopyrightText: 2009 Daniel Calviño Sánchez <danxuliu@gmail.com>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#ifndef KSELECTACTION_UNITTEST_H
#define KSELECTACTION_UNITTEST_H
#include <QObject>
class KSelectAction_UnitTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
// The next 8 are from bug 205293.
void testSetToolTipBeforeRequestingComboBoxWidget();
void testSetToolTipAfterRequestingComboBoxWidget();
void testSetToolTipBeforeRequestingToolButtonWidget();
void testSetToolTipAfterRequestingToolButtonWidget();
void testSetWhatsThisBeforeRequestingComboBoxWidget();
void testSetWhatsThisAfterRequestingComboBoxWidget();
void testSetWhatsThisBeforeRequestingToolButtonWidget();
void testSetWhatsThisAfterRequestingToolButtonWidget();
// Test for the eventFilter code.
void testChildActionStateChangeComboMode();
void testCrashComboBoxDestruction();
// The next 6 are from bug 203114.
void testRequestWidgetComboBoxModeWidgetParent();
void testRequestWidgetComboBoxModeWidgetParentSeveralActions();
void testRequestWidgetMenuModeWidgetParent();
void testRequestWidgetMenuModeWidgetParentSeveralActions();
void testRequestWidgetMenuModeWidgetParentAddActions();
void testRequestWidgetMenuModeWidgetParentRemoveActions();
};
#endif
@@ -0,0 +1,306 @@
/*
SPDX-FileCopyrightText: 2014 Montel Laurent <montel@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#include "ksplittercollapserbuttontest.h"
#include "ksplittercollapserbutton.h"
#include <QHBoxLayout>
#include <QSplitter>
#include <QTextEdit>
#include <qtest.h>
#include <qtestmouse.h>
#include "windowscheck.h"
Q_DECLARE_METATYPE(Qt::Orientation)
TestSplitter::TestSplitter(QWidget *parent)
: QWidget(parent)
{
QHBoxLayout *lay = new QHBoxLayout(this);
splitter = new QSplitter;
lay->addWidget(splitter);
splitter->setObjectName(QStringLiteral("splitter"));
edit1 = new QTextEdit;
edit1->setObjectName(QStringLiteral("edit1"));
splitter->addWidget(edit1);
edit2 = new QTextEdit;
edit2->setObjectName(QStringLiteral("edit2"));
splitter->addWidget(edit2);
}
KSplitterCollapserButtonTest::KSplitterCollapserButtonTest(QObject *parent)
: QObject(parent)
{
}
KSplitterCollapserButtonTest::~KSplitterCollapserButtonTest()
{
}
void KSplitterCollapserButtonTest::shouldHaveDefaultValue()
{
if (isWindowsCI()) {
QSKIP("GUI Tests on Windows CI are not supported");
}
TestSplitter testSplitter;
KSplitterCollapserButton *collapser = new KSplitterCollapserButton(testSplitter.edit2, testSplitter.splitter);
testSplitter.show();
QVERIFY(QTest::qWaitForWindowExposed(&testSplitter));
QVERIFY(testSplitter.isVisible());
QVERIFY(!collapser->isWidgetCollapsed());
QTextEdit *edit1 = testSplitter.findChild<QTextEdit *>(QStringLiteral("edit1"));
QVERIFY(edit1);
QTextEdit *edit2 = testSplitter.findChild<QTextEdit *>(QStringLiteral("edit2"));
QVERIFY(edit2);
QSplitter *splitter = testSplitter.findChild<QSplitter *>(QStringLiteral("splitter"));
QVERIFY(splitter);
}
void KSplitterCollapserButtonTest::shouldCollapseWhenClickOnButton()
{
if (isWindowsCI()) {
QSKIP("GUI Tests on Windows CI are not supported");
}
TestSplitter testSplitter;
KSplitterCollapserButton *splitterCollapser = new KSplitterCollapserButton(testSplitter.edit2, testSplitter.splitter);
testSplitter.show();
QVERIFY(QTest::qWaitForWindowExposed(&testSplitter));
QVERIFY(!splitterCollapser->isWidgetCollapsed());
QTest::mouseClick(splitterCollapser, Qt::LeftButton);
QVERIFY(splitterCollapser->isWidgetCollapsed());
QTest::mouseClick(splitterCollapser, Qt::LeftButton);
QVERIFY(!splitterCollapser->isWidgetCollapsed());
}
void KSplitterCollapserButtonTest::shouldRestoreCorrectPosition()
{
if (isWindowsCI()) {
QSKIP("GUI Tests on Windows CI are not supported");
}
TestSplitter testSplitter;
KSplitterCollapserButton *splitterCollapser = new KSplitterCollapserButton(testSplitter.edit2, testSplitter.splitter);
testSplitter.show();
QVERIFY(QTest::qWaitForWindowExposed(&testSplitter));
QVERIFY(testSplitter.isVisible());
QVERIFY(!splitterCollapser->isWidgetCollapsed());
QTextEdit *edit2 = testSplitter.findChild<QTextEdit *>(QStringLiteral("edit2"));
int size = edit2->width();
QTest::mouseClick(splitterCollapser, Qt::LeftButton);
QVERIFY(splitterCollapser->isWidgetCollapsed());
QCOMPARE(edit2->width(), 0);
QTest::mouseClick(splitterCollapser, Qt::LeftButton);
QVERIFY(!splitterCollapser->isWidgetCollapsed());
QCOMPARE(edit2->width(), size);
}
void KSplitterCollapserButtonTest::shouldRestoreCorrectPositionForFirstWidget()
{
if (isWindowsCI()) {
QSKIP("GUI Tests on Windows CI are not supported");
}
TestSplitter testSplitter;
KSplitterCollapserButton *splitterCollapser = new KSplitterCollapserButton(testSplitter.edit1, testSplitter.splitter);
testSplitter.show();
QVERIFY(QTest::qWaitForWindowExposed(&testSplitter));
QVERIFY(testSplitter.isVisible());
QVERIFY(!splitterCollapser->isWidgetCollapsed());
QTextEdit *edit1 = testSplitter.findChild<QTextEdit *>(QStringLiteral("edit1"));
int size = edit1->width();
QTest::mouseClick(splitterCollapser, Qt::LeftButton);
QVERIFY(splitterCollapser->isWidgetCollapsed());
QCOMPARE(edit1->width(), 0);
QTest::mouseClick(splitterCollapser, Qt::LeftButton);
QVERIFY(!splitterCollapser->isWidgetCollapsed());
QCOMPARE(edit1->width(), size);
}
void KSplitterCollapserButtonTest::shouldTestVerticalSplitterFirstWidget()
{
if (isWindowsCI()) {
QSKIP("GUI Tests on Windows CI are not supported");
}
TestSplitter testSplitter;
testSplitter.splitter->setOrientation(Qt::Vertical);
KSplitterCollapserButton *splitterCollapser = new KSplitterCollapserButton(testSplitter.edit1, testSplitter.splitter);
testSplitter.show();
QVERIFY(QTest::qWaitForWindowExposed(&testSplitter));
QVERIFY(testSplitter.isVisible());
QVERIFY(!splitterCollapser->isWidgetCollapsed());
QTextEdit *edit1 = testSplitter.findChild<QTextEdit *>(QStringLiteral("edit1"));
int size = edit1->height();
QTest::mouseClick(splitterCollapser, Qt::LeftButton);
QVERIFY(splitterCollapser->isWidgetCollapsed());
QCOMPARE(edit1->height(), 0);
QTest::mouseClick(splitterCollapser, Qt::LeftButton);
QVERIFY(!splitterCollapser->isWidgetCollapsed());
QCOMPARE(edit1->height(), size);
}
void KSplitterCollapserButtonTest::shouldTestVerticalSplitterSecondWidget()
{
if (isWindowsCI()) {
QSKIP("GUI Tests on Windows CI are not supported");
}
TestSplitter testSplitter;
testSplitter.splitter->setOrientation(Qt::Vertical);
KSplitterCollapserButton *splitterCollapser = new KSplitterCollapserButton(testSplitter.edit2, testSplitter.splitter);
testSplitter.show();
QVERIFY(QTest::qWaitForWindowExposed(&testSplitter));
QVERIFY(testSplitter.isVisible());
QVERIFY(!splitterCollapser->isWidgetCollapsed());
QTextEdit *edit2 = testSplitter.findChild<QTextEdit *>(QStringLiteral("edit2"));
int size = edit2->height();
QTest::mouseClick(splitterCollapser, Qt::LeftButton);
QVERIFY(splitterCollapser->isWidgetCollapsed());
QCOMPARE(edit2->height(), 0);
QTest::mouseClick(splitterCollapser, Qt::LeftButton);
QVERIFY(!splitterCollapser->isWidgetCollapsed());
QCOMPARE(edit2->height(), size);
}
void KSplitterCollapserButtonTest::shouldBeVisible_data()
{
QTest::addColumn<Qt::Orientation>("splitterOrientation");
QTest::addColumn<int>("widgetPosition");
QTest::newRow("Horizontal, first widget") << Qt::Horizontal << 0 /*first widget*/;
QTest::newRow("Horizontal, second widget") << Qt::Horizontal << 1 /*second widget*/;
QTest::newRow("Vertical, first widget") << Qt::Vertical << 0 /*first widget*/;
QTest::newRow("Vertical, first widget") << Qt::Vertical << 1 /*second widget*/;
}
void KSplitterCollapserButtonTest::shouldBeVisible()
{
if (isWindowsCI()) {
QSKIP("GUI Tests on Windows CI are not supported");
}
QFETCH(Qt::Orientation, splitterOrientation);
QFETCH(int, widgetPosition);
// GIVEN a splitter with two widgets and a collapser button (Horizontal splitter, and apply collapser on first widget)
TestSplitter testSplitter;
testSplitter.splitter->setOrientation(splitterOrientation);
QWidget *widget = (widgetPosition == 0) ? testSplitter.edit1 : testSplitter.edit2;
KSplitterCollapserButton *collapser = new KSplitterCollapserButton(widget, testSplitter.splitter);
// WHEN showing the splitter
testSplitter.show();
QVERIFY(QTest::qWaitForWindowExposed(&testSplitter));
QVERIFY(testSplitter.isVisible());
// THEN the button should be visible
QVERIFY(collapser->isVisible());
QVERIFY(collapser->x() > 0);
QVERIFY(collapser->y() > 0);
}
void KSplitterCollapserButtonTest::shouldBeVisibleWhenMovingHandle_data()
{
QTest::addColumn<QList<int>>("splitterPosition");
QTest::addColumn<bool>("expectedVisibility");
QTest::addColumn<Qt::Orientation>("splitterOrientation");
QTest::addColumn<int>("widgetPosition");
QTest::newRow("(Horizontal first widget) middle") << (QList<int>() << 1 << 1) << true << Qt::Horizontal << 0;
QTest::newRow("(Horizontal first widget) 1/3") << (QList<int>() << 1 << 3) << true << Qt::Horizontal << 0;
QTest::newRow("(Horizontal first widget) editor collapsed") << (QList<int>() << 0 << 1) << false << Qt::Horizontal << 0;
QTest::newRow("(Horizontal first widget) second editor collapsed") << (QList<int>() << 1 << 0) << true << Qt::Horizontal << 0;
QTest::newRow("(Horizontal second widget) middle") << (QList<int>() << 1 << 1) << true << Qt::Horizontal << 1;
QTest::newRow("(Horizontal second widget) 1/3") << (QList<int>() << 1 << 3) << true << Qt::Horizontal << 1;
QTest::newRow("(Horizontal second widget) editor collapsed") << (QList<int>() << 1 << 0) << true << Qt::Horizontal << 1;
QTest::newRow("(Horizontal second widget) first editor collapsed") << (QList<int>() << 0 << 1) << true << Qt::Horizontal << 1;
QTest::newRow("(Vertical first widget) middle") << (QList<int>() << 1 << 1) << true << Qt::Vertical << 0;
QTest::newRow("(Vertical first widget) 1/3") << (QList<int>() << 1 << 3) << true << Qt::Vertical << 0;
QTest::newRow("(Vertical first widget) editor collapsed") << (QList<int>() << 0 << 1) << true << Qt::Vertical << 0;
QTest::newRow("(Vertical first widget) second editor collapsed") << (QList<int>() << 1 << 0) << true << Qt::Vertical << 0;
QTest::newRow("(Vertical second widget) middle") << (QList<int>() << 1 << 1) << true << Qt::Vertical << 1;
QTest::newRow("(Vertical second widget) 1/3") << (QList<int>() << 1 << 3) << true << Qt::Vertical << 1;
QTest::newRow("(Vertical second widget) editor collapsed") << (QList<int>() << 1 << 0) << true << Qt::Vertical << 1;
QTest::newRow("(Vertical second widget) first editor collapsed") << (QList<int>() << 0 << 1) << false << Qt::Vertical << 1;
}
void KSplitterCollapserButtonTest::shouldBeVisibleWhenMovingHandle()
{
if (isWindowsCI()) {
QSKIP("GUI Tests on Windows CI are not supported");
}
QFETCH(QList<int>, splitterPosition);
QFETCH(bool, expectedVisibility);
QFETCH(Qt::Orientation, splitterOrientation);
QFETCH(int, widgetPosition);
// GIVEN a splitter with two widgets and a collapser button (Horizontal splitter, and apply collapser on first widget)
TestSplitter testSplitter;
testSplitter.splitter->setOrientation(splitterOrientation);
QWidget *widget = (widgetPosition == 0) ? testSplitter.edit1 : testSplitter.edit2;
KSplitterCollapserButton *collapser = new KSplitterCollapserButton(widget, testSplitter.splitter);
// WHEN showing the splitter
testSplitter.show();
QVERIFY(QTest::qWaitForWindowExposed(&testSplitter));
QVERIFY(testSplitter.isVisible());
testSplitter.splitter->setSizes(splitterPosition);
// THEN the button should be visible
QVERIFY(collapser->isVisible());
if (widgetPosition == 0) {
QCOMPARE(collapser->x() > 0, expectedVisibility);
} else {
QCOMPARE(collapser->y() > 0, expectedVisibility);
}
}
QTEST_MAIN(KSplitterCollapserButtonTest)
#include "moc_ksplittercollapserbuttontest.cpp"
@@ -0,0 +1,44 @@
/*
SPDX-FileCopyrightText: 2014 Montel Laurent <montel@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#ifndef KSPLITTERCOLLAPSERBUTTONTEST_H
#define KSPLITTERCOLLAPSERBUTTONTEST_H
#include <QWidget>
class QSplitter;
class QTextEdit;
class TestSplitter : public QWidget
{
Q_OBJECT
public:
explicit TestSplitter(QWidget *parent = nullptr);
QSplitter *splitter;
QTextEdit *edit1;
QTextEdit *edit2;
};
class KSplitterCollapserButtonTest : public QObject
{
Q_OBJECT
public:
explicit KSplitterCollapserButtonTest(QObject *parent = nullptr);
~KSplitterCollapserButtonTest() override;
private Q_SLOTS:
void shouldHaveDefaultValue();
void shouldCollapseWhenClickOnButton();
void shouldRestoreCorrectPosition();
void shouldRestoreCorrectPositionForFirstWidget();
void shouldTestVerticalSplitterFirstWidget();
void shouldTestVerticalSplitterSecondWidget();
void shouldBeVisible_data();
void shouldBeVisible();
void shouldBeVisibleWhenMovingHandle_data();
void shouldBeVisibleWhenMovingHandle();
};
#endif // KSPLITTERCOLLAPSERBUTTONTEST_H
@@ -0,0 +1,242 @@
/*
SPDX-FileCopyrightText: 2017 Henrik Fehlauer <rkflx@lab12.net>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include "ksqueezedtextlabelautotest.h"
#include <KSqueezedTextLabel>
#include <QTest>
Q_DECLARE_METATYPE(Qt::TextElideMode)
namespace
{
std::unique_ptr<KSqueezedTextLabel> createLabel(const QString &text = QStringLiteral("Squeeze me"))
{
auto label = std::make_unique<KSqueezedTextLabel>(QStringLiteral(""), nullptr);
label->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
// workaround for a QLabel bug, where the sizing for an empty label
// is off, if it was initialized to an empty text.
label->setText(QStringLiteral("x"));
label->setText(text);
label->show();
return label;
}
void squeezeLabel(KSqueezedTextLabel *label, const int pixels = 10)
{
label->resize(label->size().width() - pixels, label->size().height());
}
} // namespace
void KSqueezedTextLabelAutotest::testEmptyText()
{
const auto label = createLabel(QString());
QVERIFY(label->text().isEmpty());
QVERIFY(label->fullText().isEmpty());
QVERIFY(label->toolTip().isEmpty());
QVERIFY(!label->isSqueezed());
QCOMPARE(label->width(), 0);
}
void KSqueezedTextLabelAutotest::testElisionOnResize_data()
{
QTest::addColumn<QString>("text");
QTest::addColumn<int>("squeezePixels");
QTest::newRow("whitespace text") << " " << 10;
QTest::newRow("normal text") << "Squeeze me" << 10;
QTest::newRow("rich text") << "<h1>Squeeze me!</h1>" << 80;
// QTest::newRow("multiline text") << "Squeeze me,\nand\nme too.";
// QTest::newRow("multiline rich text") << "<i>Squeeze</i> me,\n<b>and\nme</b> too.";
}
void KSqueezedTextLabelAutotest::testElisionOnResize()
{
QFETCH(QString, text);
QFETCH(int, squeezePixels);
const auto label = createLabel(text);
QVERIFY(label->text() == text);
QVERIFY(label->fullText() == text);
QVERIFY(label->toolTip().isEmpty());
QVERIFY(!label->isSqueezed());
squeezeLabel(label.get(), squeezePixels);
QVERIFY(label->text() != text);
QVERIFY(label->fullText() == text);
QVERIFY(label->toolTip() == text);
QVERIFY(label->isSqueezed());
squeezeLabel(label.get(), -squeezePixels);
QVERIFY(label->text() == text);
QVERIFY(label->fullText() == text);
QVERIFY(label->toolTip().isEmpty());
QVERIFY(!label->isSqueezed());
}
void KSqueezedTextLabelAutotest::testElisionOnTextUpdate()
{
const auto label = createLabel();
QVERIFY(!label->isSqueezed());
label->setText(label->text() + QStringLiteral("!!!"));
QVERIFY(label->isSqueezed());
}
void KSqueezedTextLabelAutotest::testElideMode_data()
{
QTest::addColumn<Qt::TextElideMode>("mode");
QTest::addColumn<QChar>("prefix");
QTest::addColumn<QChar>("infix");
QTest::addColumn<QChar>("postfix");
const QChar ellipsisChar(0x2026);
const QChar a(QLatin1Char('a'));
const QChar b(QLatin1Char('b'));
const QChar c(QLatin1Char('c'));
QTest::newRow("ElideLeft") << Qt::ElideLeft << ellipsisChar << b << c;
QTest::newRow("ElideRight") << Qt::ElideRight << a << b << ellipsisChar;
QTest::newRow("ElideMiddle") << Qt::ElideMiddle << a << ellipsisChar << c;
QTest::newRow("ElideNone") << Qt::ElideNone << a << b << c;
}
void KSqueezedTextLabelAutotest::testElideMode()
{
QFETCH(Qt::TextElideMode, mode);
QFETCH(QChar, prefix);
QFETCH(QChar, infix);
QFETCH(QChar, postfix);
// "abc" is not sufficient, because ellipsis might be wider than a single char
const auto label = createLabel(QStringLiteral("aaabbbccc"));
label->setTextElideMode(mode);
squeezeLabel(label.get());
const int infixPos = label->text().indexOf(infix);
QVERIFY(label->isSqueezed() || mode == Qt::ElideNone);
QVERIFY(label->text().startsWith(prefix));
QVERIFY(0 < infixPos && infixPos < label->text().length() - 1);
QVERIFY(label->text().endsWith(postfix));
}
void KSqueezedTextLabelAutotest::testSizeHints()
{
const auto label = createLabel(QString());
QVERIFY(!label->isSqueezed());
QCOMPARE(label->size().width(), 0);
QCOMPARE(label->minimumSizeHint().width(), -1);
QCOMPARE(label->sizeHint().width(), 0);
label->adjustSize();
QVERIFY(!label->isSqueezed());
QCOMPARE(label->size().width(), 0);
QCOMPARE(label->minimumSizeHint().width(), -1);
QCOMPARE(label->sizeHint().width(), 0);
const QString text = QStringLiteral("Squeeze me");
label->setText(text);
const int labelWidth = label->sizeHint().width();
QVERIFY(label->isSqueezed());
QCOMPARE(label->size().width(), 0);
QCOMPARE(label->minimumSizeHint().width(), -1);
label->adjustSize();
QVERIFY(!label->isSqueezed());
QCOMPARE(label->size().width(), labelWidth);
QCOMPARE(label->minimumSizeHint().width(), -1);
QCOMPARE(label->sizeHint().width(), labelWidth);
const int indent = 40;
label->setIndent(indent);
label->adjustSize();
QVERIFY(!label->isSqueezed());
QCOMPARE(label->size().width(), labelWidth + indent);
QCOMPARE(label->minimumSizeHint().width(), -1);
QCOMPARE(label->sizeHint().width(), labelWidth + indent);
}
void KSqueezedTextLabelAutotest::testClearing()
{
const auto label = createLabel();
squeezeLabel(label.get());
QVERIFY(label->isSqueezed());
label->clear();
QVERIFY(label->text().isEmpty());
QVERIFY(label->fullText().isEmpty());
QEXPECT_FAIL("", "To fix: Reset tooltip in clear()", Continue);
QVERIFY(label->toolTip().isEmpty());
QVERIFY(!label->isSqueezed());
}
void KSqueezedTextLabelAutotest::testChrome_data()
{
const QFontMetrics fm(KSqueezedTextLabel().fontMetrics());
const int xWidth = fm.horizontalAdvance(QLatin1Char('x')) / 2;
QTest::addColumn<QString>("attribute");
QTest::addColumn<int>("amount");
QTest::addColumn<int>("widthDifference");
QTest::newRow("indent") << "indent" << 20 << 20;
QTest::newRow("margin") << "margin" << 20 << 40;
QTest::newRow("frame") << "lineWidth" << 20 << 40 + xWidth;
}
void KSqueezedTextLabelAutotest::testChrome()
{
QFETCH(QString, attribute);
QFETCH(int, amount);
QFETCH(int, widthDifference);
const auto label = createLabel();
label->setFrameStyle(QFrame::Box);
label->setLineWidth(0);
const int oldWidth = label->width();
QVERIFY(!label->isSqueezed());
label->setProperty(attribute.toLatin1().data(), amount);
QVERIFY(label->isSqueezed());
label->adjustSize();
QVERIFY(!label->isSqueezed());
QCOMPARE(label->width(), oldWidth + widthDifference);
}
QTEST_MAIN(KSqueezedTextLabelAutotest)
// TODO
// currently untested, may need clarification/definition of correct behaviour:
// - multiline text
// - setWordWrap
// - setAlignment
// - setToolTip
// - context menu
// - Qt::TextInteractionFlags, keyboard/mouse interaction
// - linkHovered/linkActivated
// - setPixmap
#include "moc_ksqueezedtextlabelautotest.cpp"
@@ -0,0 +1,31 @@
/*
SPDX-FileCopyrightText: 2017 Henrik Fehlauer <rkflx@lab12.net>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#ifndef KSQUEEZEDTEXTLABELAUTOTEST_H
#define KSQUEEZEDTEXTLABELAUTOTEST_H
#include <QObject>
class KSqueezedTextLabel;
class KSqueezedTextLabelAutotest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void testEmptyText();
void testElisionOnResize_data();
void testElisionOnResize();
void testElisionOnTextUpdate();
void testElideMode_data();
void testElideMode();
void testSizeHints();
void testClearing();
void testChrome_data();
void testChrome();
};
#endif
@@ -0,0 +1,248 @@
/*
SPDX-FileCopyrightText: 2011 John Layt <john@layt.net>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include "ktimecomboboxtest.h"
#include <QTime>
#include <QLineEdit>
#include <QTest>
#include <ktimecombobox.h>
QTEST_MAIN(KTimeComboBoxTest)
KTimeComboBoxTest::KTimeComboBoxTest()
{
QLocale::setDefault(QLocale(QLocale::C));
}
void KTimeComboBoxTest::testDefaults()
{
m_combo = new KTimeComboBox();
QCOMPARE(m_combo->time(), QTime(0, 0, 0, 0));
QCOMPARE(m_combo->minimumTime(), QTime(0, 0, 0, 0));
QCOMPARE(m_combo->maximumTime(), QTime(23, 59, 59, 999));
QCOMPARE(m_combo->isValid(), true);
QCOMPARE(m_combo->options(), KTimeComboBox::EditTime | KTimeComboBox::SelectTime);
QCOMPARE(m_combo->timeListInterval(), 15);
QCOMPARE(m_combo->displayFormat(), QLocale::ShortFormat);
delete m_combo;
}
void KTimeComboBoxTest::testValidNull()
{
m_combo = new KTimeComboBox(nullptr);
QCOMPARE(m_combo->isValid(), true);
QCOMPARE(m_combo->isNull(), false);
m_combo->setTime(QTime());
QCOMPARE(m_combo->isValid(), false);
QCOMPARE(m_combo->isNull(), true);
m_combo->setTime(QTime(0, 0, 0));
m_combo->lineEdit()->setText(QStringLiteral("99:99"));
QCOMPARE(m_combo->isValid(), false);
QCOMPARE(m_combo->isNull(), false);
delete m_combo;
}
void KTimeComboBoxTest::testTimeRange()
{
m_combo = new KTimeComboBox();
m_combo->setTime(QTime(2, 0, 0, 0));
QCOMPARE(m_combo->minimumTime(), QTime(0, 0, 0, 0));
QCOMPARE(m_combo->maximumTime(), QTime(23, 59, 59, 999));
QCOMPARE(m_combo->isValid(), true);
m_combo->setTimeRange(QTime(3, 0, 0, 0), QTime(22, 0, 0, 0));
QCOMPARE(m_combo->minimumTime(), QTime(3, 0, 0, 0));
QCOMPARE(m_combo->maximumTime(), QTime(22, 0, 0, 0));
QCOMPARE(m_combo->isValid(), false);
m_combo->setTime(QTime(23, 0, 0, 0));
QCOMPARE(m_combo->isValid(), false);
m_combo->setTime(QTime(12, 0, 0, 0));
QCOMPARE(m_combo->isValid(), true);
m_combo->setTime(QTime(3, 0, 0, 0));
QCOMPARE(m_combo->isValid(), true);
m_combo->setTime(QTime(22, 0, 0, 0));
QCOMPARE(m_combo->isValid(), true);
m_combo->setTime(QTime(2, 59, 59, 999));
QCOMPARE(m_combo->isValid(), false);
m_combo->setTime(QTime(22, 1, 0, 0));
QCOMPARE(m_combo->isValid(), false);
m_combo->setTimeRange(QTime(15, 0, 0, 0), QTime(5, 0, 0, 0));
QCOMPARE(m_combo->minimumTime(), QTime(3, 0, 0, 0));
QCOMPARE(m_combo->maximumTime(), QTime(22, 0, 0, 0));
m_combo->setMinimumTime(QTime(2, 0, 0, 0));
QCOMPARE(m_combo->minimumTime(), QTime(2, 0, 0, 0));
QCOMPARE(m_combo->maximumTime(), QTime(22, 0, 0, 0));
m_combo->setMaximumTime(QTime(21, 0, 0, 0));
QCOMPARE(m_combo->minimumTime(), QTime(2, 0, 0, 0));
QCOMPARE(m_combo->maximumTime(), QTime(21, 0, 0, 0));
delete m_combo;
}
void KTimeComboBoxTest::testTimeListInterval()
{
m_combo = new KTimeComboBox();
QCOMPARE(m_combo->timeListInterval(), 15);
m_combo->setTimeListInterval(60);
QCOMPARE(m_combo->timeListInterval(), 60);
m_combo->setTimeListInterval(7);
QCOMPARE(m_combo->timeListInterval(), 60);
m_combo->setTimeListInterval(720);
QCOMPARE(m_combo->timeListInterval(), 720);
QList<QTime> list;
list << QTime(0, 0, 0) << QTime(12, 0, 0) << QTime(23, 59, 59, 999);
QCOMPARE(m_combo->timeList(), list);
m_combo->setTimeRange(QTime(4, 0, 0, 0), QTime(5, 0, 0, 0));
m_combo->setTimeListInterval(30);
list.clear();
list << QTime(4, 0, 0) << QTime(4, 30, 0) << QTime(5, 0, 0, 0);
QCOMPARE(m_combo->timeList(), list);
m_combo->setTimeRange(QTime(4, 0, 0, 0), QTime(4, 59, 0, 0));
m_combo->setTimeListInterval(30);
list.clear();
list << QTime(4, 0, 0) << QTime(4, 30, 0) << QTime(4, 59, 0, 0);
QCOMPARE(m_combo->timeList(), list);
delete m_combo;
}
void KTimeComboBoxTest::testTimeList()
{
m_combo = new KTimeComboBox();
QList<QTime> list;
// Test default list
QTime thisTime = QTime(0, 0, 0);
for (int i = 0; i < 1440; i = i + 15) {
list << thisTime.addSecs(i * 60);
}
list << QTime(23, 59, 59, 999);
QCOMPARE(m_combo->timeList(), list);
// Test basic list
list.clear();
list << QTime(3, 0, 0) << QTime(15, 16, 17);
m_combo->setTimeList(list);
QCOMPARE(m_combo->timeList(), list);
QCOMPARE(m_combo->minimumTime(), QTime(3, 0, 0));
QCOMPARE(m_combo->maximumTime(), QTime(15, 16, 17));
// Test sort input times
list.clear();
list << QTime(17, 16, 15) << QTime(4, 0, 0);
m_combo->setTimeList(list);
std::sort(list.begin(), list.end());
QCOMPARE(m_combo->timeList(), list);
QCOMPARE(m_combo->minimumTime(), QTime(4, 0, 0));
QCOMPARE(m_combo->maximumTime(), QTime(17, 16, 15));
// Test ignore null QTime
list.clear();
list << QTime(3, 0, 0) << QTime(15, 16, 17) << QTime();
m_combo->setTimeList(list);
list.takeLast();
QCOMPARE(m_combo->timeList(), list);
QCOMPARE(m_combo->minimumTime(), QTime(3, 0, 0));
QCOMPARE(m_combo->maximumTime(), QTime(15, 16, 17));
delete m_combo;
}
void KTimeComboBoxTest::testOptions()
{
m_combo = new KTimeComboBox();
KTimeComboBox::Options options = KTimeComboBox::EditTime | KTimeComboBox::SelectTime;
QCOMPARE(m_combo->options(), options);
options = KTimeComboBox::EditTime | KTimeComboBox::WarnOnInvalid;
m_combo->setOptions(options);
QCOMPARE(m_combo->options(), options);
delete m_combo;
}
void KTimeComboBoxTest::testDisplayFormat()
{
m_combo = new KTimeComboBox();
QLocale::FormatType format = QLocale::ShortFormat;
QCOMPARE(m_combo->displayFormat(), format);
format = QLocale::NarrowFormat;
m_combo->setDisplayFormat(format);
QCOMPARE(m_combo->displayFormat(), format);
delete m_combo;
}
void KTimeComboBoxTest::testMask()
{
// Store the current locale, and set to one which reproduces the bug.
QLocale currentLocale;
// Test that the line edit input mask AM/PM portion gets correctly
// replaced with xx.
QLocale::setDefault(QLocale(QLocale::English, QLocale::Australia));
m_combo = new KTimeComboBox(nullptr);
QString mask = m_combo->lineEdit()->inputMask();
QVERIFY(mask.contains(QLatin1String("xx")));
delete m_combo;
// For 24 hour time formats, no am/pm specifier in mask
QLocale::setDefault(QLocale(QLocale::NorwegianBokmal, QLocale::Norway));
m_combo = new KTimeComboBox(nullptr);
mask = m_combo->lineEdit()->inputMask();
QVERIFY(!mask.contains(QLatin1String("xx")));
delete m_combo;
// Restore the previous locale
QLocale::setDefault(currentLocale);
}
void KTimeComboBoxTest::testEdit_data()
{
QTest::addColumn<QString>("locale");
QTest::newRow("C") << QStringLiteral("C");
QTest::newRow("el_GR") << QStringLiteral("el_GR"); // bug 361764; non-ASCII AM/PM
QTest::newRow("en_AU") << QStringLiteral("en_AU"); // bug 361764
QTest::newRow("en_CA") << QStringLiteral("en_CA"); // bug 405857
QTest::newRow("en_IE") << QStringLiteral("en_IE"); // bug 361764
QTest::newRow("en_US") << QStringLiteral("en_US");
QTest::newRow("fr_CA") << QStringLiteral("fr_CA"); // bug 409912
QTest::newRow("ko_KR") << QStringLiteral("ko_KR"); // non-ASCII AM/PM
}
static const QTime MIDNIGHT = QTime(00, 00, 00);
static const QTime END_AM = QTime(11, 59, 00);
static const QTime NOON = QTime(12, 00, 00);
static const QTime END_PM = QTime(23, 59, 00);
// Test that the widget can process times using the current locale and edit mask.
// See https://bugs.kde.org/show_bug.cgi?id=409867
void KTimeComboBoxTest::testEdit()
{
QLocale currentLocale;
QFETCH(QString, locale);
QLocale::setDefault(QLocale(locale));
m_combo = new KTimeComboBox(nullptr);
m_combo->setTime(MIDNIGHT);
QCOMPARE(m_combo->time(), MIDNIGHT);
m_combo->setTime(END_AM);
QCOMPARE(m_combo->time(), END_AM);
m_combo->setTime(NOON);
QCOMPARE(m_combo->time(), NOON);
m_combo->setTime(END_PM);
QCOMPARE(m_combo->time(), END_PM);
delete m_combo;
QLocale::setDefault(currentLocale);
}
#include "moc_ktimecomboboxtest.cpp"
@@ -0,0 +1,37 @@
/*
SPDX-FileCopyrightText: 2011 John Layt <john@layt.net>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#ifndef KTIMECOMBOBOXTEST_H
#define KTIMECOMBOBOXTEST_H
#include <QWidget>
class KTimeComboBox;
class KTimeComboBoxTest : public QWidget
{
Q_OBJECT
public:
KTimeComboBoxTest();
private Q_SLOTS:
void testDefaults();
void testValidNull();
void testTimeRange();
void testTimeListInterval();
void testTimeList();
void testOptions();
void testDisplayFormat();
void testMask();
void testEdit_data();
void testEdit();
private:
KTimeComboBox *m_combo;
};
#endif
@@ -0,0 +1,220 @@
/*
SPDX-FileCopyrightText: 2017 Elvis Angelaccio <elvis.angelaccio@kde.org>
SPDX-FileCopyrightText: 2018 Michael Heidelbach <ottwolt@gmail.com>
SPDX-License-Identifier: LGPL-2.1-or-later
*/
#include "ktooltipwidgettest.h"
#include <KToolTipWidget>
#include <QLabel>
#include <QLayout>
#include <QLineEdit>
#include <QScreen>
#include <QSignalSpy>
#include <QStyle>
#include <QTest>
#include "windowscheck.h"
void KToolTipWidgetTest::initTestCase()
{
m_screenGeometry = QGuiApplication::primaryScreen()->geometry();
}
void KToolTipWidgetTest::showTooltipShouldShowContent()
{
KToolTipWidget tooltip;
QLabel label;
tooltip.showAt(QPoint(10, 10), &label, nullptr);
QVERIFY(tooltip.isVisible());
QVERIFY(label.isVisible());
}
void KToolTipWidgetTest::hideLaterShouldHideAfterDelay()
{
KToolTipWidget tooltip;
QLabel label;
tooltip.showAt(QPoint(10, 10), &label, nullptr);
QVERIFY(tooltip.isVisible());
QVERIFY(label.isVisible());
tooltip.hideLater();
QVERIFY(tooltip.isVisible());
QVERIFY(label.isVisible());
QSignalSpy spy(&tooltip, &KToolTipWidget::hidden);
connect(&tooltip, &KToolTipWidget::hidden, this, [&]() {
QVERIFY(tooltip.isHidden());
QVERIFY(!label.isVisible());
});
QEventLoop eventLoop;
connect(&tooltip, &KToolTipWidget::hidden, &eventLoop, &QEventLoop::quit);
QCOMPARE(eventLoop.exec(), 0);
QCOMPARE(spy.count(), 1);
}
void KToolTipWidgetTest::setZeroDelayShouldHideImmediately()
{
KToolTipWidget tooltip;
QLabel label;
tooltip.setHideDelay(0);
tooltip.showAt(QPoint(10, 10), &label, nullptr);
QVERIFY(tooltip.isVisible());
QVERIFY(label.isVisible());
tooltip.hideLater();
QVERIFY(tooltip.isHidden());
QVERIFY(!label.isVisible());
}
void KToolTipWidgetTest::shouldHideImmediatelyIfContentDestroyed()
{
KToolTipWidget tooltip;
auto lineEdit = new QLineEdit();
tooltip.showAt(QPoint(10, 10), lineEdit, nullptr);
QVERIFY(tooltip.isVisible());
delete lineEdit;
QVERIFY(tooltip.isHidden());
}
void KToolTipWidgetTest::shouldNotTakeOwnershipOfContent()
{
auto parent = new QWidget();
auto label = new QLabel(parent);
auto tooltip = new KToolTipWidget();
tooltip->showAt(QPoint(10, 10), label, nullptr);
QCOMPARE(label->parent(), tooltip);
QVERIFY(label->isVisible());
QSignalSpy spy(label, &QWidget::destroyed);
delete tooltip;
QVERIFY(!label->isVisible());
QCOMPARE(label->parent(), parent);
QCOMPARE(spy.count(), 0);
delete parent;
QCOMPARE(spy.count(), 1);
}
void KToolTipWidgetTest::shouldNotObscureTarget_data()
{
qDebug() << "Style used" << QApplication::style()->objectName();
QTest::addColumn<QPoint>("position");
QTest::addColumn<QString>("content");
const QMap<QString, QPoint> positions{{QStringLiteral("topleft"), QPoint(m_offset, m_offset)},
{QStringLiteral("topright"), QPoint(-m_offset, m_offset)},
{QStringLiteral("bottomright"), QPoint(-m_offset, -m_offset)},
{QStringLiteral("bottomleft"), QPoint(m_offset, -m_offset)},
{QStringLiteral("centered"), QPoint(m_screenGeometry.width() / 2, m_screenGeometry.height() / 2)}};
QMapIterator<QString, QPoint> i(positions);
while (i.hasNext()) {
i.next();
QTest::newRow(qPrintable(QStringLiteral("small/%1").arg(i.key()))) << i.value() << QStringLiteral("dummy text");
QTest::newRow(qPrintable(QStringLiteral("multiline/%1").arg(i.key()))) << i.value() << QStringLiteral("dummy text\nLine 1\nLine 2\nLine 3");
QTest::newRow(qPrintable(QStringLiteral("one long line/%1").arg(i.key())))
<< i.value()
<< QStringLiteral(
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam nec felis sed elit auctor lobortis non a urna. Quisque non posuere mauris. "
"Suspendisse potenti. In diam leo, lobortis at placerat nec, sagittis at tortor. Pellentesque scelerisque enim vel elementum scelerisque. "
"Integer eget lectus vitae lorem pulvinar hendrerit. Suspendisse auctor sapien vel semper porta. Vestibulum fringilla aliquet tincidunt. "
"Maecenas mollis mauris et erat viverra mollis. Proin suscipit felis nisi, a dapibus est hendrerit euismod. Suspendisse quis faucibus quam. "
"Fusce eu cursus magna, et egestas purus. Duis enim sapien, feugiat id facilisis non, rhoncus ut lectus. Aliquam at nisi vel ligula "
"interdum ultricies. Donec condimentum ante quam, eu congue lectus pulvinar in. Cras interdum, neque quis fermentum consequat, lectus "
"tellus eleifend turpis.");
if (m_screenGeometry.width() >= 1600 && m_screenGeometry.height() >= 900) {
QTest::newRow(qPrintable(QStringLiteral("super large/%1").arg(i.key())))
<< i.value()
<< QStringLiteral(
"dummy 0 text\nLine 1\nLine 2\nLine 3"
"dummy 1 text\nLine 1\nLine 2\nLine 3"
"dummy 2 text\nLine 1\nLine 2\nLine 3"
"dummy 3 text\nLine 1\nLine 2\nLine 3"
"dummy 4 text\nLine 1\nLine 2\nLine 3"
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam nec felis sed elit auctor lobortis non a urna. Quisque non posuere "
"mauris. Suspendisse potenti. In diam leo, lobortis at placerat nec, sagittis at tortor. Pellentesque scelerisque enim vel elementum "
"scelerisque. Integer eget lectus vitae lorem pulvinar hendrerit. Suspendisse auctor sapien vel semper porta. Vestibulum fringilla "
"aliquet tincidunt. Maecenas mollis mauris et erat viverra mollis. Proin suscipit felis nisi, a dapibus est hendrerit euismod. "
"Suspendisse quis faucibus quam. Fusce eu cursus magna, et egestas purus. Duis enim sapien, feugiat id facilisis non, rhoncus ut "
"lectus. Aliquam at nisi vel ligula interdum ultricies. Donec condimentum ante quam, eu congue lectus pulvinar in. Cras interdum, neque "
"quis fermentum consequat, lectus tellus eleifend turpis.");
}
}
}
void KToolTipWidgetTest::shouldNotObscureTarget()
{
QFETCH(QPoint, position);
QFETCH(QString, content);
if (isWindowsCI()) {
QSKIP("GUI Tests on Windows CI are not supported");
}
QWidget *containerWidget = new QWidget();
const int margin = containerWidget->style()->pixelMetric(QStyle::PM_ToolTipLabelFrameWidth);
QLabel *targetWidget = new QLabel(QStringLiteral("dummy file"));
QLayout *layout = new QHBoxLayout(containerWidget);
layout->addWidget(targetWidget);
containerWidget->adjustSize();
containerWidget->move(position.x() >= 0 ? position.x() : m_screenGeometry.right() + position.x() - containerWidget->width(),
position.y() >= 0 ? position.y() : m_screenGeometry.bottom() + position.y() - containerWidget->height());
containerWidget->show();
QVERIFY(QTest::qWaitForWindowExposed(containerWidget));
QVERIFY(targetWidget->isVisible());
QRect targetRect = QRect(targetWidget->frameGeometry());
targetRect.moveTo(targetWidget->mapToGlobal(QPoint(0, 0)));
QLabel *contentWidget = new QLabel(content);
QVERIFY2(containerWidget->windowHandle(), "Container's window handle is invalid");
KToolTipWidget tooltipWidget;
tooltipWidget.showBelow(targetRect, contentWidget, containerWidget->windowHandle());
QVERIFY(QTest::qWaitForWindowExposed(&tooltipWidget));
const QRect tooltipRect = tooltipWidget.frameGeometry();
qDebug() << QStringLiteral("tooltip: %1x%2 x=%3, y=%4").arg(tooltipRect.width()).arg(tooltipRect.height()).arg(tooltipRect.left()).arg(tooltipRect.top());
qDebug() << QStringLiteral("target: %1x%2 x=%3, y=%4").arg(targetRect.width()).arg(targetRect.height()).arg(targetRect.left()).arg(targetRect.top());
QVERIFY2(!tooltipRect.intersects(targetRect), "Target obscured");
QCOMPARE(tooltipRect.intersected(m_screenGeometry), tooltipRect);
// Check margins
if (tooltipRect.bottom() < targetRect.top()) {
QCOMPARE(margin, targetRect.top() - tooltipRect.bottom());
} else if (tooltipRect.top() > targetRect.bottom()) {
QCOMPARE(margin, tooltipRect.top() - targetRect.bottom());
} else if (tooltipRect.right() < targetRect.left()) {
QCOMPARE(margin, targetRect.left() - tooltipRect.right());
} else if (tooltipRect.left() > targetRect.right()) {
QCOMPARE(margin, tooltipRect.left() - targetRect.right());
}
tooltipWidget.hide();
QVERIFY(tooltipWidget.isHidden());
delete contentWidget;
delete containerWidget;
}
QTEST_MAIN(KToolTipWidgetTest)
#include "moc_ktooltipwidgettest.cpp"
@@ -0,0 +1,35 @@
/*
SPDX-FileCopyrightText: 2017 Elvis Angelaccio <elvis.angelaccio@kde.org>
SPDX-License-Identifier: LGPL-2.1-or-later
*/
#ifndef KTOOLTIPWIDGETTEST_H
#define KTOOLTIPWIDGETTEST_H
#include <QObject>
#include <QRect>
class KToolTipWidgetTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void initTestCase();
void showTooltipShouldShowContent();
void hideLaterShouldHideAfterDelay();
void setZeroDelayShouldHideImmediately();
void shouldHideImmediatelyIfContentDestroyed();
void shouldNotTakeOwnershipOfContent();
void shouldNotObscureTarget_data();
void shouldNotObscureTarget();
private:
QRect m_screenGeometry;
const int m_offset = 10;
};
#endif
@@ -0,0 +1,452 @@
/*
This file is part of the KDE project
SPDX-FileCopyrightText: 2021 Steffen Hartleib <steffenhartleib@t-online.de>
SPDX-License-Identifier: LGPL-2.1-or-later
*/
#include <ktwofingerswipe.h>
#include <QTest>
#include <QSignalSpy>
#include <QWidget>
#include <QMainWindow>
#include "windowscheck.h"
class KTwoFingerSwipeTest : public QObject
{
Q_OBJECT
QPointingDevice *mDev = nullptr;
QMainWindow mMainWindow;
QWidget mWidget;
KTwoFingerSwipeRecognizer *mTwoFingerRec = nullptr;
Qt::GestureType mKTwoFingerSwipeGesture;
QPoint mTouchPointPos = QPoint(200, 200);
QSignalSpy *mSpySwipeFinished = nullptr;
QSignalSpy *mSpySwipeStarted = nullptr;
QSignalSpy *mSpySwipeUpdated = nullptr;
QSignalSpy *mSpySwipeCanceled = nullptr;
qreal mAngel = 0.0;
Q_SIGNALS:
void swipeStarted(KTwoFingerSwipe *);
void swipeFinished(KTwoFingerSwipe *);
void swipeUpdated(KTwoFingerSwipe *);
void swipeCanceled(KTwoFingerSwipe *);
protected:
bool eventFilter(QObject *watched, QEvent *e) override
{
if (e->type() == QEvent::Gesture) {
QGestureEvent *gEvent = static_cast<QGestureEvent *>(e);
KTwoFingerSwipe *swipe = static_cast<KTwoFingerSwipe *>(gEvent->gesture(mKTwoFingerSwipeGesture));
if (swipe) {
const Qt::GestureState state = swipe->state();
if (state == Qt::GestureFinished) {
Q_EMIT swipeFinished(swipe);
} else if (state == Qt::GestureStarted) {
Q_EMIT swipeStarted(swipe);
} else if (state == Qt::GestureUpdated) {
Q_EMIT swipeUpdated(swipe);
} else if (state == Qt::GestureCanceled) {
Q_EMIT swipeCanceled(swipe);
}
}
e->accept();
return true;
}
return QObject::eventFilter(watched, e);
}
protected Q_SLOTS:
void slotSwipeFinished (KTwoFingerSwipe *swipe)
{
compareGesturePositions(swipe);
}
void slotSwipeStarted (KTwoFingerSwipe *swipe)
{
compareGesturePositions(swipe);
}
void slotSwipeUpdated (KTwoFingerSwipe *swipe)
{
compareGesturePositions(swipe);
}
void slotSwipeCanceled (KTwoFingerSwipe *swipe)
{
compareGesturePositions(swipe);
}
private:
void compareGesturePositions(KTwoFingerSwipe *swipe)
{
QCOMPARE(swipe->pos(), mTouchPointPos);
QCOMPARE(swipe->screenPos(), mWidget.mapToGlobal(mTouchPointPos));
QCOMPARE(swipe->hotSpot(), mWidget.mapToGlobal(mTouchPointPos));
QCOMPARE(swipe->scenePos(), mWidget.mapToGlobal(mTouchPointPos));
QVERIFY(swipe->hasHotSpot());
mAngel = swipe->swipeAngle();
}
void clearSignalSpys()
{
mSpySwipeFinished->clear();
mSpySwipeCanceled->clear();
mSpySwipeUpdated->clear();
mSpySwipeStarted->clear();
}
private Q_SLOTS:
void cleanupTestCase()
{
delete mSpySwipeFinished;
delete mSpySwipeCanceled;
delete mSpySwipeUpdated;
delete mSpySwipeStarted;
}
void initTestCase()
{
if (isWindowsCI()) {
QSKIP("GUI Tests on Windows CI are not supported");
}
mDev = QTest::createTouchDevice();
mMainWindow.setGeometry(0, 0, 500, 500);
mMainWindow.setCentralWidget(&mWidget);
mMainWindow.show();
mWidget.installEventFilter(this);
mWidget.setAttribute(Qt::WA_AcceptTouchEvents);
QVERIFY(QTest::qWaitForWindowActive(&mMainWindow));
QVERIFY(QTest::qWaitForWindowActive(&mWidget));
mTwoFingerRec = new KTwoFingerSwipeRecognizer();
QVERIFY(mTwoFingerRec);
mKTwoFingerSwipeGesture = QGestureRecognizer::registerRecognizer(mTwoFingerRec);
QVERIFY(mKTwoFingerSwipeGesture & Qt::CustomGesture);
mWidget.grabGesture(mKTwoFingerSwipeGesture);
connect(this, &KTwoFingerSwipeTest::swipeFinished, this, &KTwoFingerSwipeTest::slotSwipeFinished);
connect(this, &KTwoFingerSwipeTest::swipeStarted, this, &KTwoFingerSwipeTest::slotSwipeStarted);
connect(this, &KTwoFingerSwipeTest::swipeUpdated, this, &KTwoFingerSwipeTest::slotSwipeUpdated);
connect(this, &KTwoFingerSwipeTest::swipeCanceled, this, &KTwoFingerSwipeTest::slotSwipeCanceled);
mSpySwipeFinished = new QSignalSpy(this, &KTwoFingerSwipeTest::swipeFinished);
QVERIFY(mSpySwipeFinished->isValid());
mSpySwipeStarted = new QSignalSpy(this, &KTwoFingerSwipeTest::swipeStarted);
QVERIFY(mSpySwipeStarted->isValid());
mSpySwipeUpdated = new QSignalSpy(this, &KTwoFingerSwipeTest::swipeUpdated);
QVERIFY(mSpySwipeUpdated->isValid());
mSpySwipeCanceled = new QSignalSpy(this, &KTwoFingerSwipeTest::swipeCanceled);
QVERIFY(mSpySwipeCanceled->isValid());
QTest::qWait(1000);
}
void testChangeTimeAndDistance()
{
QVERIFY(mTwoFingerRec->maxSwipeTime() >= 0);
mTwoFingerRec->setMaxSwipeTime(10);
QCOMPARE(mTwoFingerRec->maxSwipeTime(), 10);
mTwoFingerRec->setMaxSwipeTime(-10);
QCOMPARE(mTwoFingerRec->maxSwipeTime(), 0);
mTwoFingerRec->setMaxSwipeTime(90);
QCOMPARE(mTwoFingerRec->maxSwipeTime(), 90);
QVERIFY(mTwoFingerRec->minSswipeDistance() >= 0);
mTwoFingerRec->setSwipeDistance(10);
QCOMPARE(mTwoFingerRec->minSswipeDistance(), 10);
mTwoFingerRec->setSwipeDistance(-10);
QCOMPARE(mTwoFingerRec->minSswipeDistance(), 0);
mTwoFingerRec->setSwipeDistance(30);
QCOMPARE(mTwoFingerRec->minSswipeDistance(), 30);
}
void testSuccessfulGesture_right()
{
clearSignalSpys();
const int length = mTwoFingerRec->minSswipeDistance();
const QPoint swipeDistance = QPoint(length, 0);
QTest::touchEvent(&mWidget, mDev)
.press(0, mTouchPointPos, (QWidget *) nullptr)
.press(1, mTouchPointPos, (QWidget *) nullptr);
QTest::touchEvent(&mWidget, mDev)
.move(0, mTouchPointPos + swipeDistance / 3, (QWidget *) nullptr)
.move(1, mTouchPointPos + swipeDistance / 3, (QWidget *) nullptr);
QTest::touchEvent(&mWidget, mDev)
.move(0, mTouchPointPos + swipeDistance / 2, (QWidget *) nullptr)
.move(1, mTouchPointPos + swipeDistance / 2, (QWidget *) nullptr);
QTest::touchEvent(&mWidget, mDev)
.move(0, mTouchPointPos + swipeDistance, (QWidget *) nullptr)
.move(1, mTouchPointPos + swipeDistance, (QWidget *) nullptr);
QTest::touchEvent(&mWidget, mDev)
.release(0, mTouchPointPos + swipeDistance * 1.5, (QWidget *) nullptr)
.release(1, mTouchPointPos + swipeDistance * 1.5, (QWidget *) nullptr);
if (mSpySwipeStarted->count() == 0) {
QVERIFY(mSpySwipeStarted->wait(1000));
}
QCOMPARE(mSpySwipeStarted->count(), 1);
QCOMPARE(mSpySwipeFinished->count(), 1);
QCOMPARE(mSpySwipeCanceled->count(), 0);
QVERIFY(mSpySwipeUpdated->count() > 0);
QCOMPARE(mAngel, 0);
}
void testSuccessfulGesture_left()
{
clearSignalSpys();
const int length = mTwoFingerRec->minSswipeDistance();
const QPoint swipeDistance = QPoint(-length, 0);
QTest::touchEvent(&mWidget, mDev)
.press(0, mTouchPointPos, (QWidget *) nullptr)
.press(1, mTouchPointPos, (QWidget *) nullptr);
QTest::touchEvent(&mWidget, mDev)
.move(0, mTouchPointPos + swipeDistance / 3, (QWidget *) nullptr)
.move(1, mTouchPointPos + swipeDistance / 3, (QWidget *) nullptr);
QTest::touchEvent(&mWidget, mDev)
.move(0, mTouchPointPos + swipeDistance / 2, (QWidget *) nullptr)
.move(1, mTouchPointPos + swipeDistance / 2, (QWidget *) nullptr);
QTest::touchEvent(&mWidget, mDev)
.move(0, mTouchPointPos + swipeDistance, (QWidget *) nullptr)
.move(1, mTouchPointPos + swipeDistance, (QWidget *) nullptr);
QTest::touchEvent(&mWidget, mDev)
.release(0, mTouchPointPos + swipeDistance * 1.5, (QWidget *) nullptr)
.release(1, mTouchPointPos + swipeDistance * 1.5, (QWidget *) nullptr);
if (mSpySwipeStarted->count() == 0) {
QVERIFY(mSpySwipeStarted->wait(1000));
}
QCOMPARE(mSpySwipeStarted->count(), 1);
QCOMPARE(mSpySwipeFinished->count(), 1);
QCOMPARE(mSpySwipeCanceled->count(), 0);
QVERIFY(mSpySwipeUpdated->count() > 0);
QCOMPARE(mAngel, 180);
}
void testSuccessfulGesture_up()
{
clearSignalSpys();
const int length = mTwoFingerRec->minSswipeDistance();
const QPoint swipeDistance = QPoint(0, -length);
QTest::touchEvent(&mWidget, mDev)
.press(0, mTouchPointPos, (QWidget *) nullptr)
.press(1, mTouchPointPos, (QWidget *) nullptr);
QTest::touchEvent(&mWidget, mDev)
.move(0, mTouchPointPos + swipeDistance / 3, (QWidget *) nullptr)
.move(1, mTouchPointPos + swipeDistance / 3, (QWidget *) nullptr);
QTest::touchEvent(&mWidget, mDev)
.move(0, mTouchPointPos + swipeDistance / 2, (QWidget *) nullptr)
.move(1, mTouchPointPos + swipeDistance / 2, (QWidget *) nullptr);
QTest::touchEvent(&mWidget, mDev)
.move(0, mTouchPointPos + swipeDistance, (QWidget *) nullptr)
.move(1, mTouchPointPos + swipeDistance, (QWidget *) nullptr);
QTest::touchEvent(&mWidget, mDev)
.release(0, mTouchPointPos + swipeDistance * 1.5, (QWidget *) nullptr)
.release(1, mTouchPointPos + swipeDistance * 1.5, (QWidget *) nullptr);
if (mSpySwipeStarted->count() == 0) {
QVERIFY(mSpySwipeStarted->wait(1000));
}
QCOMPARE(mSpySwipeStarted->count(), 1);
QCOMPARE(mSpySwipeFinished->count(), 1);
QCOMPARE(mSpySwipeCanceled->count(), 0);
QVERIFY(mSpySwipeUpdated->count() > 0);
QCOMPARE(mAngel, 90);
}
void testSuccessfulGesture_down()
{
clearSignalSpys();
const int length = mTwoFingerRec->minSswipeDistance();
const QPoint swipeDistance = QPoint(0, length);
QTest::touchEvent(&mWidget, mDev)
.press(0, mTouchPointPos, (QWidget *) nullptr)
.press(1, mTouchPointPos, (QWidget *) nullptr);
QTest::touchEvent(&mWidget, mDev)
.move(0, mTouchPointPos + swipeDistance / 3, (QWidget *) nullptr)
.move(1, mTouchPointPos + swipeDistance / 3, (QWidget *) nullptr);
QTest::touchEvent(&mWidget, mDev)
.move(0, mTouchPointPos + swipeDistance / 2, (QWidget *) nullptr)
.move(1, mTouchPointPos + swipeDistance / 2, (QWidget *) nullptr);
QTest::touchEvent(&mWidget, mDev)
.move(0, mTouchPointPos + swipeDistance, (QWidget *) nullptr)
.move(1, mTouchPointPos + swipeDistance, (QWidget *) nullptr);
QTest::touchEvent(&mWidget, mDev)
.release(0, mTouchPointPos + swipeDistance * 1.5, (QWidget *) nullptr)
.release(1, mTouchPointPos + swipeDistance * 1.5, (QWidget *) nullptr);
if (mSpySwipeStarted->count() == 0) {
QVERIFY(mSpySwipeStarted->wait(1000));
}
QCOMPARE(mSpySwipeStarted->count(), 1);
QCOMPARE(mSpySwipeFinished->count(), 1);
QCOMPARE(mSpySwipeCanceled->count(), 0);
QVERIFY(mSpySwipeUpdated->count() > 0);
QCOMPARE(mAngel, 270);
}
void testFailingGesture_toSlow()
{
clearSignalSpys();
const int length = mTwoFingerRec->minSswipeDistance() / 3;
const QPoint swipeDistance = QPoint(length, 0);
QTest::touchEvent(&mWidget, mDev)
.press(0, mTouchPointPos, (QWidget *) nullptr)
.press(1, mTouchPointPos, (QWidget *) nullptr);
QTest::touchEvent(&mWidget, mDev)
.move(0, mTouchPointPos + swipeDistance / 3, (QWidget *) nullptr)
.move(1, mTouchPointPos + swipeDistance / 3, (QWidget *) nullptr);
QTest::touchEvent(&mWidget, mDev)
.move(0, mTouchPointPos + swipeDistance / 2, (QWidget *) nullptr)
.move(1, mTouchPointPos + swipeDistance / 2, (QWidget *) nullptr);
QTest::touchEvent(&mWidget, mDev)
.move(0, mTouchPointPos + swipeDistance, (QWidget *) nullptr)
.move(1, mTouchPointPos + swipeDistance, (QWidget *) nullptr);
QTest::touchEvent(&mWidget, mDev)
.release(0, mTouchPointPos + swipeDistance * 1.5, (QWidget *) nullptr)
.release(1, mTouchPointPos + swipeDistance * 1.5, (QWidget *) nullptr);
if (mSpySwipeStarted->count() == 0) {
QVERIFY(mSpySwipeStarted->wait(1000));
}
QCOMPARE(mSpySwipeStarted->count(), 1);
QCOMPARE(mSpySwipeFinished->count(), 0);
QCOMPARE(mSpySwipeCanceled->count(), 1);
QVERIFY(mSpySwipeUpdated->count() > 0);
QCOMPARE(mAngel, 0);
}
void testFailingGesture_threeFingers()
{
clearSignalSpys();
const int length = mTwoFingerRec->minSswipeDistance();
const QPoint swipeDistance = QPoint(length, 0);
QTest::touchEvent(&mWidget, mDev)
.press(0, mTouchPointPos, (QWidget *) nullptr)
.press(1, mTouchPointPos, (QWidget *) nullptr);
QTest::touchEvent(&mWidget, mDev)
.move(0, mTouchPointPos + swipeDistance / 3, (QWidget *) nullptr)
.move(1, mTouchPointPos + swipeDistance / 3, (QWidget *) nullptr);
QTest::touchEvent(&mWidget, mDev)
.move(0, mTouchPointPos + swipeDistance / 2, (QWidget *) nullptr)
.move(1, mTouchPointPos + swipeDistance / 2, (QWidget *) nullptr)
.press(2, mTouchPointPos + swipeDistance / 2, (QWidget *) nullptr);
QTest::touchEvent(&mWidget, mDev)
.move(0, mTouchPointPos + swipeDistance, (QWidget *) nullptr)
.move(1, mTouchPointPos + swipeDistance, (QWidget *) nullptr)
.move(2, mTouchPointPos + swipeDistance, (QWidget *) nullptr);
QTest::touchEvent(&mWidget, mDev)
.release(0, mTouchPointPos + swipeDistance * 1.5, (QWidget *) nullptr)
.release(1, mTouchPointPos + swipeDistance * 1.5, (QWidget *) nullptr)
.release(2, mTouchPointPos + swipeDistance * 1.5, (QWidget *) nullptr);
if (mSpySwipeCanceled->count() == 0) {
QVERIFY(mSpySwipeCanceled->wait(1000));
}
QCOMPARE(mSpySwipeStarted->count(), 1);
QCOMPARE(mSpySwipeFinished->count(), 0);
QCOMPARE(mSpySwipeCanceled->count(), 1);
QVERIFY(mSpySwipeUpdated->count() >= 0);
QCOMPARE(mAngel, 0);
}
void testFailingGesture_oneFinger()
{
clearSignalSpys();
const int length = mTwoFingerRec->minSswipeDistance();
const QPoint swipeDistance = QPoint(length, 0);
QTest::touchEvent(&mWidget, mDev)
.press(0, mTouchPointPos, (QWidget *) nullptr);
QTest::touchEvent(&mWidget, mDev)
.move(0, mTouchPointPos + swipeDistance / 3, (QWidget *) nullptr);
QTest::touchEvent(&mWidget, mDev)
.move(0, mTouchPointPos + swipeDistance / 2, (QWidget *) nullptr);
QTest::touchEvent(&mWidget, mDev)
.move(0, mTouchPointPos + swipeDistance, (QWidget *) nullptr);
QTest::touchEvent(&mWidget, mDev)
.release(0, mTouchPointPos + swipeDistance * 1.5, (QWidget *) nullptr);
QCOMPARE(mSpySwipeStarted->count(), 0);
QCOMPARE(mSpySwipeFinished->count(), 0);
QCOMPARE(mSpySwipeCanceled->count(), 0);
QVERIFY(mSpySwipeUpdated->count() == 0);
}
void testSomeRandomSwipes()
{
for (int i = 0; i < 50; ++i) {
const int x = rand() % 200 + 150;
const int y = rand() % 200 + 150;
mTouchPointPos = QPoint(x, y);
testSuccessfulGesture_right();
testSuccessfulGesture_up();
}
}
};
QTEST_MAIN(KTwoFingerSwipeTest)
#include "ktwofingerswipetest.moc"
@@ -0,0 +1,430 @@
/*
This file is part of the KDE project
SPDX-FileCopyrightText: 2021 Steffen Hartleib <steffenhartleib@t-online.de>
SPDX-License-Identifier: LGPL-2.1-or-later
*/
#include <ktwofingertap.h>
#include <QTest>
#include <QSignalSpy>
#include <QWidget>
#include <QMainWindow>
class KTwoFingerSwipeTest : public QObject
{
Q_OBJECT
QPointingDevice *mDev = nullptr;
QMainWindow mMainWindow;
QWidget mWidget;
KTwoFingerTapRecognizer *mTwoFingerRec = nullptr;
Qt::GestureType mKTwoFingerTapGesture;
QPoint mTouchPointPos = QPoint(100, 100);
QSignalSpy *mSpyTapFinished = nullptr;
QSignalSpy *mSpyTapStarted = nullptr;
QSignalSpy *mSpyTapUpdated = nullptr;
QSignalSpy *mSpyTapCanceled = nullptr;
Q_SIGNALS:
void tapStarted(KTwoFingerTap *);
void tapFinished(KTwoFingerTap *);
void tapUpdated(KTwoFingerTap *);
void tapCanceled(KTwoFingerTap *);
protected:
bool eventFilter(QObject *watched, QEvent *e) override
{
if (e->type() == QEvent::Gesture) {
QGestureEvent *gEvent = static_cast<QGestureEvent *>(e);
KTwoFingerTap *tap = static_cast<KTwoFingerTap *>(gEvent->gesture(mKTwoFingerTapGesture));
if (tap) {
const Qt::GestureState state = tap->state();
if (state == Qt::GestureFinished) {
Q_EMIT tapFinished(tap);
} else if (state == Qt::GestureStarted) {
Q_EMIT tapStarted(tap);
} else if (state == Qt::GestureUpdated) {
Q_EMIT tapUpdated(tap);
} else if (state == Qt::GestureCanceled) {
Q_EMIT tapCanceled(tap);
}
}
e->accept();
return true;
}
return QObject::eventFilter(watched, e);
}
protected Q_SLOTS:
void slotTapFinished (KTwoFingerTap *tap)
{
compareGesturePositions(tap);
}
void slotTapStarted (KTwoFingerTap *tap)
{
compareGesturePositions(tap);
}
void slotTapUpdated (KTwoFingerTap *tap)
{
compareGesturePositions(tap);
}
void slotTapCanceled (KTwoFingerTap *tap)
{
compareGesturePositions(tap);
}
private:
void compareGesturePositions(KTwoFingerTap *tap)
{
QCOMPARE(tap->pos(), mTouchPointPos);
QCOMPARE(tap->screenPos(), mWidget.mapToGlobal(mTouchPointPos));
QCOMPARE(tap->hotSpot(), mWidget.mapToGlobal(mTouchPointPos));
QCOMPARE(tap->scenePos(), mWidget.mapToGlobal(mTouchPointPos));
QVERIFY(tap->hasHotSpot());
}
void clearSignalSpys()
{
mSpyTapFinished->clear();
mSpyTapCanceled->clear();
mSpyTapUpdated->clear();
mSpyTapStarted->clear();
}
private Q_SLOTS:
void cleanupTestCase()
{
delete mSpyTapFinished;
delete mSpyTapCanceled;
delete mSpyTapUpdated;
delete mSpyTapStarted;
}
void initTestCase()
{
mDev = QTest::createTouchDevice();
mMainWindow.setGeometry(0, 0, 500, 500);
mMainWindow.setCentralWidget(&mWidget);
mMainWindow.show();
mWidget.installEventFilter(this);
mWidget.setAttribute(Qt::WA_AcceptTouchEvents);
QVERIFY(QTest::qWaitForWindowActive(&mMainWindow));
QVERIFY(QTest::qWaitForWindowActive(&mWidget));
mTwoFingerRec = new KTwoFingerTapRecognizer();
QVERIFY(mTwoFingerRec);
mKTwoFingerTapGesture = QGestureRecognizer::registerRecognizer(mTwoFingerRec);
QVERIFY(mKTwoFingerTapGesture & Qt::CustomGesture);
mWidget.grabGesture(mKTwoFingerTapGesture);
connect(this, &KTwoFingerSwipeTest::tapFinished, this, &KTwoFingerSwipeTest::slotTapFinished);
connect(this, &KTwoFingerSwipeTest::tapStarted, this, &KTwoFingerSwipeTest::slotTapStarted);
connect(this, &KTwoFingerSwipeTest::tapUpdated, this, &KTwoFingerSwipeTest::slotTapUpdated);
connect(this, &KTwoFingerSwipeTest::tapCanceled, this, &KTwoFingerSwipeTest::slotTapCanceled);
mSpyTapFinished = new QSignalSpy(this, &KTwoFingerSwipeTest::tapFinished);
QVERIFY(mSpyTapFinished->isValid());
mSpyTapStarted = new QSignalSpy(this, &KTwoFingerSwipeTest::tapStarted);
QVERIFY(mSpyTapStarted->isValid());
mSpyTapUpdated = new QSignalSpy(this, &KTwoFingerSwipeTest::tapUpdated);
QVERIFY(mSpyTapUpdated->isValid());
mSpyTapCanceled = new QSignalSpy(this, &KTwoFingerSwipeTest::tapCanceled);
QVERIFY(mSpyTapCanceled->isValid());
QTest::qWait(1000);
}
void testChangeTapRadius()
{
QVERIFY(mTwoFingerRec->tapRadius() >= 0);
mTwoFingerRec->setTapRadius(10);
QCOMPARE(mTwoFingerRec->tapRadius(), 10);
mTwoFingerRec->setTapRadius(-100);
QCOMPARE(mTwoFingerRec->tapRadius(), 0);
mTwoFingerRec->setTapRadius(40);
QCOMPARE(mTwoFingerRec->tapRadius(), 40);
}
void testSuccessfulGesture()
{
// Test a successful gesture with two fingers, where the touch points wiggle only a little bit.
clearSignalSpys();
int tapRadius = mTwoFingerRec->tapRadius();
QPoint wiggleRoom = QPoint (tapRadius / 2, tapRadius / 2);
QTest::touchEvent(&mWidget, mDev)
.press(0, mTouchPointPos, (QWidget *) nullptr);
QTest::touchEvent(&mWidget, mDev)
.move(0, mTouchPointPos + wiggleRoom, (QWidget *) nullptr)
.press(1, mTouchPointPos, (QWidget *) nullptr);
QTest::touchEvent(&mWidget, mDev)
.move(0, mTouchPointPos, (QWidget *) nullptr)
.move(1, mTouchPointPos + wiggleRoom, (QWidget *) nullptr);
QTest::touchEvent(&mWidget, mDev)
.move(0, mTouchPointPos, (QWidget *) nullptr)
.release(1, mTouchPointPos, (QWidget *) nullptr);
QTest::touchEvent(&mWidget, mDev)
.release(0, mTouchPointPos, (QWidget *) nullptr);
if (mSpyTapStarted->count() == 0) {
QVERIFY(mSpyTapStarted->wait(1000));
}
if (mSpyTapFinished->count() == 0) {
QVERIFY(mSpyTapFinished->wait(1000));
}
QCOMPARE(mSpyTapStarted->count(), 1);
QCOMPARE(mSpyTapFinished->count(), 1);
QCOMPARE(mSpyTapCanceled->count(), 0);
QVERIFY(mSpyTapUpdated->count() > 0);
}
void testFailingGesture()
{
// Test a failing gesture with two fingers, where the touch points wiggle too much at beginning.
clearSignalSpys();
int tapRadius = mTwoFingerRec->tapRadius();
QPoint wiggleRoom = QPoint (tapRadius, tapRadius);
QTest::touchEvent(&mWidget, mDev)
.press(0, mTouchPointPos, (QWidget *) nullptr);
QTest::touchEvent(&mWidget, mDev)
.move(0, mTouchPointPos + wiggleRoom, (QWidget *) nullptr)
.press(1, mTouchPointPos, (QWidget *) nullptr);
QTest::touchEvent(&mWidget, mDev)
.move(0, mTouchPointPos, (QWidget *) nullptr)
.move(1, mTouchPointPos + wiggleRoom, (QWidget *) nullptr);
QTest::touchEvent(&mWidget, mDev)
.move(0, mTouchPointPos, (QWidget *) nullptr)
.release(1, mTouchPointPos, (QWidget *) nullptr);
QTest::touchEvent(&mWidget, mDev)
.release(0, mTouchPointPos, (QWidget *) nullptr);
QCOMPARE(mSpyTapStarted->count(), 0);
QCOMPARE(mSpyTapFinished->count(), 0);
QCOMPARE(mSpyTapCanceled->count(), 0);
QCOMPARE(mSpyTapUpdated->count(), 0);
}
void testFailingGesture2()
{
// Test a failing gesture with two fingers, where the touch points wiggle too much in the middle.
clearSignalSpys();
int tapRadius = mTwoFingerRec->tapRadius();
QPoint wiggleRoom = QPoint (tapRadius, tapRadius);
QTest::touchEvent(&mWidget, mDev)
.press(0, mTouchPointPos, (QWidget *) nullptr);
QTest::touchEvent(&mWidget, mDev)
.move(0, mTouchPointPos, (QWidget *) nullptr)
.press(1, mTouchPointPos, (QWidget *) nullptr);
QTest::touchEvent(&mWidget, mDev)
.move(0, mTouchPointPos, (QWidget *) nullptr)
.move(1, mTouchPointPos + wiggleRoom, (QWidget *) nullptr);
QTest::touchEvent(&mWidget, mDev)
.move(0, mTouchPointPos, (QWidget *) nullptr)
.release(1, mTouchPointPos, (QWidget *) nullptr);
QTest::touchEvent(&mWidget, mDev)
.release(0, mTouchPointPos, (QWidget *) nullptr);
if (mSpyTapStarted->count() == 0) {
QVERIFY(mSpyTapStarted->wait(1000));
}
QCOMPARE(mSpyTapStarted->count(), 1);
QCOMPARE(mSpyTapFinished->count(), 0);
QCOMPARE(mSpyTapCanceled->count(), 1);
QVERIFY(mSpyTapUpdated->count() >= 0);
}
void testFailingGesture3()
{
// Test a failing gesture with two fingers, where the touch points wiggle too much in the middle,
// and the second finger press and release successively.
clearSignalSpys();
int tapRadius = mTwoFingerRec->tapRadius();
QPoint wiggleRoom = QPoint (tapRadius, tapRadius);
QTest::touchEvent(&mWidget, mDev)
.press(0, mTouchPointPos, (QWidget *) nullptr);
QTest::touchEvent(&mWidget, mDev)
.move(0, mTouchPointPos, (QWidget *) nullptr)
.press(1, mTouchPointPos, (QWidget *) nullptr);
QTest::touchEvent(&mWidget, mDev)
.move(0, mTouchPointPos, (QWidget *) nullptr)
.move(1, mTouchPointPos + wiggleRoom, (QWidget *) nullptr);
QTest::touchEvent(&mWidget, mDev)
.move(0, mTouchPointPos, (QWidget *) nullptr)
.release(1, mTouchPointPos, (QWidget *) nullptr);
QTest::touchEvent(&mWidget, mDev)
.move(0, mTouchPointPos, (QWidget *) nullptr)
.press(1, mTouchPointPos, (QWidget *) nullptr);
QTest::touchEvent(&mWidget, mDev)
.move(0, mTouchPointPos, (QWidget *) nullptr)
.release(1, mTouchPointPos, (QWidget *) nullptr);
QTest::touchEvent(&mWidget, mDev)
.release(0, mTouchPointPos, (QWidget *) nullptr);
if (mSpyTapStarted->count() == 0) {
QVERIFY(mSpyTapStarted->wait(1000));
}
QCOMPARE(mSpyTapStarted->count(), 1);
QCOMPARE(mSpyTapFinished->count(), 0);
QCOMPARE(mSpyTapCanceled->count(), 1);
QVERIFY(mSpyTapUpdated->count() >= 0);
}
void testFailingGesture_threeFingers()
{
// the test a gesture with three fingers should be end with gesture canceled.
clearSignalSpys();
int tapRadius = mTwoFingerRec->tapRadius();
QPoint wiggleRoom = QPoint (tapRadius / 2, tapRadius / 2);
QTest::touchEvent(&mWidget, mDev)
.press(0, mTouchPointPos, (QWidget *) nullptr);
QTest::touchEvent(&mWidget, mDev)
.move(0, mTouchPointPos, (QWidget *) nullptr)
.press(1, mTouchPointPos, (QWidget *) nullptr);
QTest::touchEvent(&mWidget, mDev)
.move(0, mTouchPointPos, (QWidget *) nullptr)
.move(1, mTouchPointPos + wiggleRoom, (QWidget *) nullptr)
.press(2, mTouchPointPos, (QWidget *) nullptr);
QTest::touchEvent(&mWidget, mDev)
.move(0, mTouchPointPos, (QWidget *) nullptr)
.release(1, mTouchPointPos, (QWidget *) nullptr);
QTest::touchEvent(&mWidget, mDev)
.release(0, mTouchPointPos, (QWidget *) nullptr);
if (mSpyTapStarted->count() == 0) {
QVERIFY(mSpyTapStarted->wait(1000));
}
QCOMPARE(mSpyTapStarted->count(), 1);
QCOMPARE(mSpyTapFinished->count(), 0);
QCOMPARE(mSpyTapCanceled->count(), 1);
QVERIFY(mSpyTapUpdated->count() >= 0);
}
void testFailingGesture_threeFingers2()
{
clearSignalSpys();
QTest::touchEvent(&mWidget, mDev)
.press(0, mTouchPointPos, (QWidget *) nullptr);
QTest::touchEvent(&mWidget, mDev)
.move(0, mTouchPointPos, (QWidget *) nullptr)
.press(1, mTouchPointPos, (QWidget *) nullptr);
QTest::touchEvent(&mWidget, mDev)
.move(0, mTouchPointPos, (QWidget *) nullptr)
.move(1, mTouchPointPos, (QWidget *) nullptr)
.press(2, mTouchPointPos, (QWidget *) nullptr);
QTest::touchEvent(&mWidget, mDev)
.move(0, mTouchPointPos, (QWidget *) nullptr)
.move(1, mTouchPointPos, (QWidget *) nullptr)
.release(3, mTouchPointPos, (QWidget *) nullptr);
QTest::touchEvent(&mWidget, mDev)
.move(0, mTouchPointPos, (QWidget *) nullptr)
.release(1, mTouchPointPos, (QWidget *) nullptr);
QTest::touchEvent(&mWidget, mDev)
.move(0, mTouchPointPos, (QWidget *) nullptr)
.press(1, mTouchPointPos, (QWidget *) nullptr);
QTest::touchEvent(&mWidget, mDev)
.move(0, mTouchPointPos, (QWidget *) nullptr)
.release(1, mTouchPointPos, (QWidget *) nullptr);
QTest::touchEvent(&mWidget, mDev)
.release(1, mTouchPointPos, (QWidget *) nullptr);
if (mSpyTapStarted->count() == 0) {
QVERIFY(mSpyTapStarted->wait(1000));
}
QCOMPARE(mSpyTapStarted->count(), 1);
QCOMPARE(mSpyTapFinished->count(), 0);
QCOMPARE(mSpyTapCanceled->count(), 1);
QVERIFY(mSpyTapUpdated->count() >= 0);
}
void testFailingGesture_oneFinger()
{
// Test a failing gesture where we use only one finger.
clearSignalSpys();
int tapRadius = mTwoFingerRec->tapRadius();
QPoint wiggleRoom = QPoint (tapRadius / 2, tapRadius / 2);
QTest::touchEvent(&mWidget, mDev)
.press(0, mTouchPointPos, (QWidget *) nullptr);
QTest::touchEvent(&mWidget, mDev)
.move(0, mTouchPointPos + wiggleRoom, (QWidget *) nullptr);
QTest::touchEvent(&mWidget, mDev)
.move(0, mTouchPointPos, (QWidget *) nullptr);
QTest::touchEvent(&mWidget, mDev)
.release(0, mTouchPointPos, (QWidget *) nullptr);
QCOMPARE(mSpyTapStarted->count(), 0);
QCOMPARE(mSpyTapFinished->count(), 0);
QCOMPARE(mSpyTapCanceled->count(), 0);
QCOMPARE(mSpyTapUpdated->count(), 0);
}
void testSomeRandomTaps()
{
for (int i = 0; i < 50; ++i) {
int v1 = rand() % 450;
int v2 = rand() % 450;
mTouchPointPos = QPoint(v1, v2);
testSuccessfulGesture();
}
}
};
QTEST_MAIN(KTwoFingerSwipeTest)
#include "ktwofingertaptest.moc"
@@ -0,0 +1,15 @@
/*
This file is part of the KDE libraries
SPDX-FileCopyrightText: 2024 Nicolas Fella <nicolas.fella@gmx.de>
SPDX-License-Identifier: LGPL-2.1-or-later
*/
inline bool isWindowsCI()
{
#ifdef Q_OS_WIN
return qEnvironmentVariable("CI") == QLatin1String("true");
#else
return false;
#endif
}
@@ -0,0 +1,11 @@
### KApiDox Project-specific Overrides File
# define so that deprecated API is not skipped
PREDEFINED += \
KWIDGETSADDONS_EXPORT= \
"KWIDGETSADDONS_ENABLE_DEPRECATED_SINCE(x, y)=1" \
"KWIDGETSADDONS_BUILD_DEPRECATED_SINCE(x, y)=1" \
"KWIDGETSADDONS_DEPRECATED_VERSION(x, y, t)=" \
"KWIDGETSADDONS_DEPRECATED_VERSION_BELATED(x, y, tx, ty, t)=" \
"KWIDGETSADDONS_ENUMERATOR_DEPRECATED_VERSION(x, y, t)=" \
"KWIDGETSADDONS_ENUMERATOR_DEPRECATED_VERSION_BELATED(x, y, tx, ty, t)="
Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 156 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 547 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 854 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 754 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

@@ -0,0 +1 @@
add_subdirectory(kmessagebox)
@@ -0,0 +1,10 @@
add_executable(kwidgetaddons-example-kmessagebox main.cpp)
target_link_libraries(kwidgetaddons-example-kmessagebox
Qt6::Widgets
KF6::WidgetsAddons
)
# We don't want to install the tutorial
#install(TARGETS kwidgetaddons-example-kmessagebox ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
@@ -0,0 +1,41 @@
/*
This file is part of the KDE project
SPDX-FileCopyrightText: 2018 Friedrich W. H. Kossebau <kossebau@kde.org>
SPDX-FileCopyrightText: 2018 Olivier Churlaud <olivier@churlaud.com>
SPDX-FileCopyrightText: 2016 Juan Carlos Torres <carlosdgtorres@gmail.com>
SPDX-License-Identifier: LGPL-3.0-or-later
*/
#include <KMessageBox>
#include <QApplication>
#include <iostream>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
// Define the question answer buttons
KGuiItem primaryAction(QStringLiteral("Hello"), // the button label
QStringLiteral("view-filter"), // iconName, can be empty to fallback to default
QStringLiteral("This is a tooltip"),
QStringLiteral("This is a WhatsThis help text."));
KGuiItem secondaryAction(QStringLiteral("Bye")); // the button label
KMessageBox::ButtonCode res = KMessageBox::questionTwoActions(nullptr, // Parent, here none
// The description can contain HTML
QStringLiteral("Description to tell you to click<br />on <b>either</b> button"),
QStringLiteral("My Title"),
primaryAction,
secondaryAction);
if (res == KMessageBox::PrimaryAction) {
std::cout << "You clicked Hello\n";
return EXIT_SUCCESS;
} else {
std::cout << "You clicked Bye\n";
return EXIT_FAILURE;
}
}
@@ -0,0 +1,21 @@
maintainer:
description: Addons to QtWidgets
tier: 1
type: functional
platforms:
- name: Linux
- name: FreeBSD
- name: Windows
- name: macOS
- name: Android
portingAid: false
deprecated: false
release: true
libraries:
- cmake: "KF6::WidgetsAddons"
cmakename: KF6WidgetsAddons
public_lib: true
group: Frameworks
subgroup: Tier 1
public_example_dir: tests/
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More