//-------------------------------------------------------------------------------
// constants
//-------------------------------------------------------------------------------
//
[Define]

TRUE 1
FALSE 0

OK 0
FAIL -1

MAX_WIDGET_AMOUNT 1000 // non-functional requirement

NAME 100
DESCRIPTION 101
LOGO_PATH 102
CAN_BE_ADDED 103
CAN_BE_REMOVED 104
KPUBLISHERID 105
KTYPE 106

EUnrecognized 0
EUidIcon 1
ESvgIcon 2
ESkinIcon 3
EMifIcon 4
ESkinAndMifIcon 5 
EImageIcon 6

[Enddefine]

//-------------------------------------------------------------------------------
// Test cases for the plugin
//-------------------------------------------------------------------------------
//


// Tests WmPlugin construction
[Test]
title WmPlugin create/delete
create wmunittest test
test HeapSet
test PluginCreate
pause 500
test PluginDelete
test HeapCheck
delete test
[Endtest] 

// Heap usage logging
[Test]
title WmPlugin memcon test
create wmunittest test
test HeapSet
test LogHeap "before wm"
test PluginCreate
test LogHeap "wm Active"
//
test SetMass 10
test PluginActivate
pause 500
test LogHeap "10 widgets"
//
test SetMass 20
test PluginWidgetsChanged
pause 250
test LogHeap "20 widgets"
//
test SetMass 30
test PluginWidgetsChanged
pause 250
test LogHeap "30 widgets"
//
test SetMass 40
test PluginWidgetsChanged
pause 250
test LogHeap "40 widgets"
//
test SetMass 50
test PluginWidgetsChanged
pause 250
test LogHeap "50 widgets"
//
test SetMass 60
test PluginWidgetsChanged
pause 250
test LogHeap "60 widgets"
//
test SetMass 70
test PluginWidgetsChanged
pause 250
test LogHeap "70 widgets"
//
test SetMass 80
test PluginWidgetsChanged
pause 250
test LogHeap "80 widgets"
//
test SetMass 90
test PluginWidgetsChanged
pause 250
test LogHeap "90 widgets"
//
test SetMass 100
test PluginWidgetsChanged
pause 250
test LogHeap "100 widgets"
//
test SetMass 200
test PluginWidgetsChanged
pause 250
test LogHeap "200 widgets"
//
test SetMass 300
test PluginWidgetsChanged
pause 250
test LogHeap "300 widgets"
//
test SetMass 400
test PluginWidgetsChanged
pause 250
test LogHeap "400 widgets"
//
test SetMass 500
test PluginWidgetsChanged
pause 250
test LogHeap "500 widgets"
//
test PluginDeactivate
pause 250
test LogHeap "wm deactive"
//
test PluginDeactivate
pause 500
test PluginDelete
test HeapCheck
test LogHeap "after wm"
delete test
[Endtest] 

// Tests WmPlugin Activate method
[Test]
title WmPlugin activate/deactivate
create wmunittest test
test HeapSet
test PluginCreate
test SetMass 10
test PluginActivate
pause 500
test PluginDeactivate
pause 500
test PluginDelete
test HeapCheck
delete test
[Endtest]

// Tests WmPlugin NotifyWidgetListChanged 10->10 wigets
[Test]
title WmPlugin notify 10->10
create wmunittest test
test HeapSet
test PluginCreate
test SetMass 10
test PluginActivate
pause 500
test SetMass 10
test PluginWidgetsChanged
pause 500
test PluginDeactivate
pause 500
test PluginDelete
test HeapCheck
delete test
[Endtest]

// Tests WmPlugin NotifyWidgetListChanged 10->11 widgets
[Test]
title WmPlugin notify 10->11
create wmunittest test
test HeapSet
test PluginCreate
test SetMass 10
test PluginActivate
pause 500
test SetMass 11
test PluginWidgetsChanged
pause 500
test PluginDeactivate
pause 500
test PluginDelete
test HeapCheck
delete test
[Endtest]

