1# This file is a Tcl script to test out Tk's Windows specific
2# clipboard code.  It is organized in the standard fashion for Tcl
3# tests.
4#
5# This file contains a collection of tests for one or more of the Tcl
6# built-in commands.  Sourcing this file into Tcl runs the tests and
7# generates output for errors.  No output means no errors were found.
8#
9# Copyright (c) 1997 by Sun Microsystems, Inc.
10# Copyright (c) 1998-2000 by Scriptics Corporation.
11# All rights reserved.
12#
13# RCS: @(#) $Id$
14
15package require tcltest 2.1
16eval tcltest::configure $argv
17tcltest::loadTestedCommands
18
19# Note that these tests may fail if another application is grabbing the
20# clipboard (e.g. an X server)
21
22test winClipboard-1.1 {TkSelGetSelection} win {
23    clipboard clear
24    catch {selection get -selection CLIPBOARD} msg
25    set msg
26} {CLIPBOARD selection doesn't exist or form "STRING" not defined}
27test winClipboard-1.2 {TkSelGetSelection} {win testclipboard} {
28    clipboard clear
29    clipboard append {}
30    catch {selection get -selection CLIPBOARD} r1
31    catch {testclipboard} r2
32    list $r1 $r2
33} {{} {}}
34test winClipboard-1.3 {TkSelGetSelection & TkWinClipboardRender} {win testclipboard} {
35    clipboard clear
36    clipboard append abcd
37    update
38    catch {selection get -selection CLIPBOARD} r1
39    catch {testclipboard} r2
40    list $r1 $r2
41} {abcd abcd}
42test winClipboard-1.4 {TkSelGetSelection & TkWinClipboardRender} {win testclipboard} {
43    clipboard clear
44    clipboard append "line 1\nline 2"
45    catch {selection get -selection CLIPBOARD} r1
46    catch {testclipboard} r2
47    list $r1 $r2
48} [list "line 1\nline 2" "line 1\r\nline 2"]
49test winClipboard-1.5 {TkSelGetSelection & TkWinClipboardRender} {win testclipboard} {
50    clipboard clear
51    clipboard append "line 1\u00c7\nline 2"
52    catch {selection get -selection CLIPBOARD} r1
53    catch {testclipboard} r2
54    list $r1 $r2
55} [list "line 1\u00c7\nline 2" [bytestring "line 1\u00c7\r\nline 2"]]
56
57test winClipboard-2.1 {TkSelUpdateClipboard reentrancy problem} {win testclipboard} {
58    clipboard clear
59    clipboard append -type OUR_ACTION "action data"
60    clipboard append "string data"
61    update
62    catch {selection get -selection CLIPBOARD -type OUR_ACTION} r1
63    catch {testclipboard} r2
64    list $r1 $r2
65} [list "action data" "string data"]
66test winClipboard-2.2 {TkSelUpdateClipboard reentrancy problem} {win testclipboard} {
67    clipboard clear
68    clipboard append -type OUR_ACTION "new data"
69    clipboard append "more data in string"
70    update
71    catch {testclipboard} r1
72    catch {selection get -selection CLIPBOARD -type OUR_ACTION} r2
73    list $r1 $r2
74} [list "more data in string" "new data"]
75
76# cleanup
77cleanupTests
78return
79