# UpdateCmd.test --
#
#	Tests the implementation of the UpdateCmd.java file.
#
# Copyright (c) 1997 by Sun Microsystems, Inc.
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
# SCCS: @(#) UpdateCmd.test 1.2 98/01/14 16:38:54

# FIXME: compare and merge with event.test

if {[lsearch [namespace children] ::tcltest] == -1} {
    package require tcltest
    namespace import -force ::tcltest::*
}

setupJavaPackage

test UpdateCmd-1.1 {UpdateCmd.cmdProc} {
    update
} {}

test UpdateCmd-1.2 {UpdateCmd.cmdProc} {
    list [catch {update i} msg] $msg
} {0 {}}

test UpdateCmd-1.3 {UpdateCmd.cmdProc} {
    update idletasks
} {}

test UpdateCmd-1.4 {UpdateCmd.cmdProc} {
    list [catch {update idletasksx} msg] $msg
} {1 {bad option "idletasksx": must be idletasks}}

test UpdateCmd-1.5 {UpdateCmd.cmdProc} {
    list [catch {update foo} msg] $msg
} {1 {bad option "foo": must be idletasks}}

test UpdateCmd-1.6 {UpdateCmd.cmdProc} {
    list [catch {update idletasks 1 foo} msg] $msg
} {1 {wrong # args: should be "update ?idletasks?"}}

test UpdateCmd-2.1 {UpdateCmd.cmdProc, resetResult} {
    after idle "set x 10"
    update
} {} 

test UpdateCmd-2.2 {UpdateCmd.cmdProc, event loop is entered} {
    set x ""
    after idle "set x 10"
    update
    set x
} 10

foreach id [after info] {
    after cancel $id
}

# cleanup
::tcltest::cleanupTests
return
