]> gitweb.factorcode.org Git - factor.git/blob - basis/ui/gadgets/editors/editors-tests.factor
factor: rename [ ] [ ] unit-test -> { } [ ] unit-test using a refactoring tool!
[factor.git] / basis / ui / gadgets / editors / editors-tests.factor
1 USING: accessors ui.gadgets.editors ui.gadgets.editors.private
2 tools.test kernel io io.streams.plain definitions namespaces
3 ui.gadgets ui.gadgets.grids prettyprint documents ui.gestures
4 ui.gadgets.debug models documents.elements ui.gadgets.scrollers
5 ui.gadgets.line-support sequences ;
6 IN: ui.gadgets.editors.tests
7
8 { "foo bar" } [
9     <editor> "editor" set
10     "editor" get [
11         "foo bar" "editor" get set-editor-string
12         "editor" get one-line-elt select-elt
13         "editor" get gadget-selection
14     ] with-grafted-gadget
15 ] unit-test
16
17 { "baz quux" } [
18     <editor> "editor" set
19     "editor" get [
20         "foo bar\nbaz quux" "editor" get set-editor-string
21         "editor" get one-line-elt select-elt
22         "editor" get gadget-selection
23     ] with-grafted-gadget
24 ] unit-test
25
26 { } [
27     <editor> "editor" set
28     "editor" get [
29         "foo bar\nbaz quux" "editor" get set-editor-string
30         4 hand-click# set
31         "editor" get position-caret
32     ] with-grafted-gadget
33 ] unit-test
34
35 { "bar" } [
36     <editor> "editor" set
37     "editor" get [
38         "bar\nbaz quux" "editor" get set-editor-string
39         { 0 3 } "editor" get caret>> set-model
40         "editor" get select-word
41         "editor" get gadget-selection
42     ] with-grafted-gadget
43 ] unit-test
44
45 "hello" <model> <model-field> "field" set
46
47 "field" get [
48     [ "hello" ] [ "field" get field-model>> value>> ] unit-test
49 ] with-grafted-gadget
50
51 { "Hello world." } [ "Hello    \n    world." join-lines ] unit-test
52 { "  Hello world.  " } [ "  Hello    \n    world.  " join-lines ] unit-test
53 { "  Hello world. Goodbye." } [ "  Hello    \n    world.  \n  Goodbye." join-lines ] unit-test
54
55 { } [ <editor> com-join-lines ] unit-test
56 { } [ <editor> "A" over set-editor-string com-join-lines ] unit-test
57 { "A B" } [ <editor> "A\nB" over set-editor-string [ com-join-lines ] [ editor-string ] bi ] unit-test
58 { "A B\nC\nD" } [ <editor> "A\nB\nC\nD" over set-editor-string { 0 0 } over set-caret dup mark>caret [ com-join-lines ] [ editor-string ] bi ] unit-test
59 { "A\nB C\nD" } [ <editor> "A\nB\nC\nD" over set-editor-string { 1 0 } over set-caret dup mark>caret [ com-join-lines ] [ editor-string ] bi ] unit-test
60 { "A\nB\nC D" } [ <editor> "A\nB\nC\nD" over set-editor-string { 2 0 } over set-caret dup mark>caret [ com-join-lines ] [ editor-string ] bi ] unit-test
61
62 { 2 } [ <editor> 20 >>min-rows 20 >>min-cols pref-viewport-dim length ] unit-test
63
64 { 20 } [
65     <editor> 20 >>min-rows 20 >>min-cols
66     dup pref-viewport-dim >>dim
67     visible-lines
68 ] unit-test