~ubuntu-branches/ubuntu/saucy/gnash/saucy-proposed

« back to all changes in this revision

Viewing changes to testsuite/actionscript.all/TextField.as

  • Committer: Bazaar Package Importer
  • Author(s): Alexander Sack
  • Date: 2008-10-13 14:29:49 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20081013142949-f6qdvnu4mn05ltdc
Tags: 0.8.4~~bzr9980-0ubuntu1
* new upstream release 0.8.4 (LP: #240325)
* ship new lib usr/lib/gnash/libmozsdk.so.* in mozilla-plugin-gnash
  - update debian/mozilla-plugin-gnash.install
* ship new lib usr/lib/gnash/libgnashnet.so.* in gnash-common
  - update debian/gnash-common.install
* add basic debian/build_head script to build latest CVS head packages.
  - add debian/build_head
* new sound architecture requires build depend on libsdl1.2-dev
  - update debian/control
* head build script now has been completely migrated to bzr (upstream +
  ubuntu)
  - update debian/build_head
* disable kde gui until klash/qt4 has been fixed; keep kde packages as empty
  packages for now.
  - update debian/rules
  - debian/klash.install
  - debian/klash.links
  - debian/klash.manpages
  - debian/konqueror-plugin-gnash.install
* drop libkonq5-dev build dependency accordingly
  - update debian/control
* don't install headers manually anymore. gnash doesnt provide a -dev
  package after all
  - update debian/rules
* update libs installed in gnash-common; libgnashserver-*.so is not available
  anymore (removed); in turn we add the new libgnashcore-*.so
  - update debian/gnash-common.install
* use -Os for optimization and properly pass CXXFLAGS=$(CFLAGS) to configure
  - update debian/rules
* touch firefox .autoreg in postinst of mozilla plugin
  - update debian/mozilla-plugin-gnash.postinst
* link gnash in ubufox plugins directory for the plugin alternative switcher
  - add debian/mozilla-plugin-gnash.links
* suggest ubufox accordingly
  - update debian/control
* add new required build-depends on libgif-dev
  - update debian/control
* add Xb-Npp-Description and Xb-Npp-File as new plugin database meta data
  - update debian/control

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
// compile this test case with Ming makeswf, and then
20
20
// execute it like this gnash -1 -r 0 -v out.swf
21
21
 
22
 
rcsid="$Id: TextField.as,v 1.45 2008/02/07 18:48:03 strk Exp $";
23
22
 
 
23
rcsid="$Id: TextField.as,v 1.56 2008/06/05 03:26:32 zoulunkai Exp $";
24
24
#include "check.as"
25
25
 
 
26
printBounds = function(b)
 
27
{
 
28
    var s = '';
 
29
    s += "xmin:"+b.xMin;
 
30
    s += " ymin:"+b.yMin;
 
31
    s += " xmax:"+b.xMax;
 
32
    s += " ymax:"+b.yMax;
 
33
    return s;
 
34
};
 
35
 
 
36
TextField.prototype.getBounds = MovieClip.prototype.getBounds;
 
37
 
26
38
#if OUTPUT_VERSION > 5
27
39
 
28
40
check_equals(typeof(TextField), 'function');
58
70
check( !TextField.prototype.hasOwnProperty('hscroll') );
59
71
xcheck( !TextField.prototype.hasOwnProperty('html') );
60
72
check( !TextField.prototype.hasOwnProperty('htmlText') );
61
 
check( !TextField.prototype.hasOwnProperty('length') );
 
73
xcheck( !TextField.prototype.hasOwnProperty('length') );
62
74
check( !TextField.prototype.hasOwnProperty('maxChars') );
63
75
check( !TextField.prototype.hasOwnProperty('maxhscroll') );
64
76
check( !TextField.prototype.hasOwnProperty('maxscroll') );
69
81
xcheck( !TextField.prototype.hasOwnProperty('selectable') );
70
82
check( !TextField.prototype.hasOwnProperty('text') );
71
83
xcheck( !TextField.prototype.hasOwnProperty('textColor') );
72
 
check( !TextField.prototype.hasOwnProperty('textHeight') );
73
 
check( !TextField.prototype.hasOwnProperty('textWidth') );
 
84
xcheck( !TextField.prototype.hasOwnProperty('textHeight') ); // should be available on first instantiation
 
85
xcheck( !TextField.prototype.hasOwnProperty('textWidth') ); // should be available on first instantiation
74
86
xcheck( !TextField.prototype.hasOwnProperty('type') ); // should be available on first instantiation
75
87
xcheck( !TextField.prototype.hasOwnProperty('variable') );
76
88
xcheck( !TextField.prototype.hasOwnProperty('wordWrap') );
101
113
check_equals(typeof(tfObj.replaceSel), 'function');
102
114
// this is a static method, it's available as TextField.getFontList
103
115
check_equals(typeof(tfObj.getFontList), 'undefined');
 
116
check_equals(typeof(tfObj._parent), 'undefined'); // no parent
104
117
 
105
118
//--------------------------------------------------
106
119
// Check textfield creation trough createTextField
133
146
xcheck( TextField.prototype.hasOwnProperty('hscroll') );
134
147
check( TextField.prototype.hasOwnProperty('html') );
135
148
xcheck( TextField.prototype.hasOwnProperty('htmlText') );
136
 
xcheck( TextField.prototype.hasOwnProperty('length') );
 
149
check( TextField.prototype.hasOwnProperty('length') );
137
150
xcheck( TextField.prototype.hasOwnProperty('maxChars') );
138
151
xcheck( TextField.prototype.hasOwnProperty('maxhscroll') );
139
152
xcheck( TextField.prototype.hasOwnProperty('maxscroll') );
144
157
check( TextField.prototype.hasOwnProperty('selectable') );
145
158
xcheck( TextField.prototype.hasOwnProperty('text') );
146
159
check( TextField.prototype.hasOwnProperty('textColor') );
147
 
xcheck( TextField.prototype.hasOwnProperty('textHeight') );
148
 
xcheck( TextField.prototype.hasOwnProperty('textWidth') );
 
160
check( TextField.prototype.hasOwnProperty('textHeight') );
 
161
check( TextField.prototype.hasOwnProperty('textWidth') );
149
162
check( TextField.prototype.hasOwnProperty('type') );
150
163
check( TextField.prototype.hasOwnProperty('variable') );
151
164
check( TextField.prototype.hasOwnProperty('wordWrap') );
 
165
check( TextField.prototype.hasOwnProperty('length') );
152
166
 
153
167
check( ! TextField.prototype.hasOwnProperty('valueOf') );
154
168
check( ! TextField.prototype.hasOwnProperty('toString') );
180
194
tf.autoSize = o;
181
195
check_equals(tf.autoSize, 'center'); // toString is called for object args
182
196
tf.autoSize = 'lEft';
183
 
xcheck_equals(tf.autoSize, 'left'); // arg is not case sensitive 
 
197
check_equals(tf.autoSize, 'left'); // arg is not case sensitive 
184
198
tf.autoSize = new Boolean(true);
185
199
check_equals(tf.autoSize, 'none'); // a Boolean is the same as any other object
186
200
 
311
325
tf.text = "Hello world";
312
326
check_equals(tf.htmlText, 'Hello world');
313
327
 
 
328
//-------------------------------------------------------------------------
314
329
// Check TextField.length  (number of characters in text)
 
330
//-------------------------------------------------------------------------
315
331
 
316
 
xcheck_equals(typeof(tf.length), 'number');
 
332
check_equals(typeof(tf.length), 'number');
317
333
check(!tf.hasOwnProperty('length'));
318
334
tf.text = "";
319
 
xcheck_equals(tf.length, 0);
 
335
check_equals(tf.length, 0);
320
336
tf.length = 10; // you don't change lenght like this, you assign to text instead
321
 
xcheck_equals(tf.length, 0);
 
337
check_equals(tf.length, 0);
322
338
tf.text = "Hello world";
323
 
xcheck_equals(tf.length, 11);
 
339
check_equals(tf.length, 11);
324
340
tf.htmlText = "Hello <b>world</b>";
325
 
xcheck_equals(tf.length, 18); // the tags are also counted
 
341
check_equals(tf.length, 18); // the tags are also counted
326
342
 
327
343
// Check TextField.maxChars
328
344
 
360
376
check_equals(tf.multiline, true);
361
377
tf.multiline = false;
362
378
 
 
379
//-------------------------------------------------------------------------
363
380
// Check TextField._name
 
381
//-------------------------------------------------------------------------
364
382
 
365
383
check_equals(typeof(tf._name), 'string');
366
384
check(!tf.hasOwnProperty('_name'));
377
395
check_equals(typeof(tfref), 'object');
378
396
// TODO: see effects of unloading the textfield ?
379
397
 
 
398
//-------------------------------------------------------------------------
380
399
// Check TextField._parent
 
400
//-------------------------------------------------------------------------
381
401
 
382
 
xcheck_equals(typeof(tf._parent), 'movieclip');
 
402
check_equals(typeof(tf._parent), 'movieclip');
383
403
check(!tf.hasOwnProperty('_parent'));
384
 
check(!tf.__proto__.hasOwnProperty('_parent'));
385
 
xcheck_equals(tf._parent, _root);
 
404
xcheck(!tf.__proto__.hasOwnProperty('_parent'));
 
405
check_equals(tf._parent, _root);
 
406
bk = tf._parent;
 
407
tf._parent = 23;
 
408
xcheck_equals(tf._parent, 23); // can be overridden !
 
409
check_equals(tf._target, "/tf"); // but won't change _target
 
410
r = delete tf._parent;
 
411
xcheck(r);
 
412
r = delete tf._parent;
 
413
check(!r);
 
414
TextField.prototype._parent = "from proto";
 
415
check_equals(tf._parent, _root); // still unchanged
 
416
delete TextField.prototype._parent;
 
417
tf._parent = bk;
386
418
 
 
419
//-------------------------------------------------------------------------
387
420
// Check TextField.password
 
421
//-------------------------------------------------------------------------
388
422
 
389
423
xcheck_equals(typeof(tf.password), 'boolean');
390
424
check(!tf.hasOwnProperty('password'));
477
511
check_equals(tf.tabIndex, 9);
478
512
delete(tf.tabIndex);
479
513
 
 
514
//-------------------------------------------------------------------------
480
515
// Check TextField._target
 
516
//-------------------------------------------------------------------------
481
517
 
482
518
check_equals(typeof(tf._target), 'string');
483
519
check( ! tf.hasOwnProperty('_target') ); 
494
530
check_equals(tf.text, 'Hello World');
495
531
tf.text = "hello world";
496
532
check_equals(tf.text, 'hello world');
497
 
xcheck_equals(tf.length, 11); // number of characters in "hello world"
 
533
check_equals(tf.length, 11); // number of characters in "hello world"
498
534
 
499
535
 
500
536
// Check TextField.textColor
508
544
 
509
545
// Check TextField.textHeight (height of the bounding box)
510
546
 
511
 
xcheck_equals(typeof(tf.textHeight), 'number');
 
547
check_equals(typeof(tf.textHeight), 'number');
512
548
check( ! tf.hasOwnProperty('textHeight') ); 
513
549
currentHeight = tf.textHeight; // WARNING: this might depend on the default font height
514
550
tf.textHeight = 1000;
515
 
xcheck_equals(tf.textHeight, currentHeight); // was read-only (I think)
 
551
check_equals(tf.textHeight, currentHeight); // was read-only (I think)
516
552
 
517
553
// Check TextField.textWidth (width of the bounding box)
518
554
 
656
692
check_equals(tf._width, 500); // as it was set by createTextField, see above
657
693
tf._width = 99999;
658
694
check_equals(tf._width, 99999); 
 
695
b = tf.getBounds(_root); bs = printBounds(b);
 
696
check_equals(bs, 'xmin:10 ymin:10 xmax:100009 ymax:510');
 
697
tf.autoSize = false;
 
698
tf.text = 'small'; // doesn't reset bounds (being autoSize false);
 
699
check_equals(tf._width, 99999); 
 
700
b = tf.getBounds(_root); bs = printBounds(b);
 
701
check_equals(bs, 'xmin:10 ymin:10 xmax:100009 ymax:510');
 
702
 
 
703
tf.autoSize = true; // changes width !!
 
704
check(tf._width < 99999); 
 
705
ow = tf._width;
 
706
 
 
707
tf.autoSize = false;  // doesn't reset to last manually set one
 
708
check_equals(tf._width, ow);
 
709
 
659
710
tf._width = 500;
660
711
 
661
712
//-------------------------------------------------------------------------
682
733
// Check TextField._xmouse
683
734
//-------------------------------------------------------------------------
684
735
 
685
 
xcheck_equals(typeof(tf._xmouse), 'number');
 
736
check_equals(typeof(tf._xmouse), 'number');
686
737
check( ! tf.hasOwnProperty('_xmouse') );
687
 
check( ! tf.__proto__.hasOwnProperty('_xmouse') );
 
738
xcheck( ! tf.__proto__.hasOwnProperty('_xmouse') );
688
739
currXmouse = tf._xmouse; // unsafe, if user moves the mouse while running the test
689
740
tf._xmouse = "a string";
690
 
xcheck_equals(typeof(tf._xmouse), 'number');
691
 
xcheck_equals(tf._xmouse, currXmouse); // possibly unsafe, if user moves the mouse while running the test
 
741
check_equals(typeof(tf._xmouse), 'number');
 
742
check_equals(tf._xmouse, currXmouse); // possibly unsafe, if user moves the mouse while running the test
692
743
 
693
744
//-------------------------------------------------------------------------
694
745
// Check TextField._xscale
695
746
//-------------------------------------------------------------------------
696
747
 
697
 
xcheck_equals(typeof(tf._xscale), 'number');
 
748
check_equals(typeof(tf._xscale), 'number');
698
749
check( ! tf.hasOwnProperty('_xscale') );
699
 
check( ! tf.__proto__.hasOwnProperty('_xscale') );
700
 
xcheck_equals(tf._xscale, 100); 
 
750
xcheck( ! tf.__proto__.hasOwnProperty('_xscale') );
 
751
check_equals(tf._xscale, 100); 
701
752
// check how .textWidth and ._width change when changing _xscale
702
753
currTextWidth = tf.textWidth;
703
754
currWidth = tf._width;
722
773
// Check TextField._ymouse
723
774
//-------------------------------------------------------------------------
724
775
 
725
 
xcheck_equals(typeof(tf._ymouse), 'number');
 
776
check_equals(typeof(tf._ymouse), 'number');
726
777
check( ! tf.hasOwnProperty('_ymouse') );
727
 
check( ! tf.__proto__.hasOwnProperty('_ymouse') );
 
778
xcheck( ! tf.__proto__.hasOwnProperty('_ymouse') );
728
779
currYmouse = tf._ymouse;
729
780
tf._ymouse = "a string";
730
 
xcheck_equals(typeof(tf._ymouse), 'number');
731
 
xcheck_equals(tf._ymouse, currYmouse); // possibly unsafe, if user moves the mouse while running the test
 
781
check_equals(typeof(tf._ymouse), 'number');
 
782
check_equals(tf._ymouse, currYmouse); // possibly unsafe, if user moves the mouse while running the test
732
783
 
733
784
//-------------------------------------------------------------------------
734
785
// Check TextField._yscale
735
786
//-------------------------------------------------------------------------
736
787
 
737
 
xcheck_equals(typeof(tf._yscale), 'number');
 
788
check_equals(typeof(tf._yscale), 'number');
738
789
check( ! tf.hasOwnProperty('_yscale') );
739
 
check( ! tf.__proto__.hasOwnProperty('_yscale') );
740
 
xcheck_equals(tf._yscale, 100); 
 
790
xcheck( ! tf.__proto__.hasOwnProperty('_yscale') );
 
791
check_equals(tf._yscale, 100); 
741
792
// check how .textHeight and ._height change based on _yscale
742
793
currTextHeight = tf.textHeight;
743
794
currHeight = tf._height;
748
799
tf._yscale = 100;
749
800
 
750
801
//-------------------------------------------------------------------------
751
 
// Check interaction between autoSize and _width
 
802
// Check interaction between autoSize and _width and wordWrap
752
803
//-------------------------------------------------------------------------
753
804
 
754
805
tf._width = 10; // "hello world" text should overflow this
762
813
check_equals(tf.textWidth, origTextWidth); // textWidth isn't influenced by autoSize 
763
814
tf.autoSize = 'none';
764
815
tf.wordWrap = true;
765
 
note("textWidth: "+tf.textWidth+" origTextWidth:"+origTextWidth);
 
816
note("After setting wordWrap flat: textWidth: "+tf.textWidth+" origTextWidth:"+origTextWidth);
766
817
check_equals(tf.textWidth, origTextWidth);  
767
818
tf._width = 10;
 
819
note("After reducing _width: textWidth: "+tf.textWidth+" origTextWidth:"+origTextWidth);
768
820
check_equals(tf._width, 10);
769
821
 
770
822
#if OUTPUT_VERSION < 8
771
 
 xcheck_equals(origTextWidth, tf.textWidth); // textWidth isn't influenced by wordWrap
 
823
 xcheck_equals(origTextWidth, tf.textWidth); 
772
824
#else
773
825
 check(origTextWidth > tf.textWidth); 
774
826
#endif
781
833
tf.text = "single line\n";
782
834
check_equals(tf._width, linewidth); 
783
835
 
 
836
// Test that setting autoSize = none
 
837
// doesn't reset the bounding box.
 
838
// See bug #24266
 
839
//
 
840
oldwidth = tf._width;
 
841
note("width: "+oldwidth);
 
842
check(oldwidth>0); // or the test is invalid
 
843
tf.autoSize = 'none'; // tf was created with bounds 0,0
 
844
check_equals(tf._width, oldwidth); // but _width didn't change to that
 
845
 
 
846
// Test that when autoSize != none,
 
847
// and wordWrap is true, text box isn't
 
848
// reset. See #24348
 
849
//
 
850
tf.wordWrap = false;
 
851
check_equals(tf._width, oldwidth); // text takes more width with wordWrap false
 
852
note("width on wordWrap="+tf.wordWrap+" autoSize="+tf.autoSize+": "+tf._width);
 
853
tf.autoSize = 'center'; 
 
854
note("width on wordWrap="+tf.wordWrap+" autoSize="+tf.autoSize+": "+tf._width);
 
855
check(tf._width > oldwidth); 
 
856
oldwidth = tf._width;
 
857
tf.wordWrap = true;
 
858
note("width on wordWrap="+tf.wordWrap+" autoSize="+tf.autoSize+": "+tf._width);
 
859
check_equals(tf._width, oldwidth);  // wordWrap change didn't reset the bbox
 
860
 
784
861
 
785
862
//------------------------------------------------------------
786
863
// Test insane calls
824
901
createTextField("tf6", 103, 10, 10, 160);
825
902
check_equals(typeof(tf6), 'undefined');
826
903
 
827
 
 
 
904
//------------------------------------------------------------
 
905
// Test properties
 
906
//------------------------------------------------------------
 
907
 
 
908
_root._visible = true; // just to be sure
 
909
_root._xscale = _root._yscale = 100;
 
910
_root.createTextField('htf',0,0,0,0,0);
 
911
check_equals(typeof(htf), 'object');
 
912
tf = htf;
 
913
with(tf) {
 
914
    _x=10;
 
915
    _y=11;
 
916
    _visible=false;
 
917
    _xscale=200;
 
918
    _yscale=201;
 
919
    _parent='fake_parent';
 
920
    _name='fake_name';
 
921
    _target='fake';
 
922
}
 
923
 
 
924
check_equals(_root._x, 0);
 
925
check_equals(_root._y, 0);
 
926
check_equals(_root._visible, true);
 
927
check_equals(_root._xscale, 100);
 
928
check_equals(_root._yscale, 100);
 
929
check_equals(_root._target, '/');
 
930
xcheck_equals(_root._parent, 'fake_parent');
 
931
check_equals(_root._name, '');
 
932
 
 
933
check_equals(tf._x, 10);
 
934
check_equals(tf._y, 11);
 
935
check_equals(tf._visible, false);
 
936
check_equals(tf._xscale, 200);
 
937
check_equals(tf._yscale, 201);
 
938
check_equals(tf._target, '/fake_name');
 
939
check_equals(tf._parent, _level0); 
 
940
check_equals(tf._name, 'fake_name');
 
941
 
 
942
_root._visible = true;
 
943
_root._x = _root._y = 0;
 
944
_root._xscale = _root._yscale = 100;
 
945
 
 
946
 
 
947
//------------------------------------------------------------
 
948
// END OF TESTS
 
949
//------------------------------------------------------------
828
950
 
829
951
#if OUTPUT_VERSION < 8
830
 
 check_totals(392);
 
952
 check_totals(426);
831
953
#else
832
 
 check_totals(393);
 
954
 check_totals(427);
833
955
#endif
834
956
 
835
957
#else // OUTPUT_VERSION <= 5