// Tests WmPlugin NotifyWidgetListChanged 10->9 widgets
[Test]
title WmPlugin notify 10->9
create wmunittest test
test HeapSet
test PluginCreate
test SetMass 10
test PluginActivate
pause 500
test SetMass 9
test PluginWidgetsChanged
pause 500
test PluginDeactivate
pause 500
test PluginDelete
test HeapCheck
delete test
[Endtest]

// Tests WmPlugin NotifyWidgetListChanged 0->10 widgets
[Test]
title WmPlugin notify 0->10
create wmunittest test
test HeapSet
test PluginCreate
test SetMass 0
test PluginActivate
pause 500
test SetMass 10
test PluginWidgetsChanged
pause 500
test PluginDeactivate
pause 500
test PluginDelete
test HeapCheck
delete test
[Endtest]

// Tests WmPlugin NotifyWidgetListChanged 10->0 widgets
[Test]
title WmPlugin notify 10->0
create wmunittest test
test HeapSet
test PluginCreate
test SetMass 10
test PluginActivate
pause 500
test SetMass 0
test PluginWidgetsChanged
pause 500
test PluginDeactivate
pause 500
test PluginDelete
test HeapCheck
delete test
[Endtest]

// Tests WmPlugin NotifyWidgetListChanged with ridiculous amount of widgets
// testing the OOM error handling
[Test]
title WmPlugin notify OOM
create wmunittest test
test HeapSet
test PluginCreate
test SetMass 10
test PluginActivate
pause 500
test SetMass 10000
test PluginWidgetsChanged
pause 500
test PluginDeactivate
pause 500
test PluginDelete
test HeapCheck
delete test
[Endtest]

// Tests WmPlugin with large data amount
[Test]
title WmPlugin capacity
create wmunittest test
test HeapSet
test PluginCreate
test SetMass MAX_WIDGET_AMOUNT
test PluginActivate
pause 3000
test PluginDelete
test HeapCheck
delete test
[Endtest] 

// Tests WmPlugin by notifying widget list changed hundreds of times
// with different widget amounts and different timeouts. Target is to
// interrupt the previous update process test that it is cancelled ok
[Test]
title WmPlugin robustness
create wmunittest test
test HeapSet
test PluginCreate
test SetMass 5
test PluginActivate
pause 500
loop 100
test SetMass 10
test PluginWidgetsChanged
pause 10
test SetMass 15
test PluginWidgetsChanged
pause 90
test SetMass 11
test PluginWidgetsChanged
pause 50
test SetMass 16
test PluginWidgetsChanged
pause 120
endloop
test PluginDeactivate
pause 500
test PluginDelete
test HeapCheck
delete test
[Endtest] 

// Tests WmPlugin by notifying widget list changed hundreds of times
// with no change in the widget list at all -> there should be no
// unnecessary drawing in widget manager UI at all
[Test]
title WmPlugin robustness 2
create wmunittest test
test HeapSet
test PluginCreate
test SetMass 5
test PluginActivate
pause 500
loop 100
test SetMass 10
test PluginWidgetsChanged
endloop
pause 500
test PluginDeactivate
pause 500
test PluginDelete
test HeapCheck
delete test
[Endtest] 


//-------------------------------------------------------------------------------
// Test cases for notifications where widget data changes
//-------------------------------------------------------------------------------
//

// Tests WmPlugin Notify one widget name changes
[Test]
title WmPlugin change name
create wmunittest test
test HeapSet
test PluginCreate
test SetMass 5
test PluginActivate
pause 1000
test ChangeContent 1 NAME "New widget name!"
test PluginWidgetsChanged
pause 1000
test ChangeContent 1 NAME "Name changes again!"
test PluginWidgetsChanged
pause 1000
test PluginDeactivate
pause 500
test PluginDelete
test HeapCheck
delete test
[Endtest]

// Tests WmPlugin Notify one widget descr. changes
[Test]
title WmPlugin change description
create wmunittest test
test HeapSet
test PluginCreate
test SetMass 5
test PluginActivate
pause 1000
test ChangeContent 1 DESCRIPTION "New description!"
test PluginWidgetsChanged
pause 1000
test ChangeContent 1 DESCRIPTION "Description changes again!"
test PluginWidgetsChanged
pause 1000
test PluginDeactivate
pause 500
test PluginDelete
test HeapCheck
delete test
[Endtest]

