1local runner = require("_runner") 2local place = require("awful.placement") 3local wibox = require("wibox") 4local beautiful = require("beautiful") 5local tooltip = require("awful.tooltip") 6local gears = require("gears") 7 8local steps = {} 9 10local w = wibox { 11 width = 250, 12 height = 250, 13 visible = true, 14 ontop = true 15} 16 17w:setup{ 18 image = beautiful.awesome_icon, 19 widget = wibox.widget.imagebox 20} 21 22-- Center eveything 23place.centered(w) 24place.centered(mouse) 25 26local tt = nil 27 28table.insert(steps, function() 29 tt = tooltip {text = "short", visible = true} 30 -- This tests changing the text while the tooltip is visible 31 tt:set_text("A long tooltip") 32 33 return true 34end) 35 36local align_pos = { 37 "top_left", "left", "bottom_left", "right", 38 "top_right", "bottom_right", "bottom", "top", 39} 40 41-- Test the various alignment code paths 42for _, v in ipairs(align_pos) do 43 table.insert(steps, function() 44 tt.align = v 45 46 return true 47 end) 48end 49 50-- Set a parent object 51table.insert(steps, function() 52 tt:add_to_object(w) 53 54 return true 55end) 56 57-- Test the other mode 58table.insert(steps, function() 59 tt.mode = "outside" 60 61 -- This only work when there is a mouse::enter event, create one 62 place.top_left(mouse) 63 place.centered(mouse) 64 65 return true 66end) 67 68--- Reset the wibox content and use a widget geometry. 69table.insert(steps, function() 70 tt:remove_from_object(w) 71 72 tt.visible = false 73 74 w:setup{ 75 { 76 image = beautiful.awesome_icon, 77 widget = wibox.widget.imagebox, 78 id = "myimagebox" 79 }, 80 top = 125, 81 bottom = 100, 82 left = 205, 83 right = 20 , 84 layout = wibox.container.margin 85 } 86 87 local imb = w:get_children_by_id("myimagebox")[1] 88 assert(imb) 89 90 tt:add_to_object(imb) 91 92 -- Move the mouse over the widget 93 place.top_left(mouse) 94 mouse.coords { 95 x = w.x + w.width - 20 - 12.5, 96 y = w.y + 125 + 12.5, 97 } 98 return true 99end) 100 101-- Test that the above move had the intended effect 102table.insert(steps, function() 103 assert(tt.current_position == "top", tt.current_position) 104 105 return true 106end) 107 108-- Try the preferred positions 109table.insert(steps, function() 110 tt.visible = false 111 112 tt.preferred_positions = {"right"} 113 114 tt.visible = true 115 116 assert(tt.current_position == "right") 117 118 return true 119end) 120 121-- Add a shape. 122table.insert(steps, function() 123 tt.shape = gears.shape.octogon 124 125 return true 126end) 127 128runner.run_steps(steps) 129 130-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 131