File: test_xrandr.lua

package info (click to toggle)
notion 4.0.2%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 4,676 kB
  • sloc: ansic: 47,508; sh: 2,096; makefile: 603; perl: 270
file content (59 lines) | stat: -rw-r--r-- 1,864 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
-- {{{ mock notion context
local firstscreen = {
    geom = function() return { x=0, y=0, w=1680, h=1050 } end,
    name = function() return "WScreen<1>" end,
    id = function() return 0 end
}
local secondscreen = {
    geom = function() return { x=1680, y=0, w=1920, h=1080 } end,
    name = function() return "WScreen" end,
    id = function() return 1 end
}

notioncore = {
  load_module = function() return 1 end,
  get_hook = function() return { add = function() end; } end,
  region_i = function(callback, type)
      local next = callback(firstscreen)
      if next then callback(secondscreen) end
  end
}

function dopath()
end

local all_outputs = { VGA1 = { x=0, y=0, w=1680, h=1050, name='VGA1' }, LVDS1 = { x=1680, y=0, w=1920, h=1080, name='LVDS1' } }

_G["mod_xrandr"] = {
--  query_screens = function() end
    get_all_outputs = function()
            return all_outputs;
        end
}

-- }}}

-- load xrandr module lua code
dofile('mod_xrandr.lua')
dofile('cfg_xrandr.lua')

local falls_within_secondscreen = falls_within(secondscreen.geom())
assert(falls_within_secondscreen(secondscreen:geom()))
assert(falls_within_secondscreen(firstscreen:geom())==false)

local outputs_within_secondscreen = mod_xrandr.get_outputs_within(all_outputs, secondscreen)
assert(singleton(outputs_within_secondscreen))
assert(firstValue(outputs_within_secondscreen).y == 0)
assert(firstValue(outputs_within_secondscreen).x == 1680)

local candidates = candidate_screens_for_output(1, all_outputs, 'VGA1')
assert(singleton(candidates))
assert(firstKey(candidates) == "WScreen<1>")

candidates = candidate_screens_for_outputs(1, all_outputs, {'VGA1'})
assert(singleton(candidates))
assert(firstKey(candidates) == "WScreen<1>")

candidates = candidate_screens_for_output(1, all_outputs, 'LVDS1')
assert(singleton(candidates))
assert(firstKey(candidates) == "WScreen")