// Tests WmPlugin Notify one widget logo changes
[Test]
title WmPlugin change logo
create wmunittest test
test HeapSet
test PluginCreate
test SetMass 5
test PluginActivate
pause 1000
test ChangeContent 1 LOGO_PATH "uid(0x10005901)"
test PluginWidgetsChanged
pause 1000
test ChangeContent 1 LOGO_PATH "c:\testframework\wmunittest\wmlogo\logo.svg"
test PluginWidgetsChanged
pause 1000
test PluginDeactivate
pause 500
test PluginDelete
test HeapCheck
delete test
[Endtest]

// Tests WmPlugin Notify CanbeAdded values change
[Test]
title WmPlugin change plus-sign
create wmunittest test
test HeapSet
test PluginCreate
test SetMass 5
test PluginActivate
pause 1000
test ChangeContent 1 CAN_BE_ADDED "0"
test PluginWidgetsChanged
pause 1000
test ChangeContent 1 CAN_BE_ADDED "1"
test PluginWidgetsChanged
pause 1000
test PluginDeactivate
pause 500
test PluginDelete
test HeapCheck
delete test
[Endtest]



//-------------------------------------------------------------------------------
// Test cases for the persistent widget order
//-------------------------------------------------------------------------------
//

// Tests persistent widget order NewL method
[Test]
title Widget order create
create wmunittest test
test HeapSet
test WidgetOrderCreate
test WidgetOrderCheckIsEmpty TRUE
test WidgetOrderDelete
test HeapCheck
delete test
[Endtest] 

// Test persistent widget order STORE method
[Test]
title Widget order store
create wmunittest test
test HeapSet
test WidgetOrderCreate
test SetMass 5
test WidgetOrderSave
test WidgetOrderDelete
test HeapCheck
delete test
[Endtest] 

// Test persistent widget order STORE method when storing an empty array
[Test]
title Widget order store empty
create wmunittest test
test HeapSet
test WidgetOrderCreate
test SetMass 0
test WidgetOrderSave
test WidgetOrderDelete
test HeapCheck
delete test
[Endtest] 


// Tests persistent widget order LOAD method
[Test]
title Widget order load
create wmunittest test
test HeapSet
test WidgetOrderCreate
test SetMass 5
test WidgetOrderSave
test WidgetOrderDelete
test WidgetOrderCreate
test WidgetOrderLoad
test WidgetOrderCheckIsEmpty FALSE
test WidgetOrderDelete
test HeapCheck
delete test
[Endtest] 

// Tests persistent widget order LOAD method when count is ZERO
[Test]
title Widget order load empty
create wmunittest test
test HeapSet
test WidgetOrderCreate
test SetMass 0
test WidgetOrderSave
test WidgetOrderDelete
test WidgetOrderCreate
test WidgetOrderLoad
test WidgetOrderCheckIsEmpty TRUE
test WidgetOrderDelete
test HeapCheck
delete test
[Endtest] 

// Tests persistent widget order INDEXOF method
[Test]
title Widget order use
create wmunittest test
test HeapSet
test WidgetOrderCreate
test SetMass 8
test WidgetOrderSave
test WidgetOrderDelete
test WidgetOrderCreate
test WidgetOrderLoad
test WidgetOrderCheckIsEmpty FALSE
test SetMass 7
test WidgetOrderUse
test WidgetOrderDelete
test HeapCheck
delete test
[Endtest] 

// Tests persistent widget order INDEXOF method when class is empty
[Test]
title Widget order use empty
create wmunittest test
test HeapSet
test WidgetOrderCreate
test SetMass 0
test WidgetOrderSave
test WidgetOrderDelete
test WidgetOrderCreate
test WidgetOrderLoad
test WidgetOrderCheckIsEmpty TRUE
test SetMass 18
test WidgetOrderUse
test WidgetOrderDelete
test HeapCheck
delete test
[Endtest] 

