Author: titmuss
Date: Tue Apr 29 02:35:20 2008
New Revision: 2384
URL: http://svn.slimdevices.com?rev=2384&root=Jive&view=rev
Log:
Bug: N/A
Description:
Improve smoke tests. Add macros to select menu items by index and by text
pattern,
these macros make the tests more robust.
Modified:
7.1/trunk/squeezeplay/src/squeezeplay/share/applets/MacroPlay/MacroPlayApplet.lua
7.1/trunk/squeezeplay/src/squeezeplay_jive/test/smoke/FactoryResetMacro.lua
7.1/trunk/squeezeplay/src/squeezeplay_jive/test/smoke/ForcedUpgradeMacro.lua
7.1/trunk/squeezeplay/src/squeezeplay_jive/test/smoke/HomeMenuMacro.lua
7.1/trunk/squeezeplay/src/squeezeplay_jive/test/smoke/Macros.lua
7.1/trunk/squeezeplay/src/squeezeplay_jive/test/smoke/PlaymodeMacro.lua
7.1/trunk/squeezeplay/src/squeezeplay_jive/test/smoke/PlaymodePause.bmp
7.1/trunk/squeezeplay/src/squeezeplay_jive/test/smoke/PlaymodePlay.bmp
7.1/trunk/squeezeplay/src/squeezeplay_jive/test/smoke/PlaymodeStop.bmp
7.1/trunk/squeezeplay/src/squeezeplay_jive/test/smoke/SoftwareUpgradeMacro.lua
Modified:
7.1/trunk/squeezeplay/src/squeezeplay/share/applets/MacroPlay/MacroPlayApplet.lua
URL:
http://svn.slimdevices.com/7.1/trunk/squeezeplay/src/squeezeplay/share/applets/MacroPlay/MacroPlayApplet.lua?rev=2384&root=Jive&r1=2383&r2=2384&view=diff
==============================================================================
---
7.1/trunk/squeezeplay/src/squeezeplay/share/applets/MacroPlay/MacroPlayApplet.lua
(original)
+++
7.1/trunk/squeezeplay/src/squeezeplay/share/applets/MacroPlay/MacroPlayApplet.lua
Tue Apr 29 02:35:20 2008
@@ -13,7 +13,7 @@
-- stuff we use
-local assert, getfenv, loadfile, ipairs, package, pairs, require, setfenv,
setmetatable, tostring, type = assert, getfenv, loadfile, ipairs, package,
pairs, require, setfenv, setmetatable, tostring, type
+local assert, getfenv, loadfile, ipairs, package, pairs, require, setfenv,
setmetatable, tostring, type, unpack = assert, getfenv, loadfile, ipairs,
package, pairs, require, setfenv, setmetatable, tostring, type, unpack
local oo = require("loop.simple")
local io = require("io")
@@ -135,16 +135,12 @@
sound = "BUMP",
}
- debug.dump(macro, -1)
-
if macro.passed then
item.icon = Icon("macroPass")
end
if macro.failed then
item.icon = Icon("macroFail")
end
-
- debug.dump(item, -1)
menu:addItem(item)
end
@@ -315,24 +311,83 @@
end
+-- returns the widgets of type class from the window
+function _macroFindWidget(class)
+ local window = Framework.windowStack[1]
+
+ -- find widget
+ local widget = {}
+ window:iterate(function(w)
+ if oo.instanceof(w, class) then
+ widget[#widget + 1] = w
+ end
+ end)
+
+ return unpack(widget)
+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)
-
+ local menu = _macroFindWidget(Menu)
+ if not menu then
+ return
+ end
+
+ local item = menu:getSelectedItem()
if not item then
return
end
-- assumes Group with "text" widget
return item:getWidget("text"):getValue()
+end
+
+
+-- select the menu item, using index
+function macroSelectMenuIndex(interval, index)
+ local menu = _macroFindWidget(Menu)
+ if not menu then
+ return
+ end
+
+ local ok = false
+
+ local len = #menu:getItems()
+ if index > len then
+ return false
+ end
+
+ while menu:getSelectedIndex() ~= index do
+ macroEvent(100, EVENT_KEY_PRESS, KEY_DOWN)
+ end
+
+ macroDelay(interval)
+ return true
+end
+
+
+-- select the menu item, based on pattern. this uses key down events.
+function macroSelectMenuItem(interval, pattern)
+ local menu = _macroFindWidget(Menu)
+ if not menu then
+ return
+ end
+
+ local len = #menu:getItems()
+
+ local ok = false
+ for i=1,len do
+ macroEvent(100, EVENT_KEY_PRESS, KEY_DOWN)
+
+ if macroIsMenuItem(pattern) then
+ ok = true
+ break
+ end
+ end
+
+ macroDelay(interval)
+ return ok
end
Modified:
7.1/trunk/squeezeplay/src/squeezeplay_jive/test/smoke/FactoryResetMacro.lua
URL:
http://svn.slimdevices.com/7.1/trunk/squeezeplay/src/squeezeplay_jive/test/smoke/FactoryResetMacro.lua?rev=2384&root=Jive&r1=2383&r2=2384&view=diff
==============================================================================
--- 7.1/trunk/squeezeplay/src/squeezeplay_jive/test/smoke/FactoryResetMacro.lua
(original)
+++ 7.1/trunk/squeezeplay/src/squeezeplay_jive/test/smoke/FactoryResetMacro.lua
Tue Apr 29 02:35:20 2008
@@ -4,9 +4,7 @@
-- Settings
-while not macroIsMenuItem("Settings") do
- macroEvent(100, EVENT_KEY_PRESS, KEY_DOWN)
-end
+macroSelectMenuItem(100, "Settings")
macroEvent(100, EVENT_KEY_PRESS, KEY_GO)
if not macroScreenshot(1000, "Settings") then
@@ -15,9 +13,7 @@
-- Advanced
-while not macroIsMenuItem("Advanced") do
- macroEvent(100, EVENT_KEY_PRESS, KEY_DOWN)
-end
+macroSelectMenuItem(100, "Advanced")
macroEvent(100, EVENT_KEY_PRESS, KEY_GO)
if not macroScreenshot(1000, "Advanced") then
@@ -26,9 +22,7 @@
-- Factory Reset
-while not macroIsMenuItem("Factory Reset") do
- macroEvent(100, EVENT_KEY_PRESS, KEY_DOWN)
-end
+macroSelectMenuItem(100, "Factory Reset")
macroEvent(500, EVENT_KEY_PRESS, KEY_GO)
if not macroScreenshot(1000, "FactoryReset1") then
@@ -37,9 +31,7 @@
-- Begin update
-while not macroIsMenuItem("Continue") do
- macroEvent(100, EVENT_KEY_PRESS, KEY_DOWN)
-end
+macroSelectMenuItem(100, "Continue")
macroEvent(1000, EVENT_KEY_PRESS, KEY_GO)
if not macroScreenshot(1000, "FactoryReset2") then
Modified:
7.1/trunk/squeezeplay/src/squeezeplay_jive/test/smoke/ForcedUpgradeMacro.lua
URL:
http://svn.slimdevices.com/7.1/trunk/squeezeplay/src/squeezeplay_jive/test/smoke/ForcedUpgradeMacro.lua?rev=2384&root=Jive&r1=2383&r2=2384&view=diff
==============================================================================
---
7.1/trunk/squeezeplay/src/squeezeplay_jive/test/smoke/ForcedUpgradeMacro.lua
(original)
+++
7.1/trunk/squeezeplay/src/squeezeplay_jive/test/smoke/ForcedUpgradeMacro.lua
Tue Apr 29 02:35:20 2008
@@ -11,9 +11,7 @@
-- Begin update
-while not macroIsMenuItem("Begin update") do
- return macroEvent(100, EVENT_KEY_PRESS, KEY_DOWN)
-end
+macroSelectMenuItem(100, "Begin update")
macroEvent(1000, EVENT_KEY_PRESS, KEY_GO)
if not macroScreenshot(1000, "CopyingUpdate") then
Modified:
7.1/trunk/squeezeplay/src/squeezeplay_jive/test/smoke/HomeMenuMacro.lua
URL:
http://svn.slimdevices.com/7.1/trunk/squeezeplay/src/squeezeplay_jive/test/smoke/HomeMenuMacro.lua?rev=2384&root=Jive&r1=2383&r2=2384&view=diff
==============================================================================
--- 7.1/trunk/squeezeplay/src/squeezeplay_jive/test/smoke/HomeMenuMacro.lua
(original)
+++ 7.1/trunk/squeezeplay/src/squeezeplay_jive/test/smoke/HomeMenuMacro.lua Tue
Apr 29 02:35:20 2008
@@ -2,6 +2,9 @@
-- go home
macroHome(1000)
+
+-- select top menu item
+macroSelectMenuIndex(100, 1)
-- check screen
if not macroScreenshot(1000, "HomeMenu") then
Modified: 7.1/trunk/squeezeplay/src/squeezeplay_jive/test/smoke/Macros.lua
URL:
http://svn.slimdevices.com/7.1/trunk/squeezeplay/src/squeezeplay_jive/test/smoke/Macros.lua?rev=2384&root=Jive&r1=2383&r2=2384&view=diff
==============================================================================
--- 7.1/trunk/squeezeplay/src/squeezeplay_jive/test/smoke/Macros.lua (original)
+++ 7.1/trunk/squeezeplay/src/squeezeplay_jive/test/smoke/Macros.lua Tue Apr 29
02:35:20 2008
@@ -1,31 +1,33 @@
return {
- auto=1,
+ auto=false,
autostart={ "homeMenu", "playmode" },
macros={
+ factoryReset={
+ desc="Verify a factory reset.",
+ file="FactoryResetMacro.lua",
+ name="Factory Reset"
+ },
forcedUpgrade={
desc="Forced software upgrade.",
file="ForcedUpgradeMacro.lua",
- name="Forced Upgrade",
+ name="Forced Upgrade"
+ },
+ homeMenu={
+ desc="Verify the home menu.",
+ file="HomeMenuMacro.lua",
+ name="Home Menu",
+ passed="Sun Apr 13 09:23:07 2008"
},
playmode={
desc="Playmode tests (stop/pause/play).",
file="PlaymodeMacro.lua",
- name="Playmode"
+ name="Playmode",
+ passed="Sun Apr 13 09:29:03 2008"
},
softwareUpgrade={
desc="User requested software upgrade.",
file="SoftwareUpgradeMacro.lua",
name="Software Upgrade"
- },
- homeMenu={
- desc="Verify the home menu.",
- file="HomeMenuMacro.lua",
- name="Home Menu"
- },
- factoryReset={
- desc="Verify a factory reset.",
- file="FactoryResetMacro.lua",
- name="Factory Reset"
}
}
}
Modified:
7.1/trunk/squeezeplay/src/squeezeplay_jive/test/smoke/PlaymodeMacro.lua
URL:
http://svn.slimdevices.com/7.1/trunk/squeezeplay/src/squeezeplay_jive/test/smoke/PlaymodeMacro.lua?rev=2384&root=Jive&r1=2383&r2=2384&view=diff
==============================================================================
--- 7.1/trunk/squeezeplay/src/squeezeplay_jive/test/smoke/PlaymodeMacro.lua
(original)
+++ 7.1/trunk/squeezeplay/src/squeezeplay_jive/test/smoke/PlaymodeMacro.lua Tue
Apr 29 02:35:20 2008
@@ -1,11 +1,9 @@
-- go home
-macroHome()
+macroHome(100)
--- key down until Now Playing
-while not macroIsMenuItem("Now Playing") do
- macroEvent(100, EVENT_KEY_PRESS, KEY_DOWN)
-end
+-- select Now Playing
+macroSelectMenuItem(100, "Now Playing")
-- key go into Now Playing
macroEvent(100, EVENT_KEY_PRESS, KEY_GO)
Modified:
7.1/trunk/squeezeplay/src/squeezeplay_jive/test/smoke/PlaymodePause.bmp
URL:
http://svn.slimdevices.com/7.1/trunk/squeezeplay/src/squeezeplay_jive/test/smoke/PlaymodePause.bmp?rev=2384&root=Jive&r1=2383&r2=2384&view=diff
==============================================================================
Binary files - no diff available.
Modified: 7.1/trunk/squeezeplay/src/squeezeplay_jive/test/smoke/PlaymodePlay.bmp
URL:
http://svn.slimdevices.com/7.1/trunk/squeezeplay/src/squeezeplay_jive/test/smoke/PlaymodePlay.bmp?rev=2384&root=Jive&r1=2383&r2=2384&view=diff
==============================================================================
Binary files - no diff available.
Modified: 7.1/trunk/squeezeplay/src/squeezeplay_jive/test/smoke/PlaymodeStop.bmp
URL:
http://svn.slimdevices.com/7.1/trunk/squeezeplay/src/squeezeplay_jive/test/smoke/PlaymodeStop.bmp?rev=2384&root=Jive&r1=2383&r2=2384&view=diff
==============================================================================
Binary files - no diff available.
Modified:
7.1/trunk/squeezeplay/src/squeezeplay_jive/test/smoke/SoftwareUpgradeMacro.lua
URL:
http://svn.slimdevices.com/7.1/trunk/squeezeplay/src/squeezeplay_jive/test/smoke/SoftwareUpgradeMacro.lua?rev=2384&root=Jive&r1=2383&r2=2384&view=diff
==============================================================================
---
7.1/trunk/squeezeplay/src/squeezeplay_jive/test/smoke/SoftwareUpgradeMacro.lua
(original)
+++
7.1/trunk/squeezeplay/src/squeezeplay_jive/test/smoke/SoftwareUpgradeMacro.lua
Tue Apr 29 02:35:20 2008
@@ -4,9 +4,7 @@
-- Settings
-while not macroIsMenuItem("Settings") do
- macroEvent(100, EVENT_KEY_PRESS, KEY_DOWN)
-end
+macroSelectMenuItem(100, "Settings")
macroEvent(100, EVENT_KEY_PRESS, KEY_GO)
if not macroScreenshot(1000, "Settings") then
@@ -15,9 +13,7 @@
-- Advanced
-while not macroIsMenuItem("Advanced") do
- macroEvent(100, EVENT_KEY_PRESS, KEY_DOWN)
-end
+macroSelectMenuItem(100, "Advanced")
macroEvent(100, EVENT_KEY_PRESS, KEY_GO)
if not macroScreenshot(1000, "Advanced") then
@@ -26,9 +22,7 @@
-- Software Update
-while not macroIsMenuItem("Software Update") do
- macroEvent(100, EVENT_KEY_PRESS, KEY_DOWN)
-end
+macroSelectMenuItem(100, "Software Update")
macroEvent(500, EVENT_KEY_PRESS, KEY_GO)
if not macroScreenshot(1000, "SoftwareUpdate") then
@@ -37,9 +31,7 @@
-- Begin update
-while not macroIsMenuItem("Begin update") do
- return macroEvent(100, EVENT_KEY_PRESS, KEY_DOWN)
-end
+macroSelectMenuItem(100, "Begin Update")
macroEvent(1000, EVENT_KEY_PRESS, KEY_GO)
if not macroScreenshot(1000, "CopyingUpdate") then
_______________________________________________
Jive-checkins mailing list
[email protected]
http://lists.slimdevices.com/cgi-bin/mailman/listinfo/jive-checkins