This tests are not-really-good because they are overly specific. They
test for the current behaviour of the implementation, but I guess that a
valid implementation could also behave slightly different. However, for
now this will have to be enough.
Signed-off-by: Uli Schlachter <psychon@znc.in>
This adds new code so that we can count how often a specific widget is
visible inside of all widget hierarchies.
Signed-off-by: Uli Schlachter <psychon@znc.in>
* Move table functions out of awful.util into new gears.table
* travis: Use v9999 prefix for full requests
Make sure no newly deprecated functions are used
* Move all `awful.util.table.*` calls to `gears.table.*` calls
Move table test functions from awful/util_spec to new gears/table_spec
Change awful.util.subsets call to gears.math.subsets in awful/key.lua
This extracts the code for finding the next screen
from focus_bydirection to a separate method on
the screen object.
The main reason was to use the finding code without
actually changing the screen focus but this should
incidentally make the code slightly easier to test
as well since both concerns can be tested in
isolation.
Signed-off-by: Christoph Mertz <chris@nimel.de>
For loading a theme, beautiful.init() has to be called. We do not handle
dynamic changes of the theme, so if the theme is changed after something
was already queried, this change will not apply. This also means that
before the theme is loaded, nothing useful can be returned. In fact,
code that tries to access the theme during require() will never get a
useful value from beautiful, but just nils.
To catch this, one Travis build is modified so that an error is raised
if the theme is accessed before beautiful.init() was called.
Signed-off-by: Uli Schlachter <psychon@znc.in>
- Execute the tests without compiling, and don't mess with the source
files when coverage is enabled.
This ensures that the coverage report lines are correct.
This disables the doc tests, as their results would be unused.
Hack: it still expands macros on util.lua, because of
`util.get_themes_dir()` and `util.get_awesome_icon_dir()`, which might
be moved later. Ref:
https://github.com/awesomeWM/awesome/pull/1239#discussion_r93828178.
- ensure that BUILD_APIDOC and DO_COVERAGE are not used together
- awesomeConfig.cmake: add DO_COVERAGE as an option
- Travis: only install codecov with DO_COVERAGE=codecov
- Travis: do not use set -v; use set -x with DO_COVERAGE
- do not use trailing slashes with dirs in tests/examples/CMakeLists.txt / .luacov
- Use latest luacov (0.12.0-1) again
This reverts parts of 4cc6a815.
I think it is better to fix any failure that 4cc6a815 tried to work around.
- Travis: simplify/fix require('luacov') for functionaltests
- tests/examples/CMakeLists.txt: resolve ../.. in SOURCE_DIR
- tests/examples/CMakeLists.txt: add DO_COVERAGE to env
- Cleanup/simplify .luacov: work with SOURCE_DIRECTORY alone
- tests/run.sh: pass through / set SOURCE_DIRECTORY when running awesome
- tests/run.sh: resolve source_dir
- use DO_COVERAGE from env only
We already have a variant of this function for transforming an actual
matrix. This adds the corresponding static factory.
Signed-off-by: Uli Schlachter <psychon@znc.in>
Matrix operations are hard. Apparently I always keep confusing the order
that transformations are applied in the matrix resulting from a matrix
multiplication.
This commit fixes things in wibox.hierarchy that were wrong due to the
wrong order and changes a unit test so that it would now catch the
breakage (and makes sure that it does not happen again).
Signed-off-by: Uli Schlachter <psychon@znc.in>
The requirement to call add_signal() was added to catch typos. However, this
requirement became increasingly annoying with property::<name> signals and e.g.
gears.object allowing arbitrary properties to be changed.
All of this ended up in a single commit because tests/examples fails if I first
let add_signal() emit a deprecation warning.
Signed-off-by: Uli Schlachter <psychon@znc.in>
The problem was that get_square_distance() made the screen one pixel larger to
the bottom/right than it really was. Thus, the (x+0,y+0)-pixel of a screen that
was below or to the right of some other screen had distance zero to both of
these screens.
This commit fixes the screen size computation and adds a small unit test for
getbycoord() and get_square_distance().
Reported by Elv13 here:
https://github.com/awesomeWM/awesome/pull/878#issuecomment-219272864
Signed-off-by: Uli Schlachter <psychon@znc.in>
This library is a wrapper around pcall() / xpcall() that prints an error message
via gears.debug.print_error() in case of errors.
Signed-off-by: Uli Schlachter <psychon@znc.in>
This adds a test that checks that :setup{ false } filters out the false, just
like it already filters out nil values. Then, this also adds a test that checks
that properties (:setup{ foo = false }) are not filtered out, because the first
version of me check did that accidentally.
Signed-off-by: Uli Schlachter <psychon@znc.in>
This avoids having to mock half the C API just because all of awful is loaded
needlessly in this unit test and is generally a good idea.
Signed-off-by: Uli Schlachter <psychon@znc.in>
It's unused since commit 0aa4304bda. Before this was a stable sorting
algorithm since table.sort is allowed to be unstable. Apparently we don't need a
stable sorting algorithm anymore.
Signed-off-by: Uli Schlachter <psychon@znc.in>
Oh hey, Pango exports an API that allows to query for named colors based on the
famous rgb.txt! Let's use that!
Signed-off-by: Uli Schlachter <psychon@znc.in>
This adds support to gears.color.parse_color to parse things like "#fff" (one
character per color component, without alpha) and "#ffff0000ffff0000" (four
characters per component, with alpha).
This makes sense on its own, but should also help with
https://github.com/awesomeWM/awesome/issues/585.
Signed-off-by: Uli Schlachter <psychon@znc.in>
This adds a cyclic dependency between the function used for the weak signal and
an object with a __gc metamethod. The problem occurs since the GC will first
finalize the object (call its __gc metamethod) and only in the next generation
will it actually collect the garbage and remove the functions from weak-tables
using it as a key.
And yes this needs special code for Lua 5.1 because there __gc doesn't work on
tables. :-(
Signed-off-by: Uli Schlachter <psychon@znc.in>
Since weak signals specifically exist to do magic with the garbage collector, do
a couple of garbage collection cycles and verify that this does not disconnect
the callback function prematurely (the function is kept alive since it is a
local variable).
(I actually did a mistake that makes this enhanced test fail and fixed it before
committing)
Signed-off-by: Uli Schlachter <psychon@znc.in>
The way of icon path lookup for `menubar` is enhanced so that it is
based on a theme-oriented way as described in the specification:
Icon Theme Specification, Ver. 0.12
http://standards.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html
To accomplish this:
* Add the two new files `icon_theme.lua` and `index_theme.lua`.
The former implements an icon lookup algorithm suggested in the URL
above. The latter implements a helper object to parse the cache file
`index.theme` of which data is used by the former.
* Modify `menu_gen.lua` to use the new algorithm.
- The implementation of `lookup_category_icons` is changed
accordingly.
- The values of the field `all_categories.icon_name` are changed file
names to icon names, i.e., file extensions which are used to
indicate image file formats are removed.
* Add the new file `icon_theme_spec.lua` for a unit test for checking
if `icon_theme.lua` together with `index_theme.lua` works as
expected.
This function updates a hierarchy if the layout of some widgets changed. It does
nothing on the parts that did not change. This should be more efficient than
recomputing the whole hierarchy whenever something changes.
Once again, this has some positive results on the "benchmark test":
Before:
create wibox: 0.083016 sec/iter ( 13 iters, 1.161 sec for benchmark)
update textclock: 0.00391091 sec/iter (271 iters, 3.219 sec for benchmark)
relayout textclock: 0.00273234 sec/iter (397 iters, 1.087 sec for benchmark)
redraw textclock: 0.0010191 sec/iter (989 iters, 1.745 sec for benchmark)
After:
create wibox: 0.083146 sec/iter ( 13 iters, 1.163 sec for benchmark)
update textclock: 0.00170519 sec/iter (647 iters, 2.201 sec for benchmark)
relayout textclock: 0.000581637 sec/iter (1880 iters, 1.094 sec for benchmark)
redraw textclock: 0.0010167 sec/iter (997 iters, 1.773 sec for benchmark)
So again no difference for creating wiboxes (100.16% compared to before). This
time we also have no real difference for creating wiboxes (99.76%). Update (44%)
and relayout (21%) are improved a lot.
Closes https://github.com/awesomeWM/awesome/pull/463.
Signed-off-by: Uli Schlachter <psychon@znc.in>
This has some positive results on the "benchmark test". Each single number is
the best one out of three runs.
Before:
create wibox: 0.0826502 sec/iter ( 13 iters, 1.157 sec for benchmark)
update textclock: 0.0186952 sec/iter ( 57 iters, 2.473 sec for benchmark)
relayout textclock: 0.0158112 sec/iter ( 64 iters, 1.028 sec for benchmark)
redraw textclock: 0.0015197 sec/iter (662 iters, 1.861 sec for benchmark)
After:
create wibox: 0.0825672 sec/iter ( 13 iters, 1.154 sec for benchmark)
update textclock: 0.00378412 sec/iter (277 iters, 4.216 sec for benchmark)
relayout textclock: 0.00259056 sec/iter (420 iters, 1.09 sec for benchmark)
redraw textclock: 0.00105128 sec/iter (958 iters, 1.79 sec for benchmark)
We see no significant change in the creation of wiboxes (99.9% compared to
before). Update (20% of the previous run time), relayout (16%) and redraw (69%)
are all sped up by this change.
Signed-off-by: Uli Schlachter <psychon@znc.in>