// Tests persistent widget order with large data amount
[Test]
title Widget order capacity
create wmunittest test
test HeapSet
test WidgetOrderCreate
test SetMass MAX_WIDGET_AMOUNT
test WidgetOrderSave
test WidgetOrderDelete
test WidgetOrderCreate
test WidgetOrderLoad
test SetMass MAX_WIDGET_AMOUNT
test WidgetOrderUse
test WidgetOrderDelete
test HeapCheck
delete test
[Endtest] 

// Tests persistent widget order save & load 100 times in sequence
[Test]
title Widget order robustness
create wmunittest test
test HeapSet
test WidgetOrderCreate
test SetMass 100
loop 100
test WidgetOrderSave
endloop
test WidgetOrderDelete
test WidgetOrderCreate
test SetMass 100
loop 100
test WidgetOrderLoad
endloop
test WidgetOrderUse
test WidgetOrderDelete
test HeapCheck
delete test
[Endtest] 


//-------------------------------------------------------------------------------
// Test cases for the image converter
//-------------------------------------------------------------------------------
//

// Tests image converter NewL method
[Test]
title Image converter create delete
create wmunittest test
test HeapSet
test ImageConverterCreate
test ImageConverterDelete
test HeapCheck
delete test
[Endtest] 

// Tests malformed icon string formats
[Test]
title malformed image formats
create wmunittest test
test HeapSet
test ImageConverterCreate
test ImageConverterConvert "foo bar" FAIL
test ImageConverterConvert "*************" FAIL
test ImageConverterConvert "uid skin mif logo icon jpg jpeg icon" FAIL
test ImageConverterConvert "girl.jpg" FAIL
test ImageConverterConvert "dirty_hack.exe" FAIL
test ImageConverterConvert "c:/testframework/wmunittest/wmlogo/logo.jpg" FAIL
test ImageConverterConvert "skin[0x10005a26 0x1000]" FAIL
test ImageConverterConvert "skin(0x10005a26)" FAIL
test ImageConverterConvert "mif(c:\testframework\wmunittest\wmlogo\logo.mif)" FAIL
test ImageConverterConvert "mif(c:\testframework\wmunittest\wmlogo\logo.mif XXX YYY)" FAIL
test ImageConverterConvert "mif  ( 16384 16385)" FAIL
test ImageConverterConvert "skin( 0x100056c6 0x86 ):mif ( c:\testframework\wmunittest\wmlogo\logo.mif )" FAIL
test ImageConverterConvert "    uid(0x10005901)" FAIL
test ImageConverterConvert "uidaan(0x10005901)" FAIL
test ImageConverterConvert "uid (%%%)" FAIL
test ImageConverterDelete
test HeapCheck
delete test
[Endtest] 


// the SKIN test will never pass on STIF because STIF AppUI does
// not have EAknEnableSkin flag defined in its BaseConstructL
// therefore commented out.

/*
// Tests image converter with skin syntax
[Test]
title Image converter skin
create wmunittest test
test HeapSet
test ImageConverterCreate
test ImageConverterConvert "skin(270501603 4145)" OK
test ImageConverterDelete
test HeapCheck
delete test
[Endtest]

// Tests image converter with skin syntax (hex)
[Test]
title Image converter skin (hex)
create wmunittest test
test HeapSet
test ImageConverterCreate
test ImageConverterConvert "skin(0x101F86E3 0x100d)" OK
test ImageConverterDelete
test HeapCheck
delete test
[Endtest]

// Tests image converter with skin syntax (padded with spaces)
[Test]
title Image converter skin (padded)
create wmunittest test
test HeapSet
test ImageConverterCreate
test ImageConverterConvert "skin ( 270501603 4145 ) " OK
test ImageConverterDelete
test HeapCheck
delete test
[Endtest]
*/

// Tests image converter skin method with null skin item ids
[Test]
title Image converter skin (null)
create wmunittest test
test HeapSet
test ImageConverterCreate
test ImageConverterConvert "skin(0 0)" FAIL
test ImageConverterDelete
test HeapCheck
delete test
[Endtest]

// Tests image converter with skin/mif syntax
[Test]
title Image converter skin/mif
create wmunittest test
test HeapSet
test ImageConverterCreate
test ImageConverterConvert "skin(270501603 4145):mif(c:\testframework\wmunittest\wmlogo\logo.mif 16384 16385)" OK
test ImageConverterDelete
test HeapCheck
delete test
[Endtest] 

