Compare commits
3 Commits
08102153b1
...
dd7ab41749
Author | SHA1 | Date |
---|---|---|
Aire-One | dd7ab41749 | |
Aire-One | 09e56887d9 | |
Aire-One | 87a767705d |
|
@ -23,6 +23,7 @@
|
|||
"keygrabber",
|
||||
"ldoc",
|
||||
"leafo",
|
||||
"lldebugger",
|
||||
"luacheck",
|
||||
"luacheckrc",
|
||||
"luadoc",
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Busted",
|
||||
"type": "lua-local",
|
||||
"request": "launch",
|
||||
"program": {
|
||||
"command": "luarocks"
|
||||
},
|
||||
"args": ["test"]
|
||||
// "ignorePatterns": "^/usr"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -1,3 +1,9 @@
|
|||
-- Enable lua-local-debugger
|
||||
-- https://github.com/tomblind/local-lua-debugger-vscode
|
||||
if os.getenv "LOCAL_LUA_DEBUGGER_VSCODE" == "1" then
|
||||
require("lldebugger").start()
|
||||
end
|
||||
|
||||
-- Fake awesome modules
|
||||
package.loaded["gears.table"] = {
|
||||
hasitem = function(t, item)
|
||||
|
|
|
@ -23,7 +23,6 @@ describe("Awesome-slot", function()
|
|||
target = target,
|
||||
signal = "signal",
|
||||
slot = function() end,
|
||||
slot_params = { key = "value" },
|
||||
}
|
||||
|
||||
assert.is_not_nil(s)
|
||||
|
@ -36,28 +35,39 @@ describe("Awesome-slot", function()
|
|||
target = target,
|
||||
signal = "signal",
|
||||
slot = function() end,
|
||||
slot_params = { key = "value" },
|
||||
}
|
||||
|
||||
slot.remove(s)
|
||||
|
||||
assert.is_false(s.connected) -- remove should also invoke disconnect_signal
|
||||
assert.is_nil(slot.get_slot(s))
|
||||
end)
|
||||
|
||||
it("should connect slot (from constructor parameters)", function()
|
||||
it("should automatically connect slot", function()
|
||||
local target = new_target()
|
||||
|
||||
local s = slot {
|
||||
target = target,
|
||||
signal = "signal",
|
||||
slot = function() end,
|
||||
slot_params = { key = "value" },
|
||||
connect = true,
|
||||
}
|
||||
|
||||
assert.is_true(s.connected)
|
||||
end)
|
||||
|
||||
it("should prevent slot connection with parameter", function()
|
||||
local target = new_target()
|
||||
|
||||
local s = slot {
|
||||
target = target,
|
||||
signal = "signal",
|
||||
slot = function() end,
|
||||
connect = false,
|
||||
}
|
||||
|
||||
assert.is_false(s.connected)
|
||||
end)
|
||||
|
||||
it("should connect signal", function()
|
||||
local target = new_target()
|
||||
|
||||
|
@ -66,6 +76,7 @@ describe("Awesome-slot", function()
|
|||
signal = "signal",
|
||||
slot = function() end,
|
||||
slot_params = { key = "value" },
|
||||
connect = false,
|
||||
}
|
||||
|
||||
slot.connect(s)
|
||||
|
@ -80,8 +91,6 @@ describe("Awesome-slot", function()
|
|||
target = target,
|
||||
signal = "signal",
|
||||
slot = function() end,
|
||||
slot_params = { key = "value" },
|
||||
connect = true,
|
||||
}
|
||||
|
||||
slot.disconnect(s)
|
||||
|
@ -96,7 +105,6 @@ describe("Awesome-slot", function()
|
|||
target = target,
|
||||
signal = "signal",
|
||||
slot = function() end,
|
||||
slot_params = { key = "value" },
|
||||
}
|
||||
|
||||
assert.is_not_nil(slot.get_slot(s))
|
||||
|
@ -111,7 +119,6 @@ describe("Awesome-slot", function()
|
|||
target = target,
|
||||
signal = "signal",
|
||||
slot = function() end,
|
||||
slot_params = { key = "value" },
|
||||
}
|
||||
|
||||
assert.is_not_nil(slot.get_slot(id))
|
||||
|
@ -124,7 +131,6 @@ describe("Awesome-slot", function()
|
|||
target = target,
|
||||
signal = "signal",
|
||||
slot = function() end,
|
||||
slot_params = { key = "value" },
|
||||
}
|
||||
|
||||
assert.is_not_nil(s.id)
|
||||
|
@ -145,7 +151,6 @@ describe("Awesome-slot", function()
|
|||
signal = signal_name,
|
||||
slot = callback,
|
||||
slot_params = params,
|
||||
connect = true,
|
||||
}
|
||||
|
||||
target:emit_signal(signal_name)
|
||||
|
@ -167,7 +172,6 @@ describe("Awesome-slot", function()
|
|||
target = target,
|
||||
signal = signal_name,
|
||||
slot = callback,
|
||||
connect = true,
|
||||
}
|
||||
|
||||
target:emit_signal(signal_name, 1, 2, 3)
|
||||
|
|
|
@ -107,10 +107,10 @@ end
|
|||
-- @tparam any params.target The slot target object.
|
||||
-- @tparam string params.signal The signal the slot connects to.
|
||||
-- @tparam function params.slot The callback function to connect to the signal.
|
||||
-- @tparam table params.slot_params The parameters to pass to the callback
|
||||
-- @tparam[opt] table params.slot_params The parameters to pass to the callback
|
||||
-- function. (The signal will invoke the callback function with this table as
|
||||
-- parameter)
|
||||
-- @tparam[opt=false] boolean params.connect Connect the slot now.
|
||||
-- @tparam[opt=true] boolean params.connect Connect the slot now.
|
||||
-- @treturn Slot The created Slot instance.
|
||||
-- @constructorfct awesome_slot
|
||||
function awesome_slot.create(params)
|
||||
|
@ -127,7 +127,7 @@ function awesome_slot.create(params)
|
|||
-- Insert the new slot into the slots list
|
||||
awesome_slot._private.registered_slots[slot.id] = slot
|
||||
|
||||
if params.connect then
|
||||
if params.connect == nil or params.connect then
|
||||
awesome_slot.connect(slot)
|
||||
end
|
||||
|
||||
|
@ -142,7 +142,7 @@ function awesome_slot.remove(slot)
|
|||
local s = awesome_slot.get_slot(slot)
|
||||
|
||||
if s.connected then
|
||||
awesome_slot.disconnect_slot(s)
|
||||
awesome_slot.disconnect(s)
|
||||
end
|
||||
|
||||
awesome_slot._private.registered_slots[s.id] = nil
|
||||
|
|
Loading…
Reference in New Issue