Author: titmuss
Date: Mon Feb 4 15:34:11 2008
New Revision: 1797
URL: http://svn.slimdevices.com?rev=1797&root=Jive&view=rev
Log:
[EMAIL PROTECTED] (orig r1787): titmuss | 2008-02-04 15:59:06 +0000
Bug: 6918
Description:
Applet to pay back macro commands, this is initially for testing crashes in
Choose Player. This applet will be extended to
allow automated testing of firmware updates and other functionality to be
peformed.
Added:
trunk/jive/src/pkg/jive/share/applets/MacroPlay/
trunk/jive/src/pkg/jive/share/applets/MacroPlay/MacroPlayApplet.lua (with
props)
trunk/jive/src/pkg/jive/share/applets/MacroPlay/MacroPlayMeta.lua (with
props)
trunk/jive/src/pkg/jive/share/applets/MacroPlay/strings.txt
Modified:
trunk/ (props changed)
Propchange: trunk/
------------------------------------------------------------------------------
--- svk:merge (original)
+++ svk:merge Mon Feb 4 15:34:11 2008
@@ -1,3 +1,3 @@
-bbe22326-0783-4b3a-ac2b-7ab96b24c8d9:/branches/7.0:1784
+bbe22326-0783-4b3a-ac2b-7ab96b24c8d9:/branches/7.0:1787
bbe22326-0783-4b3a-ac2b-7ab96b24c8d9:/branches/SN:1083
bbe22326-0783-4b3a-ac2b-7ab96b24c8d9:/branches/scrolling:1378
Added: trunk/jive/src/pkg/jive/share/applets/MacroPlay/MacroPlayApplet.lua
URL:
http://svn.slimdevices.com/trunk/jive/src/pkg/jive/share/applets/MacroPlay/MacroPlayApplet.lua?rev=1797&root=Jive&view=auto
==============================================================================
--- trunk/jive/src/pkg/jive/share/applets/MacroPlay/MacroPlayApplet.lua (added)
+++ trunk/jive/src/pkg/jive/share/applets/MacroPlay/MacroPlayApplet.lua Mon Feb
4 15:34:11 2008
@@ -1,0 +1,151 @@
+
+--[[
+=head1 NAME
+
+applets.MacroPlay.MarcoPlayApplet - applet to play ui sequences for testing.
+
+=head1 DESCRIPTION
+
+This applet will play ui sequences using a lua script for testing.
+
+=cut
+--]]
+
+
+-- stuff we use
+local ipairs, pairs, tostring = ipairs, pairs, tostring
+
+local oo = require("loop.simple")
+local math = require("math")
+local table = require("jive.utils.table")
+
+local Applet = require("jive.Applet")
+local Event = require("jive.ui.Event")
+local Framework = require("jive.ui.Framework")
+local Menu = require("jive.ui.Menu")
+local Task = require("jive.ui.Task")
+local Timer = require("jive.ui.Timer")
+
+local log = require("jive.utils.log").logger("applets.misc")
+
+
+local EVENT_KEY_PRESS = jive.ui.EVENT_KEY_PRESS
+local EVENT_KEY_DOWN = jive.ui.EVENT_KEY_DOWN
+local EVENT_KEY_UP = jive.ui.EVENT_KEY_UP
+local EVENT_KEY_HOLD = jive.ui.EVENT_KEY_HOLD
+local EVENT_SCROLL = jive.ui.EVENT_SCROLL
+local EVENT_CONSUME = jive.ui.EVENT_CONSUME
+local EVENT_ACTION = jive.ui.EVENT_ACTION
+local EVENT_WINDOW_POP = jive.ui.EVENT_WINDOW_POP
+
+local KEY_BACK = jive.ui.KEY_BACK
+local KEY_DOWN = jive.ui.KEY_DOWN
+local KEY_HOME = jive.ui.KEY_HOME
+local KEY_GO = jive.ui.KEY_GO
+local KEY_PLAY = jive.ui.KEY_PLAY
+
+
+module(...)
+oo.class(_M, Applet)
+
+
+-- XXX Load script from file
+local script = function()
+ log:info("Starting macro script")
+
+ -- key HOME
+ macroEvent(100, EVENT_KEY_PRESS, KEY_HOME)
+
+ while true do
+ -- key down until Choose Player
+ while not macroIsMenuItem("Choose Player") do
+ macroEvent(100, EVENT_KEY_PRESS, KEY_DOWN)
+ end
+
+ -- key go into Choose Player
+ macroEvent(10000, EVENT_KEY_PRESS, KEY_GO)
+
+ -- key back from Choose Player
+ macroEvent(100, EVENT_KEY_PRESS, KEY_BACK)
+
+ -- key down
+ macroEvent(100, EVENT_KEY_PRESS, KEY_DOWN)
+ end
+end
+
+
+-- macro state
+local task = false
+local timer = false
+
+
+-- play the macro
+function play(self)
+ task = Task("MacroPlay", self, script)
+ task:addTask()
+
+ timer = Timer(0, function()
+ task:addTask()
+ end, true)
+end
+
+
+-- delay macro for interval ms
+function macroDelay(interval)
+ timer:restart(interval)
+ Task:yield(false)
+end
+
+
+-- dispatch ui event Event(...), and delay for interval ms
+function macroEvent(interval, ...)
+ local event = Event:new(...)
+
+ log:info("macroEvent: ", event:tostring())
+
+ Framework:pushEvent(event)
+ macroDelay(interval)
+end
+
+
+-- returns the text of the selected menu item (or nil)
+function macroGetMenuText()
+ local window = Framework.windowStack[1]
+
+ -- find menu + selection
+ local item = false
+ window:iterate(function(widget)
+ if oo.instanceof(widget, Menu) then
+ item = widget:getSelectedItem()
+ end
+ end)
+
+ if not item then
+ return
+ end
+
+ -- assumes Group with "text" widget
+ return item:getWidget("text"):getValue()
+end
+
+
+-- returns true if the menu item 'text' is selected
+function macroIsMenuItem(text)
+ local menuText = macroGetMenuText()
+
+ log:info("macroIsMenuItem ", menuText, "==", text)
+
+ return tostring(menuText) == tostring(text)
+end
+
+
+--[[
+
+=head1 LICENSE
+
+Copyright 2007 Logitech. All Rights Reserved.
+
+This file is subject to the Logitech Public Source License Version 1.0. Please
see the LICENCE file for details.
+
+=cut
+--]]
Propchange: trunk/jive/src/pkg/jive/share/applets/MacroPlay/MacroPlayApplet.lua
------------------------------------------------------------------------------
svn:executable = *
Added: trunk/jive/src/pkg/jive/share/applets/MacroPlay/MacroPlayMeta.lua
URL:
http://svn.slimdevices.com/trunk/jive/src/pkg/jive/share/applets/MacroPlay/MacroPlayMeta.lua?rev=1797&root=Jive&view=auto
==============================================================================
--- trunk/jive/src/pkg/jive/share/applets/MacroPlay/MacroPlayMeta.lua (added)
+++ trunk/jive/src/pkg/jive/share/applets/MacroPlay/MacroPlayMeta.lua Mon Feb
4 15:34:11 2008
@@ -1,0 +1,44 @@
+
+--[[
+=head1 NAME
+
+applets.AutoFWUpdate.AutoFWUpdateMeta - AutoFWUpdate meta-info
+
+=head1 DESCRIPTION
+
+See L<applets.AutoFWUpdate.AutoFWUpdateApplet>.
+
+=head1 FUNCTIONS
+
+See L<jive.AppletMeta> for a description of standard applet meta functions.
+
+=cut
+--]]
+
+
+local oo = require("loop.simple")
+
+local AppletMeta = require("jive.AppletMeta")
+
+local appletManager = appletManager
+local jiveMain = jiveMain
+
+
+module(...)
+oo.class(_M, AppletMeta)
+
+
+function jiveVersion(meta)
+ return 1, 1
+end
+
+
+function defaultSettings(meta)
+end
+
+
+function registerApplet(meta)
+ -- menu item to start
+ jiveMain:addItem(meta:menuItem('macroPlay', 'advancedSettings',
'MACRO_PLAY', function(applet, ...) applet:play(...) end))
+end
+
Propchange: trunk/jive/src/pkg/jive/share/applets/MacroPlay/MacroPlayMeta.lua
------------------------------------------------------------------------------
svn:executable = *
Added: trunk/jive/src/pkg/jive/share/applets/MacroPlay/strings.txt
URL:
http://svn.slimdevices.com/trunk/jive/src/pkg/jive/share/applets/MacroPlay/strings.txt?rev=1797&root=Jive&view=auto
==============================================================================
--- trunk/jive/src/pkg/jive/share/applets/MacroPlay/strings.txt (added)
+++ trunk/jive/src/pkg/jive/share/applets/MacroPlay/strings.txt Mon Feb 4
15:34:11 2008
@@ -1,0 +1,3 @@
+
+MACRO_PLAY
+ EN Play Macro
_______________________________________________
Jive-checkins mailing list
[email protected]
http://lists.slimdevices.com/cgi-bin/mailman/listinfo/jive-checkins