// Tests image converter with skin/mif syntax (hex)
[Test]
title Image converter skin/mif (hex)
create wmunittest test
test HeapSet
test ImageConverterCreate
test ImageConverterConvert "skin(0x101F86E3 0x1031):mif(c:\testframework\wmunittest\wmlogo\logo.mif 0x4000 0x4001)" OK
test ImageConverterDelete
test HeapCheck
delete test
[Endtest] 

// Tests image converter with skin/mif syntax (padded with spaces)
[Test]
title Image converter skin/mif (padded)
create wmunittest test
test HeapSet
test ImageConverterCreate
test ImageConverterConvert "skin (  0x101F86E3 0x1031  ) :mif ( c:\testframework\wmunittest\wmlogo\logo.mif   0x4000  0x4001 ) " OK
test ImageConverterDelete
test HeapCheck
delete test
[Endtest] 

// Tests image converter mif method
[Test]
title Image converter mif
create wmunittest test
test HeapSet
test ImageConverterCreate
test ImageConverterConvert "mif(c:\testframework\wmunittest\wmlogo\logo.mif 16384 16385)" OK
test ImageConverterDelete
test HeapCheck
delete test
[Endtest]

// Tests image converter mif method, mask missing
[Test]
title Image converter mif (no mask)
create wmunittest test
test HeapSet
test ImageConverterCreate
test ImageConverterConvert "mif(c:\testframework\wmunittest\wmlogo\logo.mif 16384)" OK
test ImageConverterDelete
test HeapCheck
delete test
[Endtest]

// Tests image converter mif method (hex)
[Test]
title Image converter mif (hex)
create wmunittest test
test HeapSet
test ImageConverterCreate
test ImageConverterConvert "mif(c:\testframework\wmunittest\wmlogo\logo.mif 0x4000 0x4001)" OK
test ImageConverterDelete
test HeapCheck
delete test
[Endtest]

// Tests image converter mif method (padded with spaces)
[Test]
title Image converter mif (padded)
create wmunittest test
test HeapSet
test ImageConverterCreate
test ImageConverterConvert "mif (  c:\testframework\wmunittest\wmlogo\logo.mif  16384  16385  ) " OK
test ImageConverterDelete
test HeapCheck
delete test
[Endtest]


// Tests image converter mif method with invalid path
[Test]
title Image converter mif (invalid path)
create wmunittest test
test HeapSet
test ImageConverterCreate
test ImageConverterConvert "mif(c:\blabla.mif 16384 16385)" FAIL
test ImageConverterDelete
test HeapCheck
delete test
[Endtest]

// Tests image converter mif method with invalid bitmap & mask ids
[Test]
title Image converter mif (invalid ids)
create wmunittest test
test HeapSet
test ImageConverterCreate
test ImageConverterConvert "mif(c:\testframework\wmunittest\wmlogo\logo.mif 1 2)" FAIL
test ImageConverterDelete
test HeapCheck
delete test
[Endtest]

// Tests image converter uid method
[Test]
title Image converter uid
create wmunittest test
test HeapSet
test ImageConverterCreate
test ImageConverterConvert "uid(268458241)" OK
test ImageConverterDelete
test HeapCheck
delete test
[Endtest]

// Tests image converter uid method (hex)
[Test]
title Image converter uid (hex)
create wmunittest test
test HeapSet
test ImageConverterCreate
test ImageConverterConvert "uid(0x10005901)" OK
test ImageConverterDelete
test HeapCheck
delete test
[Endtest]

// Tests image converter uid method (padded with spaces)
[Test]
title Image converter uid (padded)
create wmunittest test
test HeapSet
test ImageConverterCreate
test ImageConverterConvert "uid (  0x10005901  ) " OK
test ImageConverterDelete
test HeapCheck
delete test
[Endtest]

// Tests image converter uid method with null uid
[Test]
title Image converter uid (null)
create wmunittest test
test HeapSet
test ImageConverterCreate
test ImageConverterConvert "uid(0x0)" FAIL
test ImageConverterDelete
test HeapCheck
delete test
[Endtest]

