Skip to content

Commit 5598f24

Browse files
committed
Copy & paste mod_xrandr_mock inside xrandr tests
I don't know why it's not finding mod_xrandr_mock now, I'd appreciate some help.
1 parent 9dd12ef commit 5598f24

File tree

3 files changed

+135
-0
lines changed

3 files changed

+135
-0
lines changed

test/integration/xrandr/01_remove_display.lua

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,48 @@
1+
-- TEMP
2+
-- See why it's not finding mod_xrandr_mock
3+
-- overwrite some methods in mod_xrandr to mock it
4+
print('Mocking RandR inplementation')
5+
6+
local outputOne = { name = 'ONE', x = 0, y = 0, w = 1280, h = 960 }
7+
local outputTwo = { name = 'TWO', x = 1280, y = 0, w = 1280, h = 1024 }
8+
9+
local n_screens = 2
10+
11+
function mod_xrandr.get_outputs(reg)
12+
if reg:geom().x == 0 then
13+
return { ONE = outputOne }
14+
elseif n_screens > 1 then
15+
return { TWO = outputTwo }
16+
else
17+
return {}
18+
end
19+
end
20+
21+
function mod_xrandr.get_all_outputs()
22+
if n_screens > 1 then
23+
return { ONE = outputOne, TWO = outputTwo }
24+
else
25+
return { ONE = outputOne }
26+
end
27+
end
28+
29+
function mx_names(mx)
30+
local result = ''
31+
mx:mx_i(function(child) result = result .. child:name() .. ', ' return true end)
32+
return result
33+
end
34+
35+
mod_xrandr_mock = {}
36+
function mod_xrandr_mock.set_number_of_screens(n)
37+
n_screens = n
38+
if n == 1 then
39+
os.execute("cp xrandr/fakexinerama-1monitor xrandr/.fakexinerama")
40+
else
41+
os.execute("cp xrandr/fakexinerama-2monitors xrandr/.fakexinerama")
42+
end
43+
end
44+
-- /TEMP
45+
146
if not notioncore.find_screen_id(0) then
247
return "Initial number of screens should be 2, first screen not found"
348
elseif not notioncore.find_screen_id(1) then

test/integration/xrandr/02_removed_display.lua

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,48 @@
1+
-- TEMP
2+
-- See why it's not finding mod_xrandr_mock
3+
-- overwrite some methods in mod_xrandr to mock it
4+
print('Mocking RandR inplementation')
5+
6+
local outputOne = { name = 'ONE', x = 0, y = 0, w = 1280, h = 960 }
7+
local outputTwo = { name = 'TWO', x = 1280, y = 0, w = 1280, h = 1024 }
8+
9+
local n_screens = 2
10+
11+
function mod_xrandr.get_outputs(reg)
12+
if reg:geom().x == 0 then
13+
return { ONE = outputOne }
14+
elseif n_screens > 1 then
15+
return { TWO = outputTwo }
16+
else
17+
return {}
18+
end
19+
end
20+
21+
function mod_xrandr.get_all_outputs()
22+
if n_screens > 1 then
23+
return { ONE = outputOne, TWO = outputTwo }
24+
else
25+
return { ONE = outputOne }
26+
end
27+
end
28+
29+
function mx_names(mx)
30+
local result = ''
31+
mx:mx_i(function(child) result = result .. child:name() .. ', ' return true end)
32+
return result
33+
end
34+
35+
mod_xrandr_mock = {}
36+
function mod_xrandr_mock.set_number_of_screens(n)
37+
n_screens = n
38+
if n == 1 then
39+
os.execute("cp xrandr/fakexinerama-1monitor xrandr/.fakexinerama")
40+
else
41+
os.execute("cp xrandr/fakexinerama-2monitors xrandr/.fakexinerama")
42+
end
43+
end
44+
-- /TEMP
45+
146
mod_xrandr.screenlayoutupdated()
247

348
if notioncore.find_screen_id(1) then

test/integration/xrandr/03_new_screen_has_ws.lua

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,48 @@
1+
-- TEMP
2+
-- See why it's not finding mod_xrandr_mock
3+
-- overwrite some methods in mod_xrandr to mock it
4+
print('Mocking RandR inplementation')
5+
6+
local outputOne = { name = 'ONE', x = 0, y = 0, w = 1280, h = 960 }
7+
local outputTwo = { name = 'TWO', x = 1280, y = 0, w = 1280, h = 1024 }
8+
9+
local n_screens = 2
10+
11+
function mod_xrandr.get_outputs(reg)
12+
if reg:geom().x == 0 then
13+
return { ONE = outputOne }
14+
elseif n_screens > 1 then
15+
return { TWO = outputTwo }
16+
else
17+
return {}
18+
end
19+
end
20+
21+
function mod_xrandr.get_all_outputs()
22+
if n_screens > 1 then
23+
return { ONE = outputOne, TWO = outputTwo }
24+
else
25+
return { ONE = outputOne }
26+
end
27+
end
28+
29+
function mx_names(mx)
30+
local result = ''
31+
mx:mx_i(function(child) result = result .. child:name() .. ', ' return true end)
32+
return result
33+
end
34+
35+
mod_xrandr_mock = {}
36+
function mod_xrandr_mock.set_number_of_screens(n)
37+
n_screens = n
38+
if n == 1 then
39+
os.execute("cp xrandr/fakexinerama-1monitor xrandr/.fakexinerama")
40+
else
41+
os.execute("cp xrandr/fakexinerama-2monitors xrandr/.fakexinerama")
42+
end
43+
end
44+
-- /TEMP
45+
146
mod_xrandr.screenlayoutupdated()
247

348
if (notioncore.find_screen_id(1) == Nil) then

0 commit comments

Comments
 (0)