Integration/regression testing for mod_xrandr
[notion/jeffpc.git] / test / integration / xrandr / .notion / mod_xrandr_mock.lua
blobf557f37577ca083efcb58fccb2d39bae699087ae
1 -- overwrite some methods in mod_xrandr to mock it
2 print('Mocking RandR inplementation')
4 local outputOne = { name = 'ONE', x = 0, y = 0, w = 1280, h = 960 }
5 local outputTwo = { name = 'TWO', x = 1280, y = 0, w = 1280, h = 1024 }
7 local n_screens = 2
9 function mod_xrandr.get_outputs(reg)
10 if reg:geom().x == 0 then
11 return { ONE = outputOne }
12 elseif n_screens > 1 then
13 return { TWO = outputTwo }
14 else
15 return {}
16 end
17 end
19 function mod_xrandr.get_all_outputs()
20 if n_screens > 1 then
21 return { ONE = outputOne, TWO = outputTwo }
22 else
23 return { ONE = outputOne }
24 end
25 end
27 function mx_names(mx)
28 local result = ''
29 mx:mx_i(function(child) result = result .. child:name() .. ', ' return true end)
30 return result
31 end
33 mod_xrandr_mock = {}
34 function mod_xrandr_mock.set_number_of_screens(n)
35 n_screens = n
36 if n == 1 then
37 os.execute("cp xrandr/fakexinerama-1monitor xrandr/.fakexinerama")
38 else
39 os.execute("cp xrandr/fakexinerama-2monitors xrandr/.fakexinerama")
40 end
41 end