// Tests image converter uid method with wrt widget uid.
[Test]
title Image converter wrt widget
create wmunittest test
test HeapSet
test InstallWrtWidget "c:\testframework\wmunittest\wmlogo\test.wgz"
test ImageConverterCreate
test ImageConverterConvert "uid(0x2000DAD2)" OK
test ImageConverterDelete
test UninstallWrtWidget "0x2000DAD2"
test HeapCheck
delete test
[Endtest]

// Tests image converter svg method
[Test]
title Image converter svg
create wmunittest test
test HeapSet
test ImageConverterCreate
test ImageConverterConvert "c:\testframework\wmunittest\wmlogo\logo.svg" OK
test ImageConverterDelete
test HeapCheck
delete test
[Endtest]

// Tests image converter svg method corrupt file.
[Test]
title Image converter svg (corrupted)
create wmunittest test
test HeapSet
test ImageConverterCreate
test ImageConverterConvert "c:\testframework\wmunittest\wmlogo\logocorrupt.svg" FAIL
test ImageConverterDelete
test HeapCheck
delete test
[Endtest]

// Tests image converter png method
[Test]
title Image converter png
create wmunittest test
test HeapSet
test ImageConverterCreate
test ImageConverterConvert "c:\testframework\wmunittest\wmlogo\logo.png" OK
test ImageConverterDelete
test HeapCheck
delete test
[Endtest]

// Tests image converter png method corrupt file.
[Test]
title Image converter png (corrupted)
create wmunittest test
test HeapSet
test ImageConverterCreate
test ImageConverterConvert "c:\testframework\wmunittest\wmlogo\logocorrupt.png" FAIL
test ImageConverterDelete
test HeapCheck
delete test
[Endtest]

// Tests image converter jpeg method
[Test]
title Image converter jpeg
create wmunittest test
test HeapSet
test ImageConverterCreate
test ImageConverterConvert "c:\testframework\wmunittest\wmlogo\logo.jpg" OK
test ImageConverterDelete
test HeapCheck
delete test
[Endtest]

// Tests image converter jpeg method
[Test]
title Image converter jpeg (corrupted)
create wmunittest test
test HeapSet
test ImageConverterCreate
test ImageConverterConvert "c:\testframework\wmunittest\wmlogo\logocorrupt.jpg" FAIL
test ImageConverterDelete
test HeapCheck
delete test
[Endtest]

//-------------------------------------------------------------------------------
// Misc Test cases
//-------------------------------------------------------------------------------
//

// Tests Uninstall
[Test]
title Uninstall
create wmunittest test
test PluginCreate
test InstallWrtWidget "c:\testframework\wmunittest\wmlogo\test.wgz"
test SetMass 1
test ChangeContent 0 KPUBLISHERID "com.nokia.widget.foreca.touchweather"
test PluginActivate
pause 500
test UninstallUid
test Uninstall
test UninstallUid
test WaitUninstallToFinnish
test CleanUninstall
pause 3000
test PluginDeactivate
pause 500
test PluginDelete
test WasUnistalled "com.nokia.widget.foreca.touchweather"
delete test
[Endtest]

// Tests Uninstall
[Test]
title Cancel Uninstall
create wmunittest test
test PluginCreate
test InstallWrtWidget "c:\testframework\wmunittest\wmlogo\test.wgz"
test SetMass 1
test ChangeContent 0 KPUBLISHERID "com.nokia.widget.foreca.touchweather"
test PluginActivate
pause 500
test Uninstall
pause 500
test CancelUninstall
pause 500
test PluginDeactivate
pause 500
test PluginDelete
delete test
[Endtest]

// Tests error note
[Test]
title Other error note
create wmunittest test
test HeapSet
test PluginCreate
test PluginActivate
test ErrorPopup
pause 3000
test PluginDelete
test HeapCheck
delete test
[Endtest]

/*
// Test for heikki to play :)
[Test]
title WmPlugin 1h test
create wmunittest test
test HeapSet
test PluginCreate
test SetMass 500
test PluginActivate
pause 3600000
test PluginDelete
test HeapCheck
delete test
[Endtest]
*/


