aboutsummaryrefslogtreecommitdiff
path: root/contexts/data/lib/closure-library/closure/goog/testing
diff options
context:
space:
mode:
Diffstat (limited to 'contexts/data/lib/closure-library/closure/goog/testing')
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/all-wcprops383
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/entries2197
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/asserts.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/asserts_test.html.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/asynctestcase.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/asynctestcase_async_test.html.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/asynctestcase_noasync_test.html.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/asynctestcase_test.html.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/benchmark.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/continuationtestcase.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/continuationtestcase_test.html.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/deferredtestcase.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/deferredtestcase_test.html.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/dom.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/dom_test.html.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/expectedfailures.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/expectedfailures_test.html.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/functionmock.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/functionmock_test.html.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/graphics.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/jsunit.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/loosemock.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/loosemock_test.html.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mock.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mock_test.html.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mockclassfactory.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mockclassfactory_test.html.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mockclock.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mockclock_test.html.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mockcontrol.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mockcontrol_test.html.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mockinterface.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mockmatchers.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mockmatchers_test.html.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mockrandom.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mockrandom_test.html.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mockrange.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mockrange_test.html.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mockstorage.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mockstorage_test.html.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mockuseragent.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mockuseragent_test.html.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/multitestrunner.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/objectpropertystring.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/performancetable.css.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/performancetable.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/performancetimer.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/performancetimer_test.html.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/propertyreplacer.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/propertyreplacer_test.html.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/pseudorandom.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/pseudorandom_test.html.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/recordfunction.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/recordfunction_test.html.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/shardingtestcase.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/shardingtestcase_test.html.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/singleton.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/singleton_test.html.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/stacktrace.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/stacktrace_test.html.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/strictmock.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/strictmock_test.html.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/testcase.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/testqueue.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/testrunner.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/asserts.js.svn-base1070
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/asserts_test.html.svn-base1011
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/asynctestcase.js.svn-base820
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/asynctestcase_async_test.html.svn-base102
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/asynctestcase_noasync_test.html.svn-base98
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/asynctestcase_test.html.svn-base58
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/benchmark.js.svn-base87
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/continuationtestcase.js.svn-base682
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/continuationtestcase_test.html.svn-base349
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/deferredtestcase.js.svn-base157
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/deferredtestcase_test.html.svn-base151
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/dom.js.svn-base606
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/dom_test.html.svn-base438
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/expectedfailures.js.svn-base236
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/expectedfailures_test.html.svn-base122
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/functionmock.js.svn-base177
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/functionmock_test.html.svn-base511
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/graphics.js.svn-base64
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/jsunit.js.svn-base144
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/loosemock.js.svn-base240
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/loosemock_test.html.svn-base343
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mock.js.svn-base579
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mock_test.html.svn-base213
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mockclassfactory.js.svn-base580
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mockclassfactory_test.html.svn-base241
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mockclock.js.svn-base410
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mockclock_test.html.svn-base413
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mockcontrol.js.svn-base219
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mockcontrol_test.html.svn-base127
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mockinterface.js.svn-base45
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mockmatchers.js.svn-base395
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mockmatchers_test.html.svn-base388
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mockrandom.js.svn-base126
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mockrandom_test.html.svn-base56
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mockrange.js.svn-base65
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mockrange_test.html.svn-base41
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mockstorage.js.svn-base102
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mockstorage_test.html.svn-base78
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mockuseragent.js.svn-base141
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mockuseragent_test.html.svn-base59
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/multitestrunner.js.svn-base1440
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/objectpropertystring.js.svn-base67
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/performancetable.css.svn-base46
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/performancetable.js.svn-base164
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/performancetimer.js.svn-base166
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/performancetimer_test.html.svn-base102
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/propertyreplacer.js.svn-base243
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/propertyreplacer_test.html.svn-base368
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/pseudorandom.js.svn-base179
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/pseudorandom_test.html.svn-base98
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/recordfunction.js.svn-base201
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/recordfunction_test.html.svn-base159
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/shardingtestcase.js.svn-base119
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/shardingtestcase_test.html.svn-base34
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/singleton.js.svn-base82
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/singleton_test.html.svn-base39
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/stacktrace.js.svn-base470
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/stacktrace_test.html.svn-base229
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/strictmock.js.svn-base128
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/strictmock_test.html.svn-base412
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/testcase.js.svn-base1106
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/testqueue.js.svn-base66
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/testrunner.js.svn-base391
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/asserts.js475
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/asserts_test.html114
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/async/.svn/all-wcprops17
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/async/.svn/entries96
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/async/.svn/prop-base/mockcontrol.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/async/.svn/prop-base/mockcontrol_test.html.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/async/.svn/text-base/mockcontrol.js.svn-base174
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/async/.svn/text-base/mockcontrol_test.html.svn-base223
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/asynctestcase.js50
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/benchmark.js5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/benchmarks/.svn/all-wcprops29
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/benchmarks/.svn/entries164
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/benchmarks/.svn/prop-base/jsbinarysizebutton.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/benchmarks/.svn/prop-base/jsbinarysizebutton_test.html.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/benchmarks/.svn/prop-base/jsbinarysizetoolbar.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/benchmarks/.svn/prop-base/jsbinarysizetoolbar_test.html.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/benchmarks/.svn/text-base/jsbinarysizebutton.js.svn-base64
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/benchmarks/.svn/text-base/jsbinarysizebutton_test.html.svn-base58
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/benchmarks/.svn/text-base/jsbinarysizetoolbar.js.svn-base66
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/benchmarks/.svn/text-base/jsbinarysizetoolbar_test.html.svn-base49
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/continuationtestcase.js9
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/continuationtestcase_test.html21
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/deferredtestcase.js4
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/deferredtestcase_test.html29
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/dom.js2
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/editor/.svn/all-wcprops35
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/editor/.svn/entries198
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/editor/.svn/prop-base/dom.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/editor/.svn/prop-base/dom_test.html.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/editor/.svn/prop-base/fieldmock.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/editor/.svn/prop-base/testhelper.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/editor/.svn/prop-base/testhelper_test.html.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/editor/.svn/text-base/dom.js.svn-base293
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/editor/.svn/text-base/dom_test.html.svn-base295
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/editor/.svn/text-base/fieldmock.js.svn-base90
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/editor/.svn/text-base/testhelper.js.svn-base174
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/editor/.svn/text-base/testhelper_test.html.svn-base177
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/events/.svn/all-wcprops41
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/events/.svn/entries232
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/events/.svn/prop-base/eventobserver.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/events/.svn/prop-base/eventobserver_test.html.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/events/.svn/prop-base/events.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/events/.svn/prop-base/events_test.html.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/events/.svn/prop-base/matchers.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/events/.svn/prop-base/matchers_test.html.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/events/.svn/text-base/eventobserver.js.svn-base85
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/events/.svn/text-base/eventobserver_test.html.svn-base70
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/events/.svn/text-base/events.js.svn-base554
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/events/.svn/text-base/events_test.html.svn-base434
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/events/.svn/text-base/matchers.js.svn-base41
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/events/.svn/text-base/matchers_test.html.svn-base40
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/events/eventobserver.js1
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/events/events.js55
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/events/events_test.html118
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/events/onlinehandler.js67
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/events/onlinehandler_test.html89
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/all-wcprops101
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/entries572
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/prop-base/blob.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/prop-base/blob_test.html.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/prop-base/directoryentry_test.html.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/prop-base/entry.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/prop-base/entry_test.html.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/prop-base/file.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/prop-base/fileentry_test.html.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/prop-base/filereader.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/prop-base/filereader_test.html.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/prop-base/filesystem.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/prop-base/filewriter.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/prop-base/filewriter_test.html.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/prop-base/fs.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/prop-base/fs_test.html.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/prop-base/integration_test.html.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/prop-base/progressevent.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/text-base/blob.js.svn-base115
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/text-base/blob_test.html.svn-base65
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/text-base/directoryentry_test.html.svn-base300
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/text-base/entry.js.svn-base622
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/text-base/entry_test.html.svn-base203
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/text-base/file.js.svn-base52
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/text-base/fileentry_test.html.svn-base80
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/text-base/filereader.js.svn-base272
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/text-base/filereader_test.html.svn-base236
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/text-base/filesystem.js.svn-base64
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/text-base/filewriter.js.svn-base261
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/text-base/filewriter_test.html.svn-base325
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/text-base/fs.js.svn-base146
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/text-base/fs_test.html.svn-base53
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/text-base/integration_test.html.svn-base223
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/text-base/progressevent.js.svn-base83
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/fs/blob.js1
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/fs/directoryentry_test.html15
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/fs/entry.js48
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/fs/entry_test.html24
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/fs/fileentry_test.html13
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/fs/progressevent.js2
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/functionmock.js14
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/jsunit.js10
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/messaging/.svn/all-wcprops29
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/messaging/.svn/entries164
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/messaging/.svn/prop-base/mockmessagechannel.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/messaging/.svn/prop-base/mockmessageevent.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/messaging/.svn/prop-base/mockmessageport.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/messaging/.svn/prop-base/mockportnetwork.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/messaging/.svn/text-base/mockmessagechannel.js.svn-base77
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/messaging/.svn/text-base/mockmessageevent.js.svn-base100
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/messaging/.svn/text-base/mockmessageport.js.svn-base85
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/messaging/.svn/text-base/mockportnetwork.js.svn-base64
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/messaging/mockmessagechannel.js2
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/messaging/mockportnetwork.js1
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/mock.js44
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/mock_test.html51
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/mockclock.js122
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/mockclock_test.html101
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/mockcontrol.js8
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/mockmatchers_test.html16
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/mockrange.js5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/mockstorage.js5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/multitestrunner.js4
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/net/.svn/all-wcprops23
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/net/.svn/entries130
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/net/.svn/prop-base/xhrio.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/net/.svn/prop-base/xhrio_test.html.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/net/.svn/prop-base/xhriopool.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/net/.svn/text-base/xhrio.js.svn-base671
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/net/.svn/text-base/xhrio_test.html.svn-base384
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/net/.svn/text-base/xhriopool.js.svn-base61
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/net/xhrio.js29
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/performancetable.js28
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/performancetimer.js117
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/performancetimer_test.html104
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/proto2/proto2.js127
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/proto2/proto2_test.html117
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/shardingtestcase.js1
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/singleton.js62
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/stacktrace.js46
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/stacktrace_test.html67
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/storage/fakemechanism.js66
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/style/.svn/all-wcprops29
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/style/.svn/entries164
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/style/.svn/prop-base/layoutasserts.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/style/.svn/prop-base/layoutasserts_test.html.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/style/.svn/prop-base/style.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/style/.svn/prop-base/style_test.html.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/style/.svn/text-base/layoutasserts.js.svn-base310
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/style/.svn/text-base/layoutasserts_test.html.svn-base269
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/style/.svn/text-base/style.js.svn-base86
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/style/.svn/text-base/style_test.html.svn-base105
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/style/layoutasserts.js52
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/style/style.js14
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/style/style_test.html57
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/testcase.js163
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/testrunner.js33
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/ui/.svn/all-wcprops41
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/ui/.svn/entries232
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/ui/.svn/prop-base/rendererasserts.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/ui/.svn/prop-base/rendererasserts_test.html.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/ui/.svn/prop-base/rendererharness.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/ui/.svn/prop-base/style.js.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/ui/.svn/prop-base/style_reference.html.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/ui/.svn/prop-base/style_test.html.svn-base5
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/ui/.svn/text-base/rendererasserts.js.svn-base55
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/ui/.svn/text-base/rendererasserts_test.html.svn-base52
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/ui/.svn/text-base/rendererharness.js.svn-base176
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/ui/.svn/text-base/style.js.svn-base137
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/ui/.svn/text-base/style_reference.html.svn-base27
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/ui/.svn/text-base/style_test.html.svn-base130
-rw-r--r--contexts/data/lib/closure-library/closure/goog/testing/ui/rendererasserts.js1
296 files changed, 2163 insertions, 32717 deletions
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/all-wcprops b/contexts/data/lib/closure-library/closure/goog/testing/.svn/all-wcprops
deleted file mode 100644
index 2553176..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/all-wcprops
+++ /dev/null
@@ -1,383 +0,0 @@
-K 25
-svn:wc:ra_dav:version-url
-V 45
-/svn/!svn/ver/1472/trunk/closure/goog/testing
-END
-continuationtestcase.js
-K 25
-svn:wc:ra_dav:version-url
-V 69
-/svn/!svn/ver/1302/trunk/closure/goog/testing/continuationtestcase.js
-END
-mockmatchers_test.html
-K 25
-svn:wc:ra_dav:version-url
-V 67
-/svn/!svn/ver/850/trunk/closure/goog/testing/mockmatchers_test.html
-END
-mockclassfactory.js
-K 25
-svn:wc:ra_dav:version-url
-V 64
-/svn/!svn/ver/850/trunk/closure/goog/testing/mockclassfactory.js
-END
-asynctestcase.js
-K 25
-svn:wc:ra_dav:version-url
-V 62
-/svn/!svn/ver/1302/trunk/closure/goog/testing/asynctestcase.js
-END
-testcase.js
-K 25
-svn:wc:ra_dav:version-url
-V 57
-/svn/!svn/ver/1472/trunk/closure/goog/testing/testcase.js
-END
-recordfunction_test.html
-K 25
-svn:wc:ra_dav:version-url
-V 70
-/svn/!svn/ver/1165/trunk/closure/goog/testing/recordfunction_test.html
-END
-jsunit.js
-K 25
-svn:wc:ra_dav:version-url
-V 54
-/svn/!svn/ver/850/trunk/closure/goog/testing/jsunit.js
-END
-deferredtestcase.js
-K 25
-svn:wc:ra_dav:version-url
-V 64
-/svn/!svn/ver/850/trunk/closure/goog/testing/deferredtestcase.js
-END
-multitestrunner.js
-K 25
-svn:wc:ra_dav:version-url
-V 64
-/svn/!svn/ver/1302/trunk/closure/goog/testing/multitestrunner.js
-END
-stacktrace.js
-K 25
-svn:wc:ra_dav:version-url
-V 58
-/svn/!svn/ver/850/trunk/closure/goog/testing/stacktrace.js
-END
-functionmock_test.html
-K 25
-svn:wc:ra_dav:version-url
-V 68
-/svn/!svn/ver/1120/trunk/closure/goog/testing/functionmock_test.html
-END
-asynctestcase_noasync_test.html
-K 25
-svn:wc:ra_dav:version-url
-V 76
-/svn/!svn/ver/850/trunk/closure/goog/testing/asynctestcase_noasync_test.html
-END
-shardingtestcase.js
-K 25
-svn:wc:ra_dav:version-url
-V 64
-/svn/!svn/ver/850/trunk/closure/goog/testing/shardingtestcase.js
-END
-expectedfailures.js
-K 25
-svn:wc:ra_dav:version-url
-V 64
-/svn/!svn/ver/850/trunk/closure/goog/testing/expectedfailures.js
-END
-mockrange_test.html
-K 25
-svn:wc:ra_dav:version-url
-V 64
-/svn/!svn/ver/850/trunk/closure/goog/testing/mockrange_test.html
-END
-mockuseragent_test.html
-K 25
-svn:wc:ra_dav:version-url
-V 68
-/svn/!svn/ver/850/trunk/closure/goog/testing/mockuseragent_test.html
-END
-asynctestcase_test.html
-K 25
-svn:wc:ra_dav:version-url
-V 69
-/svn/!svn/ver/1259/trunk/closure/goog/testing/asynctestcase_test.html
-END
-objectpropertystring.js
-K 25
-svn:wc:ra_dav:version-url
-V 68
-/svn/!svn/ver/850/trunk/closure/goog/testing/objectpropertystring.js
-END
-mockclock.js
-K 25
-svn:wc:ra_dav:version-url
-V 58
-/svn/!svn/ver/1366/trunk/closure/goog/testing/mockclock.js
-END
-mockrange.js
-K 25
-svn:wc:ra_dav:version-url
-V 57
-/svn/!svn/ver/850/trunk/closure/goog/testing/mockrange.js
-END
-testrunner.js
-K 25
-svn:wc:ra_dav:version-url
-V 58
-/svn/!svn/ver/850/trunk/closure/goog/testing/testrunner.js
-END
-loosemock_test.html
-K 25
-svn:wc:ra_dav:version-url
-V 64
-/svn/!svn/ver/850/trunk/closure/goog/testing/loosemock_test.html
-END
-asserts.js
-K 25
-svn:wc:ra_dav:version-url
-V 56
-/svn/!svn/ver/1472/trunk/closure/goog/testing/asserts.js
-END
-performancetable.css
-K 25
-svn:wc:ra_dav:version-url
-V 65
-/svn/!svn/ver/850/trunk/closure/goog/testing/performancetable.css
-END
-mock.js
-K 25
-svn:wc:ra_dav:version-url
-V 53
-/svn/!svn/ver/1120/trunk/closure/goog/testing/mock.js
-END
-propertyreplacer_test.html
-K 25
-svn:wc:ra_dav:version-url
-V 71
-/svn/!svn/ver/850/trunk/closure/goog/testing/propertyreplacer_test.html
-END
-performancetimer_test.html
-K 25
-svn:wc:ra_dav:version-url
-V 72
-/svn/!svn/ver/1472/trunk/closure/goog/testing/performancetimer_test.html
-END
-singleton_test.html
-K 25
-svn:wc:ra_dav:version-url
-V 64
-/svn/!svn/ver/850/trunk/closure/goog/testing/singleton_test.html
-END
-benchmark.js
-K 25
-svn:wc:ra_dav:version-url
-V 58
-/svn/!svn/ver/1270/trunk/closure/goog/testing/benchmark.js
-END
-mockclock_test.html
-K 25
-svn:wc:ra_dav:version-url
-V 64
-/svn/!svn/ver/850/trunk/closure/goog/testing/mockclock_test.html
-END
-functionmock.js
-K 25
-svn:wc:ra_dav:version-url
-V 61
-/svn/!svn/ver/1120/trunk/closure/goog/testing/functionmock.js
-END
-pseudorandom.js
-K 25
-svn:wc:ra_dav:version-url
-V 61
-/svn/!svn/ver/1302/trunk/closure/goog/testing/pseudorandom.js
-END
-propertyreplacer.js
-K 25
-svn:wc:ra_dav:version-url
-V 64
-/svn/!svn/ver/850/trunk/closure/goog/testing/propertyreplacer.js
-END
-performancetimer.js
-K 25
-svn:wc:ra_dav:version-url
-V 65
-/svn/!svn/ver/1472/trunk/closure/goog/testing/performancetimer.js
-END
-singleton.js
-K 25
-svn:wc:ra_dav:version-url
-V 57
-/svn/!svn/ver/850/trunk/closure/goog/testing/singleton.js
-END
-deferredtestcase_test.html
-K 25
-svn:wc:ra_dav:version-url
-V 72
-/svn/!svn/ver/1434/trunk/closure/goog/testing/deferredtestcase_test.html
-END
-dom_test.html
-K 25
-svn:wc:ra_dav:version-url
-V 58
-/svn/!svn/ver/850/trunk/closure/goog/testing/dom_test.html
-END
-mockuseragent.js
-K 25
-svn:wc:ra_dav:version-url
-V 62
-/svn/!svn/ver/1302/trunk/closure/goog/testing/mockuseragent.js
-END
-mockinterface.js
-K 25
-svn:wc:ra_dav:version-url
-V 61
-/svn/!svn/ver/850/trunk/closure/goog/testing/mockinterface.js
-END
-stacktrace_test.html
-K 25
-svn:wc:ra_dav:version-url
-V 65
-/svn/!svn/ver/850/trunk/closure/goog/testing/stacktrace_test.html
-END
-mock_test.html
-K 25
-svn:wc:ra_dav:version-url
-V 60
-/svn/!svn/ver/1104/trunk/closure/goog/testing/mock_test.html
-END
-mockmatchers.js
-K 25
-svn:wc:ra_dav:version-url
-V 61
-/svn/!svn/ver/1302/trunk/closure/goog/testing/mockmatchers.js
-END
-mockcontrol_test.html
-K 25
-svn:wc:ra_dav:version-url
-V 66
-/svn/!svn/ver/850/trunk/closure/goog/testing/mockcontrol_test.html
-END
-expectedfailures_test.html
-K 25
-svn:wc:ra_dav:version-url
-V 71
-/svn/!svn/ver/850/trunk/closure/goog/testing/expectedfailures_test.html
-END
-recordfunction.js
-K 25
-svn:wc:ra_dav:version-url
-V 63
-/svn/!svn/ver/1165/trunk/closure/goog/testing/recordfunction.js
-END
-mockcontrol.js
-K 25
-svn:wc:ra_dav:version-url
-V 60
-/svn/!svn/ver/1120/trunk/closure/goog/testing/mockcontrol.js
-END
-loosemock.js
-K 25
-svn:wc:ra_dav:version-url
-V 58
-/svn/!svn/ver/1302/trunk/closure/goog/testing/loosemock.js
-END
-asynctestcase_async_test.html
-K 25
-svn:wc:ra_dav:version-url
-V 74
-/svn/!svn/ver/850/trunk/closure/goog/testing/asynctestcase_async_test.html
-END
-mockclassfactory_test.html
-K 25
-svn:wc:ra_dav:version-url
-V 71
-/svn/!svn/ver/850/trunk/closure/goog/testing/mockclassfactory_test.html
-END
-graphics.js
-K 25
-svn:wc:ra_dav:version-url
-V 56
-/svn/!svn/ver/850/trunk/closure/goog/testing/graphics.js
-END
-mockstorage_test.html
-K 25
-svn:wc:ra_dav:version-url
-V 66
-/svn/!svn/ver/850/trunk/closure/goog/testing/mockstorage_test.html
-END
-performancetable.js
-K 25
-svn:wc:ra_dav:version-url
-V 65
-/svn/!svn/ver/1472/trunk/closure/goog/testing/performancetable.js
-END
-strictmock_test.html
-K 25
-svn:wc:ra_dav:version-url
-V 66
-/svn/!svn/ver/1048/trunk/closure/goog/testing/strictmock_test.html
-END
-asserts_test.html
-K 25
-svn:wc:ra_dav:version-url
-V 63
-/svn/!svn/ver/1472/trunk/closure/goog/testing/asserts_test.html
-END
-mockstorage.js
-K 25
-svn:wc:ra_dav:version-url
-V 59
-/svn/!svn/ver/850/trunk/closure/goog/testing/mockstorage.js
-END
-dom.js
-K 25
-svn:wc:ra_dav:version-url
-V 52
-/svn/!svn/ver/1324/trunk/closure/goog/testing/dom.js
-END
-mockrandom_test.html
-K 25
-svn:wc:ra_dav:version-url
-V 65
-/svn/!svn/ver/850/trunk/closure/goog/testing/mockrandom_test.html
-END
-shardingtestcase_test.html
-K 25
-svn:wc:ra_dav:version-url
-V 71
-/svn/!svn/ver/850/trunk/closure/goog/testing/shardingtestcase_test.html
-END
-strictmock.js
-K 25
-svn:wc:ra_dav:version-url
-V 59
-/svn/!svn/ver/1302/trunk/closure/goog/testing/strictmock.js
-END
-testqueue.js
-K 25
-svn:wc:ra_dav:version-url
-V 57
-/svn/!svn/ver/850/trunk/closure/goog/testing/testqueue.js
-END
-pseudorandom_test.html
-K 25
-svn:wc:ra_dav:version-url
-V 67
-/svn/!svn/ver/941/trunk/closure/goog/testing/pseudorandom_test.html
-END
-mockrandom.js
-K 25
-svn:wc:ra_dav:version-url
-V 59
-/svn/!svn/ver/1302/trunk/closure/goog/testing/mockrandom.js
-END
-continuationtestcase_test.html
-K 25
-svn:wc:ra_dav:version-url
-V 75
-/svn/!svn/ver/850/trunk/closure/goog/testing/continuationtestcase_test.html
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/entries b/contexts/data/lib/closure-library/closure/goog/testing/.svn/entries
deleted file mode 100644
index cdda153..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/entries
+++ /dev/null
@@ -1,2197 +0,0 @@
-10
-
-dir
-1494
-http://closure-library.googlecode.com/svn/trunk/closure/goog/testing
-http://closure-library.googlecode.com/svn
-
-
-
-2011-12-13T22:20:28.000000Z
-1472
-ccalabro@google.com
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-0b95b8e8-c90f-11de-9d4f-f947ee5921c8
-
-continuationtestcase.js
-file
-
-
-
-
-2011-12-23T22:42:27.336316Z
-695af05e13ddec06f703a1f2def7a166
-2011-09-27T00:20:47.000000Z
-1302
-bmccann@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-20544
-
-mockmatchers_test.html
-file
-
-
-
-
-2011-12-23T22:42:27.337316Z
-a121ff4ce11c0ce263630fe0412d09ea
-2011-04-12T20:35:47.000000Z
-850
-diegosalas@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-13683
-
-mockclassfactory.js
-file
-
-
-
-
-2011-12-23T22:42:27.337316Z
-b4e4e72720eaf8514dabf004c98acd58
-2011-04-12T20:35:47.000000Z
-850
-diegosalas@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-19442
-
-asynctestcase.js
-file
-
-
-
-
-2011-12-23T22:42:27.338316Z
-610f20380d1a4d77020b5ea7364a2e74
-2011-09-27T00:20:47.000000Z
-1302
-bmccann@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-24373
-
-testcase.js
-file
-
-
-
-
-2011-12-23T22:42:27.339316Z
-4b0aa66ab016790f7264544b525e9483
-2011-12-13T22:20:28.000000Z
-1472
-ccalabro@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-29980
-
-recordfunction_test.html
-file
-
-
-
-
-2011-12-23T22:42:27.338316Z
-b728120b7f6d87d48a797f5f9549acce
-2011-07-26T21:39:45.000000Z
-1165
-nnaze@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-5463
-
-deferredtestcase.js
-file
-
-
-
-
-2011-12-23T22:42:27.339316Z
-c8e04044b96ee368f702ff40bf2d01a0
-2011-04-12T20:35:47.000000Z
-850
-diegosalas@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-5158
-
-jsunit.js
-file
-
-
-
-
-2011-12-23T22:42:27.340316Z
-de3a6b5981bdb31c8795d6a8a3add3b9
-2011-04-12T20:35:47.000000Z
-850
-diegosalas@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-5264
-
-stacktrace.js
-file
-
-
-
-
-2011-12-23T22:42:27.340316Z
-e8b866246cd5d7b625e41d66f487b53a
-2011-04-12T20:35:47.000000Z
-850
-diegosalas@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-14422
-
-multitestrunner.js
-file
-
-
-
-
-2011-12-23T22:42:27.341316Z
-6dfcd13d160a852de34a1151e82cd255
-2011-09-27T00:20:47.000000Z
-1302
-bmccann@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-38154
-
-functionmock_test.html
-file
-
-
-
-
-2011-12-23T22:42:27.341316Z
-2e70f38a007a016090fbe907daeae995
-2011-07-13T20:04:08.000000Z
-1120
-erikwright@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-15501
-
-events
-dir
-
-asynctestcase_noasync_test.html
-file
-
-
-
-
-2011-12-23T22:42:27.342316Z
-6d5dd8c027680d58df2cdd8073a65e63
-2011-04-12T20:35:47.000000Z
-850
-diegosalas@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-2968
-
-shardingtestcase.js
-file
-
-
-
-
-2011-12-23T22:42:27.342316Z
-8df202c091194f5d83578b2fdccee91a
-2011-04-12T20:35:47.000000Z
-850
-diegosalas@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-4130
-
-expectedfailures.js
-file
-
-
-
-
-2011-12-23T22:42:27.343316Z
-bd9e17d94d9ca1e9ddb3bccf3f66df93
-2011-04-12T20:35:47.000000Z
-850
-diegosalas@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-6833
-
-fs
-dir
-
-mockrange_test.html
-file
-
-
-
-
-2011-12-23T22:42:27.343316Z
-f9547b4f26783c4597360a1e45d60801
-2011-04-12T20:35:47.000000Z
-850
-diegosalas@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-992
-
-mockuseragent_test.html
-file
-
-
-
-
-2011-12-23T22:42:27.343316Z
-d67ddf6fa9c384121c358e912099d8c5
-2011-04-12T20:35:47.000000Z
-850
-diegosalas@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-1568
-
-asynctestcase_test.html
-file
-
-
-
-
-2011-12-23T22:42:27.344316Z
-d8de9bc3f5391d7539e4f1cf540696af
-2011-08-29T23:49:09.000000Z
-1259
-licong@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-1470
-
-benchmarks
-dir
-
-objectpropertystring.js
-file
-
-
-
-
-2011-12-23T22:42:27.344316Z
-b9d5be35c644d05b795c071da9e8c83f
-2011-04-12T20:35:47.000000Z
-850
-diegosalas@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-1770
-
-mockclock.js
-file
-
-
-
-
-2011-12-23T22:42:27.344316Z
-9d1f2d2e8d5f83c9f5a1e336ab02ed4b
-2011-11-02T22:38:28.000000Z
-1366
-ryo@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-12535
-
-mockrange.js
-file
-
-
-
-
-2011-12-23T22:42:27.344316Z
-5103433afc8881b9c26b1ee6feee49e1
-2011-04-12T20:35:47.000000Z
-850
-diegosalas@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-2095
-
-testrunner.js
-file
-
-
-
-
-2011-12-23T22:42:27.345316Z
-0c490b799e23cc4b001a892eae550ccc
-2011-04-12T20:35:47.000000Z
-850
-diegosalas@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-11015
-
-loosemock_test.html
-file
-
-
-
-
-2011-12-23T22:42:27.345316Z
-fa0aab58af5d0f6cd93d5719732ab3ba
-2011-04-12T20:35:47.000000Z
-850
-diegosalas@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-8125
-
-asserts.js
-file
-
-
-
-
-2011-12-23T22:42:27.345316Z
-98a339308eb4d11c931ac5d499515d11
-2011-12-13T22:20:28.000000Z
-1472
-ccalabro@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-35298
-
-performancetable.css
-file
-
-
-
-
-2011-12-23T22:42:27.345316Z
-70e0c8412fd883a6dc05c99b143b1b11
-2011-04-12T20:35:47.000000Z
-850
-diegosalas@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-928
-
-singleton_test.html
-file
-
-
-
-
-2011-12-23T22:42:27.346316Z
-3bae89135c52551b5acfce4b9b20444c
-2011-04-12T20:35:47.000000Z
-850
-diegosalas@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-978
-
-performancetimer_test.html
-file
-
-
-
-
-2011-12-23T22:42:27.346316Z
-109de253c3b811e30ccb2a717a5aae39
-2011-12-13T22:20:28.000000Z
-1472
-ccalabro@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-3200
-
-propertyreplacer_test.html
-file
-
-
-
-
-2011-12-23T22:42:27.346316Z
-18bb76a4467a69f77ccb72a123ea6f4a
-2011-04-12T20:35:47.000000Z
-850
-diegosalas@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-11822
-
-mock.js
-file
-
-
-
-
-2011-12-23T22:42:27.346316Z
-de28aa21358d29e106e4f2b83bdfc482
-2011-07-13T20:04:08.000000Z
-1120
-erikwright@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-16959
-
-benchmark.js
-file
-
-
-
-
-2011-12-23T22:42:27.347316Z
-a177e77015d784da524192b4515d137f
-2011-09-06T21:26:02.000000Z
-1270
-nicksantos@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-2593
-
-mockclock_test.html
-file
-
-
-
-
-2011-12-23T22:42:27.347316Z
-1c175d0a73d8df3f7da200d6f3a320e4
-2011-04-12T20:35:47.000000Z
-850
-diegosalas@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-11386
-
-functionmock.js
-file
-
-
-
-
-2011-12-23T22:42:27.347316Z
-423b52f5d8982769946a309aad0ab8f4
-2011-07-13T20:04:08.000000Z
-1120
-erikwright@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-7203
-
-pseudorandom.js
-file
-
-
-
-
-2011-12-23T22:42:27.348316Z
-bff64ce11adb599a3c2ef9362e0e381d
-2011-09-27T00:20:47.000000Z
-1302
-bmccann@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-4326
-
-propertyreplacer.js
-file
-
-
-
-
-2011-12-23T22:42:27.348316Z
-ac37e82d42da27220a130abf48e4d792
-2011-04-12T20:35:47.000000Z
-850
-diegosalas@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-8409
-
-performancetimer.js
-file
-
-
-
-
-2011-12-23T22:42:27.348316Z
-388f1fce25867bd0f177d337b7c4ddcd
-2011-12-13T22:20:28.000000Z
-1472
-ccalabro@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-5023
-
-singleton.js
-file
-
-
-
-
-2011-12-23T22:42:27.348316Z
-b468a46251896c6621fa4e91addec088
-2011-04-12T20:35:47.000000Z
-850
-diegosalas@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-2642
-
-async
-dir
-
-deferredtestcase_test.html
-file
-
-
-
-
-2011-12-23T22:42:27.349316Z
-f3d69712e0941471748baac6e059c23f
-2011-11-30T22:16:21.000000Z
-1434
-chrishenry@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-4719
-
-dom_test.html
-file
-
-
-
-
-2011-12-23T22:42:27.349316Z
-8d8a735c2a5e0e7fda6122ca5c00f63b
-2011-04-12T20:35:47.000000Z
-850
-diegosalas@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-15713
-
-mockuseragent.js
-file
-
-
-
-
-2011-12-23T22:42:27.349316Z
-505e0afbb774a5dfc81ffa0e6f441ffb
-2011-09-27T00:20:47.000000Z
-1302
-bmccann@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-3577
-
-mockinterface.js
-file
-
-
-
-
-2011-12-23T22:42:27.349316Z
-dd8894fe82bb5a3ea805c6951bb8f5d4
-2011-04-12T20:35:47.000000Z
-850
-diegosalas@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-1318
-
-stacktrace_test.html
-file
-
-
-
-
-2011-12-23T22:42:27.350316Z
-113cd09b029a87704dd364a9e76f3d47
-2011-04-12T20:35:47.000000Z
-850
-diegosalas@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-8705
-
-mock_test.html
-file
-
-
-
-
-2011-12-23T22:42:27.350316Z
-a2b5969a160ea11931c5b1df6bace30f
-2011-07-07T03:19:14.000000Z
-1104
-erikwright@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-6662
-
-mockmatchers.js
-file
-
-
-
-
-2011-12-23T22:42:27.350316Z
-c5a3f76b252bd743c7896f143f030043
-2011-09-27T00:20:47.000000Z
-1302
-bmccann@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-13245
-
-mockcontrol_test.html
-file
-
-
-
-
-2011-12-23T22:42:27.350316Z
-06f58af6ee3e620b76a4231dae378173
-2011-04-12T20:35:47.000000Z
-850
-diegosalas@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-3138
-
-expectedfailures_test.html
-file
-
-
-
-
-2011-12-23T22:42:27.351316Z
-814d0a7fafb0211961d6fe2e52399352
-2011-04-12T20:35:47.000000Z
-850
-diegosalas@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-3599
-
-recordfunction.js
-file
-
-
-
-
-2011-12-23T22:42:27.351316Z
-181569e4e3dfff85c9cb369786bf63e6
-2011-07-26T21:39:45.000000Z
-1165
-nnaze@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-5744
-
-mockcontrol.js
-file
-
-
-
-
-2011-12-23T22:42:27.352316Z
-c61425cdfc05fcec9a42399c6c4b91b7
-2011-07-13T20:04:08.000000Z
-1120
-erikwright@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-7311
-
-loosemock.js
-file
-
-
-
-
-2011-12-23T22:42:27.352316Z
-1855fc25ad62c532df19ff76c9f0a7eb
-2011-09-27T00:20:47.000000Z
-1302
-bmccann@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-8270
-
-asynctestcase_async_test.html
-file
-
-
-
-
-2011-12-23T22:42:27.352316Z
-9b3481d18fac97a852572aabf3b8420f
-2011-04-12T20:35:47.000000Z
-850
-diegosalas@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-3038
-
-mockclassfactory_test.html
-file
-
-
-
-
-2011-12-23T22:42:27.352316Z
-c271e78436f30b0f672031715ecf767d
-2011-04-12T20:35:47.000000Z
-850
-diegosalas@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-6996
-
-graphics.js
-file
-
-
-
-
-2011-12-23T22:42:27.353316Z
-93e416fc4ec7fc016f4955a6f1706b13
-2011-04-12T20:35:47.000000Z
-850
-diegosalas@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-2104
-
-messaging
-dir
-
-mockstorage_test.html
-file
-
-
-
-
-2011-12-23T22:42:27.353316Z
-51dbf94c74aec85b1fd0575455fdf6dd
-2011-04-12T20:35:47.000000Z
-850
-diegosalas@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-2101
-
-performancetable.js
-file
-
-
-
-
-2011-12-23T22:42:27.354316Z
-9ba35e038ee4fb4c4cffda1855ad0232
-2011-12-13T22:20:28.000000Z
-1472
-ccalabro@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-4890
-
-strictmock_test.html
-file
-
-
-
-
-2011-12-23T22:42:27.353316Z
-a5702a4b77f4ce14d062a1dc2e3108e3
-2011-06-15T23:39:28.000000Z
-1048
-nsw@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-7546
-
-asserts_test.html
-file
-
-
-
-
-2011-12-23T22:42:27.354316Z
-a130a6a351f4b599ebb026c6b75ce5e4
-2011-12-13T22:20:28.000000Z
-1472
-ccalabro@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-34256
-
-net
-dir
-
-editor
-dir
-
-mockstorage.js
-file
-
-
-
-
-2011-12-23T22:42:27.354316Z
-d2158cd7bee1f3181927c16521d0e92b
-2011-04-12T20:35:47.000000Z
-850
-diegosalas@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-2660
-
-dom.js
-file
-
-
-
-
-2011-12-23T22:42:27.355316Z
-ef55e8d85aaee295507cbe47b76d699c
-2011-10-06T21:57:41.000000Z
-1324
-brenneman@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-21968
-
-mockrandom_test.html
-file
-
-
-
-
-2011-12-23T22:42:27.355316Z
-6011022f376605b8298f5616881fbfa6
-2011-04-12T20:35:47.000000Z
-850
-diegosalas@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-1396
-
-strictmock.js
-file
-
-
-
-
-2011-12-23T22:42:27.355316Z
-0362ff2b4889fc933f7366a934c88f29
-2011-09-27T00:20:47.000000Z
-1302
-bmccann@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-4231
-
-shardingtestcase_test.html
-file
-
-
-
-
-2011-12-23T22:42:27.355316Z
-f7bc9b0b044ce7a41044b0a90597d883
-2011-04-12T20:35:47.000000Z
-850
-diegosalas@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-735
-
-testqueue.js
-file
-
-
-
-
-2011-12-23T22:42:27.356316Z
-3194c13a4d56f8deaccb16f1e13ec610
-2011-04-12T20:35:47.000000Z
-850
-diegosalas@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-1715
-
-style
-dir
-
-pseudorandom_test.html
-file
-
-
-
-
-2011-12-23T22:42:27.356316Z
-d3f76638e3d1f2fad346b48d951af5f5
-2011-05-18T16:54:44.000000Z
-941
-azzie@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-2594
-
-mockrandom.js
-file
-
-
-
-
-2011-12-23T22:42:27.356316Z
-ab956e961b72fcd71eea517210f34484
-2011-09-27T00:20:47.000000Z
-1302
-bmccann@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-3208
-
-continuationtestcase_test.html
-file
-
-
-
-
-2011-12-23T22:42:27.356316Z
-0f718a1c0ff162520f054e8cc643fd3b
-2011-04-12T20:35:47.000000Z
-850
-diegosalas@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-8847
-
-ui
-dir
-
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/asserts.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/asserts.js.svn-base
deleted file mode 100644
index 530636b..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/asserts.js.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 15
-text/javascript
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/asserts_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/asserts_test.html.svn-base
deleted file mode 100644
index d356868..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/asserts_test.html.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 9
-text/html
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/asynctestcase.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/asynctestcase.js.svn-base
deleted file mode 100644
index 530636b..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/asynctestcase.js.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 15
-text/javascript
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/asynctestcase_async_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/asynctestcase_async_test.html.svn-base
deleted file mode 100644
index d356868..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/asynctestcase_async_test.html.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 9
-text/html
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/asynctestcase_noasync_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/asynctestcase_noasync_test.html.svn-base
deleted file mode 100644
index d356868..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/asynctestcase_noasync_test.html.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 9
-text/html
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/asynctestcase_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/asynctestcase_test.html.svn-base
deleted file mode 100644
index d356868..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/asynctestcase_test.html.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 9
-text/html
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/benchmark.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/benchmark.js.svn-base
deleted file mode 100644
index 530636b..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/benchmark.js.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 15
-text/javascript
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/continuationtestcase.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/continuationtestcase.js.svn-base
deleted file mode 100644
index 530636b..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/continuationtestcase.js.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 15
-text/javascript
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/continuationtestcase_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/continuationtestcase_test.html.svn-base
deleted file mode 100644
index d356868..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/continuationtestcase_test.html.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 9
-text/html
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/deferredtestcase.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/deferredtestcase.js.svn-base
deleted file mode 100644
index 530636b..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/deferredtestcase.js.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 15
-text/javascript
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/deferredtestcase_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/deferredtestcase_test.html.svn-base
deleted file mode 100644
index d356868..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/deferredtestcase_test.html.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 9
-text/html
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/dom.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/dom.js.svn-base
deleted file mode 100644
index 530636b..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/dom.js.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 15
-text/javascript
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/dom_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/dom_test.html.svn-base
deleted file mode 100644
index d356868..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/dom_test.html.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 9
-text/html
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/expectedfailures.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/expectedfailures.js.svn-base
deleted file mode 100644
index 530636b..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/expectedfailures.js.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 15
-text/javascript
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/expectedfailures_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/expectedfailures_test.html.svn-base
deleted file mode 100644
index d356868..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/expectedfailures_test.html.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 9
-text/html
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/functionmock.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/functionmock.js.svn-base
deleted file mode 100644
index 530636b..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/functionmock.js.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 15
-text/javascript
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/functionmock_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/functionmock_test.html.svn-base
deleted file mode 100644
index d356868..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/functionmock_test.html.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 9
-text/html
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/graphics.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/graphics.js.svn-base
deleted file mode 100644
index 530636b..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/graphics.js.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 15
-text/javascript
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/jsunit.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/jsunit.js.svn-base
deleted file mode 100644
index 530636b..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/jsunit.js.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 15
-text/javascript
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/loosemock.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/loosemock.js.svn-base
deleted file mode 100644
index 530636b..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/loosemock.js.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 15
-text/javascript
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/loosemock_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/loosemock_test.html.svn-base
deleted file mode 100644
index d356868..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/loosemock_test.html.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 9
-text/html
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mock.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mock.js.svn-base
deleted file mode 100644
index 530636b..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mock.js.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 15
-text/javascript
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mock_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mock_test.html.svn-base
deleted file mode 100644
index d356868..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mock_test.html.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 9
-text/html
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mockclassfactory.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mockclassfactory.js.svn-base
deleted file mode 100644
index 530636b..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mockclassfactory.js.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 15
-text/javascript
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mockclassfactory_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mockclassfactory_test.html.svn-base
deleted file mode 100644
index d356868..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mockclassfactory_test.html.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 9
-text/html
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mockclock.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mockclock.js.svn-base
deleted file mode 100644
index 530636b..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mockclock.js.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 15
-text/javascript
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mockclock_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mockclock_test.html.svn-base
deleted file mode 100644
index d356868..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mockclock_test.html.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 9
-text/html
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mockcontrol.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mockcontrol.js.svn-base
deleted file mode 100644
index 530636b..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mockcontrol.js.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 15
-text/javascript
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mockcontrol_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mockcontrol_test.html.svn-base
deleted file mode 100644
index d356868..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mockcontrol_test.html.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 9
-text/html
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mockinterface.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mockinterface.js.svn-base
deleted file mode 100644
index 7febff5..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mockinterface.js.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 22
-application/javascript
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mockmatchers.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mockmatchers.js.svn-base
deleted file mode 100644
index 530636b..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mockmatchers.js.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 15
-text/javascript
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mockmatchers_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mockmatchers_test.html.svn-base
deleted file mode 100644
index d356868..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mockmatchers_test.html.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 9
-text/html
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mockrandom.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mockrandom.js.svn-base
deleted file mode 100644
index 530636b..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mockrandom.js.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 15
-text/javascript
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mockrandom_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mockrandom_test.html.svn-base
deleted file mode 100644
index d356868..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mockrandom_test.html.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 9
-text/html
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mockrange.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mockrange.js.svn-base
deleted file mode 100644
index 530636b..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mockrange.js.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 15
-text/javascript
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mockrange_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mockrange_test.html.svn-base
deleted file mode 100644
index d356868..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mockrange_test.html.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 9
-text/html
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mockstorage.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mockstorage.js.svn-base
deleted file mode 100644
index 530636b..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mockstorage.js.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 15
-text/javascript
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mockstorage_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mockstorage_test.html.svn-base
deleted file mode 100644
index d356868..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mockstorage_test.html.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 9
-text/html
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mockuseragent.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mockuseragent.js.svn-base
deleted file mode 100644
index 530636b..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mockuseragent.js.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 15
-text/javascript
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mockuseragent_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mockuseragent_test.html.svn-base
deleted file mode 100644
index d356868..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/mockuseragent_test.html.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 9
-text/html
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/multitestrunner.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/multitestrunner.js.svn-base
deleted file mode 100644
index 530636b..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/multitestrunner.js.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 15
-text/javascript
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/objectpropertystring.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/objectpropertystring.js.svn-base
deleted file mode 100644
index 530636b..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/objectpropertystring.js.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 15
-text/javascript
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/performancetable.css.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/performancetable.css.svn-base
deleted file mode 100644
index 69cd899..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/performancetable.css.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 8
-text/css
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/performancetable.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/performancetable.js.svn-base
deleted file mode 100644
index 530636b..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/performancetable.js.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 15
-text/javascript
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/performancetimer.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/performancetimer.js.svn-base
deleted file mode 100644
index 530636b..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/performancetimer.js.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 15
-text/javascript
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/performancetimer_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/performancetimer_test.html.svn-base
deleted file mode 100644
index d356868..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/performancetimer_test.html.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 9
-text/html
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/propertyreplacer.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/propertyreplacer.js.svn-base
deleted file mode 100644
index 530636b..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/propertyreplacer.js.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 15
-text/javascript
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/propertyreplacer_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/propertyreplacer_test.html.svn-base
deleted file mode 100644
index d356868..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/propertyreplacer_test.html.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 9
-text/html
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/pseudorandom.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/pseudorandom.js.svn-base
deleted file mode 100644
index 530636b..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/pseudorandom.js.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 15
-text/javascript
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/pseudorandom_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/pseudorandom_test.html.svn-base
deleted file mode 100644
index d356868..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/pseudorandom_test.html.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 9
-text/html
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/recordfunction.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/recordfunction.js.svn-base
deleted file mode 100644
index 530636b..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/recordfunction.js.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 15
-text/javascript
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/recordfunction_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/recordfunction_test.html.svn-base
deleted file mode 100644
index d356868..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/recordfunction_test.html.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 9
-text/html
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/shardingtestcase.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/shardingtestcase.js.svn-base
deleted file mode 100644
index 530636b..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/shardingtestcase.js.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 15
-text/javascript
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/shardingtestcase_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/shardingtestcase_test.html.svn-base
deleted file mode 100644
index d356868..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/shardingtestcase_test.html.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 9
-text/html
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/singleton.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/singleton.js.svn-base
deleted file mode 100644
index 530636b..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/singleton.js.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 15
-text/javascript
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/singleton_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/singleton_test.html.svn-base
deleted file mode 100644
index d356868..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/singleton_test.html.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 9
-text/html
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/stacktrace.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/stacktrace.js.svn-base
deleted file mode 100644
index 530636b..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/stacktrace.js.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 15
-text/javascript
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/stacktrace_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/stacktrace_test.html.svn-base
deleted file mode 100644
index d356868..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/stacktrace_test.html.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 9
-text/html
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/strictmock.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/strictmock.js.svn-base
deleted file mode 100644
index 530636b..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/strictmock.js.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 15
-text/javascript
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/strictmock_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/strictmock_test.html.svn-base
deleted file mode 100644
index d356868..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/strictmock_test.html.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 9
-text/html
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/testcase.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/testcase.js.svn-base
deleted file mode 100644
index 530636b..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/testcase.js.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 15
-text/javascript
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/testqueue.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/testqueue.js.svn-base
deleted file mode 100644
index 530636b..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/testqueue.js.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 15
-text/javascript
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/testrunner.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/testrunner.js.svn-base
deleted file mode 100644
index 530636b..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/prop-base/testrunner.js.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 15
-text/javascript
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/asserts.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/asserts.js.svn-base
deleted file mode 100644
index 66810a1..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/asserts.js.svn-base
+++ /dev/null
@@ -1,1070 +0,0 @@
-// Copyright 2010 The Closure Library Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS-IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-goog.provide('goog.testing.JsUnitException');
-goog.provide('goog.testing.asserts');
-
-goog.require('goog.testing.stacktrace');
-
-// TODO(user): Copied from JsUnit with some small modifications, we should
-// reimplement the asserters.
-
-
-/**
- * @typedef {Array|NodeList|Arguments|{length: number}}
- */
-goog.testing.asserts.ArrayLike;
-
-var DOUBLE_EQUALITY_PREDICATE = function(var1, var2) {
- return var1 == var2;
-};
-var JSUNIT_UNDEFINED_VALUE;
-var TO_STRING_EQUALITY_PREDICATE = function(var1, var2) {
- return var1.toString() === var2.toString();
-};
-
-var PRIMITIVE_EQUALITY_PREDICATES = {
- 'String': DOUBLE_EQUALITY_PREDICATE,
- 'Number': DOUBLE_EQUALITY_PREDICATE,
- 'Boolean': DOUBLE_EQUALITY_PREDICATE,
- 'Date': function(date1, date2) {
- return date1.getTime() == date2.getTime();
- },
- 'RegExp': TO_STRING_EQUALITY_PREDICATE,
- 'Function': TO_STRING_EQUALITY_PREDICATE
-};
-
-
-function _trueTypeOf(something) {
- var result = typeof something;
- try {
- switch (result) {
- case 'string':
- break;
- case 'boolean':
- break;
- case 'number':
- break;
- case 'object':
- if (something == null) {
- result = 'null';
- break;
- }
- case 'function':
- switch (something.constructor) {
- case new String('').constructor:
- result = 'String';
- break;
- case new Boolean(true).constructor:
- result = 'Boolean';
- break;
- case new Number(0).constructor:
- result = 'Number';
- break;
- case new Array().constructor:
- result = 'Array';
- break;
- case new RegExp().constructor:
- result = 'RegExp';
- break;
- case new Date().constructor:
- result = 'Date';
- break;
- case Function:
- result = 'Function';
- break;
- default:
- var m = something.constructor.toString().match(
- /function\s*([^( ]+)\(/);
- if (m) {
- result = m[1];
- } else {
- break;
- }
- }
- break;
- }
- } catch (e) {
-
- } finally {
- result = result.substr(0, 1).toUpperCase() + result.substr(1);
- }
- return result;
-}
-
-function _displayStringForValue(aVar) {
- var result = '<' + aVar + '>';
- if (!(aVar === null || aVar === JSUNIT_UNDEFINED_VALUE)) {
- result += ' (' + _trueTypeOf(aVar) + ')';
- }
- return result;
-}
-
-function fail(failureMessage) {
- goog.testing.asserts.raiseException_('Call to fail()', failureMessage);
-}
-
-function argumentsIncludeComments(expectedNumberOfNonCommentArgs, args) {
- return args.length == expectedNumberOfNonCommentArgs + 1;
-}
-
-function commentArg(expectedNumberOfNonCommentArgs, args) {
- if (argumentsIncludeComments(expectedNumberOfNonCommentArgs, args)) {
- return args[0];
- }
-
- return null;
-}
-
-function nonCommentArg(desiredNonCommentArgIndex,
- expectedNumberOfNonCommentArgs, args) {
- return argumentsIncludeComments(expectedNumberOfNonCommentArgs, args) ?
- args[desiredNonCommentArgIndex] :
- args[desiredNonCommentArgIndex - 1];
-}
-
-function _validateArguments(expectedNumberOfNonCommentArgs, args) {
- var valid = args.length == expectedNumberOfNonCommentArgs ||
- args.length == expectedNumberOfNonCommentArgs + 1 &&
- goog.isString(args[0]);
- _assert(null, valid, 'Incorrect arguments passed to assert function');
-}
-
-function _assert(comment, booleanValue, failureMessage) {
- if (!booleanValue) {
- goog.testing.asserts.raiseException_(comment, failureMessage);
- }
-}
-
-
-/**
- * @param {*} a
- * @param {*=} opt_b
- */
-function assert(a, opt_b) {
- _validateArguments(1, arguments);
- var comment = commentArg(1, arguments);
- var booleanValue = nonCommentArg(1, 1, arguments);
-
- _assert(comment, goog.isBoolean(booleanValue),
- 'Bad argument to assert(boolean)');
- _assert(comment, booleanValue, 'Call to assert(boolean) with false');
-}
-
-
-/**
- * Asserts that the function throws an error.
- *
- * @param {!(string|Function)} a The assertion comment or the function to call.
- * @param {!Function=} opt_b The function to call (if the first argument of
- * {@code assertThrows} was the comment).
- * @return {*} The error thrown by the function.
- * @throws {goog.testing.JsUnitException} If the assertion failed.
- */
-function assertThrows(a, opt_b) {
- _validateArguments(1, arguments);
- var func = nonCommentArg(1, 1, arguments);
- var comment = commentArg(1, arguments);
- _assert(comment, typeof func == 'function',
- 'Argument passed to assertThrows is not a function');
-
- try {
- func();
- } catch (e) {
- if (e && goog.isString(e['stacktrace']) && goog.isString(e['message'])) {
- // Remove the stack trace appended to the error message by Opera 10.0
- var startIndex = e['message'].length - e['stacktrace'].length;
- if (e['message'].indexOf(e['stacktrace'], startIndex) == startIndex) {
- e['message'] = e['message'].substr(0, startIndex - 14);
- }
- }
- return e;
- }
- goog.testing.asserts.raiseException_(comment,
- 'No exception thrown from function passed to assertThrows');
-}
-
-
-/**
- * Asserts that the function does not throw an error.
- *
- * @param {!(string|Function)} a The assertion comment or the function to call.
- * @param {!Function=} opt_b The function to call (if the first argument of
- * {@code assertNotThrows} was the comment).
- * @throws {goog.testing.JsUnitException} If the assertion failed.
- */
-function assertNotThrows(a, opt_b) {
- _validateArguments(1, arguments);
- var comment = commentArg(1, arguments);
- var func = nonCommentArg(1, 1, arguments);
- _assert(comment, typeof func == 'function',
- 'Argument passed to assertNotThrows is not a function');
-
- try {
- func();
- } catch (e) {
- comment = comment ? (comment + '\n') : '';
- comment += 'A non expected exception was thrown from function passed to ' +
- 'assertNotThrows';
- // Some browsers don't have a stack trace so at least have the error
- // description.
- var stackTrace = e['stack'] || e['stacktrace'] || e.toString();
- goog.testing.asserts.raiseException_(comment, stackTrace);
- }
-}
-
-
-/**
- * Asserts that the given callback function results in a JsUnitException when
- * called, and that the resulting failure message matches the given expected
- * message.
- * @param {function() : void} callback Function to be run expected to result
- * in a JsUnitException (usually contains a call to an assert).
- * @param {string=} opt_expectedMessage Failure message expected to be given
- * with the exception.
- */
-function assertThrowsJsUnitException(callback, opt_expectedMessage) {
- var failed = false;
- try {
- goog.testing.asserts.callWithoutLogging(callback);
- } catch (ex) {
- if (!ex.isJsUnitException) {
- fail('Expected a JsUnitException');
- }
- if (typeof opt_expectedMessage != 'undefined' &&
- ex.message != opt_expectedMessage) {
- fail('Expected message [' + opt_expectedMessage + '] but got [' +
- ex.message + ']');
- }
- failed = true;
- }
- if (!failed) {
- fail('Expected a failure: ' + opt_expectedMessage);
- }
-}
-
-
-/**
- * @param {*} a
- * @param {*=} opt_b
- */
-function assertTrue(a, opt_b) {
- _validateArguments(1, arguments);
- var comment = commentArg(1, arguments);
- var booleanValue = nonCommentArg(1, 1, arguments);
-
- _assert(comment, goog.isBoolean(booleanValue),
- 'Bad argument to assertTrue(boolean)');
- _assert(comment, booleanValue, 'Call to assertTrue(boolean) with false');
-}
-
-
-/**
- * @param {*} a
- * @param {*=} opt_b
- */
-function assertFalse(a, opt_b) {
- _validateArguments(1, arguments);
- var comment = commentArg(1, arguments);
- var booleanValue = nonCommentArg(1, 1, arguments);
-
- _assert(comment, goog.isBoolean(booleanValue),
- 'Bad argument to assertFalse(boolean)');
- _assert(comment, !booleanValue, 'Call to assertFalse(boolean) with true');
-}
-
-
-/**
- * @param {*} a
- * @param {*} b
- * @param {*=} opt_c
- */
-function assertEquals(a, b, opt_c) {
- _validateArguments(2, arguments);
- var var1 = nonCommentArg(1, 2, arguments);
- var var2 = nonCommentArg(2, 2, arguments);
- _assert(commentArg(2, arguments), var1 === var2,
- 'Expected ' + _displayStringForValue(var1) + ' but was ' +
- _displayStringForValue(var2));
-}
-
-
-/**
- * @param {*} a
- * @param {*} b
- * @param {*=} opt_c
- */
-function assertNotEquals(a, b, opt_c) {
- _validateArguments(2, arguments);
- var var1 = nonCommentArg(1, 2, arguments);
- var var2 = nonCommentArg(2, 2, arguments);
- _assert(commentArg(2, arguments), var1 !== var2,
- 'Expected not to be ' + _displayStringForValue(var2));
-}
-
-
-/**
- * @param {*} a
- * @param {*=} opt_b
- */
-function assertNull(a, opt_b) {
- _validateArguments(1, arguments);
- var aVar = nonCommentArg(1, 1, arguments);
- _assert(commentArg(1, arguments), aVar === null,
- 'Expected ' + _displayStringForValue(null) + ' but was ' +
- _displayStringForValue(aVar));
-}
-
-
-/**
- * @param {*} a
- * @param {*=} opt_b
- */
-function assertNotNull(a, opt_b) {
- _validateArguments(1, arguments);
- var aVar = nonCommentArg(1, 1, arguments);
- _assert(commentArg(1, arguments), aVar !== null,
- 'Expected not to be ' + _displayStringForValue(null));
-}
-
-
-/**
- * @param {*} a
- * @param {*=} opt_b
- */
-function assertUndefined(a, opt_b) {
- _validateArguments(1, arguments);
- var aVar = nonCommentArg(1, 1, arguments);
- _assert(commentArg(1, arguments), aVar === JSUNIT_UNDEFINED_VALUE,
- 'Expected ' + _displayStringForValue(JSUNIT_UNDEFINED_VALUE) +
- ' but was ' + _displayStringForValue(aVar));
-}
-
-
-/**
- * @param {*} a
- * @param {*=} opt_b
- */
-function assertNotUndefined(a, opt_b) {
- _validateArguments(1, arguments);
- var aVar = nonCommentArg(1, 1, arguments);
- _assert(commentArg(1, arguments), aVar !== JSUNIT_UNDEFINED_VALUE,
- 'Expected not to be ' + _displayStringForValue(JSUNIT_UNDEFINED_VALUE));
-}
-
-
-/**
- * @param {*} a
- * @param {*=} opt_b
- */
-function assertNotNullNorUndefined(a, opt_b) {
- _validateArguments(1, arguments);
- assertNotNull.apply(null, arguments);
- assertNotUndefined.apply(null, arguments);
-}
-
-
-/**
- * @param {*} a
- * @param {*=} opt_b
- */
-function assertNonEmptyString(a, opt_b) {
- _validateArguments(1, arguments);
- var aVar = nonCommentArg(1, 1, arguments);
- _assert(commentArg(1, arguments),
- aVar !== JSUNIT_UNDEFINED_VALUE && aVar !== null &&
- typeof aVar == 'string' && aVar !== '',
- 'Expected non-empty string but was ' + _displayStringForValue(aVar));
-}
-
-
-/**
- * @param {*} a
- * @param {*=} opt_b
- */
-function assertNaN(a, opt_b) {
- _validateArguments(1, arguments);
- var aVar = nonCommentArg(1, 1, arguments);
- _assert(commentArg(1, arguments), isNaN(aVar), 'Expected NaN');
-}
-
-
-/**
- * @param {*} a
- * @param {*=} opt_b
- */
-function assertNotNaN(a, opt_b) {
- _validateArguments(1, arguments);
- var aVar = nonCommentArg(1, 1, arguments);
- _assert(commentArg(1, arguments), !isNaN(aVar), 'Expected not NaN');
-}
-
-
-/**
- * Runs a function in an environment where test failures are not logged. This is
- * useful for testing test code, where failures can be a normal part of a test.
- * @param {function() : void} fn Function to run without logging failures.
- */
-goog.testing.asserts.callWithoutLogging = function(fn) {
- var testRunner = goog.global['G_testRunner'];
- var oldLogTestFailure = testRunner['logTestFailure'];
- try {
- // Any failures in the callback shouldn't be recorded.
- testRunner['logTestFailure'] = undefined;
- fn();
- } finally {
- testRunner['logTestFailure'] = oldLogTestFailure;
- }
-};
-
-
-/**
- * Determines if two items of any type match, and formulates an error message
- * if not.
- * @param {*} expected Expected argument to match.
- * @param {*} actual Argument as a result of performing the test.
- * @return {?string} Null on success, error message on failure.
- */
-goog.testing.asserts.findDifferences = function(expected, actual) {
- var failures = [];
- var seen1 = [];
- var seen2 = [];
-
- // To avoid infinite recursion when the two parameters are self-referential
- // along the same path of properties, keep track of the object pairs already
- // seen in this call subtree, and abort when a cycle is detected.
- // TODO(gboyer,user): The algorithm still does not terminate in cases
- // with exponential recursion, e.g. a binary tree with leaf->root links.
- // Investigate ways to solve this without significant performance loss
- // for the common case.
- function innerAssert(var1, var2, path) {
- var depth = seen1.length;
- if (depth % 2) {
- // Compare with midpoint of seen ("Tortoise and hare" loop detection).
- // http://en.wikipedia.org/wiki/Cycle_detection#Tortoise_and_hare
- // TODO(gboyer,user): For cases with complex cycles the algorithm
- // can take a long time to terminate, look into ways to terminate sooner
- // without adding more than constant-time work in non-cycle cases.
- var mid = depth >> 1;
- // Use === to avoid cases like ['x'] == 'x', which is true.
- var match1 = seen1[mid] === var1;
- var match2 = seen2[mid] === var2;
- if (match1 || match2) {
- if (!match1 || !match2) {
- // Asymmetric cycles, so the objects have different structure.
- failures.push('Asymmetric cycle detected at ' + path);
- }
- return;
- }
- }
- seen1.push(var1);
- seen2.push(var2);
- innerAssert_(var1, var2, path);
- seen1.pop();
- seen2.pop();
- }
-
- /**
- * @suppress {missingProperties} The map_ property is unknown to the compiler
- * unless goog.structs.Map is loaded.
- */
- function innerAssert_(var1, var2, path) {
- if (var1 === var2) {
- return;
- }
-
- var typeOfVar1 = _trueTypeOf(var1);
- var typeOfVar2 = _trueTypeOf(var2);
-
- if (typeOfVar1 == typeOfVar2) {
- var isArray = typeOfVar1 == 'Array';
- var equalityPredicate = PRIMITIVE_EQUALITY_PREDICATES[typeOfVar1];
- if (equalityPredicate) {
- if (!equalityPredicate(var1, var2)) {
- failures.push(path + ' expected ' + _displayStringForValue(var1) +
- ' but was ' + _displayStringForValue(var2));
- }
- } else if (isArray && var1.length != var2.length) {
- failures.push(path + ' expected ' + var1.length + '-element array ' +
- 'but got a ' + var2.length + '-element array');
- } else {
- var childPath = path + (isArray ? '[%s]' : (path ? '.%s' : '%s'));
-
- // if an object has an __iterator__ property, we have no way of
- // actually inspecting its raw properties, and JS 1.7 doesn't
- // overload [] to make it possible for someone to generically
- // use what the iterator returns to compare the object-managed
- // properties. This gets us into deep poo with things like
- // goog.structs.Map, at least on systems that support iteration.
- if (!var1['__iterator__']) {
- for (var prop in var1) {
- if (isArray && goog.testing.asserts.isArrayIndexProp_(prop)) {
- // Skip array indices for now. We'll handle them later.
- continue;
- }
-
- if (prop in var2) {
- innerAssert(var1[prop], var2[prop],
- childPath.replace('%s', prop));
- } else {
- failures.push('property ' + prop +
- ' not present in actual ' + (path || typeOfVar2));
- }
- }
- // make sure there aren't properties in var2 that are missing
- // from var1. if there are, then by definition they don't
- // match.
- for (var prop in var2) {
- if (isArray && goog.testing.asserts.isArrayIndexProp_(prop)) {
- // Skip array indices for now. We'll handle them later.
- continue;
- }
-
- if (!(prop in var1)) {
- failures.push('property ' + prop +
- ' not present in expected ' +
- (path || typeOfVar1));
- }
- }
-
- // Handle array indices by iterating from 0 to arr.length.
- //
- // Although all browsers allow holes in arrays, browsers
- // are inconsistent in what they consider a hole. For example,
- // "[0,undefined,2]" has a hole on IE but not on Firefox.
- //
- // Because our style guide bans for...in iteration over arrays,
- // we assume that most users don't care about holes in arrays,
- // and that it is ok to say that a hole is equivalent to a slot
- // populated with 'undefined'.
- if (isArray) {
- for (prop = 0; prop < var1.length; prop++) {
- innerAssert(var1[prop], var2[prop],
- childPath.replace('%s', String(prop)));
- }
- }
- } else {
- // special-case for closure objects that have iterators
- if (goog.isFunction(var1.equals)) {
- // use the object's own equals function, assuming it accepts an
- // object and returns a boolean
- if (!var1.equals(var2)) {
- failures.push('equals() returned false for ' +
- (path || typeOfVar1));
- }
- } else if (var1.map_) {
- // assume goog.structs.Map or goog.structs.Set, where comparing
- // their private map_ field is sufficient
- innerAssert(var1.map_, var2.map_, childPath.replace('%s', 'map_'));
- } else {
- // else die, so user knows we can't do anything
- failures.push('unable to check ' + (path || typeOfVar1) +
- ' for equality: it has an iterator we do not ' +
- 'know how to handle. please add an equals method');
- }
- }
- }
- } else {
- failures.push(path + ' expected ' + _displayStringForValue(var1) +
- ' but was ' + _displayStringForValue(var2));
- }
- }
-
- innerAssert(expected, actual, '');
- return failures.length == 0 ? null :
- 'Expected ' + _displayStringForValue(expected) + ' but was ' +
- _displayStringForValue(actual) + '\n ' + failures.join('\n ');
-};
-
-
-/**
- * Notes:
- * Object equality has some nasty browser quirks, and this implementation is
- * not 100% correct. For example,
- *
- * <code>
- * var a = [0, 1, 2];
- * var b = [0, 1, 2];
- * delete a[1];
- * b[1] = undefined;
- * assertObjectEquals(a, b); // should fail, but currently passes
- * </code>
- *
- * See asserts_test.html for more interesting edge cases.
- *
- * The first comparison object provided is the expected value, the second is
- * the actual.
- *
- * @param {*} a Assertion message or comparison object.
- * @param {*} b Comparison object.
- * @param {*=} opt_c Comparison object, if an assertion message was provided.
- */
-function assertObjectEquals(a, b, opt_c) {
- _validateArguments(2, arguments);
- var v1 = nonCommentArg(1, 2, arguments);
- var v2 = nonCommentArg(2, 2, arguments);
- var failureMessage = commentArg(2, arguments) ? commentArg(2, arguments) : '';
- var differences = goog.testing.asserts.findDifferences(v1, v2);
-
- _assert(failureMessage, !differences, differences);
-}
-
-
-/**
- * Compares two arbitrary objects for non-equalness.
- *
- * All the same caveats as for assertObjectEquals apply here:
- * Undefined values may be confused for missing values, or vice versa.
- *
- * @param {*} a Assertion message or comparison object.
- * @param {*} b Comparison object.
- * @param {*=} opt_c Comparison object, if an assertion message was provided.
- */
-function assertObjectNotEquals(a, b, opt_c) {
- _validateArguments(2, arguments);
- var v1 = nonCommentArg(1, 2, arguments);
- var v2 = nonCommentArg(2, 2, arguments);
- var failureMessage = commentArg(2, arguments) ? commentArg(2, arguments) : '';
- var differences = goog.testing.asserts.findDifferences(v1, v2);
-
- _assert(failureMessage, differences, 'Objects should not be equal');
-}
-
-
-/**
- * @param {*} a
- * @param {*} b
- * @param {*=} opt_c
- */
-function assertArrayEquals(a, b, opt_c) {
- _validateArguments(2, arguments);
- var v1 = nonCommentArg(1, 2, arguments);
- var v2 = nonCommentArg(2, 2, arguments);
- var failureMessage = commentArg(2, arguments) ? commentArg(2, arguments) : '';
-
- var typeOfVar1 = _trueTypeOf(v1);
- _assert(failureMessage,
- typeOfVar1 == 'Array',
- 'Expected an array for assertArrayEquals but found a ' + typeOfVar1);
-
- var typeOfVar2 = _trueTypeOf(v2);
- _assert(failureMessage,
- typeOfVar2 == 'Array',
- 'Expected an array for assertArrayEquals but found a ' + typeOfVar2);
-
- assertObjectEquals.apply(null, arguments);
-}
-
-
-/**
- * Compares two objects that can be accessed like an array and assert that
- * each element is equal.
- * @param {string|Object} a Failure message (3 arguments)
- * or object #1 (2 arguments).
- * @param {Object} b Object #1 (2 arguments) or object #2 (3 arguments).
- * @param {Object} c Object #2 (3 arguments).
- */
-function assertElementsEquals(a, b, c) {
- _validateArguments(2, arguments);
-
- var v1 = nonCommentArg(1, 2, arguments);
- var v2 = nonCommentArg(2, 2, arguments);
- var failureMessage = commentArg(2, arguments) ? commentArg(2, arguments) : '';
-
- if (!v1) {
- assert(failureMessage, !v2);
- } else {
- assertEquals('length mismatch: ' + failureMessage, v1.length, v2.length);
- for (var i = 0; i < v1.length; ++i) {
- assertEquals(
- 'mismatch at index ' + i + ': ' + failureMessage, v1[i], v2[i]);
- }
- }
-}
-
-
-/**
- * Compares two objects that can be accessed like an array and assert that
- * each element is roughly equal.
- * @param {string|Object} a Failure message (4 arguments)
- * or object #1 (3 arguments).
- * @param {Object} b Object #1 (4 arguments) or object #2 (3 arguments).
- * @param {Object|number} c Object #2 (4 arguments) or tolerance (3 arguments).
- * @param {number=} opt_d tolerance (4 arguments).
- */
-function assertElementsRoughlyEqual(a, b, c, opt_d) {
- _validateArguments(3, arguments);
-
- var v1 = nonCommentArg(1, 3, arguments);
- var v2 = nonCommentArg(2, 3, arguments);
- var tolerance = nonCommentArg(3, 3, arguments);
- var failureMessage = commentArg(3, arguments) ? commentArg(3, arguments) : '';
-
- if (!v1) {
- assert(failureMessage, !v2);
- } else {
- assertEquals('length mismatch: ' + failureMessage, v1.length, v2.length);
- for (var i = 0; i < v1.length; ++i) {
- assertRoughlyEquals(failureMessage, v1[i], v2[i], tolerance);
- }
- }
-}
-
-
-/**
- * Compares two array-like objects without taking their order into account.
- * @param {string|goog.testing.asserts.ArrayLike} a Assertion message or the
- * expected elements.
- * @param {goog.testing.asserts.ArrayLike} b Expected elements or the actual
- * elements.
- * @param {goog.testing.asserts.ArrayLike=} opt_c Actual elements.
- */
-function assertSameElements(a, b, opt_c) {
- _validateArguments(2, arguments);
- var expected = nonCommentArg(1, 2, arguments);
- var actual = nonCommentArg(2, 2, arguments);
- var message = commentArg(2, arguments);
-
- assertTrue('Bad arguments to assertSameElements(opt_message, expected: ' +
- 'ArrayLike, actual: ArrayLike)',
- goog.isArrayLike(expected) && goog.isArrayLike(actual));
-
- // Clones expected and actual and converts them to real arrays.
- expected = goog.testing.asserts.toArray_(expected);
- actual = goog.testing.asserts.toArray_(actual);
- // TODO(user): It would be great to show only the difference
- // between the expected and actual elements.
- _assert(message, expected.length == actual.length,
- 'Expected ' + expected.length + ' elements: [' + expected + '], ' +
- 'got ' + actual.length + ' elements: [' + actual + ']');
-
- var toFind = goog.testing.asserts.toArray_(expected);
- for (var i = 0; i < actual.length; i++) {
- var index = goog.testing.asserts.indexOf_(toFind, actual[i]);
- _assert(message, index != -1, 'Expected [' + expected + '], got [' +
- actual + ']');
- toFind.splice(index, 1);
- }
-}
-
-
-/**
- * @param {*} a
- * @param {*=} opt_b
- */
-function assertEvaluatesToTrue(a, opt_b) {
- _validateArguments(1, arguments);
- var value = nonCommentArg(1, 1, arguments);
- if (!value) {
- _assert(commentArg(1, arguments), false, 'Expected to evaluate to true');
- }
-}
-
-
-/**
- * @param {*} a
- * @param {*=} opt_b
- */
-function assertEvaluatesToFalse(a, opt_b) {
- _validateArguments(1, arguments);
- var value = nonCommentArg(1, 1, arguments);
- if (value) {
- _assert(commentArg(1, arguments), false, 'Expected to evaluate to false');
- }
-}
-
-
-/**
- * @param {*} a
- * @param {*} b
- * @param {*=} opt_c
- */
-function assertHTMLEquals(a, b, opt_c) {
- _validateArguments(2, arguments);
- var var1 = nonCommentArg(1, 2, arguments);
- var var2 = nonCommentArg(2, 2, arguments);
- var var1Standardized = standardizeHTML(var1);
- var var2Standardized = standardizeHTML(var2);
-
- _assert(commentArg(2, arguments), var1Standardized === var2Standardized,
- 'Expected ' + _displayStringForValue(var1Standardized) + ' but was ' +
- _displayStringForValue(var2Standardized));
-}
-
-
-/**
- * Compares two CSS property values to make sure that they represent the same
- * things. This will normalize values in the browser. For example, in Firefox,
- * this assertion will consider "rgb(0, 0, 255)" and "#0000ff" to be identical
- * values for the "color" property. This function won't normalize everything --
- * for example, in most browsers, "blue" will not match "#0000ff". It is
- * intended only to compensate for unexpected normalizations performed by
- * the browser that should also affect your expected value.
- * @param {string} a Assertion message, or the CSS property name.
- * @param {string} b CSS property name, or the expected value.
- * @param {string} c The expected value, or the actual value.
- * @param {string=} opt_d The actual value.
- */
-function assertCSSValueEquals(a, b, c, opt_d) {
- _validateArguments(3, arguments);
- var propertyName = nonCommentArg(1, 3, arguments);
- var expectedValue = nonCommentArg(2, 3, arguments);
- var actualValue = nonCommentArg(3, 3, arguments);
- var expectedValueStandardized =
- standardizeCSSValue(propertyName, expectedValue);
- var actualValueStandardized =
- standardizeCSSValue(propertyName, actualValue);
-
- _assert(commentArg(3, arguments),
- expectedValueStandardized == actualValueStandardized,
- 'Expected ' + _displayStringForValue(expectedValueStandardized) +
- ' but was ' + _displayStringForValue(actualValueStandardized));
-}
-
-
-/**
- * @param {*} a
- * @param {*} b
- * @param {*=} opt_c
- */
-function assertHashEquals(a, b, opt_c) {
- _validateArguments(2, arguments);
- var var1 = nonCommentArg(1, 2, arguments);
- var var2 = nonCommentArg(2, 2, arguments);
- var message = commentArg(2, arguments);
- for (var key in var1) {
- _assert(message,
- key in var2, 'Expected hash had key ' + key + ' that was not found');
- _assert(message, var1[key] == var2[key], 'Value for key ' + key +
- ' mismatch - expected = ' + var1[key] + ', actual = ' + var2[key]);
- }
-
- for (var key in var2) {
- _assert(message, key in var1, 'Actual hash had key ' + key +
- ' that was not expected');
- }
-}
-
-
-/**
- * @param {*} a
- * @param {*} b
- * @param {*} c
- * @param {*=} opt_d
- */
-function assertRoughlyEquals(a, b, c, opt_d) {
- _validateArguments(3, arguments);
- var expected = nonCommentArg(1, 3, arguments);
- var actual = nonCommentArg(2, 3, arguments);
- var tolerance = nonCommentArg(3, 3, arguments);
- _assert(commentArg(3, arguments), Math.abs(expected - actual) <= tolerance,
- 'Expected ' + expected + ', but got ' + actual +
- ' which was more than ' + tolerance + ' away');
-}
-
-
-/**
- * Checks if the given element is the member of the given container.
- * @param {*} a Failure message (3 arguments) or the contained element
- * (2 arguments).
- * @param {*} b The contained element (3 arguments) or the container
- * (2 arguments).
- * @param {*=} opt_c The container.
- */
-function assertContains(a, b, opt_c) {
- _validateArguments(2, arguments);
- var contained = nonCommentArg(1, 2, arguments);
- var container = nonCommentArg(2, 2, arguments);
- _assert(commentArg(2, arguments),
- goog.testing.asserts.contains_(container, contained),
- 'Expected \'' + container + '\' to contain \'' + contained + '\'');
-}
-
-
-/**
- * Checks if the given element is not the member of the given container.
- * @param {*} a Failure message (3 arguments) or the contained element
- * (2 arguments).
- * @param {*} b The contained element (3 arguments) or the container
- * (2 arguments).
- * @param {*=} opt_c The container.
- */
-function assertNotContains(a, b, opt_c) {
- _validateArguments(2, arguments);
- var contained = nonCommentArg(1, 2, arguments);
- var container = nonCommentArg(2, 2, arguments);
- _assert(commentArg(2, arguments),
- !goog.testing.asserts.contains_(container, contained),
- 'Expected \'' + container + '\' not to contain \'' + contained + '\'');
-}
-
-
-/**
- * Converts an array like object to array or clones it if it's already array.
- * @param {goog.testing.asserts.ArrayLike} arrayLike The collection.
- * @return {!Array} Copy of the collection as array.
- * @private
- */
-goog.testing.asserts.toArray_ = function(arrayLike) {
- var ret = [];
- for (var i = 0; i < arrayLike.length; i++) {
- ret[i] = arrayLike[i];
- }
- return ret;
-};
-
-
-/**
- * Finds the position of the first occurrence of an element in a container.
- * @param {goog.testing.asserts.ArrayLike} container
- * The array to find the element in.
- * @param {*} contained Element to find.
- * @return {number} Index of the first occurrence or -1 if not found.
- * @private
- */
-goog.testing.asserts.indexOf_ = function(container, contained) {
- if (container.indexOf) {
- return container.indexOf(contained);
- } else {
- // IE6/7 do not have indexOf so do a search.
- for (var i = 0; i < container.length; i++) {
- if (container[i] === contained) {
- return i;
- }
- }
- return -1;
- }
-};
-
-
-/**
- * Tells whether the array contains the given element.
- * @param {goog.testing.asserts.ArrayLike} container The array to
- * find the element in.
- * @param {*} contained Element to find.
- * @return {boolean} Whether the element is in the array.
- * @private
- */
-goog.testing.asserts.contains_ = function(container, contained) {
- // TODO(user): Can we check for container.contains as well?
- // That would give us support for most goog.structs (though weird results
- // with anything else with a contains method, like goog.math.Range). Falling
- // back with container.some would catch all iterables, too.
- return goog.testing.asserts.indexOf_(container, contained) != -1;
-};
-
-function standardizeHTML(html) {
- var translator = document.createElement('DIV');
- translator.innerHTML = html;
-
- // Trim whitespace from result (without relying on goog.string)
- return translator.innerHTML.replace(/^\s+|\s+$/g, '');
-}
-
-
-/**
- * Standardizes a CSS value for a given property by applying it to an element
- * and then reading it back.
- * @param {string} propertyName CSS property name.
- * @param {string} value CSS value.
- * @return {string} Normalized CSS value.
- */
-function standardizeCSSValue(propertyName, value) {
- var styleDeclaration = document.createElement('DIV').style;
- styleDeclaration[propertyName] = value;
- return styleDeclaration[propertyName];
-}
-
-
-/**
- * Raises a JsUnit exception with the given comment.
- * @param {string} comment A summary for the exception.
- * @param {string=} opt_message A description of the exception.
- * @private
- */
-goog.testing.asserts.raiseException_ = function(comment, opt_message) {
- if (goog.global['CLOSURE_INSPECTOR___'] &&
- goog.global['CLOSURE_INSPECTOR___']['supportsJSUnit']) {
- goog.global['CLOSURE_INSPECTOR___']['jsUnitFailure'](comment, opt_message);
- }
-
- throw new goog.testing.JsUnitException(comment, opt_message);
-};
-
-
-/**
- * Helper function for assertObjectEquals. Tells us if a given property
- * name is an array index.
- * @param {string} prop
- * @return {boolean}
- * @private
- */
-goog.testing.asserts.isArrayIndexProp_ = function(prop) {
- return (prop | 0) == prop;
-};
-
-
-
-/**
- * @param {string} comment A summary for the exception.
- * @param {?string=} opt_message A description of the exception.
- * @constructor
- */
-goog.testing.JsUnitException = function(comment, opt_message) {
- this.isJsUnitException = true;
- this.message = (comment ? comment : '') +
- (comment && opt_message ? '\n' : '') +
- (opt_message ? opt_message : '');
- this.stackTrace = goog.testing.stacktrace.get();
- // These fields are for compatibility with jsUnitTestManager.
- this.comment = comment || null;
- this.jsUnitMessage = opt_message || '';
-};
-
-
-/** @override */
-goog.testing.JsUnitException.prototype.toString = function() {
- // TODO(agrieve): Fix dependency in build rules. For more info see
- // http://b/2020085
- return '[JsUnitException]';
-};
-
-goog.exportSymbol('fail', fail);
-goog.exportSymbol('assert', assert);
-goog.exportSymbol('assertThrows', assertThrows);
-goog.exportSymbol('assertNotThrows', assertNotThrows);
-goog.exportSymbol('assertTrue', assertTrue);
-goog.exportSymbol('assertFalse', assertFalse);
-goog.exportSymbol('assertEquals', assertEquals);
-goog.exportSymbol('assertNotEquals', assertNotEquals);
-goog.exportSymbol('assertNull', assertNull);
-goog.exportSymbol('assertNotNull', assertNotNull);
-goog.exportSymbol('assertUndefined', assertUndefined);
-goog.exportSymbol('assertNotUndefined', assertNotUndefined);
-goog.exportSymbol('assertNotNullNorUndefined', assertNotNullNorUndefined);
-goog.exportSymbol('assertNonEmptyString', assertNonEmptyString);
-goog.exportSymbol('assertNaN', assertNaN);
-goog.exportSymbol('assertNotNaN', assertNotNaN);
-goog.exportSymbol('assertObjectEquals', assertObjectEquals);
-goog.exportSymbol('assertObjectNotEquals', assertObjectNotEquals);
-goog.exportSymbol('assertArrayEquals', assertArrayEquals);
-goog.exportSymbol('assertElementsEquals', assertElementsEquals);
-goog.exportSymbol('assertElementsRoughlyEqual', assertElementsRoughlyEqual);
-goog.exportSymbol('assertSameElements', assertSameElements);
-goog.exportSymbol('assertEvaluatesToTrue', assertEvaluatesToTrue);
-goog.exportSymbol('assertEvaluatesToFalse', assertEvaluatesToFalse);
-goog.exportSymbol('assertHTMLEquals', assertHTMLEquals);
-goog.exportSymbol('assertHashEquals', assertHashEquals);
-goog.exportSymbol('assertRoughlyEquals', assertRoughlyEquals);
-goog.exportSymbol('assertContains', assertContains);
-goog.exportSymbol('assertNotContains', assertNotContains);
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/asserts_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/asserts_test.html.svn-base
deleted file mode 100644
index 8d05659..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/asserts_test.html.svn-base
+++ /dev/null
@@ -1,1011 +0,0 @@
-<!DOCTYPE html>
-<html>
-<!--
-Copyright 2007 The Closure Library Authors. All Rights Reserved.
-
-Use of this source code is governed by the Apache License, Version 2.0.
-See the COPYING file for details.
--->
-<head>
-<meta http-equiv="X-UA-Compatible" content="IE=edge">
-<title>Closure Unit Tests - goog.testing.asserts</title>
-<script src="../base.js"></script>
-<script>
- goog.require('goog.dom');
- goog.require('goog.iter.Iterator');
- goog.require('goog.iter.StopIteration');
- goog.require('goog.structs.Map');
- goog.require('goog.structs.Set');
- goog.require('goog.testing.asserts');
- goog.require('goog.testing.jsunit');
- goog.require('goog.userAgent');
-</script>
-</head>
-<body>
-<script>
-
- function testAssertTrue() {
- assertTrue(true);
- assertTrue('Good assertion', true);
- assertThrowsJsUnitException(
- function() { assertTrue(false); },
- 'Call to assertTrue(boolean) with false');
- assertThrowsJsUnitException(
- function() { assertTrue('Should be true', false); },
- 'Should be true\nCall to assertTrue(boolean) with false');
- assertThrowsJsUnitException(
- function() { assertTrue(null); },
- 'Bad argument to assertTrue(boolean)');
- assertThrowsJsUnitException(
- function() { assertTrue(undefined); },
- 'Bad argument to assertTrue(boolean)');
- }
-
- function testAssertFalse() {
- assertFalse(false);
- assertFalse('Good assertion', false);
- assertThrowsJsUnitException(
- function() { assertFalse(true); },
- 'Call to assertFalse(boolean) with true');
- assertThrowsJsUnitException(
- function() { assertFalse('Should be false', true); },
- 'Should be false\nCall to assertFalse(boolean) with true');
- assertThrowsJsUnitException(
- function() { assertFalse(null); },
- 'Bad argument to assertFalse(boolean)');
- assertThrowsJsUnitException(
- function() { assertFalse(undefined); },
- 'Bad argument to assertFalse(boolean)');
- }
-
- function testAssertEqualsWithString() {
- assertEquals('a', 'a');
- assertEquals('Good assertion', 'a', 'a');
- assertThrowsJsUnitException(
- function() { assertEquals('a', 'b'); },
- 'Expected <a> (String) but was <b> (String)');
- assertThrowsJsUnitException(
- function() { assertEquals('Bad assertion', 'a', 'b'); },
- 'Bad assertion\nExpected <a> (String) but was <b> (String)');
- }
-
- function testAssertEqualsWithInteger() {
- assertEquals(1, 1);
- assertEquals('Good assertion', 1, 1);
- assertThrowsJsUnitException(
- function() { assertEquals(1, 2); },
- 'Expected <1> (Number) but was <2> (Number)');
- assertThrowsJsUnitException(
- function() { assertEquals('Bad assertion', 1, 2); },
- 'Bad assertion\nExpected <1> (Number) but was <2> (Number)');
- }
-
- function testAssertNotEquals() {
- assertNotEquals('a', 'b');
- assertNotEquals('a', 'a', 'b');
- assertThrowsJsUnitException(
- function() { assertNotEquals('a', 'a'); },
- 'Expected not to be <a> (String)');
- assertThrowsJsUnitException(
- function() { assertNotEquals('a', 'a', 'a'); },
- 'a\nExpected not to be <a> (String)');
- }
-
- function testAssertNull() {
- assertNull(null);
- assertNull('Good assertion', null);
- assertThrowsJsUnitException(
- function() { assertNull(true); },
- 'Expected <null> but was <true> (Boolean)');
- assertThrowsJsUnitException(
- function() { assertNull('Should be null', false); },
- 'Should be null\nExpected <null> but was <false> (Boolean)');
- assertThrowsJsUnitException(
- function() { assertNull(undefined); },
- 'Expected <null> but was <undefined>');
- assertThrowsJsUnitException(
- function() { assertNull(1); },
- 'Expected <null> but was <1> (Number)');
- }
-
- function testAssertNotNull() {
- assertNotNull(true);
- assertNotNull('Good assertion', true);
- assertNotNull(false);
- assertNotNull(undefined);
- assertNotNull(1);
- assertNotNull('a');
- assertThrowsJsUnitException(
- function() { assertNotNull(null); },
- 'Expected not to be <null>');
- assertThrowsJsUnitException(
- function() { assertNotNull('Should not be null', null); },
- 'Should not be null\nExpected not to be <null>');
- }
-
- function testAssertUndefined() {
- assertUndefined(undefined);
- assertUndefined('Good assertion', undefined);
- assertThrowsJsUnitException(
- function() { assertUndefined(true); },
- 'Expected <undefined> but was <true> (Boolean)');
- assertThrowsJsUnitException(
- function() { assertUndefined('Should be undefined', false); },
- 'Should be undefined\nExpected <undefined> but was <false> (Boolean)');
- assertThrowsJsUnitException(
- function() { assertUndefined(null); },
- 'Expected <undefined> but was <null>');
- assertThrowsJsUnitException(
- function() { assertUndefined(1); },
- 'Expected <undefined> but was <1> (Number)');
- }
-
- function testAssertNotUndefined() {
- assertNotUndefined(true);
- assertNotUndefined('Good assertion', true);
- assertNotUndefined(false);
- assertNotUndefined(null);
- assertNotUndefined(1);
- assertNotUndefined('a');
- assertThrowsJsUnitException(
- function() { assertNotUndefined(undefined); },
- 'Expected not to be <undefined>');
- assertThrowsJsUnitException(
- function() { assertNotUndefined('Should not be undefined', undefined); },
- 'Should not be undefined\nExpected not to be <undefined>');
- }
-
- function testAssertNotNullNorUndefined() {
- assertNotNullNorUndefined(true);
- assertNotNullNorUndefined('Good assertion', true);
- assertNotNullNorUndefined(false);
- assertNotNullNorUndefined(1);
- assertNotNullNorUndefined(0);
- assertNotNullNorUndefined('a');
- assertThrowsJsUnitException(function() {
- assertNotNullNorUndefined(undefined);
- }, 'Expected not to be <undefined>');
- assertThrowsJsUnitException(function() {
- assertNotNullNorUndefined('Should not be undefined', undefined);
- }, 'Should not be undefined\nExpected not to be <undefined>');
- assertThrowsJsUnitException(function() {
- assertNotNullNorUndefined(null);
- }, 'Expected not to be <null>');
- assertThrowsJsUnitException(function() {
- assertNotNullNorUndefined('Should not be null', null);
- }, 'Should not be null\nExpected not to be <null>');
- }
-
- function testAssertNonEmptyString() {
- assertNonEmptyString('hello');
- assertNonEmptyString('Good assertion', 'hello');
- assertNonEmptyString('true');
- assertNonEmptyString('false');
- assertNonEmptyString('1');
- assertNonEmptyString('null');
- assertNonEmptyString('undefined');
- assertNonEmptyString('\n');
- assertNonEmptyString(' ');
- assertThrowsJsUnitException(
- function() { assertNonEmptyString(''); },
- 'Expected non-empty string but was <> (String)');
- assertThrowsJsUnitException(
- function() { assertNonEmptyString('Should be non-empty string', ''); },
- 'Should be non-empty string\n' +
- 'Expected non-empty string but was <> (String)');
- assertThrowsJsUnitException(
- function() { assertNonEmptyString(true); },
- 'Expected non-empty string but was <true> (Boolean)');
- assertThrowsJsUnitException(
- function() { assertNonEmptyString(false); },
- 'Expected non-empty string but was <false> (Boolean)');
- assertThrowsJsUnitException(
- function() { assertNonEmptyString(1); },
- 'Expected non-empty string but was <1> (Number)');
- assertThrowsJsUnitException(
- function() { assertNonEmptyString(null); },
- 'Expected non-empty string but was <null>');
- assertThrowsJsUnitException(
- function() { assertNonEmptyString(undefined); },
- 'Expected non-empty string but was <undefined>');
- assertThrowsJsUnitException(
- function() { assertNonEmptyString(['hello']); },
- 'Expected non-empty string but was <hello> (Array)');
- // Different browsers return different values/types in the failure message
- // so don't bother checking if the message is exactly as expected.
- assertThrowsJsUnitException(
- function() { assertNonEmptyString(goog.dom.createTextNode('hello')); });
- }
-
- function testAssertNaN() {
- assertNaN(NaN);
- assertNaN('Good assertion', NaN);
- assertThrowsJsUnitException(
- function() { assertNaN(1); }, 'Expected NaN');
- assertThrowsJsUnitException(
- function() { assertNaN('Should be NaN', 1); },
- 'Should be NaN\nExpected NaN');
- assertThrowsJsUnitException(
- function() { assertNaN(true); }, 'Expected NaN');
- assertThrowsJsUnitException(
- function() { assertNaN(false); }, 'Expected NaN');
- assertThrowsJsUnitException(
- function() { assertNaN(null); }, 'Expected NaN');
- assertThrowsJsUnitException(
- function() { assertNaN(''); }, 'Expected NaN');
-
- // TODO(user): These assertions fail. We should decide on the
- // semantics of assertNaN
- //assertThrowsJsUnitException(function() { assertNaN(undefined); },
- // 'Expected NaN');
- //assertThrowsJsUnitException(function() { assertNaN('a'); },
- // 'Expected NaN');
- }
-
- function testAssertNotNaN() {
- assertNotNaN(1);
- assertNotNaN('Good assertion', 1);
- assertNotNaN(true);
- assertNotNaN(false);
- assertNotNaN('');
- assertNotNaN(null);
-
- // TODO(user): These assertions fail. We should decide on the
- // semantics of assertNotNaN
- //assertNotNaN(undefined);
- //assertNotNaN('a');
-
- assertThrowsJsUnitException(
- function() { assertNotNaN(Number.NaN); },
- 'Expected not NaN');
- assertThrowsJsUnitException(
- function() { assertNotNaN('Should not be NaN', Number.NaN); },
- 'Should not be NaN\nExpected not NaN');
- }
-
- function testAssertObjectEquals() {
- var obj1 = [{'a': 'hello', 'b': 'world'}];
- var obj2 = [{'a': 'hello', 'c': 'dear', 'b' : 'world'}];
-
- // Check with obj1 and obj2 as first and second arguments respectively.
- assertThrows('Objects should not be equal', function() {
- assertObjectEquals(obj1, obj2);
- });
-
- // Check with obj1 and obj2 as second and first arguments respectively.
- assertThrows('Objects should not be equal', function() {
- assertObjectEquals(obj2, obj1);
- });
-
- // Test if equal objects are considered equal.
- var obj3 = [{'b': 'world', 'a': 'hello'}];
- assertObjectEquals(obj1, obj3);
- assertObjectEquals(obj3, obj1);
-
- // Test with a case where one of the members has an undefined value.
- var obj4 = [{'a': 'hello', 'b': undefined}];
- var obj5 = [{'a': 'hello'}];
-
- // Check with obj4 and obj5 as first and second arguments respectively.
- assertThrows('Objects should not be equal', function() {
- assertObjectEquals(obj4, obj5);
- });
-
- // Check with obj5 and obj4 as first and second arguments respectively.
- assertThrows('Objects should not be equal', function() {
- assertObjectEquals(obj5, obj4);
- });
- }
-
- function testAssertObjectNotEquals() {
- var obj1 = [{'a': 'hello', 'b': 'world'}];
- var obj2 = [{'a': 'hello', 'c': 'dear', 'b' : 'world'}];
-
- // Check with obj1 and obj2 as first and second arguments respectively.
- assertObjectNotEquals(obj1, obj2);
-
- // Check with obj1 and obj2 as second and first arguments respectively.
- assertObjectNotEquals(obj2, obj1);
-
- // Test if equal objects are considered equal.
- var obj3 = [{'b': 'world', 'a': 'hello'}];
- var error = assertThrows('Objects should be equal', function() {
- assertObjectNotEquals(obj1, obj3);
- });
- assertContains('Objects should not be equal', error.message);
- error = assertThrows('Objects should be equal', function() {
- assertObjectNotEquals(obj3, obj1);
- });
- assertContains('Objects should not be equal', error.message);
-
- // Test with a case where one of the members has an undefined value.
- var obj4 = [{'a': 'hello', 'b': undefined}];
- var obj5 = [{'a': 'hello'}];
-
- // Check with obj4 and obj5 as first and second arguments respectively.
- assertObjectNotEquals(obj4, obj5);
-
- // Check with obj5 and obj4 as first and second arguments respectively.
- assertObjectNotEquals(obj5, obj4);
- }
-
- function testAssertObjectEquals2() {
- // NOTE: (0 in [undefined]) is true on FF but false on IE.
- // (0 in {'0': undefined}) is true on both.
- // grrr.
- assertObjectEquals('arrays should be equal', [undefined], [undefined]);
- assertThrows('arrays should not be equal', function() {
- assertObjectEquals([undefined, undefined], [undefined]);
- });
- assertThrows('arrays should not be equal', function() {
- assertObjectEquals([undefined], [undefined, undefined]);
- });
- }
-
- function testAssertObjectEquals3() {
- // Check that objects that contain identical Map objects compare
- // as equals. We can't do a negative test because on browsers that
- // implement __iterator__ we can't check the values of the iterated
- // properties.
- var obj1 = [{'a': 'hi',
- 'b': new goog.structs.Map('hola', 'amigo',
- 'como', 'estas?')},
- 14,
- 'yes',
- true];
- var obj2 = [{'a': 'hi',
- 'b': new goog.structs.Map('hola', 'amigo',
- 'como', 'estas?')},
- 14,
- 'yes',
- true];
- assertObjectEquals('Objects should be equal', obj1, obj2);
-
- var obj3 = {'a': [1, 2]};
- var obj4 = {'a': [1, 2, 3]};
- assertThrows('inner arrays should not be equal', function() {
- assertObjectEquals(obj3, obj4);
- });
- assertThrows('inner arrays should not be equal', function() {
- assertObjectEquals(obj4, obj3);
- });
- }
-
- function testAssertObjectEqualsSet() {
- // verify that Sets compare equal, when run in an environment that
- // supports iterators
- var set1 = new goog.structs.Set();
- var set2 = new goog.structs.Set();
-
- set1.add('a');
- set1.add('b');
- set1.add(13);
-
- set2.add('a');
- set2.add('b');
- set2.add(13);
-
- assertObjectEquals('sets should be equal', set1, set2);
-
- set2.add('hey');
- assertThrows('sets should not be equal', function() {
- assertObjectEquals(set1, set2);
- });
- }
-
- function testAssertObjectEqualsIterNoEquals() {
- // an object with an iterator but no equals() and no map_ cannot
- // be compared
- function Thing() {
- this.what = [];
- }
- Thing.prototype.add = function(n, v) {
- this.what.push(n + '@' + v);
- };
- Thing.prototype.get = function(n) {
- var m = new RegExp('^' + n + '@(.*)$', '');
- for (var i = 0; i < this.what.length; ++i) {
- var match = this.what[i].match(m);
- if (match) {
- return match[1];
- }
- }
- return null;
- };
- Thing.prototype.__iterator__ = function() {
- var iter = new goog.iter.Iterator;
- iter.index = 0;
- iter.thing = this;
- iter.next = function() {
- if (this.index < this.thing.what.length) {
- return this.thing.what[this.index++].split('@')[0];
- } else {
- throw goog.iter.StopIteration;
- }
- };
- return iter;
- };
-
- var thing1 = new Thing(); thing1.name = 'thing1';
- var thing2 = new Thing(); thing2.name = 'thing2';
- thing1.add('red', 'fish');
- thing1.add('blue', 'fish');
-
- thing2.add('red', 'fish');
- thing2.add('blue', 'fish');
-
- assertThrows('things should not be equal', function() {
- assertObjectEquals(thing1, thing2);
- });
- }
-
- function testAssertObjectEqualsWithDates() {
- var date = new Date(2010, 0, 1);
- var dateWithMilliseconds = new Date(2010, 0, 1, 0, 0, 0, 1);
- assertObjectEquals(new Date(2010, 0, 1), date);
- assertThrows(goog.partial(assertObjectEquals, date, dateWithMilliseconds));
- }
-
- function testAssertObjectEqualsSparseArrays() {
- var arr1 = [,2,,4,,];
- var arr2 = [1,2,3,4,5];
-
- assertThrows('Sparse arrays should not be equal', function() {
- assertObjectEquals(arr1, arr2);
- });
-
- assertThrows('Sparse arrays should not be equal', function() {
- assertObjectEquals(arr2, arr1);
- });
- }
-
- function testAssertObjectEqualsSparseArrays2() {
- // On IE6-8, the expression "1 in [4,undefined]" evaluates to false,
- // but true on other browsers. FML. This test verifies a regression
- // where IE reported that arr4 was not equal to arr1 or arr2.
- var arr1 = [1,,3];
- var arr2 = [1,undefined,3];
- var arr3 = goog.array.clone(arr1);
- var arr4 = [];
- arr4.push(1, undefined, 3);
-
- // Assert that all those arrays are equivalent pairwise.
- var arrays = [arr1, arr2, arr3, arr4];
- for (var i = 0; i < arrays.length; i++) {
- for (var j = 0; j < arrays.length; j++) {
- assertArrayEquals(arrays[i], arrays[j]);
- }
- }
- }
-
- function testAssertObjectEqualsArraysWithExtraProps() {
- var arr1 = [1];
- var arr2 = [1];
- arr2.foo = 3;
-
- assertThrows('Aarrays should not be equal', function() {
- assertObjectEquals(arr1, arr2);
- });
-
- assertThrows('Arrays should not be equal', function() {
- assertObjectEquals(arr2, arr1);
- });
- }
-
- function testAssertSameElementsOnArray() {
- assertSameElements([1, 2], [2, 1]);
- assertSameElements('Good assertion', [1, 2], [2, 1]);
- assertSameElements('Good assertion with duplicates', [1, 1, 2], [2, 1, 1]);
- assertThrowsJsUnitException(
- function() {
- assertSameElements([1, 2], [1]);
- },
- 'Expected 2 elements: [1,2], got 1 elements: [1]');
- assertThrowsJsUnitException(
- function() {
- assertSameElements('Should match', [1, 2], [1]);
- },
- 'Should match\nExpected 2 elements: [1,2], got 1 elements: [1]');
- assertThrowsJsUnitException(
- function() {
- assertSameElements([1, 2], [1, 3]);
- },
- 'Expected [1,2], got [1,3]');
- assertThrowsJsUnitException(
- function() {
- assertSameElements('Should match', [1, 2], [1, 3]);
- },
- 'Should match\nExpected [1,2], got [1,3]');
- assertThrowsJsUnitException(
- function() {
- assertSameElements([1, 1, 2], [2, 2, 1]);
- },
- 'Expected [1,1,2], got [2,2,1]');
- }
-
- function testAssertSameElementsOnArrayLike() {
- assertSameElements({0: 0, 1: 1, length: 2}, {length: 2, 1: 1, 0: 0});
- assertThrowsJsUnitException(
- function() {
- assertSameElements({0: 0, 1: 1, length: 2}, {0: 0, length: 1});
- },
- 'Expected 2 elements: [0,1], got 1 elements: [0]');
- }
-
- function testAssertSameElementsWithBadArguments() {
- assertThrowsJsUnitException(
- function() {
- assertSameElements([], new goog.structs.Set());
- },
- 'Bad arguments to assertSameElements(opt_message, expected: ' +
- 'ArrayLike, actual: ArrayLike)\n' +
- 'Call to assertTrue(boolean) with false');
- }
-
- var implicitlyTrue = [
- true,
- 1,
- -1,
- ' ',
- 'string',
- Infinity,
- new Object()
- ];
-
- var implicitlyFalse = [
- false,
- 0,
- '',
- null,
- undefined,
- NaN
- ];
-
- function testAssertEvaluatesToTrue() {
- assertEvaluatesToTrue(true);
- assertEvaluatesToTrue('', true);
- assertEvaluatesToTrue('Good assertion', true);
- assertThrowsJsUnitException(
- function() { assertEvaluatesToTrue(false); },
- 'Expected to evaluate to true');
- assertThrowsJsUnitException(
- function() {assertEvaluatesToTrue('Should be true', false); },
- 'Should be true\nExpected to evaluate to true');
- for (var i = 0; i < implicitlyTrue.length; i++) {
- assertEvaluatesToTrue(String('Test ' + implicitlyTrue[i] +
- ' [' + i + ']'), implicitlyTrue[i]);
- }
- for (var i = 0; i < implicitlyFalse.length; i++) {
- assertThrowsJsUnitException(
- function() { assertEvaluatesToTrue(implicitlyFalse[i]); },
- 'Expected to evaluate to true');
- }
- }
-
- function testAssertEvaluatesToFalse() {
- assertEvaluatesToFalse(false);
- assertEvaluatesToFalse('Good assertion', false);
- assertThrowsJsUnitException(
- function() { assertEvaluatesToFalse(true); },
- 'Expected to evaluate to false');
- assertThrowsJsUnitException(
- function() { assertEvaluatesToFalse('Should be false', true); },
- 'Should be false\nExpected to evaluate to false');
- for (var i = 0; i < implicitlyFalse.length; i++) {
- assertEvaluatesToFalse(String('Test ' + implicitlyFalse[i] +
- ' [' + i + ']'), implicitlyFalse[i]);
- }
- for (var i = 0; i < implicitlyTrue.length; i++) {
- assertThrowsJsUnitException(
- function() { assertEvaluatesToFalse(implicitlyTrue[i]); },
- 'Expected to evaluate to false');
- }
- }
-
- function testAssertHTMLEquals() {
- // TODO
- }
-
- function testAssertHashEquals() {
- assertHashEquals({a: 1, b: 2}, {b: 2, a: 1});
- assertHashEquals('Good assertion', {a: 1, b: 2}, {b: 2, a: 1});
- assertHashEquals({a: undefined}, {a: undefined});
- // Missing key.
- assertThrowsJsUnitException(
- function() { assertHashEquals({a: 1, b: 2}, {a: 1}); },
- 'Expected hash had key b that was not found');
- assertThrowsJsUnitException(
- function() { assertHashEquals('Should match', {a: 1, b: 2}, {a: 1}); },
- 'Should match\nExpected hash had key b that was not found');
- assertThrowsJsUnitException(
- function() { assertHashEquals({a: undefined}, {}); },
- 'Expected hash had key a that was not found');
- // Not equal key.
- assertThrowsJsUnitException(
- function() { assertHashEquals({a: 1}, {a: 5}); },
- 'Value for key a mismatch - expected = 1, actual = 5');
- assertThrowsJsUnitException(
- function() { assertHashEquals('Should match', {a: 1}, {a: 5}); },
- 'Should match\nValue for key a mismatch - expected = 1, actual = 5');
- assertThrowsJsUnitException(
- function() { assertHashEquals({a: undefined}, {a: 1})},
- 'Value for key a mismatch - expected = undefined, actual = 1');
- // Extra key.
- assertThrowsJsUnitException(
- function() { assertHashEquals({a: 1}, {a: 1, b: 1}); },
- 'Actual hash had key b that was not expected');
- assertThrowsJsUnitException(
- function() { assertHashEquals('Should match', {a: 1}, {a: 1, b: 1}); },
- 'Should match\nActual hash had key b that was not expected');
- }
-
- function testAssertRoughlyEquals() {
- assertRoughlyEquals(1, 1, 0);
- assertRoughlyEquals('Good assertion', 1, 1, 0);
- assertRoughlyEquals(1, 1.1, 0.11);
- assertRoughlyEquals(1.1, 1, 0.11);
- assertThrowsJsUnitException(
- function() { assertRoughlyEquals(1, 1.1, 0.05); },
- 'Expected 1, but got 1.1 which was more than 0.05 away');
- assertThrowsJsUnitException(
- function() { assertRoughlyEquals('Close enough', 1, 1.1, 0.05); },
- 'Close enough\nExpected 1, but got 1.1 which was more than 0.05 away');
- }
-
- function testAssertContains() {
- var a = [1, 2, 3];
- assertContains(1, [1, 2, 3]);
- assertContains('Should contain', 1, [1, 2, 3]);
- assertThrowsJsUnitException(
- function() { assertContains(4, [1, 2, 3]); },
- 'Expected \'1,2,3\' to contain \'4\'');
- assertThrowsJsUnitException(
- function() { assertContains('Should contain', 4, [1, 2, 3]); },
- 'Should contain\nExpected \'1,2,3\' to contain \'4\'');
- // assertContains uses ===.
- var o = new Object();
- assertContains(o, [o, 2, 3]);
- assertThrowsJsUnitException(
- function() { assertContains(o, [1, 2, 3]); },
- 'Expected \'1,2,3\' to contain \'[object Object]\'');
- }
-
- function testAssertNotContains() {
- var a = [1, 2, 3];
- assertNotContains(4, [1, 2, 3]);
- assertNotContains('Should not contain', 4, [1, 2, 3]);
- assertThrowsJsUnitException(
- function() { assertNotContains(1, [1, 2, 3]); },
- 'Expected \'1,2,3\' not to contain \'1\'');
- assertThrowsJsUnitException(
- function() { assertNotContains('Should not contain', 1, [1, 2, 3]); },
- "Should not contain\nExpected '1,2,3' not to contain '1'");
- // assertNotContains uses ===.
- var o = new Object();
- assertNotContains({}, [o, 2, 3]);
- assertThrowsJsUnitException(
- function() { assertNotContains(o, [o, 2, 3]); },
- 'Expected \'[object Object],2,3\' not to contain \'[object Object]\'');
- }
-
- function testAssertThrows() {
- var failed = false;
- try {
- assertThrows('assertThrows should not pass with null param', null);
- failed = true;
- } catch (e) {
- }
- assertFalse('Fail should not get set to true', failed);
-
- try {
- assertThrows(
- 'assertThrows should not pass with undefined param',
- undefined);
- failed = true;
- } catch (e) {
- }
- assertFalse('Fail should not get set to true', failed);
-
- try {
- assertThrows('assertThrows should not pass with number param', 1);
- failed = true;
- } catch (e) {
- }
- assertFalse('Fail should not get set to true', failed);
-
- try {
- assertThrows('assertThrows should not pass with string param', 'string');
- failed = true;
- } catch (e) {
- }
- assertFalse('Fail should not get set to true', failed);
-
- try {
- assertThrows('assertThrows should not pass with object param', {});
- failed = true;
- } catch (e) {
- }
- assertFalse('Fail should not get set to true', failed);
-
- try {
- var error = assertThrows('valid function throws Error', function() {
- throw new Error('test');
- });
- } catch (e) {
- fail('assertThrows incorrectly doesn\'t detect a thrown exception');
- }
- assertEquals('error message', 'test', error.message);
-
- try {
- var stringError = assertThrows('valid function throws string error',
- function() {
- throw 'string error test';
- });
- } catch (e) {
- fail('assertThrows doesn\'t detect a thrown string exception');
- }
- assertEquals('string error', 'string error test', stringError);
- }
-
- function testAssertNotThrows() {
- var failed = false;
- try {
- assertNotThrows('assertNotThrows should not pass with null param', null);
- failed = true;
- } catch (e) {
- }
- assertFalse('Fail should not get set to true', failed);
-
- try {
- assertNotThrows(
- 'assertNotThrows should not pass with undefined param', undefined);
- failed = true;
- } catch (e) {
- }
- assertFalse('Fail should not get set to true', failed);
-
- try {
- assertNotThrows('assertNotThrows should not pass with number param', 1);
- failed = true;
- } catch (e) {
- }
- assertFalse('Fail should not get set to true', failed);
-
- try {
- assertNotThrows('assertNotThrows should not pass with string param',
- 'string');
- failed = true;
- } catch (e) {
- }
- assertFalse('Fail should not get set to true', failed);
-
-
- try {
- assertNotThrows('assertNotThrows should not pass with object param', {});
- failed = true;
- } catch (e) {
- }
- assertFalse('Fail should not get set to true', failed);
-
-
- try {
- assertNotThrows('valid function',
- function() {
- //do nothing;
- });
- } catch (e) {
- // Shouldn't be here: throw exception.
- fail('assertNotThrows returned failure on a valid function');
- }
-
- var errorDescription = 'a test error exception';
- try {
- throw new Error(errorDescription);
- assertNotThrows('non valid error throwing function',
- function() {
- throw new Error(errorDescription);
- });
- failed = true;
- } catch (e) {
- // Some browsers don't have a stack trace so expect to at least have the
- // error description.
- assertContains(errorDescription, e.message);
- }
- assertFalse('assertNotThrows did not fail on a thrown exception', failed);
- }
-
- function testAssertArrayEquals() {
- var a1 = [0, 1, 2];
- var a2 = [0, 1, 2];
- assertArrayEquals('Arrays should be equal', a1, a2);
-
- assertThrows('Should have thrown because args are not arrays', function() {
- var b1 = true;
- var b2 = true;
- assertArrayEquals(b1, b2);
- });
- }
-
- function testAssertObjectsEqualsDifferentArrays() {
- assertThrows('Should have thrown because args are different', function() {
- var a1 = ['className1'];
- var a2 = ['className2'];
- assertArrayEquals(a1, a2);
- assertObjectEquals(a1, a2);
- });
- }
-
- function testAssertObjectsEqualsDifferentTypeSameToString() {
- assertThrows('Should have thrown because args are different', function() {
- var a1 = 'className1';
- var a2 = ['className1'];
- assertObjectEquals(a1, a2);
- });
-
- assertThrows('Should have thrown because args are different', function() {
- var a1 = ['className1'];
- var a2 = {'0': 'className1'};
- assertObjectEquals(a1, a2);
- });
-
- assertThrows('Should have thrown because args are different', function() {
- var a1 = ['className1'];
- var a2 = [['className1']];
- assertObjectEquals(a1, a2);
- });
- }
-
- function testFindDifferences_equal() {
- assertNull(goog.testing.asserts.findDifferences(true, true));
- assertNull(goog.testing.asserts.findDifferences(null, null));
- assertNull(goog.testing.asserts.findDifferences(undefined, undefined));
- assertNull(goog.testing.asserts.findDifferences(1, 1));
- assertNull(goog.testing.asserts.findDifferences([1, 'a'], [1, 'a']));
- assertNull(goog.testing.asserts.findDifferences(
- [[1, 2], [3, 4]], [[1, 2], [3, 4]]));
- assertNull(goog.testing.asserts.findDifferences(
- [{a: 1, b: 2}], [{b: 2, a: 1}]));
- assertNull(goog.testing.asserts.findDifferences(null, null));
- assertNull(goog.testing.asserts.findDifferences(undefined, undefined));
- }
-
- function testFindDifferences_unequal() {
- assertNotNull(goog.testing.asserts.findDifferences(true, false));
- assertNotNull(goog.testing.asserts.findDifferences(
- [{a: 1, b: 2}], [{a: 2, b: 1}]));
- assertNotNull(goog.testing.asserts.findDifferences(
- [{a: 1}], [{a: 1, b: [2]}]));
- assertNotNull(goog.testing.asserts.findDifferences(
- [{a: 1, b: [2]}], [{a: 1}]));
- }
-
- function testFindDifferences_objectsAndNull() {
- assertNotNull(goog.testing.asserts.findDifferences({a: 1}, null));
- assertNotNull(goog.testing.asserts.findDifferences(null, {a: 1}));
- assertNotNull(goog.testing.asserts.findDifferences(null, []));
- assertNotNull(goog.testing.asserts.findDifferences([], null));
- assertNotNull(goog.testing.asserts.findDifferences([], undefined));
- }
-
- function testFindDifferences_basicCycle() {
- var a = {};
- var b = {};
- a.self = a;
- b.self = b;
- assertNull(goog.testing.asserts.findDifferences(a, b));
-
- a.unique = 1;
- assertNotNull(goog.testing.asserts.findDifferences(a, b));
- }
-
- function testFindDifferences_crossedCycle() {
- var a = {};
- var b = {};
- a.self = b;
- b.self = a;
- assertNull(goog.testing.asserts.findDifferences(a, b));
-
- a.unique = 1;
- assertNotNull(goog.testing.asserts.findDifferences(a, b));
- }
-
- function testFindDifferences_asymmetricCycle() {
- var a = {};
- var b = {};
- var c = {};
- var d = {};
- var e = {};
- a.self = b;
- b.self = a;
- c.self = d;
- d.self = e;
- e.self = c;
- assertNotNull(goog.testing.asserts.findDifferences(a, c));
- }
-
- function testFindDifferences_basicCycleArray() {
- var a = [];
- var b = [];
- a[0] = a;
- b[0] = b;
- assertNull(goog.testing.asserts.findDifferences(a, b));
-
- a[1] = 1;
- assertNotNull(goog.testing.asserts.findDifferences(a, b));
- }
-
- function testFindDifferences_crossedCycleArray() {
- var a = [];
- var b = [];
- a[0] = b;
- b[0] = a;
- assertNull(goog.testing.asserts.findDifferences(a, b));
-
- a[1] = 1;
- assertNotNull(goog.testing.asserts.findDifferences(a, b));
- }
-
- function testFindDifferences_asymmetricCycleArray() {
- var a = [];
- var b = [];
- var c = [];
- var d = [];
- var e = [];
- a[0] = b;
- b[0] = a;
- c[0] = d;
- d[0] = e;
- e[0] = c;
- assertNotNull(goog.testing.asserts.findDifferences(a, c));
- }
-
- function testFindDifferences_binaryTree() {
- function createBinTree(depth, root) {
- if (depth == 0) {
- return {root: root};
- } else {
- var node = {};
- node.left = createBinTree(depth-1, root || node);
- node.right = createBinTree(depth-1, root || node);
- return node;
- }
- }
-
- // TODO(gboyer,user): This test does not terminate with the current
- // algorithm. Can be enabled when (if) the algorithm is improved.
- //assertNull(goog.testing.asserts.findDifferences(
- // createBinTree(5, null), createBinTree(5, null)));
- assertNotNull(goog.testing.asserts.findDifferences(
- createBinTree(4, null), createBinTree(5, null)));
- }
-
- function testStringForWindowIE() {
- if (goog.userAgent.IE && !goog.userAgent.isVersion('8')) {
- // NOTE(user): This test sees of we are being affected by a JScript bug
- // in try/finally handling. This bug only affects the lowest try/finally
- // block in the stack. Calling this function via VBScript allows
- // us to run the test synchronously in an empty JS stack.
- window.execScript('stringForWindowIEHelper()', 'vbscript');
- assertEquals('<[object]> (Object)', window.stringForWindowIEResult);
- }
- }
-
- function testAssertElementsEquals() {
- assertElementsEquals([1, 2], [1, 2]);
- assertElementsEquals([1, 2], {0: 1, 1: 2, length: 2});
- assertElementsEquals('Good assertion', [1, 2], [1, 2]);
- assertThrowsJsUnitException(
- function() {
- assertElementsEquals('Message', [1, 2], [1]);
- },
- 'length mismatch: Message\n' +
- 'Expected <2> (Number) but was <1> (Number)');
- }
-
- function stringForWindowIEHelper() {
- window.stringForWindowIEResult = _displayStringForValue(window);
- }
-
-</script>
-</body>
-</html>
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/asynctestcase.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/asynctestcase.js.svn-base
deleted file mode 100644
index 3c4cfd9..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/asynctestcase.js.svn-base
+++ /dev/null
@@ -1,820 +0,0 @@
-// Copyright 2010 The Closure Library Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS-IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-// All Rights Reserved.
-
-/**
- * @fileoverview A class representing a set of test functions that use
- * asynchronous functions that cannot be meaningfully mocked.
- *
- * To create a Google-compatable JsUnit test using this test case, put the
- * following snippet in your test:
- *
- * var asyncTestCase = goog.testing.AsyncTestCase.createAndInstall();
- *
- * To make the test runner wait for your asynchronous behaviour, use:
- *
- * asyncTestCase.waitForAsync('Waiting for xhr to respond');
- *
- * The next test will not start until the following call is made, or a
- * timeout occurs:
- *
- * asyncTestCase.continueTesting();
- *
- * There does NOT need to be a 1:1 mapping of waitForAsync calls and
- * continueTesting calls. The next test will be run after a single call to
- * continueTesting is made, as long as there is no subsequent call to
- * waitForAsync in the same thread.
- *
- * Example:
- * // Returning here would cause the next test to be run.
- * asyncTestCase.waitForAsync('description 1');
- * // Returning here would *not* cause the next test to be run.
- * // Only effect of additional waitForAsync() calls is an updated
- * // description in the case of a timeout.
- * asyncTestCase.waitForAsync('updated description');
- * asyncTestCase.continueTesting();
- * // Returning here would cause the next test to be run.
- * asyncTestCase.waitForAsync('just kidding, still running.');
- * // Returning here would *not* cause the next test to be run.
- *
- * This class supports asynchronous behaviour in all test functions except for
- * tearDownPage. If such support is needed, it can be added.
- *
- * Example Usage:
- *
- * var asyncTestCase = goog.testing.AsyncTestCase.createAndInstall();
- * // Optionally, set a longer-than-normal step timeout.
- * asyncTestCase.stepTimeout = 30 * 1000;
- *
- * function testSetTimeout() {
- * var step = 0;
- * function stepCallback() {
- * step++;
- * switch (step) {
- * case 1:
- * var startTime = goog.now();
- * asyncTestCase.waitForAsync('step 1');
- * window.setTimeout(stepCallback, 100);
- * break;
- * case 2:
- * assertTrue('Timeout fired too soon',
- * goog.now() - startTime >= 100);
- * asyncTestCase.waitForAsync('step 2');
- * window.setTimeout(stepCallback, 100);
- * break;
- * case 3:
- * assertTrue('Timeout fired too soon',
- * goog.now() - startTime >= 200);
- * asyncTestCase.continueTesting();
- * break;
- * default:
- * fail('Unexpected call to stepCallback');
- * }
- * }
- * stepCallback();
- * }
- *
- * Known Issues:
- * IE7 Exceptions:
- * As the failingtest.html will show, it appears as though ie7 does not
- * propagate an exception past a function called using the func.call()
- * syntax. This causes case 3 of the failing tests (exceptions) to show up
- * as timeouts in IE.
- * window.onerror:
- * This seems to catch errors only in ff2/ff3. It does not work in Safari or
- * IE7. The consequence of this is that exceptions that would have been
- * caught by window.onerror show up as timeouts.
- *
- * @author agrieve@google.com (Andrew Grieve)
- */
-
-goog.provide('goog.testing.AsyncTestCase');
-goog.provide('goog.testing.AsyncTestCase.ControlBreakingException');
-
-goog.require('goog.testing.TestCase');
-goog.require('goog.testing.TestCase.Test');
-goog.require('goog.testing.asserts');
-
-
-
-/**
- * A test case that is capable of running tests the contain asynchronous logic.
- * @param {string=} opt_name A descriptive name for the test case.
- * @extends {goog.testing.TestCase}
- * @constructor
- */
-goog.testing.AsyncTestCase = function(opt_name) {
- goog.testing.TestCase.call(this, opt_name);
-};
-goog.inherits(goog.testing.AsyncTestCase, goog.testing.TestCase);
-
-
-/**
- * Represents result of top stack function call.
- * @typedef {{controlBreakingExceptionThrown: boolean, message: string}}
- * @private
- */
-goog.testing.AsyncTestCase.TopStackFuncResult_;
-
-
-
-/**
- * An exception class used solely for control flow.
- * @param {string=} opt_message Error message.
- * @constructor
- */
-goog.testing.AsyncTestCase.ControlBreakingException = function(opt_message) {
- /**
- * The exception message.
- * @type {string}
- */
- this.message = opt_message || '';
-};
-
-
-/**
- * Return value for .toString().
- * @type {string}
- */
-goog.testing.AsyncTestCase.ControlBreakingException.TO_STRING =
- '[AsyncTestCase.ControlBreakingException]';
-
-
-/**
- * Marks this object as a ControlBreakingException
- * @type {boolean}
- */
-goog.testing.AsyncTestCase.ControlBreakingException.prototype.
- isControlBreakingException = true;
-
-
-/** @override */
-goog.testing.AsyncTestCase.ControlBreakingException.prototype.toString =
- function() {
- // This shows up in the console when the exception is not caught.
- return goog.testing.AsyncTestCase.ControlBreakingException.TO_STRING;
-};
-
-
-/**
- * How long to wait for a single step of a test to complete in milliseconds.
- * A step starts when a call to waitForAsync() is made.
- * @type {number}
- */
-goog.testing.AsyncTestCase.prototype.stepTimeout = 1000;
-
-
-/**
- * How long to wait after a failed test before moving onto the next one.
- * The purpose of this is to allow any pending async callbacks from the failing
- * test to finish up and not cause the next test to fail.
- * @type {number}
- */
-goog.testing.AsyncTestCase.prototype.timeToSleepAfterFailure = 500;
-
-
-/**
- * Turn on extra logging to help debug failing async. tests.
- * @type {boolean}
- * @private
- */
-goog.testing.AsyncTestCase.prototype.enableDebugLogs_ = false;
-
-
-/**
- * A reference to the original asserts.js assert_() function.
- * @private
- */
-goog.testing.AsyncTestCase.prototype.origAssert_;
-
-
-/**
- * A reference to the original asserts.js fail() function.
- * @private
- */
-goog.testing.AsyncTestCase.prototype.origFail_;
-
-
-/**
- * A reference to the original window.onerror function.
- * @type {Function|undefined}
- * @private
- */
-goog.testing.AsyncTestCase.prototype.origOnError_;
-
-
-/**
- * The stage of the test we are currently on.
- * @type {Function|undefined}}
- * @private
- */
-goog.testing.AsyncTestCase.prototype.curStepFunc_;
-
-
-/**
- * The name of the stage of the test we are currently on.
- * @type {string}
- * @private
- */
-goog.testing.AsyncTestCase.prototype.curStepName_ = '';
-
-
-/**
- * The stage of the test we should run next.
- * @type {Function|undefined}
- * @private
- */
-goog.testing.AsyncTestCase.prototype.nextStepFunc;
-
-
-/**
- * The name of the stage of the test we should run next.
- * @type {string}
- * @private
- */
-goog.testing.AsyncTestCase.prototype.nextStepName_ = '';
-
-
-/**
- * The handle to the current setTimeout timer.
- * @type {number|undefined}
- * @private
- */
-goog.testing.AsyncTestCase.prototype.timeoutHandle_;
-
-
-/**
- * Marks if the cleanUp() function has been called for the currently running
- * test.
- * @type {boolean}
- * @private
- */
-goog.testing.AsyncTestCase.prototype.cleanedUp_ = false;
-
-
-/**
- * The currently active test.
- * @type {goog.testing.TestCase.Test|undefined}
- * @protected
- */
-goog.testing.AsyncTestCase.prototype.activeTest;
-
-
-/**
- * A flag to prevent recursive exception handling.
- * @type {boolean}
- * @private
- */
-goog.testing.AsyncTestCase.prototype.inException_ = false;
-
-
-/**
- * Flag used to determine if we can move to the next step in the testing loop.
- * @type {boolean}
- * @private
- */
-goog.testing.AsyncTestCase.prototype.isReady_ = true;
-
-
-/**
- * Flag that tells us if there is a function in the call stack that will make
- * a call to pump_().
- * @type {boolean}
- * @private
- */
-goog.testing.AsyncTestCase.prototype.returnWillPump_ = false;
-
-
-/**
- * The number of times we have thrown a ControlBreakingException so that we
- * know not to complain in our window.onerror handler. In Webkit, window.onerror
- * is not supported, and so this counter will keep going up but we won't care
- * about it.
- * @type {number}
- * @private
- */
-goog.testing.AsyncTestCase.prototype.numControlExceptionsExpected_ = 0;
-
-
-/**
- * Preferred way of creating an AsyncTestCase. Creates one and initializes it
- * with the G_testRunner.
- * @param {string=} opt_name A descriptive name for the test case.
- * @return {goog.testing.AsyncTestCase} The created AsyncTestCase.
- */
-goog.testing.AsyncTestCase.createAndInstall = function(opt_name) {
- var asyncTestCase = new goog.testing.AsyncTestCase(opt_name);
- goog.testing.TestCase.initializeTestRunner(asyncTestCase);
- return asyncTestCase;
-};
-
-
-/**
- * Informs the testcase not to continue to the next step in the test cycle
- * until continueTesting is called.
- * @param {string=} opt_name A description of what we are waiting for.
- */
-goog.testing.AsyncTestCase.prototype.waitForAsync = function(opt_name) {
- this.isReady_ = false;
- this.curStepName_ = opt_name || this.curStepName_;
-
- // Reset the timer that tracks if the async test takes too long.
- this.stopTimeoutTimer_();
- this.startTimeoutTimer_();
-};
-
-
-/**
- * Continue with the next step in the test cycle.
- */
-goog.testing.AsyncTestCase.prototype.continueTesting = function() {
- if (!this.isReady_) {
- // We are a potential entry point, so we pump.
- this.isReady_ = true;
- this.stopTimeoutTimer_();
- // Run this in a setTimeout so that the caller has a chance to call
- // waitForAsync() again before we continue.
- this.timeout(goog.bind(this.pump_, this, null), 0);
- }
-};
-
-
-/**
- * Handles an exception thrown by a test.
- * @param {*=} opt_e The exception object associated with the failure
- * or a string.
- * @throws Always throws a ControlBreakingException.
- */
-goog.testing.AsyncTestCase.prototype.doAsyncError = function(opt_e) {
- // If we've caught an exception that we threw, then just pass it along. This
- // can happen if doAsyncError() was called from a call to assert and then
- // again by pump_().
- if (opt_e && opt_e.isControlBreakingException) {
- throw opt_e;
- }
-
- // Prevent another timeout error from triggering for this test step.
- this.stopTimeoutTimer_();
-
- // doError() uses test.name. Here, we create a dummy test and give it a more
- // helpful name based on the step we're currently on.
- var fakeTestObj = new goog.testing.TestCase.Test(this.curStepName_,
- goog.nullFunction);
- if (this.activeTest) {
- fakeTestObj.name = this.activeTest.name + ' [' + fakeTestObj.name + ']';
- }
-
- // Note: if the test has an error, and then tearDown has an error, they will
- // both be reported.
- this.doError(fakeTestObj, opt_e);
-
- // This is a potential entry point, so we pump. We also add in a bit of a
- // delay to try and prevent any async behavior from the failed test from
- // causing the next test to fail.
- this.timeout(goog.bind(this.pump_, this, this.doAsyncErrorTearDown_),
- this.timeToSleepAfterFailure);
-
- // We just caught an exception, so we do not want the code above us on the
- // stack to continue executing. If pump_ is in our call-stack, then it will
- // batch together multiple errors, so we only increment the count if pump_ is
- // not in the stack and let pump_ increment the count when it batches them.
- if (!this.returnWillPump_) {
- this.numControlExceptionsExpected_ += 1;
- this.dbgLog_('doAsynError: numControlExceptionsExpected_ = ' +
- this.numControlExceptionsExpected_ + ' and throwing exception.');
- }
-
- // Copy the error message to ControlBreakingException.
- var message = '';
- if (typeof opt_e == 'string') {
- message = opt_e;
- } else if (opt_e && opt_e.message) {
- message = opt_e.message;
- }
- throw new goog.testing.AsyncTestCase.ControlBreakingException(message);
-};
-
-
-/**
- * Sets up the test page and then waits until the test case has been marked
- * as ready before executing the tests.
- * @override
- */
-goog.testing.AsyncTestCase.prototype.runTests = function() {
- this.hookAssert_();
- this.hookOnError_();
-
- this.setNextStep_(this.doSetUpPage_, 'setUpPage');
- // We are an entry point, so we pump.
- this.pump_();
-};
-
-
-/**
- * Starts the tests.
- * @override
- */
-goog.testing.AsyncTestCase.prototype.cycleTests = function() {
- // We are an entry point, so we pump.
- this.saveMessage('Start');
- this.setNextStep_(this.doIteration_, 'doIteration');
- this.pump_();
-};
-
-
-/**
- * Finalizes the test case, called when the tests have finished executing.
- * @override
- */
-goog.testing.AsyncTestCase.prototype.finalize = function() {
- this.unhookAll_();
- this.setNextStep_(null, 'finalized');
- goog.testing.AsyncTestCase.superClass_.finalize.call(this);
-};
-
-
-/**
- * Enables verbose logging of what is happening inside of the AsyncTestCase.
- */
-goog.testing.AsyncTestCase.prototype.enableDebugLogging = function() {
- this.enableDebugLogs_ = true;
-};
-
-
-/**
- * Logs the given debug message to the console (when enabled).
- * @param {string} message The message to log.
- * @private
- */
-goog.testing.AsyncTestCase.prototype.dbgLog_ = function(message) {
- if (this.enableDebugLogs_) {
- this.log('AsyncTestCase - ' + message);
- }
-};
-
-
-/**
- * Wraps doAsyncError() for when we are sure that the test runner has no user
- * code above it in the stack.
- * @param {string|Error=} opt_e The exception object associated with the
- * failure or a string.
- * @private
- */
-goog.testing.AsyncTestCase.prototype.doTopOfStackAsyncError_ =
- function(opt_e) {
- /** @preserveTry */
- try {
- this.doAsyncError(opt_e);
- } catch (e) {
- // We know that we are on the top of the stack, so there is no need to
- // throw this exception in this case.
- if (e.isControlBreakingException) {
- this.numControlExceptionsExpected_ -= 1;
- this.dbgLog_('doTopOfStackAsyncError_: numControlExceptionsExpected_ = ' +
- this.numControlExceptionsExpected_ + ' and catching exception.');
- } else {
- throw e;
- }
- }
-};
-
-
-/**
- * Calls the tearDown function, catching any errors, and then moves on to
- * the next step in the testing cycle.
- * @private
- */
-goog.testing.AsyncTestCase.prototype.doAsyncErrorTearDown_ = function() {
- if (this.inException_) {
- // We get here if tearDown is throwing the error.
- // Upon calling continueTesting, the inline function 'doAsyncError' (set
- // below) is run.
- this.continueTesting();
- } else {
- this.inException_ = true;
- this.isReady_ = true;
-
- // The continue point is different depending on if the error happened in
- // setUpPage() or in setUp()/test*()/tearDown().
- var stepFuncAfterError = this.nextStepFunc_;
- var stepNameAfterError = 'TestCase.execute (after error)';
- if (this.activeTest) {
- stepFuncAfterError = this.doIteration_;
- stepNameAfterError = 'doIteration (after error)';
- }
-
- // We must set the next step before calling tearDown.
- this.setNextStep_(function() {
- this.inException_ = false;
- // This is null when an error happens in setUpPage.
- this.setNextStep_(stepFuncAfterError, stepNameAfterError);
- }, 'doAsyncError');
-
- // Call the test's tearDown().
- if (!this.cleanedUp_) {
- this.cleanedUp_ = true;
- this.tearDown();
- }
- }
-};
-
-
-/**
- * Replaces the asserts.js assert_() and fail() functions with a wrappers to
- * catch the exceptions.
- * @private
- */
-goog.testing.AsyncTestCase.prototype.hookAssert_ = function() {
- if (!this.origAssert_) {
- this.origAssert_ = _assert;
- this.origFail_ = fail;
- var self = this;
- _assert = function() {
- /** @preserveTry */
- try {
- self.origAssert_.apply(this, arguments);
- } catch (e) {
- self.dbgLog_('Wrapping failed assert()');
- self.doAsyncError(e);
- }
- };
- fail = function() {
- /** @preserveTry */
- try {
- self.origFail_.apply(this, arguments);
- } catch (e) {
- self.dbgLog_('Wrapping fail()');
- self.doAsyncError(e);
- }
- };
- }
-};
-
-
-/**
- * Sets a window.onerror handler for catching exceptions that happen in async
- * callbacks. Note that as of Safari 3.1, Safari does not support this.
- * @private
- */
-goog.testing.AsyncTestCase.prototype.hookOnError_ = function() {
- if (!this.origOnError_) {
- this.origOnError_ = window.onerror;
- var self = this;
- window.onerror = function(error, url, line) {
- // Ignore exceptions that we threw on purpose.
- var cbe =
- goog.testing.AsyncTestCase.ControlBreakingException.TO_STRING;
- if (String(error).indexOf(cbe) != -1 &&
- self.numControlExceptionsExpected_) {
- self.numControlExceptionsExpected_ -= 1;
- self.dbgLog_('window.onerror: numControlExceptionsExpected_ = ' +
- self.numControlExceptionsExpected_ + ' and ignoring exception. ' +
- error);
- // Tell the browser not to compain about the error.
- return true;
- } else {
- self.dbgLog_('window.onerror caught exception.');
- var message = error + '\nURL: ' + url + '\nLine: ' + line;
- self.doTopOfStackAsyncError_(message);
- // Tell the browser to complain about the error.
- return false;
- }
- };
- }
-};
-
-
-/**
- * Unhooks window.onerror and _assert.
- * @private
- */
-goog.testing.AsyncTestCase.prototype.unhookAll_ = function() {
- if (this.origOnError_) {
- window.onerror = this.origOnError_;
- this.origOnError_ = null;
- _assert = this.origAssert_;
- this.origAssert_ = null;
- fail = this.origFail_;
- this.origFail_ = null;
- }
-};
-
-
-/**
- * Enables the timeout timer. This timer fires unless continueTesting is
- * called.
- * @private
- */
-goog.testing.AsyncTestCase.prototype.startTimeoutTimer_ = function() {
- if (!this.timeoutHandle_ && this.stepTimeout > 0) {
- this.timeoutHandle_ = this.timeout(goog.bind(function() {
- this.dbgLog_('Timeout timer fired with id ' + this.timeoutHandle_);
- this.timeoutHandle_ = null;
-
- this.doTopOfStackAsyncError_('Timed out while waiting for ' +
- 'continueTesting() to be called.');
- }, this, null), this.stepTimeout);
- this.dbgLog_('Started timeout timer with id ' + this.timeoutHandle_);
- }
-};
-
-
-/**
- * Disables the timeout timer.
- * @private
- */
-goog.testing.AsyncTestCase.prototype.stopTimeoutTimer_ = function() {
- if (this.timeoutHandle_) {
- this.dbgLog_('Clearing timeout timer with id ' + this.timeoutHandle_);
- window.clearTimeout(this.timeoutHandle_);
- this.timeoutHandle_ = 0;
- }
-};
-
-
-/**
- * Sets the next function to call in our sequence of async callbacks.
- * @param {Function} func The function that executes the next step.
- * @param {string} name A description of the next step.
- * @private
- */
-goog.testing.AsyncTestCase.prototype.setNextStep_ = function(func, name) {
- this.nextStepFunc_ = func && goog.bind(func, this);
- this.nextStepName_ = name;
-};
-
-
-/**
- * Calls the given function, redirecting any exceptions to doAsyncError.
- * @param {Function} func The function to call.
- * @return {!goog.testing.AsyncTestCase.TopStackFuncResult_} Returns a
- * TopStackFuncResult_.
- * @private
- */
-goog.testing.AsyncTestCase.prototype.callTopOfStackFunc_ = function(func) {
- /** @preserveTry */
- try {
- func.call(this);
- return {controlBreakingExceptionThrown: false, message: ''};
- } catch (e) {
- this.dbgLog_('Caught exception in callTopOfStackFunc_');
- /** @preserveTry */
- try {
- this.doAsyncError(e);
- return {controlBreakingExceptionThrown: false, message: ''};
- } catch (e2) {
- if (!e2.isControlBreakingException) {
- throw e2;
- }
- return {controlBreakingExceptionThrown: true, message: e2.message};
- }
- }
-};
-
-
-/**
- * Calls the next callback when the isReady_ flag is true.
- * @param {Function=} opt_doFirst A function to call before pumping.
- * @private
- * @throws Throws a ControlBreakingException if there were any failing steps.
- */
-goog.testing.AsyncTestCase.prototype.pump_ = function(opt_doFirst) {
- // If this function is already above us in the call-stack, then we should
- // return rather than pumping in order to minimize call-stack depth.
- if (!this.returnWillPump_) {
- this.setBatchTime(this.now_());
- this.returnWillPump_ = true;
- // If we catch an exception in the step, we don't want to return control
- // to our caller since there may be non-testcase code in our call stack.
- // Eg)
- // asyncCallback() { fail(1); fail(2); }
- // V
- // - ...
- // - pump_();
- // We don't want fail(2) to ever be called.
- var topFuncResult = {};
-
- if (opt_doFirst) {
- topFuncResult = this.callTopOfStackFunc_(opt_doFirst);
- }
- // Note: we don't check for this.running here because it is not set to true
- // while executing setUpPage and tearDownPage.
- // Also, if isReady_ is false, then one of two things will happen:
- // 1. Our timeout callback will be called.
- // 2. The tests will call continueTesting(), which will call pump_() again.
- while (this.isReady_ && this.nextStepFunc_ &&
- !topFuncResult.controlBreakingExceptionThrown) {
- this.curStepFunc_ = this.nextStepFunc_;
- this.curStepName_ = this.nextStepName_;
- this.nextStepFunc_ = null;
- this.nextStepName_ = '';
-
- this.dbgLog_('Performing step: ' + this.curStepName_);
- topFuncResult =
- this.callTopOfStackFunc_(/** @type {Function} */(this.curStepFunc_));
-
- // If the max run time is exceeded call this function again async so as
- // not to block the browser.
- var delta = this.now_() - this.getBatchTime();
- if (delta > goog.testing.TestCase.MAX_RUN_TIME &&
- !topFuncResult.controlBreakingExceptionThrown) {
- this.saveMessage('Breaking async');
- var self = this;
- this.timeout(function() { self.pump_(); }, 100);
- break;
- }
- }
- this.returnWillPump_ = false;
- // See note at top of this function.
- if (topFuncResult.controlBreakingExceptionThrown) {
- this.numControlExceptionsExpected_ += 1;
- this.dbgLog_('pump: numControlExceptionsExpected_ = ' +
- this.numControlExceptionsExpected_ + ' and throwing exception.');
- throw new goog.testing.AsyncTestCase.
- ControlBreakingException(topFuncResult.message);
- }
- } else if (opt_doFirst) {
- opt_doFirst.call(this);
- }
-};
-
-
-/**
- * Sets up the test page and then waits untill the test case has been marked
- * as ready before executing the tests.
- * @private
- */
-goog.testing.AsyncTestCase.prototype.doSetUpPage_ = function() {
- this.setNextStep_(this.execute, 'TestCase.execute');
- this.setUpPage();
-};
-
-
-/**
- * Step 1: Move to the next test.
- * @private
- */
-goog.testing.AsyncTestCase.prototype.doIteration_ = function() {
- this.activeTest = this.next();
- if (this.activeTest && this.running) {
- this.result_.runCount++;
- this.setNextStep_(this.doSetUp_, 'setUp');
- } else {
- // All tests done.
- this.finalize();
- }
-};
-
-
-/**
- * Step 2: Call setUp().
- * @private
- */
-goog.testing.AsyncTestCase.prototype.doSetUp_ = function() {
- this.log('Running test: ' + this.activeTest.name);
- this.cleanedUp_ = false;
- this.setNextStep_(this.doExecute_, this.activeTest.name);
- this.setUp();
-};
-
-
-/**
- * Step 3: Call test.execute().
- * @private
- */
-goog.testing.AsyncTestCase.prototype.doExecute_ = function() {
- this.setNextStep_(this.doTearDown_, 'tearDown');
- this.activeTest.execute();
-};
-
-
-/**
- * Step 4: Call tearDown().
- * @private
- */
-goog.testing.AsyncTestCase.prototype.doTearDown_ = function() {
- this.cleanedUp_ = true;
- this.setNextStep_(this.doNext_, 'doNext');
- this.tearDown();
-};
-
-
-/**
- * Step 5: Call doSuccess()
- * @private
- */
-goog.testing.AsyncTestCase.prototype.doNext_ = function() {
- this.setNextStep_(this.doIteration_, 'doIteration');
- this.doSuccess(/** @type {goog.testing.TestCase.Test} */(this.activeTest));
-};
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/asynctestcase_async_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/asynctestcase_async_test.html.svn-base
deleted file mode 100644
index 937417e..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/asynctestcase_async_test.html.svn-base
+++ /dev/null
@@ -1,102 +0,0 @@
-<!DOCTYPE html>
-<html>
-<!--
-Copyright 2009 The Closure Library Authors. All Rights Reserved.
-
-Use of this source code is governed by the Apache License, Version 2.0.
-See the COPYING file for details.
--->
-<!--
-Author: agrieve@google.com (Andrew Grieve)
-
-This tests that the AsyncTestCase can handle asynchronous behaviour in:
- setUpPage(),
- setUp(),
- test*(),
- tearDown()
--->
-<head>
-<meta http-equiv="X-UA-Compatible" content="IE=edge">
-<title>Closure Unit Tests - goog.testing.AsyncTestCase Asyncronous Tests</title>
- <script src="../base.js"></script>
- <script type="text/javascript">
- goog.require('goog.testing.AsyncTestCase');
- goog.require('goog.testing.jsunit');
- </script>
-</head>
-<body>
- <script>
- // Has the setUp() function been called.
- var setUpCalled = false;
- // Has the current test function completed. This helps us to ensure that
- // the next test is not started before the previous completed.
- var curTestIsDone = true;
- // Use an asynchronous test runner for our tests.
- var asyncTestCase =
- goog.testing.AsyncTestCase.createAndInstall(document.title);
-
- /**
- * Uses window.setTimeout() to perform asynchronous behaviour and uses
- * asyncTestCase.waitForAsync() and asyncTestCase.continueTesting() to mark
- * the beginning and end of it.
- * @param {number} numAsyncCalls The number of asynchronous calls to make.
- * @param {string} name The name of the current step.
- */
- function doAsyncStuff(numAsyncCalls, name) {
- if (numAsyncCalls > 0) {
- curTestIsDone = false;
- asyncTestCase.waitForAsync('doAsyncStuff-' + name + '(' + numAsyncCalls
- + ')');
- window.setTimeout(function() {
- doAsyncStuff(numAsyncCalls - 1, name);
- }, 0);
- } else {
- curTestIsDone = true;
- asyncTestCase.continueTesting();
- }
- }
-
- function setUpPage() {
- debug('setUpPage was called.');
- doAsyncStuff(3, 'setUpPage');
- }
- function setUp() {
- assertTrue(curTestIsDone);
- doAsyncStuff(3, 'setUp');
- }
- function tearDown() {
- assertTrue(curTestIsDone);
- }
- function test1() {
- assertTrue(curTestIsDone);
- doAsyncStuff(1, 'test1');
- }
- function test2_asyncContinueThenWait() {
- var activeTest = asyncTestCase.activeTest_;
- function async1() {
- asyncTestCase.continueTesting();
- asyncTestCase.waitForAsync('2');
- window.setTimeout(async2, 0);
- }
- function async2() {
- asyncTestCase.continueTesting();
- assertEquals('Did not wait for inner waitForAsync',
- activeTest,
- asyncTestCase.activeTest_);
- }
- asyncTestCase.waitForAsync('1');
- window.setTimeout(async1, 0);
- }
- function test3() {
- assertTrue(curTestIsDone);
- doAsyncStuff(2, 'test3');
- }
-
- function tearDownPage() {
- debug('tearDownPage was called.');
- assertTrue(curTestIsDone);
- }
-
- </script>
-</body>
-</html>
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/asynctestcase_noasync_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/asynctestcase_noasync_test.html.svn-base
deleted file mode 100644
index edbf55d..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/asynctestcase_noasync_test.html.svn-base
+++ /dev/null
@@ -1,98 +0,0 @@
-<!DOCTYPE html>
-<html>
-<!--
-Copyright 2009 The Closure Library Authors. All Rights Reserved.
-
-Use of this source code is governed by the Apache License, Version 2.0.
-See the COPYING file for details.
--->
-<!--
-Author: agrieve@google.com (Andrew Grieve)
-
-This tests that the AsyncTestCase can handle synchronous behaviour in:
- setUpPage(),
- setUp(),
- test*(),
- tearDown()
-It is the same test as asynctestcase_async_test.html, except that it uses a mock
-version of window.setTimeout() to eliminate all asynchronous calls.
--->
-<head>
-<meta http-equiv="X-UA-Compatible" content="IE=edge">
- <title>Closure Unit Tests - goog.testing.AsyncTestCase Synchronous Tests</title>
- <script src="../base.js"></script>
- <script type="text/javascript">
- goog.require('goog.testing.AsyncTestCase');
- goog.require('goog.testing.jsunit');
- </script>
-</head>
-<body>
- <script>
- // Has the setUp() function been called.
- var setUpCalled = false;
- // Has the current test function completed. This helps us to ensure that the
- // next test is not started before the previous completed.
- var curTestIsDone = true;
- // For restoring it later.
- var oldTimeout = window.setTimeout;
- // Use an asynchronous test runner for our tests.
- var asyncTestCase =
- goog.testing.AsyncTestCase.createAndInstall(document.title);
-
- /**
- * Uses window.setTimeout() to perform asynchronous behaviour and uses
- * asyncTestCase.waitForAsync() and asyncTestCase.continueTesting() to mark
- * the beginning and end of it.
- * @param {number} numAsyncCalls The number of asynchronous calls to make.
- * @param {string} name The name of the current step.
- */
- function doAsyncStuff(numAsyncCalls, name) {
- if (numAsyncCalls > 0) {
- curTestIsDone = false;
- asyncTestCase.waitForAsync('doAsyncStuff-' + name + '(' + numAsyncCalls
- + ')');
- window.setTimeout(function() {
- doAsyncStuff(numAsyncCalls - 1, name);
- }, 0);
- } else {
- curTestIsDone = true;
- asyncTestCase.continueTesting();
- }
- }
-
- function setUpPage() {
- debug('setUpPage was called.');
- // Don't do anything asynchronously.
- window.setTimeout = function(callback, time) {
- callback();
- };
- doAsyncStuff(3, 'setUpPage');
- }
- function setUp() {
- assertTrue(curTestIsDone);
- doAsyncStuff(3, 'setUp');
- }
- function tearDown() {
- assertTrue(curTestIsDone);
- }
- function test1() {
- assertTrue(curTestIsDone);
- doAsyncStuff(1, 'test1');
- }
- function test2() {
- assertTrue(curTestIsDone);
- doAsyncStuff(2, 'test2');
- }
- function test3() {
- assertTrue(curTestIsDone);
- doAsyncStuff(5, 'test3');
- }
- function tearDownPage() {
- debug('tearDownPage was called.');
- assertTrue(curTestIsDone);
- window.setTimeout = oldTimeout;
- }
-
- </script>
-</body>
-</html>
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/asynctestcase_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/asynctestcase_test.html.svn-base
deleted file mode 100644
index a3eabef..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/asynctestcase_test.html.svn-base
+++ /dev/null
@@ -1,58 +0,0 @@
-<!DOCTYPE html>
-<html>
-<!--
-Copyright 2011 The Closure Library Authors. All Rights Reserved.
-
-Use of this source code is governed by the Apache License, Version 2.0.
-See the COPYING file for details.
--->
-<head>
-<meta http-equiv="X-UA-Compatible" content="IE=edge">
-<title>Closure Unit Tests - goog.testing.asynctestcase</title>
-<script src="../base.js"></script>
-<script>
- goog.require('goog.debug.Error');
- goog.require('goog.testing.AsyncTestCase');
- goog.require('goog.testing.AsyncTestCase.ControlBreakingException');
- goog.require('goog.testing.asserts');
- goog.require('goog.testing.jsunit');
-</script>
-</head>
-<body>
-<script>
-
-
-function testControlBreakingExceptionThrown() {
- var asyncTestCase = new goog.testing.AsyncTestCase();
-
- // doAsyncError with no message.
- try {
- asyncTestCase.doAsyncError();
- } catch (e) {
- assertTrue(e.isControlBreakingException);
- assertEquals('', e.message);
- }
-
- // doAsyncError with string.
- var errorMessage1 = 'Error message 1';
- try {
- asyncTestCase.doAsyncError(errorMessage1);
- } catch (e) {
- assertTrue(e.isControlBreakingException);
- assertEquals(errorMessage1, e.message);
- }
-
- // doAsyncError with error.
- var errorMessage2 = 'Error message 2';
- try {
- var error = new goog.debug.Error(errorMessage2);
- asyncTestCase.doAsyncError(error);
- } catch (e) {
- assertTrue(e.isControlBreakingException);
- assertEquals(errorMessage2, e.message);
- }
-}
-
-</script>
-</body>
-</html>
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/benchmark.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/benchmark.js.svn-base
deleted file mode 100644
index 8c38ec8..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/benchmark.js.svn-base
+++ /dev/null
@@ -1,87 +0,0 @@
-// Copyright 2010 The Closure Library Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS-IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-goog.provide('goog.testing.benchmark');
-
-goog.require('goog.dom');
-goog.require('goog.dom.TagName');
-goog.require('goog.testing.PerformanceTable');
-goog.require('goog.testing.PerformanceTimer');
-goog.require('goog.testing.TestCase');
-
-
-/**
- * Run the benchmarks.
- * @private
- */
-goog.testing.benchmark.run_ = function() {
- // Parse the 'times' query parameter if it's set.
- var times = 200;
- var search = window.location.search;
- var timesMatch = search.match(/(?:\?|&)times=([^?&]+)/i);
- if (timesMatch) {
- times = Number(timesMatch[1]);
- }
-
- var prefix = 'benchmark';
-
- // First, get the functions.
- var testSource = goog.testing.TestCase.getGlobals(prefix);
-
- var benchmarks = {};
- var names = [];
-
- for (var name in testSource) {
- try {
- var ref = testSource[name];
- } catch (ex) {
- // NOTE(user): When running tests from a file:// URL on Firefox 3.5
- // for Windows, any reference to window.sessionStorage raises
- // an "Operation is not supported" exception. Ignore any exceptions raised
- // by simply accessing global properties.
- }
-
- if ((new RegExp('^' + prefix)).test(name) && goog.isFunction(ref)) {
- benchmarks[name] = ref;
- names.push(name);
- }
- }
-
- document.body.appendChild(
- goog.dom.createTextNode(
- 'Running ' + names.length + ' benchmarks ' + times + ' times each.'));
- document.body.appendChild(goog.dom.createElement(goog.dom.TagName.BR));
-
- names.sort();
-
- // Build a table and timer.
- var performanceTimer = new goog.testing.PerformanceTimer(times);
- performanceTimer.setDiscardOutliers(true);
-
- var performanceTable = new goog.testing.PerformanceTable(document.body,
- performanceTimer, 2);
-
- // Next, run the benchmarks.
- for (var i = 0; i < names.length; i++) {
- performanceTable.run(benchmarks[names[i]], names[i]);
- }
-};
-
-
-/**
- * Onload handler that runs the benchmarks.
- */
-window.onload = function() {
- goog.testing.benchmark.run_();
-};
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/continuationtestcase.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/continuationtestcase.js.svn-base
deleted file mode 100644
index 684e7da..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/continuationtestcase.js.svn-base
+++ /dev/null
@@ -1,682 +0,0 @@
-// Copyright 2009 The Closure Library Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS-IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/**
- * @fileoverview Defines test classes for tests that can wait for conditions.
- *
- * Normal unit tests must complete their test logic within a single function
- * execution. This is ideal for most tests, but makes it difficult to test
- * routines that require real time to complete. The tests and TestCase in this
- * file allow for tests that can wait until a condition is true before
- * continuing execution.
- *
- * Each test has the typical three phases of execution: setUp, the test itself,
- * and tearDown. During each phase, the test function may add wait conditions,
- * which result in new test steps being added for that phase. All steps in a
- * given phase must complete before moving on to the next phase. An error in
- * any phase will stop that test and report the error to the test runner.
- *
- * This class should not be used where adequate mocks exist. Time-based routines
- * should use the MockClock, which runs much faster and provides equivalent
- * results. Continuation tests should be used for testing code that depends on
- * browser behaviors that are difficult to mock. For example, testing code that
- * relies on Iframe load events, event or layout code that requires a setTimeout
- * to become valid, and other browser-dependent native object interactions for
- * which mocks are insufficient.
- *
- * Sample usage:
- *
- * <pre>
- * var testCase = new goog.testing.ContinuationTestCase();
- * testCase.autoDiscoverTests();
- *
- * if (typeof G_testRunner != 'undefined') {
- * G_testRunner.initialize(testCase);
- * }
- *
- * function testWaiting() {
- * var someVar = true;
- * waitForTimeout(function() {
- * assertTrue(someVar)
- * }, 500);
- * }
- *
- * function testWaitForEvent() {
- * var et = goog.events.EventTarget();
- * waitForEvent(et, 'test', function() {
- * // Test step runs after the event fires.
- * })
- * et.dispatchEvent(et, 'test');
- * }
- *
- * function testWaitForCondition() {
- * var counter = 0;
- *
- * waitForCondition(function() {
- * // This function is evaluated periodically until it returns true, or it
- * // times out.
- * return ++counter >= 3;
- * }, function() {
- * // This test step is run once the condition becomes true.
- * assertEquals(3, counter);
- * });
- * }
- * </pre>
- *
- */
-
-
-goog.provide('goog.testing.ContinuationTestCase');
-goog.provide('goog.testing.ContinuationTestCase.Step');
-goog.provide('goog.testing.ContinuationTestCase.Test');
-
-goog.require('goog.array');
-goog.require('goog.events.EventHandler');
-goog.require('goog.testing.TestCase');
-goog.require('goog.testing.TestCase.Test');
-goog.require('goog.testing.asserts');
-
-
-
-/**
- * Constructs a test case that supports tests with continuations. Test functions
- * may issue "wait" commands that suspend the test temporarily and continue once
- * the wait condition is met.
- *
- * @param {string=} opt_name Optional name for the test case.
- * @constructor
- * @extends {goog.testing.TestCase}
- */
-goog.testing.ContinuationTestCase = function(opt_name) {
- goog.testing.TestCase.call(this, opt_name);
-
- /**
- * An event handler for waiting on Closure or browser events during tests.
- * @type {goog.events.EventHandler}
- * @private
- */
- this.handler_ = new goog.events.EventHandler(this);
-};
-goog.inherits(goog.testing.ContinuationTestCase, goog.testing.TestCase);
-
-
-/**
- * The default maximum time to wait for a single test step in milliseconds.
- * @type {number}
- */
-goog.testing.ContinuationTestCase.MAX_TIMEOUT = 1000;
-
-
-/**
- * Lock used to prevent multiple test steps from running recursively.
- * @type {boolean}
- * @private
- */
-goog.testing.ContinuationTestCase.locked_ = false;
-
-
-/**
- * The current test being run.
- * @type {goog.testing.ContinuationTestCase.Test}
- * @private
- */
-goog.testing.ContinuationTestCase.prototype.currentTest_ = null;
-
-
-/**
- * Enables or disables the wait functions in the global scope.
- * @param {boolean} enable Whether the wait functions should be exported.
- * @private
- */
-goog.testing.ContinuationTestCase.prototype.enableWaitFunctions_ =
- function(enable) {
- if (enable) {
- goog.exportSymbol('waitForCondition',
- goog.bind(this.waitForCondition, this));
- goog.exportSymbol('waitForEvent', goog.bind(this.waitForEvent, this));
- goog.exportSymbol('waitForTimeout', goog.bind(this.waitForTimeout, this));
- } else {
- // Internet Explorer doesn't allow deletion of properties on the window.
- goog.global['waitForCondition'] = undefined;
- goog.global['waitForEvent'] = undefined;
- goog.global['waitForTimeout'] = undefined;
- }
-};
-
-
-/** @override */
-goog.testing.ContinuationTestCase.prototype.runTests = function() {
- this.enableWaitFunctions_(true);
- goog.testing.ContinuationTestCase.superClass_.runTests.call(this);
-};
-
-
-/** @override */
-goog.testing.ContinuationTestCase.prototype.finalize = function() {
- this.enableWaitFunctions_(false);
- goog.testing.ContinuationTestCase.superClass_.finalize.call(this);
-};
-
-
-/** @override */
-goog.testing.ContinuationTestCase.prototype.cycleTests = function() {
- // Get the next test in the queue.
- if (!this.currentTest_) {
- this.currentTest_ = this.createNextTest_();
- }
-
- // Run the next step of the current test, or exit if all tests are complete.
- if (this.currentTest_) {
- this.runNextStep_();
- } else {
- this.finalize();
- }
-};
-
-
-/**
- * Creates the next test in the queue.
- * @return {goog.testing.ContinuationTestCase.Test} The next test to execute, or
- * null if no pending tests remain.
- * @private
- */
-goog.testing.ContinuationTestCase.prototype.createNextTest_ = function() {
- var test = this.next();
- if (!test) {
- return null;
- }
-
-
- var name = test.name;
- goog.testing.TestCase.currentTestName = name;
- this.result_.runCount++;
- this.log('Running test: ' + name);
-
- return new goog.testing.ContinuationTestCase.Test(
- new goog.testing.TestCase.Test(name, this.setUp, this),
- test,
- new goog.testing.TestCase.Test(name, this.tearDown, this));
-};
-
-
-/**
- * Cleans up a finished test and cycles to the next test.
- * @private
- */
-goog.testing.ContinuationTestCase.prototype.finishTest_ = function() {
- var err = this.currentTest_.getError();
- if (err) {
- this.doError(this.currentTest_, err);
- } else {
- this.doSuccess(this.currentTest_);
- }
-
- goog.testing.TestCase.currentTestName = null;
- this.currentTest_ = null;
- this.locked_ = false;
- this.handler_.removeAll();
-
- this.timeout(goog.bind(this.cycleTests, this), 0);
-};
-
-
-/**
- * Executes the next step in the current phase, advancing through each phase as
- * all steps are completed.
- * @private
- */
-goog.testing.ContinuationTestCase.prototype.runNextStep_ = function() {
- if (this.locked_) {
- // Attempting to run a step before the previous step has finished. Try again
- // after that step has released the lock.
- return;
- }
-
- var phase = this.currentTest_.getCurrentPhase();
-
- if (!phase || !phase.length) {
- // No more steps for this test.
- this.finishTest_();
- return;
- }
-
- // Find the next step that is not in a wait state.
- var stepIndex = goog.array.findIndex(phase, function(step) {
- return !step.waiting;
- });
-
- if (stepIndex < 0) {
- // All active steps are currently waiting. Return until one wakes up.
- return;
- }
-
- this.locked_ = true;
- var step = phase[stepIndex];
-
- try {
- step.execute();
- // Remove the successfully completed step. If an error is thrown, all steps
- // will be removed for this phase.
- goog.array.removeAt(phase, stepIndex);
-
- } catch (e) {
- this.currentTest_.setError(e);
-
- // An assertion has failed, or an exception was raised. Clear the current
- // phase, whether it is setUp, test, or tearDown.
- this.currentTest_.cancelCurrentPhase();
-
- // Cancel the setUp and test phase no matter where the error occurred. The
- // tearDown phase will still run if it has pending steps.
- this.currentTest_.cancelTestPhase();
- }
-
- this.locked_ = false;
- this.runNextStep_();
-};
-
-
-/**
- * Creates a new test step that will run after a user-specified timeout.
- * @param {Function} continuation The test function to invoke after the timeout.
- * @param {number=} opt_duration The length of the timeout in milliseconds.
- */
-goog.testing.ContinuationTestCase.prototype.waitForTimeout =
- function(continuation, opt_duration) {
- var step = this.addStep_(continuation);
- step.setTimeout(goog.bind(this.handleComplete_, this, step),
- opt_duration || 0);
-};
-
-
-/**
- * Creates a new test step that will run after an event has fired. If the event
- * does not fire within a reasonable timeout, the test will fail.
- * @param {goog.events.EventTarget|EventTarget} eventTarget The target that will
- * fire the event.
- * @param {string} eventType The type of event to listen for.
- * @param {Function} continuation The test function to invoke after the event
- * fires.
- */
-goog.testing.ContinuationTestCase.prototype.waitForEvent = function(
- eventTarget,
- eventType,
- continuation) {
-
- var step = this.addStep_(continuation);
-
- var duration = goog.testing.ContinuationTestCase.MAX_TIMEOUT;
- step.setTimeout(goog.bind(this.handleTimeout_, this, step, duration),
- duration);
-
- this.handler_.listenOnce(eventTarget,
- eventType,
- goog.bind(this.handleComplete_, this, step));
-};
-
-
-/**
- * Creates a new test step which will run once a condition becomes true. The
- * condition will be polled at a user-specified interval until it becomes true,
- * or until a maximum timeout is reached.
- * @param {Function} condition The condition to poll.
- * @param {Function} continuation The test code to evaluate once the condition
- * becomes true.
- * @param {number=} opt_interval The polling interval in milliseconds.
- * @param {number=} opt_maxTimeout The maximum amount of time to wait for the
- * condition in milliseconds (defaults to 1000).
- */
-goog.testing.ContinuationTestCase.prototype.waitForCondition = function(
- condition,
- continuation,
- opt_interval,
- opt_maxTimeout) {
-
- var interval = opt_interval || 100;
- var timeout = opt_maxTimeout || goog.testing.ContinuationTestCase.MAX_TIMEOUT;
-
- var step = this.addStep_(continuation);
- this.testCondition_(step, condition, goog.now(), interval, timeout);
-};
-
-
-/**
- * Creates a new asynchronous test step which will be added to the current test
- * phase.
- * @param {Function} func The test function that will be executed for this step.
- * @return {goog.testing.ContinuationTestCase.Step} A new test step.
- * @private
- */
-goog.testing.ContinuationTestCase.prototype.addStep_ = function(func) {
- if (!this.currentTest_) {
- throw Error('Cannot add test steps outside of a running test.');
- }
-
- var step = new goog.testing.ContinuationTestCase.Step(
- this.currentTest_.name,
- func,
- this.currentTest_.scope);
- this.currentTest_.addStep(step);
- return step;
-};
-
-
-/**
- * Handles completion of a step's wait condition. Advances the test, allowing
- * the step's test method to run.
- * @param {goog.testing.ContinuationTestCase.Step} step The step that has
- * finished waiting.
- * @private
- */
-goog.testing.ContinuationTestCase.prototype.handleComplete_ = function(step) {
- step.clearTimeout();
- step.waiting = false;
- this.runNextStep_();
-};
-
-
-/**
- * Handles the timeout event for a step that has exceeded the maximum time. This
- * causes the current test to fail.
- * @param {goog.testing.ContinuationTestCase.Step} step The timed-out step.
- * @param {number} duration The length of the timeout in milliseconds.
- * @private
- */
-goog.testing.ContinuationTestCase.prototype.handleTimeout_ =
- function(step, duration) {
- step.ref = function() {
- fail('Continuation timed out after ' + duration + 'ms.');
- };
-
- // Since the test is failing, cancel any other pending event listeners.
- this.handler_.removeAll();
- this.handleComplete_(step);
-};
-
-
-/**
- * Tests a wait condition and executes the associated test step once the
- * condition is true.
- *
- * If the condition does not become true before the maximum duration, the
- * interval will stop and the test step will fail in the kill timer.
- *
- * @param {goog.testing.ContinuationTestCase.Step} step The waiting test step.
- * @param {Function} condition The test condition.
- * @param {number} startTime Time when the test step began waiting.
- * @param {number} interval The duration in milliseconds to wait between tests.
- * @param {number} timeout The maximum amount of time to wait for the condition
- * to become true. Measured from the startTime in milliseconds.
- * @private
- */
-goog.testing.ContinuationTestCase.prototype.testCondition_ = function(
- step,
- condition,
- startTime,
- interval,
- timeout) {
-
- var duration = goog.now() - startTime;
-
- if (condition()) {
- this.handleComplete_(step);
- } else if (duration < timeout) {
- step.setTimeout(goog.bind(this.testCondition_,
- this,
- step,
- condition,
- startTime,
- interval,
- timeout),
- interval);
- } else {
- this.handleTimeout_(step, duration);
- }
-};
-
-
-
-/**
- * Creates a continuation test case, which consists of multiple test steps that
- * occur in several phases.
- *
- * The steps are distributed between setUp, test, and tearDown phases. During
- * the execution of each step, 0 or more steps may be added to the current
- * phase. Once all steps in a phase have completed, the next phase will be
- * executed.
- *
- * If any errors occur (such as an assertion failure), the setUp and Test phases
- * will be cancelled immediately. The tearDown phase will always start, but may
- * be cancelled as well if it raises an error.
- *
- * @param {goog.testing.TestCase.Test} setUp A setUp test method to run before
- * the main test phase.
- * @param {goog.testing.TestCase.Test} test A test method to run.
- * @param {goog.testing.TestCase.Test} tearDown A tearDown test method to run
- * after the test method completes or fails.
- * @constructor
- * @extends {goog.testing.TestCase.Test}
- */
-goog.testing.ContinuationTestCase.Test = function(setUp, test, tearDown) {
- // This test container has a name, but no evaluation function or scope.
- goog.testing.TestCase.Test.call(this, test.name, null, null);
-
- /**
- * The list of test steps to run during setUp.
- * @type {Array.<goog.testing.TestCase.Test>}
- * @private
- */
- this.setUp_ = [setUp];
-
- /**
- * The list of test steps to run for the actual test.
- * @type {Array.<goog.testing.TestCase.Test>}
- * @private
- */
- this.test_ = [test];
-
- /**
- * The list of test steps to run during the tearDown phase.
- * @type {Array.<goog.testing.TestCase.Test>}
- * @private
- */
- this.tearDown_ = [tearDown];
-};
-goog.inherits(goog.testing.ContinuationTestCase.Test,
- goog.testing.TestCase.Test);
-
-
-/**
- * The first error encountered during the test run, if any.
- * @type {Error}
- * @private
- */
-goog.testing.ContinuationTestCase.Test.prototype.error_ = null;
-
-
-/**
- * @return {Error} The first error to be raised during the test run or null if
- * no errors occurred.
- */
-goog.testing.ContinuationTestCase.Test.prototype.getError = function() {
- return this.error_;
-};
-
-
-/**
- * Sets an error for the test so it can be reported. Only the first error set
- * during a test will be reported. Additional errors that occur in later test
- * phases will be discarded.
- * @param {Error} e An error.
- */
-goog.testing.ContinuationTestCase.Test.prototype.setError = function(e) {
- this.error_ = this.error_ || e;
-};
-
-
-/**
- * @return {Array.<goog.testing.TestCase.Test>} The current phase of steps
- * being processed. Returns null if all steps have been completed.
- */
-goog.testing.ContinuationTestCase.Test.prototype.getCurrentPhase = function() {
- if (this.setUp_.length) {
- return this.setUp_;
- }
-
- if (this.test_.length) {
- return this.test_;
- }
-
- if (this.tearDown_.length) {
- return this.tearDown_;
- }
-
- return null;
-};
-
-
-/**
- * Adds a new test step to the end of the current phase. The new step will wait
- * for a condition to be met before running, or will fail after a timeout.
- * @param {goog.testing.ContinuationTestCase.Step} step The test step to add.
- */
-goog.testing.ContinuationTestCase.Test.prototype.addStep = function(step) {
- var phase = this.getCurrentPhase();
- if (phase) {
- phase.push(step);
- } else {
- throw Error('Attempted to add a step to a completed test.');
- }
-};
-
-
-/**
- * Cancels all remaining steps in the current phase. Called after an error in
- * any phase occurs.
- */
-goog.testing.ContinuationTestCase.Test.prototype.cancelCurrentPhase =
- function() {
- this.cancelPhase_(this.getCurrentPhase());
-};
-
-
-/**
- * Skips the rest of the setUp and test phases, but leaves the tearDown phase to
- * clean up.
- */
-goog.testing.ContinuationTestCase.Test.prototype.cancelTestPhase = function() {
- this.cancelPhase_(this.setUp_);
- this.cancelPhase_(this.test_);
-};
-
-
-/**
- * Clears a test phase and cancels any pending steps found.
- * @param {Array.<goog.testing.TestCase.Test>} phase A list of test steps.
- * @private
- */
-goog.testing.ContinuationTestCase.Test.prototype.cancelPhase_ =
- function(phase) {
- while (phase && phase.length) {
- var step = phase.pop();
- if (step instanceof goog.testing.ContinuationTestCase.Step) {
- step.clearTimeout();
- }
- }
-};
-
-
-
-/**
- * Constructs a single step in a larger continuation test. Each step is similar
- * to a typical TestCase test, except it may wait for an event or timeout to
- * occur before running the test function.
- *
- * @param {string} name The test name.
- * @param {Function} ref The test function to run.
- * @param {Object=} opt_scope The object context to run the test in.
- * @constructor
- * @extends {goog.testing.TestCase.Test}
- */
-goog.testing.ContinuationTestCase.Step = function(name, ref, opt_scope) {
- goog.testing.TestCase.Test.call(this, name, ref, opt_scope);
-};
-goog.inherits(goog.testing.ContinuationTestCase.Step,
- goog.testing.TestCase.Test);
-
-
-/**
- * Whether the step is currently waiting for a condition to continue. All new
- * steps begin in wait state.
- * @type {boolean}
- */
-goog.testing.ContinuationTestCase.Step.prototype.waiting = true;
-
-
-/**
- * A saved reference to window.clearTimeout so that MockClock or other overrides
- * don't affect continuation timeouts.
- * @type {Function}
- * @private
- */
-goog.testing.ContinuationTestCase.Step.protectedClearTimeout_ =
- window.clearTimeout;
-
-
-/**
- * A saved reference to window.setTimeout so that MockClock or other overrides
- * don't affect continuation timeouts.
- * @type {Function}
- * @private
- */
-goog.testing.ContinuationTestCase.Step.protectedSetTimeout_ = window.setTimeout;
-
-
-/**
- * Key to this step's timeout. If the step is waiting for an event, the timeout
- * will be used as a kill timer. If the step is waiting
- * @type {number}
- * @private
- */
-goog.testing.ContinuationTestCase.Step.prototype.timeout_;
-
-
-/**
- * Starts a timeout for this step. Each step may have only one timeout active at
- * a time.
- * @param {Function} func The function to call after the timeout.
- * @param {number} duration The number of milliseconds to wait before invoking
- * the function.
- */
-goog.testing.ContinuationTestCase.Step.prototype.setTimeout =
- function(func, duration) {
-
- this.clearTimeout();
-
- var setTimeout = goog.testing.ContinuationTestCase.Step.protectedSetTimeout_;
- this.timeout_ = setTimeout(func, duration);
-};
-
-
-/**
- * Clears the current timeout if it is active.
- */
-goog.testing.ContinuationTestCase.Step.prototype.clearTimeout = function() {
- if (this.timeout_) {
- var clear = goog.testing.ContinuationTestCase.Step.protectedClearTimeout_;
-
- clear(this.timeout_);
- delete this.timeout_;
- }
-};
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/continuationtestcase_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/continuationtestcase_test.html.svn-base
deleted file mode 100644
index 910e9b1..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/continuationtestcase_test.html.svn-base
+++ /dev/null
@@ -1,349 +0,0 @@
-<!DOCTYPE html>
-<html>
-<!--
-Copyright 2009 The Closure Library Authors. All Rights Reserved.
-
-Use of this source code is governed by the Apache License, Version 2.0.
-See the COPYING file for details.
--->
-<!--
--->
-<head>
-<meta http-equiv="X-UA-Compatible" content="IE=edge">
-<title>Closure Unit Tests - goog.testing.ContinuationTestCase</title>
-<script src="../base.js"></script>
-<script>
-goog.require('goog.events');
-goog.require('goog.events.EventTarget');
-goog.require('goog.testing.ContinuationTestCase');
-goog.require('goog.testing.MockClock');
-goog.require('goog.testing.PropertyReplacer');
-goog.require('goog.testing.TestCase.Test');
-goog.require('goog.testing.jsunit');
-</script>
-</head>
-<body>
-<script>
-/**
- * @fileoverview This test file uses the ContinuationTestCase to test itself,
- * which is a little confusing. It's also difficult to write a truly effective
- * test, since testing a failure causes an actual failure in the test runner.
- * All tests have been manually verified using a sophisticated combination of
- * alerts and false assertions.
- */
-
-var testCase = new goog.testing.ContinuationTestCase('Continuation Test Case');
-testCase.autoDiscoverTests();
-
-// Standalone Closure Test Runner.
-if (typeof G_testRunner != 'undefined') {
- G_testRunner.initialize(testCase);
-}
-
-
-var clock = new goog.testing.MockClock();
-var count = 0;
-var stubs = new goog.testing.PropertyReplacer();
-
-
-function setUpPage() {
- count = testCase.getCount();
-}
-
-
-/**
- * Resets the mock clock. Includes a wait step to verify that setUp routines
- * can contain continuations.
- */
-function setUp() {
- waitForTimeout(function() {
- // Pointless assertion to verify that setUp methods can contain waits.
- assertEquals(count, testCase.getCount());
- }, 0);
-
- clock.reset();
-}
-
-
-/**
- * Uninstalls the mock clock if it was installed, and restores the Step timeout
- * functions to the default window implementations.
- */
-function tearDown() {
- clock.uninstall();
- stubs.reset();
-
- waitForTimeout(function() {
- // Pointless assertion to verify that tearDown methods can contain waits.
- assertTrue(testCase.now_() >= testCase.startTime_);
- }, 0);
-}
-
-
-/**
- * Installs the Mock Clock and replaces the Step timeouts with the mock
- * implementations.
- */
-function installMockClock() {
- clock.install();
-
- // Overwrite the "protected" setTimeout and clearTimeout with the versions
- // replaced by MockClock. Normal tests should never do this, but we need to
- // test the ContinuationTest itself.
- stubs.set(goog.testing.ContinuationTestCase.Step, 'protectedClearTimeout_',
- window.clearTimeout);
- stubs.set(goog.testing.ContinuationTestCase.Step, 'protectedSetTimeout_',
- window.setTimeout);
-}
-
-
-/**
- * @return {goog.testing.ContinuationTestCase.Step} A generic step in a
- * continuation test.
- */
-function getSampleStep() {
- return new goog.testing.ContinuationTestCase.Step('test', function() {});
-}
-
-
-/**
- * @return {goog.testing.ContinuationTestCase.Test} A simple continuation test
- * with generic setUp, test, and tearDown functions.
- */
-function getSampleTest() {
- var setupStep = new goog.testing.TestCase.Test('setup', function() {})
- var testStep = new goog.testing.TestCase.Test('test', function() {})
- var teardownStep = new goog.testing.TestCase.Test('teardown', function() {})
-
- return new goog.testing.ContinuationTestCase.Test(setupStep,
- testStep,
- teardownStep);
-}
-
-
-function testStepWaiting() {
- var step = getSampleStep();
- assertTrue(step.waiting);
-}
-
-
-function testStepSetTimeout() {
- installMockClock();
- var step = getSampleStep();
-
- var timeoutReached = false;
- step.setTimeout(function() {timeoutReached = true}, 100);
-
- clock.tick(50);
- assertFalse(timeoutReached);
- clock.tick(50);
- assertTrue(timeoutReached);
-}
-
-
-function testStepClearTimeout() {
- var step = new goog.testing.ContinuationTestCase.Step('test', function() {});
-
- var timeoutReached = false;
- step.setTimeout(function() {timeoutReached = true}, 100);
-
- clock.tick(50);
- assertFalse(timeoutReached);
- step.clearTimeout();
- clock.tick(50);
- assertFalse(timeoutReached);
-}
-
-
-function testTestPhases() {
- var test = getSampleTest();
-
- assertEquals('setup', test.getCurrentPhase()[0].name);
- test.cancelCurrentPhase();
-
- assertEquals('test', test.getCurrentPhase()[0].name);
- test.cancelCurrentPhase();
-
- assertEquals('teardown', test.getCurrentPhase()[0].name);
- test.cancelCurrentPhase();
-
- assertNull(test.getCurrentPhase());
-}
-
-
-function testTestSetError() {
- var test = getSampleTest();
-
- var error1 = new Error('Oh noes!');
- var error2 = new Error('B0rken.');
-
- assertNull(test.getError());
- test.setError(error1);
- assertEquals(error1, test.getError());
- test.setError(error2);
- assertEquals('Once an error has been set, it should not be overwritten.',
- error1, test.getError());
-}
-
-
-function testAddStep() {
- var test = getSampleTest();
- var step = getSampleStep();
-
- // Try adding a step to each phase and then cancelling the phase.
- for (var i = 0; i < 3; i++) {
- assertEquals(1, test.getCurrentPhase().length);
- test.addStep(step);
-
- assertEquals(2, test.getCurrentPhase().length);
- assertEquals(step, test.getCurrentPhase()[1]);
- test.cancelCurrentPhase();
- }
-
- assertNull(test.getCurrentPhase());
-}
-
-
-function testCancelTestPhase() {
- var test = getSampleTest();
-
- test.cancelTestPhase();
- assertEquals('teardown', test.getCurrentPhase()[0].name);
-
- test = getSampleTest();
- test.cancelCurrentPhase();
- test.cancelTestPhase();
- assertEquals('teardown', test.getCurrentPhase()[0].name);
-
- test = getSampleTest();
- test.cancelTestPhase();
- test.cancelTestPhase();
- assertEquals('teardown', test.getCurrentPhase()[0].name);
-}
-
-
-function testWaitForTimeout() {
- var reachedA = false;
- var reachedB = false;
- var reachedC = false;
-
- waitForTimeout(function a() {
- reachedA = true;
-
- assertTrue('A must be true at callback a.', reachedA);
- assertFalse('B must be false at callback a.', reachedB);
- assertFalse('C must be false at callback a.', reachedC);
- }, 10);
-
- waitForTimeout(function b() {
- reachedB = true;
-
- assertTrue('A must be true at callback b.', reachedA);
- assertTrue('B must be true at callback b.', reachedB);
- assertFalse('C must be false at callback b.', reachedC);
- }, 20);
-
- waitForTimeout(function c() {
- reachedC = true;
-
- assertTrue('A must be true at callback c.', reachedA);
- assertTrue('B must be true at callback c.', reachedB);
- assertTrue('C must be true at callback c.', reachedC);
- }, 20);
-
- assertFalse('a', reachedA);
- assertFalse('b', reachedB);
- assertFalse('c', reachedC);
-}
-
-
-function testWaitForEvent() {
- var et = new goog.events.EventTarget();
-
- var eventFired = false;
- goog.events.listen(et, 'testPrefire', function() {
- eventFired = true;
- et.dispatchEvent('test');
- });
-
- waitForEvent(et, 'test', function() {
- assertTrue(eventFired);
- });
-
- et.dispatchEvent('testPrefire');
-}
-
-
-function testWaitForCondition() {
- var counter = 0;
-
- waitForCondition(function() {
- return ++counter >= 3;
- }, function() {
- assertEquals(3, counter);
- }, 10, 100);
-}
-
-
-function testOutOfOrderWaits() {
- var counter = 0;
- waitForTimeout(function() {assertEquals(5, ++counter);}, 50);
- waitForTimeout(function() {assertEquals(1, ++counter);}, 10);
- waitForTimeout(function() {assertEquals(3, ++counter);}, 30);
- waitForTimeout(function() {assertEquals(2, ++counter);}, 20);
- waitForTimeout(function() {assertEquals(4, ++counter);}, 40);
-}
-
-
-/*
- * Any of the test functions below (except the condition check passed into
- * waitForCondition) can raise an assertion successfully. Any level of nested
- * test steps should be possible, in any configuration.
- */
-
-var testObj;
-
-
-function testCrazyNestedWaitFunction() {
- testObj = {
- lock: true,
- et: new goog.events.EventTarget(),
- steps: 0
- }
-
- waitForTimeout(handleTimeout, 10);
- waitForEvent(testObj.et, 'test', handleEvent);
- waitForCondition(condition, handleCondition, 1);
-}
-
-function handleTimeout() {
- testObj.steps++;
- assertEquals('handleTimeout should be called first.', 1, testObj.steps);
- waitForTimeout(fireEvent, 10);
-}
-
-function fireEvent() {
- testObj.steps++;
- assertEquals('fireEvent should be called second.', 2, testObj.steps);
- testObj.et.dispatchEvent('test');
-}
-
-function handleEvent() {
- testObj.steps++;
- assertEquals('handleEvent should be called third.', 3, testObj.steps);
- testObj.lock = false;
-}
-
-function condition() {
- return !testObj.lock;
-}
-
-function handleCondition() {
- assertFalse(testObj.lock);
- testObj.steps++;
- assertEquals('handleCondition should be called last.', 4, testObj.steps);
-}
-
-</script>
-</body>
-</html>
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/deferredtestcase.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/deferredtestcase.js.svn-base
deleted file mode 100644
index 3d28b55..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/deferredtestcase.js.svn-base
+++ /dev/null
@@ -1,157 +0,0 @@
-// Copyright 2010 The Closure Library Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS-IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/**
- * @fileoverview Defines DeferredTestCase class. By calling waitForDeferred(),
- * tests in DeferredTestCase can wait for a Deferred object to complete its
- * callbacks before continuing to the next test.
- *
- * Example Usage:
- *
- * var deferredTestCase = goog.testing.DeferredTestCase.createAndInstall();
- * // Optionally, set a longer-than-usual step timeout.
- * deferredTestCase.stepTimeout = 15 * 1000; // 15 seconds
- *
- * function testDeferredCallbacks() {
- * var callbackTime = goog.now();
- * var callbacks = new goog.async.Deferred();
- * deferredTestCase.addWaitForAsync('Waiting for 1st callback', callbacks);
- * callbacks.addCallback(
- * function() {
- * assertTrue(
- * 'We\'re going back in time!', goog.now() >= callbackTime);
- * callbackTime = goog.now();
- * });
- * deferredTestCase.addWaitForAsync('Waiting for 2nd callback', callbacks);
- * callbacks.addCallback(
- * function() {
- * assertTrue(
- * 'We\'re going back in time!', goog.now() >= callbackTime);
- * callbackTime = goog.now();
- * });
- * deferredTestCase.addWaitForAsync('Waiting for last callback', callbacks);
- * callbacks.addCallback(
- * function() {
- * assertTrue(
- * 'We\'re going back in time!', goog.now() >= callbackTime);
- * callbackTime = goog.now();
- * });
- *
- * deferredTestCase.waitForDeferred(callbacks);
- * }
- *
- * Note that DeferredTestCase still preserves the functionality of
- * AsyncTestCase.
- *
- * @see.goog.async.Deferred
- * @see goog.testing.AsyncTestCase
- */
-
-goog.provide('goog.testing.DeferredTestCase');
-
-goog.require('goog.async.Deferred');
-goog.require('goog.testing.AsyncTestCase');
-goog.require('goog.testing.TestCase');
-
-
-
-/**
- * A test case that can asynchronously wait on a Deferred object.
- * @param {string=} opt_name A descriptive name for the test case.
- * @constructor
- * @extends {goog.testing.AsyncTestCase}
- */
-goog.testing.DeferredTestCase = function(opt_name) {
- goog.testing.AsyncTestCase.call(this, opt_name);
-};
-goog.inherits(goog.testing.DeferredTestCase, goog.testing.AsyncTestCase);
-
-
-/**
- * Preferred way of creating a DeferredTestCase. Creates one and initializes it
- * with the G_testRunner.
- * @param {string=} opt_name A descriptive name for the test case.
- * @return {goog.testing.DeferredTestCase} The created DeferredTestCase.
- */
-goog.testing.DeferredTestCase.createAndInstall = function(opt_name) {
- var deferredTestCase = new goog.testing.DeferredTestCase(opt_name);
- goog.testing.TestCase.initializeTestRunner(deferredTestCase);
- return deferredTestCase;
-};
-
-
-/**
- * Handler for when the test produces an error.
- * @param {Error|string} err The error object.
- * @protected
- * @throws Always throws a ControlBreakingException.
- */
-goog.testing.DeferredTestCase.prototype.onError = function(err) {
- this.doAsyncError(err);
-};
-
-
-/**
- * Handler for when the test succeeds.
- * @protected
- */
-goog.testing.DeferredTestCase.prototype.onSuccess = function() {
- this.continueTesting();
-};
-
-
-/**
- * Adds a callback to update the wait message of this async test case. Using
- * this method generously also helps to document the test flow.
- * @param {string} msg The update wait status message.
- * @param {goog.async.Deferred} d The deferred object to add the waitForAsync
- * callback to.
- * @see goog.testing.AsyncTestCase#waitForAsync
- */
-goog.testing.DeferredTestCase.prototype.addWaitForAsync = function(msg, d) {
- d.addCallback(goog.bind(this.waitForAsync, this, msg));
-};
-
-
-/**
- * Wires up given Deferred object to the test case, then starts the
- * goog.async.Deferred object's callback.
- * @param {!string|goog.async.Deferred} a The wait status message or the
- * deferred object to wait for.
- * @param {goog.async.Deferred=} opt_b The deferred object to wait for.
- */
-goog.testing.DeferredTestCase.prototype.waitForDeferred = function(a, opt_b) {
- var waitMsg;
- var deferred;
- switch (arguments.length) {
- case 1:
- deferred = a;
- waitMsg = null;
- break;
- case 2:
- deferred = opt_b;
- waitMsg = a;
- break;
- default: // Shouldn't be here in compiled mode
- throw Error('Invalid number of arguments');
- }
-
- deferred.addCallbacks(this.onSuccess, this.onError, this);
- if (!waitMsg) {
- waitMsg =
- 'Waiting for deferred in ' + this.activeTest.name;
- }
- this.waitForAsync( /** @type {!string} */ (waitMsg));
- deferred.callback(true);
-};
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/deferredtestcase_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/deferredtestcase_test.html.svn-base
deleted file mode 100644
index 09d1910..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/deferredtestcase_test.html.svn-base
+++ /dev/null
@@ -1,151 +0,0 @@
-<!DOCTYPE html>
-<html>
-<!--
-Copyright 2010 The Closure Library Authors. All Rights Reserved.
-
-Use of this source code is governed by the Apache License, Version 2.0.
-See the COPYING file for details.
--->
-<!--
--->
-<head>
-<title>Closure Unit Tests - goog.testing.DeferredTestCase Asyncronous Tests</title>
- <script src="../base.js"></script>
- <script>
- goog.require('goog.async.Deferred');
- goog.require('goog.testing.DeferredTestCase');
- goog.require('goog.testing.TestRunner');
- goog.require('goog.testing.jsunit');
- </script>
-</head>
-<body>
- <script type="text/javascript">
- var deferredTestCase =
- goog.testing.DeferredTestCase.createAndInstall(document.title);
- var testTestCase;
- var runner;
-
- // Optionally, set a longer-than-usual step timeout.
- deferredTestCase.stepTimeout = 15 * 1000; // 15 seconds
-
- // This is the sample code in deferredtestcase.js
- function testDeferredCallbacks() {
- var callbackTime = goog.now();
- var callbacks = new goog.async.Deferred();
- deferredTestCase.addWaitForAsync('Waiting for 1st callback', callbacks);
- callbacks.addCallback(
- function() {
- assertTrue(
- 'We\'re going back in time!', goog.now() >= callbackTime);
- callbackTime = goog.now();
- });
- deferredTestCase.addWaitForAsync('Waiting for 2nd callback', callbacks);
- callbacks.addCallback(
- function() {
- assertTrue(
- 'We\'re going back in time!', goog.now() >= callbackTime);
- callbackTime = goog.now();
- });
- deferredTestCase.addWaitForAsync('Waiting for last callback', callbacks);
- callbacks.addCallback(
- function() {
- assertTrue(
- 'We\'re going back in time!', goog.now() >= callbackTime);
- callbackTime = goog.now();
- });
-
- deferredTestCase.waitForDeferred(callbacks);
- }
-
- function createDeferredTestCase(d) {
- testTestCase = new goog.testing.DeferredTestCase('Foobar TestCase');
- testTestCase.add(new goog.testing.TestCase.Test(
- 'Foobar Test',
- function() {
- this.waitForDeferred(d);
- },
- testTestCase));
-
- var testCompleteCallback = new goog.async.Deferred();
- testTestCase.setCompletedCallback(
- function() {
- testCompleteCallback.callback(true);
- });
-
- // We're not going to use the runner to run the test, but we attach one
- // here anyway because without a runner TestCase throws an exception in
- // finalize().
- var runner = new goog.testing.TestRunner();
- runner.initialize(testTestCase);
-
- return testCompleteCallback;
- }
-
- function testDeferredWait() {
- var d = new goog.async.Deferred();
- deferredTestCase.addWaitForAsync('Foobar', d);
- d.addCallback(function() {
- return goog.async.Deferred.succeed(true);
- });
- deferredTestCase.waitForDeferred(d);
- }
-
- function testNonAsync() {
- assertTrue(true);
- }
-
- function testPassWithTestRunner() {
- var d = new goog.async.Deferred();
- d.addCallback(function() {
- return goog.async.Deferred.succeed(true);
- //return goog.async.Deferred.fail(true);
- //return new goog.async.Deferred();
- });
-
- var testCompleteDeferred = createDeferredTestCase(d);
- testTestCase.execute();
-
- var deferredCallbackOnPass = new goog.async.Deferred();
- deferredCallbackOnPass.addCallback(function() {
- return testCompleteDeferred;
- });
- deferredCallbackOnPass.addCallback(function() {
- assertTrue('Test case should have succeded.', testTestCase.isSuccess());
- });
-
- deferredTestCase.waitForDeferred(deferredCallbackOnPass);
- }
-
- function testFailWithTestRunner() {
- var d = new goog.async.Deferred();
- d.addCallback(function() {
- return goog.async.Deferred.fail(true);
- });
-
- var testCompleteDeferred = createDeferredTestCase(d);
-
- // Override and consume test exception
- var origFn = testTestCase.doAsyncError;
- testTestCase.doAsyncError = function() {
- try {
- origFn();
- } catch (e) {
- testCompleteDeferred.callback(true);
- }
- }
- testTestCase.execute();
-
- var deferredCallbackOnFail = new goog.async.Deferred();
- deferredCallbackOnFail.addCallback(function() {
- return testCompleteDeferred;
- });
- deferredCallbackOnFail.addCallback(function() {
- assertTrue('Test case should have failed.', !testTestCase.isSuccess());
- });
-
- deferredTestCase.waitForDeferred(deferredCallbackOnFail);
- }
-
- </script>
-</body>
-</html>
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/dom.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/dom.js.svn-base
deleted file mode 100644
index 4056c19..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/dom.js.svn-base
+++ /dev/null
@@ -1,606 +0,0 @@
-// Copyright 2008 The Closure Library Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS-IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/**
- * @fileoverview Testing utilities for DOM related tests.
- *
- * @author robbyw@google.com (Robby Walker)
- */
-
-goog.provide('goog.testing.dom');
-
-goog.require('goog.dom');
-goog.require('goog.dom.NodeIterator');
-goog.require('goog.dom.NodeType');
-goog.require('goog.dom.TagIterator');
-goog.require('goog.dom.TagName');
-goog.require('goog.dom.classes');
-goog.require('goog.iter');
-goog.require('goog.object');
-goog.require('goog.string');
-goog.require('goog.style');
-goog.require('goog.testing.asserts');
-goog.require('goog.userAgent');
-
-
-/**
- * A unique object to use as an end tag marker.
- * @type {Object}
- * @private
- */
-goog.testing.dom.END_TAG_MARKER_ = {};
-
-
-/**
- * Tests if the given iterator over nodes matches the given Array of node
- * descriptors. Throws an error if any match fails.
- * @param {goog.iter.Iterator} it An iterator over nodes.
- * @param {Array.<Node|number|string>} array Array of node descriptors to match
- * against. Node descriptors can be any of the following:
- * Node: Test if the two nodes are equal.
- * number: Test node.nodeType == number.
- * string starting with '#': Match the node's id with the text
- * after "#".
- * other string: Match the text node's contents.
- */
-goog.testing.dom.assertNodesMatch = function(it, array) {
- var i = 0;
- goog.iter.forEach(it, function(node) {
- if (array.length <= i) {
- fail('Got more nodes than expected: ' + goog.testing.dom.describeNode_(
- node));
- }
- var expected = array[i];
-
- if (goog.dom.isNodeLike(expected)) {
- assertEquals('Nodes should match at position ' + i, expected, node);
- } else if (goog.isNumber(expected)) {
- assertEquals('Node types should match at position ' + i, expected,
- node.nodeType);
- } else if (expected.charAt(0) == '#') {
- assertEquals('Expected element at position ' + i,
- goog.dom.NodeType.ELEMENT, node.nodeType);
- var expectedId = expected.substr(1);
- assertEquals('IDs should match at position ' + i,
- expectedId, node.id);
-
- } else {
- assertEquals('Expected text node at position ' + i,
- goog.dom.NodeType.TEXT, node.nodeType);
- assertEquals('Node contents should match at position ' + i,
- expected, node.nodeValue);
- }
-
- i++;
- });
-
- assertEquals('Used entire match array', array.length, i);
-};
-
-
-/**
- * Exposes a node as a string.
- * @param {Node} node A node.
- * @return {string} A string representation of the node.
- */
-goog.testing.dom.exposeNode = function(node) {
- return (node.tagName || node.nodeValue) + (node.id ? '#' + node.id : '') +
- ':"' + (node.innerHTML || '') + '"';
-};
-
-
-/**
- * Exposes the nodes of a range wrapper as a string.
- * @param {goog.dom.AbstractRange} range A range.
- * @return {string} A string representation of the range.
- */
-goog.testing.dom.exposeRange = function(range) {
- // This is deliberately not implemented as
- // goog.dom.AbstractRange.prototype.toString, because it is non-authoritative.
- // Two equivalent ranges may have very different exposeRange values, and
- // two different ranges may have equal exposeRange values.
- // (The mapping of ranges to DOM nodes/offsets is a many-to-many mapping).
- if (!range) {
- return 'null';
- }
- return goog.testing.dom.exposeNode(range.getStartNode()) + ':' +
- range.getStartOffset() + ' to ' +
- goog.testing.dom.exposeNode(range.getEndNode()) + ':' +
- range.getEndOffset();
-};
-
-
-/**
- * Determines if the current user agent matches the specified string. Returns
- * false if the string does specify at least one user agent but does not match
- * the running agent.
- * @param {string} userAgents Space delimited string of user agents.
- * @return {boolean} Whether the user agent was matched. Also true if no user
- * agent was listed in the expectation string.
- * @private
- */
-goog.testing.dom.checkUserAgents_ = function(userAgents) {
- if (goog.string.startsWith(userAgents, '!')) {
- if (goog.string.contains(userAgents, ' ')) {
- throw new Error('Only a single negative user agent may be specified');
- }
- return !goog.userAgent[userAgents.substr(1)];
- }
-
- var agents = userAgents.split(' ');
- var hasUserAgent = false;
- for (var i = 0, len = agents.length; i < len; i++) {
- var cls = agents[i];
- if (cls in goog.userAgent) {
- hasUserAgent = true;
- if (goog.userAgent[cls]) {
- return true;
- }
- }
- }
- // If we got here, there was a user agent listed but we didn't match it.
- return !hasUserAgent;
-};
-
-
-/**
- * Map function that converts end tags to a specific object.
- * @param {Node} node The node to map.
- * @param {Object} ignore Always undefined.
- * @param {goog.dom.TagIterator} iterator The iterator.
- * @return {Node|Object} The resulting iteration item.
- * @private
- */
-goog.testing.dom.endTagMap_ = function(node, ignore, iterator) {
- return iterator.isEndTag() ? goog.testing.dom.END_TAG_MARKER_ : node;
-};
-
-
-/**
- * Check if the given node is important. A node is important if it is a
- * non-empty text node, a non-annotated element, or an element annotated to
- * match on this user agent.
- * @param {Node} node The node to test.
- * @return {boolean} Whether this node should be included for iteration.
- * @private
- */
-goog.testing.dom.nodeFilter_ = function(node) {
- if (node.nodeType == goog.dom.NodeType.TEXT) {
- // If a node is part of a string of text nodes and it has spaces in it,
- // we allow it since it's going to affect the merging of nodes done below.
- if (goog.string.isBreakingWhitespace(node.nodeValue) &&
- (!node.previousSibling ||
- node.previousSibling.nodeType != goog.dom.NodeType.TEXT) &&
- (!node.nextSibling ||
- node.nextSibling.nodeType != goog.dom.NodeType.TEXT)) {
- return false;
- }
- // Allow optional text to be specified as [[BROWSER1 BROWSER2]]Text
- var match = node.nodeValue.match(/^\[\[(.+)\]\]/);
- if (match) {
- return goog.testing.dom.checkUserAgents_(match[1]);
- }
- } else if (node.className) {
- return goog.testing.dom.checkUserAgents_(node.className);
- }
- return true;
-};
-
-
-/**
- * Determines the text to match from the given node, removing browser
- * specification strings.
- * @param {Node} node The node expected to match.
- * @return {string} The text, stripped of browser specification strings.
- * @private
- */
-goog.testing.dom.getExpectedText_ = function(node) {
- // Strip off the browser specifications.
- return node.nodeValue.match(/^(\[\[.+\]\])?(.*)/)[2];
-};
-
-
-/**
- * Describes the given node.
- * @param {Node} node The node to describe.
- * @return {string} A description of the node.
- * @private
- */
-goog.testing.dom.describeNode_ = function(node) {
- if (node.nodeType == goog.dom.NodeType.TEXT) {
- return '[Text: ' + node.nodeValue + ']';
- } else {
- return '<' + node.tagName + (node.id ? ' #' + node.id : '') + ' .../>';
- }
-};
-
-
-/**
- * Assert that the html in {@code actual} is substantially similar to
- * htmlPattern. This method tests for the same set of styles, for the same
- * order of nodes, and the presence of attributes. Breaking whitespace nodes
- * are ignored. Elements can be
- * annotated with classnames corresponding to keys in goog.userAgent and will be
- * expected to show up in that user agent and expected not to show up in
- * others.
- * @param {string} htmlPattern The pattern to match.
- * @param {!Element} actual The element to check: its contents are matched
- * against the HTML pattern.
- * @param {boolean=} opt_strictAttributes If false, attributes that appear in
- * htmlPattern must be in actual, but actual can have attributes not
- * present in htmlPattern. If true, htmlPattern and actual must have the
- * same set of attributes. Default is false.
- */
-goog.testing.dom.assertHtmlContentsMatch = function(htmlPattern, actual,
- opt_strictAttributes) {
- var div = goog.dom.createDom(goog.dom.TagName.DIV);
- div.innerHTML = htmlPattern;
-
- var errorSuffix = '\nExpected\n' + htmlPattern + '\nActual\n' +
- actual.innerHTML;
-
- var actualIt = goog.iter.filter(
- goog.iter.map(new goog.dom.TagIterator(actual),
- goog.testing.dom.endTagMap_),
- goog.testing.dom.nodeFilter_);
-
- var expectedIt = goog.iter.filter(new goog.dom.NodeIterator(div),
- goog.testing.dom.nodeFilter_);
-
- var actualNode;
- var preIterated = false;
- var advanceActualNode = function() {
- // If the iterator has already been advanced, don't advance it again.
- if (!preIterated) {
- actualNode = /** @type {Node} */ (goog.iter.nextOrValue(actualIt, null));
- }
- preIterated = false;
-
- // Advance the iterator so long as it is return end tags.
- while (actualNode == goog.testing.dom.END_TAG_MARKER_) {
- actualNode = /** @type {Node} */ (goog.iter.nextOrValue(actualIt, null));
- }
- };
-
- // HACK(user): IE has unique ideas about whitespace handling when setting
- // innerHTML. This results in elision of leading whitespace in the expected
- // nodes where doing so doesn't affect visible rendering. As a workaround, we
- // remove the leading whitespace in the actual nodes where necessary.
- //
- // The collapsible variable tracks whether we should collapse the whitespace
- // in the next Text node we encounter.
- var IE_TEXT_COLLAPSE = goog.userAgent.IE && !goog.userAgent.isVersion('9');
- var collapsible = true;
-
- var number = 0;
- goog.iter.forEach(expectedIt, function(expectedNode) {
- expectedNode = /** @type {Node} */ (expectedNode);
-
- advanceActualNode();
- assertNotNull('Finished actual HTML before finishing expected HTML at ' +
- 'node number ' + number + ': ' +
- goog.testing.dom.describeNode_(expectedNode) + errorSuffix,
- actualNode);
-
- // Do no processing for expectedNode == div.
- if (expectedNode == div) {
- return;
- }
-
- assertEquals('Should have the same node type, got ' +
- goog.testing.dom.describeNode_(actualNode) + ' but expected ' +
- goog.testing.dom.describeNode_(expectedNode) + '.' + errorSuffix,
- expectedNode.nodeType, actualNode.nodeType);
-
- if (expectedNode.nodeType == goog.dom.NodeType.ELEMENT) {
- assertEquals('Tag names should match' + errorSuffix,
- expectedNode.tagName, actualNode.tagName);
- assertObjectEquals('Should have same styles' + errorSuffix,
- goog.style.parseStyleAttribute(expectedNode.style.cssText),
- goog.style.parseStyleAttribute(actualNode.style.cssText));
- goog.testing.dom.assertAttributesEqual_(errorSuffix, expectedNode,
- actualNode, !!opt_strictAttributes);
-
- if (IE_TEXT_COLLAPSE &&
- goog.style.getCascadedStyle(
- /** @type {Element} */ (actualNode), 'display') != 'inline') {
- // Text may be collapsed after any non-inline element.
- collapsible = true;
- }
- } else {
- // Concatenate text nodes until we reach a non text node.
- var actualText = actualNode.nodeValue;
- preIterated = true;
- while ((actualNode = /** @type {Node} */
- (goog.iter.nextOrValue(actualIt, null))) &&
- actualNode.nodeType == goog.dom.NodeType.TEXT) {
- actualText += actualNode.nodeValue;
- }
-
- if (IE_TEXT_COLLAPSE) {
- // Collapse the leading whitespace, unless the string consists entirely
- // of whitespace.
- if (collapsible && !goog.string.isEmpty(actualText)) {
- actualText = goog.string.trimLeft(actualText);
- }
- // Prepare to collapse whitespace in the next Text node if this one does
- // not end in a whitespace character.
- collapsible = /\s$/.test(actualText);
- }
-
- var expectedText = goog.testing.dom.getExpectedText_(expectedNode);
- if ((actualText && !goog.string.isBreakingWhitespace(actualText)) ||
- (expectedText && !goog.string.isBreakingWhitespace(expectedText))) {
- var normalizedActual = actualText.replace(/\s+/g, ' ');
- var normalizedExpected = expectedText.replace(/\s+/g, ' ');
-
- assertEquals('Text should match' + errorSuffix, normalizedExpected,
- normalizedActual);
- }
- }
-
- number++;
- });
-
- advanceActualNode();
- assertNull('Finished expected HTML before finishing actual HTML' +
- errorSuffix, goog.iter.nextOrValue(actualIt, null));
-};
-
-
-/**
- * Assert that the html in {@code actual} is substantially similar to
- * htmlPattern. This method tests for the same set of styles, and for the same
- * order of nodes. Breaking whitespace nodes are ignored. Elements can be
- * annotated with classnames corresponding to keys in goog.userAgent and will be
- * expected to show up in that user agent and expected not to show up in
- * others.
- * @param {string} htmlPattern The pattern to match.
- * @param {string} actual The html to check.
- */
-goog.testing.dom.assertHtmlMatches = function(htmlPattern, actual) {
- var div = goog.dom.createDom(goog.dom.TagName.DIV);
- div.innerHTML = actual;
-
- goog.testing.dom.assertHtmlContentsMatch(htmlPattern, div);
-};
-
-
-/**
- * Finds the first text node descendant of root with the given content. Note
- * that this operates on a text node level, so if text nodes get split this
- * may not match the user visible text. Using normalize() may help here.
- * @param {string|RegExp} textOrRegexp The text to find, or a regular
- * expression to find a match of.
- * @param {Element} root The element to search in.
- * @return {Node} The first text node that matches, or null if none is found.
- */
-goog.testing.dom.findTextNode = function(textOrRegexp, root) {
- var it = new goog.dom.NodeIterator(root);
- var ret = goog.iter.nextOrValue(goog.iter.filter(it, function(node) {
- if (node.nodeType == goog.dom.NodeType.TEXT) {
- if (goog.isString(textOrRegexp)) {
- return node.nodeValue == textOrRegexp;
- } else {
- return !!node.nodeValue.match(textOrRegexp);
- }
- } else {
- return false;
- }
- }), null);
- return /** @type {Node} */ (ret);
-};
-
-
-/**
- * Assert the end points of a range.
- *
- * Notice that "Are two ranges visually identical?" and "Do two ranges have
- * the same endpoint?" are independent questions. Two visually identical ranges
- * may have different endpoints. And two ranges with the same endpoints may
- * be visually different.
- *
- * @param {Node} start The expected start node.
- * @param {number} startOffset The expected start offset.
- * @param {Node} end The expected end node.
- * @param {number} endOffset The expected end offset.
- * @param {goog.dom.AbstractRange} range The actual range.
- */
-goog.testing.dom.assertRangeEquals = function(start, startOffset, end,
- endOffset, range) {
- assertEquals('Unexpected start node', start, range.getStartNode());
- assertEquals('Unexpected end node', end, range.getEndNode());
- assertEquals('Unexpected start offset', startOffset, range.getStartOffset());
- assertEquals('Unexpected end offset', endOffset, range.getEndOffset());
-};
-
-
-/**
- * Gets the value of a DOM attribute in deterministic way.
- * @param {!Node} node A node.
- * @param {string} name Attribute name.
- * @return {*} Attribute value.
- * @private
- */
-goog.testing.dom.getAttributeValue_ = function(node, name) {
- // These hacks avoid nondetermistic results in the following cases:
- // IE7: document.createElement('input').height returns a random number.
- // FF3: getAttribute('disabled') returns different value for <div disabled="">
- // and <div disabled="disabled">
- // WebKit: Two radio buttons with the same name can't be checked at the same
- // time, even if only one of them is in the document.
- if (goog.userAgent.WEBKIT && node.tagName == 'INPUT' &&
- node['type'] == 'radio' && name == 'checked') {
- return false;
- }
- return goog.isDef(node[name]) &&
- typeof node.getAttribute(name) != typeof node[name] ?
- node[name] : node.getAttribute(name);
-};
-
-
-/**
- * Assert that the attributes of two Nodes are the same (ignoring any
- * instances of the style attribute).
- * @param {string} errorSuffix String to add to end of error messages.
- * @param {Node} expectedNode The node whose attributes we are expecting.
- * @param {Node} actualNode The node with the actual attributes.
- * @param {boolean} strictAttributes If false, attributes that appear in
- * expectedNode must also be in actualNode, but actualNode can have
- * attributes not present in expectedNode. If true, expectedNode and
- * actualNode must have the same set of attributes.
- * @private
- */
-goog.testing.dom.assertAttributesEqual_ = function(errorSuffix,
- expectedNode, actualNode, strictAttributes) {
- if (strictAttributes) {
- goog.testing.dom.compareClassAttribute_(expectedNode, actualNode);
- }
-
- var expectedAttributes = expectedNode.attributes;
- var actualAttributes = actualNode.attributes;
-
- for (var i = 0, len = expectedAttributes.length; i < len; i++) {
- var expectedName = expectedAttributes[i].name;
- var expectedValue = goog.testing.dom.getAttributeValue_(expectedNode,
- expectedName);
-
- var actualAttribute = actualAttributes[expectedName];
- var actualValue = goog.testing.dom.getAttributeValue_(actualNode,
- expectedName);
-
- // IE enumerates attribute names in the expected node that are not present,
- // causing an undefined actualAttribute.
- if (!expectedValue && !actualValue) {
- continue;
- }
-
- if (expectedName == 'id' && goog.userAgent.IE) {
- goog.testing.dom.compareIdAttributeForIe_(
- /** @type {string} */ (expectedValue), actualAttribute,
- strictAttributes, errorSuffix);
- continue;
- }
-
- if (goog.testing.dom.ignoreAttribute_(expectedName)) {
- continue;
- }
-
- assertNotUndefined('Expected to find attribute with name ' +
- expectedName + ', in element ' +
- goog.testing.dom.describeNode_(actualNode) + errorSuffix,
- actualAttribute);
- assertEquals('Expected attribute ' + expectedName +
- ' has a different value ' + errorSuffix,
- expectedValue,
- goog.testing.dom.getAttributeValue_(actualNode, actualAttribute.name));
- }
-
- if (strictAttributes) {
- for (i = 0; i < actualAttributes.length; i++) {
- var actualName = actualAttributes[i].name;
- var actualAttribute = actualAttributes.getNamedItem(actualName);
-
- if (!actualAttribute || goog.testing.dom.ignoreAttribute_(actualName)) {
- continue;
- }
-
- assertNotUndefined('Unexpected attribute with name ' +
- actualName + ' in element ' +
- goog.testing.dom.describeNode_(actualNode) + errorSuffix,
- expectedAttributes[actualName]);
- }
- }
-};
-
-
-/**
- * Assert the class attribute of actualNode is the same as the one in
- * expectedNode, ignoring classes that are useragents.
- * @param {Node} expectedNode The DOM node whose class we expect.
- * @param {Node} actualNode The DOM node with the actual class.
- * @private
- */
-goog.testing.dom.compareClassAttribute_ = function(expectedNode,
- actualNode) {
- var classes = goog.dom.classes.get(expectedNode);
-
- var expectedClasses = [];
- for (var i = 0, len = classes.length; i < len; i++) {
- if (!(classes[i] in goog.userAgent)) {
- expectedClasses.push(classes[i]);
- }
- }
- expectedClasses.sort();
-
- var actualClasses = goog.dom.classes.get(actualNode);
- actualClasses.sort();
-
- assertArrayEquals(
- 'Expected class was: ' + expectedClasses.join(' ') +
- ', but actual class was: ' + actualNode.className,
- expectedClasses, actualClasses);
-};
-
-
-/**
- * Set of attributes IE adds to elements randomly.
- * @type {Object}
- * @private
- */
-goog.testing.dom.BAD_IE_ATTRIBUTES_ = goog.object.createSet(
- 'methods', 'CHECKED', 'dataFld', 'dataFormatAs', 'dataSrc');
-
-
-/**
- * Whether to ignore the attribute.
- * @param {string} name Name of the attribute.
- * @return {boolean} True if the attribute should be ignored.
- * @private
- */
-goog.testing.dom.ignoreAttribute_ = function(name) {
- if (name == 'style' || name == 'class') {
- return true;
- }
- return goog.userAgent.IE && goog.testing.dom.BAD_IE_ATTRIBUTES_[name];
-};
-
-
-/**
- * Compare id attributes for IE. In IE, if an element lacks an id attribute
- * in the original HTML, the element object will still have such an attribute,
- * but its value will be the empty string.
- * @param {string} expectedValue The expected value of the id attribute.
- * @param {Attr} actualAttribute The actual id attribute.
- * @param {boolean} strictAttributes Whether strict attribute checking should be
- * done.
- * @param {string} errorSuffix String to append to error messages.
- * @private
- */
-goog.testing.dom.compareIdAttributeForIe_ = function(expectedValue,
- actualAttribute, strictAttributes, errorSuffix) {
- if (expectedValue === '') {
- if (strictAttributes) {
- assertTrue('Unexpected attribute with name id in element ' +
- errorSuffix, actualAttribute.value == '');
- }
- } else {
- assertNotUndefined('Expected to find attribute with name id, in element ' +
- errorSuffix, actualAttribute);
- assertNotEquals('Expected to find attribute with name id, in element ' +
- errorSuffix, '', actualAttribute.value);
- assertEquals('Expected attribute has a different value ' + errorSuffix,
- expectedValue, actualAttribute.value);
- }
-};
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/dom_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/dom_test.html.svn-base
deleted file mode 100644
index 0d595fe..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/dom_test.html.svn-base
+++ /dev/null
@@ -1,438 +0,0 @@
-<!DOCTYPE html>
-<html lang="en" dir="ltr">
-<!--
-Copyright 2008 The Closure Library Authors. All Rights Reserved.
-
-Use of this source code is governed by the Apache License, Version 2.0.
-See the COPYING file for details.
--->
-<head>
-<!--
-This test has not yet been updated to run on IE8. See http://b/hotlist?id=36311
--->
-<!--meta http-equiv="X-UA-Compatible" content="IE=edge"-->
-<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7">
- <title>Closure Unit Tests - goog.testing.dom</title>
- <script src="../base.js"></script>
- <script>
- goog.require('goog.dom');
- goog.require('goog.dom.TagName');
- goog.require('goog.testing.dom');
- goog.require('goog.testing.jsunit');
- goog.require('goog.userAgent');
- </script>
-</head>
-<body>
-<div id="root"></div>
-<script type="text/javascript">
- var root = goog.dom.getElement('root');
-
- function setUp() {
- root.innerHTML = '';
- }
-
- function testFindNode() {
- // Test the easiest case.
- root.innerHTML = 'a<br>b';
- assertEquals(goog.testing.dom.findTextNode('a', root), root.firstChild);
- assertEquals(goog.testing.dom.findTextNode('b', root), root.lastChild);
- assertNull(goog.testing.dom.findTextNode('c', root));
- }
-
- function testFindNodeDuplicate() {
- // Test duplicate.
- root.innerHTML = 'c<br>c';
- assertEquals('Should return first duplicate',
- goog.testing.dom.findTextNode('c', root), root.firstChild);
- }
-
- function findNodeWithHierarchy() {
- // Test a more complicated hierarchy.
- root.innerHTML = '<div>a<p>b<span>c</span>d</p>e</div>';
- assertEquals(goog.dom.TagName.DIV,
- goog.testing.dom.findTextNode('a', root).parentNode.tagName);
- assertEquals(goog.dom.TagName.P,
- goog.testing.dom.findTextNode('b', root).parentNode.tagName);
- assertEquals(goog.dom.TagName.SPAN,
- goog.testing.dom.findTextNode('c', root).parentNode.tagName);
- assertEquals(goog.dom.TagName.P,
- goog.testing.dom.findTextNode('d', root).parentNode.tagName);
- assertEquals(goog.dom.TagName.DIV,
- goog.testing.dom.findTextNode('e', root).parentNode.tagName);
- }
-
- function setUpAssertHtmlMatches() {
- var tag1, tag2;
- if (goog.userAgent.IE) {
- tag1 = goog.dom.TagName.DIV;
- } else if (goog.userAgent.WEBKIT) {
- tag1 = goog.dom.TagName.P;
- tag2 = goog.dom.TagName.BR;
- } else if (goog.userAgent.GECKO) {
- tag1 = goog.dom.TagName.SPAN;
- tag2 = goog.dom.TagName.BR;
- }
-
- var parent = goog.dom.createDom(goog.dom.TagName.DIV);
- root.appendChild(parent);
- parent.style.fontSize = '2em';
- parent.style.display = 'none';
- if (!goog.userAgent.WEBKIT) {
- parent.appendChild(goog.dom.createTextNode('NonWebKitText'));
- }
-
- if (tag1) {
- var e1 = goog.dom.createDom(tag1);
- parent.appendChild(e1);
- parent = e1;
- }
- if (tag2) {
- parent.appendChild(goog.dom.createDom(tag2));
- }
- parent.appendChild(goog.dom.createTextNode('Text'));
- if (goog.userAgent.WEBKIT) {
- root.firstChild.appendChild(goog.dom.createTextNode('WebKitText'));
- }
- }
-
- function testAssertHtmlContentsMatch() {
- setUpAssertHtmlMatches();
-
- goog.testing.dom.assertHtmlContentsMatch(
- '<div style="display: none; font-size: 2em">' +
- '[[!WEBKIT]]NonWebKitText<div class="IE"><p class="WEBKIT">' +
- '<span class="GECKO"><br class="GECKO WEBKIT">Text</span></p></div>' +
- '</div>[[WEBKIT]]WebKitText',
- root);
- }
-
- function testAssertHtmlMismatchText() {
- setUpAssertHtmlMatches();
-
- var e = assertThrows('Should fail due to mismatched text', function() {
- goog.testing.dom.assertHtmlContentsMatch(
- '<div style="display: none; font-size: 2em">' +
- '[[IE GECKO]]NonWebKitText<div class="IE"><p class="WEBKIT">' +
- '<span class="GECKO"><br class="GECKO WEBKIT">Bad</span></p></div>' +
- '</div>[[WEBKIT]]Extra',
- root);
- });
- assertContains('Text should match', e.message);
- }
-
- function testAssertHtmlMismatchTag() {
- setUpAssertHtmlMatches();
-
- var e = assertThrows('Should fail due to mismatched tag', function() {
- goog.testing.dom.assertHtmlContentsMatch(
- '<span style="display: none; font-size: 2em">' +
- '[[IE GECKO]]NonWebKitText<div class="IE"><p class="WEBKIT">' +
- '<span class="GECKO"><br class="GECKO WEBKIT">Text</span></p></div>' +
- '</span>[[WEBKIT]]Extra',
- root);
- });
- assertContains('Tag names should match', e.message);
- }
-
- function testAssertHtmlMismatchStyle() {
- setUpAssertHtmlMatches();
-
- var e = assertThrows('Should fail due to mismatched style', function() {
- goog.testing.dom.assertHtmlContentsMatch(
- '<div style="display: none; font-size: 3em">' +
- '[[IE GECKO]]NonWebKitText<div class="IE"><p class="WEBKIT">' +
- '<span class="GECKO"><br class="GECKO WEBKIT">Text</span></p></div>' +
- '</div>[[WEBKIT]]Extra',
- root);
- });
- assertContains('Should have same styles', e.message);
- }
-
- function testAssertHtmlMismatchOptionalText() {
- setUpAssertHtmlMatches();
-
- var e = assertThrows('Should fail due to mismatched text', function() {
- goog.testing.dom.assertHtmlContentsMatch(
- '<div style="display: none; font-size: 2em">' +
- '[[IE GECKO]]Bad<div class="IE"><p class="WEBKIT">' +
- '<span class="GECKO"><br class="GECKO WEBKIT">Text</span></p></div>' +
- '</div>[[WEBKIT]]Bad',
- root);
- });
- assertContains('Text should match', e.message);
- }
-
- function testAssertHtmlMismatchExtraActualAfterText() {
- root.innerHTML = '<div>abc</div>def';
-
- var e = assertThrows('Should fail due to extra actual nodes', function() {
- goog.testing.dom.assertHtmlContentsMatch('<div>abc</div>', root);
- });
- assertContains('Finished expected HTML before', e.message);
- }
-
- function testAssertHtmlMismatchExtraActualAfterElement() {
- root.innerHTML = '<br>def';
-
- var e = assertThrows('Should fail due to extra actual nodes', function() {
- goog.testing.dom.assertHtmlContentsMatch('<br>', root);
- });
- assertContains('Finished expected HTML before', e.message);
- }
-
- function testAssertHtmlMatchesWithSplitTextNodes() {
- root.appendChild(goog.dom.createTextNode('1'));
- root.appendChild(goog.dom.createTextNode('2'));
- root.appendChild(goog.dom.createTextNode('3'));
- goog.testing.dom.assertHtmlContentsMatch('123', root);
- }
-
- function testAssertHtmlMatchesWithDifferentlyOrderedAttributes() {
- root.innerHTML = '<div foo="a" bar="b" class="className"></div>';
-
- goog.testing.dom.assertHtmlContentsMatch(
- '<div bar="b" class="className" foo="a"></div>', root, true);
- }
-
- function testAssertHtmlMismatchWithDifferentNumberOfAttributes() {
- root.innerHTML = '<div foo="a" bar="b"></div>';
-
- var e = assertThrows(function() {
- goog.testing.dom.assertHtmlContentsMatch(
- '<div foo="a"></div>', root, true);
- });
- assertContains('Unexpected attribute with name bar in element', e.message);
- }
-
- function testAssertHtmlMismatchWithDifferentAttributeNames() {
- root.innerHTML = '<div foo="a" bar="b"></div>';
-
- var e = assertThrows(function() {
- goog.testing.dom.assertHtmlContentsMatch(
- '<div foo="a" baz="b"></div>', root, true);
- });
- assertContains('Expected to find attribute with name baz', e.message);
- }
-
- function testAssertHtmlMismatchWithDifferentClassNames() {
- root.innerHTML = '<div class="className1"></div>';
-
- var e = assertThrows(function() {
- goog.testing.dom.assertHtmlContentsMatch(
- '<div class="className2"></div>', root, true);
- });
- assertContains(
- 'Expected class was: className2, but actual class was: className1',
- e.message);
- }
-
- function testAssertHtmlMatchesWithClassNameAndUserAgentSpecified() {
- root.innerHTML =
- '<div>' + (goog.userAgent.GECKO ? '<div class="foo"></div>' : '') +
- '</div>';
-
- goog.testing.dom.assertHtmlContentsMatch(
- '<div><div class="foo GECKO"></div></div>',
- root, true);
- }
-
- function testAssertHtmlMatchesWithClassesInDifferentOrder() {
- root.innerHTML = '<div class="class1 class2"></div>';
-
- goog.testing.dom.assertHtmlContentsMatch(
- '<div class="class2 class1"></div>', root, true);
- }
-
- function testAssertHtmlMismatchWithDifferentAttributeValues() {
- root.innerHTML = '<div foo="b" bar="a"></div>';
-
- var e = assertThrows(function() {
- goog.testing.dom.assertHtmlContentsMatch(
- '<div foo="a" bar="a"></div>', root, true);
- });
- assertContains('Expected attribute foo has a different value', e.message);
- }
-
- function testAssertHtmlMatchesWhenStrictAttributesIsFalse() {
- root.innerHTML = '<div foo="a" bar="b"></div>';
-
- goog.testing.dom.assertHtmlContentsMatch('<div foo="a"></div>', root);
- }
-
- function testAssertHtmlMatchesForMethodsAttribute() {
- root.innerHTML = '<a methods="get"></a>';
-
- goog.testing.dom.assertHtmlContentsMatch('<a></a>', root);
- goog.testing.dom.assertHtmlContentsMatch('<a methods="get"></a>', root);
- goog.testing.dom.assertHtmlContentsMatch('<a methods="get"></a>', root,
- true);
- }
-
- function testAssertHtmlMatchesForMethodsAttribute() {
- root.innerHTML = '<input></input>';
-
- goog.testing.dom.assertHtmlContentsMatch('<input></input>', root);
- goog.testing.dom.assertHtmlContentsMatch('<input></input>', root, true);
- }
-
- function testAssertHtmlMatchesForIdAttribute() {
- root.innerHTML = '<div id="foo"></div>';
-
- goog.testing.dom.assertHtmlContentsMatch('<div></div>', root);
- goog.testing.dom.assertHtmlContentsMatch('<div id="foo"></div>', root);
- goog.testing.dom.assertHtmlContentsMatch('<div id="foo"></div>', root,
- true);
- }
-
- function testAssertHtmlMatchesWhenIdIsNotSpecified() {
- root.innerHTML = '<div id="someId"></div>';
-
- goog.testing.dom.assertHtmlContentsMatch('<div></div>', root);
- }
-
- function testAssertHtmlMismatchWhenIdIsNotSpecified() {
- root.innerHTML = '<div id="someId"></div>';
-
- var e = assertThrows(function() {
- goog.testing.dom.assertHtmlContentsMatch('<div></div>', root, true);
- });
- assertContains('Unexpected attribute with name id in element', e.message);
- }
-
- function testAssertHtmlMismatchWhenIdIsSpecified() {
- root.innerHTML = '<div></div>';
-
- var e = assertThrows(function() {
- goog.testing.dom.assertHtmlContentsMatch('<div id="someId"></div>', root);
- });
- assertContains('Expected to find attribute with name id, in element',
- e.message);
-
- e = assertThrows(function() {
- goog.testing.dom.assertHtmlContentsMatch('<div id="someId"></div>', root,
- true);
- });
- assertContains('Expected to find attribute with name id, in element',
- e.message);
- }
-
- function testAssertHtmlMatchesWhenIdIsEmpty() {
- root.innerHTML = '<div></div>';
-
- goog.testing.dom.assertHtmlContentsMatch('<div></div>', root);
- goog.testing.dom.assertHtmlContentsMatch('<div></div>', root, true);
- }
-
- function testAssertHtmlMatchesWithDisabledAttribute() {
- var disabledShortest = '<input disabled>';
- var disabledShort = '<input DISABLED="">';
- var disabledLong = '<input disabled="disabled">';
- var enabled = '<input>';
-
- root.innerHTML = disabledLong;
- goog.testing.dom.assertHtmlContentsMatch(disabledShortest, root, true);
- goog.testing.dom.assertHtmlContentsMatch(disabledShort, root, true);
- goog.testing.dom.assertHtmlContentsMatch(disabledLong, root, true);
-
-
- var e = assertThrows('Should fail due to mismatched text', function() {
- goog.testing.dom.assertHtmlContentsMatch(enabled, root, true);
- });
- // Attribute value mismatch in IE.
- // Unexpected attribute error in other browsers.
- assertContains('disabled', e.message);
- }
-
- function testAssertHtmlMatchesWithCheckedAttribute() {
- var checkedShortest = '<input type="radio" name="x" checked>';
- var checkedShort = '<input type="radio" name="x" CHECKED="">';
- var checkedLong = '<input type="radio" name="x" checked="checked">';
- var unchecked = '<input type="radio" name="x">';
-
- root.innerHTML = checkedLong;
- goog.testing.dom.assertHtmlContentsMatch(checkedShortest, root, true);
- goog.testing.dom.assertHtmlContentsMatch(checkedShort, root, true);
- goog.testing.dom.assertHtmlContentsMatch(checkedLong, root, true);
- if (!goog.userAgent.IE) {
- // CHECKED attribute is ignored because it's among BAD_IE_ATTRIBUTES_.
- var e = assertThrows('Should fail due to mismatched text', function() {
- goog.testing.dom.assertHtmlContentsMatch(unchecked, root, true);
- });
- assertContains('Unexpected attribute with name checked', e.message);
- }
- }
-
- function testAssertHtmlMatchesWithWhitespace() {
- root.innerHTML = '';
- root.appendChild(goog.dom.createTextNode(' A '));
- goog.testing.dom.assertHtmlContentsMatch(' A ', root);
-
- root.innerHTML = '';
- root.appendChild(goog.dom.createTextNode(' A '));
- root.appendChild(goog.dom.createDom('span', null, ' B '));
- root.appendChild(goog.dom.createTextNode(' C '));
- goog.testing.dom.assertHtmlContentsMatch(
- ' A <span> B </span> C ', root);
-
- root.innerHTML = '';
- root.appendChild(goog.dom.createTextNode(' A'));
- root.appendChild(goog.dom.createDom('span', null, ' B'));
- root.appendChild(goog.dom.createTextNode(' C'));
- goog.testing.dom.assertHtmlContentsMatch(
- ' A<span> B</span> C', root);
- }
-
- function testAssertHtmlMatchesWithWhitespaceAndNesting() {
- root.innerHTML = '';
- root.appendChild(goog.dom.createDom('div', null,
- goog.dom.createDom('b', null, ' A '),
- goog.dom.createDom('b', null, ' B ')));
- root.appendChild(goog.dom.createDom('div', null,
- goog.dom.createDom('b', null, ' C '),
- goog.dom.createDom('b', null, ' D ')));
-
- goog.testing.dom.assertHtmlContentsMatch(
- '<div><b> A </b><b> B </b></div>' +
- '<div><b> C </b><b> D </b></div>', root);
-
- root.innerHTML = '';
- root.appendChild(goog.dom.createDom('b', null,
- goog.dom.createDom('b', null,
- goog.dom.createDom('b', null, ' A '))));
- root.appendChild(goog.dom.createDom('b', null, ' B '));
-
- goog.testing.dom.assertHtmlContentsMatch(
- '<b><b><b> A </b></b></b><b> B </b>', root);
-
- root.innerHTML = '';
- root.appendChild(goog.dom.createDom('div', null,
- goog.dom.createDom('b', null,
- goog.dom.createDom('b', null, ' A '))));
- root.appendChild(goog.dom.createDom('b', null, ' B '));
-
- goog.testing.dom.assertHtmlContentsMatch(
- '<div><b><b> A </b></b></div><b> B </b>', root);
-
- root.innerHTML = '&nbsp;';
- goog.testing.dom.assertHtmlContentsMatch(
- '&nbsp;', root);
- }
-
- function testAssertHtmlMatches() {
- // Since assertHtmlMatches is based on assertHtmlContentsMatch, we leave the
- // majority of edge case testing to the above. Here we just do a sanity
- // check.
- goog.testing.dom.assertHtmlMatches('<div>abc</div>', '<div>abc</div>');
- goog.testing.dom.assertHtmlMatches('<div>abc</div>', '<div>abc</div> ');
- goog.testing.dom.assertHtmlMatches(
- '<div style="font-size: 1px; color: red">abc</div>',
- '<div style="color: red; font-size: 1px;;">abc</div>');
-
- var e = assertThrows('Should fail due to mismatched text', function() {
- goog.testing.dom.assertHtmlMatches('<div>abc</div>', '<div>abd</div>');
- });
- assertContains('Text should match', e.message);
- }
-</script>
-</body>
-</html>
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/expectedfailures.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/expectedfailures.js.svn-base
deleted file mode 100644
index 33fc553..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/expectedfailures.js.svn-base
+++ /dev/null
@@ -1,236 +0,0 @@
-// Copyright 2008 The Closure Library Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS-IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/**
- * @fileoverview Helper class to allow for expected unit test failures.
- *
- * @author robbyw@google.com (Robby Walker)
- */
-
-goog.provide('goog.testing.ExpectedFailures');
-
-goog.require('goog.debug.DivConsole');
-goog.require('goog.debug.Logger');
-goog.require('goog.dom');
-goog.require('goog.dom.TagName');
-goog.require('goog.events');
-goog.require('goog.events.EventType');
-goog.require('goog.style');
-goog.require('goog.testing.JsUnitException');
-goog.require('goog.testing.TestCase');
-goog.require('goog.testing.asserts');
-
-
-
-/**
- * Helper class for allowing some unit tests to fail, particularly designed to
- * mark tests that should be fixed on a given browser.
- *
- * <pre>
- * var expectedFailures = new goog.testing.ExpectedFailures();
- *
- * function tearDown() {
- * expectedFailures.handleTearDown();
- * }
- *
- * function testSomethingThatBreaksInWebKit() {
- * expectedFailures.expectFailureFor(goog.userAgent.WEBKIT);
- *
- * try {
- * ...
- * assert(somethingThatFailsInWebKit);
- * ...
- * } catch (e) {
- * expectedFailures.handleException(e);
- * }
- * }
- * </pre>
- *
- * @constructor
- */
-goog.testing.ExpectedFailures = function() {
- goog.testing.ExpectedFailures.setUpConsole_();
- this.reset_();
-};
-
-
-/**
- * The lazily created debugging console.
- * @type {goog.debug.DivConsole?}
- * @private
- */
-goog.testing.ExpectedFailures.console_ = null;
-
-
-/**
- * Logger for the expected failures.
- * @type {goog.debug.Logger}
- * @private
- */
-goog.testing.ExpectedFailures.prototype.logger_ =
- goog.debug.Logger.getLogger('goog.testing.ExpectedFailures');
-
-
-/**
- * Whether or not we are expecting failure.
- * @type {boolean}
- * @private
- */
-goog.testing.ExpectedFailures.prototype.expectingFailure_;
-
-
-/**
- * The string to emit upon an expected failure.
- * @type {string}
- * @private
- */
-goog.testing.ExpectedFailures.prototype.failureMessage_;
-
-
-/**
- * An array of suppressed failures.
- * @type {Array}
- * @private
- */
-goog.testing.ExpectedFailures.prototype.suppressedFailures_;
-
-
-/**
- * Sets up the debug console, if it isn't already set up.
- * @private
- */
-goog.testing.ExpectedFailures.setUpConsole_ = function() {
- if (!goog.testing.ExpectedFailures.console_) {
- var xButton = goog.dom.createDom(goog.dom.TagName.DIV, {
- 'style': 'position: absolute; border-left:1px solid #333;' +
- 'border-bottom:1px solid #333; right: 0; top: 0; width: 1em;' +
- 'height: 1em; cursor: pointer; background-color: #cde;' +
- 'text-align: center; color: black'
- }, 'X');
- var div = goog.dom.createDom(goog.dom.TagName.DIV, {
- 'style': 'position: absolute; border: 1px solid #333; right: 10px;' +
- 'top : 10px; width: 400px; display: none'
- }, xButton);
- document.body.appendChild(div);
- goog.events.listen(xButton, goog.events.EventType.CLICK, function() {
- goog.style.showElement(div, false);
- });
-
- goog.testing.ExpectedFailures.console_ = new goog.debug.DivConsole(div);
- goog.testing.ExpectedFailures.prototype.logger_.addHandler(
- goog.bind(goog.style.showElement, null, div, true));
- goog.testing.ExpectedFailures.prototype.logger_.addHandler(
- goog.bind(goog.testing.ExpectedFailures.console_.addLogRecord,
- goog.testing.ExpectedFailures.console_));
- }
-};
-
-
-/**
- * Register to expect failure for the given condition. Multiple calls to this
- * function act as a boolean OR. The first applicable message will be used.
- * @param {boolean} condition Whether to expect failure.
- * @param {string=} opt_message Descriptive message of this expected failure.
- */
-goog.testing.ExpectedFailures.prototype.expectFailureFor = function(
- condition, opt_message) {
- this.expectingFailure_ = this.expectingFailure_ || condition;
- if (condition) {
- this.failureMessage_ = this.failureMessage_ || opt_message || '';
- }
-};
-
-
-/**
- * Determines if the given exception was expected.
- * @param {Object} ex The exception to check.
- * @return {boolean} Whether the exception was expected.
- */
-goog.testing.ExpectedFailures.prototype.isExceptionExpected = function(ex) {
- return this.expectingFailure_ && ex instanceof goog.testing.JsUnitException;
-};
-
-
-/**
- * Handle an exception, suppressing it if it is a unit test failure that we
- * expected.
- * @param {Error} ex The exception to handle.
- */
-goog.testing.ExpectedFailures.prototype.handleException = function(ex) {
- if (this.isExceptionExpected(ex)) {
- this.logger_.info('Suppressing test failure in ' +
- goog.testing.TestCase.currentTestName + ':' +
- (this.failureMessage_ ? '\n(' + this.failureMessage_ + ')' : ''),
- ex);
- this.suppressedFailures_.push(ex);
- return;
- }
-
- // Rethrow the exception if we weren't expecting it or if it is a normal
- // exception.
- throw ex;
-};
-
-
-/**
- * Run the given function, catching any expected failures.
- * @param {Function} func The function to run.
- * @param {boolean=} opt_lenient Whether to ignore if the expected failures
- * didn't occur. In this case a warning will be logged in handleTearDown.
- */
-goog.testing.ExpectedFailures.prototype.run = function(func, opt_lenient) {
- try {
- func();
- } catch (ex) {
- this.handleException(ex);
- }
-
- if (!opt_lenient && this.expectingFailure_ &&
- !this.suppressedFailures_.length) {
- fail(this.getExpectationMessage_());
- }
-};
-
-
-/**
- * @return {string} A warning describing an expected failure that didn't occur.
- * @private
- */
-goog.testing.ExpectedFailures.prototype.getExpectationMessage_ = function() {
- return 'Expected a test failure in \'' +
- goog.testing.TestCase.currentTestName + '\' but the test passed.';
-};
-
-
-/**
- * Handle the tearDown phase of a test, alerting the user if an expected test
- * was not suppressed.
- */
-goog.testing.ExpectedFailures.prototype.handleTearDown = function() {
- if (this.expectingFailure_ && !this.suppressedFailures_.length) {
- this.logger_.warning(this.getExpectationMessage_());
- }
- this.reset_();
-};
-
-
-/**
- * Reset internal state.
- * @private
- */
-goog.testing.ExpectedFailures.prototype.reset_ = function() {
- this.expectingFailure_ = false;
- this.failureMessage_ = '';
- this.suppressedFailures_ = [];
-};
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/expectedfailures_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/expectedfailures_test.html.svn-base
deleted file mode 100644
index 899d6c9..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/expectedfailures_test.html.svn-base
+++ /dev/null
@@ -1,122 +0,0 @@
-<!DOCTYPE html>
-<html>
-<!--
-Copyright 2008 The Closure Library Authors. All Rights Reserved.
-
-Use of this source code is governed by the Apache License, Version 2.0.
-See the COPYING file for details.
--->
-<head>
-<meta http-equiv="X-UA-Compatible" content="IE=edge">
-<title>Closure Unit Tests - goog.testing.ExpectedFailures</title>
-<script src="../base.js"></script>
-<script>
- goog.require('goog.testing.ExpectedFailures');
- goog.require('goog.testing.jsunit');
-</script>
-</head>
-<body>
-<script type="text/javascript">
- var count, expectedFailures, lastLevel, lastMessage;
-
- // Stub out the logger.
- goog.testing.ExpectedFailures.prototype.logger_.log = function(level,
- message) {
- lastLevel = level;
- lastMessage = message;
- count++;
- };
-
- function setUp() {
- expectedFailures = new goog.testing.ExpectedFailures();
- count = 0;
- lastLevel = lastMessage = '';
- }
-
- // Individual test methods.
-
- function testNoExpectedFailure() {
- expectedFailures.handleTearDown()
- }
-
- function testPreventExpectedFailure() {
- expectedFailures.expectFailureFor(true);
-
- expectedFailures.handleException(new goog.testing.JsUnitException('', ''));
- assertEquals('Should have logged a message', 1, count);
- assertEquals('Should have logged an info message',
- goog.debug.Logger.Level.INFO, lastLevel);
- assertContains('Should log a suppression message',
- 'Suppressing test failure', lastMessage);
-
- expectedFailures.handleTearDown();
- assertEquals('Should not have logged another message', 1, count);
- }
-
- function testDoNotPreventException() {
- var ex = 'exception';
- expectedFailures.expectFailureFor(false);
- var e = assertThrows('Should have rethrown exception', function() {
- expectedFailures.handleException(ex);
- });
- assertEquals('Should rethrow same exception', ex, e);
- }
-
- function testExpectedFailureDidNotOccur() {
- expectedFailures.expectFailureFor(true);
-
- expectedFailures.handleTearDown();
- assertEquals('Should have logged a message', 1, count);
- assertEquals('Should have logged a warning',
- goog.debug.Logger.Level.WARNING, lastLevel);
- assertContains('Should log a suppression message',
- 'Expected a test failure', lastMessage);
- }
-
- function testRun() {
- expectedFailures.expectFailureFor(true);
-
- expectedFailures.run(function() {
- fail('Expected failure');
- });
-
- assertEquals('Should have logged a message', 1, count);
- assertEquals('Should have logged an info message',
- goog.debug.Logger.Level.INFO, lastLevel);
- assertContains('Should log a suppression message',
- 'Suppressing test failure', lastMessage);
-
- expectedFailures.handleTearDown();
- assertEquals('Should not have logged another message', 1, count);
- }
-
- function testRunStrict() {
- expectedFailures.expectFailureFor(true);
-
- var ex = assertThrows(function() {
- expectedFailures.run(function() {
- // Doesn't fail!
- });
- });
- assertContains(
- "Expected a test failure in 'testRunStrict' but the test passed.",
- ex.message);
- }
-
- function testRunLenient() {
- expectedFailures.expectFailureFor(true);
-
- expectedFailures.run(function() {
- // Doesn't fail!
- }, true);
- expectedFailures.handleTearDown();
- assertEquals('Should have logged a message', 1, count);
- assertEquals('Should have logged a warning',
- goog.debug.Logger.Level.WARNING, lastLevel);
- assertContains('Should log a suppression message',
- 'Expected a test failure', lastMessage);
- }
-
-</script>
-</body>
-</html>
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/functionmock.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/functionmock.js.svn-base
deleted file mode 100644
index f00bb61..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/functionmock.js.svn-base
+++ /dev/null
@@ -1,177 +0,0 @@
-// Copyright 2008 The Closure Library Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS-IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/**
- * @fileoverview Enable mocking of functions not attached to objects
- * whether they be global / top-level or anonymous methods / closures.
- *
- * See the unit tests for usage.
- *
- */
-
-goog.provide('goog.testing');
-goog.provide('goog.testing.FunctionMock');
-goog.provide('goog.testing.GlobalFunctionMock');
-goog.provide('goog.testing.MethodMock');
-
-goog.require('goog.object');
-goog.require('goog.testing.LooseMock');
-goog.require('goog.testing.Mock');
-goog.require('goog.testing.MockInterface');
-goog.require('goog.testing.PropertyReplacer');
-goog.require('goog.testing.StrictMock');
-
-
-/**
- * Class used to mock a function. Useful for mocking closures and anonymous
- * callbacks etc. Creates a function object that extends goog.testing.Mock.
- * @param {string=} opt_functionName The optional name of the function to mock.
- * Set to '[anonymous mocked function]' if not passed in.
- * @param {number=} opt_strictness One of goog.testing.Mock.LOOSE or
- * goog.testing.mock.STRICT. The default is STRICT.
- * @return {goog.testing.MockInterface} The mocked function.
- * @suppress {missingProperties} Mocks do not fit in the type system well.
- */
-goog.testing.FunctionMock = function(opt_functionName, opt_strictness) {
- var fn = function() {
- var args = Array.prototype.slice.call(arguments);
- args.splice(0, 0, opt_functionName || '[anonymous mocked function]');
- return fn.$mockMethod.apply(fn, args);
- };
- var base = opt_strictness === goog.testing.Mock.LOOSE ?
- goog.testing.LooseMock : goog.testing.StrictMock;
- goog.object.extend(fn, new base({}));
-
- return /** @type {goog.testing.MockInterface} */ (fn);
-};
-
-
-/**
- * Mocks an existing function. Creates a goog.testing.FunctionMock
- * and registers it in the given scope with the name specified by functionName.
- * @param {Object} scope The scope of the method to be mocked out.
- * @param {string} functionName The name of the function we're going to mock.
- * @param {number=} opt_strictness One of goog.testing.Mock.LOOSE or
- * goog.testing.mock.STRICT. The default is STRICT.
- * @return {goog.testing.MockInterface} The mocked method.
- */
-goog.testing.MethodMock = function(scope, functionName, opt_strictness) {
- if (!(functionName in scope)) {
- throw Error(functionName + ' is not a property of the given scope.');
- }
-
- var fn = goog.testing.FunctionMock(functionName, opt_strictness);
-
- fn.$propertyReplacer_ = new goog.testing.PropertyReplacer();
- fn.$propertyReplacer_.set(scope, functionName, fn);
- fn.$tearDown = goog.testing.MethodMock.$tearDown;
-
- return fn;
-};
-
-
-/**
- * Resets the global function that we mocked back to its original state.
- * @this {goog.testing.MockInterface}
- */
-goog.testing.MethodMock.$tearDown = function() {
- this.$propertyReplacer_.reset();
-};
-
-
-/**
- * Mocks a global / top-level function. Creates a goog.testing.MethodMock
- * in the global scope with the name specified by functionName.
- * @param {string} functionName The name of the function we're going to mock.
- * @param {number=} opt_strictness One of goog.testing.Mock.LOOSE or
- * goog.testing.mock.STRICT. The default is STRICT.
- * @return {goog.testing.MockInterface} The mocked global function.
- */
-goog.testing.GlobalFunctionMock = function(functionName, opt_strictness) {
- return goog.testing.MethodMock(goog.global, functionName, opt_strictness);
-};
-
-
-/**
- * Convenience method for creating a mock for a function.
- * @param {string=} opt_functionName The optional name of the function to mock
- * set to '[anonymous mocked function]' if not passed in.
- * @param {number=} opt_strictness One of goog.testing.Mock.LOOSE or
- * goog.testing.mock.STRICT. The default is STRICT.
- * @return {goog.testing.MockInterface} The mocked function.
- */
-goog.testing.createFunctionMock = function(opt_functionName, opt_strictness) {
- return goog.testing.FunctionMock(opt_functionName, opt_strictness);
-};
-
-
-/**
- * Convenience method for creating a mock for a method.
- * @param {Object} scope The scope of the method to be mocked out.
- * @param {string} functionName The name of the function we're going to mock.
- * @param {number=} opt_strictness One of goog.testing.Mock.LOOSE or
- * goog.testing.mock.STRICT. The default is STRICT.
- * @return {goog.testing.MockInterface} The mocked global function.
- */
-goog.testing.createMethodMock = function(scope, functionName, opt_strictness) {
- return goog.testing.MethodMock(scope, functionName, opt_strictness);
-};
-
-
-/**
- * Convenience method for creating a mock for a constructor. Copies class
- * members to the mock.
- *
- * <p>When mocking a constructor to return a mocked instance, remember to create
- * the instance mock before mocking the constructor. If you mock the constructor
- * first, then the mock framework will be unable to examine the prototype chain
- * when creating the mock instance.
- * @param {Object} scope The scope of the constructor to be mocked out.
- * @param {string} constructorName The name of the constructor we're going to
- * mock.
- * @param {number=} opt_strictness One of goog.testing.Mock.LOOSE or
- * goog.testing.mock.STRICT. The default is STRICT.
- * @return {goog.testing.MockInterface} The mocked constructor.
- */
-goog.testing.createConstructorMock = function(scope, constructorName,
- opt_strictness) {
- var realConstructor = scope[constructorName];
- var constructorMock = goog.testing.MethodMock(scope, constructorName,
- opt_strictness);
-
- // Copy class members from the real constructor to the mock. Do not copy
- // the closure superClass_ property (see goog.inherits), the built-in
- // prototype property, or properties added to Function.prototype
- // (see goog.MODIFY_FUNCTION_PROTOTYPES in closure/base.js).
- for (var property in realConstructor) {
- if (property != 'superClass_' &&
- property != 'prototype' &&
- realConstructor.hasOwnProperty(property)) {
- constructorMock[property] = realConstructor[property];
- }
- }
- return constructorMock;
-};
-
-
-/**
- * Convenience method for creating a mocks for a global / top-level function.
- * @param {string} functionName The name of the function we're going to mock.
- * @param {number=} opt_strictness One of goog.testing.Mock.LOOSE or
- * goog.testing.mock.STRICT. The default is STRICT.
- * @return {goog.testing.MockInterface} The mocked global function.
- */
-goog.testing.createGlobalFunctionMock = function(functionName, opt_strictness) {
- return goog.testing.GlobalFunctionMock(functionName, opt_strictness);
-};
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/functionmock_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/functionmock_test.html.svn-base
deleted file mode 100644
index e2e2515..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/functionmock_test.html.svn-base
+++ /dev/null
@@ -1,511 +0,0 @@
-<!DOCTYPE html>
-<!--
-
- Test mocking global / top-level functions
-
--->
-
-<html>
-<!--
-Copyright 2008 The Closure Library Authors. All Rights Reserved.
-
-Use of this source code is governed by the Apache License, Version 2.0.
-See the COPYING file for details.
--->
-<head>
-<meta http-equiv="X-UA-Compatible" content="IE=edge">
-<title>Global Mock Unit Test</title>
-<script src="../base.js"></script>
-<script>
- goog.require('goog.array');
- goog.require('goog.testing.asserts');
- goog.require('goog.testing.FunctionMock');
- goog.require('goog.testing.GlobalFunctionMock');
- goog.require('goog.testing.MethodMock');
- goog.require('goog.testing.Mock');
- goog.require('goog.testing.StrictMock');
- goog.require('goog.testing.jsunit');
-</script>
-</head>
-<body>
-<script>
-
-// Global scope so we can tear it down safely
-var mockGlobal;
-
-function tearDown() {
- if (mockGlobal) {
- mockGlobal.$tearDown();
- }
-}
-
-
-//----- Tests for goog.testing.FunctionMock
-
-function testMockFunctionCallOrdering() {
- var doOneTest = function(mockFunction, success, expected_args, actual_args) {
- goog.array.forEach(expected_args, function(arg) { mockFunction(arg); });
- mockFunction.$replay();
- var callFunction = function() {
- goog.array.forEach(actual_args, function(arg) { mockFunction(arg); });
- mockFunction.$verify();
- };
- if (success) {
- callFunction();
- } else {
- assertThrows(callFunction);
- }
- };
-
- var doTest = function(strict_ok, loose_ok, expected_args, actual_args) {
- doOneTest(goog.testing.createFunctionMock(), strict_ok,
- expected_args, actual_args);
- doOneTest(goog.testing.createFunctionMock('name'), strict_ok,
- expected_args, actual_args);
- doOneTest(goog.testing.createFunctionMock('name', goog.testing.Mock.STRICT),
- strict_ok, expected_args, actual_args);
- doOneTest(goog.testing.createFunctionMock('name', goog.testing.Mock.LOOSE),
- loose_ok, expected_args, actual_args);
- }
-
- doTest(true, true, [1, 2], [1, 2]);
- doTest(false, true, [1, 2], [2, 1]);
- doTest(false, false, [1, 2], [2, 2]);
- doTest(false, false, [1, 2], [1]);
- doTest(false, false, [1, 2], [1, 1]);
- doTest(false, false, [1, 2], [1]);
-}
-
-function testMocksFunctionWithNoArgs() {
- var mockFoo = goog.testing.createFunctionMock();
- mockFoo();
- mockFoo.$replay();
- mockFoo();
- mockFoo.$verify();
-}
-
-function testMocksFunctionWithOneArg() {
- var mockFoo = goog.testing.createFunctionMock();
- mockFoo('x');
- mockFoo.$replay();
- mockFoo('x');
- mockFoo.$verify();
-}
-
-function testMocksFunctionWithMultipleArgs() {
- var mockFoo = goog.testing.createFunctionMock();
- mockFoo('x', 'y');
- mockFoo.$replay();
- mockFoo('x', 'y');
- mockFoo.$verify();
-}
-
-function testFailsIfCalledWithIncorrectArgs() {
- var mockFoo = goog.testing.createFunctionMock();
-
- mockFoo();
- mockFoo.$replay();
- assertThrows(function() {mockFoo('x');});
- mockFoo.$reset();
-
- mockFoo('x');
- mockFoo.$replay();
- assertThrows(function() {mockFoo();});
- mockFoo.$reset();
-
- mockFoo('x');
- mockFoo.$replay();
- assertThrows(function() {mockFoo('x', 'y');});
- mockFoo.$reset();
-
- mockFoo('x', 'y');
- mockFoo.$replay();
- assertThrows(function() {mockFoo('x');});
- mockFoo.$reset();
-
- mockFoo('correct');
- mockFoo.$replay();
- assertThrows(function() {mockFoo('wrong');});
- mockFoo.$reset();
-
- mockFoo('correct', 'args');
- mockFoo.$replay();
- assertThrows(function() {mockFoo('wrong', 'args');});
- mockFoo.$reset();
-}
-
-function testMocksFunctionWithReturnValue() {
- var mockFoo = goog.testing.createFunctionMock();
- mockFoo().$returns('bar');
- mockFoo.$replay();
- assertEquals('bar', mockFoo());
- mockFoo.$verify();
-}
-
-function testFunctionMockWorksWhenPassedAsACallback() {
- var invoker = {
- register: function(callback) {
- this.callback = callback;
- },
-
- invoke: function(args) {
- return this.callback(args);
- }
- };
-
- var mockFunction = goog.testing.createFunctionMock();
- mockFunction('bar').$returns('baz');
-
- mockFunction.$replay();
- invoker.register(mockFunction);
- assertEquals('baz', invoker.invoke('bar'));
- mockFunction.$verify();
-}
-
-function testFunctionMockQuacksLikeAStrictMock() {
- var mockFunction = goog.testing.createFunctionMock();
- assertQuacksLike(mockFunction, goog.testing.StrictMock);
-}
-
-
-//----- Global functions for goog.testing.GlobalFunctionMock to mock
-
-function globalFoo() {
- return 'I am Spartacus!';
-}
-
-function globalBar(who, what) {
- return [who, 'is', what].join(' ');
-}
-
-
-//----- Tests for goog.testing.createGlobalFunctionMock
-
-function testMocksGlobalFunctionWithNoArgs() {
- mockGlobal = goog.testing.createGlobalFunctionMock('globalFoo');
- mockGlobal().$returns('No, I am Spartacus!');
-
- mockGlobal.$replay();
- assertEquals('No, I am Spartacus!', globalFoo());
- mockGlobal.$verify();
-}
-
-function testMocksGlobalFunctionUsingGlobalName() {
- goog.testing.createGlobalFunctionMock('globalFoo');
- globalFoo().$returns('No, I am Spartacus!');
-
- globalFoo.$replay();
- assertEquals('No, I am Spartacus!', globalFoo());
- globalFoo.$verify();
- globalFoo.$tearDown();
-}
-
-function testMocksGlobalFunctionWithArgs() {
- var mockReturnValue = 'Noam is Chomsky!';
- mockGlobal = goog.testing.createGlobalFunctionMock('globalBar');
- mockGlobal('Noam', 'Spartacus').$returns(mockReturnValue);
-
- mockGlobal.$replay();
- assertEquals(mockReturnValue, globalBar('Noam', 'Spartacus'));
- mockGlobal.$verify();
-}
-
-function testGlobalFunctionMockFailsWithIncorrectArgs() {
- mockGlobal = goog.testing.createGlobalFunctionMock('globalBar');
- mockGlobal('a', 'b');
-
- mockGlobal.$replay();
-
- assertThrows('Mock should have failed because of incorrect arguments',
- function() {globalBar('b', 'a')});
-}
-
-function testGlobalFunctionMockQuacksLikeAFunctionMock() {
- mockGlobal = goog.testing.createGlobalFunctionMock('globalFoo');
- assertQuacksLike(mockGlobal, goog.testing.FunctionMock);
-}
-
-function testMockedFunctionsAvailableInGlobalAndGoogGlobalAndWindowScope() {
- mockGlobal = goog.testing.createGlobalFunctionMock('globalFoo');
-
- // we expect this call 3 times through global, goog.global and window scope
- mockGlobal().$times(3);
-
- mockGlobal.$replay();
- goog.global.globalFoo();
- window.globalFoo();
- globalFoo();
- mockGlobal.$verify();
-}
-
-function testTearDownRestoresOriginalGlobalFunction() {
- mockGlobal = goog.testing.createGlobalFunctionMock('globalFoo');
- mockGlobal().$returns('No, I am Spartacus!');
-
- mockGlobal.$replay();
- assertEquals('No, I am Spartacus!', globalFoo());
- mockGlobal.$tearDown();
- assertEquals('I am Spartacus!', globalFoo());
- mockGlobal.$verify();
-}
-
-function testTearDownHandlesMultipleMocking() {
- var mock1 = goog.testing.createGlobalFunctionMock('globalFoo');
- var mock2 = goog.testing.createGlobalFunctionMock('globalFoo');
- var mock3 = goog.testing.createGlobalFunctionMock('globalFoo');
- mock1().$returns('No, I am Spartacus 1!');
- mock2().$returns('No, I am Spartacus 2!');
- mock3().$returns('No, I am Spartacus 3!');
-
- mock1.$replay();
- mock2.$replay();
- mock3.$replay();
- assertEquals('No, I am Spartacus 3!', globalFoo());
- mock3.$tearDown();
- assertEquals('No, I am Spartacus 2!', globalFoo());
- mock2.$tearDown();
- assertEquals('No, I am Spartacus 1!', globalFoo());
- mock1.$tearDown();
- assertEquals('I am Spartacus!', globalFoo());
-}
-
-function testGlobalFunctionMockCallOrdering() {
- var mock = goog.testing.createGlobalFunctionMock('globalFoo');
- mock(1);
- mock(2);
- mock.$replay();
- assertThrows(function(){globalFoo(2);});
- mock.$tearDown();
-
- mock = goog.testing.createGlobalFunctionMock('globalFoo',
- goog.testing.Mock.STRICT);
- mock(1);
- mock(2);
- mock.$replay();
- globalFoo(1);
- globalFoo(2);
- mock.$verify();
- mock.$tearDown();
-
- mock = goog.testing.createGlobalFunctionMock('globalFoo',
- goog.testing.Mock.STRICT);
- mock(1);
- mock(2);
- mock.$replay();
- assertThrows(function(){globalFoo(2);});
- mock.$tearDown();
-
- mock = goog.testing.createGlobalFunctionMock('globalFoo',
- goog.testing.Mock.LOOSE);
- mock(1);
- mock(2);
- mock.$replay();
- globalFoo(2);
- globalFoo(1);
- mock.$verify();
- mock.$tearDown();
-}
-
-//----- Functions for goog.testing.MethodMock to mock
-
-var mynamespace = {};
-
-mynamespace.myMethod = function() {
- return 'I should be mocked.';
-};
-
-function testMocksMethod() {
- mockMethod = goog.testing.createMethodMock(mynamespace, 'myMethod');
- mockMethod().$returns('I have been mocked!');
-
- mockMethod.$replay();
- assertEquals('I have been mocked!', mockMethod());
- mockMethod.$verify();
-}
-
-function testMocksMethodInNamespace() {
- goog.testing.createMethodMock(mynamespace, 'myMethod');
- mynamespace.myMethod().$returns('I have been mocked!');
-
- mynamespace.myMethod.$replay();
- assertEquals('I have been mocked!', mynamespace.myMethod());
- mynamespace.myMethod.$verify();
- mynamespace.myMethod.$tearDown();
-}
-
-function testMethodMockCanOnlyMockExistingMethods() {
- assertThrows(function() {
- goog.testing.createMethodMock(mynamespace, 'doesNotExist');
- });
-}
-
-function testMethodMockCallOrdering() {
- goog.testing.createMethodMock(mynamespace, 'myMethod');
- mynamespace.myMethod(1);
- mynamespace.myMethod(2);
- mynamespace.myMethod.$replay();
- assertThrows(function(){mynamespace.myMethod(2);});
- mynamespace.myMethod.$tearDown();
-
- goog.testing.createMethodMock(mynamespace, 'myMethod',
- goog.testing.Mock.STRICT);
- mynamespace.myMethod(1);
- mynamespace.myMethod(2);
- mynamespace.myMethod.$replay();
- mynamespace.myMethod(1);
- mynamespace.myMethod(2);
- mynamespace.myMethod.$verify();
- mynamespace.myMethod.$tearDown();
-
- goog.testing.createMethodMock(mynamespace, 'myMethod',
- goog.testing.Mock.STRICT);
- mynamespace.myMethod(1);
- mynamespace.myMethod(2);
- mynamespace.myMethod.$replay();
- assertThrows(function(){mynamespace.myMethod(2);});
- mynamespace.myMethod.$tearDown();
-
- goog.testing.createMethodMock(mynamespace, 'myMethod',
- goog.testing.Mock.LOOSE);
- mynamespace.myMethod(1);
- mynamespace.myMethod(2);
- mynamespace.myMethod.$replay();
- mynamespace.myMethod(2);
- mynamespace.myMethod(1);
- mynamespace.myMethod.$verify();
- mynamespace.myMethod.$tearDown();
-}
-
-//----- Functions for goog.testing.createConstructorMock to mock
-
-var constructornamespace = {};
-
-constructornamespace.MyConstructor = function() {
-};
-
-constructornamespace.MyConstructor.prototype.myMethod = function() {
- return 'I should be mocked.';
-};
-
-constructornamespace.MyConstructorWithArgument = function(argument) {
- this.argument_ = argument;
-};
-
-constructornamespace.MyConstructorWithArgument.prototype.myMethod = function() {
- return this.argument_;
-};
-
-constructornamespace.MyConstructorWithClassMembers = function() {
-};
-
-constructornamespace.MyConstructorWithClassMembers.CONSTANT = 42;
-
-constructornamespace.MyConstructorWithClassMembers.classMethod = function() {
- return 'class method return value';
-};
-
-function testConstructorMock() {
- var mockObject =
- new goog.testing.StrictMock(constructornamespace.MyConstructor);
- var mockConstructor = goog.testing.createConstructorMock(
- constructornamespace, 'MyConstructor');
- mockConstructor().$returns(mockObject);
- mockObject.myMethod().$returns('I have been mocked!');
-
- mockConstructor.$replay();
- mockObject.$replay();
- assertEquals('I have been mocked!',
- new constructornamespace.MyConstructor().myMethod());
- mockConstructor.$verify();
- mockObject.$verify();
- mockConstructor.$tearDown();
-}
-
-function testConstructorMockWithArgument() {
- var mockObject = new goog.testing.StrictMock(
- constructornamespace.MyConstructorWithArgument);
- var mockConstructor = goog.testing.createConstructorMock(
- constructornamespace, 'MyConstructorWithArgument');
- mockConstructor(goog.testing.mockmatchers.isString).$returns(mockObject);
- mockObject.myMethod().$returns('I have been mocked!');
-
- mockConstructor.$replay();
- mockObject.$replay();
- assertEquals('I have been mocked!',
- new constructornamespace.MyConstructorWithArgument('I should be mocked.')
- .myMethod());
- mockConstructor.$verify();
- mockObject.$verify();
- mockConstructor.$tearDown();
-}
-
-/**
- * Test that class members are copied to the mock constructor.
- */
-function testConstructorMockWithClassMembers() {
- var mockConstructor = goog.testing.createConstructorMock(
- constructornamespace, 'MyConstructorWithClassMembers');
- assertEquals(42, constructornamespace.MyConstructorWithClassMembers.CONSTANT);
- assertEquals('class method return value',
- constructornamespace.MyConstructorWithClassMembers.classMethod());
- mockConstructor.$tearDown();
-}
-
-function testConstructorMockCallOrdering() {
- var instance = {};
-
- goog.testing.createConstructorMock(constructornamespace,
- 'MyConstructorWithArgument');
- constructornamespace.MyConstructorWithArgument(1).$returns(instance);
- constructornamespace.MyConstructorWithArgument(2).$returns(instance);
- constructornamespace.MyConstructorWithArgument.$replay();
- assertThrows(
- function(){new constructornamespace.MyConstructorWithArgument(2);});
- constructornamespace.MyConstructorWithArgument.$tearDown();
-
- goog.testing.createConstructorMock(constructornamespace,
- 'MyConstructorWithArgument',
- goog.testing.Mock.STRICT);
- constructornamespace.MyConstructorWithArgument(1).$returns(instance);
- constructornamespace.MyConstructorWithArgument(2).$returns(instance);
- constructornamespace.MyConstructorWithArgument.$replay();
- new constructornamespace.MyConstructorWithArgument(1);
- new constructornamespace.MyConstructorWithArgument(2);
- constructornamespace.MyConstructorWithArgument.$verify();
- constructornamespace.MyConstructorWithArgument.$tearDown();
-
- goog.testing.createConstructorMock(constructornamespace,
- 'MyConstructorWithArgument',
- goog.testing.Mock.STRICT);
- constructornamespace.MyConstructorWithArgument(1).$returns(instance);
- constructornamespace.MyConstructorWithArgument(2).$returns(instance);
- constructornamespace.MyConstructorWithArgument.$replay();
- assertThrows(
- function(){new constructornamespace.MyConstructorWithArgument(2);});
- constructornamespace.MyConstructorWithArgument.$tearDown();
-
- goog.testing.createConstructorMock(constructornamespace,
- 'MyConstructorWithArgument',
- goog.testing.Mock.LOOSE);
- constructornamespace.MyConstructorWithArgument(1).$returns(instance);
- constructornamespace.MyConstructorWithArgument(2).$returns(instance);
- constructornamespace.MyConstructorWithArgument.$replay();
- new constructornamespace.MyConstructorWithArgument(2);
- new constructornamespace.MyConstructorWithArgument(1);
- constructornamespace.MyConstructorWithArgument.$verify();
- constructornamespace.MyConstructorWithArgument.$tearDown();
-}
-
-//----- Helper assertions
-
-function assertQuacksLike(obj, target) {
- for (meth in target.prototype) {
- if (!goog.string.endsWith(meth, '_')) {
- assertNotUndefined('Should have implemented '+ meth +'()', obj[meth]);
- }
- }
-}
-</script>
-
-</body>
-</html>
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/graphics.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/graphics.js.svn-base
deleted file mode 100644
index fea11c8..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/graphics.js.svn-base
+++ /dev/null
@@ -1,64 +0,0 @@
-// Copyright 2008 The Closure Library Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS-IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/**
- * @fileoverview Testing utilities for DOM related tests.
- *
- * @author robbyw@google.com (Robby Walker)
- */
-
-goog.provide('goog.testing.graphics');
-
-goog.require('goog.graphics.Path.Segment');
-goog.require('goog.testing.asserts');
-
-
-/**
- * Array mapping numeric segment constant to a descriptive character.
- * @type {Array.<string>}
- * @private
- */
-goog.testing.graphics.SEGMENT_NAMES_ = function() {
- var arr = [];
- arr[goog.graphics.Path.Segment.MOVETO] = 'M';
- arr[goog.graphics.Path.Segment.LINETO] = 'L';
- arr[goog.graphics.Path.Segment.CURVETO] = 'C';
- arr[goog.graphics.Path.Segment.ARCTO] = 'A';
- arr[goog.graphics.Path.Segment.CLOSE] = 'X';
- return arr;
-}();
-
-
-/**
- * Test if the given path matches the expected array of commands and parameters.
- * @param {Array.<string|number>} expected The expected array of commands and
- * parameters.
- * @param {goog.graphics.Path} path The path to test against.
- */
-goog.testing.graphics.assertPathEquals = function(expected, path) {
- var actual = [];
- path.forEachSegment(function(seg, args) {
- actual.push(goog.testing.graphics.SEGMENT_NAMES_[seg]);
- Array.prototype.push.apply(actual, args);
- });
- assertEquals(expected.length, actual.length);
- for (var i = 0; i < expected.length; i++) {
- if (goog.isNumber(expected[i])) {
- assertTrue(goog.isNumber(actual[i]));
- assertRoughlyEquals(expected[i], actual[i], 0.01);
- } else {
- assertEquals(expected[i], actual[i]);
- }
- }
-};
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/jsunit.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/jsunit.js.svn-base
deleted file mode 100644
index 97d343d..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/jsunit.js.svn-base
+++ /dev/null
@@ -1,144 +0,0 @@
-// Copyright 2007 The Closure Library Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS-IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/**
- * @fileoverview Utilities for working with JsUnit. Writes out the JsUnit file
- * that needs to be included in every unit test.
- *
- * Testing code should not have dependencies outside of goog.testing so as to
- * reduce the chance of masking missing dependencies.
- *
- */
-
-goog.provide('goog.testing.jsunit');
-
-goog.require('goog.testing.TestCase');
-goog.require('goog.testing.TestRunner');
-
-
-/**
- * Base path for JsUnit app files, relative to Closure's base path.
- * @type {string}
- */
-goog.testing.jsunit.BASE_PATH =
- '../../third_party/java/jsunit/core/app/';
-
-
-/**
- * Filename for the core JS Unit script.
- * @type {string}
- */
-goog.testing.jsunit.CORE_SCRIPT =
- goog.testing.jsunit.BASE_PATH + 'jsUnitCore.js';
-
-
-/**
- * @define {boolean} If this code is being parsed by JsTestC, we let it disable
- * the onload handler to avoid running the test in JsTestC.
- */
-goog.testing.jsunit.AUTO_RUN_ONLOAD = true;
-
-
-(function() {
-
- // Store a reference to the window's timeout so that it can't be overridden
- // by tests.
- var realTimeout = window.setTimeout;
-
- // Check for JsUnit's test runner (need to check for >2.2 and <=2.2)
- if (top['JsUnitTestManager'] || top['jsUnitTestManager']) {
- // Running inside JsUnit so add support code.
- var path = goog.basePath + goog.testing.jsunit.CORE_SCRIPT;
- document.write('<script type="text/javascript" src="' +
- path + '"></' + 'script>');
-
- } else {
-
- // Create a test runner.
- var tr = new goog.testing.TestRunner();
-
- // Export it so that it can be queried by Selenium and tests that use a
- // compiled test runner.
- goog.exportSymbol('G_testRunner', tr);
- goog.exportSymbol('G_testRunner.initialize', tr.initialize);
- goog.exportSymbol('G_testRunner.isInitialized', tr.isInitialized);
- goog.exportSymbol('G_testRunner.isFinished', tr.isFinished);
- goog.exportSymbol('G_testRunner.isSuccess', tr.isSuccess);
- goog.exportSymbol('G_testRunner.getReport', tr.getReport);
- goog.exportSymbol('G_testRunner.getRunTime', tr.getRunTime);
- goog.exportSymbol('G_testRunner.getNumFilesLoaded', tr.getNumFilesLoaded);
- goog.exportSymbol('G_testRunner.setStrict', tr.setStrict);
- goog.exportSymbol('G_testRunner.logTestFailure', tr.logTestFailure);
-
- // Export debug as a global function for JSUnit compatibility. This just
- // calls log on the current test case.
- if (!goog.global['debug']) {
- goog.exportSymbol('debug', goog.bind(tr.log, tr));
- }
-
- // If the application has defined a global error filter, set it now. This
- // allows users who use a base test include to set the error filter before
- // the testing code is loaded.
- if (goog.global['G_errorFilter']) {
- tr.setErrorFilter(goog.global['G_errorFilter']);
- }
-
- // Add an error handler to report errors that may occur during
- // initialization of the page.
- var onerror = window.onerror;
- window.onerror = function(error, url, line) {
- // Call any existing onerror handlers.
- if (onerror) {
- onerror(error, url, line);
- }
- if (typeof error == 'object') {
- // Webkit started passing an event object as the only argument to
- // window.onerror. It doesn't contain an error message, url or line
- // number. We therefore log as much info as we can.
- if (error.target && error.target.tagName == 'SCRIPT') {
- tr.logError('UNKNOWN ERROR: Script ' + error.target.src);
- } else {
- tr.logError('UNKNOWN ERROR: No error information available.');
- }
- } else {
- tr.logError('JS ERROR: ' + error + '\nURL: ' + url + '\nLine: ' + line);
- }
- };
-
- // Create an onload handler, if the test runner hasn't been initialized then
- // no test has been registered with the test runner by the test file. We
- // then create a new test case and auto discover any tests in the global
- // scope. If this code is being parsed by JsTestC, we let it disable the
- // onload handler to avoid running the test in JsTestC.
- if (goog.testing.jsunit.AUTO_RUN_ONLOAD) {
- var onload = window.onload;
- window.onload = function() {
- // Call any existing onload handlers.
- if (onload) {
- onload();
- }
- // Wait 500ms longer so that we don't interfere with Selenium.
- realTimeout(function() {
- if (!tr.initialized) {
- var test = new goog.testing.TestCase(document.title);
- test.autoDiscoverTests();
- tr.initialize(test);
- }
- tr.execute();
- }, 500);
- window.onload = null;
- };
- }
- }
-})();
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/loosemock.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/loosemock.js.svn-base
deleted file mode 100644
index 182bb3b..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/loosemock.js.svn-base
+++ /dev/null
@@ -1,240 +0,0 @@
-// Copyright 2008 The Closure Library Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS-IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/**
- * @fileoverview This file defines a loose mock implementation.
- */
-
-goog.provide('goog.testing.LooseExpectationCollection');
-goog.provide('goog.testing.LooseMock');
-
-goog.require('goog.array');
-goog.require('goog.structs.Map');
-goog.require('goog.testing.Mock');
-
-
-
-/**
- * This class is an ordered collection of expectations for one method. Since
- * the loose mock does most of its verification at the time of $verify, this
- * class is necessary to manage the return/throw behavior when the mock is
- * being called.
- * @constructor
- */
-goog.testing.LooseExpectationCollection = function() {
- /**
- * The list of expectations. All of these should have the same name.
- * @type {Array.<goog.testing.MockExpectation>}
- * @private
- */
- this.expectations_ = [];
-};
-
-
-/**
- * Adds an expectation to this collection.
- * @param {goog.testing.MockExpectation} expectation The expectation to add.
- */
-goog.testing.LooseExpectationCollection.prototype.addExpectation =
- function(expectation) {
- this.expectations_.push(expectation);
-};
-
-
-/**
- * Gets the list of expectations in this collection.
- * @return {Array.<goog.testing.MockExpectation>} The array of expectations.
- */
-goog.testing.LooseExpectationCollection.prototype.getExpectations = function() {
- return this.expectations_;
-};
-
-
-
-/**
- * This is a mock that does not care about the order of method calls. As a
- * result, it won't throw exceptions until verify() is called. The only
- * exception is that if a method is called that has no expectations, then an
- * exception will be thrown.
- * @param {Object} objectToMock The object to mock.
- * @param {boolean=} opt_ignoreUnexpectedCalls Whether to ignore unexpected
- * calls.
- * @param {boolean=} opt_mockStaticMethods An optional argument denoting that
- * a mock should be constructed from the static functions of a class.
- * @param {boolean=} opt_createProxy An optional argument denoting that
- * a proxy for the target mock should be created.
- * @constructor
- * @extends {goog.testing.Mock}
- */
-goog.testing.LooseMock = function(objectToMock, opt_ignoreUnexpectedCalls,
- opt_mockStaticMethods, opt_createProxy) {
- goog.testing.Mock.call(this, objectToMock, opt_mockStaticMethods,
- opt_createProxy);
-
- /**
- * A map of method names to a LooseExpectationCollection for that method.
- * @type {goog.structs.Map}
- * @private
- */
- this.$expectations_ = new goog.structs.Map();
-
- /**
- * The calls that have been made; we cache them to verify at the end. Each
- * element is an array where the first element is the name, and the second
- * element is the arguments.
- * @type {Array.<Array.<*>>}
- * @private
- */
- this.$calls_ = [];
-
- /**
- * Whether to ignore unexpected calls.
- * @type {boolean}
- * @private
- */
- this.$ignoreUnexpectedCalls_ = !!opt_ignoreUnexpectedCalls;
-};
-goog.inherits(goog.testing.LooseMock, goog.testing.Mock);
-
-
-/**
- * A setter for the ignoreUnexpectedCalls field.
- * @param {boolean} ignoreUnexpectedCalls Whether to ignore unexpected calls.
- * @return {goog.testing.LooseMock} This mock object.
- */
-goog.testing.LooseMock.prototype.$setIgnoreUnexpectedCalls = function(
- ignoreUnexpectedCalls) {
- this.$ignoreUnexpectedCalls_ = ignoreUnexpectedCalls;
- return this;
-};
-
-
-/** @override */
-goog.testing.LooseMock.prototype.$recordExpectation = function() {
- if (!this.$expectations_.containsKey(this.$pendingExpectation.name)) {
- this.$expectations_.set(this.$pendingExpectation.name,
- new goog.testing.LooseExpectationCollection());
- }
-
- var collection = this.$expectations_.get(this.$pendingExpectation.name);
- collection.addExpectation(this.$pendingExpectation);
-};
-
-
-/** @override */
-goog.testing.LooseMock.prototype.$recordCall = function(name, args) {
- if (!this.$expectations_.containsKey(name)) {
- if (this.$ignoreUnexpectedCalls_) {
- return;
- }
- this.$throwCallException(name, args);
- }
-
- // Start from the beginning of the expectations for this name,
- // and iterate over them until we find an expectation that matches
- // and also has calls remaining.
- var collection = this.$expectations_.get(name);
- var matchingExpectation = null;
- var expectations = collection.getExpectations();
- for (var i = 0; i < expectations.length; i++) {
- var expectation = expectations[i];
- if (this.$verifyCall(expectation, name, args)) {
- matchingExpectation = expectation;
- if (expectation.actualCalls < expectation.maxCalls) {
- break;
- } // else continue and see if we can find something that does match
- }
- }
- if (matchingExpectation == null) {
- this.$throwCallException(name, args, expectation);
- }
-
- matchingExpectation.actualCalls++;
- if (matchingExpectation.actualCalls > matchingExpectation.maxCalls) {
- this.$throwException('Too many calls to ' + matchingExpectation.name +
- '\nExpected: ' + matchingExpectation.maxCalls + ' but was: ' +
- matchingExpectation.actualCalls);
- }
-
- this.$calls_.push([name, args]);
- return this.$do(matchingExpectation, args);
-};
-
-
-/** @override */
-goog.testing.LooseMock.prototype.$reset = function() {
- goog.testing.LooseMock.superClass_.$reset.call(this);
-
- this.$expectations_ = new goog.structs.Map();
- this.$calls_ = [];
-};
-
-
-/** @override */
-goog.testing.LooseMock.prototype.$replay = function() {
- goog.testing.LooseMock.superClass_.$replay.call(this);
-
- // Verify that there are no expectations that can never be reached.
- // This can't catch every situation, but it is a decent sanity check
- // and it's similar to the behavior of EasyMock in java.
- var collections = this.$expectations_.getValues();
- for (var i = 0; i < collections.length; i++) {
- var expectations = collections[i].getExpectations();
- for (var j = 0; j < expectations.length; j++) {
- var expectation = expectations[j];
- // If this expectation can be called infinite times, then
- // check if any subsequent expectation has the exact same
- // argument list.
- if (!isFinite(expectation.maxCalls)) {
- for (var k = j + 1; k < expectations.length; k++) {
- var laterExpectation = expectations[k];
- if (laterExpectation.minCalls > 0 &&
- goog.array.equals(expectation.argumentList,
- laterExpectation.argumentList)) {
- var name = expectation.name;
- var argsString = this.$argumentsAsString(expectation.argumentList);
- this.$throwException([
- 'Expected call to ', name, ' with arguments ', argsString,
- ' has an infinite max number of calls; can\'t expect an',
- ' identical call later with a positive min number of calls'
- ].join(''));
- }
- }
- }
- }
- }
-};
-
-
-/** @override */
-goog.testing.LooseMock.prototype.$verify = function() {
- goog.testing.LooseMock.superClass_.$verify.call(this);
- var collections = this.$expectations_.getValues();
-
- for (var i = 0; i < collections.length; i++) {
- var expectations = collections[i].getExpectations();
- for (var j = 0; j < expectations.length; j++) {
- var expectation = expectations[j];
- if (expectation.actualCalls > expectation.maxCalls) {
- this.$throwException('Too many calls to ' + expectation.name +
- '\nExpected: ' + expectation.maxCalls + ' but was: ' +
- expectation.actualCalls);
- } else if (expectation.actualCalls < expectation.minCalls) {
- this.$throwException('Not enough calls to ' + expectation.name +
- '\nExpected: ' + expectation.minCalls + ' but was: ' +
- expectation.actualCalls);
- }
- }
- }
-};
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/loosemock_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/loosemock_test.html.svn-base
deleted file mode 100644
index bae04f3..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/loosemock_test.html.svn-base
+++ /dev/null
@@ -1,343 +0,0 @@
-<!DOCTYPE html>
-<html>
-<!--
-Copyright 2008 The Closure Library Authors. All Rights Reserved.
-
-Use of this source code is governed by the Apache License, Version 2.0.
-See the COPYING file for details.
--->
-<head>
-<meta http-equiv="X-UA-Compatible" content="IE=edge">
-<title>Closure Unit Tests - goog.testing.LooseMock</title>
-<script src="../base.js"></script>
-<script>
- goog.require('goog.testing.LooseMock');
- goog.require('goog.testing.PropertyReplacer');
- goog.require('goog.testing.jsunit');
- goog.require('goog.testing.mockmatchers');
-</script>
-</head>
-<body>
-<script>
- // The object that we will be mocking
- var RealObject = function() {
- };
-
- RealObject.prototype.a = function() {
- fail('real object should never be called');
- };
-
- RealObject.prototype.b = function() {
- fail('real object should never be called');
- };
-
- var mock;
-
- var stubs;
-
- function setUp() {
- var obj = new RealObject();
- mock = new goog.testing.LooseMock(obj);
- stubs = new goog.testing.PropertyReplacer();
- }
-
- function tearDown() {
- stubs.reset();
- }
-
- /*
- * Calling this method evades the logTestFailure in
- * goog.testing.Mock.prototype.$recordAndThrow, so it doesn't look like the
- * test failed.
- */
- function silenceFailureLogging() {
- if (goog.global['G_testRunner']) {
- stubs.set(goog.global['G_testRunner'],
- 'logTestFailure', goog.nullFunction);
- }
- }
-
- function unsilenceFailureLogging() {
- stubs.reset();
- }
-
- /**
- * Version of assertThrows that doesn't log the exception generated by the
- * mocks under test.
- * TODO: would be nice to check that a particular substring is in the thrown
- * message so we know it's not something dumb like a syntax error
- */
- function assertThrowsQuiet(var_args) {
- silenceFailureLogging();
- assertThrows.apply(null, arguments);
- unsilenceFailureLogging();
- }
-
- // Most of the basic functionality is tested in strictmock_test; these tests
- // cover the cases where loose mocks are different from strict mocks
- function testSimpleExpectations() {
- mock.a(5);
- mock.b();
- mock.$replay();
- mock.a(5);
- mock.b();
- mock.$verify();
-
- mock.$reset();
-
- mock.a();
- mock.b();
- mock.$replay();
- mock.b();
- mock.a();
- mock.$verify();
-
- mock.$reset();
-
- mock.a(5).$times(2);
- mock.a(5);
- mock.a(2);
- mock.$replay();
- mock.a(5);
- mock.a(5);
- mock.a(5);
- mock.a(2);
- mock.$verify();
- }
-
-
- function testMultipleExpectations() {
- mock.a().$returns(1);
- mock.a().$returns(2);
- mock.$replay();
- assertEquals(1, mock.a());
- assertEquals(2, mock.a());
- mock.$verify();
- }
-
-
- function testMultipleExpectationArgs() {
- mock.a('asdf').$anyTimes();
- mock.a('qwer').$anyTimes();
- mock.b().$times(3);
- mock.$replay();
- mock.a('asdf');
- mock.b();
- mock.a('asdf');
- mock.a('qwer');
- mock.b();
- mock.a('qwer');
- mock.b();
- mock.$verify();
-
- mock.$reset();
-
- mock.a('asdf').$anyTimes();
- mock.a('qwer').$anyTimes();
- mock.$replay();
- mock.a('asdf');
- mock.a('qwer');
- goog.bind(mock.a, mock, 'asdf');
- goog.bind(mock.$verify, mock);
- }
-
- function testSameMethodOutOfOrder() {
- mock.a('foo').$returns(1);
- mock.a('bar').$returns(2);
- mock.$replay();
- assertEquals(2, mock.a('bar'));
- assertEquals(1, mock.a('foo'));
- }
-
- function testSameMethodDifferentReturnValues() {
- mock.a('foo').$returns(1).$times(2);
- mock.a('foo').$returns(3);
- mock.a('bar').$returns(2);
- mock.$replay();
- assertEquals(1, mock.a('foo'));
- assertEquals(2, mock.a('bar'));
- assertEquals(1, mock.a('foo'));
- assertEquals(3, mock.a('foo'));
- assertThrowsQuiet(function() {
- mock.a('foo');
- mock.$verify();
- });
- }
-
- function testSameMethodBrokenExpectations() {
- // This is a weird corner case.
- // No way to ever make this verify no matter what you call after replaying,
- // because the second expectation of mock.a('foo') will be masked by
- // the first expectation that can be called any number of times, and so we
- // can never satisfy that second expectation.
- mock.a('foo').$returns(1).$anyTimes();
- mock.a('bar').$returns(2);
- mock.a('foo').$returns(3);
-
- // LooseMock can detect this case and fail on $replay.
- assertThrowsQuiet(goog.bind(mock.$replay, mock));
- mock.$reset();
-
- // This is a variant of the corner case above, but it's harder to determine
- // that the expectation to mock.a('bar') can never be satisfied. So we don't
- // fail on $replay, but we do fail on $verify.
- mock.a(goog.testing.mockmatchers.isString).$returns(1).$anyTimes();
- mock.a('bar').$returns(2);
- mock.$replay();
-
- assertEquals(1, mock.a('foo'));
- assertEquals(1, mock.a('bar'));
- assertThrowsQuiet(goog.bind(mock.$verify, mock));
- }
-
- function testSameMethodMultipleAnyTimes() {
- mock.a('foo').$returns(1).$anyTimes();
- mock.a('foo').$returns(2).$anyTimes();
- mock.$replay();
- assertEquals(1, mock.a('foo'));
- assertEquals(1, mock.a('foo'));
- assertEquals(1, mock.a('foo'));
- // Note we'll never return 2 but that's ok.
- mock.$verify();
- }
-
- function testFailingFast() {
- mock.a().$anyTimes();
- mock.$replay();
- mock.a();
- mock.a();
- assertThrowsQuiet(goog.bind(mock.b, mock));
- mock.$reset();
-
- // too many
- mock.a();
- mock.b();
- mock.$replay();
- mock.a();
- mock.b();
-
- var message;
- silenceFailureLogging();
- try {
- mock.a();
- } catch (e) {
- message = e.message;
- }
- unsilenceFailureLogging();
-
- assertTrue('No exception thrown on unexpected call', goog.isDef(message));
- assertContains('Too many calls to a', message);
- }
-
- function testTimes() {
- mock.a().$times(3);
- mock.b().$times(2);
- mock.$replay();
- mock.a();
- mock.b();
- mock.b();
- mock.a();
- mock.a();
- mock.$verify();
- }
-
-
- function testFailingSlow() {
- // not enough
- mock.a().$times(3);
- mock.$replay();
- mock.a();
- mock.a();
- assertThrowsQuiet(goog.bind(mock.$verify, mock));
-
- mock.$reset();
-
- // not enough, interleaved order
- mock.a().$times(3);
- mock.b().$times(3);
- mock.$replay();
- mock.a();
- mock.b();
- mock.a();
- mock.b();
- assertThrowsQuiet(goog.bind(mock.$verify, mock));
-
- mock.$reset();
- // bad args
- mock.a('asdf').$anyTimes();
- mock.$replay();
- mock.a('asdf');
- assertThrowsQuiet(goog.bind(mock.a, mock, 'qwert'));
- assertThrowsQuiet(goog.bind(mock.$verify, mock));
- }
-
-
- function testArgsAndReturns() {
- mock.a('asdf').$atLeastOnce().$returns(5);
- mock.b('qwer').$times(2).$returns(3);
- mock.$replay();
- assertEquals(5, mock.a('asdf'));
- assertEquals(3, mock.b('qwer'));
- assertEquals(5, mock.a('asdf'));
- assertEquals(5, mock.a('asdf'));
- assertEquals(3, mock.b('qwer'));
- mock.$verify();
- }
-
-
- function testThrows() {
- mock.a().$throws('exception!');
- mock.$replay();
- assertThrowsQuiet(goog.bind(mock.a, mock));
- mock.$verify();
- }
-
-
- function testDoes() {
- mock.a(1, 2).$does(function(a, b) {return a + b;});
- mock.$replay();
- assertEquals('Mock should call the function', 3, mock.a(1, 2));
- mock.$verify();
- }
-
- function testIgnoresExtraCalls() {
- mock = new goog.testing.LooseMock(RealObject, true);
- mock.a();
- mock.$replay();
- mock.a();
- mock.b(); // doesn't throw
- mock.$verify();
- }
-
- function testSkipAnyTimes() {
- mock = new goog.testing.LooseMock(RealObject);
- mock.a(1).$anyTimes();
- mock.a(2).$anyTimes();
- mock.a(3).$anyTimes();
- mock.$replay();
- mock.a(1);
- mock.a(3);
- mock.$verify();
- }
-
- function testErrorMessageForBadArgs() {
- mock.a();
- mock.$anyTimes();
-
- mock.$replay();
-
- var message;
- silenceFailureLogging();
- try {
- mock.a('a');
- } catch (e) {
- message = e.message;
- }
- unsilenceFailureLogging();
-
- assertTrue('No exception thrown on verify', goog.isDef(message));
- assertContains('Bad arguments to a()', message);
- }
-</script>
-</body>
-</html>
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mock.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mock.js.svn-base
deleted file mode 100644
index 2312cc5..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mock.js.svn-base
+++ /dev/null
@@ -1,579 +0,0 @@
-// Copyright 2008 The Closure Library Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS-IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/**
- * @fileoverview This file defines base classes used for creating mocks in
- * JavaScript. The API was inspired by EasyMock.
- *
- * The basic API is:
- * <ul>
- * <li>Create an object to be mocked
- * <li>Create a mock object, passing in the above object to the constructor
- * <li>Set expectations by calling methods on the mock object
- * <li>Call $replay() on the mock object
- * <li>Pass the mock to code that will make real calls on it
- * <li>Call $verify() to make sure that expectations were met
- * </ul>
- *
- * For examples, please see the unit tests for LooseMock and StrictMock.
- *
- * Still TODO
- * implement better (and pluggable) argument matching
- * Have the exceptions for LooseMock show the number of expected/actual calls
- * loose and strict mocks share a lot of code - move it to the base class
- *
- */
-
-goog.provide('goog.testing.Mock');
-goog.provide('goog.testing.MockExpectation');
-
-goog.require('goog.array');
-goog.require('goog.testing.JsUnitException');
-goog.require('goog.testing.MockInterface');
-goog.require('goog.testing.mockmatchers');
-
-
-
-/**
- * This is a class that represents an expectation.
- * @param {string} name The name of the method for this expectation.
- * @constructor
- */
-goog.testing.MockExpectation = function(name) {
- /**
- * The name of the method that is expected to be called.
- * @type {string}
- */
- this.name = name;
-
- /**
- * An array of error messages for expectations not met.
- * @type {Array}
- */
- this.errorMessages = [];
-};
-
-
-/**
- * The minimum number of times this method should be called.
- * @type {number}
- */
-goog.testing.MockExpectation.prototype.minCalls = 1;
-
-
-/**
- * The maximum number of times this method should be called.
- * @type {number}
- */
-goog.testing.MockExpectation.prototype.maxCalls = 1;
-
-
-/**
- * The value that this method should return.
- * @type {*}
- */
-goog.testing.MockExpectation.prototype.returnValue;
-
-
-/**
- * The value that will be thrown when the method is called
- * @type {*}
- */
-goog.testing.MockExpectation.prototype.exceptionToThrow;
-
-
-/**
- * The arguments that are expected to be passed to this function
- * @type {Array.<*>}
- */
-goog.testing.MockExpectation.prototype.argumentList;
-
-
-/**
- * The number of times this method is called by real code.
- * @type {number}
- */
-goog.testing.MockExpectation.prototype.actualCalls = 0;
-
-
-/**
- * The number of times this method is called during the verification phase.
- * @type {number}
- */
-goog.testing.MockExpectation.prototype.verificationCalls = 0;
-
-
-/**
- * The function which will be executed when this method is called.
- * Method arguments will be passed to this function, and return value
- * of this function will be returned by the method.
- * @type {Function}
- */
-goog.testing.MockExpectation.prototype.toDo;
-
-
-/**
- * Allow expectation failures to include messages.
- * @param {string} message The failure message.
- */
-goog.testing.MockExpectation.prototype.addErrorMessage = function(message) {
- this.errorMessages.push(message);
-};
-
-
-/**
- * Get the error messages seen so far.
- * @return {string} Error messages separated by \n.
- */
-goog.testing.MockExpectation.prototype.getErrorMessage = function() {
- return this.errorMessages.join('\n');
-};
-
-
-/**
- * Get how many error messages have been seen so far.
- * @return {number} Count of error messages.
- */
-goog.testing.MockExpectation.prototype.getErrorMessageCount = function() {
- return this.errorMessages.length;
-};
-
-
-
-/**
- * The base class for a mock object.
- * @param {Object|Function} objectToMock The object that should be mocked, or
- * the constructor of an object to mock.
- * @param {boolean=} opt_mockStaticMethods An optional argument denoting that
- * a mock should be constructed from the static functions of a class.
- * @param {boolean=} opt_createProxy An optional argument denoting that
- * a proxy for the target mock should be created.
- * @constructor
- * @implements {goog.testing.MockInterface}
- */
-goog.testing.Mock = function(objectToMock, opt_mockStaticMethods,
- opt_createProxy) {
- if (!goog.isObject(objectToMock) && !goog.isFunction(objectToMock)) {
- throw new Error('objectToMock must be an object or constructor.');
- }
- if (opt_createProxy && !opt_mockStaticMethods &&
- goog.isFunction(objectToMock)) {
- /** @constructor */
- function tempCtor() {};
- goog.inherits(tempCtor, objectToMock);
- this.$proxy = new tempCtor();
- } else if (opt_createProxy && opt_mockStaticMethods &&
- goog.isFunction(objectToMock)) {
- throw Error('Cannot create a proxy when opt_mockStaticMethods is true');
- } else if (opt_createProxy && !goog.isFunction(objectToMock)) {
- throw Error('Must have a constructor to create a proxy');
- }
-
- if (goog.isFunction(objectToMock) && !opt_mockStaticMethods) {
- this.$initializeFunctions_(objectToMock.prototype);
- } else {
- this.$initializeFunctions_(objectToMock);
- }
- this.$argumentListVerifiers_ = {};
-};
-
-
-/**
- * Option that may be passed when constructing function, method, and
- * constructor mocks. Indicates that the expected calls should be accepted in
- * any order.
- * @const
- * @type {number}
- */
-goog.testing.Mock.LOOSE = 1;
-
-
-/**
- * Option that may be passed when constructing function, method, and
- * constructor mocks. Indicates that the expected calls should be accepted in
- * the recorded order only.
- * @const
- * @type {number}
- */
-goog.testing.Mock.STRICT = 0;
-
-
-/**
- * A proxy for the mock. This can be used for dependency injection in lieu of
- * the mock if the test requires a strict instanceof check.
- * @type {Object}
- */
-goog.testing.Mock.prototype.$proxy = null;
-
-
-/**
- * Map of argument name to optional argument list verifier function.
- * @type {Object}
- */
-goog.testing.Mock.prototype.$argumentListVerifiers_;
-
-
-/**
- * Whether or not we are in recording mode.
- * @type {boolean}
- * @private
- */
-goog.testing.Mock.prototype.$recording_ = true;
-
-
-/**
- * The expectation currently being created. All methods that modify the
- * current expectation return the Mock object for easy chaining, so this is
- * where we keep track of the expectation that's currently being modified.
- * @type {goog.testing.MockExpectation}
- * @protected
- */
-goog.testing.Mock.prototype.$pendingExpectation;
-
-
-/**
- * First exception thrown by this mock; used in $verify.
- * @type {Object}
- * @private
- */
-goog.testing.Mock.prototype.$threwException_ = null;
-
-
-/**
- * Initializes the functions on the mock object.
- * @param {Object} objectToMock The object being mocked.
- * @private
- */
-goog.testing.Mock.prototype.$initializeFunctions_ = function(objectToMock) {
- // TODO (arv): Implement goog.object.getIterator and replace this loop.
- for (var prop in objectToMock) {
- if (typeof objectToMock[prop] == 'function') {
- this[prop] = goog.bind(this.$mockMethod, this, prop);
- if (this.$proxy) {
- this.$proxy[prop] = goog.bind(this.$mockMethod, this, prop);
- }
- }
- }
-};
-
-
-/**
- * Registers a verfifier function to use when verifying method argument lists.
- * @param {string} methodName The name of the method for which the verifierFn
- * should be used.
- * @param {Function} fn Argument list verifier function. Should take 2 argument
- * arrays as arguments, and return true if they are considered equivalent.
- * @return {goog.testing.Mock} This mock object.
- */
-goog.testing.Mock.prototype.$registerArgumentListVerifier = function(methodName,
- fn) {
- this.$argumentListVerifiers_[methodName] = fn;
- return this;
-};
-
-
-/**
- * The function that replaces all methods on the mock object.
- * @param {string} name The name of the method being mocked.
- * @return {*} In record mode, returns the mock object. In replay mode, returns
- * whatever the creator of the mock set as the return value.
- */
-goog.testing.Mock.prototype.$mockMethod = function(name) {
- try {
- // Shift off the name argument so that args contains the arguments to
- // the mocked method.
- var args = goog.array.slice(arguments, 1);
- if (this.$recording_) {
- this.$pendingExpectation = new goog.testing.MockExpectation(name);
- this.$pendingExpectation.argumentList = args;
- this.$recordExpectation();
- return this;
- } else {
- return this.$recordCall(name, args);
- }
- } catch (ex) {
- this.$recordAndThrow(ex);
- }
-};
-
-
-/**
- * Records the currently pending expectation, intended to be overridden by a
- * subclass.
- * @protected
- */
-goog.testing.Mock.prototype.$recordExpectation = function() {};
-
-
-/**
- * Records an actual method call, intended to be overridden by a
- * subclass. The subclass must find the pending expectation and return the
- * correct value.
- * @param {string} name The name of the method being called.
- * @param {Array} args The arguments to the method.
- * @return {*} The return expected by the mock.
- * @protected
- */
-goog.testing.Mock.prototype.$recordCall = function(name, args) {
- return undefined;
-};
-
-
-/**
- * If the expectation expects to throw, this method will throw.
- * @param {goog.testing.MockExpectation} expectation The expectation.
- */
-goog.testing.Mock.prototype.$maybeThrow = function(expectation) {
- if (typeof expectation.exceptionToThrow != 'undefined') {
- throw expectation.exceptionToThrow;
- }
-};
-
-
-/**
- * If this expectation defines a function to be called,
- * it will be called and its result will be returned.
- * Otherwise, if the expectation expects to throw, it will throw.
- * Otherwise, this method will return defined value.
- * @param {goog.testing.MockExpectation} expectation The expectation.
- * @param {Array} args The arguments to the method.
- * @return {*} The return value expected by the mock.
- */
-goog.testing.Mock.prototype.$do = function(expectation, args) {
- if (typeof expectation.toDo == 'undefined') {
- this.$maybeThrow(expectation);
- return expectation.returnValue;
- } else {
- return expectation.toDo.apply(this, args);
- }
-};
-
-
-/**
- * Specifies a return value for the currently pending expectation.
- * @param {*} val The return value.
- * @return {goog.testing.Mock} This mock object.
- */
-goog.testing.Mock.prototype.$returns = function(val) {
- this.$pendingExpectation.returnValue = val;
- return this;
-};
-
-
-/**
- * Specifies a value for the currently pending expectation to throw.
- * @param {*} val The value to throw.
- * @return {goog.testing.Mock} This mock object.
- */
-goog.testing.Mock.prototype.$throws = function(val) {
- this.$pendingExpectation.exceptionToThrow = val;
- return this;
-};
-
-
-/**
- * Specifies a function to call for currently pending expectation.
- * Note, that using this method overrides declarations made
- * using $returns() and $throws() methods.
- * @param {Function} func The function to call.
- * @return {goog.testing.Mock} This mock object.
- */
-goog.testing.Mock.prototype.$does = function(func) {
- this.$pendingExpectation.toDo = func;
- return this;
-};
-
-
-/**
- * Allows the expectation to be called 0 or 1 times.
- * @return {goog.testing.Mock} This mock object.
- */
-goog.testing.Mock.prototype.$atMostOnce = function() {
- this.$pendingExpectation.minCalls = 0;
- this.$pendingExpectation.maxCalls = 1;
- return this;
-};
-
-
-/**
- * Allows the expectation to be called any number of times, as long as it's
- * called once.
- * @return {goog.testing.Mock} This mock object.
- */
-goog.testing.Mock.prototype.$atLeastOnce = function() {
- this.$pendingExpectation.maxCalls = Infinity;
- return this;
-};
-
-
-/**
- * Allows the expectation to be called any number of times.
- * @return {goog.testing.Mock} This mock object.
- */
-goog.testing.Mock.prototype.$anyTimes = function() {
- this.$pendingExpectation.minCalls = 0;
- this.$pendingExpectation.maxCalls = Infinity;
- return this;
-};
-
-
-/**
- * Specifies the number of times the expectation should be called.
- * @param {number} times The number of times this method will be called.
- * @return {goog.testing.Mock} This mock object.
- */
-goog.testing.Mock.prototype.$times = function(times) {
- this.$pendingExpectation.minCalls = times;
- this.$pendingExpectation.maxCalls = times;
- return this;
-};
-
-
-/**
- * Switches from recording to replay mode.
- */
-goog.testing.Mock.prototype.$replay = function() {
- this.$recording_ = false;
-};
-
-
-/**
- * Resets the state of this mock object. This clears all pending expectations
- * without verifying, and puts the mock in recording mode.
- */
-goog.testing.Mock.prototype.$reset = function() {
- this.$recording_ = true;
- this.$threwException_ = null;
- delete this.$pendingExpectation;
-};
-
-
-/**
- * Throws an exception and records that an exception was thrown.
- * @param {string} comment A short comment about the exception.
- * @param {?string=} opt_message A longer message about the exception.
- * @throws {Object} JsUnitException object.
- * @protected
- */
-goog.testing.Mock.prototype.$throwException = function(comment, opt_message) {
- this.$recordAndThrow(new goog.testing.JsUnitException(comment, opt_message));
-};
-
-
-/**
- * Throws an exception and records that an exception was thrown.
- * @param {Object} ex Exception.
- * @throws {Object} #ex.
- * @protected
- */
-goog.testing.Mock.prototype.$recordAndThrow = function(ex) {
- // If it's an assert exception, record it.
- if (ex['isJsUnitException']) {
- var testRunner = goog.global['G_testRunner'];
- if (testRunner) {
- var logTestFailureFunction = testRunner['logTestFailure'];
- if (logTestFailureFunction) {
- logTestFailureFunction.call(testRunner, ex);
- }
- }
-
- if (!this.$threwException_) {
- // Only remember first exception thrown.
- this.$threwException_ = ex;
- }
- }
- throw ex;
-};
-
-
-/**
- * Verify that all of the expectations were met. Should be overridden by
- * subclasses.
- */
-goog.testing.Mock.prototype.$verify = function() {
- if (this.$threwException_) {
- throw this.$threwException_;
- }
-};
-
-
-/**
- * Verifies that a method call matches an expectation.
- * @param {goog.testing.MockExpectation} expectation The expectation to check.
- * @param {string} name The name of the called method.
- * @param {Array.<*>?} args The arguments passed to the mock.
- * @return {boolean} Whether the call matches the expectation.
- */
-goog.testing.Mock.prototype.$verifyCall = function(expectation, name, args) {
- if (expectation.name != name) {
- return false;
- }
- var verifierFn =
- this.$argumentListVerifiers_.hasOwnProperty(expectation.name) ?
- this.$argumentListVerifiers_[expectation.name] :
- goog.testing.mockmatchers.flexibleArrayMatcher;
-
- return verifierFn(expectation.argumentList, args, expectation);
-};
-
-
-/**
- * Render the provided argument array to a string to help
- * clients with debugging tests.
- * @param {Array.<*>?} args The arguments passed to the mock.
- * @return {string} Human-readable string.
- */
-goog.testing.Mock.prototype.$argumentsAsString = function(args) {
- var retVal = [];
- for (var i = 0; i < args.length; i++) {
- try {
- retVal.push(goog.typeOf(args[i]));
- } catch (e) {
- retVal.push('[unknown]');
- }
- }
- return '(' + retVal.join(', ') + ')';
-};
-
-
-/**
- * Throw an exception based on an incorrect method call.
- * @param {string} name Name of method called.
- * @param {Array.<*>?} args Arguments passed to the mock.
- * @param {goog.testing.MockExpectation=} opt_expectation Expected next call,
- * if any.
- */
-goog.testing.Mock.prototype.$throwCallException = function(name, args,
- opt_expectation) {
- var errorStringBuffer = [];
- var actualArgsString = this.$argumentsAsString(args);
- var expectedArgsString = opt_expectation ?
- this.$argumentsAsString(opt_expectation.argumentList) : '';
-
- if (opt_expectation && opt_expectation.name == name) {
- errorStringBuffer.push('Bad arguments to ', name, '().\n',
- 'Actual: ', actualArgsString, '\n',
- 'Expected: ', expectedArgsString, '\n',
- opt_expectation.getErrorMessage());
- } else {
- errorStringBuffer.push('Unexpected call to ', name,
- actualArgsString, '.');
- if (opt_expectation) {
- errorStringBuffer.push('\nNext expected call was to ',
- opt_expectation.name,
- expectedArgsString);
- }
- }
- this.$throwException(errorStringBuffer.join(''));
-};
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mock_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mock_test.html.svn-base
deleted file mode 100644
index be592a6..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mock_test.html.svn-base
+++ /dev/null
@@ -1,213 +0,0 @@
-<!DOCTYPE html>
-<html>
-<!--
-Copyright 2008 The Closure Library Authors. All Rights Reserved.
-
-Use of this source code is governed by the Apache License, Version 2.0.
-See the COPYING file for details.
--->
-<head>
-<meta http-equiv="X-UA-Compatible" content="IE=edge">
-<title>Closure Unit Tests - goog.testing.Mock</title>
-<script src="../base.js"></script>
-<script>
- goog.require('goog.array');
- goog.require('goog.object');
- goog.require('goog.testing.Mock');
- goog.require('goog.testing.MockExpectation');
- goog.require('goog.testing.jsunit');
-</script>
-</head>
-<body>
-<script>
-
- // The object that we will be mocking
- var RealObject = function() {
- };
-
- RealObject.prototype.a = function() {
- fail('real object should never be called');
- };
-
- RealObject.prototype.b = function() {
- fail('real object should never be called');
- };
-
- var matchers = goog.testing.mockmatchers;
- var mock;
-
- function setUp() {
- var obj = new RealObject();
- mock = new goog.testing.Mock(obj);
- }
-
- function testMockErrorMessage() {
- var expectation = new goog.testing.MockExpectation('a');
- assertEquals(0, expectation.getErrorMessageCount());
- assertEquals('', expectation.getErrorMessage());
-
- expectation.addErrorMessage('foo failed');
- assertEquals(1, expectation.getErrorMessageCount());
- assertEquals('foo failed', expectation.getErrorMessage());
-
- expectation.addErrorMessage('bar failed');
- assertEquals(2, expectation.getErrorMessageCount());
- assertEquals('foo failed\nbar failed', expectation.getErrorMessage());
- }
-
- function testVerifyArgumentList() {
- var expectation = new goog.testing.MockExpectation('a');
- assertEquals('', expectation.getErrorMessage());
-
- // test single string arg
- expectation.argumentList = ['foo'];
- assertTrue(mock.$verifyCall(expectation, 'a', ['foo']));
-
- // single numeric arg
- expectation.argumentList = [2]
- assertTrue(mock.$verifyCall(expectation, 'a', [2]));
-
- // single object arg (using standard === comparison)
- var obj = {prop1: 'prop1', prop2: 2};
- expectation.argumentList = [obj];
- assertTrue(mock.$verifyCall(expectation, 'a', [obj]));
-
- // make sure comparison succeeds if args are similar, but not ===
- var obj2 = {prop1: 'prop1', prop2: 2};
- expectation.argumentList = [obj];
- assertTrue(mock.$verifyCall(expectation, 'a', [obj2]));
- assertEquals('', expectation.getErrorMessage());
-
- // multiple args
- expectation.argumentList = ['foo', 2, obj, obj2];
- assertTrue(mock.$verifyCall(expectation, 'a', ['foo', 2, obj, obj2]));
-
- // test flexible arg matching.
- expectation.argumentList = ['foo', matchers.isNumber];
- assertTrue(mock.$verifyCall(expectation, 'a', ['foo', 1]));
-
- expectation.argumentList = [new matchers.InstanceOf(RealObject)];
- assertTrue(mock.$verifyCall(expectation, 'a', [new RealObject()]));
- }
-
- function testVerifyArgumentListForObjectMethods() {
- var expectation = new goog.testing.MockExpectation('toString');
- expectation.argumentList = []
- assertTrue(mock.$verifyCall(expectation, 'toString', []));
- }
-
- function testRegisterArgumentListVerifier() {
- var expectationA = new goog.testing.MockExpectation('a');
- var expectationB = new goog.testing.MockExpectation('b');
-
- // Simple matcher that return true if all args are === equivalent.
- mock.$registerArgumentListVerifier('a', function(expectedArgs, args) {
- return goog.array.equals(expectedArgs, args, function(a, b) {
- return (a === b);
- });
- });
-
- // test single string arg
- expectationA.argumentList = ['foo'];
- assertTrue(mock.$verifyCall(expectationA, 'a', ['foo']));
-
- // single numeric arg
- expectationA.argumentList = [2]
- assertTrue(mock.$verifyCall(expectationA, 'a', [2]));
-
- // single object arg (using standard === comparison)
- var obj = {prop1: 'prop1', prop2: 2};
- expectationA.argumentList = [obj];
- expectationB.argumentList = [obj];
- assertTrue(mock.$verifyCall(expectationA, 'a', [obj]));
- assertTrue(mock.$verifyCall(expectationB, 'b', [obj]));
-
- // if args are similar, but not ===, then comparison should succeed
- // for method with registered object matcher, and fail for method without
- var obj2 = {prop1: 'prop1', prop2: 2};
- expectationA.argumentList = [obj];
- expectationB.argumentList = [obj];
- assertFalse(mock.$verifyCall(expectationA, 'a', [obj2]))
- assertTrue(mock.$verifyCall(expectationB, 'b', [obj2]));
-
-
- // multiple args, should fail for method with registered arg matcher,
- // and succeed for method without.
- expectationA.argumentList = ['foo', 2, obj, obj2];
- expectationB.argumentList = ['foo', 2, obj, obj2];
- assertFalse(mock.$verifyCall(expectationA, 'a', ['foo', 2, obj2, obj]));
- assertTrue(mock.$verifyCall(expectationB, 'b', ['foo', 2, obj2, obj]));
- }
-
-
- function testCreateProxy() {
- mock = new goog.testing.Mock(RealObject, false, true);
- assertTrue(mock.$proxy instanceof RealObject);
- assertThrows(function() {
- new goog.testing.Mock(RealObject, true, true);
- });
- assertThrows(function() {
- new goog.testing.Mock(1, false, true);
- });
- }
-
-
- function testValidConstructorArgument() {
- var someNamespace = { };
- assertThrows(function() {
- new goog.testing.Mock(someNamespace.RealObjectWithTypo);
- });
- }
-
-
- function testArgumentsAsString() {
- assertEquals('()', mock.$argumentsAsString([]));
- assertEquals('(string, number, object, null)',
- mock.$argumentsAsString(['red', 1, {}, null]));
- }
-
-
- function testThrowCallExceptionBadArgs() {
- var msg;
- mock.$throwException = function(m) {
- msg = m;
- };
-
- mock.$throwCallException(
- 'fn1', [ 'b' ],
- { name: 'fn1',
- argumentList: [ 'c' ],
- getErrorMessage: function() { return ''; } });
- assertContains(
- 'Bad arguments to fn1().\nActual: (string)\nExpected: (string)', msg);
- }
-
- function testThrowCallExceptionUnexpected() {
- var msg;
- mock.$throwException = function(m) {
- msg = m;
- };
-
- mock.$throwCallException('fn1', [ 'b' ]);
- assertEquals('Unexpected call to fn1(string).', msg);
- }
-
- function testThrowCallExceptionUnexpectedWithNext() {
- var msg;
- mock.$throwException = function(m) {
- msg = m;
- };
-
- mock.$throwCallException(
- 'fn1', [ 'b' ],
- { name: 'fn2',
- argumentList: [ 3 ],
- getErrorMessage: function() { return ''; } });
- assertEquals(
- 'Unexpected call to fn1(string).\n' +
- 'Next expected call was to fn2(number)', msg);
- }
-
-</script>
-</body>
-</html>
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mockclassfactory.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mockclassfactory.js.svn-base
deleted file mode 100644
index 4f71b39..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mockclassfactory.js.svn-base
+++ /dev/null
@@ -1,580 +0,0 @@
-// Copyright 2008 The Closure Library Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS-IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/**
- * @fileoverview This file defines a factory that can be used to mock and
- * replace an entire class. This allows for mocks to be used effectively with
- * "new" instead of having to inject all instances. Essentially, a given class
- * is replaced with a proxy to either a loose or strict mock. Proxies locate
- * the appropriate mock based on constructor arguments.
- *
- * The usage is:
- * <ul>
- * <li>Create a mock with one of the provided methods with a specifc set of
- * constructor arguments
- * <li>Set expectations by calling methods on the mock object
- * <li>Call $replay() on the mock object
- * <li>Instantiate the object as normal
- * <li>Call $verify() to make sure that expectations were met
- * <li>Call reset on the factory to revert all classes back to their original
- * state
- * </ul>
- *
- * For examples, please see the unit test.
- *
- */
-
-
-goog.provide('goog.testing.MockClassFactory');
-goog.provide('goog.testing.MockClassRecord');
-
-goog.require('goog.array');
-goog.require('goog.object');
-goog.require('goog.testing.LooseMock');
-goog.require('goog.testing.StrictMock');
-goog.require('goog.testing.TestCase');
-goog.require('goog.testing.mockmatchers');
-
-
-
-/**
- * A record that represents all the data associated with a mock replacement of
- * a given class.
- * @param {Object} namespace The namespace in which the mocked class resides.
- * @param {string} className The name of the class within the namespace.
- * @param {Function} originalClass The original class implementation before it
- * was replaced by a proxy.
- * @param {Function} proxy The proxy that replaced the original class.
- * @constructor
- */
-goog.testing.MockClassRecord = function(namespace, className, originalClass,
- proxy) {
- /**
- * A standard closure namespace (e.g. goog.foo.bar) that contains the mock
- * class referenced by this MockClassRecord.
- * @type {Object}
- * @private
- */
- this.namespace_ = namespace;
-
- /**
- * The name of the class within the provided namespace.
- * @type {string}
- * @private
- */
- this.className_ = className;
-
- /**
- * The original class implementation.
- * @type {Function}
- * @private
- */
- this.originalClass_ = originalClass;
-
- /**
- * The proxy being used as a replacement for the original class.
- * @type {Function}
- * @private
- */
- this.proxy_ = proxy;
-
- /**
- * A mocks that will be constructed by their argument list. The entries are
- * objects with the format {'args': args, 'mock': mock}.
- * @type {Array.<Object>}
- * @private
- */
- this.instancesByArgs_ = [];
-};
-
-
-/**
- * A mock associated with the static functions for a given class.
- * @type {goog.testing.StrictMock|goog.testing.LooseMock|null}
- * @private
- */
-goog.testing.MockClassRecord.prototype.staticMock_ = null;
-
-
-/**
- * A getter for this record's namespace.
- * @return {Object} The namespace.
- */
-goog.testing.MockClassRecord.prototype.getNamespace = function() {
- return this.namespace_;
-};
-
-
-/**
- * A getter for this record's class name.
- * @return {string} The name of the class referenced by this record.
- */
-goog.testing.MockClassRecord.prototype.getClassName = function() {
- return this.className_;
-};
-
-
-/**
- * A getter for the original class.
- * @return {Function} The original class implementation before mocking.
- */
-goog.testing.MockClassRecord.prototype.getOriginalClass = function() {
- return this.originalClass_;
-};
-
-
-/**
- * A getter for the proxy being used as a replacement for the original class.
- * @return {Function} The proxy.
- */
-goog.testing.MockClassRecord.prototype.getProxy = function() {
- return this.proxy_;
-};
-
-
-/**
- * A getter for the static mock.
- * @return {goog.testing.StrictMock|goog.testing.LooseMock|null} The static
- * mock associated with this record.
- */
-goog.testing.MockClassRecord.prototype.getStaticMock = function() {
- return this.staticMock_;
-};
-
-
-/**
- * A setter for the static mock.
- * @param {goog.testing.StrictMock|goog.testing.LooseMock} staticMock A mock to
- * associate with the static functions for the referenced class.
- */
-goog.testing.MockClassRecord.prototype.setStaticMock = function(staticMock) {
- this.staticMock_ = staticMock;
-};
-
-
-/**
- * Adds a new mock instance mapping. The mapping connects a set of function
- * arguments to a specific mock instance.
- * @param {Array} args An array of function arguments.
- * @param {goog.testing.StrictMock|goog.testing.LooseMock} mock A mock
- * associated with the supplied arguments.
- */
-goog.testing.MockClassRecord.prototype.addMockInstance = function(args, mock) {
- this.instancesByArgs_.push({args: args, mock: mock});
-};
-
-
-/**
- * Finds the mock corresponding to a given argument set. Throws an error if
- * there is no appropriate match found.
- * @param {Array} args An array of function arguments.
- * @return {goog.testing.StrictMock|goog.testing.LooseMock|null} The mock
- * corresponding to a given argument set.
- */
-goog.testing.MockClassRecord.prototype.findMockInstance = function(args) {
- for (var i = 0; i < this.instancesByArgs_.length; i++) {
- var instanceArgs = this.instancesByArgs_[i].args;
- if (goog.testing.mockmatchers.flexibleArrayMatcher(instanceArgs, args)) {
- return this.instancesByArgs_[i].mock;
- }
- }
-
- return null;
-};
-
-
-/**
- * Resets this record by reverting all the mocked classes back to the original
- * implementation and clearing out the mock instance list.
- */
-goog.testing.MockClassRecord.prototype.reset = function() {
- this.namespace_[this.className_] = this.originalClass_;
- this.instancesByArgs_ = [];
-};
-
-
-
-/**
- * A factory used to create new mock class instances. It is able to generate
- * both static and loose mocks. The MockClassFactory is a singleton since it
- * tracks the classes that have been mocked internally.
- * @constructor
- */
-goog.testing.MockClassFactory = function() {
- if (goog.testing.MockClassFactory.instance_) {
- return goog.testing.MockClassFactory.instance_;
- }
-
- /**
- * A map from class name -> goog.testing.MockClassRecord.
- * @type {Object}
- * @private
- */
- this.mockClassRecords_ = {};
-
- goog.testing.MockClassFactory.instance_ = this;
-};
-
-
-/**
- * A singleton instance of the MockClassFactory.
- * @type {goog.testing.MockClassFactory?}
- * @private
- */
-goog.testing.MockClassFactory.instance_ = null;
-
-
-/**
- * The names of the fields that are defined on Object.prototype.
- * @type {Array.<string>}
- * @private
- */
-goog.testing.MockClassFactory.PROTOTYPE_FIELDS_ = [
- 'constructor',
- 'hasOwnProperty',
- 'isPrototypeOf',
- 'propertyIsEnumerable',
- 'toLocaleString',
- 'toString',
- 'valueOf'
-];
-
-
-/**
- * Iterates through a namespace to find the name of a given class. This is done
- * solely to support compilation since string identifiers would break down.
- * Tests usually aren't compiled, but the functionality is supported.
- * @param {Object} namespace A javascript namespace (e.g. goog.testing).
- * @param {Function} classToMock The class whose name should be returned.
- * @return {string} The name of the class.
- * @private
- */
-goog.testing.MockClassFactory.prototype.getClassName_ = function(namespace,
- classToMock) {
- if (namespace === goog.global) {
- namespace = goog.testing.TestCase.getGlobals();
- }
- for (var prop in namespace) {
- if (namespace[prop] === classToMock) {
- return prop;
- }
- }
-
- throw Error('Class is not a part of the given namespace');
-};
-
-
-/**
- * Returns whether or not a given class has been mocked.
- * @param {string} className The name of the class.
- * @return {boolean} Whether or not the given class name has a MockClassRecord.
- * @private
- */
-goog.testing.MockClassFactory.prototype.classHasMock_ = function(className) {
- return !!this.mockClassRecords_[className];
-};
-
-
-/**
- * Returns a proxy constructor closure. Since this is a constructor, "this"
- * refers to the local scope of the constructed object thus bind cannot be
- * used.
- * @param {string} className The name of the class.
- * @param {Function} mockFinder A bound function that returns the mock
- * associated with a class given the constructor's argument list.
- * @return {Function} A proxy constructor.
- * @private
- */
-goog.testing.MockClassFactory.prototype.getProxyCtor_ = function(className,
- mockFinder) {
- return function() {
- this.$mock_ = mockFinder(className, arguments);
- if (!this.$mock_) {
- // The "arguments" variable is not a proper Array so it must be converted.
- var args = Array.prototype.slice.call(arguments, 0);
- throw Error('No mock found for ' + className + ' with arguments ' +
- args.join(', '));
- }
- };
-};
-
-
-/**
- * Returns a proxy function for a mock class instance. This function cannot
- * be used with bind since "this" must refer to the scope of the proxy
- * constructor.
- * @param {string} fnName The name of the function that should be proxied.
- * @return {Function} A proxy function.
- * @private
- */
-goog.testing.MockClassFactory.prototype.getProxyFunction_ = function(fnName) {
- return function() {
- return this.$mock_[fnName].apply(this.$mock_, arguments);
- };
-};
-
-
-/**
- * Find a mock instance for a given class name and argument list.
- * @param {string} className The name of the class.
- * @param {Array} args The argument list to match.
- * @return {goog.testing.StrictMock|goog.testing.LooseMock} The mock found for
- * the given argument list.
- * @private
- */
-goog.testing.MockClassFactory.prototype.findMockInstance_ = function(className,
- args) {
- return this.mockClassRecords_[className].findMockInstance(args);
-};
-
-
-/**
- * Create a proxy class. A proxy will pass functions to the mock for a class.
- * The proxy class only covers prototype methods. A static mock is not build
- * simultaneously since it might be strict or loose. The proxy class inherits
- * from the target class in order to preserve instanceof checks.
- * @param {Object} namespace A javascript namespace (e.g. goog.testing).
- * @param {Function} classToMock The class that will be proxied.
- * @param {string} className The name of the class.
- * @return {Function} The proxy for provided class.
- * @private
- */
-goog.testing.MockClassFactory.prototype.createProxy_ = function(namespace,
- classToMock, className) {
- var proxy = this.getProxyCtor_(className,
- goog.bind(this.findMockInstance_, this));
- var protoToProxy = classToMock.prototype;
- goog.inherits(proxy, classToMock);
-
- for (var prop in protoToProxy) {
- if (goog.isFunction(protoToProxy[prop])) {
- proxy.prototype[prop] = this.getProxyFunction_(prop);
- }
- }
-
- // For IE the for-in-loop does not contain any properties that are not
- // enumerable on the prototype object (for example isPrototypeOf from
- // Object.prototype) and it will also not include 'replace' on objects that
- // extend String and change 'replace' (not that it is common for anyone to
- // extend anything except Object).
- // TODO (arv): Implement goog.object.getIterator and replace this loop.
-
- goog.array.forEach(goog.testing.MockClassFactory.PROTOTYPE_FIELDS_,
- function(field) {
- if (Object.prototype.hasOwnProperty.call(protoToProxy, field)) {
- proxy.prototype[field] = this.getProxyFunction_(field);
- }
- }, this);
-
- this.mockClassRecords_[className] = new goog.testing.MockClassRecord(
- namespace, className, classToMock, proxy);
- namespace[className] = proxy;
- return proxy;
-};
-
-
-/**
- * Gets either a loose or strict mock for a given class based on a set of
- * arguments.
- * @param {Object} namespace A javascript namespace (e.g. goog.testing).
- * @param {Function} classToMock The class that will be mocked.
- * @param {boolean} isStrict Whether or not the mock should be strict.
- * @param {Array} ctorArgs The arguments associated with this instance's
- * constructor.
- * @return {goog.testing.StrictMock|goog.testing.LooseMock} The mock created
- * for the provided class.
- * @private
- */
-goog.testing.MockClassFactory.prototype.getMockClass_ =
- function(namespace, classToMock, isStrict, ctorArgs) {
- var className = this.getClassName_(namespace, classToMock);
-
- // The namespace and classToMock variables should be removed from the
- // passed in argument stack.
- ctorArgs = goog.array.slice(ctorArgs, 2);
-
- if (goog.isFunction(classToMock)) {
- var mock = isStrict ? new goog.testing.StrictMock(classToMock) :
- new goog.testing.LooseMock(classToMock);
-
- if (!this.classHasMock_(className)) {
- this.createProxy_(namespace, classToMock, className);
- } else {
- var instance = this.findMockInstance_(className, ctorArgs);
- if (instance) {
- throw Error('Mock instance already created for ' + className +
- ' with arguments ' + ctorArgs.join(', '));
- }
- }
- this.mockClassRecords_[className].addMockInstance(ctorArgs, mock);
-
- return mock;
- } else {
- throw Error('Cannot create a mock class for ' + className +
- ' of type ' + typeof classToMock);
- }
-};
-
-
-/**
- * Gets a strict mock for a given class.
- * @param {Object} namespace A javascript namespace (e.g. goog.testing).
- * @param {Function} classToMock The class that will be mocked.
- * @param {...*} var_args The arguments associated with this instance's
- * constructor.
- * @return {goog.testing.StrictMock} The mock created for the provided class.
- */
-goog.testing.MockClassFactory.prototype.getStrictMockClass =
- function(namespace, classToMock, var_args) {
- var args = /** @type {Array} */ (arguments);
- return /** @type {goog.testing.StrictMock} */ (this.getMockClass_(namespace,
- classToMock, true, args));
-};
-
-
-/**
- * Gets a loose mock for a given class.
- * @param {Object} namespace A javascript namespace (e.g. goog.testing).
- * @param {Function} classToMock The class that will be mocked.
- * @param {...*} var_args The arguments associated with this instance's
- * constructor.
- * @return {goog.testing.LooseMock} The mock created for the provided class.
- */
-goog.testing.MockClassFactory.prototype.getLooseMockClass =
- function(namespace, classToMock, var_args) {
- var args = /** @type {Array} */ (arguments);
- return /** @type {goog.testing.LooseMock} */ (this.getMockClass_(namespace,
- classToMock, false, args));
-};
-
-
-/**
- * Creates either a loose or strict mock for the static functions of a given
- * class.
- * @param {Function} classToMock The class whose static functions will be
- * mocked. This should be the original class and not the proxy.
- * @param {string} className The name of the class.
- * @param {Function} proxy The proxy that will replace the original class.
- * @param {boolean} isStrict Whether or not the mock should be strict.
- * @return {goog.testing.StrictMock|goog.testing.LooseMock} The mock created
- * for the static functions of the provided class.
- * @private
- */
-goog.testing.MockClassFactory.prototype.createStaticMock_ =
- function(classToMock, className, proxy, isStrict) {
- var mock = isStrict ? new goog.testing.StrictMock(classToMock, true) :
- new goog.testing.LooseMock(classToMock, false, true);
-
- for (var prop in classToMock) {
- if (goog.isFunction(classToMock[prop])) {
- proxy[prop] = goog.bind(mock.$mockMethod, mock, prop);
- } else if (classToMock[prop] !== classToMock.prototype) {
- proxy[prop] = classToMock[prop];
- }
- }
-
- this.mockClassRecords_[className].setStaticMock(mock);
- return mock;
-};
-
-
-/**
- * Gets either a loose or strict mock for the static functions of a given class.
- * @param {Object} namespace A javascript namespace (e.g. goog.testing).
- * @param {Function} classToMock The class whose static functions will be
- * mocked. This should be the original class and not the proxy.
- * @param {boolean} isStrict Whether or not the mock should be strict.
- * @return {goog.testing.StrictMock|goog.testing.LooseMock} The mock created
- * for the static functions of the provided class.
- * @private
- */
-goog.testing.MockClassFactory.prototype.getStaticMock_ = function(namespace,
- classToMock, isStrict) {
- var className = this.getClassName_(namespace, classToMock);
-
- if (goog.isFunction(classToMock)) {
- if (!this.classHasMock_(className)) {
- var proxy = this.createProxy_(namespace, classToMock, className);
- var mock = this.createStaticMock_(classToMock, className, proxy,
- isStrict);
- return mock;
- }
-
- if (!this.mockClassRecords_[className].getStaticMock()) {
- var proxy = this.mockClassRecords_[className].getProxy();
- var originalClass = this.mockClassRecords_[className].getOriginalClass();
- var mock = this.createStaticMock_(originalClass, className, proxy,
- isStrict);
- return mock;
- } else {
- var mock = this.mockClassRecords_[className].getStaticMock();
- var mockIsStrict = mock instanceof goog.testing.StrictMock;
-
- if (mockIsStrict != isStrict) {
- var mockType = mock instanceof goog.testing.StrictMock ? 'strict' :
- 'loose';
- var requestedType = isStrict ? 'strict' : 'loose';
- throw Error('Requested a ' + requestedType + ' static mock, but a ' +
- mockType + ' mock already exists.');
- }
-
- return mock;
- }
- } else {
- throw Error('Cannot create a mock for the static functions of ' +
- className + ' of type ' + typeof classToMock);
- }
-};
-
-
-/**
- * Gets a strict mock for the static functions of a given class.
- * @param {Object} namespace A javascript namespace (e.g. goog.testing).
- * @param {Function} classToMock The class whose static functions will be
- * mocked. This should be the original class and not the proxy.
- * @return {goog.testing.StrictMock} The mock created for the static functions
- * of the provided class.
- */
-goog.testing.MockClassFactory.prototype.getStrictStaticMock =
- function(namespace, classToMock) {
- return /** @type {goog.testing.StrictMock} */ (this.getStaticMock_(namespace,
- classToMock, true));
-};
-
-
-/**
- * Gets a loose mock for the static functions of a given class.
- * @param {Object} namespace A javascript namespace (e.g. goog.testing).
- * @param {Function} classToMock The class whose static functions will be
- * mocked. This should be the original class and not the proxy.
- * @return {goog.testing.LooseMock} The mock created for the static functions
- * of the provided class.
- */
-goog.testing.MockClassFactory.prototype.getLooseStaticMock =
- function(namespace, classToMock) {
- return /** @type {goog.testing.LooseMock} */ (this.getStaticMock_(namespace,
- classToMock, false));
-};
-
-
-/**
- * Resests the factory by reverting all mocked classes to their original
- * implementations and removing all MockClassRecords.
- */
-goog.testing.MockClassFactory.prototype.reset = function() {
- goog.object.forEach(this.mockClassRecords_, function(record) {
- record.reset();
- });
- this.mockClassRecords_ = {};
-};
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mockclassfactory_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mockclassfactory_test.html.svn-base
deleted file mode 100644
index ba6d0f8..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mockclassfactory_test.html.svn-base
+++ /dev/null
@@ -1,241 +0,0 @@
-<!DOCTYPE html>
-<html>
-<!--
-Copyright 2008 The Closure Library Authors. All Rights Reserved.
-
-Use of this source code is governed by the Apache License, Version 2.0.
-See the COPYING file for details.
--->
-<head>
-<meta http-equiv="X-UA-Compatible" content="IE=edge">
-<title>Closure Unit Tests - goog.testing.MockClassFactory</title>
-<script src="../base.js"></script>
-<script>
- goog.require('goog.testing.MockClassFactory');
- goog.require('goog.testing.jsunit');
-</script>
-</head>
-<body>
-<script>
- goog.provide('fake.BaseClass');
- goog.provide('fake.ChildClass');
-
- // Classes that will be mocked. A base class and child class are used to
- // test inheritance.
- fake.BaseClass = function(a) {
- fail('real object should never be called');
- };
-
- fake.BaseClass.prototype.foo = function() {
- fail('real object should never be called');
- };
-
- fake.BaseClass.prototype.toString = function() {return 'foo';}
-
- fake.BaseClass.prototype.toLocaleString = function() {return 'bar';}
-
- fake.ChildClass = function(a) {
- fail('real object should never be called');
- };
- goog.inherits(fake.ChildClass, fake.BaseClass);
-
- fake.ChildClass.staticFoo = function() {
- fail('real object should never be called');
- };
-
- fake.ChildClass.prototype.bar = function() {
- fail('real object should never be called');
- };
-
- fake.ChildClass.staticProperty = 'staticPropertyOnClass';
-
- function TopLevelBaseClass() {
- }
-
- var mockClassFactory = new goog.testing.MockClassFactory();
- var matchers = goog.testing.mockmatchers;
-
- function tearDown() {
- mockClassFactory.reset();
- };
-
- function testGetStrictMockClass() {
- var mock1 = mockClassFactory.getStrictMockClass(fake, fake.BaseClass, 1);
- mock1.foo();
- mock1.$replay();
-
- var mock2 = mockClassFactory.getStrictMockClass(fake, fake.BaseClass, 2);
- mock2.foo();
- mock2.$replay();
-
- var mock3 = mockClassFactory.getStrictMockClass(fake, fake.ChildClass, 3);
- mock3.foo();
- mock3.bar();
- mock3.$replay();
-
- var instance1 = new fake.BaseClass(1);
- instance1.foo();
- mock1.$verify();
-
- var instance2 = new fake.BaseClass(2);
- instance2.foo();
- mock2.$verify();
-
- var instance3 = new fake.ChildClass(3);
- instance3.foo();
- instance3.bar();
- mock3.$verify();
-
- assertThrows(function() {new fake.BaseClass(-1)});
- assertTrue(instance1 instanceof fake.BaseClass);
- assertTrue(instance2 instanceof fake.BaseClass);
- assertTrue(instance3 instanceof fake.ChildClass);
- };
-
- function testGetStrictMockClassCreatesAllProxies() {
- var mock1 = mockClassFactory.getStrictMockClass(fake, fake.BaseClass, 1);
- // toString(), toLocaleString() and others are treaded specially in
- // createProxy_().
- mock1.toString();
- mock1.toLocaleString();
- mock1.$replay();
-
- var instance1 = new fake.BaseClass(1);
- instance1.toString();
- instance1.toLocaleString();
- mock1.$verify();
- }
-
- function testGetLooseMockClass() {
- var mock1 = mockClassFactory.getLooseMockClass(fake, fake.BaseClass, 1);
- mock1.foo().$anyTimes().$returns(3);
- mock1.$replay();
-
- var mock2 = mockClassFactory.getLooseMockClass(fake, fake.BaseClass, 2);
- mock2.foo().$times(3);
- mock2.$replay();
-
- var mock3 = mockClassFactory.getLooseMockClass(fake, fake.ChildClass, 3);
- mock3.foo().$atLeastOnce().$returns(5);
- mock3.bar().$atLeastOnce();
- mock3.$replay();
-
- var instance1 = new fake.BaseClass(1);
- assertEquals(3, instance1.foo());
- assertEquals(3, instance1.foo());
- assertEquals(3, instance1.foo());
- assertEquals(3, instance1.foo());
- assertEquals(3, instance1.foo());
- mock1.$verify();
-
- var instance2 = new fake.BaseClass(2);
- instance2.foo();
- instance2.foo();
- instance2.foo();
- mock2.$verify();
-
- var instance3 = new fake.ChildClass(3);
- assertEquals(5, instance3.foo());
- assertEquals(5, instance3.foo());
- instance3.bar();
- mock3.$verify();
-
- assertThrows(function() {new fake.BaseClass(-1)});
- assertTrue(instance1 instanceof fake.BaseClass);
- assertTrue(instance2 instanceof fake.BaseClass);
- assertTrue(instance3 instanceof fake.ChildClass);
- };
-
- function testGetStrictStaticMock() {
- var staticMock = mockClassFactory.getStrictStaticMock(fake,
- fake.ChildClass);
- var mock = mockClassFactory.getStrictMockClass(fake, fake.ChildClass, 1);
-
- mock.foo();
- mock.bar();
- staticMock.staticFoo();
- mock.$replay();
- staticMock.$replay();
-
- var instance = new fake.ChildClass(1);
- instance.foo();
- instance.bar();
- fake.ChildClass.staticFoo();
- mock.$verify();
- staticMock.$verify();
-
- assertTrue(instance instanceof fake.BaseClass);
- assertTrue(instance instanceof fake.ChildClass);
- assertThrows(function() {
- mockClassFactory.getLooseStaticMock(fake, fake.ChildClass)
- });
- };
-
- function testGetStrictStaticMockKeepsStaticProperties() {
- var OriginalChildClass = fake.ChildClass;
- var staticMock = mockClassFactory.getStrictStaticMock(fake,
- fake.ChildClass);
- assertEquals(OriginalChildClass.staticProperty,
- fake.ChildClass.staticProperty);
- };
-
- function testGetLooseStaticMockKeepsStaticProperties() {
- var OriginalChildClass = fake.ChildClass;
- var staticMock = mockClassFactory.getLooseStaticMock(fake,
- fake.ChildClass);
- assertEquals(OriginalChildClass.staticProperty,
- fake.ChildClass.staticProperty);
- };
-
- function testGetLooseStaticMock() {
- var staticMock = mockClassFactory.getLooseStaticMock(fake,
- fake.ChildClass);
- var mock = mockClassFactory.getStrictMockClass(fake, fake.ChildClass, 1);
-
- mock.foo();
- mock.bar();
- staticMock.staticFoo().$atLeastOnce();
- mock.$replay();
- staticMock.$replay();
-
- var instance = new fake.ChildClass(1);
- instance.foo();
- instance.bar();
- fake.ChildClass.staticFoo();
- fake.ChildClass.staticFoo();
- mock.$verify();
- staticMock.$verify();
-
- assertTrue(instance instanceof fake.BaseClass);
- assertTrue(instance instanceof fake.ChildClass);
- assertThrows(function() {
- mockClassFactory.getStrictStaticMock(fake, fake.ChildClass)
- });
- };
-
- function testFlexibleClassMockInstantiation() {
- // This mock should be returned for all instances created with a number
- // as the first argument.
- var mock = mockClassFactory.getStrictMockClass(fake, fake.ChildClass,
- matchers.isNumber);
- mock.foo(); // Will be called by the first mock instance.
- mock.foo(); // Will be called by the second mock instance.
- mock.$replay();
-
- var instance1 = new fake.ChildClass(1);
- var instance2 = new fake.ChildClass(2);
- instance1.foo();
- instance2.foo();
- assertThrows(function() {
- new fake.ChildClass('foo');
- });
- mock.$verify();
- };
-
- function testMockTopLevelClass() {
- var mock = mockClassFactory.getStrictMockClass(goog.global,
- goog.global.TopLevelBaseClass);
- }
-</script>
-</body>
-</html>
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mockclock.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mockclock.js.svn-base
deleted file mode 100644
index 30b62bc..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mockclock.js.svn-base
+++ /dev/null
@@ -1,410 +0,0 @@
-// Copyright 2007 The Closure Library Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS-IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/**
- * @fileoverview Mock Clock implementation for working with setTimeout,
- * setInterval, clearTimeout and clearInterval within unit tests.
- *
- * Derived from jsUnitMockTimeout.js, contributed to JsUnit by
- * Pivotal Computer Systems, www.pivotalsf.com
- *
- */
-
-goog.provide('goog.testing.MockClock');
-
-goog.require('goog.Disposable');
-goog.require('goog.testing.PropertyReplacer');
-
-
-
-/**
- * Class for unit testing code that uses setTimeout and clearTimeout.
- *
- * NOTE: If you are using MockClock to test code that makes use of
- * goog.fx.Animation, then you must either:
- *
- * 1. Install and dispose of the MockClock in setUpPage() and tearDownPage()
- * respectively (rather than setUp()/tearDown()).
- *
- * or
- *
- * 2. Ensure that every test clears the animation queue by calling
- * mockClock.tick(x) at the end of each test function (where `x` is large
- * enough to complete all animations).
- *
- * Otherwise, if any animation is left pending at the time that
- * MockClock.dispose() is called, that will permanently prevent any future
- * animations from playing on the page.
- *
- * @param {boolean=} opt_autoInstall Install the MockClock at construction time.
- * @constructor
- * @extends {goog.Disposable}
- */
-goog.testing.MockClock = function(opt_autoInstall) {
- goog.Disposable.call(this);
-
- /**
- * Reverse-order queue of timers to fire.
- *
- * The last item of the queue is popped off. Insertion happens from the
- * right. For example, the expiration times for each element of the queue
- * might be in the order 300, 200, 200.
- *
- * @type {Array.<Object>}
- * @private
- */
- this.queue_ = [];
-
- /**
- * Set of timeouts that should be treated as cancelled.
- *
- * Rather than removing cancelled timers directly from the queue, this set
- * simply marks them as deleted so that they can be ignored when their
- * turn comes up. The keys are the timeout keys that are cancelled, each
- * mapping to true.
- *
- * @type {Object}
- * @private
- */
- this.deletedKeys_ = {};
-
- if (opt_autoInstall) {
- this.install();
- }
-};
-goog.inherits(goog.testing.MockClock, goog.Disposable);
-
-
-/**
- * Count of the number of timeouts made.
- * @type {number}
- * @private
- */
-goog.testing.MockClock.prototype.timeoutsMade_ = 0;
-
-
-/**
- * PropertyReplacer instance which overwrites and resets setTimeout,
- * setInterval, etc. or null if the MockClock is not installed.
- * @type {goog.testing.PropertyReplacer}
- * @private
- */
-goog.testing.MockClock.prototype.replacer_ = null;
-
-
-/**
- * Map of deleted keys. These keys represents keys that were deleted in a
- * clearInterval, timeoutid -> object.
- * @type {Object}
- * @private
- */
-goog.testing.MockClock.prototype.deletedKeys_ = null;
-
-
-/**
- * The current simulated time in milliseconds.
- * @type {number}
- * @private
- */
-goog.testing.MockClock.prototype.nowMillis_ = 0;
-
-
-/**
- * Additional delay between the time a timeout was set to fire, and the time
- * it actually fires. Useful for testing workarounds for this Firefox 2 bug:
- * https://bugzilla.mozilla.org/show_bug.cgi?id=291386
- * May be negative.
- * @type {number}
- * @private
- */
-goog.testing.MockClock.prototype.timeoutDelay_ = 0;
-
-
-/**
- * Installs the MockClock by overriding the window object's implementation of
- * setTimeout, setInterval, clearTimeout and clearInterval.
- */
-goog.testing.MockClock.prototype.install = function() {
- if (!this.replacer_) {
- var r = this.replacer_ = new goog.testing.PropertyReplacer();
- r.set(window, 'setTimeout', goog.bind(this.setTimeout_, this));
- r.set(window, 'setInterval', goog.bind(this.setInterval_, this));
- r.set(window, 'clearTimeout', goog.bind(this.clearTimeout_, this));
- r.set(window, 'clearInterval', goog.bind(this.clearInterval_, this));
-
- // PropertyReplacer#set can't be called with renameable functions.
- this.oldGoogNow_ = goog.now;
- goog.now = goog.bind(this.getCurrentTime, this);
- }
-};
-
-
-/**
- * Removes the MockClock's hooks into the window functions and revert to their
- * original values.
- */
-goog.testing.MockClock.prototype.uninstall = function() {
- if (this.replacer_) {
- this.replacer_.reset();
- this.replacer_ = null;
- goog.now = this.oldGoogNow_;
- }
-};
-
-
-/** @override */
-goog.testing.MockClock.prototype.disposeInternal = function() {
- this.uninstall();
- this.queue_ = null;
- this.deletedKeys_ = null;
- goog.testing.MockClock.superClass_.disposeInternal.call(this);
-};
-
-
-/**
- * Resets the MockClock, removing all timeouts that are scheduled and resets
- * the fake timer count.
- */
-goog.testing.MockClock.prototype.reset = function() {
- this.queue_ = [];
- this.deletedKeys_ = {};
- this.nowMillis_ = 0;
- this.timeoutsMade_ = 0;
- this.timeoutDelay_ = 0;
-};
-
-
-/**
- * Sets the amount of time between when a timeout is scheduled to fire and when
- * it actually fires.
- * @param {number} delay The delay in milliseconds. May be negative.
- */
-goog.testing.MockClock.prototype.setTimeoutDelay = function(delay) {
- this.timeoutDelay_ = delay;
-};
-
-
-/**
- * @return {number} delay The amount of time between when a timeout is
- * scheduled to fire and when it actually fires, in milliseconds. May
- * be negative.
- */
-goog.testing.MockClock.prototype.getTimeoutDelay = function() {
- return this.timeoutDelay_;
-};
-
-
-/**
- * Increments the MockClock's time by a given number of milliseconds, running
- * any functions that are now overdue.
- * @param {number=} opt_millis Number of milliseconds to increment the counter.
- * If not specified, clock ticks 1 millisecond.
- * @return {number} Current mock time in milliseconds.
- */
-goog.testing.MockClock.prototype.tick = function(opt_millis) {
- if (typeof opt_millis != 'number') {
- opt_millis = 1;
- }
- var endTime = this.nowMillis_ + opt_millis;
- this.runFunctionsWithinRange_(endTime);
- this.nowMillis_ = endTime;
- return endTime;
-};
-
-
-/**
- * @return {number} The number of timeouts that have been scheduled.
- */
-goog.testing.MockClock.prototype.getTimeoutsMade = function() {
- return this.timeoutsMade_;
-};
-
-
-/**
- * @return {number} The MockClock's current time in milliseconds.
- */
-goog.testing.MockClock.prototype.getCurrentTime = function() {
- return this.nowMillis_;
-};
-
-
-/**
- * @param {number} timeoutKey The timeout key.
- * @return {boolean} Whether the timer has been set and not cleared,
- * independent of the timeout's expiration. In other words, the timeout
- * could have passed or could be scheduled for the future. Either way,
- * this function returns true or false depending only on whether the
- * provided timeoutKey represents a timeout that has been set and not
- * cleared.
- */
-goog.testing.MockClock.prototype.isTimeoutSet = function(timeoutKey) {
- return timeoutKey <= this.timeoutsMade_ && !this.deletedKeys_[timeoutKey];
-};
-
-
-/**
- * Runs any function that is scheduled before a certain time. Timeouts can
- * be made to fire early or late if timeoutDelay_ is non-0.
- * @param {number} endTime The latest time in the range, in milliseconds.
- * @private
- */
-goog.testing.MockClock.prototype.runFunctionsWithinRange_ = function(
- endTime) {
- var adjustedEndTime = endTime - this.timeoutDelay_;
-
- // Repeatedly pop off the last item since the queue is always sorted.
- while (this.queue_.length &&
- this.queue_[this.queue_.length - 1].runAtMillis <= adjustedEndTime) {
- var timeout = this.queue_.pop();
-
- if (!(timeout.timeoutKey in this.deletedKeys_)) {
- // Only move time forwards.
- this.nowMillis_ = Math.max(this.nowMillis_,
- timeout.runAtMillis + this.timeoutDelay_);
- // Call timeout in global scope and pass the timeout key as the argument.
- timeout.funcToCall.call(goog.global, timeout.timeoutKey);
- // In case the interval was cleared in the funcToCall
- if (timeout.recurring) {
- this.scheduleFunction_(
- timeout.timeoutKey, timeout.funcToCall, timeout.millis, true);
- }
- }
- }
-};
-
-
-/**
- * Schedules a function to be run at a certain time.
- * @param {number} timeoutKey The timeout key.
- * @param {Function} funcToCall The function to call.
- * @param {number} millis The number of milliseconds to call it in.
- * @param {boolean} recurring Whether to function call should recur.
- * @private
- */
-goog.testing.MockClock.prototype.scheduleFunction_ = function(
- timeoutKey, funcToCall, millis, recurring) {
- var timeout = {
- runAtMillis: this.nowMillis_ + millis,
- funcToCall: funcToCall,
- recurring: recurring,
- timeoutKey: timeoutKey,
- millis: millis
- };
-
- goog.testing.MockClock.insert_(timeout, this.queue_);
-};
-
-
-/**
- * Inserts a timer descriptor into a descending-order queue.
- *
- * Later-inserted duplicates appear at lower indices. For example, the
- * asterisk in (5,4,*,3,2,1) would be the insertion point for 3.
- *
- * @param {Object} timeout The timeout to insert, with numerical runAtMillis
- * property.
- * @param {Array.<Object>} queue The queue to insert into, with each element
- * having a numerical runAtMillis property.
- * @private
- */
-goog.testing.MockClock.insert_ = function(timeout, queue) {
- // Although insertion of N items is quadratic, requiring goog.structs.Heap
- // from a unit test will make tests more prone to breakage. Since unit
- // tests are normally small, scalability is not a primary issue.
-
- // Find an insertion point. Since the queue is in reverse order (so we
- // can pop rather than unshift), and later timers with the same time stamp
- // should be executed later, we look for the element strictly greater than
- // the one we are inserting.
-
- for (var i = queue.length; i != 0; i--) {
- if (queue[i - 1].runAtMillis > timeout.runAtMillis) {
- break;
- }
- queue[i] = queue[i - 1];
- }
-
- queue[i] = timeout;
-};
-
-
-/**
- * Maximum 32-bit signed integer.
- *
- * Timeouts over this time return immediately in many browsers, due to integer
- * overflow. Such known browsers include Firefox, Chrome, and Safari, but not
- * IE.
- *
- * @type {number}
- * @private
- */
-goog.testing.MockClock.MAX_INT_ = 2147483647;
-
-
-/**
- * Schedules a function to be called after {@code millis} milliseconds.
- * Mock implementation for window.setTimeout
- * @param {Function} funcToCall The function to call.
- * @param {number} millis The number of milliseconds to call it after.
- * @return {number} The number of timeouts created.
- * @private
- */
-goog.testing.MockClock.prototype.setTimeout_ = function(funcToCall, millis) {
- if (millis > goog.testing.MockClock.MAX_INT_) {
- throw Error(
- 'Bad timeout value: ' + millis + '. Timeouts over MAX_INT ' +
- '(24.8 days) cause timeouts to be fired ' +
- 'immediately in most browsers, except for IE.');
- }
- this.timeoutsMade_ = this.timeoutsMade_ + 1;
- this.scheduleFunction_(this.timeoutsMade_, funcToCall, millis, false);
- return this.timeoutsMade_;
-};
-
-
-/**
- * Schedules a function to be called every {@code millis} milliseconds.
- * Mock implementation for window.setInterval
- * @param {Function} funcToCall The function to call.
- * @param {number} millis The number of milliseconds between calls.
- * @return {number} The number of timeouts created.
- * @private
- */
-goog.testing.MockClock.prototype.setInterval_ = function(funcToCall, millis) {
- this.timeoutsMade_ = this.timeoutsMade_ + 1;
- this.scheduleFunction_(this.timeoutsMade_, funcToCall, millis, true);
- return this.timeoutsMade_;
-};
-
-
-/**
- * Clears a timeout.
- * Mock implementation for window.clearTimeout
- * @param {number} timeoutKey The timeout key to clear.
- * @private
- */
-goog.testing.MockClock.prototype.clearTimeout_ = function(timeoutKey) {
- this.deletedKeys_[timeoutKey] = true;
-};
-
-
-/**
- * Clears an interval.
- * Mock implementation for window.clearInterval
- * @param {number} timeoutKey The interval key to clear.
- * @private
- */
-goog.testing.MockClock.prototype.clearInterval_ = function(timeoutKey) {
- this.deletedKeys_[timeoutKey] = true;
-};
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mockclock_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mockclock_test.html.svn-base
deleted file mode 100644
index f168f83..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mockclock_test.html.svn-base
+++ /dev/null
@@ -1,413 +0,0 @@
-<!DOCTYPE html>
-<html>
-<!--
-Copyright 2007 The Closure Library Authors. All Rights Reserved.
-
-Use of this source code is governed by the Apache License, Version 2.0.
-See the COPYING file for details.
--->
-<head>
-<meta http-equiv="X-UA-Compatible" content="IE=edge">
-<title>Closure Unit Tests - goog.testing.MockClock</title>
-<script src="../base.js"></script>
-<script>
- goog.require('goog.functions');
- goog.require('goog.testing.MockClock');
- goog.require('goog.testing.jsunit');
-</script>
-</head>
-<body>
-<script>
-
- function testMockClockWasInstalled() {
- var clock = new goog.testing.MockClock();
- var originalTimeout = window.setTimeout;
- clock.install();
- assertNotEquals(window.setTimeout, originalTimeout);
- setTimeout(function() {}, 100);
- assertEquals(1, clock.getTimeoutsMade());
- setInterval(function() {}, 200);
- assertEquals(2, clock.getTimeoutsMade());
- clock.uninstall();
- assertEquals(window.setTimeout, originalTimeout);
- assertNull(clock.replacer_);
- }
-
-
- function testSetTimeoutAndTick() {
- var clock = new goog.testing.MockClock(true);
- var m5 = false, m10 = false, m15 = false, m20 = false;
- setTimeout(function() { m5 = true; }, 5);
- setTimeout(function() { m10 = true; }, 10);
- setTimeout(function() { m15 = true; }, 15);
- setTimeout(function() { m20 = true; }, 20);
- assertEquals(4, clock.getTimeoutsMade());
-
- assertEquals(4, clock.tick(4));
- assertEquals(4, clock.getCurrentTime());
-
- assertFalse(m5);
- assertFalse(m10);
- assertFalse(m15);
- assertFalse(m20);
-
- assertEquals(5, clock.tick(1));
- assertEquals(5, clock.getCurrentTime());
-
- assertTrue('m5 should now be true', m5);
- assertFalse(m10);
- assertFalse(m15);
- assertFalse(m20);
-
- assertEquals(10, clock.tick(5));
- assertEquals(10, clock.getCurrentTime());
-
- assertTrue('m5 should be true', m5);
- assertTrue('m10 should now be true', m10);
- assertFalse(m15);
- assertFalse(m20);
-
- assertEquals(15, clock.tick(5));
- assertEquals(15, clock.getCurrentTime());
-
- assertTrue('m5 should be true', m5);
- assertTrue('m10 should be true', m10);
- assertTrue('m15 should now be true', m15);
- assertFalse(m20);
-
- assertEquals(20, clock.tick(5));
- assertEquals(20, clock.getCurrentTime());
-
- assertTrue('m5 should be true', m5);
- assertTrue('m10 should be true', m10);
- assertTrue('m15 should be true', m15);
- assertTrue('m20 should now be true', m20);
-
- clock.uninstall();
- }
-
-
- function testSetInterval() {
- var clock = new goog.testing.MockClock(true);
- var times = 0
- setInterval(function() { times++; }, 100);
-
- clock.tick(500);
- assertEquals(5, times);
- clock.tick(100);
- assertEquals(6, times);
- clock.tick(100);
- assertEquals(7, times);
- clock.tick(50);
- assertEquals(7, times);
- clock.tick(50);
- assertEquals(8, times);
-
- clock.uninstall();
- }
-
-
- function testClearTimeout() {
- var clock = new goog.testing.MockClock(true);
- var ran = false;
- var c = setTimeout(function() { ran = true; }, 100);
- clock.tick(50);
- assertFalse(ran);
- clearTimeout(c);
- clock.tick(100);
- assertFalse(ran);
- clock.uninstall();
- }
-
-
- function testClearInterval() {
- var clock = new goog.testing.MockClock(true);
- var times = 0
- var c = setInterval(function() { times++; }, 100);
-
- clock.tick(500);
- assertEquals(5, times);
- clock.tick(100);
- assertEquals(6, times);
- clock.tick(100);
- clearInterval(c);
- assertEquals(7, times);
- clock.tick(50);
- assertEquals(7, times);
- clock.tick(50);
- assertEquals(7, times);
-
- clock.uninstall();
- }
-
-
- function testClearInterval2() {
- // Tests that we can clear the interval from inside the function
- var clock = new goog.testing.MockClock(true);
- var times = 0
- var c = setInterval(function() {
- times++;
- if (times == 6) {
- clearInterval(c);
- }
- }, 100);
-
- clock.tick(500);
- assertEquals(5, times);
- clock.tick(100);
- assertEquals(6, times);
- clock.tick(100);
- assertEquals(6, times);
- clock.tick(50);
- assertEquals(6, times);
- clock.tick(50);
- assertEquals(6, times);
-
- clock.uninstall();
- }
-
-
- function testMockGoogNow() {
- assertNotEquals(0, goog.now());
- var clock = new goog.testing.MockClock(true);
- assertEquals(0, goog.now());
- clock.tick(50);
- assertEquals(50, goog.now());
- clock.uninstall();
- assertNotEquals(50, goog.now());
- }
-
-
- function testTimeoutDelay() {
- var clock = new goog.testing.MockClock(true);
- var m5 = false, m10 = false, m20 = false;
- setTimeout(function() { m5 = true; }, 5);
- setTimeout(function() { m10 = true; }, 10);
- setTimeout(function() { m20 = true; }, 20);
-
- // Fire 3ms early, so m5 fires at t=2
- clock.setTimeoutDelay(-3);
- clock.tick(1);
- assertFalse(m5);
- assertFalse(m10);
- clock.tick(1);
- assertTrue(m5);
- assertFalse(m10);
-
- // Fire 3ms late, so m10 fires at t=13
- clock.setTimeoutDelay(3);
- assertEquals(12, clock.tick(10));
- assertEquals(12, clock.getCurrentTime());
- assertFalse(m10);
- clock.tick(1);
- assertTrue(m10);
- assertFalse(m20);
-
- // Fire 10ms early, so m20 fires now, since it's after t=10
- clock.setTimeoutDelay(-10);
- assertFalse(m20);
- assertEquals(14, clock.tick(1));
- assertEquals(14, clock.getCurrentTime());
- assertTrue(m20);
-
- clock.uninstall();
- }
-
-
- function testTimerCallbackCanCreateIntermediateTimer() {
- var clock = new goog.testing.MockClock(true);
- var sequence = [];
-
- // Create 3 timers: 1, 2, and 3. Timer 1 should fire at T=1, timer 2 at
- // T=2, and timer 3 at T=3. The catch: Timer 2 is created by the
- // callback within timer 0.
-
- // Testing method: Create a simple string sequencing each timer and at
- // what time it fired.
-
- setTimeout(function() {
- sequence.push('timer1 at T=' + goog.now());
- setTimeout(function() {
- sequence.push('timer2 at T=' + goog.now());
- }, 1);
- }, 1);
-
- setTimeout(function() {
- sequence.push('timer3 at T=' + goog.now());
- }, 3);
-
- clock.tick(4);
-
- assertEquals(
- 'Each timer should fire in sequence at the correct time.',
- 'timer1 at T=1, timer2 at T=2, timer3 at T=3',
- sequence.join(', '));
-
- clock.uninstall();
- }
-
-
- function testCorrectArgumentsPassedToCallback() {
- var clock = new goog.testing.MockClock(true);
- var timeoutId;
- var timeoutExecuted = false;
-
- timeoutId = setTimeout(function(arg) {
- assertEquals('"this" must be goog.global',
- goog.global, this);
- assertEquals('The timeout ID must be the first parameter',
- timeoutId, arg);
- assertEquals('Exactly one argument must be passed',
- 1, arguments.length);
- timeoutExecuted = true;
- }, 1);
-
- clock.tick(4);
-
- assertTrue('The timeout was not executed', timeoutExecuted);
-
- clock.uninstall();
- }
-
-
- function testTickZero() {
- var clock = new goog.testing.MockClock(true);
- var calls = 0;
-
- setTimeout(function() {
- assertEquals('I need to be first', 0, calls);
- calls++;
- }, 0);
-
- setTimeout(function() {
- assertEquals('I need to be second', 1, calls);
- calls++;
- }, 0);
-
- clock.tick(0);
- assertEquals(2, calls);
-
- setTimeout(function() {
- assertEquals('I need to be third', 2, calls);
- calls++;
- }, 0);
-
- clock.tick(0);
- assertEquals(3, calls);
-
- assertEquals('Time should still be zero', 0, goog.now());
-
- clock.uninstall();
- }
-
-
- function testReset() {
- var clock = new goog.testing.MockClock(true);
-
- setTimeout(function() {
- fail('Timeouts should be cleared after a reset');
- }, 0);
-
- clock.reset();
- clock.tick(999999);
- clock.uninstall();
- }
-
-
- function testQueueInsertionHelper() {
- var queue = [];
-
- function queueToString() {
- var buffer = [];
- for (var i = 0; i < queue.length; i++) {
- buffer.push(queue[i].runAtMillis);
- }
- return buffer.join(',');
- }
-
- goog.testing.MockClock.insert_({runAtMillis: 2}, queue);
- assertEquals('Only item',
- '2', queueToString());
-
- goog.testing.MockClock.insert_({runAtMillis: 4}, queue);
- assertEquals('Biggest item',
- '4,2', queueToString());
-
- goog.testing.MockClock.insert_({runAtMillis: 5}, queue);
- assertEquals('An even bigger item',
- '5,4,2', queueToString());
-
- goog.testing.MockClock.insert_({runAtMillis: 1}, queue);
- assertEquals('Smallest item',
- '5,4,2,1', queueToString());
-
- goog.testing.MockClock.insert_({runAtMillis: 1, dup: true}, queue);
- assertEquals('Duplicate smallest item',
- '5,4,2,1,1', queueToString());
- assertTrue('Duplicate item comes at a smaller index', queue[3].dup);
-
- goog.testing.MockClock.insert_({runAtMillis: 3}, queue);
- goog.testing.MockClock.insert_({runAtMillis: 3, dup:true}, queue);
- assertEquals('Duplicate a middle item',
- '5,4,3,3,2,1,1', queueToString());
- assertTrue('Duplicate item comes at a smaller index', queue[2].dup);
- }
-
- function testIsTimeoutSet() {
- var clock = new goog.testing.MockClock(true);
- var timeoutKey = setTimeout(function(){}, 1);
- assertTrue('Timeout ' + timeoutKey + ' should be set',
- clock.isTimeoutSet(timeoutKey));
- var nextTimeoutKey = timeoutKey + 1;
- assertFalse('Timeout ' + nextTimeoutKey + ' should not be set',
- clock.isTimeoutSet(nextTimeoutKey));
- clearTimeout(timeoutKey);
- assertFalse('Timeout ' + timeoutKey + ' should no longer be set',
- clock.isTimeoutSet(timeoutKey));
- var newTimeoutKey = setTimeout(function(){}, 1);
- clock.tick(5);
- assertFalse('Timeout ' + timeoutKey + ' should not be set',
- clock.isTimeoutSet(timeoutKey));
- assertTrue('Timeout ' + newTimeoutKey + ' should be set',
- clock.isTimeoutSet(newTimeoutKey));
- clock.uninstall();
- }
-
- function testBalksOnTimeoutsGreaterThanMaxInt() {
- // Browsers have trouble with timeout greater than max int, so we
- // want Mock Clock to fail if this happens.
- var clock = new goog.testing.MockClock(true);
- // Functions on window don't seem to be able to throw exceptions in
- // IE6. Explicitly reading the property makes it work.
- var setTimeout = window.setTimeout;
- assertThrows('Timeouts > MAX_INT should fail',
- function() {
- setTimeout(goog.nullFunction, 2147483648);
- });
- assertThrows('Timeouts much greater than MAX_INT should fail',
- function() {
- setTimeout(goog.nullFunction, 2147483648 * 10);
- });
- clock.uninstall();
- }
-
- function testCorrectSetTimeoutIsRestored() {
- var original = window.setTimeout;
- var safe = goog.functions.error('should not have been called');
- try {
- window.setTimeout = safe;
- var clock = new goog.testing.MockClock(true);
- assertNotEquals('setTimeout is replaced', safe, window.setTimeout);
- clock.uninstall();
- // NOTE: If this assertion proves to be flaky in IE, the string value of
- // the two functions have to be compared as described in
- // goog.testing.TestCase#finalize.
- assertEquals('setTimeout is restored', safe, window.setTimeout);
- } finally {
- window.setTimeout = original;
- }
- }
-
-</script>
-</body>
-</html>
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mockcontrol.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mockcontrol.js.svn-base
deleted file mode 100644
index b77e19a..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mockcontrol.js.svn-base
+++ /dev/null
@@ -1,219 +0,0 @@
-// Copyright 2008 The Closure Library Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS-IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/**
- * @fileoverview A MockControl holds a set of mocks for a particular test.
- * It consolidates calls to $replay, $verify, and $tearDown, which simplifies
- * the test and helps avoid omissions.
- *
- * You can create and control a mock:
- * var mockFoo = mockControl.addMock(new MyMock(Foo));
- *
- * MockControl also exposes some convenience functions that create
- * controlled mocks for common mocks: StrictMock, LooseMock,
- * FunctionMock, MethodMock, and GlobalFunctionMock.
- *
- */
-
-
-goog.provide('goog.testing.MockControl');
-
-goog.require('goog.array');
-goog.require('goog.testing');
-goog.require('goog.testing.LooseMock');
-goog.require('goog.testing.MockInterface');
-goog.require('goog.testing.StrictMock');
-
-
-
-/**
- * Controls a set of mocks. Controlled mocks are replayed, verified, and
- * cleaned-up at the same time.
- * @constructor
- */
-goog.testing.MockControl = function() {
- /**
- * The list of mocks being controlled.
- * @type {Array.<goog.testing.MockInterface>}
- * @private
- */
- this.mocks_ = [];
-};
-
-
-/**
- * Takes control of this mock.
- * @param {goog.testing.MockInterface} mock Mock to be controlled.
- * @return {goog.testing.MockInterface} The same mock passed in,
- * for convenience.
- */
-goog.testing.MockControl.prototype.addMock = function(mock) {
- this.mocks_.push(mock);
- return mock;
-};
-
-
-/**
- * Calls replay on each controlled mock.
- */
-goog.testing.MockControl.prototype.$replayAll = function() {
- goog.array.forEach(this.mocks_, function(m) {
- m.$replay();
- });
-};
-
-
-/**
- * Calls reset on each controlled mock.
- */
-goog.testing.MockControl.prototype.$resetAll = function() {
- goog.array.forEach(this.mocks_, function(m) {
- m.$reset();
- });
-};
-
-
-/**
- * Calls verify on each controlled mock.
- */
-goog.testing.MockControl.prototype.$verifyAll = function() {
- goog.array.forEach(this.mocks_, function(m) {
- m.$verify();
- });
-};
-
-
-/**
- * Calls tearDown on each controlled mock, if necesssary.
- */
-goog.testing.MockControl.prototype.$tearDown = function() {
- goog.array.forEach(this.mocks_, function(m) {
- // $tearDown if defined.
- if (m.$tearDown) {
- m.$tearDown();
- }
- // TODO(user): Somehow determine if verifyAll should have been called
- // but was not.
- });
-};
-
-
-/**
- * Creates a controlled StrictMock. Passes its arguments through to the
- * StrictMock constructor.
- * @param {Object} objectToMock The object to mock.
- * @param {boolean=} opt_mockStaticMethods An optional argument denoting that
- * a mock should be constructed from the static functions of a class.
- * @param {boolean=} opt_createProxy An optional argument denoting that
- * a proxy for the target mock should be created.
- * @return {goog.testing.StrictMock} The mock object.
- */
-goog.testing.MockControl.prototype.createStrictMock = function(
- objectToMock, opt_mockStaticMethods, opt_createProxy) {
- var m = new goog.testing.StrictMock(objectToMock, opt_mockStaticMethods,
- opt_createProxy);
- this.addMock(m);
- return m;
-};
-
-
-/**
- * Creates a controlled LooseMock. Passes its arguments through to the
- * LooseMock constructor.
- * @param {Object} objectToMock The object to mock.
- * @param {boolean=} opt_ignoreUnexpectedCalls Whether to ignore unexpected
- * calls.
- * @param {boolean=} opt_mockStaticMethods An optional argument denoting that
- * a mock should be constructed from the static functions of a class.
- * @param {boolean=} opt_createProxy An optional argument denoting that
- * a proxy for the target mock should be created.
- * @return {goog.testing.LooseMock} The mock object.
- */
-goog.testing.MockControl.prototype.createLooseMock = function(
- objectToMock, opt_ignoreUnexpectedCalls,
- opt_mockStaticMethods, opt_createProxy) {
- var m = new goog.testing.LooseMock(objectToMock, opt_ignoreUnexpectedCalls,
- opt_mockStaticMethods, opt_createProxy);
- this.addMock(m);
- return m;
-};
-
-
-/**
- * Creates a controlled FunctionMock. Passes its arguments through to the
- * FunctionMock constructor.
- * @param {string=} opt_functionName The optional name of the function to mock
- * set to '[anonymous mocked function]' if not passed in.
- * @param {number=} opt_strictness One of goog.testing.Mock.LOOSE or
- * goog.testing.mock.STRICT. The default is STRICT.
- * @return {goog.testing.MockInterface} The mocked function.
- */
-goog.testing.MockControl.prototype.createFunctionMock = function(
- opt_functionName, opt_strictness) {
- var m = goog.testing.createFunctionMock(opt_functionName, opt_strictness);
- this.addMock(m);
- return m;
-};
-
-
-/**
- * Creates a controlled MethodMock. Passes its arguments through to the
- * MethodMock constructor.
- * @param {Object} scope The scope of the method to be mocked out.
- * @param {string} functionName The name of the function we're going to mock.
- * @param {number=} opt_strictness One of goog.testing.Mock.LOOSE or
- * goog.testing.mock.STRICT. The default is STRICT.
- * @return {goog.testing.MockInterface} The mocked method.
- */
-goog.testing.MockControl.prototype.createMethodMock = function(
- scope, functionName, opt_strictness) {
- var m = goog.testing.createMethodMock(scope, functionName, opt_strictness);
- this.addMock(m);
- return m;
-};
-
-
-/**
- * Creates a controlled MethodMock for a constructor. Passes its arguments
- * through to the MethodMock constructor. See
- * {@link goog.testing.createConstructorMock} for details.
- * @param {Object} scope The scope of the constructor to be mocked out.
- * @param {string} constructorName The name of the function we're going to mock.
- * @param {number=} opt_strictness One of goog.testing.Mock.LOOSE or
- * goog.testing.mock.STRICT. The default is STRICT.
- * @return {goog.testing.MockInterface} The mocked method.
- */
-goog.testing.MockControl.prototype.createConstructorMock = function(
- scope, constructorName, opt_strictness) {
- var m = goog.testing.createConstructorMock(scope, constructorName,
- opt_strictness);
- this.addMock(m);
- return m;
-};
-
-
-/**
- * Creates a controlled GlobalFunctionMock. Passes its arguments through to the
- * GlobalFunctionMock constructor.
- * @param {string} functionName The name of the function we're going to mock.
- * @param {number=} opt_strictness One of goog.testing.Mock.LOOSE or
- * goog.testing.mock.STRICT. The default is STRICT.
- * @return {goog.testing.MockInterface} The mocked function.
- */
-goog.testing.MockControl.prototype.createGlobalFunctionMock = function(
- functionName, opt_strictness) {
- var m = goog.testing.createGlobalFunctionMock(functionName, opt_strictness);
- this.addMock(m);
- return m;
-};
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mockcontrol_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mockcontrol_test.html.svn-base
deleted file mode 100644
index 9eb5251..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mockcontrol_test.html.svn-base
+++ /dev/null
@@ -1,127 +0,0 @@
-<!DOCTYPE html>
-<html>
-<!--
-Copyright 2008 The Closure Library Authors. All Rights Reserved.
-
-Use of this source code is governed by the Apache License, Version 2.0.
-See the COPYING file for details.
--->
-<!--
-
--->
-<head>
-<meta http-equiv="X-UA-Compatible" content="IE=edge">
-<title>Closure Unit Tests - goog.testing.MockControl</title>
-<script src="../base.js"></script>
-<script>
- goog.require('goog.testing.MockControl');
- goog.require('goog.testing.jsunit');
-</script>
-</head>
-<body>
-<script>
-
- // Emulate the behavior of a mock.
- function MockMock() {
- this.replayCalled = false;
- this.resetCalled = false;
- this.verifyCalled = false;
- this.tearDownCalled = false;
- };
-
- MockMock.prototype.$replay = function() {
- this.replayCalled = true;
- };
-
- MockMock.prototype.$reset = function() {
- this.resetCalled = true;
- };
-
- MockMock.prototype.$verify = function() {
- this.verifyCalled = true;
- };
-
- function setUp() {
- var mock = new goog.testing.Mock(MockMock);
- };
-
- function testAdd() {
- var mockMock = new MockMock();
-
- var control = new goog.testing.MockControl();
- assertEquals(mockMock, control.addMock(mockMock));
- }
-
- function testReplayAll() {
- var mockMock1 = new MockMock();
- var mockMock2 = new MockMock();
- var mockMockExcluded = new MockMock();
-
- var control = new goog.testing.MockControl();
- control.addMock(mockMock1);
- control.addMock(mockMock2);
-
- control.$replayAll();
- assertTrue(mockMock1.replayCalled);
- assertTrue(mockMock2.replayCalled);
- assertFalse(mockMockExcluded.replayCalled);
- }
-
- function testResetAll() {
- var mockMock1 = new MockMock();
- var mockMock2 = new MockMock();
- var mockMockExcluded = new MockMock();
-
- var control = new goog.testing.MockControl();
- control.addMock(mockMock1);
- control.addMock(mockMock2);
-
- control.$resetAll();
- assertTrue(mockMock1.resetCalled);
- assertTrue(mockMock2.resetCalled);
- assertFalse(mockMockExcluded.resetCalled);
- }
-
- function testVerifyAll() {
- var mockMock1 = new MockMock();
- var mockMock2 = new MockMock();
- var mockMockExcluded = new MockMock();
-
- var control = new goog.testing.MockControl();
- control.addMock(mockMock1);
- control.addMock(mockMock2);
-
- control.$verifyAll();
- assertTrue(mockMock1.verifyCalled);
- assertTrue(mockMock2.verifyCalled);
- assertFalse(mockMockExcluded.verifyCalled);
- }
-
- function testTearDownAll() {
- var mockMock1 = new MockMock();
- var mockMock2 = new MockMock();
- var mockMockExcluded = new MockMock();
-
- // $tearDown is optional.
- mockMock2.$tearDown = function() {
- this.tearDownCalled = true;
- };
- mockMockExcluded.$tearDown = function() {
- this.tearDownCalled = true;
- };
-
- var control = new goog.testing.MockControl();
- control.addMock(mockMock1);
- control.addMock(mockMock2);
-
- control.$tearDown();
-
- // mockMock2 has a tearDown method and is in the control.
- assertTrue(mockMock2.tearDownCalled);
- assertFalse(mockMock1.tearDownCalled);
- assertFalse(mockMockExcluded.tearDownCalled);
- }
-
-</script>
-</body>
-</html>
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mockinterface.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mockinterface.js.svn-base
deleted file mode 100644
index 1a53470..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mockinterface.js.svn-base
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright 2010 The Closure Library Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS-IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/**
- * @fileoverview An interface that all mocks should share.
- * @author nicksantos@google.com (Nick Santos)
- */
-
-goog.provide('goog.testing.MockInterface');
-
-
-
-/** @interface */
-goog.testing.MockInterface = function() {};
-
-
-/**
- * Write down all the expected functions that have been called on the
- * mock so far. From here on out, future function calls will be
- * compared against this list.
- */
-goog.testing.MockInterface.prototype.$replay = function() {};
-
-
-/**
- * Reset the mock.
- */
-goog.testing.MockInterface.prototype.$reset = function() {};
-
-
-/**
- * Assert that the expected function calls match the actual calls.
- */
-goog.testing.MockInterface.prototype.$verify = function() {};
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mockmatchers.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mockmatchers.js.svn-base
deleted file mode 100644
index 7dc56f8..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mockmatchers.js.svn-base
+++ /dev/null
@@ -1,395 +0,0 @@
-// Copyright 2008 The Closure Library Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS-IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/**
- * @fileoverview Matchers to be used with the mock utilities. They allow for
- * flexible matching by type. Custom matchers can be created by passing a
- * matcher function into an ArgumentMatcher instance.
- *
- * For examples, please see the unit test.
- *
- */
-
-
-goog.provide('goog.testing.mockmatchers');
-goog.provide('goog.testing.mockmatchers.ArgumentMatcher');
-goog.provide('goog.testing.mockmatchers.IgnoreArgument');
-goog.provide('goog.testing.mockmatchers.InstanceOf');
-goog.provide('goog.testing.mockmatchers.ObjectEquals');
-goog.provide('goog.testing.mockmatchers.RegexpMatch');
-goog.provide('goog.testing.mockmatchers.SaveArgument');
-goog.provide('goog.testing.mockmatchers.TypeOf');
-
-goog.require('goog.array');
-goog.require('goog.dom');
-goog.require('goog.testing.asserts');
-
-
-
-/**
- * A simple interface for executing argument matching. A match in this case is
- * testing to see if a supplied object fits a given criteria. True is returned
- * if the given criteria is met.
- * @param {Function=} opt_matchFn A function that evaluates a given argument
- * and returns true if it meets a given criteria.
- * @param {?string=} opt_matchName The name expressing intent as part of
- * an error message for when a match fails.
- * @constructor
- */
-goog.testing.mockmatchers.ArgumentMatcher =
- function(opt_matchFn, opt_matchName) {
- /**
- * A function that evaluates a given argument and returns true if it meets a
- * given criteria.
- * @type {Function}
- * @private
- */
- this.matchFn_ = opt_matchFn || null;
-
- /**
- * A string indicating the match intent (e.g. isBoolean or isString).
- * @type {?string}
- * @private
- */
- this.matchName_ = opt_matchName || null;
-};
-
-
-/**
- * A function that takes a match argument and an optional MockExpectation
- * which (if provided) will get error information and returns whether or
- * not it matches.
- * @param {*} toVerify The argument that should be verified.
- * @param {goog.testing.MockExpectation?=} opt_expectation The expectation
- * for this match.
- * @return {boolean} Whether or not a given argument passes verification.
- */
-goog.testing.mockmatchers.ArgumentMatcher.prototype.matches =
- function(toVerify, opt_expectation) {
- if (this.matchFn_) {
- var isamatch = this.matchFn_(toVerify);
- if (!isamatch && opt_expectation) {
- if (this.matchName_) {
- opt_expectation.addErrorMessage('Expected: ' +
- this.matchName_ + ' but was: ' + _displayStringForValue(toVerify));
- } else {
- opt_expectation.addErrorMessage('Expected: missing mockmatcher' +
- ' description but was: ' +
- _displayStringForValue(toVerify));
- }
- }
- return isamatch;
- } else {
- throw Error('No match function defined for this mock matcher');
- }
-};
-
-
-
-/**
- * A matcher that verifies that an argument is an instance of a given class.
- * @param {Function} ctor The class that will be used for verification.
- * @constructor
- * @extends {goog.testing.mockmatchers.ArgumentMatcher}
- */
-goog.testing.mockmatchers.InstanceOf = function(ctor) {
- goog.testing.mockmatchers.ArgumentMatcher.call(this,
- function(obj) {
- return obj instanceof ctor;
- // NOTE: Browser differences on ctor.toString() output
- // make using that here problematic. So for now, just let
- // people know the instanceOf() failed without providing
- // browser specific details...
- }, 'instanceOf()');
-};
-goog.inherits(goog.testing.mockmatchers.InstanceOf,
- goog.testing.mockmatchers.ArgumentMatcher);
-
-
-
-/**
- * A matcher that verifies that an argument is of a given type (e.g. "object").
- * @param {string} type The type that a given argument must have.
- * @constructor
- * @extends {goog.testing.mockmatchers.ArgumentMatcher}
- */
-goog.testing.mockmatchers.TypeOf = function(type) {
- goog.testing.mockmatchers.ArgumentMatcher.call(this,
- function(obj) {
- return goog.typeOf(obj) == type;
- }, 'typeOf(' + type + ')');
-};
-goog.inherits(goog.testing.mockmatchers.TypeOf,
- goog.testing.mockmatchers.ArgumentMatcher);
-
-
-
-/**
- * A matcher that verifies that an argument matches a given RegExp.
- * @param {RegExp} regexp The regular expression that the argument must match.
- * @constructor
- * @extends {goog.testing.mockmatchers.ArgumentMatcher}
- */
-goog.testing.mockmatchers.RegexpMatch = function(regexp) {
- goog.testing.mockmatchers.ArgumentMatcher.call(this,
- function(str) {
- return regexp.test(str);
- }, 'match(' + regexp + ')');
-};
-goog.inherits(goog.testing.mockmatchers.RegexpMatch,
- goog.testing.mockmatchers.ArgumentMatcher);
-
-
-
-/**
- * A matcher that always returns true. It is useful when the user does not care
- * for some arguments.
- * For example: mockFunction('username', 'password', IgnoreArgument);
- * @constructor
- * @extends {goog.testing.mockmatchers.ArgumentMatcher}
- */
-goog.testing.mockmatchers.IgnoreArgument = function() {
- goog.testing.mockmatchers.ArgumentMatcher.call(this,
- function() {
- return true;
- }, 'true');
-};
-goog.inherits(goog.testing.mockmatchers.IgnoreArgument,
- goog.testing.mockmatchers.ArgumentMatcher);
-
-
-
-/**
- * A matcher that verifies that the argument is an object that equals the given
- * expected object, using a deep comparison.
- * @param {Object} expectedObject An object to match against when
- * verifying the argument.
- * @constructor
- * @extends {goog.testing.mockmatchers.ArgumentMatcher}
- */
-goog.testing.mockmatchers.ObjectEquals = function(expectedObject) {
- goog.testing.mockmatchers.ArgumentMatcher.call(this,
- function(matchObject) {
- assertObjectEquals('Expected equal objects', expectedObject,
- matchObject);
- return true;
- }, 'objectEquals(' + expectedObject + ')');
-};
-goog.inherits(goog.testing.mockmatchers.ObjectEquals,
- goog.testing.mockmatchers.ArgumentMatcher);
-
-
-/** @override */
-goog.testing.mockmatchers.ObjectEquals.prototype.matches =
- function(toVerify, opt_expectation) {
- // Override the default matches implementation to capture the exception thrown
- // by assertObjectEquals (if any) and add that message to the expectation.
- try {
- return goog.testing.mockmatchers.ObjectEquals.superClass_.matches.call(
- this, toVerify, opt_expectation);
- } catch (e) {
- if (opt_expectation) {
- opt_expectation.addErrorMessage(e.message);
- }
- return false;
- }
-};
-
-
-
-/**
- * A matcher that saves the argument that it is verifying so that your unit test
- * can perform extra tests with this argument later. For example, if the
- * argument is a callback method, the unit test can then later call this
- * callback to test the asynchronous portion of the call.
- * @param {goog.testing.mockmatchers.ArgumentMatcher|Function=} opt_matcher
- * Argument matcher or matching function that will be used to validate the
- * argument. By default, argument will always be valid.
- * @param {?string=} opt_matchName The name expressing intent as part of
- * an error message for when a match fails.
- * @constructor
- * @extends {goog.testing.mockmatchers.ArgumentMatcher}
- */
-goog.testing.mockmatchers.SaveArgument = function(opt_matcher, opt_matchName) {
- goog.testing.mockmatchers.ArgumentMatcher.call(
- this, /** @type {Function} */ (opt_matcher), opt_matchName);
-
- if (opt_matcher instanceof goog.testing.mockmatchers.ArgumentMatcher) {
- /**
- * Delegate match requests to this matcher.
- * @type {goog.testing.mockmatchers.ArgumentMatcher}
- * @private
- */
- this.delegateMatcher_ = opt_matcher;
- } else if (!opt_matcher) {
- this.delegateMatcher_ = goog.testing.mockmatchers.ignoreArgument;
- }
-};
-goog.inherits(goog.testing.mockmatchers.SaveArgument,
- goog.testing.mockmatchers.ArgumentMatcher);
-
-
-/** @override */
-goog.testing.mockmatchers.SaveArgument.prototype.matches = function(
- toVerify, opt_expectation) {
- this.arg = toVerify;
- if (this.delegateMatcher_) {
- return this.delegateMatcher_.matches(toVerify, opt_expectation);
- }
- return goog.testing.mockmatchers.SaveArgument.superClass_.matches.call(
- this, toVerify, opt_expectation);
-};
-
-
-/**
- * Saved argument that was verified.
- * @type {*}
- */
-goog.testing.mockmatchers.SaveArgument.prototype.arg;
-
-
-/**
- * An instance of the IgnoreArgument matcher. Returns true for all matches.
- * @type {goog.testing.mockmatchers.IgnoreArgument}
- */
-goog.testing.mockmatchers.ignoreArgument =
- new goog.testing.mockmatchers.IgnoreArgument();
-
-
-/**
- * A matcher that verifies that an argument is an array.
- * @type {goog.testing.mockmatchers.ArgumentMatcher}
- */
-goog.testing.mockmatchers.isArray =
- new goog.testing.mockmatchers.ArgumentMatcher(goog.isArray,
- 'isArray');
-
-
-/**
- * A matcher that verifies that an argument is a array-like. A NodeList is an
- * example of a collection that is very close to an array.
- * @type {goog.testing.mockmatchers.ArgumentMatcher}
- */
-goog.testing.mockmatchers.isArrayLike =
- new goog.testing.mockmatchers.ArgumentMatcher(goog.isArrayLike,
- 'isArrayLike');
-
-
-/**
- * A matcher that verifies that an argument is a date-like.
- * @type {goog.testing.mockmatchers.ArgumentMatcher}
- */
-goog.testing.mockmatchers.isDateLike =
- new goog.testing.mockmatchers.ArgumentMatcher(goog.isDateLike,
- 'isDateLike');
-
-
-/**
- * A matcher that verifies that an argument is a string.
- * @type {goog.testing.mockmatchers.ArgumentMatcher}
- */
-goog.testing.mockmatchers.isString =
- new goog.testing.mockmatchers.ArgumentMatcher(goog.isString,
- 'isString');
-
-
-/**
- * A matcher that verifies that an argument is a boolean.
- * @type {goog.testing.mockmatchers.ArgumentMatcher}
- */
-goog.testing.mockmatchers.isBoolean =
- new goog.testing.mockmatchers.ArgumentMatcher(goog.isBoolean,
- 'isBoolean');
-
-
-/**
- * A matcher that verifies that an argument is a number.
- * @type {goog.testing.mockmatchers.ArgumentMatcher}
- */
-goog.testing.mockmatchers.isNumber =
- new goog.testing.mockmatchers.ArgumentMatcher(goog.isNumber,
- 'isNumber');
-
-
-/**
- * A matcher that verifies that an argument is a function.
- * @type {goog.testing.mockmatchers.ArgumentMatcher}
- */
-goog.testing.mockmatchers.isFunction =
- new goog.testing.mockmatchers.ArgumentMatcher(goog.isFunction,
- 'isFunction');
-
-
-/**
- * A matcher that verifies that an argument is an object.
- * @type {goog.testing.mockmatchers.ArgumentMatcher}
- */
-goog.testing.mockmatchers.isObject =
- new goog.testing.mockmatchers.ArgumentMatcher(goog.isObject,
- 'isObject');
-
-
-/**
- * A matcher that verifies that an argument is like a DOM node.
- * @type {goog.testing.mockmatchers.ArgumentMatcher}
- */
-goog.testing.mockmatchers.isNodeLike =
- new goog.testing.mockmatchers.ArgumentMatcher(goog.dom.isNodeLike,
- 'isNodeLike');
-
-
-/**
- * A function that checks to see if an array matches a given set of
- * expectations. The expectations array can be a mix of ArgumentMatcher
- * implementations and values. True will be returned if values are identical or
- * if a matcher returns a positive result.
- * @param {Array} expectedArr An array of expectations which can be either
- * values to check for equality or ArgumentMatchers.
- * @param {Array} arr The array to match.
- * @param {goog.testing.MockExpectation?=} opt_expectation The expectation
- * for this match.
- * @return {boolean} Whether or not the given array matches the expectations.
- */
-goog.testing.mockmatchers.flexibleArrayMatcher =
- function(expectedArr, arr, opt_expectation) {
- return goog.array.equals(expectedArr, arr, function(a, b) {
- var errCount = 0;
- if (opt_expectation) {
- errCount = opt_expectation.getErrorMessageCount();
- }
- var isamatch = a === b ||
- a instanceof goog.testing.mockmatchers.ArgumentMatcher &&
- a.matches(b, opt_expectation);
- var failureMessage = null;
- if (!isamatch) {
- failureMessage = goog.testing.asserts.findDifferences(a, b);
- isamatch = !failureMessage;
- }
- if (!isamatch && opt_expectation) {
- // If the error count changed, the match sent out an error
- // message. If the error count has not changed, then
- // we need to send out an error message...
- if (errCount == opt_expectation.getErrorMessageCount()) {
- // Use the _displayStringForValue() from assert.js
- // for consistency...
- if (!failureMessage) {
- failureMessage = 'Expected: ' + _displayStringForValue(a) +
- ' but was: ' + _displayStringForValue(b);
- }
- opt_expectation.addErrorMessage(failureMessage);
- }
- }
- return isamatch;
- });
-};
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mockmatchers_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mockmatchers_test.html.svn-base
deleted file mode 100644
index c8a9e17..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mockmatchers_test.html.svn-base
+++ /dev/null
@@ -1,388 +0,0 @@
-<!DOCTYPE html>
-<html>
-<!--
-Copyright 2008 The Closure Library Authors. All Rights Reserved.
-
-Use of this source code is governed by the Apache License, Version 2.0.
-See the COPYING file for details.
--->
-<!--
-
- @author earmbrust@google.com (Erick Armbrust)
--->
-<head>
-<meta http-equiv="X-UA-Compatible" content="IE=edge">
-<title>Closure Unit Tests - goog.testing.mockmatchers</title>
-<script src="../base.js"></script>
-<script>
- goog.require('goog.dom');
- goog.require('goog.testing.FunctionMock');
- goog.require('goog.testing.mockmatchers');
- goog.require('goog.testing.jsunit');
-</script>
-</head>
-<body>
-
-<div id="someDiv">
-</div>
-
-<script>
- // A local reference to the mockmatchers namespace.
- var matchers = goog.testing.mockmatchers;
-
- // Simple classes to test the InstanceOf matcher.
- var foo = function() {};
- var bar = function() {};
-
- // Simple class to test adding error messages to
- // MockExpectation objects
- function MockMock() {
- this.errorMessages = [];
- }
-
- var mockExpect = null;
-
- MockMock.prototype.addErrorMessage = function(msg) {
- this.errorMessages.push(msg);
- };
-
-
- MockMock.prototype.getErrorMessageCount = function() {
- return this.errorMessages.length;
- };
-
-
- function setUp() {
- mockExpect = new MockMock();
- }
-
-
- function testNoMatchName() {
- // A matcher that does not fill in the match name
- var matcher = new goog.testing.mockmatchers.ArgumentMatcher(goog.isString);
-
- // Make sure the lack of match name doesn't affect the ability
- // to return True/False
- assertTrue(matcher.matches('hello'));
- assertFalse(matcher.matches(123));
-
- // Make sure we handle the lack of a match name
- assertFalse(matcher.matches(456, mockExpect));
- assertEquals(1, mockExpect.errorMessages.length);
- assertEquals("Expected: missing mockmatcher description " +
- "but was: <456> (Number)", mockExpect.errorMessages[0]);
- }
-
-
- function testInstanceOf() {
- var matcher = new matchers.InstanceOf(foo);
- assertTrue(matcher.matches(new foo()));
- assertFalse(matcher.matches(new bar()));
-
- assertFalse(matcher.matches(new bar(), mockExpect));
- assertEquals(1, mockExpect.errorMessages.length);
- assertEquals("Expected: instanceOf() " +
- "but was: <[object Object]> (Object)",
- mockExpect.errorMessages[0]);
- }
-
-
- function testTypeOf() {
- var matcher = new matchers.TypeOf('number');
- assertTrue(matcher.matches(1));
- assertTrue(matcher.matches(2));
- assertFalse(matcher.matches('test'));
-
- assertFalse(matcher.matches(true, mockExpect));
- assertEquals(1, mockExpect.errorMessages.length);
- assertEquals("Expected: typeOf(number) but was: <true> (Boolean)",
- mockExpect.errorMessages[0]);
- }
-
-
- function testRegexpMatch() {
- var matcher = new matchers.RegexpMatch(/^cho[dtp]/);
- assertTrue(matcher.matches('chodhop'));
- assertTrue(matcher.matches('chopper'));
- assertFalse(matcher.matches('chocolate'));
- assertFalse(matcher.matches(null));
-
- assertFalse(matcher.matches('an anger', mockExpect));
- assertEquals(1, mockExpect.errorMessages.length);
- assertEquals('Expected: match(/^cho[dtp]/) but was: <an anger> (String)',
- mockExpect.errorMessages[0]);
- }
-
-
- function testObjectEquals() {
- // Test a simple match.
- var simpleMatcher = new matchers.ObjectEquals({name: 'Bob', age: 42});
- assertTrue(simpleMatcher.matches({name: 'Bob', age: 42}, mockExpect));
- assertEquals(0, mockExpect.getErrorMessageCount());
- expectObjectEqualsFailure(simpleMatcher, {name: 'Bill', age: 42},
- 'name expected <Bob> (String) but was <Bill> (String)');
- expectObjectEqualsFailure(simpleMatcher, {name: 'Bob', age: 21},
- 'age expected <42> (Number) but was <21> (Number)');
- expectObjectEqualsFailure(simpleMatcher, {name: 'Bob'},
- 'property age not present in actual Object');
- expectObjectEqualsFailure(simpleMatcher,
- {name: 'Bob', age: 42, country: 'USA'},
- 'property country not present in expected Object');
-
- // Multiple mismatches should include multiple messages.
- expectObjectEqualsFailure(simpleMatcher, {name: 'Jim', age: 36},
- 'name expected <Bob> (String) but was <Jim> (String)\n' +
- ' age expected <42> (Number) but was <36> (Number)');
- }
-
- function testComplexObjectEquals() {
- var complexMatcher = new matchers.ObjectEquals(
- {a: 'foo', b: 2, c: ['bar', 3], d: {sub1: 'baz', sub2: -1}});
- assertTrue(complexMatcher.matches(
- {a: 'foo', b: 2, c: ['bar', 3], d: {sub1: 'baz', sub2: -1}}));
- expectObjectEqualsFailure(complexMatcher,
- {a: 'foo', b: 2, c: ['bar', 3], d: {sub1: 'zap', sub2: -1}},
- 'sub1 expected <baz> (String) but was <zap> (String)');
- expectObjectEqualsFailure(complexMatcher,
- {a: 'foo', b: 2, c: ['bar', 6], d: {sub1: 'baz', sub2: -1}},
- 'c[1] expected <3> (Number) but was <6> (Number)');
- }
-
-
- function testSaveArgument() {
- var saveMatcher = new matchers.SaveArgument();
- assertTrue(saveMatcher.matches(42));
- assertEquals(42, saveMatcher.arg);
-
- saveMatcher = new matchers.SaveArgument(goog.isString);
- assertTrue(saveMatcher.matches('test'));
- assertEquals('test', saveMatcher.arg);
- assertFalse(saveMatcher.matches(17));
- assertEquals(17, saveMatcher.arg);
-
- saveMatcher = new matchers.SaveArgument(new matchers.ObjectEquals({
- value: 'value'
- }));
- assertTrue(saveMatcher.matches({ value: 'value' }));
- assertEquals('value', saveMatcher.arg.value);
- assertFalse(saveMatcher.matches('test'));
- assertEquals('test', saveMatcher.arg);
- }
-
-
- function testIsArray() {
- assertTrue(matchers.isArray.matches([]));
- assertTrue(matchers.isArray.matches(new Array()));
- assertFalse(matchers.isArray.matches('test'));
-
- assertFalse(matchers.isArray.matches({}, mockExpect));
- assertEquals(1, mockExpect.errorMessages.length);
- assertEquals("Expected: isArray but was: <[object Object]> (Object)",
- mockExpect.errorMessages[0]);
- }
-
-
- function testIsArrayLike() {
- var nodeList = (function() {
- var div = document.createElement('div');
- div.appendChild(document.createElement('p'));
- div.appendChild(document.createElement('p'));
- return div.getElementsByTagName('div');
- })();
-
- assertTrue(matchers.isArrayLike.matches([]));
- assertTrue(matchers.isArrayLike.matches(new Array()));
- assertTrue(matchers.isArrayLike.matches(nodeList));
- assertFalse(matchers.isArrayLike.matches('test'));
-
- assertFalse(matchers.isArrayLike.matches(3, mockExpect));
- assertEquals(1, mockExpect.errorMessages.length);
- assertEquals("Expected: isArrayLike but was: <3> (Number)",
- mockExpect.errorMessages[0]);
- }
-
-
- function testIsDateLike() {
- assertTrue(matchers.isDateLike.matches(new Date()));
- assertFalse(matchers.isDateLike.matches('test'));
-
- assertFalse(matchers.isDateLike.matches('test', mockExpect));
- assertEquals(1, mockExpect.errorMessages.length);
- assertEquals("Expected: isDateLike but was: <test> (String)",
- mockExpect.errorMessages[0]);
- }
-
-
- function testIsString() {
- assertTrue(matchers.isString.matches('a'));
- assertTrue(matchers.isString.matches('b'));
- assertFalse(matchers.isString.matches(null));
-
- assertFalse(matchers.isString.matches(null, mockExpect));
- assertEquals(1, mockExpect.errorMessages.length);
- assertEquals("Expected: isString but was: <null>",
- mockExpect.errorMessages[0]);
- }
-
-
- function testIsBoolean() {
- assertTrue(matchers.isBoolean.matches(true));
- assertTrue(matchers.isBoolean.matches(false));
- assertFalse(matchers.isBoolean.matches(null));
-
- assertFalse(matchers.isBoolean.matches([], mockExpect));
- assertEquals(1, mockExpect.errorMessages.length);
- assertEquals("Expected: isBoolean but was: <> (Array)",
- mockExpect.errorMessages[0]);
- }
-
-
- function testIsNumber() {
- assertTrue(matchers.isNumber.matches(-1));
- assertTrue(matchers.isNumber.matches(1));
- assertTrue(matchers.isNumber.matches(1.25));
- assertFalse(matchers.isNumber.matches(null));
-
- assertFalse(matchers.isNumber.matches('hello', mockExpect));
- assertEquals(1, mockExpect.errorMessages.length);
- assertEquals("Expected: isNumber but was: <hello> (String)",
- mockExpect.errorMessages[0]);
- }
-
-
- function testIsFunction() {
- assertTrue(matchers.isFunction.matches(function() {}));
- assertFalse(matchers.isFunction.matches('test'));
-
- assertFalse(matchers.isFunction.matches({}, mockExpect));
- assertEquals(1, mockExpect.errorMessages.length);
- assertEquals("Expected: isFunction but was: <[object Object]> (Object)",
- mockExpect.errorMessages[0]);
- }
-
-
- function testIsObject() {
- assertTrue(matchers.isObject.matches({}));
- assertTrue(matchers.isObject.matches(new Object()));
- assertTrue(matchers.isObject.matches(new function() {}));
- assertTrue(matchers.isObject.matches([]));
- assertTrue(matchers.isObject.matches(new Array()));
- assertTrue(matchers.isObject.matches(function() {}));
- assertFalse(matchers.isObject.matches(null));
-
- assertFalse(matchers.isObject.matches(1234, mockExpect));
- assertEquals(1, mockExpect.errorMessages.length);
- assertEquals("Expected: isObject but was: <1234> (Number)",
- mockExpect.errorMessages[0]);
- }
-
-
- function testIsNodeLike() {
- assertFalse(matchers.isNodeLike.matches({}));
- assertFalse(matchers.isNodeLike.matches(1));
- assertFalse(matchers.isNodeLike.matches(function() {}));
- assertFalse(matchers.isNodeLike.matches(false));
- assertTrue(matchers.isNodeLike.matches(document.body));
- assertTrue(matchers.isNodeLike.matches(goog.dom.getElement('someDiv')));
-
- assertFalse(matchers.isNodeLike.matches('test', mockExpect));
- assertEquals(1, mockExpect.errorMessages.length);
- assertEquals("Expected: isNodeLike but was: <test> (String)",
- mockExpect.errorMessages[0]);
- }
-
-
- function testIgnoreArgumentsMatcher() {
- // ignoreArgument always returns true:
- assertTrue(matchers.ignoreArgument.matches());
- assertTrue(matchers.ignoreArgument.matches(356));
- assertTrue(matchers.ignoreArgument.matches('str'));
- assertTrue(matchers.ignoreArgument.matches(['array', 123, false]));
- assertTrue(matchers.ignoreArgument.matches({'map': 1, key2: 'value2'}));
- }
-
-
- function testFlexibleArrayMatcher() {
- // Test that basic lists are verified properly.
- var a1 = [1, 'test'];
- var a2 = [1, 'test'];
- var a3 = [1, 'test', 'extra'];
- assertTrue(matchers.flexibleArrayMatcher(a1, a2));
- assertFalse(matchers.flexibleArrayMatcher(a1, a3));
-
- // Test that basic lists with basic class instances are verified properly.
- var instance = new foo();
- a1 = [1, 'test', instance];
- a2 = [1, 'test', instance];
- a3 = [1, 'test', new foo()];
- assertTrue(matchers.flexibleArrayMatcher(a1, a2));
- assertTrue(matchers.flexibleArrayMatcher(a1, a3));
-
- // Create an argument verifier that returns a consistent value.
- var verifyValue = true;
- var argVerifier = function() {};
- goog.inherits(argVerifier, matchers.ArgumentMatcher);
- argVerifier.prototype.matches = function(arg) {
- return verifyValue;
- };
-
- // Test that the arguments are always verified when the verifier returns
- // true.
- a1 = [1, 'test', new argVerifier()];
- a2 = [1, 'test', 'anything'];
- a3 = [1, 'test', 12345];
- assertTrue(matchers.flexibleArrayMatcher(a1, a2));
- assertTrue(matchers.flexibleArrayMatcher(a1, a3));
-
- // Now test the case when then verifier returns false.
- verifyValue = false;
- assertFalse(matchers.flexibleArrayMatcher(a1, a2));
- assertFalse(matchers.flexibleArrayMatcher(a1, a3));
-
- // And test we report errors back up via the opt_expectation
- assertFalse(matchers.flexibleArrayMatcher(a2, a3, mockExpect));
- assertEquals(1, mockExpect.errorMessages.length);
- assertEquals(
- 'Expected <anything> (String) but was <12345> (Number)\n' +
- ' expected <anything> (String) but was <12345> (Number)',
- mockExpect.errorMessages[0]);
-
- // And test we report errors found via the matcher
- a1 = [1, goog.testing.mockmatchers.isString ];
- a2 = [1, 'test string'];
- a3 = [1, null];
- assertTrue(matchers.flexibleArrayMatcher(a1, a2, mockExpect));
- assertFalse(matchers.flexibleArrayMatcher(a1, a3, mockExpect));
- // Old error is still there
- assertEquals(2, mockExpect.errorMessages.length);
- assertEquals(
- 'Expected <anything> (String) but was <12345> (Number)\n' +
- ' expected <anything> (String) but was <12345> (Number)',
- mockExpect.errorMessages[0]);
- // plus the new error...
- assertEquals("Expected: isString but was: <null>",
- mockExpect.errorMessages[1]);
- }
-
-
- /**
- * Utility method for checking for an ObjectEquals match failure. Checks that
- * the expected error message was included in the error messages appended to
- * the expectation object.
- * @param {goog.testing.mockmatchers.ArgumentMatcher.ObjectEquals} matcher
- * The matcher to test against.
- * @param {Object} matchObject The object to compare.
- * @param {string=} opt_errorMsg The deep object comparison failure message
- * to check for.
- */
- function expectObjectEqualsFailure(matcher, matchObject, opt_errorMsg) {
- mockExpect.errorMessages = [];
- assertFalse(matcher.matches(matchObject, mockExpect));
- assertNotEquals(0, mockExpect.getErrorMessageCount());
- if (opt_errorMsg) {
- assertContains(opt_errorMsg, mockExpect.errorMessages[0]);
- }
- }
-</script>
-</body>
-</html>
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mockrandom.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mockrandom.js.svn-base
deleted file mode 100644
index a29df1b..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mockrandom.js.svn-base
+++ /dev/null
@@ -1,126 +0,0 @@
-// Copyright 2008 The Closure Library Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS-IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/**
- * @fileoverview MockRandom provides a mechanism for specifying a stream of
- * numbers to expect from calls to Math.random().
- *
- */
-
-goog.provide('goog.testing.MockRandom');
-
-goog.require('goog.Disposable');
-
-
-
-/**
- * Class for unit testing code that uses Math.random.
- *
- * @param {Array.<number>} sequence The sequence of numbers to return.
- * @param {boolean=} opt_install Whether to install the MockRandom at
- * construction time.
- * @extends {goog.Disposable}
- * @constructor
- */
-goog.testing.MockRandom = function(sequence, opt_install) {
- goog.Disposable.call(this);
-
- /**
- * The sequence of numbers to be returned by calls to random()
- * @type {Array.<number>}
- * @private
- */
- this.sequence_ = sequence || [];
-
- /**
- * The original Math.random function.
- * @type {function(): number}
- * @private
- */
- this.mathRandom_ = Math.random;
-
- if (opt_install) {
- this.install();
- }
-};
-goog.inherits(goog.testing.MockRandom, goog.Disposable);
-
-
-/**
- * Whether this MockRandom has been installed.
- * @type {boolean}
- * @private
- */
-goog.testing.MockRandom.prototype.installed_;
-
-
-/**
- * Installs this MockRandom as the system number generator.
- */
-goog.testing.MockRandom.prototype.install = function() {
- if (!this.installed_) {
- Math.random = goog.bind(this.random, this);
- this.installed_ = true;
- }
-};
-
-
-/**
- * @return {number} The next number in the sequence. If there are no more values
- * left, this will return a random number.
- */
-goog.testing.MockRandom.prototype.random = function() {
- return this.hasMoreValues() ? this.sequence_.shift() : this.mathRandom_();
-};
-
-
-/**
- * @return {boolean} Whether there are more numbers left in the sequence.
- */
-goog.testing.MockRandom.prototype.hasMoreValues = function() {
- return this.sequence_.length > 0;
-};
-
-
-/**
- * Injects new numbers into the beginning of the sequence.
- * @param {Array.<number>|number} values Number or array of numbers to inject.
- */
-goog.testing.MockRandom.prototype.inject = function(values) {
- if (goog.isArray(values)) {
- this.sequence_ = values.concat(this.sequence_);
- } else {
- this.sequence_.splice(0, 0, values);
- }
-};
-
-
-/**
- * Uninstalls the MockRandom.
- */
-goog.testing.MockRandom.prototype.uninstall = function() {
- if (this.installed_) {
- Math.random = this.mathRandom_;
- this.installed_ = false;
- }
-};
-
-
-/** @override */
-goog.testing.MockRandom.prototype.disposeInternal = function() {
- this.uninstall();
- delete this.sequence_;
- delete this.mathRandom_;
- goog.testing.MockRandom.superClass_.disposeInternal.call(this);
-};
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mockrandom_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mockrandom_test.html.svn-base
deleted file mode 100644
index ebf3ff1..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mockrandom_test.html.svn-base
+++ /dev/null
@@ -1,56 +0,0 @@
-<!DOCTYPE html>
-<html>
-<!--
-Copyright 2008 The Closure Library Authors. All Rights Reserved.
-
-Use of this source code is governed by the Apache License, Version 2.0.
-See the COPYING file for details.
--->
-<head>
-<meta http-equiv="X-UA-Compatible" content="IE=edge">
-<title>Closure Unit Tests - goog.testing.MockRandom</title>
-<script src="../base.js"></script>
-<script>
- goog.require('goog.testing.MockRandom');
- goog.require('goog.testing.jsunit');
-</script>
-</head>
-<body>
-<script>
-
- function testMockRandomInstall() {
- var random = new goog.testing.MockRandom([]);
- var originalRandom = Math.random;
-
- assertFalse(!!random.installed_);
-
- random.install();
- assertTrue(random.installed_);
- assertNotEquals(Math.random, originalRandom);
-
- random.uninstall();
- assertFalse(random.installed_);
- assertEquals(originalRandom, Math.random);
- }
-
- function testMockRandomRandom() {
- var random = new goog.testing.MockRandom([], true);
-
- assertFalse(random.hasMoreValues());
-
- random.inject(2);
- assertTrue(random.hasMoreValues());
- assertEquals(2, Math.random());
-
- random.inject([1, 2, 3]);
- assertTrue(random.hasMoreValues());
- assertEquals(1, Math.random());
- assertEquals(2, Math.random());
- assertEquals(3, Math.random());
- assertFalse(random.hasMoreValues());
- assertNotUndefined(Math.random());
- }
-
-</script>
-</body>
-</html>
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mockrange.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mockrange.js.svn-base
deleted file mode 100644
index a49389d..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mockrange.js.svn-base
+++ /dev/null
@@ -1,65 +0,0 @@
-// Copyright 2008 The Closure Library Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS-IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/**
- * @fileoverview LooseMock of goog.dom.AbstractRange.
- *
- */
-
-goog.provide('goog.testing.MockRange');
-
-goog.require('goog.dom.AbstractRange');
-goog.require('goog.testing.LooseMock');
-
-
-
-/**
- * LooseMock of goog.dom.AbstractRange. Useful because the mock framework cannot
- * simply create a mock out of an abstract class, and cannot create a mock out
- * of classes that implements __iterator__ because it relies on the default
- * behavior of iterating through all of an object's properties.
- * @constructor
- * @extends {goog.testing.LooseMock}
- */
-goog.testing.MockRange = function() {
- goog.testing.LooseMock.call(this, goog.testing.MockRange.ConcreteRange_);
-};
-goog.inherits(goog.testing.MockRange, goog.testing.LooseMock);
-
-
-// *** Private helper class ************************************************* //
-
-
-
-/**
- * Concrete subclass of goog.dom.AbstractRange that simply sets the abstract
- * method __iterator__ to undefined so that javascript defaults to iterating
- * through all of the object's properties.
- * @constructor
- * @extends {goog.dom.AbstractRange}
- * @private
- */
-goog.testing.MockRange.ConcreteRange_ = function() {
- goog.dom.AbstractRange.call(this);
-};
-goog.inherits(goog.testing.MockRange.ConcreteRange_, goog.dom.AbstractRange);
-
-
-/**
- * Undefine the iterator so the mock framework can loop through this class'
- * properties.
- * @type {undefined}
- * @override
- */
-goog.testing.MockRange.ConcreteRange_.prototype.__iterator__ = undefined;
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mockrange_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mockrange_test.html.svn-base
deleted file mode 100644
index d4b5324..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mockrange_test.html.svn-base
+++ /dev/null
@@ -1,41 +0,0 @@
-<!DOCTYPE html>
-<html>
-<!--
-Copyright 2008 The Closure Library Authors. All Rights Reserved.
-
-Use of this source code is governed by the Apache License, Version 2.0.
-See the COPYING file for details.
--->
-<!--
-
--->
-<head>
-<meta http-equiv="X-UA-Compatible" content="IE=edge">
-<title>Closure Unit Tests - goog.testing.MockRange</title>
-<script src="../base.js"></script>
-<script>
- goog.require('goog.testing.MockRange');
- goog.require('goog.testing.jsunit');
-</script>
-</head>
-<body>
-<script>
-
- /**
- * Tests that a MockRange can be created successfully, a call to a mock
- * method can be recorded, and the correct behavior replayed and verified.
- */
- function testMockMethod() {
- var mockRange = new goog.testing.MockRange();
- mockRange.getStartOffset().$returns(42);
- mockRange.$replay();
-
- assertEquals('Mock method should return recorded value',
- 42,
- mockRange.getStartOffset());
- mockRange.$verify();
- }
-
-</script>
-</body>
-</html>
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mockstorage.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mockstorage.js.svn-base
deleted file mode 100644
index 2d191ab..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mockstorage.js.svn-base
+++ /dev/null
@@ -1,102 +0,0 @@
-// Copyright 2011 The Closure Library Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS-IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/**
- * @fileoverview Provides a JS storage class implementing the HTML5 Storage
- * interface.
- */
-
-
-goog.require('goog.structs.Map');
-
-
-goog.provide('goog.testing.MockStorage');
-
-
-
-/**
- * A JS storage instance, implementing the HMTL5 Storage interface.
- * See http://www.w3.org/TR/webstorage/ for details.
- *
- * @constructor
- * @implements {Storage}
- */
-goog.testing.MockStorage = function() {
- /**
- * The underlying storage object.
- * @type {goog.structs.Map}
- * @private
- */
- this.store_ = new goog.structs.Map();
-
- /**
- * The number of elements in the storage.
- * @type {number}
- */
- this.length = 0;
-};
-
-
-/**
- * Sets an item to the storage.
- * @param {string} key Storage key.
- * @param {*} value Storage value. Must be convertible to string.
- */
-goog.testing.MockStorage.prototype.setItem = function(key, value) {
- this.store_.set(key, String(value));
- this.length = this.store_.getCount();
-};
-
-
-/**
- * Gets an item from the storage. The item returned is the "structured clone"
- * of the value from setItem. In practice this means it's the value cast to a
- * string.
- * @param {string} key Storage key.
- * @return {?string} Storage value for key; null if does not exist.
- */
-goog.testing.MockStorage.prototype.getItem = function(key) {
- var val = this.store_.get(key);
- // Enforce that getItem returns string values.
- return (val != null) ? /** @type {string} */ (val) : null;
-};
-
-
-/**
- * Removes and item from the storage.
- * @param {string} key Storage key.
- */
-goog.testing.MockStorage.prototype.removeItem = function(key) {
- this.store_.remove(key);
- this.length = this.store_.getCount();
-};
-
-
-/**
- * Clears the storage.
- */
-goog.testing.MockStorage.prototype.clear = function() {
- this.store_.clear();
- this.length = 0;
-};
-
-
-/**
- * Returns the key at the given index.
- * @param {number} index The index for the key.
- * @return {?string} Key at the given index, null if not found.
- */
-goog.testing.MockStorage.prototype.key = function(index) {
- return this.store_.getKeys()[index] || null;
-};
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mockstorage_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mockstorage_test.html.svn-base
deleted file mode 100644
index a36a88a..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mockstorage_test.html.svn-base
+++ /dev/null
@@ -1,78 +0,0 @@
-<!DOCTYPE html>
-<html>
-<!--
-Copyright 2011 The Closure Library Authors. All Rights Reserved.
-
-Use of this source code is governed by the Apache License, Version 2.0.
-See the COPYING file for details.
--->
-<!--
-
--->
-<head>
-<meta http-equiv="X-UA-Compatible" content="IE=edge">
-<title>Closure Unit Tests - goog.testing.MockStorage</title>
-<script src="../base.js"></script>
-<script>
- goog.require('goog.testing.MockStorage');
- goog.require('goog.testing.jsunit');
-</script>
-</head>
-<body>
-<script>
- var instance;
-
- function setUp() {
- instance = new goog.testing.MockStorage();
- }
-
- /**
- * Tests the MockStorage interface.
- */
- function testMockStorage() {
- assertEquals(0, instance.length);
-
- instance.setItem('foo', 'bar');
- assertEquals(1, instance.length);
- assertEquals('bar', instance.getItem('foo'));
- assertEquals('foo', instance.key(0));
-
- instance.setItem('foo', 'baz');
- assertEquals('baz', instance.getItem('foo'));
-
- instance.setItem('goo', 'gl');
- assertEquals(2, instance.length);
- assertEquals('gl', instance.getItem('goo'));
- assertEquals('goo', instance.key(1));
-
- assertNull(instance.getItem('poogle'));
-
- instance.removeItem('foo');
- assertEquals(1, instance.length);
- assertEquals('goo', instance.key(0));
-
- instance.setItem('a', 12);
- assertEquals('12', instance.getItem('a'));
- instance.setItem('b', false);
- assertEquals('false', instance.getItem('b'));
- instance.setItem('c', {a: 1, b: 12});
- assertEquals('[object Object]', instance.getItem('c'));
-
- instance.clear();
- assertEquals(0, instance.length);
-
- // Test some special cases.
- instance.setItem('emptyString', '');
- assertEquals('', instance.getItem('emptyString'));
- instance.setItem('isNull', null);
- assertEquals('null', instance.getItem('isNull'))
- instance.setItem('isUndefined', undefined);
- assertEquals('undefined', instance.getItem('isUndefined'))
- instance.setItem('', 'empty key');
- assertEquals('empty key', instance.getItem(''));
- assertEquals(4, instance.length);
- }
-
-</script>
-</body>
-</html>
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mockuseragent.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mockuseragent.js.svn-base
deleted file mode 100644
index ced41cd..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mockuseragent.js.svn-base
+++ /dev/null
@@ -1,141 +0,0 @@
-// Copyright 2008 The Closure Library Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS-IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/**
- * @fileoverview MockUserAgent overrides goog.userAgent.getUserAgentString()
- * depending on a specified configuration.
- *
- */
-
-goog.provide('goog.testing.MockUserAgent');
-
-goog.require('goog.Disposable');
-goog.require('goog.userAgent');
-
-
-
-/**
- * Class for unit testing code that uses goog.userAgent.
- *
- * @extends {goog.Disposable}
- * @constructor
- */
-goog.testing.MockUserAgent = function() {
- goog.Disposable.call(this);
-
- /**
- * The userAgent string used by goog.userAgent.
- * @type {?string}
- * @private
- */
- this.userAgent_ = goog.userAgent.getUserAgentString();
-
- /**
- * The original goog.userAgent.getUserAgentString function.
- * @type {function():?string}
- * @private
- */
- this.originalUserAgentFunction_ = goog.userAgent.getUserAgentString;
-
- /**
- * The navigator object used by goog.userAgent
- * @type {Object}
- * @private
- */
- this.navigator_ = goog.userAgent.getNavigator();
-
- /**
- * The original goog.userAgent.getNavigator function
- * @type {function():Object}
- * @private
- */
- this.originalNavigatorFunction_ = goog.userAgent.getNavigator;
-};
-goog.inherits(goog.testing.MockUserAgent, goog.Disposable);
-
-
-/**
- * Whether this MockUserAgent has been installed.
- * @type {boolean}
- * @private
- */
-goog.testing.MockUserAgent.prototype.installed_;
-
-
-/**
- * Installs this MockUserAgent.
- */
-goog.testing.MockUserAgent.prototype.install = function() {
- if (!this.installed_) {
- goog.userAgent.getUserAgentString =
- goog.bind(this.getUserAgentString, this);
- goog.userAgent.getNavigator = goog.bind(this.getNavigator, this);
- this.installed_ = true;
- }
-};
-
-
-/**
- * @return {?string} The userAgent set in this class.
- */
-goog.testing.MockUserAgent.prototype.getUserAgentString = function() {
- return this.userAgent_;
-};
-
-
-/**
- * @param {string} userAgent The desired userAgent string to use.
- */
-goog.testing.MockUserAgent.prototype.setUserAgentString = function(userAgent) {
- this.userAgent_ = userAgent;
-};
-
-
-/**
- * @return {Object} The Navigator set in this class.
- */
-goog.testing.MockUserAgent.prototype.getNavigator = function() {
- return this.navigator_;
-};
-
-
-/**
- * @param {Object} navigator The desired Navigator object to use.
- */
-goog.testing.MockUserAgent.prototype.setNavigator = function(navigator) {
- this.navigator_ = navigator;
-};
-
-
-/**
- * Uninstalls the MockUserAgent.
- */
-goog.testing.MockUserAgent.prototype.uninstall = function() {
- if (this.installed_) {
- goog.userAgent.getUserAgentString = this.originalUserAgentFunction_;
- goog.userAgent.getNavigator = this.originalNavigatorFunction_;
- this.installed_ = false;
- }
-};
-
-
-/** @override */
-goog.testing.MockUserAgent.prototype.disposeInternal = function() {
- this.uninstall();
- delete this.userAgent_;
- delete this.originalUserAgentFunction_;
- delete this.navigator_;
- delete this.originalNavigatorFunction_;
- goog.testing.MockUserAgent.superClass_.disposeInternal.call(this);
-};
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mockuseragent_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mockuseragent_test.html.svn-base
deleted file mode 100644
index 2c9e525..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/mockuseragent_test.html.svn-base
+++ /dev/null
@@ -1,59 +0,0 @@
-<!DOCTYPE html>
-<html>
-<!--
-Copyright 2008 The Closure Library Authors. All Rights Reserved.
-
-Use of this source code is governed by the Apache License, Version 2.0.
-See the COPYING file for details.
--->
-<!--
-
- @author andybons@google.com (Andrew Bonventre)
--->
-<head>
-<meta http-equiv="X-UA-Compatible" content="IE=edge">
-<title>Closure Unit Tests - goog.testing.MockUserAgent</title>
-<script src="../base.js"></script>
-<script>
- goog.require('goog.testing.MockUserAgent');
- goog.require('goog.testing.jsunit');
- goog.require('goog.userAgent');
-</script>
-</head>
-<body>
-<script>
-
- function testMockUserAgentInstall() {
- var userAgent = new goog.testing.MockUserAgent();
-
- var originalUserAgentFunction = goog.userAgent.getUserAgentString;
-
- assertFalse(!!userAgent.installed_);
-
- userAgent.install();
- assertTrue(userAgent.installed_);
- assertNotEquals(goog.userAgent.getUserAgentString,
- originalUserAgentFunction);
-
- userAgent.uninstall();
- assertFalse(userAgent.installed_);
- assertEquals(originalUserAgentFunction, goog.userAgent.getUserAgentString);
- }
-
- function testMockUserAgentGetAgent() {
- var uaString = 'Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) ' +
- 'AppleWebKit/525.13 (KHTML, like Gecko) ' +
- 'Chrome/0.2.149.27 Safari/525.13';
-
- var userAgent = new goog.testing.MockUserAgent();
- userAgent.setUserAgentString(uaString);
- userAgent.install();
-
- assertTrue(userAgent.installed_);
-
- assertEquals(uaString, goog.userAgent.getUserAgentString());
- }
-
-</script>
-</body>
-</html>
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/multitestrunner.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/multitestrunner.js.svn-base
deleted file mode 100644
index 4c94b95..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/multitestrunner.js.svn-base
+++ /dev/null
@@ -1,1440 +0,0 @@
-// Copyright 2008 The Closure Library Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS-IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/**
- * @fileoverview Utility for running multiple test files that utilize the same
- * interface as goog.testing.TestRunner. Each test is run in series and their
- * results aggregated. The main usecase for the MultiTestRunner is to allow
- * the testing of all tests in a project locally.
- *
- */
-
-goog.provide('goog.testing.MultiTestRunner');
-goog.provide('goog.testing.MultiTestRunner.TestFrame');
-
-goog.require('goog.Timer');
-goog.require('goog.array');
-goog.require('goog.dom');
-goog.require('goog.dom.classes');
-goog.require('goog.events.EventHandler');
-goog.require('goog.functions');
-goog.require('goog.string');
-goog.require('goog.ui.Component');
-goog.require('goog.ui.ServerChart');
-goog.require('goog.ui.ServerChart.ChartType');
-goog.require('goog.ui.TableSorter');
-
-
-
-/**
- * A component for running multiple tests within the browser.
- * @param {goog.dom.DomHelper=} opt_domHelper A DOM helper.
- * @extends {goog.ui.Component}
- * @constructor
- */
-goog.testing.MultiTestRunner = function(opt_domHelper) {
- goog.ui.Component.call(this, opt_domHelper);
-
- /**
- * Array of tests to execute, when combined with the base path this should be
- * a relative path to the test from the page containing the multi testrunner.
- * @type {Array.<string>}
- * @private
- */
- this.allTests_ = [];
-
- /**
- * Tests that match the filter function.
- * @type {Array.<string>}
- * @private
- */
- this.activeTests_ = [];
-
- /**
- * An event handler for handling events.
- * @type {goog.events.EventHandler}
- * @private
- */
- this.eh_ = new goog.events.EventHandler(this);
-
- /**
- * A table sorter for the stats.
- * @type {goog.ui.TableSorter}
- * @private
- */
- this.tableSorter_ = new goog.ui.TableSorter(this.dom_);
-};
-goog.inherits(goog.testing.MultiTestRunner, goog.ui.Component);
-
-
-/**
- * Default maximimum amount of time to spend at each stage of the test.
- * @type {number}
- */
-goog.testing.MultiTestRunner.DEFAULT_TIMEOUT_MS = 45 * 1000;
-
-
-/**
- * Messages corresponding to the numeric states.
- * @type {Array.<string>}
- */
-goog.testing.MultiTestRunner.STATES = [
- 'waiting for test runner',
- 'initializing tests',
- 'waiting for tests to finish'
-];
-
-
-/**
- * The test suite's name.
- * @type {string} name
- * @private
- */
-goog.testing.MultiTestRunner.prototype.name_ = '';
-
-
-/**
- * The base path used to resolve files within the allTests_ array.
- * @type {string}
- * @private
- */
-goog.testing.MultiTestRunner.prototype.basePath_ = '';
-
-
-/**
- * A set of tests that have finished. All extant keys map to true.
- * @type {Object.<boolean>}
- * @private
- */
-goog.testing.MultiTestRunner.prototype.finished_ = null;
-
-
-/**
- * Whether the report should contain verbose information about the passes.
- * @type {boolean}
- * @private
- */
-goog.testing.MultiTestRunner.prototype.verbosePasses_ = false;
-
-
-/**
- * Whether to hide passing tests completely in the report, makes verbosePasses_
- * obsolete.
- * @type {boolean}
- * @private
- */
-goog.testing.MultiTestRunner.prototype.hidePasses_ = false;
-
-
-/**
- * Flag used to tell the test runner to stop after the current test.
- * @type {boolean}
- * @private
- */
-goog.testing.MultiTestRunner.prototype.stopped_ = false;
-
-
-/**
- * Flag indicating whether the test runner is active.
- * @type {boolean}
- * @private
- */
-goog.testing.MultiTestRunner.prototype.active_ = false;
-
-
-/**
- * Index of the next test to run.
- * @type {number}
- * @private
- */
-goog.testing.MultiTestRunner.prototype.startedCount_ = 0;
-
-
-/**
- * Count of the results received so far.
- * @type {number}
- * @private
- */
-goog.testing.MultiTestRunner.prototype.resultCount_ = 0;
-
-
-/**
- * Number of passes so far.
- * @type {number}
- * @private
- */
-goog.testing.MultiTestRunner.prototype.passes_ = 0;
-
-
-/**
- * Timestamp for the current start time.
- * @type {number}
- * @private
- */
-goog.testing.MultiTestRunner.prototype.startTime_ = 0;
-
-
-/**
- * Only tests whose paths patch this filter function will be
- * executed.
- * @type {function(string): boolean}
- * @private
- */
-goog.testing.MultiTestRunner.prototype.filterFn_ = goog.functions.TRUE;
-
-
-/**
- * Number of milliseconds to wait for loading and initialization steps.
- * @type {number}
- * @private
- */
-goog.testing.MultiTestRunner.prototype.timeoutMs_ =
- goog.testing.MultiTestRunner.DEFAULT_TIMEOUT_MS;
-
-
-/**
- * An array of objects containing stats about the tests.
- * @type {Array.<Object>?}
- * @private
- */
-goog.testing.MultiTestRunner.prototype.stats_ = null;
-
-
-/**
- * Reference to the start button element.
- * @type {Element}
- * @private
- */
-goog.testing.MultiTestRunner.prototype.startButtonEl_ = null;
-
-
-/**
- * Reference to the stop button element.
- * @type {Element}
- * @private
- */
-goog.testing.MultiTestRunner.prototype.stopButtonEl_ = null;
-
-
-/**
- * Reference to the log element.
- * @type {Element}
- * @private
- */
-goog.testing.MultiTestRunner.prototype.logEl_ = null;
-
-
-/**
- * Reference to the report element.
- * @type {Element}
- * @private
- */
-goog.testing.MultiTestRunner.prototype.reportEl_ = null;
-
-
-/**
- * Reference to the stats element.
- * @type {Element}
- * @private
- */
-goog.testing.MultiTestRunner.prototype.statsEl_ = null;
-
-
-/**
- * Reference to the progress bar's element.
- * @type {Element}
- * @private
- */
-goog.testing.MultiTestRunner.prototype.progressEl_ = null;
-
-
-/**
- * Reference to the progress bar's inner row element.
- * @type {Element}
- * @private
- */
-goog.testing.MultiTestRunner.prototype.progressRow_ = null;
-
-
-/**
- * Reference to the log tab.
- * @type {Element}
- * @private
- */
-goog.testing.MultiTestRunner.prototype.logTabEl_ = null;
-
-
-/**
- * Reference to the report tab.
- * @type {Element}
- * @private
- */
-goog.testing.MultiTestRunner.prototype.reportTabEl_ = null;
-
-
-/**
- * Reference to the stats tab.
- * @type {Element}
- * @private
- */
-goog.testing.MultiTestRunner.prototype.statsTabEl_ = null;
-
-
-/**
- * The number of tests to run at a time.
- * @type {number}
- * @private
- */
-goog.testing.MultiTestRunner.prototype.poolSize_ = 1;
-
-
-/**
- * The size of the stats bucket for the number of files loaded histogram.
- * @type {number}
- * @private
- */
-goog.testing.MultiTestRunner.prototype.numFilesStatsBucketSize_ = 20;
-
-
-/**
- * The size of the stats bucket in ms for the run time histogram.
- * @type {number}
- * @private
- */
-goog.testing.MultiTestRunner.prototype.runTimeStatsBucketSize_ = 500;
-
-
-/**
- * Sets the name for the test suite.
- * @param {string} name The suite's name.
- * @return {goog.testing.MultiTestRunner} Instance for chaining.
- */
-goog.testing.MultiTestRunner.prototype.setName = function(name) {
- this.name_ = name;
- return this;
-};
-
-
-/**
- * Returns the name for the test suite.
- * @return {string} The name for the test suite.
- */
-goog.testing.MultiTestRunner.prototype.getName = function() {
- return this.name_;
-};
-
-
-/**
- * Sets the basepath that tests added using addTests are resolved with.
- * @param {string} path The relative basepath.
- * @return {goog.testing.MultiTestRunner} Instance for chaining.
- */
-goog.testing.MultiTestRunner.prototype.setBasePath = function(path) {
- this.basePath_ = path;
- return this;
-};
-
-
-/**
- * Returns the basepath that tests added using addTests are resolved with.
- * @return {string} The basepath that tests added using addTests are resolved
- * with.
- */
-goog.testing.MultiTestRunner.prototype.getBasePath = function() {
- return this.basePath_;
-};
-
-
-/**
- * Sets whether the report should contain verbose information for tests that
- * pass.
- * @param {boolean} verbose Whether report should be verbose.
- * @return {goog.testing.MultiTestRunner} Instance for chaining.
- */
-goog.testing.MultiTestRunner.prototype.setVerbosePasses = function(verbose) {
- this.verbosePasses_ = verbose;
- return this;
-};
-
-
-/**
- * Returns whether the report should contain verbose information for tests that
- * pass.
- * @return {boolean} Whether the report should contain verbose information for
- * tests that pass.
- */
-goog.testing.MultiTestRunner.prototype.getVerbosePasses = function() {
- return this.verbosePasses_;
-};
-
-
-/**
- * Sets whether the report should contain passing tests at all, makes
- * setVerbosePasses obsolete.
- * @param {boolean} hide Whether report should not contain passing tests.
- * @return {goog.testing.MultiTestRunner} Instance for chaining.
- */
-goog.testing.MultiTestRunner.prototype.setHidePasses = function(hide) {
- this.hidePasses_ = hide;
- return this;
-};
-
-
-/**
- * Returns whether the report should contain passing tests at all, makes
- * setVerbosePasses obsolete.
- * @return {boolean} Whether the report should contain passing tests at all,
- * makes setVerbosePasses obsolete.
- */
-goog.testing.MultiTestRunner.prototype.getHidePasses = function() {
- return this.hidePasses_;
-};
-
-
-/**
- * Sets the bucket sizes for the histograms.
- * @param {number} f Bucket size for num files loaded histogram.
- * @param {number} t Bucket size for run time histogram.
- * @return {goog.testing.MultiTestRunner} Instance for chaining.
- */
-goog.testing.MultiTestRunner.prototype.setStatsBucketSizes = function(f, t) {
- this.numFilesStatsBucketSize_ = f;
- this.runTimeStatsBucketSize_ = t;
- return this;
-};
-
-
-/**
- * Sets the number of milliseconds to wait for the page to load, initialize and
- * run the tests.
- * @param {number} timeout Time in milliseconds.
- * @return {goog.testing.MultiTestRunner} Instance for chaining.
- */
-goog.testing.MultiTestRunner.prototype.setTimeout = function(timeout) {
- this.timeoutMs_ = timeout;
- return this;
-};
-
-
-/**
- * Returns the number of milliseconds to wait for the page to load, initialize
- * and run the tests.
- * @return {number} The number of milliseconds to wait for the page to load,
- * initialize and run the tests.
- */
-goog.testing.MultiTestRunner.prototype.getTimeout = function() {
- return this.timeoutMs_;
-};
-
-
-/**
- * Sets the number of tests that can be run at the same time. This only improves
- * performance due to the amount of time spent loading the tests.
- * @param {number} size The number of tests to run at a time.
- * @return {goog.testing.MultiTestRunner} Instance for chaining.
- */
-goog.testing.MultiTestRunner.prototype.setPoolSize = function(size) {
- this.poolSize_ = size;
- return this;
-};
-
-
-/**
- * Returns the number of tests that can be run at the same time. This only
- * improves performance due to the amount of time spent loading the tests.
- * @return {number} The number of tests that can be run at the same time. This
- * only improves performance due to the amount of time spent loading the
- * tests.
- */
-goog.testing.MultiTestRunner.prototype.getPoolSize = function() {
- return this.poolSize_;
-};
-
-
-/**
- * Sets a filter function. Only test paths that match the filter function
- * will be executed.
- * @param {function(string): boolean} filterFn Filters test paths.
- * @return {goog.testing.MultiTestRunner} Instance for chaining.
- */
-goog.testing.MultiTestRunner.prototype.setFilterFunction = function(filterFn) {
- this.filterFn_ = filterFn;
- return this;
-};
-
-
-/**
- * Returns a filter function. Only test paths that match the filter function
- * will be executed.
- * @return {function(string): boolean} A filter function. Only test paths that
- * match the filter function will be executed.
-
- */
-goog.testing.MultiTestRunner.prototype.getFilterFunction = function() {
- return this.filterFn_;
-};
-
-
-/**
- * Adds an array of tests to the tests that the test runner should execute.
- * @param {Array.<string>} tests Adds tests to the test runner.
- * @return {goog.testing.MultiTestRunner} Instance for chaining.
- */
-goog.testing.MultiTestRunner.prototype.addTests = function(tests) {
- goog.array.extend(this.allTests_, tests);
- return this;
-};
-
-
-/**
- * Returns the list of all tests added to the runner.
- * @return {Array.<string>} The list of all tests added to the runner.
- */
-goog.testing.MultiTestRunner.prototype.getAllTests = function() {
- return this.allTests_;
-};
-
-
-/**
- * Returns the list of tests that will be run when start() is called.
- * @return {Array.<string>} The list of tests that will be run when start() is
- * called.
- */
-goog.testing.MultiTestRunner.prototype.getTestsToRun = function() {
- return goog.array.filter(this.allTests_, this.filterFn_);
-};
-
-
-/**
- * Returns a list of tests from runner that have been marked as failed.
- * @return {Array.<string>} A list of tests from runner that have been marked as
- * failed.
- */
-goog.testing.MultiTestRunner.prototype.getTestsThatFailed = function() {
- var stats = this.stats_;
- var failedTests = [];
- if (stats) {
- for (var i = 0, stat; stat = stats[i]; i++) {
- if (!stat.success) {
- failedTests.push(stat.testFile);
- }
- }
- }
- return failedTests;
-};
-
-
-/**
- * Deletes and re-creates the progress table inside the progess element.
- * @private
- */
-goog.testing.MultiTestRunner.prototype.resetProgressDom_ = function() {
- goog.dom.removeChildren(this.progressEl_);
- var progressTable = this.dom_.createDom('table');
- var progressTBody = this.dom_.createDom('tbody');
- this.progressRow_ = this.dom_.createDom('tr');
- for (var i = 0; i < this.activeTests_.length; i++) {
- var progressCell = this.dom_.createDom('td');
- this.progressRow_.appendChild(progressCell);
- }
- progressTBody.appendChild(this.progressRow_);
- progressTable.appendChild(progressTBody);
- this.progressEl_.appendChild(progressTable);
-};
-
-
-/** @override */
-goog.testing.MultiTestRunner.prototype.createDom = function() {
- goog.testing.MultiTestRunner.superClass_.createDom.call(this);
- var el = this.getElement();
- el.className = goog.getCssName('goog-testrunner');
-
- this.progressEl_ = this.dom_.createDom('div');
- this.progressEl_.className = goog.getCssName('goog-testrunner-progress');
- el.appendChild(this.progressEl_);
-
- var buttons = this.dom_.createDom('div');
- buttons.className = goog.getCssName('goog-testrunner-buttons');
- this.startButtonEl_ = this.dom_.createDom('button', null, 'Start');
- this.stopButtonEl_ =
- this.dom_.createDom('button', {'disabled': true}, 'Stop');
- buttons.appendChild(this.startButtonEl_);
- buttons.appendChild(this.stopButtonEl_);
- el.appendChild(buttons);
-
- this.eh_.listen(this.startButtonEl_, 'click',
- this.onStartClicked_);
- this.eh_.listen(this.stopButtonEl_, 'click',
- this.onStopClicked_);
-
- this.logEl_ = this.dom_.createElement('div');
- this.logEl_.className = goog.getCssName('goog-testrunner-log');
- el.appendChild(this.logEl_);
-
- this.reportEl_ = this.dom_.createElement('div');
- this.reportEl_.className = goog.getCssName('goog-testrunner-report');
- this.reportEl_.style.display = 'none';
- el.appendChild(this.reportEl_);
-
- this.statsEl_ = this.dom_.createElement('div');
- this.statsEl_.className = goog.getCssName('goog-testrunner-stats');
- this.statsEl_.style.display = 'none';
- el.appendChild(this.statsEl_);
-
- this.logTabEl_ = this.dom_.createDom('div', null, 'Log');
- this.logTabEl_.className = goog.getCssName('goog-testrunner-logtab') + ' ' +
- goog.getCssName('goog-testrunner-activetab');
- el.appendChild(this.logTabEl_);
-
- this.reportTabEl_ = this.dom_.createDom('div', null, 'Report');
- this.reportTabEl_.className = goog.getCssName('goog-testrunner-reporttab');
- el.appendChild(this.reportTabEl_);
-
- this.statsTabEl_ = this.dom_.createDom('div', null, 'Stats');
- this.statsTabEl_.className = goog.getCssName('goog-testrunner-statstab');
- el.appendChild(this.statsTabEl_);
-
- this.eh_.listen(this.logTabEl_, 'click', this.onLogTabClicked_);
- this.eh_.listen(this.reportTabEl_, 'click', this.onReportTabClicked_);
- this.eh_.listen(this.statsTabEl_, 'click', this.onStatsTabClicked_);
-
-};
-
-
-/** @override */
-goog.testing.MultiTestRunner.prototype.disposeInternal = function() {
- goog.testing.MultiTestRunner.superClass_.disposeInternal.call(this);
- this.tableSorter_.dispose();
- this.eh_.dispose();
- this.startButtonEl_ = null;
- this.stopButtonEl_ = null;
- this.logEl_ = null;
- this.reportEl_ = null;
- this.progressEl_ = null;
- this.logTabEl_ = null;
- this.reportTabEl_ = null;
- this.statsTabEl_ = null;
- this.statsEl_ = null;
-};
-
-
-/**
- * Starts executing the tests.
- */
-goog.testing.MultiTestRunner.prototype.start = function() {
- this.startButtonEl_.disabled = true;
- this.stopButtonEl_.disabled = false;
- this.stopped_ = false;
- this.active_ = true;
- this.finished_ = {};
- this.activeTests_ = this.getTestsToRun();
- this.startedCount_ = 0;
- this.resultCount_ = 0;
- this.passes_ = 0;
- this.stats_ = [];
- this.startTime_ = goog.now();
-
- this.resetProgressDom_();
- goog.dom.removeChildren(this.logEl_);
-
- this.resetReport_();
- this.clearStats_();
- this.showTab_(0);
-
- // Ensure the pool isn't too big.
- while (this.getChildCount() > this.poolSize_) {
- this.removeChildAt(0, true).dispose();
- }
-
- // Start a test in each runner.
- for (var i = 0; i < this.poolSize_; i++) {
- if (i >= this.getChildCount()) {
- var testFrame = new goog.testing.MultiTestRunner.TestFrame(
- this.basePath_, this.timeoutMs_, this.verbosePasses_, this.dom_);
- this.addChild(testFrame, true);
- }
- this.runNextTest_(
- /** @type {goog.testing.MultiTestRunner.TestFrame} */
- (this.getChildAt(i)));
- }
-};
-
-
-/**
- * Logs a message to the log window.
- * @param {string} msg A message to log.
- */
-goog.testing.MultiTestRunner.prototype.log = function(msg) {
- if (msg != '.') {
- msg = this.getTimeStamp_() + ' : ' + msg;
- }
-
- this.logEl_.appendChild(this.dom_.createDom('div', null, msg));
-
- // Autoscroll if we're near the bottom.
- var top = this.logEl_.scrollTop;
- var height = this.logEl_.scrollHeight - this.logEl_.offsetHeight;
- if (top == 0 || top > height - 50) {
- this.logEl_.scrollTop = height;
- }
-};
-
-
-/**
- * Processes a result returned from a TestFrame. If there are tests remaining
- * it will trigger the next one to be run, otherwise if there are no tests and
- * all results have been recieved then it will call finish.
- * @param {goog.testing.MultiTestRunner.TestFrame} frame The frame that just
- * finished.
- */
-goog.testing.MultiTestRunner.prototype.processResult = function(frame) {
- var success = frame.isSuccess();
- var report = frame.getReport();
- var test = frame.getTestFile();
-
- this.stats_.push(frame.getStats());
- this.finished_[test] = true;
-
- var prefix = success ? '' : '*** FAILURE *** ';
- this.log(prefix +
- this.trimFileName_(test) + ' : ' + (success ? 'Passed' : 'Failed'));
-
- this.resultCount_++;
-
- if (success) {
- this.passes_++;
- }
-
- this.drawProgressSegment_(test, success);
- this.writeCurrentSummary_();
- if (!(success && this.hidePasses_)) {
- this.drawTestResult_(test, success, report);
- }
-
- if (!this.stopped_ && this.startedCount_ < this.activeTests_.length) {
- this.runNextTest_(frame);
- } else if (this.resultCount_ == this.activeTests_.length) {
- this.finish_();
- }
-};
-
-
-/**
- * Runs the next available test, if there are any left.
- * @param {goog.testing.MultiTestRunner.TestFrame} frame Where to run the test.
- * @private
- */
-goog.testing.MultiTestRunner.prototype.runNextTest_ = function(frame) {
- if (this.startedCount_ < this.activeTests_.length) {
- var nextTest = this.activeTests_[this.startedCount_++];
- this.log(this.trimFileName_(nextTest) + ' : Loading');
- frame.runTest(nextTest);
- }
-};
-
-
-/**
- * Handles the test finishing, processing the results and rendering the report.
- * @private
- */
-goog.testing.MultiTestRunner.prototype.finish_ = function() {
- if (this.stopped_) {
- this.log('Stopped');
- } else {
- this.log('Finished');
- }
-
- this.startButtonEl_.disabled = false;
- this.stopButtonEl_.disabled = true;
- this.active_ = false;
-
- this.showTab_(1);
- this.drawStats_();
-
- // Remove all the test frames
- while (this.getChildCount() > 0) {
- this.removeChildAt(0, true).dispose();
- }
-
- // Compute tests that did not finish before the stop button was hit.
- var unfinished = [];
- for (var i = 0; i < this.activeTests_.length; i++) {
- var test = this.activeTests_[i];
- if (!this.finished_[test]) {
- unfinished.push(test);
- }
- }
-
- if (unfinished.length) {
- this.reportEl_.appendChild(goog.dom.createDom('pre', undefined,
- 'Theses tests did not finish:\n' + unfinished.join('\n')));
- }
-};
-
-
-/**
- * Resets the report, clearing out all children and drawing the initial summary.
- * @private
- */
-goog.testing.MultiTestRunner.prototype.resetReport_ = function() {
- goog.dom.removeChildren(this.reportEl_);
- var summary = this.dom_.createDom('div');
- summary.className = goog.getCssName('goog-testrunner-progress-summary');
- this.reportEl_.appendChild(summary);
- this.writeCurrentSummary_();
-};
-
-
-/**
- * Draws the stats for the test run.
- * @private
- */
-goog.testing.MultiTestRunner.prototype.drawStats_ = function() {
- this.drawFilesHistogram_();
-
- // Only show time stats if pool size is 1, otherwise times are wrong.
- if (this.poolSize_ == 1) {
- this.drawRunTimePie_();
- this.drawTimeHistogram_();
- }
-
- this.drawWorstTestsTable_();
-};
-
-
-/**
- * Draws the histogram showing number of files loaded.
- * @private
- */
-goog.testing.MultiTestRunner.prototype.drawFilesHistogram_ = function() {
- this.drawStatsHistogram_(
- 'numFilesLoaded',
- this.numFilesStatsBucketSize_,
- goog.functions.identity,
- 500,
- 'Histogram showing distribution of\nnumber of files loaded per test');
-};
-
-
-/**
- * Draws the histogram showing how long each test took to complete.
- * @private
- */
-goog.testing.MultiTestRunner.prototype.drawTimeHistogram_ = function() {
- this.drawStatsHistogram_(
- 'totalTime',
- this.runTimeStatsBucketSize_,
- function(x) { return x / 1000; },
- 500,
- 'Histogram showing distribution of\ntime spent running tests in s');
-};
-
-
-/**
- * Draws a stats histogram.
- * @param {string} statsField Field of the stats object to graph.
- * @param {number} bucketSize The size for the histogram's buckets.
- * @param {function(*, ...[*]): *} valueTransformFn Function for transforming
- * the x-labels value for display.
- * @param {number} width The width in pixels of the graph.
- * @param {string} title The graph's title.
- * @private
- */
-goog.testing.MultiTestRunner.prototype.drawStatsHistogram_ = function(
- statsField, bucketSize, valueTransformFn, width, title) {
-
- var hist = {}, data = [], xlabels = [], ylabels = [];
- var max = 0;
- for (var i = 0; i < this.stats_.length; i++) {
- var num = this.stats_[i][statsField];
- var bucket = Math.floor(num / bucketSize) * bucketSize;
- if (bucket > max) {
- max = bucket;
- }
- if (!hist[bucket]) {
- hist[bucket] = 1;
- } else {
- hist[bucket]++;
- }
- }
- var maxBucketSize = 0;
- for (var i = 0; i <= max; i += bucketSize) {
- xlabels.push(valueTransformFn(i));
- var count = hist[i] || 0;
- if (count > maxBucketSize) {
- maxBucketSize = count;
- }
- data.push(count);
- }
- var diff = Math.max(1, Math.ceil(maxBucketSize / 10));
- for (var i = 0; i <= maxBucketSize; i += diff) {
- ylabels.push(i);
- }
- var chart = new goog.ui.ServerChart(
- goog.ui.ServerChart.ChartType.VERTICAL_STACKED_BAR, width, 250);
- chart.setTitle(title);
- chart.addDataSet(data, 'ff9900');
- chart.setLeftLabels(ylabels);
- chart.setGridY(ylabels.length - 1);
- chart.setXLabels(xlabels);
- chart.render(this.statsEl_);
-};
-
-
-/**
- * Draws a pie chart showing the percentage of time spent running the tests
- * compared to loading them etc.
- * @private
- */
-goog.testing.MultiTestRunner.prototype.drawRunTimePie_ = function() {
- var totalTime = 0, runTime = 0;
- for (var i = 0; i < this.stats_.length; i++) {
- var stat = this.stats_[i];
- totalTime += stat.totalTime;
- runTime += stat.runTime;
- }
- var loadTime = totalTime - runTime;
- var pie = new goog.ui.ServerChart(
- goog.ui.ServerChart.ChartType.PIE, 500, 250);
- pie.setMinValue(0);
- pie.setMaxValue(totalTime);
- pie.addDataSet([runTime, loadTime], 'ff9900');
- pie.setXLabels([
- 'Test execution (' + runTime + 'ms)',
- 'Loading (' + loadTime + 'ms)']);
- pie.render(this.statsEl_);
-};
-
-
-/**
- * Draws a pie chart showing the percentage of time spent running the tests
- * compared to loading them etc.
- * @private
- */
-goog.testing.MultiTestRunner.prototype.drawWorstTestsTable_ = function() {
- this.stats_.sort(function(a, b) {
- return b['numFilesLoaded'] - a['numFilesLoaded'];
- });
-
- var tbody = goog.bind(this.dom_.createDom, this.dom_, 'tbody');
- var thead = goog.bind(this.dom_.createDom, this.dom_, 'thead');
- var tr = goog.bind(this.dom_.createDom, this.dom_, 'tr');
- var th = goog.bind(this.dom_.createDom, this.dom_, 'th');
- var td = goog.bind(this.dom_.createDom, this.dom_, 'td');
- var a = goog.bind(this.dom_.createDom, this.dom_, 'a');
-
- var head = thead({'style': 'cursor: pointer'},
- tr(null,
- th(null, ' '),
- th(null, 'Test file'),
- th('center', 'Num files loaded'),
- th('center', 'Run time (ms)'),
- th('center', 'Total time (ms)')));
- var body = tbody();
- var table = this.dom_.createDom('table', null, head, body);
-
- for (var i = 0; i < this.stats_.length; i++) {
- var stat = this.stats_[i];
- body.appendChild(tr(null,
- td('center', String(i + 1)),
- td(null, a(
- {'href': this.basePath_ + stat['testFile'], 'target': '_blank'},
- stat['testFile'])),
- td('center', String(stat['numFilesLoaded'])),
- td('center', String(stat['runTime'])),
- td('center', String(stat['totalTime']))));
- }
-
- this.statsEl_.appendChild(table);
-
- this.tableSorter_.setDefaultSortFunction(goog.ui.TableSorter.numericSort);
- this.tableSorter_.setSortFunction(
- 1 /* test file name */, goog.ui.TableSorter.alphaSort);
- this.tableSorter_.decorate(table);
-};
-
-
-/**
- * Clears the stats page.
- * @private
- */
-goog.testing.MultiTestRunner.prototype.clearStats_ = function() {
- goog.dom.removeChildren(this.statsEl_);
-};
-
-
-/**
- * Updates the report's summary.
- * @private
- */
-goog.testing.MultiTestRunner.prototype.writeCurrentSummary_ = function() {
- var total = this.activeTests_.length;
- var executed = this.resultCount_;
- var passes = this.passes_;
- var duration = Math.round((goog.now() - this.startTime_) / 1000);
- var text = executed + ' of ' + total + ' tests executed.<br>' +
- passes + ' passed, ' + (executed - passes) + ' failed.<br>' +
- 'Duration: ' + duration + 's.';
- this.reportEl_.firstChild.innerHTML = text;
-};
-
-
-/**
- * Adds a segment to the progress bar.
- * @param {string} title Title for the segment.
- * @param {*} success Whether the segment should indicate a success.
- * @private
- */
-goog.testing.MultiTestRunner.prototype.drawProgressSegment_ =
- function(title, success) {
- var part = this.progressRow_.cells[this.resultCount_ - 1];
- part.title = title + ' : ' + (success ? 'SUCCESS' : 'FAILURE');
- part.style.backgroundColor = success ? '#090' : '#900';
-};
-
-
-/**
- * Draws a test result in the report pane.
- * @param {string} test Test name.
- * @param {*} success Whether the test succeeded.
- * @param {string} report The report.
- * @private
- */
-goog.testing.MultiTestRunner.prototype.drawTestResult_ = function(
- test, success, report) {
- var text = goog.string.isEmpty(report) ?
- 'No report for ' + test + '\n' : report;
- var el = this.dom_.createDom('div');
- text = goog.string.htmlEscape(text).replace(/\n/g, '<br>');
- if (success) {
- el.className = goog.getCssName('goog-testrunner-report-success');
- } else {
- text += '<a href="' + this.basePath_ + test +
- '">Run individually &raquo;</a><br>&nbsp;';
- el.className = goog.getCssName('goog-testrunner-report-failure');
- }
- el.innerHTML = text;
- this.reportEl_.appendChild(el);
-};
-
-
-/**
- * Returns the current timestamp.
- * @return {string} HH:MM:SS.
- * @private
- */
-goog.testing.MultiTestRunner.prototype.getTimeStamp_ = function() {
- var d = new Date;
- return goog.string.padNumber(d.getHours(), 2) + ':' +
- goog.string.padNumber(d.getMinutes(), 2) + ':' +
- goog.string.padNumber(d.getSeconds(), 2);
-};
-
-
-/**
- * Trims a filename to be less than 35-characters, ensuring that we do not break
- * a path part.
- * @param {string} name The file name.
- * @return {string} The shortened name.
- * @private
- */
-goog.testing.MultiTestRunner.prototype.trimFileName_ = function(name) {
- if (name.length < 35) {
- return name;
- }
- var parts = name.split('/');
- var result = '';
- while (result.length < 35 && parts.length > 0) {
- result = '/' + parts.pop() + result;
- }
- return '...' + result;
-};
-
-
-/**
- * Shows the report and hides the log if the argument is true.
- * @param {number} tab Which tab to show.
- * @private
- */
-goog.testing.MultiTestRunner.prototype.showTab_ = function(tab) {
- var activeTabCssClass = goog.getCssName('goog-testrunner-activetab');
- if (tab == 0) {
- this.logEl_.style.display = '';
- goog.dom.classes.add(this.logTabEl_, activeTabCssClass);
- } else {
- this.logEl_.style.display = 'none';
- goog.dom.classes.remove(this.logTabEl_, activeTabCssClass);
- }
-
- if (tab == 1) {
- this.reportEl_.style.display = '';
- goog.dom.classes.add(this.reportTabEl_, activeTabCssClass);
- } else {
- this.reportEl_.style.display = 'none';
- goog.dom.classes.remove(this.reportTabEl_, activeTabCssClass);
- }
-
- if (tab == 2) {
- this.statsEl_.style.display = '';
- goog.dom.classes.add(this.statsTabEl_, activeTabCssClass);
- } else {
- this.statsEl_.style.display = 'none';
- goog.dom.classes.remove(this.statsTabEl_, activeTabCssClass);
- }
-};
-
-
-/**
- * Handles the start button being clicked.
- * @param {goog.events.BrowserEvent} e The click event.
- * @private
- */
-goog.testing.MultiTestRunner.prototype.onStartClicked_ = function(e) {
- this.start();
-};
-
-
-/**
- * Handles the stop button being clicked.
- * @param {goog.events.BrowserEvent} e The click event.
- * @private
- */
-goog.testing.MultiTestRunner.prototype.onStopClicked_ = function(e) {
- this.stopped_ = true;
- this.finish_();
-};
-
-
-/**
- * Handles the log tab being clicked.
- * @param {goog.events.BrowserEvent} e The click event.
- * @private
- */
-goog.testing.MultiTestRunner.prototype.onLogTabClicked_ = function(e) {
- this.showTab_(0);
-};
-
-
-/**
- * Handles the log tab being clicked.
- * @param {goog.events.BrowserEvent} e The click event.
- * @private
- */
-goog.testing.MultiTestRunner.prototype.onReportTabClicked_ = function(e) {
- this.showTab_(1);
-};
-
-
-/**
- * Handles the stats tab being clicked.
- * @param {goog.events.BrowserEvent} e The click event.
- * @private
- */
-goog.testing.MultiTestRunner.prototype.onStatsTabClicked_ = function(e) {
- this.showTab_(2);
-};
-
-
-
-/**
- * Class used to manage the interaction with a single iframe.
- * @param {string} basePath The base path for tests.
- * @param {number} timeoutMs The time to wait for the test to load and run.
- * @param {boolean} verbosePasses Whether to show results for passes.
- * @param {goog.dom.DomHelper=} opt_domHelper Optional dom helper.
- * @constructor
- * @extends {goog.ui.Component}
- */
-goog.testing.MultiTestRunner.TestFrame = function(
- basePath, timeoutMs, verbosePasses, opt_domHelper) {
- goog.ui.Component.call(this, opt_domHelper);
-
- /**
- * Base path where tests should be resolved from.
- * @type {string}
- * @private
- */
- this.basePath_ = basePath;
-
- /**
- * The timeout for the test.
- * @type {number}
- * @private
- */
- this.timeoutMs_ = timeoutMs;
-
- /**
- * Whether to show a summary for passing tests.
- * @type {boolean}
- * @private
- */
- this.verbosePasses_ = verbosePasses;
-
- /**
- * An event handler for handling events.
- * @type {goog.events.EventHandler}
- * @private
- */
- this.eh_ = new goog.events.EventHandler(this);
-
-};
-goog.inherits(goog.testing.MultiTestRunner.TestFrame, goog.ui.Component);
-
-
-/**
- * Reference to the iframe.
- * @type {HTMLIFrameElement}
- * @private
- */
-goog.testing.MultiTestRunner.TestFrame.prototype.iframeEl_ = null;
-
-
-/**
- * Whether the iframe for the current test has loaded.
- * @type {boolean}
- * @private
- */
-goog.testing.MultiTestRunner.TestFrame.prototype.iframeLoaded_ = false;
-
-
-/**
- * The test file being run.
- * @type {string}
- * @private
- */
-goog.testing.MultiTestRunner.TestFrame.prototype.testFile_ = '';
-
-
-/**
- * The report returned from the test.
- * @type {string}
- * @private
- */
-goog.testing.MultiTestRunner.TestFrame.prototype.report_ = '';
-
-
-/**
- * The total time loading and running the test in milliseconds.
- * @type {number}
- * @private
- */
-goog.testing.MultiTestRunner.TestFrame.prototype.totalTime_ = 0;
-
-
-/**
- * The actual runtime of the test in milliseconds.
- * @type {number}
- * @private
- */
-goog.testing.MultiTestRunner.TestFrame.prototype.runTime_ = 0;
-
-
-/**
- * The number of files loaded by the test.
- * @type {number}
- * @private
- */
-goog.testing.MultiTestRunner.TestFrame.prototype.numFilesLoaded_ = 0;
-
-
-/**
- * Whether the test was successful, null if no result has been returned yet.
- * @type {?boolean}
- * @private
- */
-goog.testing.MultiTestRunner.TestFrame.prototype.isSuccess_ = null;
-
-
-/**
- * Timestamp for the when the test was started.
- * @type {number}
- * @private
- */
-goog.testing.MultiTestRunner.TestFrame.prototype.startTime_ = 0;
-
-
-/**
- * Timestamp for the last state, used to determine timeouts.
- * @type {number}
- * @private
- */
-goog.testing.MultiTestRunner.TestFrame.prototype.lastStateTime_ = 0;
-
-
-/**
- * The state of the active test.
- * @type {number}
- * @private
- */
-goog.testing.MultiTestRunner.TestFrame.prototype.currentState_ = 0;
-
-
-/** @override */
-goog.testing.MultiTestRunner.TestFrame.prototype.disposeInternal = function() {
- goog.testing.MultiTestRunner.TestFrame.superClass_.disposeInternal.call(this);
- this.dom_.removeNode(this.iframeEl_);
- this.eh_.dispose();
- this.iframeEl_ = null;
-};
-
-
-/**
- * Runs a test file in this test frame.
- * @param {string} testFile The test to run.
- */
-goog.testing.MultiTestRunner.TestFrame.prototype.runTest = function(testFile) {
- this.lastStateTime_ = this.startTime_ = goog.now();
-
- if (!this.iframeEl_) {
- this.createIframe_();
- }
-
- this.iframeLoaded_ = false;
- this.currentState_ = 0;
- this.isSuccess_ = null;
- this.report_ = '';
- this.testFile_ = testFile;
-
- try {
- this.iframeEl_.src = this.basePath_ + testFile;
- } catch (e) {
- // Failures will trigger a JS exception on the local file system.
- this.report_ = this.testFile_ + ' failed to load : ' + e.message;
- this.isSuccess_ = false;
- this.finish_();
- return;
- }
-
- this.checkForCompletion_();
-};
-
-
-/**
- * @return {string} The test file the TestFrame is running.
- */
-goog.testing.MultiTestRunner.TestFrame.prototype.getTestFile = function() {
- return this.testFile_;
-};
-
-
-/**
- * @return {Object} Stats about the test run.
- */
-goog.testing.MultiTestRunner.TestFrame.prototype.getStats = function() {
- return {
- 'testFile': this.testFile_,
- 'success': this.isSuccess_,
- 'runTime': this.runTime_,
- 'totalTime': this.totalTime_,
- 'numFilesLoaded': this.numFilesLoaded_
- };
-};
-
-
-/**
- * @return {string} The report for the test run.
- */
-goog.testing.MultiTestRunner.TestFrame.prototype.getReport = function() {
- return this.report_;
-};
-
-
-/**
- * @return {?boolean} Whether the test frame had a success.
- */
-goog.testing.MultiTestRunner.TestFrame.prototype.isSuccess = function() {
- return this.isSuccess_;
-};
-
-
-/**
- * Handles the TestFrame finishing a single test.
- * @private
- */
-goog.testing.MultiTestRunner.TestFrame.prototype.finish_ = function() {
- this.totalTime_ = goog.now() - this.startTime_;
- // TODO(user): Fire an event instead?
- if (this.getParent() && this.getParent().processResult) {
- this.getParent().processResult(this);
- }
-};
-
-
-/**
- * Creates an iframe to run the tests in. For overriding in unit tests.
- * @private
- */
-goog.testing.MultiTestRunner.TestFrame.prototype.createIframe_ = function() {
- this.iframeEl_ =
- (/** @type {HTMLIFrameElement} */ this.dom_.createDom('iframe'));
- this.getElement().appendChild(this.iframeEl_);
- this.eh_.listen(this.iframeEl_, 'load', this.onIframeLoaded_);
-};
-
-
-/**
- * Handles the iframe loading.
- * @param {goog.events.BrowserEvent} e The load event.
- * @private
- */
-goog.testing.MultiTestRunner.TestFrame.prototype.onIframeLoaded_ = function(e) {
- this.iframeLoaded_ = true;
-};
-
-
-/**
- * Checks the active test for completion, keeping track of the tests' various
- * execution stages.
- * @private
- */
-goog.testing.MultiTestRunner.TestFrame.prototype.checkForCompletion_ =
- function() {
- var js = goog.dom.getFrameContentWindow(this.iframeEl_);
- switch (this.currentState_) {
- case 0:
- if (this.iframeLoaded_ && js['G_testRunner']) {
- this.lastStateTime_ = goog.now();
- this.currentState_++;
- }
- break;
- case 1:
- if (js['G_testRunner']['isInitialized']()) {
- this.lastStateTime_ = goog.now();
- this.currentState_++;
- }
- break;
- case 2:
- if (js['G_testRunner']['isFinished']()) {
- var tr = js['G_testRunner'];
- this.isSuccess_ = tr['isSuccess']();
- this.report_ = tr['getReport'](this.verbosePasses_);
- this.runTime_ = tr['getRunTime']();
- this.numFilesLoaded_ = tr['getNumFilesLoaded']();
- this.finish_();
- return;
- }
- }
-
- // Check to see if the test has timed out.
- if (goog.now() - this.lastStateTime_ > this.timeoutMs_) {
- this.report_ = this.testFile_ + ' timed out ' +
- goog.testing.MultiTestRunner.STATES[this.currentState_];
- this.isSuccess_ = false;
- this.finish_();
- return;
- }
-
- // Check again in 100ms.
- goog.Timer.callOnce(this.checkForCompletion_, 100, this);
-};
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/objectpropertystring.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/objectpropertystring.js.svn-base
deleted file mode 100644
index b8ee65a..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/objectpropertystring.js.svn-base
+++ /dev/null
@@ -1,67 +0,0 @@
-// Copyright 2009 The Closure Library Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS-IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/**
- * @fileoverview Helper for passing property names as string literals in
- * compiled test code.
- *
- */
-
-goog.provide('goog.testing.ObjectPropertyString');
-
-
-
-/**
- * Object to pass a property name as a string literal and its containing object
- * when the JSCompiler is rewriting these names. This should only be used in
- * test code.
- *
- * @param {Object} object The containing object.
- * @param {Object|string} propertyString Property name as a string literal.
- * @constructor
- */
-goog.testing.ObjectPropertyString = function(object, propertyString) {
- this.object_ = object;
- this.propertyString_ = /** @type {string} */ (propertyString);
-};
-
-
-/**
- * @type {Object}
- * @private
- */
-goog.testing.ObjectPropertyString.prototype.object_;
-
-
-/**
- * @type {string}
- * @private
- */
-goog.testing.ObjectPropertyString.prototype.propertyString_;
-
-
-/**
- * @return {Object} The object.
- */
-goog.testing.ObjectPropertyString.prototype.getObject = function() {
- return this.object_;
-};
-
-
-/**
- * @return {string} The property string.
- */
-goog.testing.ObjectPropertyString.prototype.getPropertyString = function() {
- return this.propertyString_;
-};
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/performancetable.css.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/performancetable.css.svn-base
deleted file mode 100644
index 28056d0..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/performancetable.css.svn-base
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright 2009 The Closure Library Authors. All Rights Reserved.
- *
- * Use of this source code is governed by the Apache License, Version 2.0.
- * See the COPYING file for details.
- */
-
-/* Author: attila@google.com (Attila Bodis) */
-/* Author: nicksantos@google.com (Nick Santos) */
-
-table.test-results {
- font: 12px "Courier New", Courier, monospace;
-}
-
-table.test-results thead th {
- padding: 2px;
- color: #fff;
- background-color: #369;
- text-align: center;
-}
-
-table.test-results tbody td {
- padding: 2px;
- color: #333;
- background-color: #ffc;
- text-align: right;
-}
-
-table.test-results tbody td.test-description {
- text-align: left;
-}
-
-table.test-results tbody td.test-average {
- color: #000;
- font-weight: bold;
-}
-
-table.test-results tbody tr.test-suspicious td.test-standard-deviation {
- color: #800;
-}
-
-table.test-results tbody td.test-error {
- color: #800;
- font-weight: bold;
- text-align: center;
-}
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/performancetable.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/performancetable.js.svn-base
deleted file mode 100644
index 7894837..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/performancetable.js.svn-base
+++ /dev/null
@@ -1,164 +0,0 @@
-// Copyright 2009 The Closure Library Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS-IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/**
- * @fileoverview A table for showing the results of performance testing.
- *
- * {@see goog.testing.benchmark} for an easy way to use this functionality.
- *
- * @author attila@google.com (Attila Bodis)
- * @author nicksantos@google.com (Nick Santos)
- */
-
-goog.provide('goog.testing.PerformanceTable');
-
-goog.require('goog.dom');
-goog.require('goog.testing.PerformanceTimer');
-
-
-
-/**
- * A UI widget that runs performance tests and displays the results.
- * @param {Element} root The element where the table should be attached.
- * @param {goog.testing.PerformanceTimer=} opt_timer A timer to use for
- * executing functions and profiling them.
- * @param {number=} opt_precision Number of digits of precision to include in
- * results. Defaults to 0.
- * @constructor
- */
-goog.testing.PerformanceTable = function(root, opt_timer, opt_precision) {
- /**
- * Where the table should be attached.
- * @type {Element}
- * @private
- */
- this.root_ = root;
-
- /**
- * Number of digits of precision to include in results.
- * Defaults to 0.
- * @type {number}
- * @private
- */
- this.precision_ = opt_precision || 0;
-
- var timer = opt_timer;
- if (!timer) {
- timer = new goog.testing.PerformanceTimer();
- timer.setNumSamples(5);
- timer.setDiscardOutliers(true);
- }
-
- /**
- * A timer for running the tests.
- * @type {goog.testing.PerformanceTimer}
- * @private
- */
- this.timer_ = timer;
-
- this.initRoot_();
-};
-
-
-/**
- * @return {goog.testing.PerformanceTimer} The timer being used.
- */
-goog.testing.PerformanceTable.prototype.getTimer = function() {
- return this.timer_;
-};
-
-
-/**
- * Render the initial table.
- * @private
- */
-goog.testing.PerformanceTable.prototype.initRoot_ = function() {
- this.root_.innerHTML =
- '<table class="test-results" cellspacing="1">' +
- ' <thead>' +
- ' <tr>' +
- ' <th rowspan="2">Test Description</th>' +
- ' <th rowspan="2">Runs</th>' +
- ' <th colspan="4">Results (ms)</th>' +
- ' </tr>' +
- ' <tr>' +
- ' <th>Average</th>' +
- ' <th>Std Dev</th>' +
- ' <th>Minimum</th>' +
- ' <th>Maximum</th>' +
- ' </tr>' +
- ' </thead>' +
- ' <tbody>' +
- ' </tbody>' +
- '</table>';
-};
-
-
-/**
- * @return {Element} The body of the table.
- * @private
- */
-goog.testing.PerformanceTable.prototype.getTableBody_ = function() {
- return this.root_.getElementsByTagName(goog.dom.TagName.TBODY)[0];
-};
-
-
-/**
- * Round to the specified precision.
- * @param {number} num The number to round.
- * @return {string} The rounded number, as a string.
- * @private
- */
-goog.testing.PerformanceTable.prototype.round_ = function(num) {
- var factor = Math.pow(10, this.precision_);
- return String(Math.round(num * factor) / factor);
-};
-
-
-/**
- * Run the given function with the performance timer, and show the results.
- * @param {Function} fn The function to run.
- * @param {string=} opt_desc A description to associate with this run.
- */
-goog.testing.PerformanceTable.prototype.run = function(fn, opt_desc) {
- var results = this.timer_.run(fn);
- var average = results['average'];
- var standardDeviation = results['standardDeviation'];
- var isSuspicious = average < 0 || standardDeviation > average * .5;
- var resultsRow = goog.dom.createDom('tr', null,
- goog.dom.createDom('td', 'test-description',
- opt_desc || 'No description'),
- goog.dom.createDom('td', 'test-count', String(results['count'])),
- goog.dom.createDom('td', 'test-average', this.round_(average)),
- goog.dom.createDom('td', 'test-standard-deviation',
- this.round_(standardDeviation)),
- goog.dom.createDom('td', 'test-minimum', String(results['minimum'])),
- goog.dom.createDom('td', 'test-maximum', String(results['maximum'])));
- if (isSuspicious) {
- resultsRow.className = 'test-suspicious';
- }
- this.getTableBody_().appendChild(resultsRow);
-};
-
-
-/**
- * Report an error in the table.
- * @param {*} reason The reason for the error.
- */
-goog.testing.PerformanceTable.prototype.reportError = function(reason) {
- this.getTableBody_().appendChild(
- goog.dom.createDom('tr', null,
- goog.dom.createDom('td', {'class': 'test-error', 'colSpan': 5},
- String(reason))));
-};
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/performancetimer.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/performancetimer.js.svn-base
deleted file mode 100644
index 599bf4a..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/performancetimer.js.svn-base
+++ /dev/null
@@ -1,166 +0,0 @@
-// Copyright 2008 The Closure Library Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS-IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/**
- * @fileoverview Performance timer.
- *
- * {@see goog.testing.benchmark} for an easy way to use this functionality.
- *
- * @author attila@google.com (Attila Bodis)
- */
-
-goog.provide('goog.testing.PerformanceTimer');
-
-goog.require('goog.array');
-goog.require('goog.math');
-
-
-
-/**
- * Creates a performance timer that runs test functions a number of times to
- * generate timing samples, and provides performance statistics (minimum,
- * maximum, average, and standard deviation).
- * @param {number=} opt_numSamples Number of times to run the test function;
- * defaults to 10.
- * @param {number=} opt_timeoutInterval Number of milliseconds after which the
- * test is to be aborted; defaults to 5 seconds (5,000ms).
- * @constructor
- */
-goog.testing.PerformanceTimer = function(opt_numSamples, opt_timeoutInterval) {
- /**
- * Number of times the test function is to be run; defaults to 10.
- * @type {number}
- * @private
- */
- this.numSamples_ = opt_numSamples || 10;
-
- /**
- * Number of milliseconds after which the test is to be aborted; defaults to
- * 5,000ms.
- * @type {number}
- * @private
- */
- this.timeoutInterval_ = opt_timeoutInterval || 5000;
-
- /**
- * Whether to discard outliers (i.e. the smallest and the largest values)
- * from the sample set before computing statistics. Defaults to false.
- * @type {boolean}
- * @private
- */
- this.discardOutliers_ = false;
-};
-
-
-/**
- * @return {number} The number of times the test function will be run.
- */
-goog.testing.PerformanceTimer.prototype.getNumSamples = function() {
- return this.numSamples_;
-};
-
-
-/**
- * Sets the number of times the test function will be run.
- * @param {number} numSamples Number of times to run the test function.
- */
-goog.testing.PerformanceTimer.prototype.setNumSamples = function(numSamples) {
- this.numSamples_ = numSamples;
-};
-
-
-/**
- * @return {number} The number of milliseconds after which the test times out.
- */
-goog.testing.PerformanceTimer.prototype.getTimeoutInterval = function() {
- return this.timeoutInterval_;
-};
-
-
-/**
- * Sets the number of milliseconds after which the test times out.
- * @param {number} timeoutInterval Timeout interval in ms.
- */
-goog.testing.PerformanceTimer.prototype.setTimeoutInterval = function(
- timeoutInterval) {
- this.timeoutInterval_ = timeoutInterval;
-};
-
-
-/**
- * Sets whether to ignore the smallest and the largest values when computing
- * stats.
- * @param {boolean} discard Whether to discard outlier values.
- */
-goog.testing.PerformanceTimer.prototype.setDiscardOutliers = function(discard) {
- this.discardOutliers_ = discard;
-};
-
-
-/**
- * @return {boolean} Whether outlier values are discarded prior to computing
- * stats.
- */
-goog.testing.PerformanceTimer.prototype.isDiscardOutliers = function() {
- return this.discardOutliers_;
-};
-
-
-/**
- * Executes the test function the required number of times (or until the
- * test run exceeds the timeout interval, whichever comes first). Returns
- * an object containing the following:
- * <pre>
- * {
- * 'average': average execution time (ms)
- * 'count': number of executions (may be fewer than expected due to timeout)
- * 'maximum': longest execution time (ms)
- * 'minimum': shortest execution time (ms)
- * 'standardDeviation': sample standard deviation (ms)
- * 'total': total execution time (ms)
- * }
- * </pre>
- *
- * @param {Function} testFn Test function whose performance is to
- * be measured.
- * @return {Object} Object containing performance stats.
- */
-goog.testing.PerformanceTimer.prototype.run = function(testFn) {
- var samples = [];
- var testStart = goog.now();
- var totalRunTime = 0;
-
- for (var i = 0; i < this.numSamples_ && totalRunTime <= this.timeoutInterval_;
- i++) {
- var sampleStart = goog.now();
- testFn();
- var sampleEnd = goog.now();
- samples[i] = sampleEnd - sampleStart;
- totalRunTime = sampleEnd - testStart;
- }
-
- if (this.discardOutliers_ && samples.length > 2) {
- goog.array.remove(samples, Math.min.apply(null, samples));
- goog.array.remove(samples, Math.max.apply(null, samples));
- }
-
- return {
- 'average': goog.math.average.apply(null, samples),
- 'count': i,
- 'maximum': Math.max.apply(null, samples),
- 'minimum': Math.min.apply(null, samples),
- 'standardDeviation': goog.math.standardDeviation.apply(null, samples),
- 'total': goog.math.sum.apply(null, samples)
- };
-};
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/performancetimer_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/performancetimer_test.html.svn-base
deleted file mode 100644
index 58e863d..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/performancetimer_test.html.svn-base
+++ /dev/null
@@ -1,102 +0,0 @@
-<!DOCTYPE html>
-<html>
-<!--
-Copyright 2008 The Closure Library Authors. All Rights Reserved.
-
-Use of this source code is governed by the Apache License, Version 2.0.
-See the COPYING file for details.
--->
-<!--
-Author: attila@google.com (Attila Bodis)
--->
-<head>
-<meta http-equiv="X-UA-Compatible" content="IE=edge">
- <title>Closure Unit Tests - goog.testing.PerformanceTimer</title>
- <script src="../base.js"></script>
- <script>
- goog.require('goog.dom');
- goog.require('goog.testing.MockClock');
- goog.require('goog.testing.PerformanceTimer');
- goog.require('goog.testing.jsunit');
- </script>
-</head>
-<body>
- <div id="sandbox"></div>
- <script>
- var mockClock;
- var sandbox = document.getElementById('sandbox');
- var timer;
-
- // Fast test function, pretty much guaranteed to run in under 5,000ms.
- function fastTestFunction() {
- for (var i = 0; i < 10; i++) {
- var div = document.createElement('div');
- div.innerHTML = 'Div no. ' + i;
- sandbox.appendChild(div);
- }
- }
-
- function setUp() {
- mockClock = new goog.testing.MockClock(false);
- timer = new goog.testing.PerformanceTimer();
- }
-
- function tearDown() {
- mockClock.dispose();
- timer = null;
- goog.dom.removeChildren(sandbox);
- }
-
- function testConstructor() {
- assertTrue('Timer must be an instance of goog.testing.PerformanceTimer',
- timer instanceof goog.testing.PerformanceTimer);
- assertEquals('Timer must collect the default number of samples', 10,
- timer.getNumSamples());
- assertEquals('Timer must have the default timeout interval', 5000,
- timer.getTimeoutInterval());
- }
-
- function testRun() {
- // Fast test function should complete successfully in under 5 seconds...
- var results = timer.run(fastTestFunction);
-
- assertNotNull('Results must be available',
- results);
- assertTrue('Average must be a nonnegative number',
- results['average'] >= 0);
- assertEquals('Count must be as expected', 10,
- results['count']);
- assertTrue('Maximum must be a nonnegative number',
- results['maximum'] >= 0);
- assertTrue('Mimimum must be a nonnegative number',
- results['minimum'] >= 0);
- assertTrue('Standard deviation must be a nonnegative number',
- results['standardDeviation'] >= 0);
- assertTrue('Total must be a nonnegative number',
- results['total'] >= 0);
- assertTrue('Average must be between minimum and maximum',
- results['minimum'] <= results['average'] &&
- results['average'] <= results['maximum']);
- }
-
- function testTimeout() {
- mockClock.install();
- var count = 0;
-
- var testFunction = function() {
- mockClock.tick(100);
- ++count;
- };
-
- timer.setNumSamples(200);
- timer.setTimeoutInterval(2500);
- var results = timer.run(testFunction);
-
- assertNotNull('Results must be available', results);
- assertEquals('Count is wrong', count, results['count']);
- assertTrue('Count must less than expected',
- results['count'] < timer.getNumSamples());
- }
- </script>
-</body>
-</html>
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/propertyreplacer.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/propertyreplacer.js.svn-base
deleted file mode 100644
index 305e2b0..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/propertyreplacer.js.svn-base
+++ /dev/null
@@ -1,243 +0,0 @@
-// Copyright 2008 The Closure Library Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS-IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/**
- * @fileoverview Helper class for creating stubs for testing.
- *
- */
-
-goog.provide('goog.testing.PropertyReplacer');
-
-goog.require('goog.userAgent');
-
-
-
-/**
- * Helper class for stubbing out variables and object properties for unit tests.
- * This class can change the value of some variables before running the test
- * cases, and to reset them in the tearDown phase.
- * See googletest.StubOutForTesting as an analogy in Python:
- * http://protobuf.googlecode.com/svn/trunk/python/stubout.py
- *
- * Example usage:
- * <pre>var stubs = new goog.testing.PropertyReplacer();
- *
- * function setUp() {
- * // Mock functions used in all test cases.
- * stubs.set(Math, 'random', function() {
- * return 4; // Chosen by fair dice roll. Guaranteed to be random.
- * });
- * }
- *
- * function tearDown() {
- * stubs.reset();
- * }
- *
- * function testThreeDice() {
- * // Mock a constant used only in this test case.
- * stubs.set(goog.global, 'DICE_COUNT', 3);
- * assertEquals(12, rollAllDice());
- * }</pre>
- *
- * Constraints on altered objects:
- * <ul>
- * <li>DOM subclasses aren't supported.
- * <li>The value of the objects' constructor property must either be equal to
- * the real constructor or kept untouched.
- * </ul>
- *
- * @constructor
- */
-goog.testing.PropertyReplacer = function() {
- /**
- * Stores the values changed by the set() method in chronological order.
- * Its items are objects with 3 fields: 'object', 'key', 'value'. The
- * original value for the given key in the given object is stored under the
- * 'value' key.
- * @type {Array.<Object>}
- * @private
- */
- this.original_ = [];
-};
-
-
-/**
- * Indicates that a key didn't exist before having been set by the set() method.
- * @type {Object}
- * @private
- */
-goog.testing.PropertyReplacer.NO_SUCH_KEY_ = {};
-
-
-/**
- * Tells if the given key exists in the object. Ignores inherited fields.
- * @param {Object|Function} obj The JavaScript or native object or function
- * whose key is to be checked.
- * @param {string} key The key to check.
- * @return {boolean} Whether the object has the key as own key.
- * @private
- */
-goog.testing.PropertyReplacer.hasKey_ = function(obj, key) {
- if (!(key in obj)) {
- return false;
- }
- // hasOwnProperty is only reliable with JavaScript objects. It returns false
- // for built-in DOM attributes.
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
- return true;
- }
- // In all browsers except Opera obj.constructor never equals to Object if
- // obj is an instance of a native class. In Opera we have to fall back on
- // examining obj.toString().
- if (obj.constructor == Object &&
- (!goog.userAgent.OPERA ||
- Object.prototype.toString.call(obj) == '[object Object]')) {
- return false;
- }
- try {
- // Firefox hack to consider "className" part of the HTML elements or
- // "body" part of document. Although they are defined in the prototype of
- // HTMLElement or Document, accessing them this way throws an exception.
- // <pre>
- // var dummy = document.body.constructor.prototype.className
- // [Exception... "Cannot modify properties of a WrappedNative"]
- // </pre>
- var dummy = obj.constructor.prototype[key];
- } catch (e) {
- return true;
- }
- return !(key in obj.constructor.prototype);
-};
-
-
-/**
- * Deletes a key from an object. Sets it to undefined or empty string if the
- * delete failed.
- * @param {Object|Function} obj The object or function to delete a key from.
- * @param {string} key The key to delete.
- * @private
- */
-goog.testing.PropertyReplacer.deleteKey_ = function(obj, key) {
- try {
- delete obj[key];
- // Delete has no effect for built-in properties of DOM nodes in FF.
- if (!goog.testing.PropertyReplacer.hasKey_(obj, key)) {
- return;
- }
- } catch (e) {
- // IE throws TypeError when trying to delete properties of native objects
- // (e.g. DOM nodes or window), even if they have been added by JavaScript.
- }
-
- obj[key] = undefined;
- if (obj[key] == 'undefined') {
- // Some properties such as className in IE are always evaluated as string
- // so undefined will become 'undefined'.
- obj[key] = '';
- }
-};
-
-
-/**
- * Adds or changes a value in an object while saving its original state.
- * @param {Object|Function} obj The JavaScript or native object or function to
- * alter. See the constraints in the class description.
- * @param {string} key The key to change the value for.
- * @param {*} value The new value to set.
- */
-goog.testing.PropertyReplacer.prototype.set = function(obj, key, value) {
- var origValue = goog.testing.PropertyReplacer.hasKey_(obj, key) ? obj[key] :
- goog.testing.PropertyReplacer.NO_SUCH_KEY_;
- this.original_.push({object: obj, key: key, value: origValue});
- obj[key] = value;
-};
-
-
-/**
- * Changes an existing value in an object to another one of the same type while
- * saving its original state. The advantage of {@code replace} over {@link #set}
- * is that {@code replace} protects against typos and erroneously passing tests
- * after some members have been renamed during a refactoring.
- * @param {Object|Function} obj The JavaScript or native object or function to
- * alter. See the constraints in the class description.
- * @param {string} key The key to change the value for. It has to be present
- * either in {@code obj} or in its prototype chain.
- * @param {*} value The new value to set. It has to have the same type as the
- * original value. The types are compared with {@link goog.typeOf}.
- * @throws {Error} In case of missing key or type mismatch.
- */
-goog.testing.PropertyReplacer.prototype.replace = function(obj, key, value) {
- if (!(key in obj)) {
- throw Error('Cannot replace missing property "' + key + '" in ' + obj);
- }
- if (goog.typeOf(obj[key]) != goog.typeOf(value)) {
- throw Error('Cannot replace property "' + key + '" in ' + obj +
- ' with a value of different type');
- }
- this.set(obj, key, value);
-};
-
-
-/**
- * Builds an object structure for the provided namespace path. Doesn't
- * overwrite those prefixes of the path that are already objects or functions.
- * @param {string} path The path to create or alter, e.g. 'goog.ui.Menu'.
- * @param {*} value The value to set.
- */
-goog.testing.PropertyReplacer.prototype.setPath = function(path, value) {
- var parts = path.split('.');
- var obj = goog.global;
- for (var i = 0; i < parts.length - 1; i++) {
- var part = parts[i];
- if (part == 'prototype' && !obj[part]) {
- throw Error('Cannot set the prototype of ' + parts.slice(0, i).join('.'));
- }
- if (!goog.isObject(obj[part]) && !goog.isFunction(obj[part])) {
- this.set(obj, part, {});
- }
- obj = obj[part];
- }
- this.set(obj, parts[parts.length - 1], value);
-};
-
-
-/**
- * Deletes the key from the object while saving its original value.
- * @param {Object|Function} obj The JavaScript or native object or function to
- * alter. See the constraints in the class description.
- * @param {string} key The key to delete.
- */
-goog.testing.PropertyReplacer.prototype.remove = function(obj, key) {
- if (goog.testing.PropertyReplacer.hasKey_(obj, key)) {
- this.original_.push({object: obj, key: key, value: obj[key]});
- goog.testing.PropertyReplacer.deleteKey_(obj, key);
- }
-};
-
-
-/**
- * Resets all changes made by goog.testing.PropertyReplacer.prototype.set.
- */
-goog.testing.PropertyReplacer.prototype.reset = function() {
- for (var i = this.original_.length - 1; i >= 0; i--) {
- var original = this.original_[i];
- if (original.value == goog.testing.PropertyReplacer.NO_SUCH_KEY_) {
- goog.testing.PropertyReplacer.deleteKey_(original.object, original.key);
- } else {
- original.object[original.key] = original.value;
- }
- delete this.original_[i];
- }
- this.original_.length = 0;
-};
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/propertyreplacer_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/propertyreplacer_test.html.svn-base
deleted file mode 100644
index 6ad2eff..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/propertyreplacer_test.html.svn-base
+++ /dev/null
@@ -1,368 +0,0 @@
-<!DOCTYPE html>
-<html>
-<!--
-Copyright 2008 The Closure Library Authors. All Rights Reserved.
-
-Use of this source code is governed by the Apache License, Version 2.0.
-See the COPYING file for details.
--->
-<head>
-<meta http-equiv="X-UA-Compatible" content="IE=edge">
-<title>Closure Unit Tests - goog.testing.PropertyReplacer</title>
-<script src="../base.js"></script>
-<script>
- goog.require('goog.testing.PropertyReplacer');
- goog.require('goog.testing.asserts');
- goog.require('goog.testing.jsunit');
-</script>
-</head>
-<body>
-<script>
-
-// Test PropertyReplacer with JavaScript objects.
-function testSetJsProperties() {
- var stubs = new goog.testing.PropertyReplacer();
- var x = {a: 1, b: undefined};
-
- // Setting simple values.
- stubs.set(x, 'num', 1);
- assertEquals('x.num = 1', 1, x.num);
- stubs.set(x, 'undef', undefined);
- assertTrue('x.undef = undefined', 'undef' in x && x.undef === undefined);
- stubs.set(x, 'null', null);
- assertTrue('x["null"] = null', x['null'] === null);
-
- // Setting a simple value that existed originally.
- stubs.set(x, 'b', null);
- assertTrue('x.b = null', x.b === null);
-
- // Setting a complex value.
- stubs.set(x, 'obj', {});
- assertEquals('x.obj = {}', 'object', typeof x.obj);
- stubs.set(x.obj, 'num', 2);
- assertEquals('x.obj.num = 2', 2, x.obj.num);
-
- // Overwriting a leaf.
- stubs.set(x.obj, 'num', 3);
- assertEquals('x.obj.num = 3', 3, x.obj.num);
-
- // Overwriting a non-leaf.
- stubs.set(x, 'obj', {});
- assertFalse('x.obj = {} again', 'num' in x.obj);
-
- // Setting a function.
- stubs.set(x, 'func', function(n) { return n + 1; });
- assertEquals('x.func = lambda n: n+1', 11, x.func(10));
-
- // Setting a constructor and a prototype method.
- stubs.set(x, 'Class', function(num) { this.num = num; });
- stubs.set(x.Class.prototype, 'triple', function() { return this.num * 3; });
- assertEquals('prototype method', 12, (new x.Class(4)).triple());
-
- // Cleaning up with UnsetAll() twice. The second run should have no effect.
- for (var i = 0; i < 2; i++) {
- stubs.reset();
- assertEquals('x.a preserved', 1, x.a);
- assertTrue('x.b reset', 'b' in x && x.b === undefined);
- assertFalse('x.num removed', 'num' in x);
- assertFalse('x.undef removed', 'undef' in x);
- assertFalse('x["null"] removed', 'null' in x);
- assertFalse('x.obj removed', 'obj' in x);
- assertFalse('x.func removed', 'func' in x);
- assertFalse('x.Class removed', 'Class' in x);
- }
-}
-
-// Test removing JavaScript object properties.
-function testRemoveJsProperties() {
- var stubs = new goog.testing.PropertyReplacer();
- var orig = {'a': 1, 'b': undefined};
- var x = {'a': 1, 'b': undefined};
-
- stubs.remove(x, 'a');
- assertFalse('x.a removed', 'a' in x);
- assertTrue('x.b not removed', 'b' in x);
- stubs.reset();
- assertObjectEquals('x.a reset', x, orig);
-
- stubs.remove(x, 'b');
- assertFalse('x.b removed', 'b' in x);
- stubs.reset();
- assertObjectEquals('x.b reset', x, orig);
-
- stubs.set(x, 'c', 2);
- stubs.remove(x, 'c');
- assertObjectEquals('x.c added then removed', x, orig);
- stubs.reset();
- assertObjectEquals('x.c reset', x, orig);
-
- stubs.remove(x, 'b');
- stubs.set(x, 'b', undefined);
- assertObjectEquals('x.b removed then added', x, orig);
- stubs.reset();
- assertObjectEquals('x.b reset', x, orig);
-
- stubs.remove(x, 'd');
- assertObjectEquals('removing non-existing key', x, orig);
- stubs.reset();
- assertObjectEquals('reset removing non-existing key', x, orig);
-}
-
-// Test PropertyReplacer with prototype chain.
-function testPrototype() {
- var stubs = new goog.testing.PropertyReplacer();
-
- // Simple inheritance.
- var a = {a: 0};
- function B() {};
- B.prototype = a;
- var b = new B();
-
- stubs.set(a, 0, 1);
- stubs.set(b, 0, 2);
- stubs.reset();
- assertEquals('a.a == 0', 0, a['a']);
- assertEquals('b.a == 0', 0, b['a']);
-
- // Inheritance with goog.inherits.
- var c = {a: 0};
- function C() {};
- C.prototype = c;
- function D() {};
- goog.inherits(D, C);
- var d = new D();
-
- var stubs = new goog.testing.PropertyReplacer();
- stubs.set(c, 'a', 1);
- stubs.set(d, 'a', 2);
- stubs.reset();
- assertEquals('c.a == 0', 0, c['a']);
- assertEquals('d.a == 0', 0, d['a']);
-
- // Setting prototype fields.
- stubs.set(B.prototype, 'c', 'z');
- assertEquals('b.c=="z"', 'z', b.c);
- stubs.reset();
- assertFalse('b.c deleted', 'c' in b);
-
- // Setting Object.prototype's fields.
- stubs.set(Object.prototype, 'one', 1);
- assertEquals('b.one==1', 1, b.one);
- stubs.reset();
- assertFalse('b.one deleted', 'one' in b);
-
- stubs.set(Object.prototype, 'two', 2);
- stubs.remove(b, 'two');
- assertEquals('b.two==2', 2, b.two);
- stubs.remove(Object.prototype, 'two');
- assertFalse('b.two deleted', 'two' in b);
- stubs.reset();
- assertFalse('Object prototype reset', 'two' in b);
-}
-
-// Test replacing function properties.
-function testFunctionProperties() {
- var stubs = new goog.testing.PropertyReplacer();
- stubs.set(Array, 'x', 1);
- assertEquals('Array.x==1', 1, Array.x);
- stubs.reset();
- assertFalse('Array.x deleted', 'x' in Array);
-
- stubs.set(Math.random, 'x', 1);
- assertEquals('Math.random.x==1', 1, Math.random.x);
- stubs.reset();
- assertFalse('Math.random.x deleted', 'x' in Math.random);
-}
-
-// Test the hasKey_ private method.
-function testHasKey() {
- f = goog.testing.PropertyReplacer.hasKey_;
-
- assertFalse('{}.a', f({}, 'a'));
- assertTrue('{a:0}.a', f({a: 0}, 'a'));
-
- function C() {};
- C.prototype.a = 0;
- assertFalse('C.prototype.a set, is C.a own?', f(C, 'a'));
- assertTrue('C.prototype.a', f(C.prototype, 'a'));
- assertFalse('C.a not set', f(C, 'a'));
- C.a = 0;
- assertTrue('C.a set', f(C, 'a'));
-
- var c = new C();
- assertFalse('C().a, inherited', f(c, 'a'));
- c.a = 0;
- assertTrue('C().a, own', f(c, 'a'));
-
- assertFalse('window, invalid key', f(window, 'no such key'));
- assertTrue('window, global variable', f(window, 'goog'));
- assertTrue('window, build-in key', f(window, 'location'))
-
- assertFalse('document, invalid key', f(document, 'no such key'));
- assertTrue('document.body', f(document, 'body'));
-
- var div = document.createElement('div');
- assertFalse('div, invalid key', f(div, 'no such key'));
- assertTrue('div.className', f(div, 'className'));
- div['a'] = 0;
- assertTrue('div, key added by JS', f(div, 'a'));
-
- assertFalse('Date().getTime', f(new Date(), 'getTime'));
- assertTrue('Date.prototype.getTime', f(Date.prototype, 'getTime'));
-
- assertFalse('Math, invalid key', f(Math, 'no such key'));
- assertTrue('Math.random', f(Math, 'random'));
-
- function Parent() {};
- Parent.prototype.a = 0;
- function Child() {};
- goog.inherits(Child, Parent);
- assertFalse('goog.inherits, parent prototype', f(new Child, 'a'));
- Child.prototype.a = 1;
- assertFalse('goog.inherits, child prototype', f(new Child, 'a'));
-
- function OverwrittenProto() {};
- OverwrittenProto.prototype = {a: 0};
- assertFalse(f(new OverwrittenProto, 'a'));
-}
-
-// Test PropertyReplacer with DOM objects' built in attributes.
-function testDomBuiltInAttributes() {
- var div = document.createElement('div');
- div.id = 'old-id';
-
- var stubs = new goog.testing.PropertyReplacer();
- stubs.set(div, 'id', 'new-id');
- stubs.set(div, 'className', 'test-class');
- assertEquals('div.id == "new-id"', 'new-id', div.id);
- assertEquals('div.className == "test-class"', 'test-class', div.className);
-
- stubs.remove(div, 'className');
- // '' in Firefox, undefined in Chrome.
- assertEvaluatesToFalse('div.className is empty', div.className);
-
- stubs.reset();
- assertEquals('div.id == "old-id"', 'old-id', div.id);
- assertEquals('div.name == ""', '', div.className);
-}
-
-// Test PropertyReplacer with DOM objects' custom attributes.
-function testDomCustomAttributes() {
- var div = document.createElement('div');
- div.attr1 = 'old';
-
- var stubs = new goog.testing.PropertyReplacer();
- stubs.set(div, 'attr1', 'new');
- stubs.set(div, 'attr2', 'new');
- assertEquals('div.attr1 == "new"', 'new', div.attr1);
- assertEquals('div.attr2 == "new"', 'new', div.attr2);
-
- stubs.set(div, 'attr3', 'new');
- stubs.remove(div, 'attr3');
- assertEquals('div.attr3 == undefined', undefined, div.attr3);
-
- stubs.reset();
- assertEquals('div.attr1 == "old"', 'old', div.attr1);
- assertEquals('div.attr2 == undefined', undefined, div.attr2);
-}
-
-// Test PropertyReplacer overriding Math.random.
-function testMathRandom() {
- var stubs = new goog.testing.PropertyReplacer();
- stubs.set(Math, 'random', function() { return -1; });
- assertEquals('mocked Math.random', -1, Math.random());
-
- stubs.reset();
- assertNotEquals('original Math.random', -1, Math.random());
-}
-
-// Tests the replace method of PropertyReplacer.
-function testReplace() {
- var stubs = new goog.testing.PropertyReplacer();
- function C() {
- this.a = 1;
- };
- C.prototype.b = 1;
- C.prototype.toString = function() {
- return 'obj';
- };
- var obj = new C();
-
- stubs.replace(obj, 'a', 2);
- assertEquals('successfully replaced the own property of an object', 2, obj.a);
-
- stubs.replace(obj, 'b', 2);
- assertEquals('successfully replaced the property in the prototype', 2, obj.b);
-
- var error = assertThrows('cannot replace missing key',
- goog.bind(stubs.replace, stubs, obj, 'unknown', 1));
- // Using assertContains instead of assertEquals because Opera 10.0 adds
- // the stack trace to the error message.
- assertEquals('error message for missing key',
- 'Cannot replace missing property "unknown" in obj', error.message);
- assertFalse('object not touched', 'unknown' in obj);
-
- var error = assertThrows('cannot change value type',
- goog.bind(stubs.replace, stubs, obj, 'a', '3'));
- assertContains('error message for type mismatch',
- 'Cannot replace property "a" in obj with a value of different type',
- error.message);
-}
-
-// Tests altering complete namespace paths.
-function testSetPath() {
- goog.global.a = {b: {}};
- var stubs = new goog.testing.PropertyReplacer();
-
- stubs.setPath('a.b.c.d', 1);
- assertObjectEquals('a.b.c.d=1', {b: {c: {d: 1}}}, goog.global.a);
- stubs.setPath('a.b.e', 2);
- assertObjectEquals('a.b.e=2', {b: {c: {d: 1}, e: 2}}, goog.global.a);
- stubs.setPath('a.f', 3);
- assertObjectEquals('a.f=3', {b: {c: {d: 1}, e: 2}, f: 3}, goog.global.a);
- stubs.setPath('a.f.g', 4);
- assertObjectEquals('a.f.g=4', {b: {c: {d: 1}, e: 2}, f: {g: 4}},
- goog.global.a);
- stubs.setPath('a', 5);
- assertEquals('a=5', 5, goog.global.a);
-
- stubs.setPath('x.y.z', 5);
- assertObjectEquals('x.y.z=5', {y: {z: 5}}, goog.global.x);
-
- stubs.reset();
- assertObjectEquals('a.* reset', {b: {}}, goog.global.a);
- // NOTE: it's impossible to delete global variables in Internet Explorer,
- // so ('x' in goog.global) would be true.
- assertUndefined('x.* reset', goog.global.x);
-}
-
-// Tests altering paths with functions in them.
-function testSetPathWithFunction() {
- var f = function() {};
- goog.global.a = {b: f};
- var stubs = new goog.testing.PropertyReplacer();
-
- stubs.setPath('a.b.c', 1);
- assertEquals('a.b.c=1, f kept', f, goog.global.a.b);
- assertEquals('a.b.c=1, c set', 1, goog.global.a.b.c);
-
- stubs.setPath('a.b.prototype.d', 2);
- assertEquals('a.b.prototype.d=2, b kept', f, goog.global.a.b);
- assertEquals('a.b.prototype.d=2, c kept', 1, goog.global.a.b.c);
- assertFalse('a.b.prototype.d=2, a.b.d not set', 'd' in goog.global.a.b);
- assertTrue('a.b.prototype.d=2, proto set', 'd' in goog.global.a.b.prototype);
- assertEquals('a.b.prototype.d=2, d set', 2, new goog.global.a.b().d);
-
- var invalidSetPath = function() {
- stubs.setPath('a.prototype.e', 3);
- };
- assertThrows('setting the prototype of a non-function', invalidSetPath);
-
- stubs.reset();
- assertObjectEquals('a.b.c reset', {b: f}, goog.global.a);
- assertObjectEquals('a.b.prototype reset', {}, goog.global.a.b.prototype);
-}
-
-</script>
-</body>
-</html>
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/pseudorandom.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/pseudorandom.js.svn-base
deleted file mode 100644
index 23ea0ef..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/pseudorandom.js.svn-base
+++ /dev/null
@@ -1,179 +0,0 @@
-// Copyright 2011 The Closure Library Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS-IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/**
- * @fileoverview PseudoRandom provides a mechanism for generating deterministic
- * psuedo random numbers based on a seed. Based on the Park-Miller algorithm.
- * See http://dx.doi.org/10.1145%2F63039.63042 for details.
- *
- */
-
-goog.provide('goog.testing.PseudoRandom');
-
-goog.require('goog.Disposable');
-
-
-
-/**
- * Class for unit testing code that uses Math.random. Generates deterministic
- * random numbers.
- *
- * @param {number=} opt_seed The seed to use.
- * @param {boolean=} opt_install Whether to install the PseudoRandom at
- * construction time.
- * @extends {goog.Disposable}
- * @constructor
- */
-goog.testing.PseudoRandom = function(opt_seed, opt_install) {
- goog.Disposable.call(this);
-
- if (!goog.isDef(opt_seed)) {
- opt_seed = goog.testing.PseudoRandom.seedUniquifier_++ + goog.now();
- }
- this.seed(opt_seed);
-
- if (opt_install) {
- this.install();
- }
-};
-goog.inherits(goog.testing.PseudoRandom, goog.Disposable);
-
-
-/**
- * Helps create a unique seed.
- * @type {number}
- * @private
- */
-goog.testing.PseudoRandom.seedUniquifier_ = 0;
-
-
-/**
- * Constant used as part of the algorithm.
- * @type {number}
- */
-goog.testing.PseudoRandom.A = 48271;
-
-
-/**
- * Constant used as part of the algorithm. 2^31 - 1.
- * @type {number}
- */
-goog.testing.PseudoRandom.M = 2147483647;
-
-
-/**
- * Constant used as part of the algorithm. It is equal to M / A.
- * @type {number}
- */
-goog.testing.PseudoRandom.Q = 44488;
-
-
-/**
- * Constant used as part of the algorithm. It is equal to M % A.
- * @type {number}
- */
-goog.testing.PseudoRandom.R = 3399;
-
-
-/**
- * Constant used as part of the algorithm to get values from range [0, 1).
- * @type {number}
- */
-goog.testing.PseudoRandom.ONE_OVER_M_MINUS_ONE =
- 1.0 / (goog.testing.PseudoRandom.M - 1);
-
-
-/**
- * The seed of the random sequence and also the next returned value (before
- * normalization). Must be between 1 and M - 1 (inclusive).
- * @type {number}
- * @private
- */
-goog.testing.PseudoRandom.prototype.seed_ = 1;
-
-
-/**
- * Whether this PseudoRandom has been installed.
- * @type {boolean}
- * @private
- */
-goog.testing.PseudoRandom.prototype.installed_;
-
-
-/**
- * The original Math.random function.
- * @type {function(): number}
- * @private
- */
-goog.testing.PseudoRandom.prototype.mathRandom_;
-
-
-/**
- * Installs this PseudoRandom as the system number generator.
- */
-goog.testing.PseudoRandom.prototype.install = function() {
- if (!this.installed_) {
- this.mathRandom_ = Math.random;
- Math.random = goog.bind(this.random, this);
- this.installed_ = true;
- }
-};
-
-
-/** @override */
-goog.testing.PseudoRandom.prototype.disposeInternal = function() {
- goog.testing.PseudoRandom.superClass_.disposeInternal.call(this);
- this.uninstall();
-};
-
-
-/**
- * Uninstalls the PseudoRandom.
- */
-goog.testing.PseudoRandom.prototype.uninstall = function() {
- if (this.installed_) {
- Math.random = this.mathRandom_;
- this.installed_ = false;
- }
-};
-
-
-/**
- * Seed the generator.
- *
- * @param {number=} seed The seed to use.
- */
-goog.testing.PseudoRandom.prototype.seed = function(seed) {
- this.seed_ = seed % (goog.testing.PseudoRandom.M - 1);
- if (this.seed_ <= 0) {
- this.seed_ += goog.testing.PseudoRandom.M - 1;
- }
-};
-
-
-/**
- * @return {number} The next number in the sequence.
- */
-goog.testing.PseudoRandom.prototype.random = function() {
- var hi = Math.floor(this.seed_ / goog.testing.PseudoRandom.Q);
- var lo = this.seed_ % goog.testing.PseudoRandom.Q;
- var test = goog.testing.PseudoRandom.A * lo -
- goog.testing.PseudoRandom.R * hi;
- if (test > 0) {
- this.seed_ = test;
- } else {
- this.seed_ = test + goog.testing.PseudoRandom.M;
- }
- return (this.seed_ - 1) * goog.testing.PseudoRandom.ONE_OVER_M_MINUS_ONE;
-};
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/pseudorandom_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/pseudorandom_test.html.svn-base
deleted file mode 100644
index 62d0261..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/pseudorandom_test.html.svn-base
+++ /dev/null
@@ -1,98 +0,0 @@
-<!DOCTYPE html>
-<html>
-<!--
-Copyright 2009 The Closure Library Authors. All Rights Reserved.
-
-Use of this source code is governed by the Apache License, Version 2.0.
-See the COPYING file for details.
--->
-<head>
-<meta http-equiv="X-UA-Compatible" content="IE=edge">
-<title>Closure Unit Tests - goog.testing.PseudoRandom</title>
-<script src="../base.js"></script>
-<script>
- goog.require('goog.testing.PseudoRandom');
- goog.require('goog.testing.jsunit');
-</script>
-</head>
-<body>
-<script>
-
- function runFairnessTest(sides, rolls, chiSquareLimit) {
- // Initialize the count table for dice rolls.
- var counts = [];
- for (var i = 0; i < sides; ++i) {
- counts[i] = 0;
- }
- // Roll the dice many times and count the results.
- for (var i = 0; i < rolls; ++i) {
- ++counts[Math.floor(Math.random() * sides)];
- }
- // If the dice is fair, we expect a uniform distribution.
- var expected = rolls / sides;
- // Pearson's chi-square test for a distribution fit.
- var chiSquare = 0
- for (var i = 0; i < sides; ++i) {
- chiSquare += (counts[i] - expected) * (counts[i] - expected) / expected;
- }
- assert('Chi-square test for a distribution fit failed',
- chiSquare < chiSquareLimit);
- }
-
- function testInstall() {
- var random = new goog.testing.PseudoRandom();
- var originalRandom = Math.random;
-
- assertFalse(!!random.installed_);
-
- random.install();
- assertTrue(random.installed_);
- assertNotEquals(Math.random, originalRandom);
-
- random.uninstall();
- assertFalse(random.installed_);
- assertEquals(originalRandom, Math.random);
- }
-
- function testBounds() {
- var random = new goog.testing.PseudoRandom();
- random.install();
-
- for (var i = 0; i < 100000; ++i) {
- var value = Math.random();
- assert('Random value out of bounds', value >= 0 && value < 1);
- }
-
- random.uninstall();
- }
-
- function testFairness() {
- var random = new goog.testing.PseudoRandom(0, true);
-
- // Chi-square statistics: p-value = 0.05, df = 5, limit = 11.07.
- runFairnessTest(6, 100000, 11.07);
- // Chi-square statistics: p-value = 0.05, df = 100, limit = 124.34.
- runFairnessTest(101, 100000, 124.34);
-
- random.uninstall();
- }
-
- function testReseed() {
- var random = new goog.testing.PseudoRandom(100, true);
-
- var sequence = [];
- for (var i = 0; i < 64000; ++i) {
- sequence.push(Math.random());
- }
-
- random.seed(100);
- for (var i = 0; i < sequence.length; ++i) {
- assertEquals(sequence[i], Math.random());
- }
-
- random.uninstall();
- }
-
-</script>
-</body>
-</html>
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/recordfunction.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/recordfunction.js.svn-base
deleted file mode 100644
index ae10c28..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/recordfunction.js.svn-base
+++ /dev/null
@@ -1,201 +0,0 @@
-// Copyright 2010 The Closure Library Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS-IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/**
- * @fileoverview Helper class for recording the calls of a function.
- *
- * Example:
- * <pre>
- * var stubs = new goog.testing.PropertyReplacer();
- *
- * function tearDown() {
- * stubs.reset();
- * }
- *
- * function testShuffle() {
- * stubs.set(Math, 'random', goog.testing.recordFunction(Math.random));
- * var arr = shuffle([1, 2, 3, 4, 5]);
- * assertSameElements([1, 2, 3, 4, 5], arr);
- * assertEquals(4, Math.random.getCallCount());
- * }
- *
- * function testOpenDialog() {
- * stubs.set(goog.ui, 'Dialog',
- * goog.testing.recordConstructor(goog.ui.Dialog));
- * openConfirmDialog();
- * var lastDialogInstance = goog.ui.Dialog.getLastCall().getThis();
- * assertEquals('confirm', lastDialogInstance.getTitle());
- * }
- * </pre>
- *
- */
-
-goog.provide('goog.testing.FunctionCall');
-goog.provide('goog.testing.recordConstructor');
-goog.provide('goog.testing.recordFunction');
-
-
-/**
- * Wraps the function into another one which calls the inner function and
- * records its calls. The recorded function will have 3 static methods:
- * {@code getCallCount}, {@code getCalls} and {@code getLastCall} but won't
- * inherit the original function's prototype and static fields.
- *
- * @param {!Function=} opt_f The function to wrap and record. Defaults to
- * {@link goog.nullFunction}.
- * @return {!Function} The wrapped function.
- */
-goog.testing.recordFunction = function(opt_f) {
- var f = opt_f || goog.nullFunction;
- var calls = [];
-
- function recordedFunction() {
- try {
- var ret = f.apply(this, arguments);
- calls.push(new goog.testing.FunctionCall(f, this, arguments, ret, null));
- return ret;
- } catch (err) {
- calls.push(new goog.testing.FunctionCall(f, this, arguments, undefined,
- err));
- throw err;
- }
- }
-
- /**
- * @return {number} Total number of calls.
- */
- recordedFunction.getCallCount = function() {
- return calls.length;
- };
-
- /**
- * @return {!Array.<!goog.testing.FunctionCall>} All calls of the recorded
- * function.
- */
- recordedFunction.getCalls = function() {
- return calls;
- };
-
- /**
- * @return {goog.testing.FunctionCall} Last call of the recorded function or
- * null if it hasn't been called.
- */
- recordedFunction.getLastCall = function() {
- return calls[calls.length - 1] || null;
- };
-
- /**
- * Returns and removes the last call of the recorded function.
- * @return {goog.testing.FunctionCall} Last call of the recorded function or
- * null if it hasn't been called.
- */
- recordedFunction.popLastCall = function() {
- return calls.pop() || null;
- };
-
- /**
- * Resets the recorded function and removes all calls.
- */
- recordedFunction.reset = function() {
- calls.length = 0;
- };
-
- return recordedFunction;
-};
-
-
-/**
- * Same as {@link goog.testing.recordFunction} but the recorded function will
- * have the same prototype and static fields as the original one. It can be
- * used with constructors.
- *
- * @param {!Function} ctor The function to wrap and record.
- * @return {!Function} The wrapped function.
- */
-goog.testing.recordConstructor = function(ctor) {
- var recordedConstructor = goog.testing.recordFunction(ctor);
- recordedConstructor.prototype = ctor.prototype;
- goog.mixin(recordedConstructor, ctor);
- return recordedConstructor;
-};
-
-
-
-/**
- * Struct for a single function call.
- * @param {!Function} func The called function.
- * @param {!Object} thisContext {@code this} context of called function.
- * @param {!Arguments} args Arguments of the called function.
- * @param {*} ret Return value of the function or undefined in case of error.
- * @param {*} error The error thrown by the function or null if none.
- * @constructor
- */
-goog.testing.FunctionCall = function(func, thisContext, args, ret, error) {
- this.function_ = func;
- this.thisContext_ = thisContext;
- this.arguments_ = Array.prototype.slice.call(args);
- this.returnValue_ = ret;
- this.error_ = error;
-};
-
-
-/**
- * @return {!Function} The called function.
- */
-goog.testing.FunctionCall.prototype.getFunction = function() {
- return this.function_;
-};
-
-
-/**
- * @return {!Object} {@code this} context of called function. It is the same as
- * the created object if the function is a constructor.
- */
-goog.testing.FunctionCall.prototype.getThis = function() {
- return this.thisContext_;
-};
-
-
-/**
- * @return {!Array} Arguments of the called function.
- */
-goog.testing.FunctionCall.prototype.getArguments = function() {
- return this.arguments_;
-};
-
-
-/**
- * Returns the nth argument of the called function.
- * @param {number} index 0-based index of the argument.
- * @return {*} The argument value or undefined if there is no such argument.
- */
-goog.testing.FunctionCall.prototype.getArgument = function(index) {
- return this.arguments_[index];
-};
-
-
-/**
- * @return {*} Return value of the function or undefined in case of error.
- */
-goog.testing.FunctionCall.prototype.getReturnValue = function() {
- return this.returnValue_;
-};
-
-
-/**
- * @return {*} The error thrown by the function or null if none.
- */
-goog.testing.FunctionCall.prototype.getError = function() {
- return this.error_;
-};
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/recordfunction_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/recordfunction_test.html.svn-base
deleted file mode 100644
index bb78aee..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/recordfunction_test.html.svn-base
+++ /dev/null
@@ -1,159 +0,0 @@
-<!DOCTYPE html>
-<html>
-<!--
-Copyright 2010 The Closure Library Authors. All Rights Reserved.
-
-Use of this source code is governed by the Apache License, Version 2.0.
-See the COPYING file for details.
--->
-<!--
--->
-<head>
-<meta http-equiv="X-UA-Compatible" content="IE=edge">
-<title>Closure Unit Tests - goog.testing.recordFunction</title>
-<script src="../base.js"></script>
-<script>
- goog.require('goog.functions');
- goog.require('goog.testing.PropertyReplacer');
- goog.require('goog.testing.jsunit');
- goog.require('goog.testing.recordConstructor');
- goog.require('goog.testing.recordFunction');
-</script>
-</head>
-<body>
-<script>
-
-var stubs = new goog.testing.PropertyReplacer();
-
-function tearDown() {
- stubs.reset();
-}
-
-function testNoCalls() {
- var f = goog.testing.recordFunction(goog.functions.identity);
- assertEquals('call count', 0, f.getCallCount());
- assertNull('last call', f.getLastCall());
- assertArrayEquals('all calls', [], f.getCalls());
-}
-
-function testWithoutArguments() {
- var f = goog.testing.recordFunction();
- assertUndefined('f(1)', f(1));
- assertEquals('call count', 1, f.getCallCount());
- var lastCall = f.getLastCall();
- assertEquals('original function', goog.nullFunction, lastCall.getFunction());
- assertEquals('this context', window, lastCall.getThis());
- assertArrayEquals('arguments', [1], lastCall.getArguments());
- assertEquals('arguments[0]', 1, lastCall.getArgument(0));
- assertUndefined('arguments[1]', lastCall.getArgument(1));
- assertUndefined('return value', lastCall.getReturnValue());
-}
-
-function testWithIdentityFunction() {
- var f = goog.testing.recordFunction(goog.functions.identity);
- var dummyThis = {};
- assertEquals('f(1)', 1, f(1));
- assertEquals('f.call(dummyThis, 2)', 2, f.call(dummyThis, 2));
-
- var calls = f.getCalls();
- var firstCall = calls[0];
- var lastCall = f.getLastCall();
- assertEquals('call count', 2, f.getCallCount());
- assertEquals('last call', calls[1], lastCall);
- assertEquals('original function', goog.functions.identity,
- lastCall.getFunction());
- assertEquals('this context of first call', window, firstCall.getThis());
- assertEquals('this context of last call', dummyThis, lastCall.getThis());
- assertArrayEquals('arguments of the first call', [1],
- firstCall.getArguments());
- assertArrayEquals('arguments of the last call', [2], lastCall.getArguments());
- assertEquals('return value of the first call', 1, firstCall.getReturnValue());
- assertEquals('return value of the last call', 2, lastCall.getReturnValue());
- assertNull('error thrown by the first call', firstCall.getError());
- assertNull('error thrown by the last call', lastCall.getError());
-}
-
-function testWithErrorFunction() {
- var f = goog.testing.recordFunction(goog.functions.error('error'));
-
- var error = assertThrows('f(1) should throw an error', function() {
- f(1);
- });
- assertEquals('error message', 'error', error.message);
- assertEquals('call count', 1, f.getCallCount());
- var lastCall = f.getLastCall();
- assertEquals('this context', window, lastCall.getThis());
- assertArrayEquals('arguments', [1], lastCall.getArguments());
- assertUndefined('return value', lastCall.getReturnValue());
- assertEquals('recorded error message', 'error', lastCall.getError().message);
-}
-
-function testWithClass() {
- var ns = {};
- /** @constructor */
- ns.TestClass = function(num) {
- this.setX(ns.TestClass.identity(1) + num);
- }
- ns.TestClass.prototype.setX = function(x) {
- this.x = x;
- };
- ns.TestClass.identity = function(x) {
- return x;
- };
- var originalNsTestClass = ns.TestClass;
-
- stubs.set(ns, 'TestClass', goog.testing.recordConstructor(ns.TestClass));
- stubs.set(ns.TestClass.prototype, 'setX',
- goog.testing.recordFunction(ns.TestClass.prototype.setX));
- stubs.set(ns.TestClass, 'identity',
- goog.testing.recordFunction(ns.TestClass.identity));
-
- var obj = new ns.TestClass(2);
- assertEquals('constructor is called once', 1, ns.TestClass.getCallCount());
- var lastConstructorCall = ns.TestClass.getLastCall();
- assertArrayEquals('... with argument 2', [2],
- lastConstructorCall.getArguments());
- assertEquals('the created object', obj, lastConstructorCall.getThis());
- assertEquals('type of the created object', originalNsTestClass,
- obj.constructor);
-
- assertEquals('setX is called once', 1, obj.setX.getCallCount());
- assertArrayEquals('... with argument 3', [3],
- obj.setX.getLastCall().getArguments());
- assertEquals('The x field is properly set', 3, obj.x);
-
- assertEquals('identity is called once', 1,
- ns.TestClass.identity.getCallCount());
- assertArrayEquals('... with argument 1', [1],
- ns.TestClass.identity.getLastCall().getArguments());
-}
-
-function testPopLastCall() {
- var f = goog.testing.recordFunction();
- f(0);
- f(1);
-
- var firstCall = f.getCalls()[0];
- var lastCall = f.getCalls()[1];
- assertEquals('return value of popLastCall', lastCall, f.popLastCall());
- assertArrayEquals('1 call remains', [firstCall], f.getCalls());
- assertEquals('next return value of popLastCall', firstCall, f.popLastCall());
- assertArrayEquals('0 calls remain', [], f.getCalls());
- assertNull('no more calls to pop', f.popLastCall());
-}
-
-function testReset() {
- var f = goog.testing.recordFunction();
- f(0);
- f(1);
-
- assertEquals('Should be two calls.', 2, f.getCallCount());
-
- f.reset();
-
- assertEquals('Call count should reset.', 0, f.getCallCount());
-}
-
-</script>
-</body>
-</html>
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/shardingtestcase.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/shardingtestcase.js.svn-base
deleted file mode 100644
index 2798b43..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/shardingtestcase.js.svn-base
+++ /dev/null
@@ -1,119 +0,0 @@
-// Copyright 2009 The Closure Library Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS-IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/**
- * @fileoverview Utility for sharding tests.
- *
- * Usage instructions:
- * <ol>
- * <li>Instead of writing your large test in foo_test.html, write it in
- * foo_test_template.html</li>
- * <li>Add a call to {@code goog.testing.ShardingTestCase.shardByFileName()}
- * near the top of your test, before any test cases or setup methods.</li>
- * <li>Symlink foo_test_template.html into different sharded test files
- * named foo_1of4_test.html, foo_2of4_test.html, etc, using `ln -s`.</li>
- * <li>Add the symlinks as foo_1of4_test.html.
- * In perforce, run the command `g4 add foo_1of4_test.html` followed
- * by `g4 reopen -t symlink foo_1of4_test.html` so that perforce treats the file
- * as a symlink
- * </li>
- * </ol>
- *
- */
-
-goog.provide('goog.testing.ShardingTestCase');
-
-goog.require('goog.asserts');
-goog.require('goog.testing.TestCase');
-
-/**
- * A test case that runs tests in per-file shards.
- * @param {number} shardIndex Shard index for this page,
- * <strong>1-indexed</strong>.
- * @param {number} numShards Number of shards to split up test cases into.
- * @extends {goog.testing.TestCase}
- * @constructor
- */
-goog.testing.ShardingTestCase = function(shardIndex, numShards, opt_name) {
- goog.base(this, opt_name);
-
- goog.asserts.assert(shardIndex > 0, 'Shard index should be positive');
- goog.asserts.assert(numShards > 0, 'Number of shards should be positive');
- goog.asserts.assert(shardIndex <= numShards,
- 'Shard index out of bounds');
-
- /**
- * @type {number}
- * @private
- */
- this.shardIndex_ = shardIndex;
-
- /**
- * @type {number}
- * @private
- */
- this.numShards_ = numShards;
-};
-goog.inherits(goog.testing.ShardingTestCase, goog.testing.TestCase);
-
-
-/**
- * Whether we've actually partitioned the tests yet. We may execute twice
- * ('Run again without reloading') without failing.
- * @type {boolean}
- * @private
- */
-goog.testing.ShardingTestCase.prototype.sharded_ = false;
-
-
-/**
- * Installs a runTests global function that goog.testing.JsUnit will use to
- * run tests, which will run a single shard of the tests present on the page.
- */
-goog.testing.ShardingTestCase.prototype.runTests = function() {
- if (!this.sharded_) {
- var numTests = this.getCount();
- goog.asserts.assert(numTests >= this.numShards_,
- 'Must have at least as many tests as shards!');
- var shardSize = Math.ceil(numTests / this.numShards_);
- var startIndex = (this.shardIndex_ - 1) * shardSize;
- var endIndex = startIndex + shardSize;
- goog.asserts.assert(this.order == goog.testing.TestCase.Order.SORTED,
- 'Only SORTED order is allowed for sharded tests');
- this.setTests(this.getTests().slice(startIndex, endIndex));
- this.sharded_ = true;
- }
-
- // Call original runTests method to execute the tests.
- goog.base(this, 'runTests');
-};
-
-
-/**
- * Shards tests based on the test filename. Assumes that the filename is
- * formatted like 'foo_1of5_test.html'.
- * @param {string=} opt_name A descriptive name for the test case.
- */
-goog.testing.ShardingTestCase.shardByFileName = function(opt_name) {
- var path = window.location.pathname;
- var shardMatch = path.match(/_(\d+)of(\d+)_test\.html/);
- goog.asserts.assert(shardMatch,
- 'Filename must be of the form "foo_1of5_test.html"');
- var shardIndex = parseInt(shardMatch[1], 10);
- var numShards = parseInt(shardMatch[2], 10);
-
- var testCase = new goog.testing.ShardingTestCase(
- shardIndex, numShards, opt_name);
- goog.testing.TestCase.initializeTestRunner(testCase);
-};
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/shardingtestcase_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/shardingtestcase_test.html.svn-base
deleted file mode 100644
index cc79280..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/shardingtestcase_test.html.svn-base
+++ /dev/null
@@ -1,34 +0,0 @@
-<!DOCTYPE html>
-<html>
-<!--
-Copyright 2011 The Closure Library Authors. All Rights Reserved.
-
-Use of this source code is governed by the Apache License, Version 2.0.
-See the COPYING file for details.
--->
-<head>
-<meta http-equiv="X-UA-Compatible" content="IE=edge">
-<title>Closure Unit Tests - goog.testing.asserts</title>
-<script src="../base.js"></script>
-<script>
- goog.require('goog.testing.ShardingTestCase');
- goog.require('goog.testing.asserts');
- goog.require('goog.testing.jsunit');
-</script>
-</head>
-<body>
-<script>
-
-goog.testing.TestCase.initializeTestRunner(
- new goog.testing.ShardingTestCase(1, 2));
-
-function testA() {
-}
-
-function testB() {
- fail('testB should not be in this shard');
-}
-
-</script>
-</body>
-</html>
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/singleton.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/singleton.js.svn-base
deleted file mode 100644
index 73187c2..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/singleton.js.svn-base
+++ /dev/null
@@ -1,82 +0,0 @@
-// Copyright 2009 The Closure Library Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS-IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/**
- * @fileoverview This module simplifies testing code which uses many stateful
- * singletons. The {@link goog.testing.singleton.addSingletonGetter} function
- * adds a static {@code getInstance} method to the class, which in addition to
- * creating and returning a singleton instance, registers it in a global
- * repository. This way the effect of all {@code getInstance} calls can be
- * simply reset in {@code tearDown} without knowing what singletons were
- * instantiated in the tests.
- *
- * Usage:
- * <ol>
- * <li>Load {@code base.js}.
- * <li>Load {@code goog.testing.singleton}. It overrides
- * {@link goog.addSingletonGetter} by
- * {@link goog.testing.addSingletonGetter}.
- * <li>Load the code to test.
- * <li>Call {@link goog.testing.singleton.reset} in the {@code tearDown}.
- * </ol>
- *
- */
-
-goog.provide('goog.testing.singleton');
-
-goog.require('goog.array');
-
-
-/**
- * List of all singleton classes for which the instance has been created.
- * @type {Array.<!Function>}
- * @private
- */
-goog.testing.singletons_ = [];
-
-
-/**
- * Adds a {@code getInstance} static method to the given class which in addition
- * to always returning the same instance object, registers the constructor in a
- * global array.
- * @param {!Function} ctor The constructor for the class to add the static
- * method to.
- */
-goog.testing.singleton.addSingletonGetter = function(ctor) {
- ctor.getInstance = function() {
- if (!ctor.instance_) {
- ctor.instance_ = new ctor();
- goog.testing.singletons_.push(ctor);
- }
- return ctor.instance_;
- };
-};
-
-
-/**
- * Deletes all singleton instances, so {@code getInstance} will return a new
- * instance on next call.
- */
-goog.testing.singleton.reset = function() {
- goog.array.forEach(goog.testing.singletons_, function(ctor) {
- delete ctor.instance_;
- });
- goog.array.clear(goog.testing.singletons_);
-};
-
-
-/**
- * Overrides {@code goog.addSingletonGetter} in {@code base.js}.
- */
-goog.addSingletonGetter = goog.testing.singleton.addSingletonGetter;
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/singleton_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/singleton_test.html.svn-base
deleted file mode 100644
index 2012ce9..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/singleton_test.html.svn-base
+++ /dev/null
@@ -1,39 +0,0 @@
-<!DOCTYPE html>
-<html>
-<!--
-Copyright 2009 The Closure Library Authors. All Rights Reserved.
-
-Use of this source code is governed by the Apache License, Version 2.0.
-See the COPYING file for details.
--->
-<!--
--->
-<head>
-<meta http-equiv="X-UA-Compatible" content="IE=edge">
-<title>Closure Unit Tests - goog.testing.singleton</title>
-<script src="../base.js"></script>
-<script>
- goog.require('goog.testing.asserts');
- goog.require('goog.testing.jsunit');
- goog.require('goog.testing.singleton');
-</script>
-</head>
-<body>
-<script>
-
-function testGetInstance() {
- function SingletonClass() {}
- goog.addSingletonGetter(SingletonClass);
-
- var s1 = SingletonClass.getInstance();
- var s2 = SingletonClass.getInstance();
- assertEquals('second getInstance call returns the same instance', s1, s2);
-
- goog.testing.singleton.reset();
- var s3 = SingletonClass.getInstance();
- assertNotEquals('getInstance returns a new instance after reset', s1, s3);
-}
-
-</script>
-</body>
-</html>
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/stacktrace.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/stacktrace.js.svn-base
deleted file mode 100644
index 4159135..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/stacktrace.js.svn-base
+++ /dev/null
@@ -1,470 +0,0 @@
-// Copyright 2009 The Closure Library Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS-IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/**
- * @fileoverview Tools for parsing and pretty printing error stack traces.
- *
- */
-
-goog.provide('goog.testing.stacktrace');
-goog.provide('goog.testing.stacktrace.Frame');
-
-
-
-/**
- * Class representing one stack frame.
- * @param {string} context Context object, empty in case of global functions or
- * if the browser doesn't provide this information.
- * @param {string} name Function name, empty in case of anonymous functions.
- * @param {string} alias Alias of the function if available. For example the
- * function name will be 'c' and the alias will be 'b' if the function is
- * defined as <code>a.b = function c() {};</code>.
- * @param {string} args Arguments of the function in parentheses if available.
- * @param {string} path File path or URL including line number and optionally
- * column number separated by colons.
- * @constructor
- */
-goog.testing.stacktrace.Frame = function(context, name, alias, args, path) {
- this.context_ = context;
- this.name_ = name;
- this.alias_ = alias;
- this.args_ = args;
- this.path_ = path;
-};
-
-
-/**
- * @return {string} The function name or empty string if the function is
- * anonymous and the object field which it's assigned to is unknown.
- */
-goog.testing.stacktrace.Frame.prototype.getName = function() {
- return this.name_;
-};
-
-
-/**
- * @return {boolean} Whether the stack frame contains an anonymous function.
- */
-goog.testing.stacktrace.Frame.prototype.isAnonymous = function() {
- return !this.name_ || this.context_ == '[object Object]';
-};
-
-
-/**
- * Brings one frame of the stack trace into a common format across browsers.
- * @return {string} Pretty printed stack frame.
- */
-goog.testing.stacktrace.Frame.prototype.toCanonicalString = function() {
- var htmlEscape = goog.testing.stacktrace.htmlEscape_;
- var deobfuscate = goog.testing.stacktrace.maybeDeobfuscateFunctionName_;
-
- var canonical = [
- this.context_ ? htmlEscape(this.context_) + '.' : '',
- this.name_ ? htmlEscape(deobfuscate(this.name_)) : 'anonymous',
- htmlEscape(this.args_),
- this.alias_ ? ' [as ' + htmlEscape(deobfuscate(this.alias_)) + ']' : ''
- ];
-
- if (this.path_) {
- canonical.push(' at ');
- // If Closure Inspector is installed and running, then convert the line
- // into a source link for displaying the code in Firebug.
- if (goog.testing.stacktrace.isClosureInspectorActive_()) {
- var lineNumber = this.path_.match(/\d+$/)[0];
- canonical.push('<a href="" onclick="CLOSURE_INSPECTOR___.showLine(\'',
- htmlEscape(this.path_), '\', \'', lineNumber, '\'); return false">',
- htmlEscape(this.path_), '</a>');
- } else {
- canonical.push(htmlEscape(this.path_));
- }
- }
- return canonical.join('');
-};
-
-
-/**
- * Maximum number of steps while the call chain is followed.
- * @type {number}
- * @private
- */
-goog.testing.stacktrace.MAX_DEPTH_ = 20;
-
-
-/**
- * Maximum length of a string that can be matched with a RegExp on
- * Firefox 3x. Exceeding this approximate length will cause string.match
- * to exceed Firefox's stack quota. This situation can be encountered
- * when goog.globalEval is invoked with a long argument; such as
- * when loading a module.
- * @type {number}
- * @private
- */
-goog.testing.stacktrace.MAX_FIREFOX_FRAMESTRING_LENGTH_ = 500000;
-
-
-/**
- * RegExp pattern for JavaScript identifiers. We don't support Unicode
- * identifiers defined in ECMAScript v3.
- * @type {string}
- * @private
- */
-goog.testing.stacktrace.IDENTIFIER_PATTERN_ = '[a-zA-Z_$][\\w$]*';
-
-
-/**
- * RegExp pattern for function name alias in the Chrome stack trace.
- * @type {string}
- * @private
- */
-goog.testing.stacktrace.CHROME_ALIAS_PATTERN_ =
- '(?: \\[as (' + goog.testing.stacktrace.IDENTIFIER_PATTERN_ + ')\\])?';
-
-
-/**
- * RegExp pattern for function names and constructor calls in the Chrome stack
- * trace.
- * @type {string}
- * @private
- */
-goog.testing.stacktrace.CHROME_FUNCTION_NAME_PATTERN_ =
- '(?:new )?(?:' + goog.testing.stacktrace.IDENTIFIER_PATTERN_ +
- '|<anonymous>)';
-
-
-/**
- * RegExp pattern for function call in the Chrome stack trace.
- * Creates 3 submatches with context object (optional), function name and
- * function alias (optional).
- * @type {string}
- * @private
- */
-goog.testing.stacktrace.CHROME_FUNCTION_CALL_PATTERN_ =
- ' (?:(.*?)\\.)?(' + goog.testing.stacktrace.CHROME_FUNCTION_NAME_PATTERN_ +
- ')' + goog.testing.stacktrace.CHROME_ALIAS_PATTERN_;
-
-
-/**
- * RegExp pattern for an URL + position inside the file.
- * @type {string}
- * @private
- */
-goog.testing.stacktrace.URL_PATTERN_ =
- '((?:http|https|file)://[^\\s)]+|javascript:.*)';
-
-
-/**
- * RegExp pattern for an URL + line number + column number in Chrome.
- * The URL is either in submatch 1 or submatch 2.
- * @type {string}
- * @private
- */
-goog.testing.stacktrace.CHROME_URL_PATTERN_ = ' (?:' +
- '\\(unknown source\\)' + '|' +
- '\\(native\\)' + '|' +
- '\\((?:eval at )?' + goog.testing.stacktrace.URL_PATTERN_ + '\\)' + '|' +
- goog.testing.stacktrace.URL_PATTERN_ + ')';
-
-
-/**
- * Regular expression for parsing one stack frame in Chrome.
- * @type {!RegExp}
- * @private
- */
-goog.testing.stacktrace.CHROME_STACK_FRAME_REGEXP_ = new RegExp('^ at' +
- '(?:' + goog.testing.stacktrace.CHROME_FUNCTION_CALL_PATTERN_ + ')?' +
- goog.testing.stacktrace.CHROME_URL_PATTERN_ + '$');
-
-
-/**
- * RegExp pattern for function call in the Firefox stack trace.
- * Creates 2 submatches with function name (optional) and arguments.
- * @type {string}
- * @private
- */
-goog.testing.stacktrace.FIREFOX_FUNCTION_CALL_PATTERN_ =
- '(' + goog.testing.stacktrace.IDENTIFIER_PATTERN_ + ')?' +
- '(\\(.*\\))?@';
-
-
-/**
- * Regular expression for parsing one stack frame in Firefox.
- * @type {!RegExp}
- * @private
- */
-goog.testing.stacktrace.FIREFOX_STACK_FRAME_REGEXP_ = new RegExp('^' +
- goog.testing.stacktrace.FIREFOX_FUNCTION_CALL_PATTERN_ +
- '(?::0|' + goog.testing.stacktrace.URL_PATTERN_ + ')$');
-
-
-/**
- * Regular expression for finding the function name in its source.
- * @type {!RegExp}
- * @private
- */
-goog.testing.stacktrace.FUNCTION_SOURCE_REGEXP_ = new RegExp(
- '^function (' + goog.testing.stacktrace.IDENTIFIER_PATTERN_ + ')');
-
-
-/**
- * Creates a stack trace by following the call chain. Based on
- * {@link goog.debug.getStacktrace}.
- * @return {!Array.<!goog.testing.stacktrace.Frame>} Stack frames.
- * @private
- */
-goog.testing.stacktrace.followCallChain_ = function() {
- var frames = [];
- var fn = arguments.callee.caller;
- var depth = 0;
-
- while (fn && depth < goog.testing.stacktrace.MAX_DEPTH_) {
- var fnString = Function.prototype.toString.call(fn);
- var match = fnString.match(goog.testing.stacktrace.FUNCTION_SOURCE_REGEXP_);
- var functionName = match ? match[1] : '';
-
- var argsBuilder = ['('];
- if (fn.arguments) {
- for (var i = 0; i < fn.arguments.length; i++) {
- var arg = fn.arguments[i];
- if (i > 0) {
- argsBuilder.push(', ');
- }
- if (goog.isString(arg)) {
- argsBuilder.push('"', arg, '"');
- } else {
- // Some args are mocks, and we don't want to fail from them not having
- // expected a call to toString, so instead insert a static string.
- if (arg && arg['$replay']) {
- argsBuilder.push('goog.testing.Mock');
- } else {
- argsBuilder.push(String(arg));
- }
- }
- }
- } else {
- // Opera 10 doesn't know the arguments of native functions.
- argsBuilder.push('unknown');
- }
- argsBuilder.push(')');
- var args = argsBuilder.join('');
-
- frames.push(new goog.testing.stacktrace.Frame('', functionName, '', args,
- ''));
-
- /** @preserveTry */
- try {
- fn = fn.caller;
- } catch (e) {
- break;
- }
- depth++;
- }
-
- return frames;
-};
-
-
-/**
- * Parses one stack frame.
- * @param {string} frameStr The stack frame as string.
- * @return {goog.testing.stacktrace.Frame} Stack frame object or null if the
- * parsing failed.
- * @private
- */
-goog.testing.stacktrace.parseStackFrame_ = function(frameStr) {
- var m = frameStr.match(goog.testing.stacktrace.CHROME_STACK_FRAME_REGEXP_);
- if (m) {
- return new goog.testing.stacktrace.Frame(m[1] || '', m[2] || '', m[3] || '',
- '', m[4] || m[5] || '');
- }
-
- if (frameStr.length >
- goog.testing.stacktrace.MAX_FIREFOX_FRAMESTRING_LENGTH_) {
- return goog.testing.stacktrace.parseLongFirefoxFrame_(frameStr);
- }
-
- m = frameStr.match(goog.testing.stacktrace.FIREFOX_STACK_FRAME_REGEXP_);
- if (m) {
- return new goog.testing.stacktrace.Frame('', m[1] || '', '', m[2] || '',
- m[3] || '');
- }
-
- return null;
-};
-
-
-/**
- * Parses a long firefox stack frame.
- * @param {string} frameStr The stack frame as string.
- * @return {!goog.testing.stacktrace.Frame} Stack frame object.
- * @private
- */
-goog.testing.stacktrace.parseLongFirefoxFrame_ = function(frameStr) {
- var firstParen = frameStr.indexOf('(');
- var lastAmpersand = frameStr.lastIndexOf('@');
- var lastColon = frameStr.lastIndexOf(':');
- var functionName = '';
- if ((firstParen >= 0) && (firstParen < lastAmpersand)) {
- functionName = frameStr.substring(0, firstParen);
- }
- var loc = '';
- if ((lastAmpersand >= 0) && (lastAmpersand + 1 < lastColon)) {
- loc = frameStr.substring(lastAmpersand + 1);
- }
- var args = '';
- if ((firstParen >= 0 && lastAmpersand > 0) &&
- (firstParen < lastAmpersand)) {
- args = frameStr.substring(firstParen, lastAmpersand);
- }
- return new goog.testing.stacktrace.Frame('', functionName, '', args, loc);
-};
-
-
-/**
- * Function to deobfuscate function names.
- * @type {function(string): string}
- * @private
- */
-goog.testing.stacktrace.deobfuscateFunctionName_;
-
-
-/**
- * Sets function to deobfuscate function names.
- * @param {function(string): string} fn function to deobfuscate function names.
- */
-goog.testing.stacktrace.setDeobfuscateFunctionName = function(fn) {
- goog.testing.stacktrace.deobfuscateFunctionName_ = fn;
-};
-
-
-/**
- * Deobfuscates a compiled function name with the function passed to
- * {@link #setDeobfuscateFunctionName}. Returns the original function name if
- * the deobfuscator hasn't been set.
- * @param {string} name The function name to deobfuscate.
- * @return {string} The deobfuscated function name.
- * @private
- */
-goog.testing.stacktrace.maybeDeobfuscateFunctionName_ = function(name) {
- return goog.testing.stacktrace.deobfuscateFunctionName_ ?
- goog.testing.stacktrace.deobfuscateFunctionName_(name) : name;
-};
-
-
-/**
- * @return {boolean} Whether the Closure Inspector is active.
- * @private
- */
-goog.testing.stacktrace.isClosureInspectorActive_ = function() {
- return Boolean(goog.global['CLOSURE_INSPECTOR___'] &&
- goog.global['CLOSURE_INSPECTOR___']['supportsJSUnit']);
-};
-
-
-/**
- * Escapes the special character in HTML.
- * @param {string} text Plain text.
- * @return {string} Escaped text.
- * @private
- */
-goog.testing.stacktrace.htmlEscape_ = function(text) {
- return text.replace(/&/g, '&amp;').
- replace(/</g, '&lt;').
- replace(/>/g, '&gt;').
- replace(/"/g, '&quot;');
-};
-
-
-/**
- * Converts the stack frames into canonical format. Chops the beginning and the
- * end of it which come from the testing environment, not from the test itself.
- * @param {!Array.<goog.testing.stacktrace.Frame>} frames The frames.
- * @return {string} Canonical, pretty printed stack trace.
- * @private
- */
-goog.testing.stacktrace.framesToString_ = function(frames) {
- // Removes the anonymous calls from the end of the stack trace (they come
- // from testrunner.js, testcase.js and asserts.js), so the stack trace will
- // end with the test... method.
- var lastIndex = frames.length - 1;
- while (frames[lastIndex] && frames[lastIndex].isAnonymous()) {
- lastIndex--;
- }
-
- // Removes the beginning of the stack trace until the call of the private
- // _assert function (inclusive), so the stack trace will begin with a public
- // asserter. Does nothing if _assert is not present in the stack trace.
- var privateAssertIndex = -1;
- for (var i = 0; i < frames.length; i++) {
- if (frames[i] && frames[i].getName() == '_assert') {
- privateAssertIndex = i;
- break;
- }
- }
-
- var canonical = [];
- for (var i = privateAssertIndex + 1; i <= lastIndex; i++) {
- canonical.push('> ');
- if (frames[i]) {
- canonical.push(frames[i].toCanonicalString());
- } else {
- canonical.push('(unknown)');
- }
- canonical.push('\n');
- }
- return canonical.join('');
-};
-
-
-/**
- * Parses the browser's native stack trace.
- * @param {string} stack Stack trace.
- * @return {!Array.<goog.testing.stacktrace.Frame>} Stack frames. The
- * unrecognized frames will be nulled out.
- * @private
- */
-goog.testing.stacktrace.parse_ = function(stack) {
- var lines = stack.replace(/\s*$/, '').split('\n');
- var frames = [];
- for (var i = 0; i < lines.length; i++) {
- frames.push(goog.testing.stacktrace.parseStackFrame_(lines[i]));
- }
- return frames;
-};
-
-
-/**
- * Brings the stack trace into a common format across browsers.
- * @param {string} stack Browser-specific stack trace.
- * @return {string} Same stack trace in common format.
- */
-goog.testing.stacktrace.canonicalize = function(stack) {
- var frames = goog.testing.stacktrace.parse_(stack);
- return goog.testing.stacktrace.framesToString_(frames);
-};
-
-
-/**
- * Gets the native stack trace if available otherwise follows the call chain.
- * @return {string} The stack trace in canonical format.
- */
-goog.testing.stacktrace.get = function() {
- var stack = new Error().stack;
- var frames = stack ? goog.testing.stacktrace.parse_(stack) :
- goog.testing.stacktrace.followCallChain_();
- return goog.testing.stacktrace.framesToString_(frames);
-};
-
-
-goog.exportSymbol('setDeobfuscateFunctionName',
- goog.testing.stacktrace.setDeobfuscateFunctionName);
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/stacktrace_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/stacktrace_test.html.svn-base
deleted file mode 100644
index 28171c1..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/stacktrace_test.html.svn-base
+++ /dev/null
@@ -1,229 +0,0 @@
-<!DOCTYPE html>
-<html>
-<!--
-Copyright 2009 The Closure Library Authors. All Rights Reserved.
-
-Use of this source code is governed by the Apache License, Version 2.0.
-See the COPYING file for details.
--->
-<!--
--->
-<head>
-<meta http-equiv="X-UA-Compatible" content="IE=edge">
-<title>Closure Unit Tests - goog.testing.stacktrace</title>
-<script src="../base.js"></script>
-<script>
- goog.require('goog.string');
- goog.require('goog.testing.ExpectedFailures');
- goog.require('goog.testing.PropertyReplacer');
- goog.require('goog.testing.StrictMock');
- goog.require('goog.testing.asserts');
- goog.require('goog.testing.jsunit');
- goog.require('goog.testing.stacktrace');
- goog.require('goog.userAgent');
-</script>
-</head>
-<body>
-<script>
-
-var stubs = new goog.testing.PropertyReplacer();
-var expectedFailures = new goog.testing.ExpectedFailures();
-
-function setUp() {
- stubs.set(goog.testing.stacktrace, 'isClosureInspectorActive_', function() {
- return false;
- });
-}
-
-function tearDown() {
- stubs.reset();
- expectedFailures.handleTearDown();
-}
-
-function testParseStackFrameInChrome() {
- var frameString = ' at Error (unknown source)';
- var frame = goog.testing.stacktrace.parseStackFrame_(frameString);
- var expected = new goog.testing.stacktrace.Frame('', 'Error', '', '', '');
- assertObjectEquals('exception name only', expected, frame);
-
- frameString = ' at Object.assert (file:///.../asserts.js:29:10)';
- frame = goog.testing.stacktrace.parseStackFrame_(frameString);
- expected = new goog.testing.stacktrace.Frame('Object', 'assert', '', '',
- 'file:///.../asserts.js:29:10')
- assertObjectEquals('context object + function name + url', expected, frame);
-
- frameString = ' at http://www.example.com/jsunit.js:117:13';
- frame = goog.testing.stacktrace.parseStackFrame_(frameString);
- expected = new goog.testing.stacktrace.Frame('', '', '', '',
- 'http://www.example.com/jsunit.js:117:13');
- assertObjectEquals('url only', expected, frame);
-
- frameString = ' at [object Object].exec [as execute] (file:///foo)';
- frame = goog.testing.stacktrace.parseStackFrame_(frameString);
- expected = new goog.testing.stacktrace.Frame('[object Object]', 'exec',
- 'execute', '', 'file:///foo');
- assertObjectEquals('function alias', expected, frame);
-
- frameString = ' at new Class (file:///foo)';
- frame = goog.testing.stacktrace.parseStackFrame_(frameString);
- expected = new goog.testing.stacktrace.Frame('', 'new Class', '', '',
- 'file:///foo');
- assertObjectEquals('constructor call', expected, frame);
-
- frameString = ' at new <anonymous> (file:///foo)';
- frame = goog.testing.stacktrace.parseStackFrame_(frameString);
- expected = new goog.testing.stacktrace.Frame('', 'new <anonymous>', '', '',
- 'file:///foo');
- assertObjectEquals('anonymous constructor call', expected, frame);
-
- frameString = ' at Array.forEach (native)';
- frame = goog.testing.stacktrace.parseStackFrame_(frameString);
- expected = new goog.testing.stacktrace.Frame('Array', 'forEach', '', '', '');
- assertObjectEquals('native function call', expected, frame);
-
- frameString = ' at foo (eval at file://bar)';
- frame = goog.testing.stacktrace.parseStackFrame_(frameString);
- expected = new goog.testing.stacktrace.Frame('', 'foo', '', '', 'file://bar');
- assertObjectEquals('eval', expected, frame);
-}
-
-// All test strings are parsed with the conventional and long
-// frame algorithms.
-function testParseStackFrameInFirefox() {
- var frameString = 'Error("Assertion failed")@:0';
- var frame = goog.testing.stacktrace.parseStackFrame_(frameString);
- var expected = new goog.testing.stacktrace.Frame('', 'Error', '',
- '("Assertion failed")', '');
- assertObjectEquals('function name + arguments', expected, frame);
-
- frame = goog.testing.stacktrace.parseLongFirefoxFrame_(frameString);
- assertObjectEquals('function name + arguments', expected, frame);
-
- frameString = '()@file:///foo:42';
- frame = goog.testing.stacktrace.parseStackFrame_(frameString);
- expected = new goog.testing.stacktrace.Frame('', '', '', '()',
- 'file:///foo:42');
- assertObjectEquals('anonymous function', expected, frame);
-
- frame = goog.testing.stacktrace.parseLongFirefoxFrame_(frameString);
- assertObjectEquals('anonymous function', expected, frame);
-
- frameString = '@javascript:alert(0)';
- frame = goog.testing.stacktrace.parseStackFrame_(frameString);
- expected = new goog.testing.stacktrace.Frame('', '', '', '',
- 'javascript:alert(0)');
- assertObjectEquals('anonymous function', expected, frame);
-
- frame = goog.testing.stacktrace.parseLongFirefoxFrame_(frameString);
- assertObjectEquals('anonymous function', expected, frame);
-}
-
-function testCanonicalizeFrame() {
- var frame = new goog.testing.stacktrace.Frame('<window>', 'foo', 'bar',
- '("<a>\'&amp;")', 'http://x?a=1&b=2:1');
- assertEquals('canonical stack frame, everything is escaped',
- '&lt;window&gt;.foo(&quot;&lt;a&gt;\'&amp;amp;&quot;) ' +
- '[as bar] at http://x?a=1&amp;b=2:1', frame.toCanonicalString());
-}
-
-function testCanonicalizeFrameWithClosureInspector() {
- stubs.set(goog.testing.stacktrace, 'isClosureInspectorActive_', function() {
- return true;
- });
-
- var frame = new goog.testing.stacktrace.Frame('', 'foo', '', '()',
- 'http://x?a=1&b=2:1');
- assertEquals('canonical stack frame with closure inspector link',
- 'foo() at <a href="" onclick="CLOSURE_INSPECTOR___.showLine(' +
- '\'http://x?a=1&amp;b=2:1\', \'1\'); return false">' +
- 'http://x?a=1&amp;b=2:1<' + '/a>',
- frame.toCanonicalString());
-}
-
-function testDeobfuscateFunctionName() {
- goog.testing.stacktrace.setDeobfuscateFunctionName(function(name) {
- return name.replace(/\$/g, '.');
- });
-
- var frame = new goog.testing.stacktrace.Frame('', 'a$b$c', 'd$e', '', '');
- assertEquals('deobfuscated function name', 'a.b.c [as d.e]',
- frame.toCanonicalString());
-}
-
-function testFramesToString() {
- var normalFrame = new goog.testing.stacktrace.Frame('', 'foo', '', '', '');
- var anonFrame = new goog.testing.stacktrace.Frame('', '', '', '', '');
- var frames = [normalFrame, anonFrame, null, anonFrame];
- var stack = goog.testing.stacktrace.framesToString_(frames);
- assertEquals('framesToString', '> foo\n> anonymous\n> (unknown)\n', stack);
-}
-
-function testFollowCallChain() {
- var func = function(var_args) {
- return goog.testing.stacktrace.followCallChain_();
- };
-
- // Created a fake type with a toString method.
- function LocalType() {};
- LocalType.prototype.toString = function() {
- return 'sg';
- };
-
- // Create a mock with no expectations.
- var mock = new goog.testing.StrictMock(LocalType);
-
- mock.$replay();
-
- var frames = func(undefined, null, false, 0, '', {}, goog.nullFunction,
- mock, new LocalType);
-
- // Opera before version 10 doesn't support the caller attribute. In that
- // browser followCallChain_() returns empty stack trace.
- expectedFailures.expectFailureFor(goog.userAgent.OPERA &&
- !goog.userAgent.isVersion('10'));
- try {
- assertTrue('The stack trace consists of >=2 frames', frames.length >= 2)
- } catch (e) {
- expectedFailures.handleException(e);
- }
-
- if (frames.length >= 2) {
- assertEquals('innermost function is anonymous', '', frames[0].getName());
- // There are white space differences how browsers convert functions to
- // strings.
- var expected = '(undefined,null,false,0,"",[objectObject],function(){},' +
- 'goog.testing.Mock,sg)';
- assertEquals('arguments of the innermost function (ignoring whitespaces)',
- expected, frames[0].args_.replace(/\s/g, ''));
- assertEquals('test function name', 'testFollowCallChain',
- frames[1].getName());
- }
-
- mock.$verify();
-}
-
-// Create a stack trace string with one modest record and one long record,
-// Verify that all frames are parsed. The length of the long arg is set
-// to blow Firefox 3x's stack if put through a RegExp.
-function testParsingLongStackTrace() {
- var longArg = goog.string.buildString(
- '(', goog.string.repeat('x', 1000000), ')');
- var stackTrace = goog.string.buildString(
- 'shortFrame()@:0\n',
- 'longFrame',
- longArg,
- '@http://google.com/somescript:0\n');
- var frames = goog.testing.stacktrace.parse_(stackTrace);
- assertEquals('number of returned frames', 2, frames.length);
- var expected = new goog.testing.stacktrace.Frame(
- '', 'shortFrame', '', '()', '');
- assertObjectEquals('short frame', expected, frames[0]);
-
- expected = new goog.testing.stacktrace.Frame(
- '', 'longFrame', '', longArg, 'http://google.com/somescript:0');
- assertObjectEquals('exception name only', expected, frames[1]);
-}
-
-</script>
-</body>
-</html>
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/strictmock.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/strictmock.js.svn-base
deleted file mode 100644
index 69914f8..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/strictmock.js.svn-base
+++ /dev/null
@@ -1,128 +0,0 @@
-// Copyright 2008 The Closure Library Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS-IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/**
- * @fileoverview This file defines a strict mock implementation.
- */
-
-goog.provide('goog.testing.StrictMock');
-
-goog.require('goog.array');
-goog.require('goog.testing.Mock');
-
-
-
-/**
- * This is a mock that verifies that methods are called in the order that they
- * are specified during the recording phase. Since it verifies order, it
- * follows 'fail fast' semantics. If it detects a deviation from the
- * expectations, it will throw an exception and not wait for verify to be
- * called.
- * @param {Object} objectToMock The object to mock.
- * @param {boolean=} opt_mockStaticMethods An optional argument denoting that
- * a mock should be constructed from the static functions of a class.
- * @param {boolean=} opt_createProxy An optional argument denoting that
- * a proxy for the target mock should be created.
- * @constructor
- * @extends {goog.testing.Mock}
- */
-goog.testing.StrictMock = function(objectToMock, opt_mockStaticMethods,
- opt_createProxy) {
- goog.testing.Mock.call(this, objectToMock, opt_mockStaticMethods,
- opt_createProxy);
-
- /**
- * An array of MockExpectations.
- * @type {Array.<goog.testing.MockExpectation>}
- * @private
- */
- this.$expectations_ = [];
-};
-goog.inherits(goog.testing.StrictMock, goog.testing.Mock);
-
-
-/** @override */
-goog.testing.StrictMock.prototype.$recordExpectation = function() {
- this.$expectations_.push(this.$pendingExpectation);
-};
-
-
-/** @override */
-goog.testing.StrictMock.prototype.$recordCall = function(name, args) {
- if (this.$expectations_.length == 0) {
- this.$throwCallException(name, args);
- }
-
- // If the current expectation has a different name, make sure it was called
- // enough and then discard it. We're through with it.
- var currentExpectation = this.$expectations_[0];
- while (!this.$verifyCall(currentExpectation, name, args)) {
-
- // This might be an item which has passed its min, and we can now
- // look past it, or it might be below its min and generate an error.
- if (currentExpectation.actualCalls < currentExpectation.minCalls) {
- this.$throwCallException(name, args, currentExpectation);
- }
-
- this.$expectations_.shift();
- if (this.$expectations_.length < 1) {
- // Nothing left, but this may be a failed attempt to call the previous
- // item on the list, which may have been between its min and max.
- this.$throwCallException(name, args, currentExpectation);
- }
- currentExpectation = this.$expectations_[0];
- }
-
- if (currentExpectation.maxCalls == 0) {
- this.$throwCallException(name, args);
- }
-
- currentExpectation.actualCalls++;
- // If we hit the max number of calls for this expectation, we're finished
- // with it.
- if (currentExpectation.actualCalls == currentExpectation.maxCalls) {
- this.$expectations_.shift();
- }
-
- return this.$do(currentExpectation, args);
-};
-
-
-/** @override */
-goog.testing.StrictMock.prototype.$reset = function() {
- goog.testing.StrictMock.superClass_.$reset.call(this);
-
- goog.array.clear(this.$expectations_);
-};
-
-
-/** @override */
-goog.testing.StrictMock.prototype.$verify = function() {
- goog.testing.StrictMock.superClass_.$verify.call(this);
-
- while (this.$expectations_.length > 0) {
- var expectation = this.$expectations_[0];
- if (expectation.actualCalls < expectation.minCalls) {
- this.$throwException('Missing a call to ' + expectation.name +
- '\nExpected: ' + expectation.minCalls + ' but was: ' +
- expectation.actualCalls);
-
- } else {
- // Don't need to check max, that's handled when the call is made
- this.$expectations_.shift();
- }
- }
-};
-
-
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/strictmock_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/strictmock_test.html.svn-base
deleted file mode 100644
index c868dd4..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/strictmock_test.html.svn-base
+++ /dev/null
@@ -1,412 +0,0 @@
-<!DOCTYPE html>
-<html>
-<!--
-Copyright 2008 The Closure Library Authors. All Rights Reserved.
-
-Use of this source code is governed by the Apache License, Version 2.0.
-See the COPYING file for details.
--->
-<head>
-<meta http-equiv="X-UA-Compatible" content="IE=edge">
-<title>Closure Unit Tests - goog.testing.StrictMock</title>
-<script src="../base.js"></script>
-<script>
- goog.require('goog.testing.StrictMock');
- goog.require('goog.testing.jsunit');
-</script>
-</head>
-<body>
-<script>
-
- // The object that we will be mocking
- var RealObject = function() {
- };
-
- RealObject.prototype.a = function() {
- fail('real object should never be called');
- };
-
- RealObject.prototype.b = function() {
- fail('real object should never be called');
- };
-
- RealObject.prototype.c = function() {
- fail('real object should never be called');
- };
-
- var mock;
-
- function setUp() {
- var obj = new RealObject();
- mock = new goog.testing.StrictMock(obj);
- }
-
-
- function testMockFunction() {
- var mock = new goog.testing.StrictMock(RealObject);
- mock.a();
- mock.b();
- mock.c();
- mock.$replay();
- mock.a();
- mock.b();
- mock.c();
- mock.$verify();
-
- mock.$reset();
-
- assertThrows(function() {mock.x()});
- }
-
-
- function testSimpleExpectations() {
- mock.a();
- mock.$replay();
- mock.a();
- mock.$verify();
-
- mock.$reset();
-
- mock.a();
- mock.b();
- mock.a();
- mock.a();
- mock.$replay();
- mock.a();
- mock.b();
- mock.a();
- mock.a();
- mock.$verify();
- }
-
-
- function testFailToSetExpectation() {
- mock.$replay();
- assertThrows(goog.bind(mock.a, mock));
-
- mock.$reset();
-
- mock.$replay();
- assertThrows(goog.bind(mock.b, mock));
- }
-
-
- function testUnexpectedCall() {
- mock.a();
- mock.$replay();
- mock.a();
- assertThrows(goog.bind(mock.a, mock));
-
- mock.$reset();
-
- mock.a();
- mock.$replay();
- assertThrows(goog.bind(mock.b, mock));
- }
-
-
- function testNotEnoughCalls() {
- mock.a();
- mock.$replay();
- assertThrows(goog.bind(mock.$verify, mock));
-
- mock.$reset();
-
- mock.a();
- mock.b();
- mock.$replay();
- mock.a();
- assertThrows(goog.bind(mock.$verify, mock));
- }
-
-
- function testOutOfOrderCalls() {
- mock.a();
- mock.b();
- mock.$replay();
- assertThrows(goog.bind(mock.b, mock));
- }
-
-
- function testVerify() {
- mock.a();
- mock.$replay();
- mock.a();
- mock.$verify();
-
- mock.$reset();
-
- mock.a();
- mock.$replay();
- assertThrows(goog.bind(mock.$verify, mock));
- }
-
-
- function testArgumentMatching() {
- mock.a('foo');
- mock.b('bar');
- mock.$replay();
- mock.a('foo');
- assertThrows(function() {mock.b('foo')});
-
- mock.$reset();
- mock.a('foo');
- mock.a('bar');
- mock.$replay();
- mock.a('foo');
- mock.a('bar');
- mock.$verify();
-
- mock.$reset();
- mock.a('foo');
- mock.a('bar');
- mock.$replay();
- assertThrows(function() {mock.a('bar')});
- }
-
-
- function testReturnValue() {
- mock.a().$returns(5);
- mock.$replay();
-
- assertEquals('Mock should return the right value', 5, mock.a());
-
- mock.$verify();
- }
-
-
- function testAtMostOnce() {
- // Zero times SUCCESS.
- mock.a().$atMostOnce();
- mock.$replay();
- mock.$verify();
-
- mock.$reset();
-
- // One time SUCCESS.
- mock.a().$atMostOnce();
- mock.$replay();
- mock.a();
- mock.$verify();
-
- mock.$reset();
-
- // Many times FAIL.
- mock.a().$atMostOnce();
- mock.$replay();
- mock.a();
- assertThrows(goog.bind(mock.a, mock));
-
- mock.$reset();
-
- // atMostOnce only lasts until a new method is called.
- mock.a().$atMostOnce();
- mock.b();
- mock.a();
- mock.$replay();
- mock.b();
- assertThrows(goog.bind(mock.$verify, mock));
- }
-
-
- function testAtLeastOnce() {
- // atLeastOnce does not mean zero times
- mock.a().$atLeastOnce();
- mock.$replay();
- assertThrows(goog.bind(mock.$verify, mock));
-
- mock.$reset();
-
- // atLeastOnce does mean three times
- mock.a().$atLeastOnce();
- mock.$replay();
- mock.a();
- mock.a();
- mock.a();
- mock.$verify();
-
- mock.$reset();
-
- // atLeastOnce only lasts until a new method is called
- mock.a().$atLeastOnce();
- mock.b();
- mock.a();
- mock.$replay();
- mock.a();
- mock.a();
- mock.b();
- mock.a();
- assertThrows(goog.bind(mock.a, mock));
- }
-
-
- function testAtLeastOnceWithArgs() {
- mock.a('asdf').$atLeastOnce();
- mock.a('qwert');
- mock.$replay();
- mock.a('asdf');
- mock.a('asdf');
- mock.a('qwert');
- mock.$verify();
-
- mock.$reset();
-
- mock.a('asdf').$atLeastOnce();
- mock.a('qwert');
- mock.$replay();
- mock.a('asdf');
- mock.a('asdf');
- assertThrows(function() {mock.a('zxcv')});
- assertThrows(goog.bind(mock.$verify, mock));
- }
-
-
- function testAnyTimes() {
- mock.a().$anyTimes();
- mock.$replay();
- mock.$verify();
-
- mock.$reset();
-
- mock.a().$anyTimes();
- mock.$replay();
- mock.a();
- mock.a();
- mock.a();
- mock.a();
- mock.a();
- mock.$verify();
- }
-
-
- function testAnyTimesWithArguments() {
- mock.a('foo').$anyTimes();
- mock.$replay();
- mock.$verify();
-
- mock.$reset();
-
- mock.a('foo').$anyTimes();
- mock.a('bar').$anyTimes();
- mock.$replay();
- mock.a('foo');
- mock.a('foo');
- mock.a('foo');
- mock.a('bar');
- mock.a('bar');
- mock.$verify();
- }
-
-
- function testZeroTimes() {
- mock.a().$times(0);
- mock.$replay();
- mock.$verify();
-
- mock.$reset();
-
- mock.a().$times(0);
- mock.$replay();
- assertThrows(function() {mock.a()});
- }
-
-
- function testZeroTimesWithArguments() {
- mock.a('foo').$times(0);
- mock.$replay();
- mock.$verify();
-
- mock.$reset();
-
- mock.a('foo').$times(0);
- mock.$replay();
- assertThrows(function() {mock.a('foo')});
- }
-
-
- function testTooManyCalls() {
- mock.a().$times(2);
- mock.$replay();
- mock.a();
- mock.a();
- assertThrows(function() {mock.a()});
- }
-
-
- function testTooManyCallsWithArguments() {
- mock.a('foo').$times(2);
- mock.$replay();
- mock.a('foo');
- mock.a('foo');
- assertThrows(function() {mock.a('foo')});
- }
-
-
- function testMultipleSkippedAnyTimes() {
- mock.a().$anyTimes();
- mock.b().$anyTimes();
- mock.c().$anyTimes();
- mock.$replay();
- mock.c();
- mock.$verify();
- }
-
-
- function testMultipleSkippedAnyTimesWithArguments() {
- mock.a('foo').$anyTimes();
- mock.a('bar').$anyTimes();
- mock.a('baz').$anyTimes();
- mock.$replay();
- mock.a('baz');
- mock.$verify();
- }
-
-
- function testVerifyThrows() {
- mock.a(1);
- mock.$replay();
- mock.a(1);
- try {
- mock.a(2);
- fail('bad mock, should fail');
- } catch (ex) {
- // this could be an event handler, for example
- }
- assertThrows(goog.bind(mock.$verify, mock));
- }
-
-
- function testThrows() {
- mock.a().$throws('exception!');
- mock.$replay();
- assertThrows(goog.bind(mock.a, mock));
- mock.$verify();
- }
-
-
- function testDoes() {
- mock.a(1, 2).$does(function(a, b) {return a + b;});
- mock.$replay();
- assertEquals('Mock should call the function', 3, mock.a(1, 2));
- mock.$verify();
- }
-
- function testErrorMessageForBadArgs() {
- mock.a();
- mock.$anyTimes();
-
- mock.$replay();
-
- var message;
- try {
- mock.a('a');
- } catch (e) {
- message = e.message;
- }
-
- assertTrue('No exception thrown on verify', goog.isDef(message));
- assertContains('Bad arguments to a()', message);
- }
-</script>
-</body>
-</html>
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/testcase.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/testcase.js.svn-base
deleted file mode 100644
index 4d4186c..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/testcase.js.svn-base
+++ /dev/null
@@ -1,1106 +0,0 @@
-// Copyright 2007 The Closure Library Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS-IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/**
- * @fileoverview A class representing a set of test functions to be run.
- *
- * Testing code should not have dependencies outside of goog.testing so as to
- * reduce the chance of masking missing dependencies.
- *
- * This file does not compile correctly with --collapse_properties. Use
- * --property_renaming=ALL_UNQUOTED instead.
- *
- */
-
-goog.provide('goog.testing.TestCase');
-goog.provide('goog.testing.TestCase.Error');
-goog.provide('goog.testing.TestCase.Order');
-goog.provide('goog.testing.TestCase.Result');
-goog.provide('goog.testing.TestCase.Test');
-
-goog.require('goog.testing.asserts');
-goog.require('goog.testing.stacktrace');
-
-
-
-/**
- * A class representing a JsUnit test case. A TestCase is made up of a number
- * of test functions which can be run. Individual test cases can override the
- * following functions to set up their test environment:
- * - runTests - completely override the test's runner
- * - setUpPage - called before any of the test functions are run
- * - tearDownPage - called after all tests are finished
- * - setUp - called before each of the test functions
- * - tearDown - called after each of the test functions
- * - shouldRunTests - called before a test run, all tests are skipped if it
- * returns false. Can be used to disable tests on browsers
- * where they aren't expected to pass.
- *
- * Use {@link #autoDiscoverTests}
- *
- * @param {string=} opt_name The name of the test case, defaults to
- * 'Untitled Test Case'.
- * @constructor
- */
-goog.testing.TestCase = function(opt_name) {
- /**
- * A name for the test case.
- * @type {string}
- * @private
- */
- this.name_ = opt_name || 'Untitled Test Case';
-
- /**
- * Array of test functions that can be executed.
- * @type {Array.<goog.testing.TestCase.Test>}
- * @private
- */
- this.tests_ = [];
-
- /**
- * Set of test names and/or indices to execute, or null if all tests should
- * be executed.
- *
- * Indices are included to allow automation tools to run a subset of the
- * tests without knowing the exact contents of the test file.
- *
- * Indices should only be used with SORTED ordering.
- *
- * Example valid values:
- * <ul>
- * <li>[testName]
- * <li>[testName1, testName2]
- * <li>[2] - will run the 3rd test in the order specified
- * <li>[1,3,5]
- * <li>[testName1, testName2, 3, 5] - will work
- * <ul>
- * @type {Object}
- * @private
- */
- this.testsToRun_ = null;
-
- var search = window.location.search;
-
- // Parse the 'runTests' query parameter into a set of test names and/or
- // test indices.
- var runTestsMatch = search.match(/(?:\?|&)runTests=([^?&]+)/i);
- if (runTestsMatch) {
- this.testsToRun_ = {};
- var arr = runTestsMatch[1].split(',');
- for (var i = 0, len = arr.length; i < len; i++) {
- this.testsToRun_[arr[i]] = 1;
- }
- }
-
- // Checks the URL for a valid order param.
- var orderMatch = search.match(/(?:\?|&)order=(natural|random|sorted)/i);
- if (orderMatch) {
- this.order = orderMatch[1];
- }
-
- /**
- * Object used to encapsulate the test results.
- * @type {goog.testing.TestCase.Result}
- * @protected
- * @suppress {underscore}
- */
- this.result_ = new goog.testing.TestCase.Result(this);
-
- // This silences a compiler warning from the legacy property check, which
- // is deprecated. It idly writes to testRunner properties that are used
- // in this file.
- var testRunnerMethods = {isFinished: true, hasErrors: true};
-};
-
-
-/**
- * The order to run the auto-discovered tests.
- * @enum {string}
- */
-goog.testing.TestCase.Order = {
- /**
- * This is browser dependent and known to be different in FF and Safari
- * compared to others.
- */
- NATURAL: 'natural',
-
- /** Random order. */
- RANDOM: 'random',
-
- /** Sorted based on the name. */
- SORTED: 'sorted'
-};
-
-
-/**
- * The maximum amount of time that the test can run before we force it to be
- * async. This prevents the test runner from blocking the browser and
- * potentially hurting the Selenium test harness.
- * @type {number}
- */
-goog.testing.TestCase.MAX_RUN_TIME = 200;
-
-
-/**
- * The order to run the auto-discovered tests in.
- * @type {string}
- */
-goog.testing.TestCase.prototype.order = goog.testing.TestCase.Order.SORTED;
-
-
-/**
- * Save a reference to window.timeout, so any code that overrides the default
- * behavior (e.g. MockClock) doesn't affect our runner.
- * @type {function((Function|string), number, *=): number}
- * @private
- */
-goog.testing.TestCase.protectedTimeout_ = window.setTimeout;
-
-
-/**
- * Saved string referencing window.setTimeout's string serialization. IE
- * sometimes fails to uphold equality for setTimeout, but the string version
- * stays the same.
- * @type {string}
- * @private
- */
-goog.testing.TestCase.setTimeoutAsString_ = String(window.setTimeout);
-
-
-/**
- * TODO(user) replace this with prototype.currentTest.
- * Name of the current test that is running, or null if none is running.
- * @type {?string}
- */
-goog.testing.TestCase.currentTestName = null;
-
-
-/**
- * Avoid a dependency on goog.userAgent and keep our own reference of whether
- * the browser is IE.
- * @type {boolean}
- */
-goog.testing.TestCase.IS_IE = typeof opera == 'undefined' && !!navigator &&
- navigator.userAgent.indexOf('MSIE') != -1;
-
-
-/**
- * Whether the test case has ever tried to execute.
- * @type {boolean}
- */
-goog.testing.TestCase.prototype.started = false;
-
-
-/**
- * Whether the test case is running.
- * @type {boolean}
- */
-goog.testing.TestCase.prototype.running = false;
-
-
-/**
- * Timestamp for when the test was started.
- * @type {number}
- * @private
- */
-goog.testing.TestCase.prototype.startTime_ = 0;
-
-
-/**
- * Time since the last batch of tests was started, if batchTime exceeds
- * {@link #MAX_RUN_TIME} a timeout will be used to stop the tests blocking the
- * browser and a new batch will be started.
- * @type {number}
- * @private
- */
-goog.testing.TestCase.prototype.batchTime_ = 0;
-
-
-/**
- * Pointer to the current test.
- * @type {number}
- * @private
- */
-goog.testing.TestCase.prototype.currentTestPointer_ = 0;
-
-
-/**
- * Optional callback that will be executed when the test has finalized.
- * @type {Function}
- * @private
- */
-goog.testing.TestCase.prototype.onCompleteCallback_ = null;
-
-
-/**
- * The test runner that is running this case.
- * @type {goog.testing.TestRunner?}
- * @private
- */
-goog.testing.TestCase.prototype.testRunner_ = null;
-
-
-/**
- * Adds a new test to the test case.
- * @param {goog.testing.TestCase.Test} test The test to add.
- */
-goog.testing.TestCase.prototype.add = function(test) {
- this.tests_.push(test);
-};
-
-
-/**
- * Sets the tests.
- * @param {Array.<goog.testing.TestCase.Test>} tests A new test array.
- * @protected
- */
-goog.testing.TestCase.prototype.setTests = function(tests) {
- this.tests_ = tests;
-};
-
-
-/**
- * Gets the tests.
- * @return {Array.<goog.testing.TestCase.Test>} The test array.
- * @protected
- */
-goog.testing.TestCase.prototype.getTests = function() {
- return this.tests_;
-};
-
-
-/**
- * Returns the number of tests contained in the test case.
- * @return {number} The number of tests.
- */
-goog.testing.TestCase.prototype.getCount = function() {
- return this.tests_.length;
-};
-
-
-/**
- * Returns the current test and increments the pointer.
- * @return {goog.testing.TestCase.Test?} The current test case.
- */
-goog.testing.TestCase.prototype.next = function() {
- var test;
- while ((test = this.tests_[this.currentTestPointer_++])) {
- if (!this.testsToRun_ || this.testsToRun_[test.name] ||
- this.testsToRun_[this.currentTestPointer_ - 1]) {
- return test;
- }
- }
- return null;
-};
-
-
-/**
- * Resets the test case pointer, so that next returns the first test.
- */
-goog.testing.TestCase.prototype.reset = function() {
- this.currentTestPointer_ = 0;
- this.result_ = new goog.testing.TestCase.Result(this);
-};
-
-
-/**
- * Sets the callback function that should be executed when the tests have
- * completed.
- * @param {Function} fn The callback function.
- */
-goog.testing.TestCase.prototype.setCompletedCallback = function(fn) {
- this.onCompleteCallback_ = fn;
-};
-
-
-/**
- * Sets the test runner that is running this test case.
- * @param {goog.testing.TestRunner} tr The test runner.
- */
-goog.testing.TestCase.prototype.setTestRunner = function(tr) {
- this.testRunner_ = tr;
-};
-
-
-/**
- * Can be overridden in test classes to indicate whether the tests in a case
- * should be run in that particular situation. For example, this could be used
- * to stop tests running in a particular browser, where browser support for
- * the class under test was absent.
- * @return {boolean} Whether any of the tests in the case should be run.
- */
-goog.testing.TestCase.prototype.shouldRunTests = function() {
- return true;
-};
-
-
-/**
- * Executes each of the tests.
- */
-goog.testing.TestCase.prototype.execute = function() {
- this.started = true;
- this.reset();
- this.startTime_ = this.now_();
- this.running = true;
- this.result_.totalCount = this.getCount();
-
- if (!this.shouldRunTests()) {
- this.log('shouldRunTests() returned false, skipping these tests.');
- this.result_.testSuppressed = true;
- this.finalize();
- return;
- }
-
- this.log('Starting tests: ' + this.name_);
- this.cycleTests();
-};
-
-
-/**
- * Finalizes the test case, called when the tests have finished executing.
- */
-goog.testing.TestCase.prototype.finalize = function() {
- this.saveMessage('Done');
-
- this.tearDownPage();
-
- var restoredSetTimeout =
- goog.testing.TestCase.protectedTimeout_ == window.setTimeout;
- if (!restoredSetTimeout && goog.testing.TestCase.IS_IE &&
- String(window.setTimeout) == goog.testing.TestCase.setTimeoutAsString_) {
- // In strange cases, IE's value of setTimeout *appears* to change, but
- // the string representation stays stable.
- restoredSetTimeout = true;
- }
-
- if (!restoredSetTimeout) {
- var message = 'ERROR: Test did not restore setTimeout';
- this.saveMessage(message);
- var err = new goog.testing.TestCase.Error(this.name_, message);
- this.result_.errors.push(err);
- }
- window.setTimeout = goog.testing.TestCase.protectedTimeout_;
- this.endTime_ = this.now_();
- this.running = false;
- this.result_.runTime = this.endTime_ - this.startTime_;
- this.result_.numFilesLoaded = this.countNumFilesLoaded_();
-
- this.log(this.result_.getSummary());
-
- if (this.result_.isSuccess()) {
- this.log('Tests complete');
- } else {
- this.log('Tests Failed');
- }
- if (this.onCompleteCallback_) {
- var fn = this.onCompleteCallback_;
- // Execute's the completed callback in the context of the global object.
- fn();
- this.onCompleteCallback_ = null;
- }
-};
-
-
-/**
- * Saves a message to the result set.
- * @param {string} message The message to save.
- */
-goog.testing.TestCase.prototype.saveMessage = function(message) {
- this.result_.messages.push(this.getTimeStamp_() + ' ' + message);
-};
-
-
-/**
- * @return {boolean} Whether the test case is running inside the multi test
- * runner.
- */
-goog.testing.TestCase.prototype.isInsideMultiTestRunner = function() {
- var top = goog.global['top'];
- return top && typeof top['_allTests'] != 'undefined';
-};
-
-
-/**
- * Logs an object to the console, if available.
- * @param {*} val The value to log. Will be ToString'd.
- */
-goog.testing.TestCase.prototype.log = function(val) {
- if (!this.isInsideMultiTestRunner() && window.console) {
- if (typeof val == 'string') {
- val = this.getTimeStamp_() + ' : ' + val;
- }
- if (val instanceof Error && val.stack) {
- // Chrome does console.log asynchronously in a different process
- // (http://code.google.com/p/chromium/issues/detail?id=50316).
- // This is an acute problem for Errors, which almost never survive.
- // Grab references to the immutable strings so they survive.
- window.console.log(val, val.message, val.stack);
- // TODO(gboyer): Consider for Chrome cloning any object if we can ensure
- // there are no circular references.
- } else {
- window.console.log(val);
- }
- }
-};
-
-
-/**
- * @return {boolean} Whether the test was a success.
- */
-goog.testing.TestCase.prototype.isSuccess = function() {
- return !!this.result_ && this.result_.isSuccess();
-};
-
-
-/**
- * Returns a string detailing the results from the test.
- * @param {boolean=} opt_verbose If true results will include data about all
- * tests, not just what failed.
- * @return {string} The results from the test.
- */
-goog.testing.TestCase.prototype.getReport = function(opt_verbose) {
- var rv = [];
- if (this.testRunner_ && !this.testRunner_.isFinished()) {
- rv.push(this.name_ + ' [RUNNING]');
- } else {
- var success = this.result_.isSuccess() && !this.testRunner_.hasErrors();
- rv.push(this.name_ + ' [' + (success ? 'PASSED' : 'FAILED') + ']');
- }
- rv.push(this.trimPath_(window.location.href));
- rv.push(this.result_.getSummary());
- if (opt_verbose) {
- rv.push('.', this.result_.messages.join('\n'));
- } else if (!this.result_.isSuccess()) {
- rv.push(this.result_.errors.join('\n'));
- }
- rv.push(' ');
- return rv.join('\n');
-};
-
-
-/**
- * Returns the amount of time it took for the test to run.
- * @return {number} The run time, in milliseconds.
- */
-goog.testing.TestCase.prototype.getRunTime = function() {
- return this.result_.runTime;
-};
-
-
-/**
- * Returns the number of script files that were loaded in order to run the test.
- * @return {number} The number of script files.
- */
-goog.testing.TestCase.prototype.getNumFilesLoaded = function() {
- return this.result_.numFilesLoaded;
-};
-
-
-/**
- * Executes each of the tests.
- * Overridable by the individual test case. This allows test cases to defer
- * when the test is actually started. If overridden, finalize must be called
- * by the test to indicate it has finished.
- */
-goog.testing.TestCase.prototype.runTests = function() {
- this.setUpPage();
- this.execute();
-};
-
-
-/**
- * Reorders the tests depending on the {@code order} field.
- * @param {Array.<goog.testing.TestCase.Test>} tests An array of tests to
- * reorder.
- * @private
- */
-goog.testing.TestCase.prototype.orderTests_ = function(tests) {
- switch (this.order) {
- case goog.testing.TestCase.Order.RANDOM:
- // Fisher-Yates shuffle
- var i = tests.length;
- while (i > 1) {
- // goog.math.randomInt is inlined to reduce dependencies.
- var j = Math.floor(Math.random() * i); // exclusive
- i--;
- var tmp = tests[i];
- tests[i] = tests[j];
- tests[j] = tmp;
- }
- break;
-
- case goog.testing.TestCase.Order.SORTED:
- tests.sort(function(t1, t2) {
- if (t1.name == t2.name) {
- return 0;
- }
- return t1.name < t2.name ? -1 : 1;
- });
- break;
-
- // Do nothing for NATURAL.
- }
-};
-
-
-/**
- * Gets the object with all globals.
- * @param {string=} opt_prefix An optional prefix. If specified, only get things
- * under this prefix.
- * @return {Object} An object with all globals starting with the prefix.
- */
-goog.testing.TestCase.prototype.getGlobals = function(opt_prefix) {
- return goog.testing.TestCase.getGlobals(opt_prefix);
-};
-
-
-/**
- * Gets the object with all globals.
- * @param {string=} opt_prefix An optional prefix. If specified, only get things
- * under this prefix.
- * @return {Object} An object with all globals starting with the prefix.
- */
-goog.testing.TestCase.getGlobals = function(opt_prefix) {
- // Look in the global scope for most browsers, on IE we use the little known
- // RuntimeObject which holds references to all globals. We reference this
- // via goog.global so that there isn't an aliasing that throws an exception
- // in Firefox.
- return typeof goog.global['RuntimeObject'] != 'undefined' ?
- goog.global['RuntimeObject']((opt_prefix || '') + '*') : goog.global;
-};
-
-
-/**
- * Gets called before any tests are executed. Can be overridden to set up the
- * environment for the whole test case.
- */
-goog.testing.TestCase.prototype.setUpPage = function() {};
-
-
-/**
- * Gets called after all tests have been executed. Can be overridden to tear
- * down the entire test case.
- */
-goog.testing.TestCase.prototype.tearDownPage = function() {};
-
-
-/**
- * Gets called before every goog.testing.TestCase.Test is been executed. Can be
- * overridden to add set up functionality to each test.
- */
-goog.testing.TestCase.prototype.setUp = function() {};
-
-
-/**
- * Gets called after every goog.testing.TestCase.Test has been executed. Can be
- * overriden to add tear down functionality to each test.
- */
-goog.testing.TestCase.prototype.tearDown = function() {};
-
-
-/**
- * @return {string} The function name prefix used to auto-discover tests.
- * @protected
- */
-goog.testing.TestCase.prototype.getAutoDiscoveryPrefix = function() {
- return 'test';
-};
-
-
-/**
- * @return {number} Time since the last batch of tests was started.
- * @protected
- */
-goog.testing.TestCase.prototype.getBatchTime = function() {
- return this.batchTime_;
-};
-
-
-/**
- * @param {number} batchTime Time since the last batch of tests was started.
- * @protected
- */
-goog.testing.TestCase.prototype.setBatchTime = function(batchTime) {
- this.batchTime_ = batchTime;
-};
-
-
-/**
- * Creates a {@code goog.testing.TestCase.Test} from an auto-discovered
- * function.
- * @param {string} name The name of the function.
- * @param {function() : void} ref The auto-discovered function.
- * @return {goog.testing.TestCase.Test} The newly created test.
- * @protected
- */
-goog.testing.TestCase.prototype.createTestFromAutoDiscoveredFunction =
- function(name, ref) {
- return new goog.testing.TestCase.Test(name, ref, goog.global);
-};
-
-
-/**
- * Adds any functions defined in the global scope that are prefixed with "test"
- * to the test case. Also overrides setUp, tearDown, setUpPage, tearDownPage
- * and runTests if they are defined.
- */
-goog.testing.TestCase.prototype.autoDiscoverTests = function() {
- var prefix = this.getAutoDiscoveryPrefix();
- var testSource = this.getGlobals(prefix);
-
- var foundTests = [];
-
- for (var name in testSource) {
-
- try {
- var ref = testSource[name];
- } catch (ex) {
- // NOTE(user): When running tests from a file:// URL on Firefox 3.5
- // for Windows, any reference to window.sessionStorage raises
- // an "Operation is not supported" exception. Ignore any exceptions raised
- // by simply accessing global properties.
- }
-
- if ((new RegExp('^' + prefix)).test(name) && goog.isFunction(ref)) {
- foundTests.push(this.createTestFromAutoDiscoveredFunction(name, ref));
- }
- }
-
- this.orderTests_(foundTests);
-
- for (var i = 0; i < foundTests.length; i++) {
- this.add(foundTests[i]);
- }
-
- this.log(this.getCount() + ' tests auto-discovered');
-
- if (goog.global['setUp']) {
- this.setUp = goog.bind(goog.global['setUp'], goog.global);
- }
- if (goog.global['tearDown']) {
- this.tearDown = goog.bind(goog.global['tearDown'], goog.global);
- }
- if (goog.global['setUpPage']) {
- this.setUpPage = goog.bind(goog.global['setUpPage'], goog.global);
- }
- if (goog.global['tearDownPage']) {
- this.tearDownPage = goog.bind(goog.global['tearDownPage'], goog.global);
- }
- if (goog.global['runTests']) {
- this.runTests = goog.bind(goog.global['runTests'], goog.global);
- }
- if (goog.global['shouldRunTests']) {
- this.shouldRunTests = goog.bind(goog.global['shouldRunTests'], goog.global);
- }
-};
-
-
-/**
- * Cycles through the tests, breaking out using a setTimeout if the execution
- * time has execeeded {@link #MAX_RUN_TIME}.
- */
-goog.testing.TestCase.prototype.cycleTests = function() {
- this.saveMessage('Start');
- this.batchTime_ = this.now_();
- var nextTest;
- while ((nextTest = this.next()) && this.running) {
- this.result_.runCount++;
- // Execute the test and handle the error, we execute all tests rather than
- // stopping after a single error.
- var cleanedUp = false;
-
- try {
- this.log('Running test: ' + nextTest.name);
-
- goog.testing.TestCase.currentTestName = nextTest.name;
- this.setUp();
- nextTest.execute();
- this.tearDown();
- goog.testing.TestCase.currentTestName = null;
-
- cleanedUp = true;
-
- this.doSuccess(nextTest);
- } catch (e) {
- this.doError(nextTest, e);
-
- if (!cleanedUp) {
- try {
- this.tearDown();
- } catch (e2) {} // Fail silently if tearDown is throwing the errors.
- }
- }
-
- // If the max run time is exceeded call this function again async so as not
- // to block the browser.
- if (this.currentTestPointer_ < this.tests_.length &&
- this.now_() - this.batchTime_ > goog.testing.TestCase.MAX_RUN_TIME) {
- this.saveMessage('Breaking async');
- this.timeout(goog.bind(this.cycleTests, this), 100);
- return;
- }
- }
- // Tests are done.
- this.finalize();
-};
-
-
-/**
- * Counts the number of files that were loaded for dependencies that are
- * required to run the test.
- * @return {number} The number of files loaded.
- * @private
- */
-goog.testing.TestCase.prototype.countNumFilesLoaded_ = function() {
- var scripts = document.getElementsByTagName('script');
- var count = 0;
- for (var i = 0, n = scripts.length; i < n; i++) {
- if (scripts[i].src) {
- count++;
- }
- }
- return count;
-};
-
-
-/**
- * Calls a function after a delay, using the protected timeout.
- * @param {Function} fn The function to call.
- * @param {number} time Delay in milliseconds.
- * @return {number} The timeout id.
- * @protected
- */
-goog.testing.TestCase.prototype.timeout = function(fn, time) {
- var protectedTimeout = goog.testing.TestCase.protectedTimeout_;
- return protectedTimeout(fn, time);
-};
-
-
-/**
- * @return {number} The current time in milliseconds, don't use goog.now as some
- * tests override it.
- * @private
- */
-goog.testing.TestCase.prototype.now_ = function() {
- return new Date().getTime();
-};
-
-
-/**
- * Returns the current time.
- * @return {string} HH:MM:SS.
- * @private
- */
-goog.testing.TestCase.prototype.getTimeStamp_ = function() {
- var d = new Date;
-
- // Ensure millis are always 3-digits
- var millis = '00' + d.getMilliseconds();
- millis = millis.substr(millis.length - 3);
-
- return this.pad_(d.getHours()) + ':' + this.pad_(d.getMinutes()) + ':' +
- this.pad_(d.getSeconds()) + '.' + millis;
-};
-
-
-/**
- * Pads a number to make it have a leading zero if it's less than 10.
- * @param {number} number The number to pad.
- * @return {string} The resulting string.
- * @private
- */
-goog.testing.TestCase.prototype.pad_ = function(number) {
- return number < 10 ? '0' + number : String(number);
-};
-
-
-/**
- * Trims a path to be only that after google3.
- * @param {string} path The path to trim.
- * @return {string} The resulting string.
- * @private
- */
-goog.testing.TestCase.prototype.trimPath_ = function(path) {
- return path.substring(path.indexOf('google3') + 8);
-};
-
-
-/**
- * Handles a test that passed.
- * @param {goog.testing.TestCase.Test} test The test that passed.
- * @protected
- */
-goog.testing.TestCase.prototype.doSuccess = function(test) {
- this.result_.successCount++;
- var message = test.name + ' : PASSED';
- this.saveMessage(message);
- this.log(message);
-};
-
-
-/**
- * Handles a test that failed.
- * @param {goog.testing.TestCase.Test} test The test that failed.
- * @param {*=} opt_e The exception object associated with the
- * failure or a string.
- * @protected
- */
-goog.testing.TestCase.prototype.doError = function(test, opt_e) {
- var message = test.name + ' : FAILED';
- this.log(message);
- this.saveMessage(message);
- var err = this.logError(test.name, opt_e);
- this.result_.errors.push(err);
-};
-
-
-/**
- * @param {string} name Failed test name.
- * @param {*=} opt_e The exception object associated with the
- * failure or a string.
- * @return {goog.testing.TestCase.Error} Error object.
- */
-goog.testing.TestCase.prototype.logError = function(name, opt_e) {
- var errMsg = null;
- var stack = null;
- if (opt_e) {
- this.log(opt_e);
- if (goog.isString(opt_e)) {
- errMsg = opt_e;
- } else {
- errMsg = opt_e.message || opt_e.description || opt_e.toString();
- stack = opt_e.stack ? goog.testing.stacktrace.canonicalize(opt_e.stack) :
- opt_e['stackTrace'];
- }
- } else {
- errMsg = 'An unknown error occurred';
- }
- var err = new goog.testing.TestCase.Error(name, errMsg, stack);
-
- // Avoid double logging.
- if (!opt_e || !opt_e['isJsUnitException'] ||
- !opt_e['loggedJsUnitException']) {
- this.saveMessage(err.toString());
- }
- if (opt_e && opt_e['isJsUnitException']) {
- opt_e['loggedJsUnitException'] = true;
- }
-
- return err;
-};
-
-
-
-/**
- * A class representing a single test function.
- * @param {string} name The test name.
- * @param {Function} ref Reference to the test function.
- * @param {Object=} opt_scope Optional scope that the test function should be
- * called in.
- * @constructor
- */
-goog.testing.TestCase.Test = function(name, ref, opt_scope) {
- /**
- * The name of the test.
- * @type {string}
- */
- this.name = name;
-
- /**
- * Reference to the test function.
- * @type {Function}
- */
- this.ref = ref;
-
- /**
- * Scope that the test function should be called in.
- * @type {Object}
- */
- this.scope = opt_scope || null;
-};
-
-
-/**
- * Executes the test function.
- */
-goog.testing.TestCase.Test.prototype.execute = function() {
- this.ref.call(this.scope);
-};
-
-
-
-/**
- * A class for representing test results. A bag of public properties.
- * @param {goog.testing.TestCase} testCase The test case that owns this result.
- * @constructor
- */
-goog.testing.TestCase.Result = function(testCase) {
-
- /**
- * The test case that owns this result.
- * @type {goog.testing.TestCase}
- * @private
- */
- this.testCase_ = testCase;
-
- /**
- * Total number of tests that should have been run.
- * @type {number}
- */
- this.totalCount = 0;
-
- /**
- * Total number of tests that were actually run.
- * @type {number}
- */
- this.runCount = 0;
-
- /**
- * Number of successful tests.
- * @type {number}
- */
- this.successCount = 0;
-
- /**
- * The amount of time the tests took to run.
- * @type {number}
- */
- this.runTime = 0;
-
- /**
- * The number of files loaded to run this test.
- * @type {number}
- */
- this.numFilesLoaded = 0;
-
- /**
- * Whether this test case was suppressed by shouldRunTests() returning false.
- * @type {boolean}
- */
- this.testSuppressed = false;
-
- /**
- * Errors encountered while running the test.
- * @type {Array.<goog.testing.TestCase.Error>}
- */
- this.errors = [];
-
- /**
- * Messages to show the user after running the test.
- * @type {Array.<string>}
- */
- this.messages = [];
-};
-
-
-/**
- * @return {boolean} Whether the test was successful.
- */
-goog.testing.TestCase.Result.prototype.isSuccess = function() {
- var noErrors = this.runCount == this.successCount && this.errors.length == 0;
- if (noErrors && !this.testSuppressed && this.isStrict()) {
- return this.runCount > 0;
- }
- return noErrors;
-};
-
-
-/**
- * @return {string} A summary of the tests, including total number of tests that
- * passed, failed, and the time taken.
- */
-goog.testing.TestCase.Result.prototype.getSummary = function() {
- var summary = this.runCount + ' of ' + this.totalCount + ' tests run in ' +
- this.runTime + 'ms.\n';
- if (this.testSuppressed) {
- summary += 'Tests not run because shouldRunTests() returned false.';
- } else if (this.runCount == 0) {
- summary += 'No tests found. ';
- if (this.isStrict()) {
- summary +=
- 'Call G_testRunner.setStrict(false) if this is expected behavior. ';
- }
- } else {
- summary += this.successCount + ' passed, ' +
- (this.totalCount - this.successCount) + ' failed.\n' +
- Math.round(this.runTime / this.runCount) + ' ms/test. ' +
- this.numFilesLoaded + ' files loaded.';
- }
-
- return summary;
-};
-
-
-/**
- * Initializes the given test case with the global test runner 'G_testRunner'.
- * @param {goog.testing.TestCase} testCase The test case to install.
- */
-goog.testing.TestCase.initializeTestRunner = function(testCase) {
- testCase.autoDiscoverTests();
- var gTestRunner = goog.global['G_testRunner'];
- if (gTestRunner) {
- gTestRunner['initialize'](testCase);
- } else {
- throw Error('G_testRunner is undefined. Please ensure goog.testing.jsunit' +
- 'is included.');
- }
-};
-
-
-/**
- * Determines whether the test result should report failure if no tests are run.
- * @return {boolean} Whether this is strict.
- */
-goog.testing.TestCase.Result.prototype.isStrict = function() {
- return this.testCase_.testRunner_.isStrict();
-};
-
-
-
-/**
- * A class representing an error thrown by the test
- * @param {string} source The name of the test which threw the error.
- * @param {string} message The error message.
- * @param {string=} opt_stack A string showing the execution stack.
- * @constructor
- */
-goog.testing.TestCase.Error = function(source, message, opt_stack) {
- /**
- * The name of the test which threw the error.
- * @type {string}
- */
- this.source = source;
-
- /**
- * Reference to the test function.
- * @type {string}
- */
- this.message = message;
-
- /**
- * Scope that the test function should be called in.
- * @type {?string}
- */
- this.stack = opt_stack || null;
-};
-
-
-/**
- * Returns a string representing the error object.
- * @return {string} A string representation of the error.
- */
-goog.testing.TestCase.Error.prototype.toString = function() {
- return 'ERROR in ' + this.source + '\n' +
- this.message + (this.stack ? '\n' + this.stack : '');
-};
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/testqueue.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/testqueue.js.svn-base
deleted file mode 100644
index e070130..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/testqueue.js.svn-base
+++ /dev/null
@@ -1,66 +0,0 @@
-// Copyright 2007 The Closure Library Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS-IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/**
- * @fileoverview Generic queue for writing unit tests.
- */
-
-goog.provide('goog.testing.TestQueue');
-
-
-
-/**
- * Generic queue for writing unit tests
- * @constructor
- */
-goog.testing.TestQueue = function() {
- /**
- * Events that have accumulated
- * @type {Array.<Object>}
- * @private
- */
- this.events_ = [];
-};
-
-
-/**
- * Adds a new event onto the queue.
- * @param {Object} event The event to queue.
- */
-goog.testing.TestQueue.prototype.enqueue = function(event) {
- this.events_.push(event);
-};
-
-
-/**
- * Returns whether the queue is empty.
- * @return {boolean} Whether the queue is empty.
- */
-goog.testing.TestQueue.prototype.isEmpty = function() {
- return this.events_.length == 0;
-};
-
-
-/**
- * Gets the next event from the queue. Throws an exception if the queue is
- * empty.
- * @param {string=} opt_comment Comment if the queue is empty.
- * @return {Object} The next event from the queue.
- */
-goog.testing.TestQueue.prototype.dequeue = function(opt_comment) {
- if (this.isEmpty()) {
- throw Error('Handler is empty: ' + opt_comment);
- }
- return this.events_.shift();
-};
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/testrunner.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/testrunner.js.svn-base
deleted file mode 100644
index a80743a..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/.svn/text-base/testrunner.js.svn-base
+++ /dev/null
@@ -1,391 +0,0 @@
-// Copyright 2007 The Closure Library Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS-IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/**
- * @fileoverview The test runner is a singleton object that is used to execute
- * a goog.testing.TestCases, display the results, and expose the results to
- * Selenium for automation. If a TestCase hasn't been registered with the
- * runner by the time window.onload occurs, the testRunner will try to auto-
- * discover JsUnit style test pages.
- *
- * The hooks for selenium are :-
- * - Boolean G_testRunner.isFinished()
- * - Boolean G_testRunner.isSuccess()
- * - String G_testRunner.getReport()
- * - number G_testRunner.getRunTime()
- *
- * Testing code should not have dependencies outside of goog.testing so as to
- * reduce the chance of masking missing dependencies.
- *
- */
-
-goog.provide('goog.testing.TestRunner');
-
-goog.require('goog.testing.TestCase');
-
-
-
-/**
- * Construct a test runner.
- *
- * NOTE(user): This is currently pretty weird, I'm essentially trying to
- * create a wrapper that the Selenium test can hook into to query the state of
- * the running test case, while making goog.testing.TestCase general.
- *
- * @constructor
- */
-goog.testing.TestRunner = function() {
- /**
- * Errors that occurred in the window.
- * @type {Array.<string>}
- */
- this.errors = [];
-};
-
-
-/**
- * Reference to the active test case.
- * @type {goog.testing.TestCase?}
- */
-goog.testing.TestRunner.prototype.testCase = null;
-
-
-/**
- * Whether the test runner has been initialized yet.
- * @type {boolean}
- */
-goog.testing.TestRunner.prototype.initialized = false;
-
-
-/**
- * Element created in the document to add test results to.
- * @type {Element}
- * @private
- */
-goog.testing.TestRunner.prototype.logEl_ = null;
-
-
-/**
- * Function to use when filtering errors.
- * @type {(function(string))?}
- * @private
- */
-goog.testing.TestRunner.prototype.errorFilter_ = null;
-
-
-/**
- * Whether an empty test case counts as an error.
- * @type {boolean}
- * @private
- */
-goog.testing.TestRunner.prototype.strict_ = true;
-
-
-/**
- * Initializes the test runner.
- * @param {goog.testing.TestCase} testCase The test case to initialize with.
- */
-goog.testing.TestRunner.prototype.initialize = function(testCase) {
- if (!this.logEl_) {
- var el = document.getElementById('closureTestRunnerLog');
- if (el == null) {
- el = document.createElement('div');
- document.body.appendChild(el);
- }
- this.logEl_ = el;
- }
-
- if (this.testCase && this.testCase.running) {
- throw Error('The test runner is already waiting for a test to complete');
- }
- this.testCase = testCase;
- testCase.setTestRunner(this);
- this.initialized = true;
-};
-
-
-/**
- * By default, the test runner is strict, and fails if it runs an empty
- * test case.
- * @param {boolean} strict Whether the test runner should fail on an empty
- * test case.
- */
-goog.testing.TestRunner.prototype.setStrict = function(strict) {
- this.strict_ = strict;
-};
-
-
-/**
- * @return {boolean} Whether the test runner should fail on an empty
- * test case.
- */
-goog.testing.TestRunner.prototype.isStrict = function() {
- return this.strict_;
-};
-
-
-/**
- * Returns true if the test runner is initialized.
- * Used by Selenium Hooks.
- * @return {boolean} Whether the test runner is active.
- */
-goog.testing.TestRunner.prototype.isInitialized = function() {
- return this.initialized;
-};
-
-
-/**
- * Returns true if the test runner is finished.
- * Used by Selenium Hooks.
- * @return {boolean} Whether the test runner is active.
- */
-goog.testing.TestRunner.prototype.isFinished = function() {
- return this.errors.length > 0 ||
- this.initialized && !!this.testCase && this.testCase.started &&
- !this.testCase.running;
-};
-
-
-/**
- * Returns true if the test case didn't fail.
- * Used by Selenium Hooks.
- * @return {boolean} Whether the current test returned successfully.
- */
-goog.testing.TestRunner.prototype.isSuccess = function() {
- return !this.hasErrors() && !!this.testCase && this.testCase.isSuccess();
-};
-
-
-/**
- * Returns true if the test case runner has errors that were caught outside of
- * the test case.
- * @return {boolean} Whether there were JS errors.
- */
-goog.testing.TestRunner.prototype.hasErrors = function() {
- return this.errors.length > 0;
-};
-
-
-/**
- * Logs an error that occurred. Used in the case of environment setting up
- * an onerror handler.
- * @param {string} msg Error message.
- */
-goog.testing.TestRunner.prototype.logError = function(msg) {
- if (!this.errorFilter_ || this.errorFilter_.call(null, msg)) {
- this.errors.push(msg);
- }
-};
-
-
-/**
- * Log failure in current running test.
- * @param {Error} ex Exception.
- */
-goog.testing.TestRunner.prototype.logTestFailure = function(ex) {
- var testName = /** @type {string} */ goog.testing.TestCase.currentTestName;
- if (this.testCase) {
- this.testCase.logError(testName, ex);
- } else {
- // NOTE: Do not forget to log the original exception raised.
- throw new Error('Test runner not initialized with a test case. Original ' +
- 'exception: ' + ex.message);
- }
-};
-
-
-/**
- * Sets a function to use as a filter for errors.
- * @param {function(string)} fn Filter function.
- */
-goog.testing.TestRunner.prototype.setErrorFilter = function(fn) {
- this.errorFilter_ = fn;
-};
-
-
-/**
- * Returns a report of the test case that ran.
- * Used by Selenium Hooks.
- * @param {boolean=} opt_verbose If true results will include data about all
- * tests, not just what failed.
- * @return {string} A report summary of the test.
- */
-goog.testing.TestRunner.prototype.getReport = function(opt_verbose) {
- var report = [];
- if (this.testCase) {
- report.push(this.testCase.getReport(opt_verbose));
- }
- if (this.errors.length > 0) {
- report.push('JavaScript errors detected by test runner:');
- report.push.apply(report, this.errors);
- report.push('\n');
- }
- return report.join('\n');
-};
-
-
-/**
- * Returns the amount of time it took for the test to run.
- * Used by Selenium Hooks.
- * @return {number} The run time, in milliseconds.
- */
-goog.testing.TestRunner.prototype.getRunTime = function() {
- return this.testCase ? this.testCase.getRunTime() : 0;
-};
-
-
-/**
- * Returns the number of script files that were loaded in order to run the test.
- * @return {number} The number of script files.
- */
-goog.testing.TestRunner.prototype.getNumFilesLoaded = function() {
- return this.testCase ? this.testCase.getNumFilesLoaded() : 0;
-};
-
-
-/**
- * Executes a test case and prints the results to the window.
- */
-goog.testing.TestRunner.prototype.execute = function() {
- if (!this.testCase) {
- throw Error('The test runner must be initialized with a test case before ' +
- 'execute can be called.');
- }
- this.testCase.setCompletedCallback(goog.bind(this.onComplete_, this));
- this.testCase.runTests();
-};
-
-
-/**
- * Writes the results to the document when the test case completes.
- * @private
- */
-goog.testing.TestRunner.prototype.onComplete_ = function() {
- var log = this.testCase.getReport(true);
- if (this.errors.length > 0) {
- log += '\n' + this.errors.join('\n');
- }
-
- // Remove all children from the log element.
- var logEl = this.logEl_;
- while (logEl.firstChild) {
- logEl.removeChild(logEl.firstChild);
- }
-
- this.writeLog(log);
-
- var runAgainLink = document.createElement('a');
- runAgainLink.style.display = 'block';
- runAgainLink.style.fontSize = 'small';
- runAgainLink.href = '';
- runAgainLink.onclick = goog.bind(function() {
- this.execute();
- return false;
- }, this);
- runAgainLink.innerHTML = 'Run again without reloading';
- logEl.appendChild(runAgainLink);
-};
-
-
-/**
- * Writes a nicely formatted log out to the document.
- * @param {string} log The string to write.
- */
-goog.testing.TestRunner.prototype.writeLog = function(log) {
- var lines = log.split('\n');
- for (var i = 0; i < lines.length; i++) {
- var line = lines[i];
- var color;
- var isFailOrError = /FAILED/.test(line) || /ERROR/.test(line);
- if (/PASSED/.test(line)) {
- color = 'darkgreen';
- } else if (isFailOrError) {
- color = 'darkred';
- } else {
- color = '#333';
- }
- var div = document.createElement('div');
- if (line.substr(0, 2) == '> ') {
- // The stack trace may contain links so it has to be interpreted as HTML.
- div.innerHTML = line;
- } else {
- div.appendChild(document.createTextNode(line));
- }
-
- if (isFailOrError) {
- var testNameMatch = /(\S+) (\[[^\]]*] )?: (FAILED|ERROR)/.exec(line);
- if (testNameMatch) {
- // Build a URL to run the test individually. If this test was already
- // part of another subset test, we need to overwrite the old runTests
- // query parameter. We also need to do this without bringing in any
- // extra dependencies, otherwise we could mask missing dependency bugs.
- var newSearch = 'runTests=' + testNameMatch[1];
- var search = window.location.search;
- if (search) {
- var oldTests = /runTests=([^&]*)/.exec(search);
- if (oldTests) {
- newSearch = search.substr(0, oldTests.index) +
- newSearch +
- search.substr(oldTests.index + oldTests[0].length);
- } else {
- newSearch = search + '&' + newSearch;
- }
- } else {
- newSearch = '?' + newSearch;
- }
- var href = window.location.href;
- var hash = window.location.hash;
- if (hash && hash.charAt(0) != '#') {
- hash = '#' + hash;
- }
- href = href.split('#')[0].split('?')[0] + newSearch + hash;
-
- // Add the link.
- var a = document.createElement('A');
- a.innerHTML = '(run individually)';
- a.style.fontSize = '0.8em';
- a.href = href;
- div.appendChild(document.createTextNode(' '));
- div.appendChild(a);
- }
- }
-
- div.style.color = color;
- div.style.font = 'normal 100% monospace';
-
- try {
- div.style.whiteSpace = 'pre-wrap';
- } catch (e) {
- // NOTE(user): IE raises an exception when assigning to pre-wrap.
- // Thankfully, it doesn't collapse whitespace when using monospace fonts,
- // so it will display correctly if we ignore the exception.
- }
-
- if (i < 2) {
- div.style.fontWeight = 'bold';
- }
- this.logEl_.appendChild(div);
- }
-};
-
-
-/**
- * Logs a message to the current test case.
- * @param {string} s The text to output to the log.
- */
-goog.testing.TestRunner.prototype.log = function(s) {
- if (this.testCase) {
- this.testCase.log(s);
- }
-};
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/asserts.js b/contexts/data/lib/closure-library/closure/goog/testing/asserts.js
index 66810a1..bdf7b19 100644
--- a/contexts/data/lib/closure-library/closure/goog/testing/asserts.js
+++ b/contexts/data/lib/closure-library/closure/goog/testing/asserts.js
@@ -45,7 +45,31 @@ var PRIMITIVE_EQUALITY_PREDICATES = {
};
-function _trueTypeOf(something) {
+/**
+ * Compares equality of two numbers, allowing them to differ up to a given
+ * tolerance.
+ * @param {number} var1 A number.
+ * @param {number} var2 A number.
+ * @param {number} tolerance the maximum allowed difference.
+ * @return {boolean} Whether the two variables are sufficiently close.
+ * @private
+ */
+goog.testing.asserts.numberRoughEqualityPredicate_ = function(
+ var1, var2, tolerance) {
+ return Math.abs(var1 - var2) <= tolerance;
+};
+
+
+/**
+ * @type {Object.<string, function(*, *, number): boolean>}
+ * @private
+ */
+goog.testing.asserts.primitiveRoughEqualityPredicates_ = {
+ 'Number': goog.testing.asserts.numberRoughEqualityPredicate_
+};
+
+
+var _trueTypeOf = function(something) {
var result = typeof something;
try {
switch (result) {
@@ -100,58 +124,111 @@ function _trueTypeOf(something) {
result = result.substr(0, 1).toUpperCase() + result.substr(1);
}
return result;
-}
+};
-function _displayStringForValue(aVar) {
- var result = '<' + aVar + '>';
+var _displayStringForValue = function(aVar) {
+ var result;
+ try {
+ result = '<' + String(aVar) + '>';
+ } catch (ex) {
+ result = '<toString failed: ' + ex.message + '>';
+ // toString does not work on this object :-(
+ }
if (!(aVar === null || aVar === JSUNIT_UNDEFINED_VALUE)) {
result += ' (' + _trueTypeOf(aVar) + ')';
}
return result;
-}
+};
-function fail(failureMessage) {
- goog.testing.asserts.raiseException_('Call to fail()', failureMessage);
-}
+var fail = function(failureMessage) {
+ goog.testing.asserts.raiseException('Call to fail()', failureMessage);
+};
-function argumentsIncludeComments(expectedNumberOfNonCommentArgs, args) {
+var argumentsIncludeComments = function(expectedNumberOfNonCommentArgs, args) {
return args.length == expectedNumberOfNonCommentArgs + 1;
-}
+};
-function commentArg(expectedNumberOfNonCommentArgs, args) {
+var commentArg = function(expectedNumberOfNonCommentArgs, args) {
if (argumentsIncludeComments(expectedNumberOfNonCommentArgs, args)) {
return args[0];
}
return null;
-}
+};
-function nonCommentArg(desiredNonCommentArgIndex,
+var nonCommentArg = function(desiredNonCommentArgIndex,
expectedNumberOfNonCommentArgs, args) {
return argumentsIncludeComments(expectedNumberOfNonCommentArgs, args) ?
args[desiredNonCommentArgIndex] :
args[desiredNonCommentArgIndex - 1];
-}
+};
-function _validateArguments(expectedNumberOfNonCommentArgs, args) {
+var _validateArguments = function(expectedNumberOfNonCommentArgs, args) {
var valid = args.length == expectedNumberOfNonCommentArgs ||
args.length == expectedNumberOfNonCommentArgs + 1 &&
goog.isString(args[0]);
_assert(null, valid, 'Incorrect arguments passed to assert function');
-}
+};
-function _assert(comment, booleanValue, failureMessage) {
+var _assert = function(comment, booleanValue, failureMessage) {
if (!booleanValue) {
- goog.testing.asserts.raiseException_(comment, failureMessage);
+ goog.testing.asserts.raiseException(comment, failureMessage);
}
-}
+};
/**
- * @param {*} a
- * @param {*=} opt_b
+ * @param {*} expected The expected value.
+ * @param {*} actual The actual value.
+ * @return {string} A failure message of the values don't match.
+ * @private
*/
-function assert(a, opt_b) {
+goog.testing.asserts.getDefaultErrorMsg_ = function(expected, actual) {
+ var msg = 'Expected ' + _displayStringForValue(expected) + ' but was ' +
+ _displayStringForValue(actual);
+ if ((typeof expected == 'string') && (typeof actual == 'string')) {
+ // Try to find a human-readable difference.
+ var limit = Math.min(expected.length, actual.length);
+ var commonPrefix = 0;
+ while (commonPrefix < limit &&
+ expected.charAt(commonPrefix) == actual.charAt(commonPrefix)) {
+ commonPrefix++;
+ }
+
+ var commonSuffix = 0;
+ while (commonSuffix < limit &&
+ expected.charAt(expected.length - commonSuffix - 1) ==
+ actual.charAt(actual.length - commonSuffix - 1)) {
+ commonSuffix++;
+ }
+
+ if (commonPrefix + commonSuffix > limit) {
+ commonSuffix = 0;
+ }
+
+ if (commonPrefix > 2 || commonSuffix > 2) {
+ var printString = function(str) {
+ var startIndex = Math.max(0, commonPrefix - 2);
+ var endIndex = Math.min(str.length, str.length - (commonSuffix - 2));
+ return (startIndex > 0 ? '...' : '') +
+ str.substring(startIndex, endIndex) +
+ (endIndex < str.length ? '...' : '');
+ };
+
+ msg += '\nDifference was at position ' + commonPrefix +
+ '. Expected [' + printString(expected) +
+ '] vs. actual [' + printString(actual) + ']';
+ }
+ }
+ return msg;
+};
+
+
+/**
+ * @param {*} a The value to assert (1 arg) or debug message (2 args).
+ * @param {*=} opt_b The value to assert (2 args only).
+ */
+var assert = function(a, opt_b) {
_validateArguments(1, arguments);
var comment = commentArg(1, arguments);
var booleanValue = nonCommentArg(1, 1, arguments);
@@ -159,7 +236,7 @@ function assert(a, opt_b) {
_assert(comment, goog.isBoolean(booleanValue),
'Bad argument to assert(boolean)');
_assert(comment, booleanValue, 'Call to assert(boolean) with false');
-}
+};
/**
@@ -171,7 +248,7 @@ function assert(a, opt_b) {
* @return {*} The error thrown by the function.
* @throws {goog.testing.JsUnitException} If the assertion failed.
*/
-function assertThrows(a, opt_b) {
+var assertThrows = function(a, opt_b) {
_validateArguments(1, arguments);
var func = nonCommentArg(1, 1, arguments);
var comment = commentArg(1, arguments);
@@ -190,9 +267,9 @@ function assertThrows(a, opt_b) {
}
return e;
}
- goog.testing.asserts.raiseException_(comment,
+ goog.testing.asserts.raiseException(comment,
'No exception thrown from function passed to assertThrows');
-}
+};
/**
@@ -203,7 +280,7 @@ function assertThrows(a, opt_b) {
* {@code assertNotThrows} was the comment).
* @throws {goog.testing.JsUnitException} If the assertion failed.
*/
-function assertNotThrows(a, opt_b) {
+var assertNotThrows = function(a, opt_b) {
_validateArguments(1, arguments);
var comment = commentArg(1, arguments);
var func = nonCommentArg(1, 1, arguments);
@@ -219,9 +296,9 @@ function assertNotThrows(a, opt_b) {
// Some browsers don't have a stack trace so at least have the error
// description.
var stackTrace = e['stack'] || e['stacktrace'] || e.toString();
- goog.testing.asserts.raiseException_(comment, stackTrace);
+ goog.testing.asserts.raiseException(comment, stackTrace);
}
-}
+};
/**
@@ -233,7 +310,7 @@ function assertNotThrows(a, opt_b) {
* @param {string=} opt_expectedMessage Failure message expected to be given
* with the exception.
*/
-function assertThrowsJsUnitException(callback, opt_expectedMessage) {
+var assertThrowsJsUnitException = function(callback, opt_expectedMessage) {
var failed = false;
try {
goog.testing.asserts.callWithoutLogging(callback);
@@ -251,14 +328,14 @@ function assertThrowsJsUnitException(callback, opt_expectedMessage) {
if (!failed) {
fail('Expected a failure: ' + opt_expectedMessage);
}
-}
+};
/**
- * @param {*} a
- * @param {*=} opt_b
+ * @param {*} a The value to assert (1 arg) or debug message (2 args).
+ * @param {*=} opt_b The value to assert (2 args only).
*/
-function assertTrue(a, opt_b) {
+var assertTrue = function(a, opt_b) {
_validateArguments(1, arguments);
var comment = commentArg(1, arguments);
var booleanValue = nonCommentArg(1, 1, arguments);
@@ -266,14 +343,14 @@ function assertTrue(a, opt_b) {
_assert(comment, goog.isBoolean(booleanValue),
'Bad argument to assertTrue(boolean)');
_assert(comment, booleanValue, 'Call to assertTrue(boolean) with false');
-}
+};
/**
- * @param {*} a
- * @param {*=} opt_b
+ * @param {*} a The value to assert (1 arg) or debug message (2 args).
+ * @param {*=} opt_b The value to assert (2 args only).
*/
-function assertFalse(a, opt_b) {
+var assertFalse = function(a, opt_b) {
_validateArguments(1, arguments);
var comment = commentArg(1, arguments);
var booleanValue = nonCommentArg(1, 1, arguments);
@@ -281,133 +358,130 @@ function assertFalse(a, opt_b) {
_assert(comment, goog.isBoolean(booleanValue),
'Bad argument to assertFalse(boolean)');
_assert(comment, !booleanValue, 'Call to assertFalse(boolean) with true');
-}
+};
/**
- * @param {*} a
- * @param {*} b
- * @param {*=} opt_c
+ * @param {*} a The expected value (2 args) or the debug message (3 args).
+ * @param {*} b The actual value (2 args) or the expected value (3 args).
+ * @param {*=} opt_c The actual value (3 args only).
*/
-function assertEquals(a, b, opt_c) {
+var assertEquals = function(a, b, opt_c) {
_validateArguments(2, arguments);
var var1 = nonCommentArg(1, 2, arguments);
var var2 = nonCommentArg(2, 2, arguments);
_assert(commentArg(2, arguments), var1 === var2,
- 'Expected ' + _displayStringForValue(var1) + ' but was ' +
- _displayStringForValue(var2));
-}
+ goog.testing.asserts.getDefaultErrorMsg_(var1, var2));
+};
/**
- * @param {*} a
- * @param {*} b
- * @param {*=} opt_c
+ * @param {*} a The expected value (2 args) or the debug message (3 args).
+ * @param {*} b The actual value (2 args) or the expected value (3 args).
+ * @param {*=} opt_c The actual value (3 args only).
*/
-function assertNotEquals(a, b, opt_c) {
+var assertNotEquals = function(a, b, opt_c) {
_validateArguments(2, arguments);
var var1 = nonCommentArg(1, 2, arguments);
var var2 = nonCommentArg(2, 2, arguments);
_assert(commentArg(2, arguments), var1 !== var2,
'Expected not to be ' + _displayStringForValue(var2));
-}
+};
/**
- * @param {*} a
- * @param {*=} opt_b
+ * @param {*} a The value to assert (1 arg) or debug message (2 args).
+ * @param {*=} opt_b The value to assert (2 args only).
*/
-function assertNull(a, opt_b) {
+var assertNull = function(a, opt_b) {
_validateArguments(1, arguments);
var aVar = nonCommentArg(1, 1, arguments);
_assert(commentArg(1, arguments), aVar === null,
- 'Expected ' + _displayStringForValue(null) + ' but was ' +
- _displayStringForValue(aVar));
-}
+ goog.testing.asserts.getDefaultErrorMsg_(null, aVar));
+};
/**
- * @param {*} a
- * @param {*=} opt_b
+ * @param {*} a The value to assert (1 arg) or debug message (2 args).
+ * @param {*=} opt_b The value to assert (2 args only).
*/
-function assertNotNull(a, opt_b) {
+var assertNotNull = function(a, opt_b) {
_validateArguments(1, arguments);
var aVar = nonCommentArg(1, 1, arguments);
_assert(commentArg(1, arguments), aVar !== null,
'Expected not to be ' + _displayStringForValue(null));
-}
+};
/**
- * @param {*} a
- * @param {*=} opt_b
+ * @param {*} a The value to assert (1 arg) or debug message (2 args).
+ * @param {*=} opt_b The value to assert (2 args only).
*/
-function assertUndefined(a, opt_b) {
+var assertUndefined = function(a, opt_b) {
_validateArguments(1, arguments);
var aVar = nonCommentArg(1, 1, arguments);
_assert(commentArg(1, arguments), aVar === JSUNIT_UNDEFINED_VALUE,
- 'Expected ' + _displayStringForValue(JSUNIT_UNDEFINED_VALUE) +
- ' but was ' + _displayStringForValue(aVar));
-}
+ goog.testing.asserts.getDefaultErrorMsg_(JSUNIT_UNDEFINED_VALUE, aVar));
+};
/**
- * @param {*} a
- * @param {*=} opt_b
+ * @param {*} a The value to assert (1 arg) or debug message (2 args).
+ * @param {*=} opt_b The value to assert (2 args only).
*/
-function assertNotUndefined(a, opt_b) {
+var assertNotUndefined = function(a, opt_b) {
_validateArguments(1, arguments);
var aVar = nonCommentArg(1, 1, arguments);
_assert(commentArg(1, arguments), aVar !== JSUNIT_UNDEFINED_VALUE,
'Expected not to be ' + _displayStringForValue(JSUNIT_UNDEFINED_VALUE));
-}
+};
/**
- * @param {*} a
- * @param {*=} opt_b
+ * @param {*} a The value to assert (1 arg) or debug message (2 args).
+ * @param {*=} opt_b The value to assert (2 args only).
*/
-function assertNotNullNorUndefined(a, opt_b) {
+var assertNotNullNorUndefined = function(a, opt_b) {
_validateArguments(1, arguments);
assertNotNull.apply(null, arguments);
assertNotUndefined.apply(null, arguments);
-}
+};
/**
- * @param {*} a
- * @param {*=} opt_b
+ * @param {*} a The value to assert (1 arg) or debug message (2 args).
+ * @param {*=} opt_b The value to assert (2 args only).
*/
-function assertNonEmptyString(a, opt_b) {
+var assertNonEmptyString = function(a, opt_b) {
_validateArguments(1, arguments);
var aVar = nonCommentArg(1, 1, arguments);
_assert(commentArg(1, arguments),
aVar !== JSUNIT_UNDEFINED_VALUE && aVar !== null &&
typeof aVar == 'string' && aVar !== '',
'Expected non-empty string but was ' + _displayStringForValue(aVar));
-}
+};
/**
- * @param {*} a
- * @param {*=} opt_b
+ * @param {*} a The value to assert (1 arg) or debug message (2 args).
+ * @param {*=} opt_b The value to assert (2 args only).
*/
-function assertNaN(a, opt_b) {
+var assertNaN = function(a, opt_b) {
_validateArguments(1, arguments);
var aVar = nonCommentArg(1, 1, arguments);
_assert(commentArg(1, arguments), isNaN(aVar), 'Expected NaN');
-}
+};
/**
- * @param {*} a
- * @param {*=} opt_b
+ * @param {*} a The value to assert (1 arg) or debug message (2 args).
+ * @param {*=} opt_b The value to assert (2 args only).
*/
-function assertNotNaN(a, opt_b) {
+var assertNotNaN = function(a, opt_b) {
_validateArguments(1, arguments);
var aVar = nonCommentArg(1, 1, arguments);
_assert(commentArg(1, arguments), !isNaN(aVar), 'Expected not NaN');
-}
+};
/**
@@ -429,13 +503,39 @@ goog.testing.asserts.callWithoutLogging = function(fn) {
/**
+ * The return value of the equality predicate passed to findDifferences below,
+ * in cases where the predicate can't test the input variables for equality.
+ * @type {?string}
+ */
+goog.testing.asserts.EQUALITY_PREDICATE_CANT_PROCESS = null;
+
+
+/**
+ * The return value of the equality predicate passed to findDifferences below,
+ * in cases where the input vriables are equal.
+ * @type {?string}
+ */
+goog.testing.asserts.EQUALITY_PREDICATE_VARS_ARE_EQUAL = '';
+
+
+/**
* Determines if two items of any type match, and formulates an error message
* if not.
* @param {*} expected Expected argument to match.
* @param {*} actual Argument as a result of performing the test.
+ * @param {(function(string, *, *): ?string)=} opt_equalityPredicate An optional
+ * function that can be used to check equality of variables. It accepts 3
+ * arguments: type-of-variables, var1, var2 (in that order) and returns an
+ * error message if the variables are not equal,
+ * goog.testing.asserts.EQUALITY_PREDICATE_VARS_ARE_EQUAL if the variables
+ * are equal, or
+ * goog.testing.asserts.EQUALITY_PREDICATE_CANT_PROCESS if the predicate
+ * couldn't check the input variables. The function will be called only if
+ * the types of var1 and var2 are identical.
* @return {?string} Null on success, error message on failure.
*/
-goog.testing.asserts.findDifferences = function(expected, actual) {
+goog.testing.asserts.findDifferences = function(expected, actual,
+ opt_equalityPredicate) {
var failures = [];
var seen1 = [];
var seen2 = [];
@@ -474,7 +574,20 @@ goog.testing.asserts.findDifferences = function(expected, actual) {
seen2.pop();
}
+ var equalityPredicate = opt_equalityPredicate || function(type, var1, var2) {
+ var typedPredicate = PRIMITIVE_EQUALITY_PREDICATES[type];
+ if (!typedPredicate) {
+ return goog.testing.asserts.EQUALITY_PREDICATE_CANT_PROCESS;
+ }
+ var equal = typedPredicate(var1, var2);
+ return equal ? goog.testing.asserts.EQUALITY_PREDICATE_VARS_ARE_EQUAL :
+ goog.testing.asserts.getDefaultErrorMsg_(var1, var2);
+ };
+
/**
+ * @param {*} var1 An item in the expected object.
+ * @param {*} var2 The corresponding item in the actual object.
+ * @param {string} path Their path in the objects.
* @suppress {missingProperties} The map_ property is unknown to the compiler
* unless goog.structs.Map is loaded.
*/
@@ -488,14 +601,15 @@ goog.testing.asserts.findDifferences = function(expected, actual) {
if (typeOfVar1 == typeOfVar2) {
var isArray = typeOfVar1 == 'Array';
- var equalityPredicate = PRIMITIVE_EQUALITY_PREDICATES[typeOfVar1];
- if (equalityPredicate) {
- if (!equalityPredicate(var1, var2)) {
- failures.push(path + ' expected ' + _displayStringForValue(var1) +
- ' but was ' + _displayStringForValue(var2));
+ var errorMessage = equalityPredicate(typeOfVar1, var1, var2);
+ if (errorMessage !=
+ goog.testing.asserts.EQUALITY_PREDICATE_CANT_PROCESS) {
+ if (errorMessage !=
+ goog.testing.asserts.EQUALITY_PREDICATE_VARS_ARE_EQUAL) {
+ failures.push(path + ': ' + errorMessage);
}
} else if (isArray && var1.length != var2.length) {
- failures.push(path + ' expected ' + var1.length + '-element array ' +
+ failures.push(path + ': Expected ' + var1.length + '-element array ' +
'but got a ' + var2.length + '-element array');
} else {
var childPath = path + (isArray ? '[%s]' : (path ? '.%s' : '%s'));
@@ -575,15 +689,15 @@ goog.testing.asserts.findDifferences = function(expected, actual) {
}
}
} else {
- failures.push(path + ' expected ' + _displayStringForValue(var1) +
- ' but was ' + _displayStringForValue(var2));
+ failures.push(path + ' ' +
+ goog.testing.asserts.getDefaultErrorMsg_(var1, var2));
}
}
innerAssert(expected, actual, '');
return failures.length == 0 ? null :
- 'Expected ' + _displayStringForValue(expected) + ' but was ' +
- _displayStringForValue(actual) + '\n ' + failures.join('\n ');
+ goog.testing.asserts.getDefaultErrorMsg_(expected, actual) +
+ '\n ' + failures.join('\n ');
};
@@ -609,7 +723,7 @@ goog.testing.asserts.findDifferences = function(expected, actual) {
* @param {*} b Comparison object.
* @param {*=} opt_c Comparison object, if an assertion message was provided.
*/
-function assertObjectEquals(a, b, opt_c) {
+var assertObjectEquals = function(a, b, opt_c) {
_validateArguments(2, arguments);
var v1 = nonCommentArg(1, 2, arguments);
var v2 = nonCommentArg(2, 2, arguments);
@@ -617,7 +731,39 @@ function assertObjectEquals(a, b, opt_c) {
var differences = goog.testing.asserts.findDifferences(v1, v2);
_assert(failureMessage, !differences, differences);
-}
+};
+
+
+/**
+ * Similar to assertObjectEquals above, but accepts a tolerance margin.
+ *
+ * @param {*} a Assertion message or comparison object.
+ * @param {*} b Comparison object.
+ * @param {*} c Comparison object or tolerance.
+ * @param {*=} opt_d Tolerance, if an assertion message was provided.
+ */
+var assertObjectRoughlyEquals = function(a, b, c, opt_d) {
+ _validateArguments(3, arguments);
+ var v1 = nonCommentArg(1, 3, arguments);
+ var v2 = nonCommentArg(2, 3, arguments);
+ var tolerance = nonCommentArg(3, 3, arguments);
+ var failureMessage = commentArg(3, arguments) ? commentArg(3, arguments) : '';
+ var equalityPredicate = function(type, var1, var2) {
+ var typedPredicate =
+ goog.testing.asserts.primitiveRoughEqualityPredicates_[type];
+ if (!typedPredicate) {
+ return goog.testing.asserts.EQUALITY_PREDICATE_CANT_PROCESS;
+ }
+ var equal = typedPredicate(var1, var2, tolerance);
+ return equal ? goog.testing.asserts.EQUALITY_PREDICATE_VARS_ARE_EQUAL :
+ goog.testing.asserts.getDefaultErrorMsg_(var1, var2) +
+ ' which was more than ' + tolerance + ' away';
+ };
+ var differences = goog.testing.asserts.findDifferences(
+ v1, v2, equalityPredicate);
+
+ _assert(failureMessage, !differences, differences);
+};
/**
@@ -630,7 +776,7 @@ function assertObjectEquals(a, b, opt_c) {
* @param {*} b Comparison object.
* @param {*=} opt_c Comparison object, if an assertion message was provided.
*/
-function assertObjectNotEquals(a, b, opt_c) {
+var assertObjectNotEquals = function(a, b, opt_c) {
_validateArguments(2, arguments);
var v1 = nonCommentArg(1, 2, arguments);
var v2 = nonCommentArg(2, 2, arguments);
@@ -638,15 +784,19 @@ function assertObjectNotEquals(a, b, opt_c) {
var differences = goog.testing.asserts.findDifferences(v1, v2);
_assert(failureMessage, differences, 'Objects should not be equal');
-}
+};
/**
- * @param {*} a
- * @param {*} b
- * @param {*=} opt_c
+ * Compares two arrays ignoring negative indexes and extra properties on the
+ * array objects. Use case: Internet Explorer adds the index, lastIndex and
+ * input enumerable fields to the result of string.match(/regexp/g), which makes
+ * assertObjectEquals fail.
+ * @param {*} a The expected array (2 args) or the debug message (3 args).
+ * @param {*} b The actual array (2 args) or the expected array (3 args).
+ * @param {*=} opt_c The actual array (3 args only).
*/
-function assertArrayEquals(a, b, opt_c) {
+var assertArrayEquals = function(a, b, opt_c) {
_validateArguments(2, arguments);
var v1 = nonCommentArg(1, 2, arguments);
var v2 = nonCommentArg(2, 2, arguments);
@@ -662,8 +812,9 @@ function assertArrayEquals(a, b, opt_c) {
typeOfVar2 == 'Array',
'Expected an array for assertArrayEquals but found a ' + typeOfVar2);
- assertObjectEquals.apply(null, arguments);
-}
+ assertObjectEquals(failureMessage,
+ Array.prototype.concat.call(v1), Array.prototype.concat.call(v2));
+};
/**
@@ -674,7 +825,7 @@ function assertArrayEquals(a, b, opt_c) {
* @param {Object} b Object #1 (2 arguments) or object #2 (3 arguments).
* @param {Object} c Object #2 (3 arguments).
*/
-function assertElementsEquals(a, b, c) {
+var assertElementsEquals = function(a, b, c) {
_validateArguments(2, arguments);
var v1 = nonCommentArg(1, 2, arguments);
@@ -690,7 +841,7 @@ function assertElementsEquals(a, b, c) {
'mismatch at index ' + i + ': ' + failureMessage, v1[i], v2[i]);
}
}
-}
+};
/**
@@ -702,7 +853,7 @@ function assertElementsEquals(a, b, c) {
* @param {Object|number} c Object #2 (4 arguments) or tolerance (3 arguments).
* @param {number=} opt_d tolerance (4 arguments).
*/
-function assertElementsRoughlyEqual(a, b, c, opt_d) {
+var assertElementsRoughlyEqual = function(a, b, c, opt_d) {
_validateArguments(3, arguments);
var v1 = nonCommentArg(1, 3, arguments);
@@ -718,7 +869,7 @@ function assertElementsRoughlyEqual(a, b, c, opt_d) {
assertRoughlyEquals(failureMessage, v1[i], v2[i], tolerance);
}
}
-}
+};
/**
@@ -729,7 +880,7 @@ function assertElementsRoughlyEqual(a, b, c, opt_d) {
* elements.
* @param {goog.testing.asserts.ArrayLike=} opt_c Actual elements.
*/
-function assertSameElements(a, b, opt_c) {
+var assertSameElements = function(a, b, opt_c) {
_validateArguments(2, arguments);
var expected = nonCommentArg(1, 2, arguments);
var actual = nonCommentArg(2, 2, arguments);
@@ -755,41 +906,41 @@ function assertSameElements(a, b, opt_c) {
actual + ']');
toFind.splice(index, 1);
}
-}
+};
/**
- * @param {*} a
- * @param {*=} opt_b
+ * @param {*} a The value to assert (1 arg) or debug message (2 args).
+ * @param {*=} opt_b The value to assert (2 args only).
*/
-function assertEvaluatesToTrue(a, opt_b) {
+var assertEvaluatesToTrue = function(a, opt_b) {
_validateArguments(1, arguments);
var value = nonCommentArg(1, 1, arguments);
if (!value) {
_assert(commentArg(1, arguments), false, 'Expected to evaluate to true');
}
-}
+};
/**
- * @param {*} a
- * @param {*=} opt_b
+ * @param {*} a The value to assert (1 arg) or debug message (2 args).
+ * @param {*=} opt_b The value to assert (2 args only).
*/
-function assertEvaluatesToFalse(a, opt_b) {
+var assertEvaluatesToFalse = function(a, opt_b) {
_validateArguments(1, arguments);
var value = nonCommentArg(1, 1, arguments);
if (value) {
_assert(commentArg(1, arguments), false, 'Expected to evaluate to false');
}
-}
+};
/**
- * @param {*} a
- * @param {*} b
- * @param {*=} opt_c
+ * @param {*} a The expected value (2 args) or the debug message (3 args).
+ * @param {*} b The actual value (2 args) or the expected value (3 args).
+ * @param {*=} opt_c The actual value (3 args only).
*/
-function assertHTMLEquals(a, b, opt_c) {
+var assertHTMLEquals = function(a, b, opt_c) {
_validateArguments(2, arguments);
var var1 = nonCommentArg(1, 2, arguments);
var var2 = nonCommentArg(2, 2, arguments);
@@ -797,9 +948,9 @@ function assertHTMLEquals(a, b, opt_c) {
var var2Standardized = standardizeHTML(var2);
_assert(commentArg(2, arguments), var1Standardized === var2Standardized,
- 'Expected ' + _displayStringForValue(var1Standardized) + ' but was ' +
- _displayStringForValue(var2Standardized));
-}
+ goog.testing.asserts.getDefaultErrorMsg_(
+ var1Standardized, var2Standardized));
+};
/**
@@ -815,7 +966,7 @@ function assertHTMLEquals(a, b, opt_c) {
* @param {string} c The expected value, or the actual value.
* @param {string=} opt_d The actual value.
*/
-function assertCSSValueEquals(a, b, c, opt_d) {
+var assertCSSValueEquals = function(a, b, c, opt_d) {
_validateArguments(3, arguments);
var propertyName = nonCommentArg(1, 3, arguments);
var expectedValue = nonCommentArg(2, 3, arguments);
@@ -827,17 +978,17 @@ function assertCSSValueEquals(a, b, c, opt_d) {
_assert(commentArg(3, arguments),
expectedValueStandardized == actualValueStandardized,
- 'Expected ' + _displayStringForValue(expectedValueStandardized) +
- ' but was ' + _displayStringForValue(actualValueStandardized));
-}
+ goog.testing.asserts.getDefaultErrorMsg_(
+ expectedValueStandardized, actualValueStandardized));
+};
/**
- * @param {*} a
- * @param {*} b
- * @param {*=} opt_c
+ * @param {*} a The expected value (2 args) or the debug message (3 args).
+ * @param {*} b The actual value (2 args) or the expected value (3 args).
+ * @param {*=} opt_c The actual value (3 args only).
*/
-function assertHashEquals(a, b, opt_c) {
+var assertHashEquals = function(a, b, opt_c) {
_validateArguments(2, arguments);
var var1 = nonCommentArg(1, 2, arguments);
var var2 = nonCommentArg(2, 2, arguments);
@@ -853,24 +1004,26 @@ function assertHashEquals(a, b, opt_c) {
_assert(message, key in var1, 'Actual hash had key ' + key +
' that was not expected');
}
-}
+};
/**
- * @param {*} a
- * @param {*} b
- * @param {*} c
- * @param {*=} opt_d
+ * @param {*} a The expected value (3 args) or the debug message (4 args).
+ * @param {*} b The actual value (3 args) or the expected value (4 args).
+ * @param {*} c The tolerance (3 args) or the actual value (4 args).
+ * @param {*=} opt_d The tolerance (4 args only).
*/
-function assertRoughlyEquals(a, b, c, opt_d) {
+var assertRoughlyEquals = function(a, b, c, opt_d) {
_validateArguments(3, arguments);
var expected = nonCommentArg(1, 3, arguments);
var actual = nonCommentArg(2, 3, arguments);
var tolerance = nonCommentArg(3, 3, arguments);
- _assert(commentArg(3, arguments), Math.abs(expected - actual) <= tolerance,
+ _assert(commentArg(3, arguments),
+ goog.testing.asserts.numberRoughEqualityPredicate_(
+ expected, actual, tolerance),
'Expected ' + expected + ', but got ' + actual +
' which was more than ' + tolerance + ' away');
-}
+};
/**
@@ -881,14 +1034,14 @@ function assertRoughlyEquals(a, b, c, opt_d) {
* (2 arguments).
* @param {*=} opt_c The container.
*/
-function assertContains(a, b, opt_c) {
+var assertContains = function(a, b, opt_c) {
_validateArguments(2, arguments);
var contained = nonCommentArg(1, 2, arguments);
var container = nonCommentArg(2, 2, arguments);
_assert(commentArg(2, arguments),
goog.testing.asserts.contains_(container, contained),
'Expected \'' + container + '\' to contain \'' + contained + '\'');
-}
+};
/**
@@ -899,14 +1052,14 @@ function assertContains(a, b, opt_c) {
* (2 arguments).
* @param {*=} opt_c The container.
*/
-function assertNotContains(a, b, opt_c) {
+var assertNotContains = function(a, b, opt_c) {
_validateArguments(2, arguments);
var contained = nonCommentArg(1, 2, arguments);
var container = nonCommentArg(2, 2, arguments);
_assert(commentArg(2, arguments),
!goog.testing.asserts.contains_(container, contained),
'Expected \'' + container + '\' not to contain \'' + contained + '\'');
-}
+};
/**
@@ -963,13 +1116,13 @@ goog.testing.asserts.contains_ = function(container, contained) {
return goog.testing.asserts.indexOf_(container, contained) != -1;
};
-function standardizeHTML(html) {
+var standardizeHTML = function(html) {
var translator = document.createElement('DIV');
translator.innerHTML = html;
// Trim whitespace from result (without relying on goog.string)
return translator.innerHTML.replace(/^\s+|\s+$/g, '');
-}
+};
/**
@@ -979,20 +1132,19 @@ function standardizeHTML(html) {
* @param {string} value CSS value.
* @return {string} Normalized CSS value.
*/
-function standardizeCSSValue(propertyName, value) {
+var standardizeCSSValue = function(propertyName, value) {
var styleDeclaration = document.createElement('DIV').style;
styleDeclaration[propertyName] = value;
return styleDeclaration[propertyName];
-}
+};
/**
* Raises a JsUnit exception with the given comment.
* @param {string} comment A summary for the exception.
* @param {string=} opt_message A description of the exception.
- * @private
*/
-goog.testing.asserts.raiseException_ = function(comment, opt_message) {
+goog.testing.asserts.raiseException = function(comment, opt_message) {
if (goog.global['CLOSURE_INSPECTOR___'] &&
goog.global['CLOSURE_INSPECTOR___']['supportsJSUnit']) {
goog.global['CLOSURE_INSPECTOR___']['jsUnitFailure'](comment, opt_message);
@@ -1003,10 +1155,9 @@ goog.testing.asserts.raiseException_ = function(comment, opt_message) {
/**
- * Helper function for assertObjectEquals. Tells us if a given property
- * name is an array index.
- * @param {string} prop
- * @return {boolean}
+ * Helper function for assertObjectEquals.
+ * @param {string} prop A property name.
+ * @return {boolean} If the property name is an array index.
* @private
*/
goog.testing.asserts.isArrayIndexProp_ = function(prop) {
@@ -1034,11 +1185,10 @@ goog.testing.JsUnitException = function(comment, opt_message) {
/** @override */
goog.testing.JsUnitException.prototype.toString = function() {
- // TODO(agrieve): Fix dependency in build rules. For more info see
- // http://b/2020085
- return '[JsUnitException]';
+ return this.message;
};
+
goog.exportSymbol('fail', fail);
goog.exportSymbol('assert', assert);
goog.exportSymbol('assertThrows', assertThrows);
@@ -1056,6 +1206,7 @@ goog.exportSymbol('assertNonEmptyString', assertNonEmptyString);
goog.exportSymbol('assertNaN', assertNaN);
goog.exportSymbol('assertNotNaN', assertNotNaN);
goog.exportSymbol('assertObjectEquals', assertObjectEquals);
+goog.exportSymbol('assertObjectRoughlyEquals', assertObjectRoughlyEquals);
goog.exportSymbol('assertObjectNotEquals', assertObjectNotEquals);
goog.exportSymbol('assertArrayEquals', assertArrayEquals);
goog.exportSymbol('assertElementsEquals', assertElementsEquals);
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/asserts_test.html b/contexts/data/lib/closure-library/closure/goog/testing/asserts_test.html
index 8d05659..e90d114 100644
--- a/contexts/data/lib/closure-library/closure/goog/testing/asserts_test.html
+++ b/contexts/data/lib/closure-library/closure/goog/testing/asserts_test.html
@@ -820,21 +820,68 @@ See the COPYING file for details.
assertArrayEquals('Arrays should be equal', a1, a2);
assertThrows('Should have thrown because args are not arrays', function() {
- var b1 = true;
- var b2 = true;
- assertArrayEquals(b1, b2);
+ assertArrayEquals(true, true);
});
+
+ a1 = [0, undefined, 2];
+ a2 = [0, , 2];
+ // The following test fails unexpectedly. The bug is tracked at
+ // http://code.google.com/p/closure-library/issues/detail?id=419
+ // assertThrows(
+ // 'assertArrayEquals distinguishes undefined items from sparse arrays',
+ // function() {
+ // assertArrayEquals(a1, a2);
+ // });
+
+ // For the record. This behavior will probably change in the future.
+ assertArrayEquals(
+ 'Bug: sparse arrays and undefined items are not distinguished',
+ [0, undefined, 2], [0, , 2]);
+
+ assertThrows('The array elements should be compared with ===', function() {
+ assertArrayEquals([0], ['0'])
+ });
+
+ assertThrows('Arrays with different length should be different',
+ function() {
+ assertArrayEquals([0, undefined], [0])
+ });
+
+ a1 = [0];
+ a2 = [0];
+ a2[-1] = -1;
+ assertArrayEquals('Negative indexes are ignored', a1, a2);
+
+ a1 = [0];
+ a2 = [0];
+ a2['extra'] = 1
+ assertArrayEquals(
+ 'Extra properties are ignored. Use assertObjectEquals to compare them.',
+ a1, a2);
+
+ assertArrayEquals('An example where assertObjectEquals would fail in IE.',
+ ['x'], 'x'.match(/x/g))
}
function testAssertObjectsEqualsDifferentArrays() {
assertThrows('Should have thrown because args are different', function() {
var a1 = ['className1'];
var a2 = ['className2'];
- assertArrayEquals(a1, a2);
assertObjectEquals(a1, a2);
});
}
+ function testAssertObjectsEqualsNegativeArrayIndexes() {
+ var a1 = [0];
+ var a2 = [0];
+ a2[-1] = -1;
+ // The following test fails unexpectedly. The bug is tracked at
+ // http://code.google.com/p/closure-library/issues/detail?id=418
+ // assertThrows('assertObjectEquals compares negative indexes', function() {
+ // assertObjectEquals(a1, a2);
+ // });
+ }
+
function testAssertObjectsEqualsDifferentTypeSameToString() {
assertThrows('Should have thrown because args are different', function() {
var a1 = 'className1';
@@ -855,6 +902,15 @@ See the COPYING file for details.
});
}
+ function testAssertObjectsRoughlyEquals() {
+ assertObjectRoughlyEquals({'a': 1}, {'a': 1.2}, 0.3);
+ assertThrowsJsUnitException(
+ function() { assertObjectRoughlyEquals({'a': 1}, {'a': 1.2}, 0.1); },
+ 'Expected <[object Object]> (Object) but was <[object Object]> ' +
+ '(Object)\n a: Expected <1> (Number) but was <1.2> (Number) which ' +
+ 'was more than 0.1 away');
+ }
+
function testFindDifferences_equal() {
assertNull(goog.testing.asserts.findDifferences(true, true));
assertNull(goog.testing.asserts.findDifferences(null, null));
@@ -990,6 +1046,32 @@ See the COPYING file for details.
}
}
+ function testStringSamePrefix() {
+ assertThrowsJsUnitException(
+ function() { assertEquals('abcdefghi', 'abcdefghx'); },
+ 'Expected <abcdefghi> (String) but was <abcdefghx> (String)\n' +
+ 'Difference was at position 8. Expected [...ghi] vs. actual [...ghx]');
+ }
+
+ function testStringSameSuffix() {
+ assertThrowsJsUnitException(
+ function() { assertEquals('xbcdefghi', 'abcdefghi'); },
+ 'Expected <xbcdefghi> (String) but was <abcdefghi> (String)\n' +
+ 'Difference was at position 0. Expected [xbc...] vs. actual [abc...]');
+ }
+
+ function testStringDissimilarShort() {
+ assertThrowsJsUnitException(
+ function() { assertEquals('x', 'y'); },
+ 'Expected <x> (String) but was <y> (String)');
+ }
+
+ function testStringDissimilarLong() {
+ assertThrowsJsUnitException(
+ function() { assertEquals('xxxxxxxxxx', 'yyyyyyyyyy'); },
+ 'Expected <xxxxxxxxxx> (String) but was <yyyyyyyyyy> (String)');
+ }
+
function testAssertElementsEquals() {
assertElementsEquals([1, 2], [1, 2]);
assertElementsEquals([1, 2], {0: 1, 1: 2, length: 2});
@@ -1006,6 +1088,30 @@ See the COPYING file for details.
window.stringForWindowIEResult = _displayStringForValue(window);
}
+ function testDisplayStringForValue() {
+ assertEquals('<hello> (String)', _displayStringForValue('hello'));
+ assertEquals('<1> (Number)', _displayStringForValue(1));
+ assertEquals('<null>', _displayStringForValue(null));
+ assertEquals('<undefined>', _displayStringForValue(undefined));
+ assertEquals('<hello,,,,1> (Array)', _displayStringForValue(
+ ['hello', /* array hole */, undefined, null, 1]));
+ }
+
+ function testDisplayStringForValue_exception() {
+ assertEquals('<toString failed: foo message> (Object)',
+ _displayStringForValue({toString: function() {
+ throw Error('foo message');
+ }}));
+ }
+
+ function testDisplayStringForValue_cycle() {
+ var cycle = ['cycle'];
+ cycle.push(cycle);
+ assertTrue(
+ 'Computing string should terminate and result in a reasonable length',
+ _displayStringForValue(cycle).length < 1000);
+ }
+
</script>
</body>
</html>
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/async/.svn/all-wcprops b/contexts/data/lib/closure-library/closure/goog/testing/async/.svn/all-wcprops
deleted file mode 100644
index a34ad80..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/async/.svn/all-wcprops
+++ /dev/null
@@ -1,17 +0,0 @@
-K 25
-svn:wc:ra_dav:version-url
-V 51
-/svn/!svn/ver/1434/trunk/closure/goog/testing/async
-END
-mockcontrol.js
-K 25
-svn:wc:ra_dav:version-url
-V 65
-/svn/!svn/ver/850/trunk/closure/goog/testing/async/mockcontrol.js
-END
-mockcontrol_test.html
-K 25
-svn:wc:ra_dav:version-url
-V 73
-/svn/!svn/ver/1434/trunk/closure/goog/testing/async/mockcontrol_test.html
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/async/.svn/entries b/contexts/data/lib/closure-library/closure/goog/testing/async/.svn/entries
deleted file mode 100644
index 9043113..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/async/.svn/entries
+++ /dev/null
@@ -1,96 +0,0 @@
-10
-
-dir
-1494
-http://closure-library.googlecode.com/svn/trunk/closure/goog/testing/async
-http://closure-library.googlecode.com/svn
-
-
-
-2011-11-30T22:16:21.000000Z
-1434
-chrishenry@google.com
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-0b95b8e8-c90f-11de-9d4f-f947ee5921c8
-
-mockcontrol.js
-file
-
-
-
-
-2011-12-23T22:42:26.940311Z
-008c591a7303cb0978222f1c9d0f0d36
-2011-04-12T20:35:47.000000Z
-850
-diegosalas@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-6338
-
-mockcontrol_test.html
-file
-
-
-
-
-2011-12-23T22:42:26.941311Z
-2d8cd4667fc5ca6aafc4bfd1e0d6811f
-2011-11-30T22:16:21.000000Z
-1434
-chrishenry@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-7058
-
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/async/.svn/prop-base/mockcontrol.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/async/.svn/prop-base/mockcontrol.js.svn-base
deleted file mode 100644
index 7febff5..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/async/.svn/prop-base/mockcontrol.js.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 22
-application/javascript
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/async/.svn/prop-base/mockcontrol_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/async/.svn/prop-base/mockcontrol_test.html.svn-base
deleted file mode 100644
index d356868..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/async/.svn/prop-base/mockcontrol_test.html.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 9
-text/html
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/async/.svn/text-base/mockcontrol.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/async/.svn/text-base/mockcontrol.js.svn-base
deleted file mode 100644
index 7505812..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/async/.svn/text-base/mockcontrol.js.svn-base
+++ /dev/null
@@ -1,174 +0,0 @@
-// Copyright 2010 The Closure Library Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS-IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/**
- * @fileoverview A wrapper for MockControl that provides mocks and assertions
- * for testing asynchronous code. All assertions will only be verified when
- * $verifyAll is called on the wrapped MockControl.
- *
- * This class is meant primarily for testing code that exposes asynchronous APIs
- * without being truly asynchronous (using asynchronous primitives like browser
- * events or timeouts). This is often the case when true asynchronous
- * depedencies have been mocked out. This means that it doesn't rely on
- * AsyncTestCase or DeferredTestCase, although it can be used with those as
- * well.
- *
- * Example usage:
- *
- * <pre>
- * var mockControl = new goog.testing.MockControl();
- * var asyncMockControl = new goog.testing.async.MockControl(mockControl);
- *
- * myAsyncObject.onSuccess(asyncMockControl.asyncAssertEquals(
- * 'callback should run and pass the correct value',
- * 'http://someurl.com');
- * asyncMockControl.assertDeferredEquals(
- * 'deferred object should be resolved with the correct value',
- * 'http://someurl.com',
- * myAsyncObject.getDeferredUrl());
- * asyncMockControl.run();
- * mockControl.$verifyAll();
- * </pre>
- *
- */
-
-
-goog.provide('goog.testing.async.MockControl');
-
-goog.require('goog.asserts');
-goog.require('goog.async.Deferred');
-goog.require('goog.debug');
-goog.require('goog.testing.asserts');
-goog.require('goog.testing.mockmatchers.IgnoreArgument');
-
-
-
-/**
- * Provides asynchronous mocks and assertions controlled by a parent
- * MockControl.
- *
- * @param {goog.testing.MockControl} mockControl The parent MockControl.
- * @constructor
- */
-goog.testing.async.MockControl = function(mockControl) {
- /**
- * The parent MockControl.
- * @type {goog.testing.MockControl}
- * @private
- */
- this.mockControl_ = mockControl;
-};
-
-
-/**
- * Returns a function that will assert that it will be called, and run the given
- * callback when it is.
- *
- * @param {string} name The name of the callback mock.
- * @param {function(...[*]) : *} callback The wrapped callback. This will be
- * called when the returned function is called.
- * @param {Object=} opt_selfObj The object which this should point to when the
- * callback is run.
- * @return {!Function} The mock callback.
- * @suppress {missingProperties} Mocks do not fit in the type system well.
- */
-goog.testing.async.MockControl.prototype.createCallbackMock = function(
- name, callback, opt_selfObj) {
- goog.asserts.assert(
- goog.isString(name),
- 'name parameter ' + goog.debug.deepExpose(name) + ' should be a string');
-
- var ignored = new goog.testing.mockmatchers.IgnoreArgument();
-
- // Use everyone's favorite "double-cast" trick to subvert the type system.
- var obj = /** @type {Object} */ (this.mockControl_.createFunctionMock(name));
- var fn = /** @type {Function} */ (obj);
-
- fn(ignored).$does(function(args) {
- if (opt_selfObj) {
- callback = goog.bind(callback, opt_selfObj);
- }
- return callback.apply(this, args);
- });
- fn.$replay();
- return function() { return fn(arguments); };
-};
-
-
-/**
- * Returns a function that will assert that its arguments are equal to the
- * arguments given to asyncAssertEquals. In addition, the function also asserts
- * that it will be called.
- *
- * @param {string} message A message to print if the arguments are wrong.
- * @param {...*} var_args The arguments to assert.
- * @return {function(...[*]) : void} The mock callback.
- */
-goog.testing.async.MockControl.prototype.asyncAssertEquals = function(
- message, var_args) {
- var expectedArgs = Array.prototype.slice.call(arguments, 1);
- return this.createCallbackMock('asyncAssertEquals', function() {
- assertObjectEquals(
- message, expectedArgs, Array.prototype.slice.call(arguments));
- });
-};
-
-
-/**
- * Asserts that a deferred object will have an error and call its errback
- * function.
- * @param {goog.async.Deferred} deferred The deferred object.
- * @param {function() : void} fn A function wrapping the code in which the error
- * will occur.
- */
-goog.testing.async.MockControl.prototype.assertDeferredError = function(
- deferred, fn) {
- deferred.addErrback(this.createCallbackMock(
- 'assertDeferredError', function() {}));
- goog.testing.asserts.callWithoutLogging(fn);
-};
-
-
-/**
- * Asserts that a deferred object will call its callback with the given value.
- *
- * @param {string} message A message to print if the arguments are wrong.
- * @param {goog.async.Deferred|*} expected The expected value. If this is a
- * deferred object, then the expected value is the deferred value.
- * @param {goog.async.Deferred|*} actual The actual value. If this is a deferred
- * object, then the actual value is the deferred value. Either this or
- * 'expected' must be deferred.
- */
-goog.testing.async.MockControl.prototype.assertDeferredEquals = function(
- message, expected, actual) {
- if (expected instanceof goog.async.Deferred &&
- actual instanceof goog.async.Deferred) {
- // Assert that the first deferred is resolved.
- expected.addCallback(this.createCallbackMock(
- 'assertDeferredEquals', function(exp) {
- // Assert that the second deferred is resolved, and that the value is
- // as expected.
- actual.addCallback(this.asyncAssertEquals(message, exp));
- }, this));
- } else if (expected instanceof goog.async.Deferred) {
- expected.addCallback(this.createCallbackMock(
- 'assertDeferredEquals', function(exp) {
- assertObjectEquals(message, exp, actual);
- }));
- } else if (actual instanceof goog.async.Deferred) {
- actual.addCallback(this.asyncAssertEquals(message, expected));
- } else {
- throw Error('Either expected or actual must be deferred');
- }
-};
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/async/.svn/text-base/mockcontrol_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/async/.svn/text-base/mockcontrol_test.html.svn-base
deleted file mode 100644
index 83c4797..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/async/.svn/text-base/mockcontrol_test.html.svn-base
+++ /dev/null
@@ -1,223 +0,0 @@
-<!DOCTYPE html>
-<html>
-<!--
-Copyright 2010 The Closure Library Authors. All Rights Reserved.
-
-Use of this source code is governed by the Apache License, Version 2.0.
-See the COPYING file for details.
--->
-<!--
--->
-<head>
-<title>
- Closure Unit Tests - goog.testing.async.MockControl;
-</title>
-<script type="text/javascript" src="../../base.js"></script>
-<script type="text/javascript">
-goog.require('goog.async.Deferred');
-goog.require('goog.testing.MockControl');
-goog.require('goog.testing.async.MockControl');
-goog.require('goog.testing.jsunit');
-goog.require('goog.testing.asserts');
-</script>
-</head>
-<body>
-<script type="text/javascript">
-var mockControl;
-var asyncMockControl;
-
-var mockControl2;
-var asyncMockControl2;
-
-function setUp() {
- mockControl = new goog.testing.MockControl();
- asyncMockControl = new goog.testing.async.MockControl(mockControl);
-
- // We need two of these for the tests where we need to verify our meta-test
- // assertions without verifying our tested assertions.
- mockControl2 = new goog.testing.MockControl();
- asyncMockControl2 = new goog.testing.async.MockControl(mockControl2);
-}
-
-function assertVerifyFails() {
- assertThrowsJsUnitException(function() { mockControl.$verifyAll(); });
-}
-
-function testCreateCallbackMockFailure() {
- asyncMockControl.createCallbackMock('failingCallbackMock', function() {});
- assertVerifyFails();
-}
-
-function testCreateCallbackMockSuccess() {
- var callback = asyncMockControl.createCallbackMock(
- 'succeedingCallbackMock', function() {});
- callback();
- mockControl.$verifyAll();
-}
-
-function testCreateCallbackMockSuccessWithArg() {
- var callback = asyncMockControl.createCallbackMock(
- 'succeedingCallbackMockWithArg',
- asyncMockControl.createCallbackMock(
- 'metaCallbackMock',
- function(val) { assertEquals(10, val); }));
- callback(10);
- mockControl.$verifyAll();
-}
-
-function testCreateCallbackMockSuccessWithArgs() {
- var callback = asyncMockControl.createCallbackMock(
- 'succeedingCallbackMockWithArgs',
- asyncMockControl.createCallbackMock(
- 'metaCallbackMock', function(val1, val2, val3) {
- assertEquals(10, val1);
- assertEquals('foo', val2);
- assertObjectEquals({foo: 'bar'}, val3);
- }));
- callback(10, 'foo', {foo: 'bar'});
- mockControl.$verifyAll();
-}
-
-function testAsyncAssertEqualsFailureNeverCalled() {
- asyncMockControl.asyncAssertEquals('never called', 12);
- assertVerifyFails();
-}
-
-function testAsyncAssertEqualsFailureNumberOfArgs() {
- assertThrowsJsUnitException(function() {
- asyncMockControl.asyncAssertEquals('wrong number of args', 12)();
- });
-}
-
-function testAsyncAssertEqualsFailureOneArg() {
- assertThrowsJsUnitException(function() {
- asyncMockControl.asyncAssertEquals('wrong arg value', 12)(13);
- });
-}
-
-function testAsyncAssertEqualsFailureThreeArgs() {
- assertThrowsJsUnitException(function() {
- asyncMockControl.asyncAssertEquals('wrong arg values', 1, 2, 15)(2, 2, 15);
- });
-}
-
-function testAsyncAssertEqualsSuccessNoArgs() {
- asyncMockControl.asyncAssertEquals('should be called')();
- mockControl.$verifyAll();
-}
-
-function testAsyncAssertEqualsSuccessThreeArgs() {
- asyncMockControl.asyncAssertEquals('should have args', 1, 2, 3)(1, 2, 3);
- mockControl.$verifyAll();
-}
-
-function testAssertDeferredErrorFailureNoError() {
- var deferred = new goog.async.Deferred();
- asyncMockControl.assertDeferredError(deferred, function() {});
- assertVerifyFails();
-}
-
-function testAssertDeferredErrorSuccess() {
- var deferred = new goog.async.Deferred();
- asyncMockControl.assertDeferredError(deferred, function() {
- deferred.errback(new Error('FAIL'));
- });
- mockControl.$verifyAll();
-}
-
-function testAssertDeferredEqualsFailureActualDeferredNeverResolves() {
- var actual = new goog.async.Deferred();
- asyncMockControl.assertDeferredEquals('doesn\'t resolve', 12, actual);
- assertVerifyFails();
-}
-
-function testAssertDeferredEqualsFailureActualDeferredNeverResolvesBoth() {
- var actualDeferred = new goog.async.Deferred();
- var expectedDeferred = new goog.async.Deferred();
- expectedDeferred.callback(12);
- asyncMockControl.assertDeferredEquals(
- 'doesn\'t resolve', expectedDeferred, actualDeferred);
- assertVerifyFails();
-}
-
-function testAssertDeferredEqualsFailureExpectedDeferredNeverResolves() {
- var expected = new goog.async.Deferred();
- asyncMockControl.assertDeferredEquals('doesn\'t resolve', expected, 12);
- assertVerifyFails();
-}
-
-function testAssertDeferredEqualsFailureExpectedDeferredNeverResolvesBoth() {
- var actualDeferred = new goog.async.Deferred();
- var expectedDeferred = new goog.async.Deferred();
- actualDeferred.callback(12);
- asyncMockControl.assertDeferredEquals(
- 'doesn\'t resolve', expectedDeferred, actualDeferred);
- assertVerifyFails();
-}
-
-function testAssertDeferredEqualsFailureWrongValueActualDeferred() {
- var actual = new goog.async.Deferred();
- asyncMockControl.assertDeferredEquals('doesn\'t resolve', 12, actual);
- asyncMockControl2.assertDeferredError(actual, function() {
- actual.callback(13);
- });
- mockControl2.$verifyAll();
-}
-
-function testAssertDeferredEqualsFailureWrongValueExpectedDeferred() {
- var expected = new goog.async.Deferred();
- asyncMockControl.assertDeferredEquals('doesn\'t resolve', expected, 12);
- asyncMockControl2.assertDeferredError(expected, function() {
- expected.callback(13);
- });
- mockControl2.$verifyAll();
-}
-
-function testAssertDeferredEqualsFailureWongValueBothDeferred() {
- var actualDeferred = new goog.async.Deferred();
- var expectedDeferred = new goog.async.Deferred();
- asyncMockControl.assertDeferredEquals(
- 'different values', expectedDeferred, actualDeferred);
- expectedDeferred.callback(12);
- asyncMockControl2.assertDeferredError(actualDeferred, function() {
- actualDeferred.callback(13);
- });
- assertVerifyFails();
- mockControl2.$verifyAll();
-}
-
-function testAssertDeferredEqualsFailureNeitherDeferredEverResolves() {
- var actualDeferred = new goog.async.Deferred();
- var expectedDeferred = new goog.async.Deferred();
- asyncMockControl.assertDeferredEquals(
- 'doesn\'t resolve', expectedDeferred, actualDeferred);
- assertVerifyFails();
-}
-
-function testAssertDeferredEqualsSuccessActualDeferred() {
- var actual = new goog.async.Deferred();
- asyncMockControl.assertDeferredEquals('should succeed', 12, actual);
- actual.callback(12);
- mockControl.$verifyAll();
-}
-
-function testAssertDeferredEqualsSuccessExpectedDeferred() {
- var expected = new goog.async.Deferred();
- asyncMockControl.assertDeferredEquals('should succeed', expected, 12);
- expected.callback(12);
- mockControl.$verifyAll();
-}
-
-function testAssertDeferredEqualsSuccessBothDeferred() {
- var actualDeferred = new goog.async.Deferred();
- var expectedDeferred = new goog.async.Deferred();
- asyncMockControl.assertDeferredEquals(
- 'should succeed', expectedDeferred, actualDeferred);
- expectedDeferred.callback(12);
- actualDeferred.callback(12);
- mockControl.$verifyAll();
-}
-
-</script>
-</body>
-</html>
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/asynctestcase.js b/contexts/data/lib/closure-library/closure/goog/testing/asynctestcase.js
index 3c4cfd9..2657f91 100644
--- a/contexts/data/lib/closure-library/closure/goog/testing/asynctestcase.js
+++ b/contexts/data/lib/closure-library/closure/goog/testing/asynctestcase.js
@@ -308,6 +308,16 @@ goog.testing.AsyncTestCase.prototype.numControlExceptionsExpected_ = 0;
/**
+ * The current step name.
+ * @return {!string} Step name.
+ * @protected
+ */
+goog.testing.AsyncTestCase.prototype.getCurrentStepName = function() {
+ return this.curStepName_;
+};
+
+
+/**
* Preferred way of creating an AsyncTestCase. Creates one and initializes it
* with the G_testRunner.
* @param {string=} opt_name A descriptive name for the test case.
@@ -375,9 +385,13 @@ goog.testing.AsyncTestCase.prototype.doAsyncError = function(opt_e) {
fakeTestObj.name = this.activeTest.name + ' [' + fakeTestObj.name + ']';
}
- // Note: if the test has an error, and then tearDown has an error, they will
- // both be reported.
- this.doError(fakeTestObj, opt_e);
+ if (this.activeTest) {
+ // Note: if the test has an error, and then tearDown has an error, they will
+ // both be reported.
+ this.doError(fakeTestObj, opt_e);
+ } else {
+ this.exceptionBeforeTest = opt_e;
+ }
// This is a potential entry point, so we pump. We also add in a bit of a
// delay to try and prevent any async behavior from the failed test from
@@ -637,7 +651,7 @@ goog.testing.AsyncTestCase.prototype.startTimeoutTimer_ = function() {
goog.testing.AsyncTestCase.prototype.stopTimeoutTimer_ = function() {
if (this.timeoutHandle_) {
this.dbgLog_('Clearing timeout timer with id ' + this.timeoutHandle_);
- window.clearTimeout(this.timeoutHandle_);
+ this.clearTimeout(this.timeoutHandle_);
this.timeoutHandle_ = 0;
}
};
@@ -693,16 +707,8 @@ goog.testing.AsyncTestCase.prototype.pump_ = function(opt_doFirst) {
// If this function is already above us in the call-stack, then we should
// return rather than pumping in order to minimize call-stack depth.
if (!this.returnWillPump_) {
- this.setBatchTime(this.now_());
+ this.setBatchTime(this.now());
this.returnWillPump_ = true;
- // If we catch an exception in the step, we don't want to return control
- // to our caller since there may be non-testcase code in our call stack.
- // Eg)
- // asyncCallback() { fail(1); fail(2); }
- // V
- // - ...
- // - pump_();
- // We don't want fail(2) to ever be called.
var topFuncResult = {};
if (opt_doFirst) {
@@ -726,7 +732,7 @@ goog.testing.AsyncTestCase.prototype.pump_ = function(opt_doFirst) {
// If the max run time is exceeded call this function again async so as
// not to block the browser.
- var delta = this.now_() - this.getBatchTime();
+ var delta = this.now() - this.getBatchTime();
if (delta > goog.testing.TestCase.MAX_RUN_TIME &&
!topFuncResult.controlBreakingExceptionThrown) {
this.saveMessage('Breaking async');
@@ -736,14 +742,6 @@ goog.testing.AsyncTestCase.prototype.pump_ = function(opt_doFirst) {
}
}
this.returnWillPump_ = false;
- // See note at top of this function.
- if (topFuncResult.controlBreakingExceptionThrown) {
- this.numControlExceptionsExpected_ += 1;
- this.dbgLog_('pump: numControlExceptionsExpected_ = ' +
- this.numControlExceptionsExpected_ + ' and throwing exception.');
- throw new goog.testing.AsyncTestCase.
- ControlBreakingException(topFuncResult.message);
- }
} else if (opt_doFirst) {
opt_doFirst.call(this);
}
@@ -769,7 +767,13 @@ goog.testing.AsyncTestCase.prototype.doIteration_ = function() {
this.activeTest = this.next();
if (this.activeTest && this.running) {
this.result_.runCount++;
- this.setNextStep_(this.doSetUp_, 'setUp');
+ // If this test should be marked as having failed, doIteration will go
+ // straight to the next test.
+ if (this.maybeFailTestEarly(this.activeTest)) {
+ this.setNextStep_(this.doIteration_, 'doIteration');
+ } else {
+ this.setNextStep_(this.doSetUp_, 'setUp');
+ }
} else {
// All tests done.
this.finalize();
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/benchmark.js b/contexts/data/lib/closure-library/closure/goog/testing/benchmark.js
index 8c38ec8..d71173f 100644
--- a/contexts/data/lib/closure-library/closure/goog/testing/benchmark.js
+++ b/contexts/data/lib/closure-library/closure/goog/testing/benchmark.js
@@ -46,7 +46,7 @@ goog.testing.benchmark.run_ = function() {
try {
var ref = testSource[name];
} catch (ex) {
- // NOTE(user): When running tests from a file:// URL on Firefox 3.5
+ // NOTE(brenneman): When running tests from a file:// URL on Firefox 3.5
// for Windows, any reference to window.sessionStorage raises
// an "Operation is not supported" exception. Ignore any exceptions raised
// by simply accessing global properties.
@@ -81,7 +81,8 @@ goog.testing.benchmark.run_ = function() {
/**
* Onload handler that runs the benchmarks.
+ * @param {Event} e The event object.
*/
-window.onload = function() {
+window.onload = function(e) {
goog.testing.benchmark.run_();
};
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/benchmarks/.svn/all-wcprops b/contexts/data/lib/closure-library/closure/goog/testing/benchmarks/.svn/all-wcprops
deleted file mode 100644
index f4edbf0..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/benchmarks/.svn/all-wcprops
+++ /dev/null
@@ -1,29 +0,0 @@
-K 25
-svn:wc:ra_dav:version-url
-V 55
-/svn/!svn/ver/850/trunk/closure/goog/testing/benchmarks
-END
-jsbinarysizetoolbar_test.html
-K 25
-svn:wc:ra_dav:version-url
-V 85
-/svn/!svn/ver/850/trunk/closure/goog/testing/benchmarks/jsbinarysizetoolbar_test.html
-END
-jsbinarysizebutton.js
-K 25
-svn:wc:ra_dav:version-url
-V 77
-/svn/!svn/ver/850/trunk/closure/goog/testing/benchmarks/jsbinarysizebutton.js
-END
-jsbinarysizetoolbar.js
-K 25
-svn:wc:ra_dav:version-url
-V 78
-/svn/!svn/ver/850/trunk/closure/goog/testing/benchmarks/jsbinarysizetoolbar.js
-END
-jsbinarysizebutton_test.html
-K 25
-svn:wc:ra_dav:version-url
-V 84
-/svn/!svn/ver/850/trunk/closure/goog/testing/benchmarks/jsbinarysizebutton_test.html
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/benchmarks/.svn/entries b/contexts/data/lib/closure-library/closure/goog/testing/benchmarks/.svn/entries
deleted file mode 100644
index 464dad6..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/benchmarks/.svn/entries
+++ /dev/null
@@ -1,164 +0,0 @@
-10
-
-dir
-1494
-http://closure-library.googlecode.com/svn/trunk/closure/goog/testing/benchmarks
-http://closure-library.googlecode.com/svn
-
-
-
-2011-04-12T20:35:47.000000Z
-850
-diegosalas@google.com
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-0b95b8e8-c90f-11de-9d4f-f947ee5921c8
-
-jsbinarysizetoolbar_test.html
-file
-
-
-
-
-2011-12-23T22:42:26.797309Z
-80ebf4ada09af967168f11422a3e556c
-2011-04-12T20:35:47.000000Z
-850
-diegosalas@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-1378
-
-jsbinarysizebutton.js
-file
-
-
-
-
-2011-12-23T22:42:26.797309Z
-6ea554359603211dc04c258f0bc7d515
-2011-04-12T20:35:47.000000Z
-850
-diegosalas@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-2328
-
-jsbinarysizetoolbar.js
-file
-
-
-
-
-2011-12-23T22:42:26.798309Z
-8e689b633772f961215b70da50a78ad1
-2011-04-12T20:35:47.000000Z
-850
-diegosalas@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-2090
-
-jsbinarysizebutton_test.html
-file
-
-
-
-
-2011-12-23T22:42:26.798309Z
-b4098d0ed38eeb1928e3a11617d7516c
-2011-04-12T20:35:47.000000Z
-850
-diegosalas@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-1622
-
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/benchmarks/.svn/prop-base/jsbinarysizebutton.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/benchmarks/.svn/prop-base/jsbinarysizebutton.js.svn-base
deleted file mode 100644
index 530636b..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/benchmarks/.svn/prop-base/jsbinarysizebutton.js.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 15
-text/javascript
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/benchmarks/.svn/prop-base/jsbinarysizebutton_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/benchmarks/.svn/prop-base/jsbinarysizebutton_test.html.svn-base
deleted file mode 100644
index d356868..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/benchmarks/.svn/prop-base/jsbinarysizebutton_test.html.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 9
-text/html
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/benchmarks/.svn/prop-base/jsbinarysizetoolbar.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/benchmarks/.svn/prop-base/jsbinarysizetoolbar.js.svn-base
deleted file mode 100644
index 530636b..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/benchmarks/.svn/prop-base/jsbinarysizetoolbar.js.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 15
-text/javascript
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/benchmarks/.svn/prop-base/jsbinarysizetoolbar_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/benchmarks/.svn/prop-base/jsbinarysizetoolbar_test.html.svn-base
deleted file mode 100644
index d356868..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/benchmarks/.svn/prop-base/jsbinarysizetoolbar_test.html.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 9
-text/html
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/benchmarks/.svn/text-base/jsbinarysizebutton.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/benchmarks/.svn/text-base/jsbinarysizebutton.js.svn-base
deleted file mode 100644
index ef73f2c..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/benchmarks/.svn/text-base/jsbinarysizebutton.js.svn-base
+++ /dev/null
@@ -1,64 +0,0 @@
-// Copyright 2008 The Closure Library Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS-IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/**
- * @fileoverview Sample code to instantiate a few goog.ui.Buttons. The
- * size of the resulting jsbinary for this sample file is tracked using
- * Greenspan (http://go/greenspan).
- *
- */
-
-goog.provide('goog.ui.benchmarks.jsbinarysizebutton');
-
-goog.require('goog.array');
-goog.require('goog.dom');
-goog.require('goog.events');
-goog.require('goog.ui.Button');
-goog.require('goog.ui.ButtonSide');
-goog.require('goog.ui.Component.EventType');
-goog.require('goog.ui.CustomButton');
-
-
-function drawButtons() {
- function logEvent(e) {
- }
-
- // Create a simple button programmatically
- var b1 = new goog.ui.Button('Hello!');
- b1.render(goog.dom.getElement('b1'));
- b1.setTooltip('I changed the tooltip.');
- goog.events.listen(b1, goog.ui.Component.EventType.ACTION, logEvent);
-
- // Create some custom buttons programatically.
- var disabledButton, leftButton, centerButton, rightButton;
- var customButtons = [
- new goog.ui.CustomButton('Button'),
- new goog.ui.CustomButton('Another Button'),
- disabledButton = new goog.ui.CustomButton('Disabled Button'),
- new goog.ui.CustomButton('Yet Another Button'),
- leftButton = new goog.ui.CustomButton('Left'),
- centerButton = new goog.ui.CustomButton('Center'),
- rightButton = new goog.ui.CustomButton('Right')
- ];
- disabledButton.setEnabled(false);
- leftButton.setCollapsed(goog.ui.ButtonSide.END);
- centerButton.setCollapsed(goog.ui.ButtonSide.BOTH);
- rightButton.setCollapsed(goog.ui.ButtonSide.START);
- goog.array.forEach(customButtons, function(b) {
- b.render(goog.dom.getElement('cb1'));
- goog.events.listen(b, goog.ui.Component.EventType.ACTION, logEvent);
- });
-}
-
-goog.exportSymbol('drawButtons', drawButtons);
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/benchmarks/.svn/text-base/jsbinarysizebutton_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/benchmarks/.svn/text-base/jsbinarysizebutton_test.html.svn-base
deleted file mode 100644
index d07ba7c..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/benchmarks/.svn/text-base/jsbinarysizebutton_test.html.svn-base
+++ /dev/null
@@ -1,58 +0,0 @@
-<!DOCTYPE html>
-<html>
-<!--
-Copyright 2010 The Closure Library Authors. All Rights Reserved.
-
-Use of this source code is governed by the Apache License, Version 2.0.
-See the COPYING file for details.
--->
-<head>
-<meta http-equiv="X-UA-Compatible" content="IE=edge">
- <title>Closure Unit Test - goog._jsbinarysize.button</title>
- <script src="../../base.js"></script>
- <script src="jsbinarysizebutton.js"></script>
- <script>
- goog.require("goog.testing.jsunit");
- </script>
- <link rel="stylesheet" type="text/css" href="../../demos/css/demo.css">
- <link rel="stylesheet" type="text/css" href="../../demos/css/button.css">
- <script>
- function setUp() {
- goog.dom.getElement('b1').innerHTML = '';
- goog.dom.getElement('cb1').innerHTML = '';
-
- }
-
- function tearDown() {
- goog.dom.getElement('b1').innerHTML = '';
- goog.dom.getElement('cb1').innerHTML = '';
- }
-
- function testDrawButton() {
- drawButtons();
- var buttonElem = goog.dom.getElement('b1').firstChild
- assertNotNull("Button container was not rendered", buttonElem);
- assertEquals("Button does not have correct title", "I changed the tooltip.",
- buttonElem.title);
- }
-
- function testDrawCustomButton() {
- drawButtons();
- var buttonElems = goog.dom.getElement('cb1').childNodes
- assertEquals("Incorrect number of buttons rendered", 7, buttonElems.length);
- }
- </script>
-</head>
-<body>
-<fieldset>
- <legend>Buttons should be rendered here <button onclick="drawButtons()">
- render</button></legend>
-
- <div id="buttons">
- <div id="b1"></div>
- <div id="cb1"></div>
- </div>
-</fieldset>
-</body>
-
-</html>
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/benchmarks/.svn/text-base/jsbinarysizetoolbar.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/benchmarks/.svn/text-base/jsbinarysizetoolbar.js.svn-base
deleted file mode 100644
index 5313471..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/benchmarks/.svn/text-base/jsbinarysizetoolbar.js.svn-base
+++ /dev/null
@@ -1,66 +0,0 @@
-// Copyright 2008 The Closure Library Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS-IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/**
- * @fileoverview Sample code to render a simple goog.ui.Toolbar. The
- * size of the resulting jsbinary for this sample file is tracked using
- * Greenspan (http://go/greenspan).
- *
- */
-
-goog.provide('goog.ui.benchmarks.jsbinarysizetoolbar');
-
-goog.require('goog.array');
-goog.require('goog.dom');
-goog.require('goog.events');
-goog.require('goog.object');
-goog.require('goog.ui.Component.EventType');
-goog.require('goog.ui.Option');
-goog.require('goog.ui.Toolbar');
-goog.require('goog.ui.ToolbarButton');
-goog.require('goog.ui.ToolbarSelect');
-goog.require('goog.ui.ToolbarSeparator');
-
-function drawToolbar() {
- function logEvent(e) {
- }
-
- var EVENTS = goog.object.getValues(goog.ui.Component.EventType);
-
- // Create the toolbar
- var t1 = new goog.ui.Toolbar();
-
- // Add a button
- t1.addChild(new goog.ui.ToolbarButton('Button'), true);
- t1.getChildAt(0).setTooltip('This is a tooltip for a button');
-
- // Add a separator
- t1.addChild(new goog.ui.ToolbarSeparator(), true);
-
- // Create the select menu
- var s1 = new goog.ui.ToolbarSelect('Select font');
- goog.array.forEach(['Normal', 'Times', 'Courier New', 'Georgia', 'Trebuchet',
- 'Verdana'],
- function(label) {
- var item = new goog.ui.Option(label);
- s1.addItem(item);
- });
- s1.setTooltip('Font');
-
- t1.addChild(s1, true);
- goog.events.listen(t1, EVENTS, logEvent);
- t1.render(goog.dom.getElement('toolbar'));
-}
-
-goog.exportSymbol('drawToolbar', drawToolbar);
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/benchmarks/.svn/text-base/jsbinarysizetoolbar_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/benchmarks/.svn/text-base/jsbinarysizetoolbar_test.html.svn-base
deleted file mode 100644
index 8676153..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/benchmarks/.svn/text-base/jsbinarysizetoolbar_test.html.svn-base
+++ /dev/null
@@ -1,49 +0,0 @@
-<!DOCTYPE html>
-<html>
-<!--
-Copyright 2010 The Closure Library Authors. All Rights Reserved.
-
-Use of this source code is governed by the Apache License, Version 2.0.
-See the COPYING file for details.
--->
-<head>
-<meta http-equiv="X-UA-Compatible" content="IE=edge">
- <title>Closure Unit Test - goog._jsbinarysize.toolbar</title>
- <script src="../../base.js"></script>
- <script src="jsbinarysizetoolbar.js"></script>
- <script>
- goog.require("goog.testing.jsunit");
- </script>
- <link rel="stylesheet" type="text/css" href="../../demos/css/demo.css">
- <link rel="stylesheet" type="text/css" href="../../demos/css/menus.css">
- <link rel="stylesheet" type="text/css" href="../../demos/css/toolbar.css">
- <script>
- function setUp() {
- goog.dom.getElement('toolbar').innerHTML = '';
- }
-
- function tearDown() {
- goog.dom.getElement('toolbar').innerHTML = '';
- }
-
- function testDrawToolbar() {
- drawToolbar();
- var toolbarElem = goog.dom.getElement('toolbar').firstChild
- assertNotNull("Toolbar container was not rendered", toolbarElem);
- assertEquals("Toolbar does not have expected number of children", 3,
- toolbarElem.childNodes.length);
-
-
- }
- </script>
-</head>
-<body>
-<fieldset>
- <legend>Toolbar should be rendered here <button onclick="drawToolbar()">
- render</button></legend>
-
- <div id="toolbar"></div>
-</fieldset>
-</body>
-
-</html>
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/continuationtestcase.js b/contexts/data/lib/closure-library/closure/goog/testing/continuationtestcase.js
index 684e7da..1fb57df 100644
--- a/contexts/data/lib/closure-library/closure/goog/testing/continuationtestcase.js
+++ b/contexts/data/lib/closure-library/closure/goog/testing/continuationtestcase.js
@@ -74,6 +74,7 @@
* }
* </pre>
*
+ * @author brenneman@google.com (Shawn Brenneman)
*/
@@ -288,7 +289,13 @@ goog.testing.ContinuationTestCase.prototype.runNextStep_ = function() {
/**
- * Creates a new test step that will run after a user-specified timeout.
+ * Creates a new test step that will run after a user-specified
+ * timeout. No guarantee is made on the execution order of the
+ * continuation, except for those provided by each browser's
+ * window.setTimeout. In particular, if two continuations are
+ * registered at the same time with very small delta for their
+ * durations, this class can not guarantee that the continuation with
+ * the smaller duration will be executed first.
* @param {Function} continuation The test function to invoke after the timeout.
* @param {number=} opt_duration The length of the timeout in milliseconds.
*/
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/continuationtestcase_test.html b/contexts/data/lib/closure-library/closure/goog/testing/continuationtestcase_test.html
index 910e9b1..d273afe 100644
--- a/contexts/data/lib/closure-library/closure/goog/testing/continuationtestcase_test.html
+++ b/contexts/data/lib/closure-library/closure/goog/testing/continuationtestcase_test.html
@@ -7,6 +7,7 @@ Use of this source code is governed by the Apache License, Version 2.0.
See the COPYING file for details.
-->
<!--
+Author: brenneman@google.com (Shawn Brenneman)
-->
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
@@ -75,7 +76,7 @@ function tearDown() {
waitForTimeout(function() {
// Pointless assertion to verify that tearDown methods can contain waits.
- assertTrue(testCase.now_() >= testCase.startTime_);
+ assertTrue(testCase.now() >= testCase.startTime_);
}, 0);
}
@@ -278,20 +279,22 @@ function testWaitForCondition() {
var counter = 0;
waitForCondition(function() {
- return ++counter >= 3;
+ return ++counter >= 2;
}, function() {
- assertEquals(3, counter);
- }, 10, 100);
+ assertEquals(2, counter);
+ }, 10, 200);
}
function testOutOfOrderWaits() {
var counter = 0;
- waitForTimeout(function() {assertEquals(5, ++counter);}, 50);
- waitForTimeout(function() {assertEquals(1, ++counter);}, 10);
- waitForTimeout(function() {assertEquals(3, ++counter);}, 30);
- waitForTimeout(function() {assertEquals(2, ++counter);}, 20);
- waitForTimeout(function() {assertEquals(4, ++counter);}, 40);
+
+ // Note that if the delta between the timeout is too small, two
+ // continuation may be invoked at the same timer tick, using the
+ // registration order.
+ waitForTimeout(function() {assertEquals(3, ++counter);}, 200);
+ waitForTimeout(function() {assertEquals(1, ++counter);}, 0);
+ waitForTimeout(function() {assertEquals(2, ++counter);}, 100);
}
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/deferredtestcase.js b/contexts/data/lib/closure-library/closure/goog/testing/deferredtestcase.js
index 3d28b55..e499cc1 100644
--- a/contexts/data/lib/closure-library/closure/goog/testing/deferredtestcase.js
+++ b/contexts/data/lib/closure-library/closure/goog/testing/deferredtestcase.js
@@ -146,11 +146,9 @@ goog.testing.DeferredTestCase.prototype.waitForDeferred = function(a, opt_b) {
default: // Shouldn't be here in compiled mode
throw Error('Invalid number of arguments');
}
-
deferred.addCallbacks(this.onSuccess, this.onError, this);
if (!waitMsg) {
- waitMsg =
- 'Waiting for deferred in ' + this.activeTest.name;
+ waitMsg = 'Waiting for deferred in ' + this.getCurrentStepName();
}
this.waitForAsync( /** @type {!string} */ (waitMsg));
deferred.callback(true);
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/deferredtestcase_test.html b/contexts/data/lib/closure-library/closure/goog/testing/deferredtestcase_test.html
index 09d1910..d6820bf 100644
--- a/contexts/data/lib/closure-library/closure/goog/testing/deferredtestcase_test.html
+++ b/contexts/data/lib/closure-library/closure/goog/testing/deferredtestcase_test.html
@@ -16,6 +16,7 @@ See the COPYING file for details.
goog.require('goog.testing.DeferredTestCase');
goog.require('goog.testing.TestRunner');
goog.require('goog.testing.jsunit');
+ goog.require('goog.testing.recordFunction');
</script>
</head>
<body>
@@ -98,8 +99,6 @@ See the COPYING file for details.
var d = new goog.async.Deferred();
d.addCallback(function() {
return goog.async.Deferred.succeed(true);
- //return goog.async.Deferred.fail(true);
- //return new goog.async.Deferred();
});
var testCompleteDeferred = createDeferredTestCase(d);
@@ -124,26 +123,16 @@ See the COPYING file for details.
var testCompleteDeferred = createDeferredTestCase(d);
- // Override and consume test exception
- var origFn = testTestCase.doAsyncError;
- testTestCase.doAsyncError = function() {
- try {
- origFn();
- } catch (e) {
- testCompleteDeferred.callback(true);
- }
- }
- testTestCase.execute();
-
- var deferredCallbackOnFail = new goog.async.Deferred();
- deferredCallbackOnFail.addCallback(function() {
- return testCompleteDeferred;
- });
- deferredCallbackOnFail.addCallback(function() {
- assertTrue('Test case should have failed.', !testTestCase.isSuccess());
+ // Mock doAsyncError to instead let the test completes successfully,
+ // but record the failure. The test works as is because the failing
+ // deferred is not actually asynchronous.
+ var mockDoAsyncError = goog.testing.recordFunction(function() {
+ testTestCase.continueTesting();
});
+ testTestCase.doAsyncError = mockDoAsyncError;
- deferredTestCase.waitForDeferred(deferredCallbackOnFail);
+ testTestCase.execute();
+ assertEquals(1, mockDoAsyncError.getCallCount());
}
</script>
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/dom.js b/contexts/data/lib/closure-library/closure/goog/testing/dom.js
index 4056c19..1179a29 100644
--- a/contexts/data/lib/closure-library/closure/goog/testing/dom.js
+++ b/contexts/data/lib/closure-library/closure/goog/testing/dom.js
@@ -273,7 +273,7 @@ goog.testing.dom.assertHtmlContentsMatch = function(htmlPattern, actual,
}
};
- // HACK(user): IE has unique ideas about whitespace handling when setting
+ // HACK(brenneman): IE has unique ideas about whitespace handling when setting
// innerHTML. This results in elision of leading whitespace in the expected
// nodes where doing so doesn't affect visible rendering. As a workaround, we
// remove the leading whitespace in the actual nodes where necessary.
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/editor/.svn/all-wcprops b/contexts/data/lib/closure-library/closure/goog/testing/editor/.svn/all-wcprops
deleted file mode 100644
index 77e2ac1..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/editor/.svn/all-wcprops
+++ /dev/null
@@ -1,35 +0,0 @@
-K 25
-svn:wc:ra_dav:version-url
-V 52
-/svn/!svn/ver/1302/trunk/closure/goog/testing/editor
-END
-dom_test.html
-K 25
-svn:wc:ra_dav:version-url
-V 65
-/svn/!svn/ver/850/trunk/closure/goog/testing/editor/dom_test.html
-END
-testhelper_test.html
-K 25
-svn:wc:ra_dav:version-url
-V 73
-/svn/!svn/ver/1156/trunk/closure/goog/testing/editor/testhelper_test.html
-END
-fieldmock.js
-K 25
-svn:wc:ra_dav:version-url
-V 64
-/svn/!svn/ver/850/trunk/closure/goog/testing/editor/fieldmock.js
-END
-testhelper.js
-K 25
-svn:wc:ra_dav:version-url
-V 66
-/svn/!svn/ver/1302/trunk/closure/goog/testing/editor/testhelper.js
-END
-dom.js
-K 25
-svn:wc:ra_dav:version-url
-V 58
-/svn/!svn/ver/850/trunk/closure/goog/testing/editor/dom.js
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/editor/.svn/entries b/contexts/data/lib/closure-library/closure/goog/testing/editor/.svn/entries
deleted file mode 100644
index 58767c8..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/editor/.svn/entries
+++ /dev/null
@@ -1,198 +0,0 @@
-10
-
-dir
-1494
-http://closure-library.googlecode.com/svn/trunk/closure/goog/testing/editor
-http://closure-library.googlecode.com/svn
-
-
-
-2011-09-27T00:20:47.000000Z
-1302
-bmccann@google.com
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-0b95b8e8-c90f-11de-9d4f-f947ee5921c8
-
-dom_test.html
-file
-
-
-
-
-2011-12-23T22:42:27.128313Z
-b635f4e62292e4ff089c9a59593464de
-2011-04-12T20:35:47.000000Z
-850
-diegosalas@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-10897
-
-testhelper_test.html
-file
-
-
-
-
-2011-12-23T22:42:27.129313Z
-6d83e59e3efce2e4ad0014c026d79426
-2011-07-26T02:32:30.000000Z
-1156
-nicksantos@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-5808
-
-fieldmock.js
-file
-
-
-
-
-2011-12-23T22:42:27.129313Z
-3e1e208e4d902d568c1f72567b2b3ec1
-2011-04-12T20:35:47.000000Z
-850
-diegosalas@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-2753
-
-testhelper.js
-file
-
-
-
-
-2011-12-23T22:42:27.130313Z
-95780254270823404fe7aed28ffac4d9
-2011-09-27T00:20:47.000000Z
-1302
-bmccann@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-5486
-
-dom.js
-file
-
-
-
-
-2011-12-23T22:42:27.130313Z
-cd5256d7adbb12905002b561ade42c03
-2011-04-12T20:35:47.000000Z
-850
-diegosalas@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-12933
-
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/editor/.svn/prop-base/dom.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/editor/.svn/prop-base/dom.js.svn-base
deleted file mode 100644
index 530636b..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/editor/.svn/prop-base/dom.js.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 15
-text/javascript
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/editor/.svn/prop-base/dom_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/editor/.svn/prop-base/dom_test.html.svn-base
deleted file mode 100644
index d356868..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/editor/.svn/prop-base/dom_test.html.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 9
-text/html
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/editor/.svn/prop-base/fieldmock.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/editor/.svn/prop-base/fieldmock.js.svn-base
deleted file mode 100644
index 530636b..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/editor/.svn/prop-base/fieldmock.js.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 15
-text/javascript
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/editor/.svn/prop-base/testhelper.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/editor/.svn/prop-base/testhelper.js.svn-base
deleted file mode 100644
index 530636b..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/editor/.svn/prop-base/testhelper.js.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 15
-text/javascript
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/editor/.svn/prop-base/testhelper_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/editor/.svn/prop-base/testhelper_test.html.svn-base
deleted file mode 100644
index d356868..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/editor/.svn/prop-base/testhelper_test.html.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 9
-text/html
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/editor/.svn/text-base/dom.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/editor/.svn/text-base/dom.js.svn-base
deleted file mode 100644
index d30b711..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/editor/.svn/text-base/dom.js.svn-base
+++ /dev/null
@@ -1,293 +0,0 @@
-// Copyright 2009 The Closure Library Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS-IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/**
- * @fileoverview Testing utilities for editor specific DOM related tests.
- *
- */
-
-goog.provide('goog.testing.editor.dom');
-
-goog.require('goog.dom.NodeType');
-goog.require('goog.dom.TagIterator');
-goog.require('goog.dom.TagWalkType');
-goog.require('goog.iter');
-goog.require('goog.string');
-goog.require('goog.testing.asserts');
-
-
-/**
- * Returns the previous (in document order) node from the given node that is a
- * non-empty text node, or null if none is found or opt_stopAt is not an
- * ancestor of node. Note that if the given node has children, the search will
- * start from the end tag of the node, meaning all its descendants will be
- * included in the search, unless opt_skipDescendants is true.
- * @param {Node} node Node to start searching from.
- * @param {Node=} opt_stopAt Node to stop searching at (search will be
- * restricted to this node's subtree), defaults to the body of the document
- * containing node.
- * @param {boolean=} opt_skipDescendants Whether to skip searching the given
- * node's descentants.
- * @return {Text} The previous (in document order) node from the given node
- * that is a non-empty text node, or null if none is found.
- */
-goog.testing.editor.dom.getPreviousNonEmptyTextNode = function(
- node, opt_stopAt, opt_skipDescendants) {
- return goog.testing.editor.dom.getPreviousNextNonEmptyTextNodeHelper_(
- node, opt_stopAt, opt_skipDescendants, true);
-};
-
-
-/**
- * Returns the next (in document order) node from the given node that is a
- * non-empty text node, or null if none is found or opt_stopAt is not an
- * ancestor of node. Note that if the given node has children, the search will
- * start from the start tag of the node, meaning all its descendants will be
- * included in the search, unless opt_skipDescendants is true.
- * @param {Node} node Node to start searching from.
- * @param {Node=} opt_stopAt Node to stop searching at (search will be
- * restricted to this node's subtree), defaults to the body of the document
- * containing node.
- * @param {boolean=} opt_skipDescendants Whether to skip searching the given
- * node's descentants.
- * @return {Text} The next (in document order) node from the given node that
- * is a non-empty text node, or null if none is found or opt_stopAt is not
- * an ancestor of node.
- */
-goog.testing.editor.dom.getNextNonEmptyTextNode = function(
- node, opt_stopAt, opt_skipDescendants) {
- return goog.testing.editor.dom.getPreviousNextNonEmptyTextNodeHelper_(
- node, opt_stopAt, opt_skipDescendants, false);
-};
-
-
-/**
- * Helper that returns the previous or next (in document order) node from the
- * given node that is a non-empty text node, or null if none is found or
- * opt_stopAt is not an ancestor of node. Note that if the given node has
- * children, the search will start from the end or start tag of the node
- * (depending on whether it's searching for the previous or next node), meaning
- * all its descendants will be included in the search, unless
- * opt_skipDescendants is true.
- * @param {Node} node Node to start searching from.
- * @param {Node=} opt_stopAt Node to stop searching at (search will be
- * restricted to this node's subtree), defaults to the body of the document
- * containing node.
- * @param {boolean=} opt_skipDescendants Whether to skip searching the given
- * node's descentants.
- * @param {boolean=} opt_isPrevious Whether to search for the previous non-empty
- * text node instead of the next one.
- * @return {Text} The next (in document order) node from the given node that
- * is a non-empty text node, or null if none is found or opt_stopAt is not
- * an ancestor of node.
- * @private
- */
-goog.testing.editor.dom.getPreviousNextNonEmptyTextNodeHelper_ = function(
- node, opt_stopAt, opt_skipDescendants, opt_isPrevious) {
- opt_stopAt = opt_stopAt || node.ownerDocument.body;
- // Initializing the iterator to iterate over the children of opt_stopAt
- // makes it stop only when it finishes iterating through all of that
- // node's children, even though we will start at a different node and exit
- // that starting node's subtree in the process.
- var iter = new goog.dom.TagIterator(opt_stopAt, opt_isPrevious);
-
- // TODO(user): Move this logic to a new method in TagIterator such as
- // skipToNode().
- // Then we set the iterator to start at the given start node, not opt_stopAt.
- var walkType; // Let TagIterator set the initial walk type by default.
- var depth = goog.testing.editor.dom.getRelativeDepth_(node, opt_stopAt);
- if (depth == -1) {
- return null; // Fail because opt_stopAt is not an ancestor of node.
- }
- if (node.nodeType == goog.dom.NodeType.ELEMENT) {
- if (opt_skipDescendants) {
- // Specifically set the initial walk type so that we skip the descendant
- // subtree by starting at the start if going backwards or at the end if
- // going forwards.
- walkType = opt_isPrevious ? goog.dom.TagWalkType.START_TAG :
- goog.dom.TagWalkType.END_TAG;
- } else {
- // We're starting "inside" an element node so the depth needs to be one
- // deeper than the node's actual depth. That's how TagIterator works!
- depth++;
- }
- }
- iter.setPosition(node, walkType, depth);
-
- // Advance the iterator so it skips the start node.
- try {
- iter.next();
- } catch (e) {
- return null; // It could have been a leaf node.
- }
- // Now just get the first non-empty text node the iterator finds.
- var filter = goog.iter.filter(iter,
- goog.testing.editor.dom.isNonEmptyTextNode_);
- try {
- return /** @type {Text} */ (filter.next());
- } catch (e) { // No next item is available so return null.
- return null;
- }
-};
-
-
-/**
- * Returns whether the given node is a non-empty text node.
- * @param {Node} node Node to be checked.
- * @return {boolean} Whether the given node is a non-empty text node.
- * @private
- */
-goog.testing.editor.dom.isNonEmptyTextNode_ = function(node) {
- return !!node && node.nodeType == goog.dom.NodeType.TEXT && node.length > 0;
-};
-
-
-/**
- * Returns the depth of the given node relative to the given parent node, or -1
- * if the given node is not a descendant of the given parent node. E.g. if
- * node == parentNode returns 0, if node.parentNode == parentNode returns 1,
- * etc.
- * @param {Node} node Node whose depth to get.
- * @param {Node} parentNode Node relative to which the depth should be
- * calculated.
- * @return {number} The depth of the given node relative to the given parent
- * node, or -1 if the given node is not a descendant of the given parent
- * node.
- * @private
- */
-goog.testing.editor.dom.getRelativeDepth_ = function(node, parentNode) {
- var depth = 0;
- while (node) {
- if (node == parentNode) {
- return depth;
- }
- node = node.parentNode;
- depth++;
- }
- return -1;
-};
-
-
-/**
- * Assert that the range is surrounded by the given strings. This is useful
- * because different browsers can place the range endpoints inside different
- * nodes even when visually the range looks the same. Also, there may be empty
- * text nodes in the way (again depending on the browser) making it difficult to
- * use assertRangeEquals.
- * @param {string} before String that should occur immediately before the start
- * point of the range. If this is the empty string, assert will only succeed
- * if there is no text before the start point of the range.
- * @param {string} after String that should occur immediately after the end
- * point of the range. If this is the empty string, assert will only succeed
- * if there is no text after the end point of the range.
- * @param {goog.dom.AbstractRange} range The range to be tested.
- * @param {Node=} opt_stopAt Node to stop searching at (search will be
- * restricted to this node's subtree).
- */
-goog.testing.editor.dom.assertRangeBetweenText = function(before,
- after,
- range,
- opt_stopAt) {
- var previousText =
- goog.testing.editor.dom.getTextFollowingRange_(range, true, opt_stopAt);
- if (before == '') {
- assertNull('Expected nothing before range but found <' + previousText + '>',
- previousText);
- } else {
- assertNotNull('Expected <' + before + '> before range but found nothing',
- previousText);
- assertTrue('Expected <' + before + '> before range but found <' +
- previousText + '>',
- goog.string.endsWith(
- /** @type {string} */ (previousText), before));
- }
- var nextText =
- goog.testing.editor.dom.getTextFollowingRange_(range, false, opt_stopAt);
- if (after == '') {
- assertNull('Expected nothing after range but found <' + nextText + '>',
- nextText);
- } else {
- assertNotNull('Expected <' + after + '> after range but found nothing',
- nextText);
- assertTrue('Expected <' + after + '> after range but found <' +
- nextText + '>',
- goog.string.startsWith(
- /** @type {string} */ (nextText), after));
- }
-};
-
-
-/**
- * Returns the text that follows the given range, where the term "follows" means
- * "comes immediately before the start of the range" if isBefore is true, and
- * "comes immediately after the end of the range" if isBefore is false, or null
- * if no non-empty text node is found.
- * @param {goog.dom.AbstractRange} range The range to search from.
- * @param {boolean} isBefore Whether to search before the range instead of
- * after it.
- * @param {Node=} opt_stopAt Node to stop searching at (search will be
- * restricted to this node's subtree).
- * @return {?string} The text that follows the given range, or null if no
- * non-empty text node is found.
- * @private
- */
-goog.testing.editor.dom.getTextFollowingRange_ = function(range,
- isBefore,
- opt_stopAt) {
- var followingTextNode;
- var endpointNode = isBefore ? range.getStartNode() : range.getEndNode();
- var endpointOffset = isBefore ? range.getStartOffset() : range.getEndOffset();
- var getFollowingTextNode =
- isBefore ? goog.testing.editor.dom.getPreviousNonEmptyTextNode :
- goog.testing.editor.dom.getNextNonEmptyTextNode;
-
- if (endpointNode.nodeType == goog.dom.NodeType.TEXT) {
- // Range endpoint is in a text node.
- var endText = endpointNode.nodeValue;
- if (isBefore ? endpointOffset > 0 : endpointOffset < endText.length) {
- // There is text in this node following the endpoint so return the portion
- // that follows the endpoint.
- return isBefore ? endText.substr(0, endpointOffset) :
- endText.substr(endpointOffset);
- } else {
- // There is no text following the endpoint so look for the follwing text
- // node.
- followingTextNode = getFollowingTextNode(endpointNode, opt_stopAt);
- return followingTextNode && followingTextNode.nodeValue;
- }
- } else {
- // Range endpoint is in an element node.
- var numChildren = endpointNode.childNodes.length;
- if (isBefore ? endpointOffset > 0 : endpointOffset < numChildren) {
- // There is at least one child following the endpoint.
- var followingChild =
- endpointNode.childNodes[isBefore ? endpointOffset - 1 :
- endpointOffset];
- if (goog.testing.editor.dom.isNonEmptyTextNode_(followingChild)) {
- // The following child has text so return that.
- return followingChild.nodeValue;
- } else {
- // The following child has no text so look for the following text node.
- followingTextNode = getFollowingTextNode(followingChild, opt_stopAt);
- return followingTextNode && followingTextNode.nodeValue;
- }
- } else {
- // There is no child following the endpoint, so search from the endpoint
- // node, but don't search its children because they are not following the
- // endpoint!
- followingTextNode = getFollowingTextNode(endpointNode, opt_stopAt, true);
- return followingTextNode && followingTextNode.nodeValue;
- }
- }
-};
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/editor/.svn/text-base/dom_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/editor/.svn/text-base/dom_test.html.svn-base
deleted file mode 100644
index c260510..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/editor/.svn/text-base/dom_test.html.svn-base
+++ /dev/null
@@ -1,295 +0,0 @@
-<!DOCTYPE html>
-<html lang="en" dir="ltr">
-<head>
-<meta http-equiv="X-UA-Compatible" content="IE=edge">
- <!--
-
- @author marcosalmeida@google.com (Marcos Almeida)
- -->
- <title>Closure Unit Tests - goog.testing.editor.dom</title>
- <script src="../../base.js"></script>
- <script>
- goog.require('goog.dom');
- goog.require('goog.dom.TagName');
- goog.require('goog.functions');
- goog.require('goog.testing.editor.dom');
- goog.require('goog.testing.jsunit');
- </script>
-</head>
-<body>
-<div id="root"></div>
-<script type="text/javascript">
- var root = goog.dom.getElement('root');
- var parentNode, childNode1, childNode2, childNode3;
- var first, middle, last;
-
- function tearDown() {
- root.innerHTML = '';
- }
-
- function setUpNonEmptyTests() {
- childNode1 = goog.dom.createElement(goog.dom.TagName.DIV);
- childNode2 = goog.dom.createElement(goog.dom.TagName.DIV);
- childNode3 = goog.dom.createElement(goog.dom.TagName.DIV);
- parentNode = goog.dom.createDom(goog.dom.TagName.DIV,
- null,
- childNode1,
- childNode2,
- childNode3);
- goog.dom.appendChild(root, parentNode);
-
- childNode1.appendChild(goog.dom.createTextNode('One'));
- childNode1.appendChild(goog.dom.createTextNode(''));
-
- childNode2.appendChild(goog.dom.createElement(goog.dom.TagName.BR));
- childNode2.appendChild(goog.dom.createTextNode('TwoA'));
- childNode2.appendChild(goog.dom.createTextNode('TwoB'));
- childNode2.appendChild(goog.dom.createElement(goog.dom.TagName.BR));
-
- childNode3.appendChild(goog.dom.createTextNode(''));
- childNode3.appendChild(goog.dom.createTextNode('Three'));
- }
-
- function testGetNextNonEmptyTextNode() {
- setUpNonEmptyTests();
-
- var nodeOne =
- goog.testing.editor.dom.getNextNonEmptyTextNode(parentNode);
- assertEquals('Should have found the next non-empty text node',
- 'One',
- nodeOne.nodeValue);
- var nodeTwoA =
- goog.testing.editor.dom.getNextNonEmptyTextNode(nodeOne);
- assertEquals('Should have found the next non-empty text node',
- 'TwoA',
- nodeTwoA.nodeValue);
- var nodeTwoB =
- goog.testing.editor.dom.getNextNonEmptyTextNode(nodeTwoA);
- assertEquals('Should have found the next non-empty text node',
- 'TwoB',
- nodeTwoB.nodeValue);
- var nodeThree =
- goog.testing.editor.dom.getNextNonEmptyTextNode(nodeTwoB);
- assertEquals('Should have found the next non-empty text node',
- 'Three',
- nodeThree.nodeValue);
- var nodeNull =
- goog.testing.editor.dom.getNextNonEmptyTextNode(nodeThree, parentNode);
- assertNull('Should not have found any non-empty text node', nodeNull);
-
- var nodeStop =
- goog.testing.editor.dom.getNextNonEmptyTextNode(nodeOne, childNode1);
- assertNull('Should have stopped before finding a node', nodeStop);
-
- var nodeBeforeStop =
- goog.testing.editor.dom.getNextNonEmptyTextNode(nodeTwoA, childNode2);
- assertEquals('Should have found the next non-empty text node',
- 'TwoB',
- nodeBeforeStop.nodeValue);
- }
-
- function testGetPreviousNonEmptyTextNode() {
- setUpNonEmptyTests();
-
- var nodeThree =
- goog.testing.editor.dom.getPreviousNonEmptyTextNode(parentNode);
- assertEquals('Should have found the previous non-empty text node',
- 'Three',
- nodeThree.nodeValue);
- var nodeTwoB =
- goog.testing.editor.dom.getPreviousNonEmptyTextNode(nodeThree);
- assertEquals('Should have found the previous non-empty text node',
- 'TwoB',
- nodeTwoB.nodeValue);
- var nodeTwoA =
- goog.testing.editor.dom.getPreviousNonEmptyTextNode(nodeTwoB);
- assertEquals('Should have found the previous non-empty text node',
- 'TwoA',
- nodeTwoA.nodeValue);
- var nodeOne =
- goog.testing.editor.dom.getPreviousNonEmptyTextNode(nodeTwoA);
- assertEquals('Should have found the previous non-empty text node',
- 'One',
- nodeOne.nodeValue);
- var nodeNull =
- goog.testing.editor.dom.getPreviousNonEmptyTextNode(nodeOne,
- parentNode);
- assertNull('Should not have found any non-empty text node', nodeNull);
-
- var nodeStop =
- goog.testing.editor.dom.getPreviousNonEmptyTextNode(nodeThree,
- childNode3);
- assertNull('Should have stopped before finding a node', nodeStop);
-
- var nodeBeforeStop =
- goog.testing.editor.dom.getPreviousNonEmptyTextNode(nodeTwoB,
- childNode2);
- assertEquals('Should have found the previous non-empty text node',
- 'TwoA',
- nodeBeforeStop.nodeValue);
- }
-
-
- function setUpAssertRangeBetweenText() {
- // Create the following structure: <[01]><[]><[23]>
- // Where <> delimits spans, [] delimits text nodes, 01 and 23 are text.
- // We will test all 10 positions in between 0 and 2. All should pass.
- first = goog.dom.createDom(goog.dom.TagName.SPAN, null, '01');
- middle = goog.dom.createElement(goog.dom.TagName.SPAN);
- var emptyTextNode = goog.dom.createTextNode('');
- goog.dom.appendChild(middle, emptyTextNode);
- last = goog.dom.createDom(goog.dom.TagName.SPAN, null, '23');
- goog.dom.appendChild(root, first);
- goog.dom.appendChild(root, middle);
- goog.dom.appendChild(root, last);
- }
-
- function createFakeRange(startNode, startOffset, opt_endNode, opt_endOffset) {
- opt_endNode = opt_endNode || startNode;
- opt_endOffset = opt_endOffset || startOffset;
- return {
- getStartNode: goog.functions.constant(startNode),
- getStartOffset: goog.functions.constant(startOffset),
- getEndNode: goog.functions.constant(opt_endNode),
- getEndOffset: goog.functions.constant(opt_endOffset)
- };
- }
-
- function testAssertRangeBetweenText0() {
- setUpAssertRangeBetweenText();
- goog.testing.editor.dom.assertRangeBetweenText('0', '1',
- createFakeRange(first.firstChild, 1));
- }
-
- function testAssertRangeBetweenText1() {
- setUpAssertRangeBetweenText();
- goog.testing.editor.dom.assertRangeBetweenText('1', '2',
- createFakeRange(first.firstChild, 2));
- }
-
- function testAssertRangeBetweenText2() {
- setUpAssertRangeBetweenText();
- goog.testing.editor.dom.assertRangeBetweenText('1', '2',
- createFakeRange(first, 1));
- }
-
- function testAssertRangeBetweenText3() {
- setUpAssertRangeBetweenText();
- goog.testing.editor.dom.assertRangeBetweenText('1', '2',
- createFakeRange(root, 1));
- }
-
- function testAssertRangeBetweenText4() {
- setUpAssertRangeBetweenText();
- goog.testing.editor.dom.assertRangeBetweenText('1', '2',
- createFakeRange(middle, 0));
- }
-
- function testAssertRangeBetweenText5() {
- setUpAssertRangeBetweenText();
- goog.testing.editor.dom.assertRangeBetweenText('1', '2',
- createFakeRange(middle.firstChild, 0));
- }
-
- function testAssertRangeBetweenText6() {
- setUpAssertRangeBetweenText();
- goog.testing.editor.dom.assertRangeBetweenText('1', '2',
- createFakeRange(middle, 1));
- }
-
- function testAssertRangeBetweenText7() {
- setUpAssertRangeBetweenText();
- goog.testing.editor.dom.assertRangeBetweenText('1', '2',
- createFakeRange(root, 2));
- }
-
- function testAssertRangeBetweenText8() {
- setUpAssertRangeBetweenText();
- goog.testing.editor.dom.assertRangeBetweenText('1', '2',
- createFakeRange(last, 0));
- }
-
- function testAssertRangeBetweenText9() {
- setUpAssertRangeBetweenText();
- goog.testing.editor.dom.assertRangeBetweenText('1', '2',
- createFakeRange(last.firstChild, 0));
- }
-
-
- function testAssertRangeBetweenTextBefore() {
- setUpAssertRangeBetweenText();
- // Test that it works when the cursor is at the beginning of all text.
- goog.testing.editor.dom.assertRangeBetweenText('', '0',
- createFakeRange(first.firstChild, 0),
- root); // Restrict to root div so it won't find /n's and script.
- }
-
- function testAssertRangeBetweenTextAfter() {
- setUpAssertRangeBetweenText();
- // Test that it works when the cursor is at the end of all text.
- goog.testing.editor.dom.assertRangeBetweenText('3', '',
- createFakeRange(last.firstChild, 2),
- root); // Restrict to root div so it won't find /n's and script.
- }
-
-
- function testAssertRangeBetweenTextFail1() {
- setUpAssertRangeBetweenText();
- var e = assertThrows('assertRangeBetweenText should have failed',
- function() {
- goog.testing.editor.dom.assertRangeBetweenText('1', '3',
- createFakeRange(first.firstChild, 2));
- });
- assertContains('Assert reason incorrect',
- 'Expected <3> after range but found <23>', e.message);
- }
-
- function testAssertRangeBetweenTextFail2() {
- setUpAssertRangeBetweenText();
- var e = assertThrows('assertRangeBetweenText should have failed',
- function() {
- goog.testing.editor.dom.assertRangeBetweenText('1', '2',
- createFakeRange(first.firstChild, 2, last.firstChild, 1));
- });
- assertContains('Assert reason incorrect',
- 'Expected <2> after range but found <3>', e.message);
- }
-
- function testAssertRangeBetweenTextBeforeFail() {
- setUpAssertRangeBetweenText();
- // Test that it gives the right message when the cursor is at the beginning
- // of all text but you're expecting something before it.
- var e = assertThrows('assertRangeBetweenText should have failed',
- function() {
- goog.testing.editor.dom.assertRangeBetweenText('-1', '0',
- createFakeRange(first.firstChild, 0),
- root); // Restrict to root div so it won't find /n's and script.
- });
- assertContains('Assert reason incorrect',
- 'Expected <-1> before range but found nothing', e.message);
- }
-
- function testAssertRangeBetweenTextAfterFail() {
- setUpAssertRangeBetweenText();
- // Test that it gives the right message when the cursor is at the end
- // of all text but you're expecting something after it.
- var e = assertThrows('assertRangeBetweenText should have failed',
- function() {
- goog.testing.editor.dom.assertRangeBetweenText('3', '4',
- createFakeRange(last.firstChild, 2),
- root); // Restrict to root div so it won't find /n's and script.
- });
- assertContains('Assert reason incorrect',
- 'Expected <4> after range but found nothing', e.message);
- }
-
-
-</script>
-</body>
-</html>
-<!--
-Copyright 2009 The Closure Library Authors. All Rights Reserved.
-
-Use of this source code is governed by the Apache License, Version 2.0.
-See the COPYING file for details.
--->
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/editor/.svn/text-base/fieldmock.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/editor/.svn/text-base/fieldmock.js.svn-base
deleted file mode 100644
index d981a6b..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/editor/.svn/text-base/fieldmock.js.svn-base
+++ /dev/null
@@ -1,90 +0,0 @@
-// Copyright 2008 The Closure Library Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS-IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/**
- * @fileoverview Mock of goog.editor.field.
- *
- * @author robbyw@google.com (Robby Walker)
- */
-
-goog.provide('goog.testing.editor.FieldMock');
-
-goog.require('goog.dom');
-goog.require('goog.dom.Range');
-goog.require('goog.editor.Field');
-goog.require('goog.testing.LooseMock');
-
-
-
-/**
- * Mock of goog.editor.Field.
- * @param {Window=} opt_window Window the field would edit. Defaults to
- * {@code window}.
- * @param {Window=} opt_appWindow "AppWindow" of the field, which can be
- * different from {@code opt_window} when mocking a field that uses an
- * iframe. Defaults to {@code opt_window}.
- * @param {goog.dom.AbstractRange=} opt_range An object (mock or real) to be
- * returned by getRange(). If ommitted, a new goog.dom.Range is created
- * from the window every time getRange() is called.
- * @constructor
- * @extends {goog.testing.LooseMock}
- * @suppress {missingProperties} Mocks do not fit in the type system well.
- */
-goog.testing.editor.FieldMock =
- function(opt_window, opt_appWindow, opt_range) {
- goog.testing.LooseMock.call(this, goog.editor.Field);
- opt_window = opt_window || window;
- opt_appWindow = opt_appWindow || opt_window;
-
- this.getAppWindow();
- this.$anyTimes();
- this.$returns(opt_appWindow);
-
- this.getRange();
- this.$anyTimes();
- this.$does(function() {
- return opt_range || goog.dom.Range.createFromWindow(opt_window);
- });
-
- this.getEditableDomHelper();
- this.$anyTimes();
- this.$returns(goog.dom.getDomHelper(opt_window.document));
-
- this.usesIframe();
- this.$anyTimes();
-
- this.getBaseZindex();
- this.$anyTimes();
- this.$returns(0);
-
-
- // These methods cannot be set on the prototype, because the prototype
- // gets stepped on by the mock framework.
- var inModalMode = false;
-
- /**
- * @return {boolean} Whether we're in modal interaction mode.
- */
- this.inModalMode = function() {
- return inModalMode;
- };
-
- /**
- * @param {boolean} mode Sets whether we're in modal interaction mode.
- */
- this.setModalMode = function(mode) {
- inModalMode = mode;
- };
-};
-goog.inherits(goog.testing.editor.FieldMock, goog.testing.LooseMock);
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/editor/.svn/text-base/testhelper.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/editor/.svn/text-base/testhelper.js.svn-base
deleted file mode 100644
index 10f6f18..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/editor/.svn/text-base/testhelper.js.svn-base
+++ /dev/null
@@ -1,174 +0,0 @@
-// Copyright 2008 The Closure Library Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS-IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/**
- * @fileoverview Class that allows for simple text editing tests.
- *
- * @author robbyw@google.com (Robby Walker)
- */
-
-goog.provide('goog.testing.editor.TestHelper');
-
-goog.require('goog.Disposable');
-goog.require('goog.dom');
-goog.require('goog.dom.Range');
-goog.require('goog.editor.BrowserFeature');
-goog.require('goog.editor.node');
-goog.require('goog.testing.dom');
-
-
-/**
- * Create a new test controller.
- * @param {Element} root The root editable element.
- * @constructor
- * @extends {goog.Disposable}
- */
-goog.testing.editor.TestHelper = function(root) {
- if (!root) {
- throw Error('Null root');
- }
- goog.Disposable.call(this);
-
- /**
- * Convenience variable for root DOM element.
- * @type {!Element}
- * @private
- */
- this.root_ = root;
-
- /**
- * The starting HTML of the editable element.
- * @type {string}
- * @private
- */
- this.savedHtml_ = '';
-};
-goog.inherits(goog.testing.editor.TestHelper, goog.Disposable);
-
-
-/**
- * Selects a new root element.
- * @param {Element} root The root editable element.
- */
-goog.testing.editor.TestHelper.prototype.setRoot = function(root) {
- if (!root) {
- throw Error('Null root');
- }
- this.root_ = root;
-};
-
-
-/**
- * Make the root element editable. Alse saves its HTML to be restored
- * in tearDown.
- */
-goog.testing.editor.TestHelper.prototype.setUpEditableElement = function() {
- this.savedHtml_ = this.root_.innerHTML;
- if (goog.editor.BrowserFeature.HAS_CONTENT_EDITABLE) {
- this.root_.contentEditable = true;
- } else {
- this.root_.ownerDocument.designMode = 'on';
- }
- this.root_.setAttribute('g_editable', 'true');
-};
-
-
-/**
- * Reset the element previously initialized, restoring its HTML and making it
- * non editable.
- */
-goog.testing.editor.TestHelper.prototype.tearDownEditableElement = function() {
- if (goog.editor.BrowserFeature.HAS_CONTENT_EDITABLE) {
- this.root_.contentEditable = false;
- } else {
- this.root_.ownerDocument.designMode = 'off';
- }
- goog.dom.removeChildren(this.root_);
- this.root_.innerHTML = this.savedHtml_;
- this.root_.removeAttribute('g_editable');
-
- if (goog.editor.plugins && goog.editor.plugins.AbstractBubblePlugin) {
- // Remove old bubbles.
- for (var key in goog.editor.plugins.AbstractBubblePlugin.bubbleMap_) {
- goog.editor.plugins.AbstractBubblePlugin.bubbleMap_[key].dispose();
- }
- // Ensure we get a new bubble for each test.
- goog.editor.plugins.AbstractBubblePlugin.bubbleMap_ = {};
- }
-};
-
-
-/**
- * Assert that the html in 'root' is substantially similar to htmlPattern.
- * This method tests for the same set of styles, and for the same order of
- * nodes. Breaking whitespace nodes are ignored. Elements can be annotated
- * with classnames corresponding to keys in goog.userAgent and will be
- * expected to show up in that user agent and expected not to show up in
- * others.
- * @param {string} htmlPattern The pattern to match.
- */
-goog.testing.editor.TestHelper.prototype.assertHtmlMatches = function(
- htmlPattern) {
- goog.testing.dom.assertHtmlContentsMatch(htmlPattern, this.root_);
-};
-
-
-/**
- * Finds the first text node descendant of root with the given content.
- * @param {string|RegExp} textOrRegexp The text to find, or a regular
- * expression to find a match of.
- * @return {Node} The first text node that matches, or null if none is found.
- */
-goog.testing.editor.TestHelper.prototype.findTextNode = function(textOrRegexp) {
- return goog.testing.dom.findTextNode(textOrRegexp, this.root_);
-};
-
-
-/**
- * Select from the given from offset in the given from node to the given
- * to offset in the optionally given to node. If nodes are passed in, uses them,
- * otherwise uses findTextNode to find the nodes to select. Selects a caret
- * if opt_to and opt_toOffset are not given.
- * @param {Node|string} from Node or text of the node to start the selection at.
- * @param {number} fromOffset Offset within the above node to start the
- * selection at.
- * @param {Node|string=} opt_to Node or text of the node to end the selection
- * at.
- * @param {number=} opt_toOffset Offset within the above node to end the
- * selection at.
- */
-goog.testing.editor.TestHelper.prototype.select = function(from, fromOffset,
- opt_to, opt_toOffset) {
- var end;
- var start = end = goog.isString(from) ? this.findTextNode(from) : from;
- var endOffset;
- var startOffset = endOffset = fromOffset;
-
- if (opt_to && goog.isNumber(opt_toOffset)) {
- end = goog.isString(opt_to) ? this.findTextNode(opt_to) : opt_to;
- endOffset = opt_toOffset;
- }
-
- goog.dom.Range.createFromNodes(start, startOffset, end, endOffset).select();
-};
-
-
-/** @override */
-goog.testing.editor.TestHelper.prototype.disposeInternal = function() {
- if (goog.editor.node.isEditableContainer(this.root_)) {
- this.tearDownEditableElement();
- }
- delete this.root_;
- goog.base(this, 'disposeInternal');
-};
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/editor/.svn/text-base/testhelper_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/editor/.svn/text-base/testhelper_test.html.svn-base
deleted file mode 100644
index 56ad06e..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/editor/.svn/text-base/testhelper_test.html.svn-base
+++ /dev/null
@@ -1,177 +0,0 @@
-<!DOCTYPE html>
-<html lang="en" dir="ltr">
-<head>
-<!--
-Copyright 2008 The Closure Library Authors. All Rights Reserved.
-
-Use of this source code is governed by the Apache License, Version 2.0.
-See the COPYING file for details.
--->
-<meta http-equiv="X-UA-Compatible" content="IE=edge">
- <title>Closure Unit Tests - goog.testing.editor.TestHelper</title>
- <script src="../../base.js"></script>
- <script>
- goog.require('goog.dom');
- goog.require('goog.dom.TagName');
- goog.require('goog.editor.node');
- goog.require('goog.testing.editor.TestHelper');
- goog.require('goog.testing.jsunit');
- </script>
-</head>
-<body>
-<div id="root"></div>
-<div id="root2">Root 2</div>
-<script type="text/javascript">
- var root = goog.dom.getElement('root');
- var helper;
-
- function setUp() {
- goog.dom.removeChildren(root);
- helper = new goog.testing.editor.TestHelper(root);
- }
-
- function tearDown() {
- helper.dispose();
- }
-
- function testSetRoot() {
- helper.setRoot(goog.dom.getElement('root2'));
- helper.assertHtmlMatches('Root 2');
- }
-
- function testSetupEditableElement() {
- helper.setUpEditableElement();
- assertTrue(goog.editor.node.isEditableContainer(root));
- }
-
- function testTearDownEditableElement() {
- helper.setUpEditableElement();
- assertTrue(goog.editor.node.isEditableContainer(root));
-
- helper.tearDownEditableElement();
- assertFalse(goog.editor.node.isEditableContainer(root));
- }
-
- function testFindNode() {
- // Test the easiest case.
- root.innerHTML = 'a<br>b';
- assertEquals(helper.findTextNode('a'), root.firstChild);
- assertEquals(helper.findTextNode('b'), root.lastChild);
- assertNull(helper.findTextNode('c'));
- }
-
- function testFindNodeDuplicate() {
- // Test duplicate.
- root.innerHTML = 'c<br>c';
- assertEquals('Should return first duplicate', helper.findTextNode('c'),
- root.firstChild);
- }
-
- function findNodeWithHierarchy() {
- // Test a more complicated hierarchy.
- root.innerHTML = '<div>a<p>b<span>c</span>d</p>e</div>';
- assertEquals(goog.dom.TagName.DIV,
- helper.findTextNode('a').parentNode.tagName);
- assertEquals(goog.dom.TagName.P,
- helper.findTextNode('b').parentNode.tagName);
- assertEquals(goog.dom.TagName.SPAN,
- helper.findTextNode('c').parentNode.tagName);
- assertEquals(goog.dom.TagName.P,
- helper.findTextNode('d').parentNode.tagName);
- assertEquals(goog.dom.TagName.DIV,
- helper.findTextNode('e').parentNode.tagName);
- }
-
- function setUpAssertHtmlMatches() {
- var tag1, tag2;
- if (goog.userAgent.IE) {
- tag1 = goog.dom.TagName.DIV;
- } else if (goog.userAgent.WEBKIT) {
- tag1 = goog.dom.TagName.P;
- tag2 = goog.dom.TagName.BR;
- } else if (goog.userAgent.GECKO) {
- tag1 = goog.dom.TagName.SPAN;
- tag2 = goog.dom.TagName.BR;
- }
-
- var parent = goog.dom.createDom(goog.dom.TagName.DIV);
- root.appendChild(parent);
- parent.style.fontSize = '2em';
- parent.style.display = 'none';
- if (goog.userAgent.IE || goog.userAgent.GECKO) {
- parent.appendChild(goog.dom.createTextNode('NonWebKitText'));
- }
-
- if (tag1) {
- var e1 = goog.dom.createDom(tag1);
- parent.appendChild(e1);
- parent = e1;
- }
- if (tag2) {
- parent.appendChild(goog.dom.createDom(tag2));
- }
- parent.appendChild(goog.dom.createTextNode('Text'));
- if (goog.userAgent.WEBKIT) {
- root.firstChild.appendChild(goog.dom.createTextNode('WebKitText'));
- }
- }
-
- function testAssertHtmlMatches() {
- setUpAssertHtmlMatches();
-
- helper.assertHtmlMatches('<div style="display: none; font-size: 2em">' +
- '[[IE GECKO]]NonWebKitText<div class="IE"><p class="WEBKIT">' +
- '<span class="GECKO"><br class="GECKO WEBKIT">Text</span></p></div>' +
- '</div>[[WEBKIT]]WebKitText');
- }
-
- function testAssertHtmlMismatchText() {
- setUpAssertHtmlMatches();
-
- var e = assertThrows('Should fail due to mismatched text', function() {
- helper.assertHtmlMatches('<div style="display: none; font-size: 2em">' +
- '[[IE GECKO]]NonWebKitText<div class="IE"><p class="WEBKIT">' +
- '<span class="GECKO"><br class="GECKO WEBKIT">Bad</span></p></div>' +
- '</div>[[WEBKIT]]Extra');
- });
- assertContains('Text should match', e.message);
- }
-
- function testAssertHtmlMismatchTag() {
- setUpAssertHtmlMatches();
-
- var e = assertThrows('Should fail due to mismatched tag', function() {
- helper.assertHtmlMatches('<span style="display: none; font-size: 2em">' +
- '[[IE GECKO]]NonWebKitText<div class="IE"><p class="WEBKIT">' +
- '<span class="GECKO"><br class="GECKO WEBKIT">Text</span></p></div>' +
- '</span>[[WEBKIT]]Extra');
- });
- assertContains('Tag names should match', e.message);
- }
-
- function testAssertHtmlMismatchStyle() {
- setUpAssertHtmlMatches();
-
- var e = assertThrows('Should fail due to mismatched style', function() {
- helper.assertHtmlMatches('<div style="display: none; font-size: 3em">' +
- '[[IE GECKO]]NonWebKitText<div class="IE"><p class="WEBKIT">' +
- '<span class="GECKO"><br class="GECKO WEBKIT">Text</span></p></div>' +
- '</div>[[WEBKIT]]Extra');
- });
- assertContains('Should have same styles', e.message);
- }
-
- function testAssertHtmlMismatchOptionalText() {
- setUpAssertHtmlMatches();
-
- var e = assertThrows('Should fail due to mismatched style', function() {
- helper.assertHtmlMatches('<div style="display: none; font-size: 2em">' +
- '[[IE GECKO]]Bad<div class="IE"><p class="WEBKIT">' +
- '<span class="GECKO"><br class="GECKO WEBKIT">Text</span></p></div>' +
- '</div>[[WEBKIT]]Bad');
- });
- assertContains('Text should match', e.message);
- }
-</script>
-</body>
-</html>
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/events/.svn/all-wcprops b/contexts/data/lib/closure-library/closure/goog/testing/events/.svn/all-wcprops
deleted file mode 100644
index 40217df..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/events/.svn/all-wcprops
+++ /dev/null
@@ -1,41 +0,0 @@
-K 25
-svn:wc:ra_dav:version-url
-V 52
-/svn/!svn/ver/1121/trunk/closure/goog/testing/events
-END
-events.js
-K 25
-svn:wc:ra_dav:version-url
-V 62
-/svn/!svn/ver/1121/trunk/closure/goog/testing/events/events.js
-END
-matchers.js
-K 25
-svn:wc:ra_dav:version-url
-V 63
-/svn/!svn/ver/850/trunk/closure/goog/testing/events/matchers.js
-END
-eventobserver.js
-K 25
-svn:wc:ra_dav:version-url
-V 68
-/svn/!svn/ver/850/trunk/closure/goog/testing/events/eventobserver.js
-END
-events_test.html
-K 25
-svn:wc:ra_dav:version-url
-V 68
-/svn/!svn/ver/850/trunk/closure/goog/testing/events/events_test.html
-END
-matchers_test.html
-K 25
-svn:wc:ra_dav:version-url
-V 70
-/svn/!svn/ver/850/trunk/closure/goog/testing/events/matchers_test.html
-END
-eventobserver_test.html
-K 25
-svn:wc:ra_dav:version-url
-V 75
-/svn/!svn/ver/850/trunk/closure/goog/testing/events/eventobserver_test.html
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/events/.svn/entries b/contexts/data/lib/closure-library/closure/goog/testing/events/.svn/entries
deleted file mode 100644
index 5f866d1..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/events/.svn/entries
+++ /dev/null
@@ -1,232 +0,0 @@
-10
-
-dir
-1494
-http://closure-library.googlecode.com/svn/trunk/closure/goog/testing/events
-http://closure-library.googlecode.com/svn
-
-
-
-2011-07-13T20:14:20.000000Z
-1121
-mariakhomenko@google.com
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-0b95b8e8-c90f-11de-9d4f-f947ee5921c8
-
-events.js
-file
-
-
-
-
-2011-12-23T22:42:26.643307Z
-e80b3f1837081d109617ca4492cc79c5
-2011-07-13T20:14:20.000000Z
-1121
-mariakhomenko@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-22268
-
-matchers.js
-file
-
-
-
-
-2011-12-23T22:42:26.644307Z
-0868ba07c360e7c0bbacc323ffe7dc48
-2011-04-12T20:35:47.000000Z
-850
-diegosalas@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-1446
-
-eventobserver.js
-file
-
-
-
-
-2011-12-23T22:42:26.645307Z
-63e612ab2b563faea779310778325f0e
-2011-04-12T20:35:47.000000Z
-850
-diegosalas@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-2567
-
-events_test.html
-file
-
-
-
-
-2011-12-23T22:42:26.646307Z
-13aa8b71279f7a76677065217ff78310
-2011-04-12T20:35:47.000000Z
-850
-diegosalas@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-15057
-
-matchers_test.html
-file
-
-
-
-
-2011-12-23T22:42:26.646307Z
-122f3cc4347b5bebf86da42e712bb0c1
-2011-04-12T20:35:47.000000Z
-850
-diegosalas@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-1099
-
-eventobserver_test.html
-file
-
-
-
-
-2011-12-23T22:42:26.646307Z
-24ad4c01167ec29fda328f32f7cd4e3c
-2011-04-12T20:35:47.000000Z
-850
-diegosalas@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-2185
-
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/events/.svn/prop-base/eventobserver.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/events/.svn/prop-base/eventobserver.js.svn-base
deleted file mode 100644
index 530636b..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/events/.svn/prop-base/eventobserver.js.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 15
-text/javascript
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/events/.svn/prop-base/eventobserver_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/events/.svn/prop-base/eventobserver_test.html.svn-base
deleted file mode 100644
index d356868..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/events/.svn/prop-base/eventobserver_test.html.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 9
-text/html
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/events/.svn/prop-base/events.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/events/.svn/prop-base/events.js.svn-base
deleted file mode 100644
index 530636b..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/events/.svn/prop-base/events.js.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 15
-text/javascript
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/events/.svn/prop-base/events_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/events/.svn/prop-base/events_test.html.svn-base
deleted file mode 100644
index d356868..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/events/.svn/prop-base/events_test.html.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 9
-text/html
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/events/.svn/prop-base/matchers.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/events/.svn/prop-base/matchers.js.svn-base
deleted file mode 100644
index 530636b..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/events/.svn/prop-base/matchers.js.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 15
-text/javascript
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/events/.svn/prop-base/matchers_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/events/.svn/prop-base/matchers_test.html.svn-base
deleted file mode 100644
index d356868..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/events/.svn/prop-base/matchers_test.html.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 9
-text/html
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/events/.svn/text-base/eventobserver.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/events/.svn/text-base/eventobserver.js.svn-base
deleted file mode 100644
index 83d6888..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/events/.svn/text-base/eventobserver.js.svn-base
+++ /dev/null
@@ -1,85 +0,0 @@
-// Copyright 2010 The Closure Library Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS-IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/**
- * @fileoverview Event observer.
- *
- * Provides an event observer that holds onto events that it handles. This
- * can be used in unit testing to verify an event target's events --
- * that the order count, types, etc. are correct.
- *
- * Example usage:
- * <pre>
- * var observer = new goog.testing.events.EventObserver();
- * var widget = new foo.Widget();
- * goog.events.listen(widget, ['select', 'submit'], observer);
- * // Simulate user action of 3 select events and 2 submit events.
- * assertEquals(3, observer.getEvents('select').length);
- * assertEquals(2, observer.getEvents('submit').length);
- * </pre>
- *
- */
-
-goog.provide('goog.testing.events.EventObserver');
-
-goog.require('goog.array');
-
-
-
-/**
- * Event observer. Implements a handleEvent interface so it may be used as
- * a listener in listening functions and methods.
- * @see goog.events.listen
- * @see goog.events.EventHandler
- * @constructor
- */
-goog.testing.events.EventObserver = function() {
-
- /**
- * A list of events handled by the observer in order of handling, oldest to
- * newest.
- * @type {!Array.<!goog.events.Event>}
- * @private
- */
- this.events_ = [];
-};
-
-
-/**
- * Handles an event and remembers it. Event listening functions and methods
- * will call this method when this observer is used as a listener.
- * @see goog.events.listen
- * @see goog.events.EventHandler
- * @param {!goog.events.Event} e Event to handle.
- */
-goog.testing.events.EventObserver.prototype.handleEvent = function(e) {
- this.events_.push(e);
-};
-
-
-/**
- * @param {string=} opt_type If given, only return events of this type.
- * @return {!Array.<!goog.events.Event>} The events handled, oldest to newest.
- */
-goog.testing.events.EventObserver.prototype.getEvents = function(opt_type) {
- var events = goog.array.clone(this.events_);
-
- if (opt_type) {
- events = goog.array.filter(events, function(event) {
- return event.type == opt_type;
- });
- }
-
- return events;
-};
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/events/.svn/text-base/eventobserver_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/events/.svn/text-base/eventobserver_test.html.svn-base
deleted file mode 100644
index 200eae6..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/events/.svn/text-base/eventobserver_test.html.svn-base
+++ /dev/null
@@ -1,70 +0,0 @@
-<!DOCTYPE html>
-<html>
-<!--
-Copyright 2010 The Closure Library Authors. All Rights Reserved.
-
-Use of this source code is governed by the Apache License, Version 2.0.
-See the COPYING file for details.
--->
-<head>
-<meta http-equiv="X-UA-Compatible" content="IE=edge">
-<title>Closure Unit Tests - goog.testing.events.EventObserver</title>
- <script src="../../base.js"></script>
-<script>
- goog.require('goog.array');
- goog.require('goog.events');
- goog.require('goog.events.EventTarget');
- goog.require('goog.testing.events.EventObserver');
- goog.require('goog.testing.jsunit');
-</script>
-</head>
-<body>
-<script>
-
- // Return an event's type
- function getEventType(e) {
- return e.type;
- }
-
- function testGetEvents() {
- var observer = new goog.testing.events.EventObserver();
- var target = new goog.events.EventTarget();
- goog.events.listen(target, ['foo', 'bar', 'baz'], observer);
-
- var eventTypes = [
- 'bar', 'baz', 'foo', 'qux', 'quux', 'corge', 'foo', 'baz'];
- goog.array.forEach(eventTypes, goog.bind(target.dispatchEvent, target));
-
- var replayEvents = observer.getEvents();
-
- assertArrayEquals('Only the listened-for event types should be remembered',
- ['bar', 'baz', 'foo', 'foo', 'baz'],
- goog.array.map(observer.getEvents(), getEventType));
-
- assertArrayEquals(['bar'],
- goog.array.map(observer.getEvents('bar'), getEventType));
- assertArrayEquals(['baz', 'baz'],
- goog.array.map(observer.getEvents('baz'), getEventType));
- assertArrayEquals(['foo', 'foo'],
- goog.array.map(observer.getEvents('foo'), getEventType));
- }
-
- function testHandleEvent() {
- var events = [
- new goog.events.Event('foo'),
- new goog.events.Event('bar'),
- new goog.events.Event('baz')
- ];
-
- var observer = new goog.testing.events.EventObserver();
- goog.array.forEach(events, goog.bind(observer.handleEvent, observer));
-
- assertArrayEquals(events, observer.getEvents());
- assertArrayEquals([events[0]], observer.getEvents('foo'));
- assertArrayEquals([events[1]], observer.getEvents('bar'));
- assertArrayEquals([events[2]], observer.getEvents('baz'));
- }
-
-</script>
-</body>
-</html>
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/events/.svn/text-base/events.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/events/.svn/text-base/events.js.svn-base
deleted file mode 100644
index 8928c0b..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/events/.svn/text-base/events.js.svn-base
+++ /dev/null
@@ -1,554 +0,0 @@
-// Copyright 2008 The Closure Library Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS-IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/**
- * @fileoverview Event Simulation.
- *
- * Utility functions for simulating events at the Closure level. All functions
- * in this package generate events by calling goog.events.fireListeners,
- * rather than interfacing with the browser directly. This is intended for
- * testing purposes, and should not be used in production code.
- *
- * The decision to use Closure events and dispatchers instead of the browser's
- * native events and dispatchers was conscious and deliberate. Native event
- * dispatchers have their own set of quirks and edge cases. Pure JS dispatchers
- * are more robust and transparent.
- *
- * If you think you need a testing mechanism that uses native Event objects,
- * please, please email closure-tech first to explain your use case before you
- * sink time into this.
- *
- * @author nicksantos@google.com (Nick Santos)
- */
-
-goog.provide('goog.testing.events');
-goog.provide('goog.testing.events.Event');
-
-goog.require('goog.events');
-goog.require('goog.events.BrowserEvent');
-goog.require('goog.events.BrowserEvent.MouseButton');
-goog.require('goog.events.BrowserFeature');
-goog.require('goog.events.Event');
-goog.require('goog.events.EventType');
-goog.require('goog.events.KeyCodes');
-goog.require('goog.object');
-goog.require('goog.style');
-goog.require('goog.userAgent');
-
-
-
-/**
- * goog.events.BrowserEvent expects an Event so we provide one for JSCompiler.
- *
- * @param {string} type Event Type.
- * @param {Object=} opt_target Reference to the object that is the target of
- * this event.
- * @constructor
- * @extends {Event}
- */
-goog.testing.events.Event = function(type, opt_target) {
- /**
- * Event type.
- * @type {string}
- */
- this.type = type;
-
- /**
- * Target of the event.
- * @type {Object|undefined}
- */
- this.target = opt_target;
-
- /**
- * Object that had the listener attached.
- * @type {Object|undefined}
- */
- this.currentTarget = this.target;
-};
-goog.object.extend(
- goog.testing.events.Event.prototype, goog.events.Event.prototype);
-
-
-/**
- * A static helper function that sets the mouse position to the event.
- * @param {Event} event A simulated native event.
- * @param {goog.math.Coordinate=} opt_coords Mouse position. Defaults to event's
- * target's position (if available), otherwise (0, 0).
- * @private
- */
-goog.testing.events.setEventClientXY_ = function(event, opt_coords) {
- if (!opt_coords && event.target &&
- event.target.nodeType == goog.dom.NodeType.ELEMENT) {
- try {
- opt_coords =
- goog.style.getClientPosition(/** @type {Element} **/ (event.target));
- } catch (ex) {
- // IE sometimes throws if it can't get the position.
- }
- }
- event.clientX = opt_coords ? opt_coords.x : 0;
- event.clientY = opt_coords ? opt_coords.y : 0;
-
- // Pretend the browser window is at (0, 0).
- event.screenX = event.clientX;
- event.screenY = event.clientY;
-};
-
-
-/**
- * Simulates a mousedown, mouseup, and then click on the given event target,
- * with the left mouse button.
- * @param {EventTarget} target The target for the event.
- * @param {goog.events.BrowserEvent.MouseButton=} opt_button Mouse button;
- * defaults to {@code goog.events.BrowserEvent.MouseButton.LEFT}.
- * @param {goog.math.Coordinate=} opt_coords Mouse position. Defaults to event's
- * target's position (if available), otherwise (0, 0).
- * @param {Object=} opt_eventProperties Event properties to be mixed into the
- * BrowserEvent.
- * @return {boolean} The returnValue of the sequence: false if preventDefault()
- * was called on any of the events, true otherwise.
- */
-goog.testing.events.fireClickSequence =
- function(target, opt_button, opt_coords, opt_eventProperties) {
- // Fire mousedown, mouseup, and click. Then return the bitwise AND of the 3.
- return !!(goog.testing.events.fireMouseDownEvent(
- target, opt_button, opt_coords, opt_eventProperties) &
- goog.testing.events.fireMouseUpEvent(
- target, opt_button, opt_coords, opt_eventProperties) &
- goog.testing.events.fireClickEvent(
- target, opt_button, opt_coords, opt_eventProperties));
-};
-
-
-/**
- * Simulates the sequence of events fired by the browser when the user double-
- * clicks the given target.
- * @param {EventTarget} target The target for the event.
- * @param {goog.math.Coordinate=} opt_coords Mouse position. Defaults to event's
- * target's position (if available), otherwise (0, 0).
- * @param {Object=} opt_eventProperties Event properties to be mixed into the
- * BrowserEvent.
- * @return {boolean} The returnValue of the sequence: false if preventDefault()
- * was called on any of the events, true otherwise.
- */
-goog.testing.events.fireDoubleClickSequence = function(
- target, opt_coords, opt_eventProperties) {
- // Fire mousedown, mouseup, click, mousedown, mouseup, click, dblclick.
- // Then return the bitwise AND of the 7.
- var btn = goog.events.BrowserEvent.MouseButton.LEFT;
- return !!(goog.testing.events.fireMouseDownEvent(
- target, btn, opt_coords, opt_eventProperties) &
- goog.testing.events.fireMouseUpEvent(
- target, btn, opt_coords, opt_eventProperties) &
- goog.testing.events.fireClickEvent(
- target, btn, opt_coords, opt_eventProperties) &
- // IE fires a selectstart instead of the second mousedown in a
- // dblclick, but we don't care about selectstart.
- (goog.userAgent.IE ||
- goog.testing.events.fireMouseDownEvent(
- target, btn, opt_coords, opt_eventProperties)) &
- goog.testing.events.fireMouseUpEvent(
- target, btn, opt_coords, opt_eventProperties) &
- // IE doesn't fire the second click in a dblclick.
- (goog.userAgent.IE ||
- goog.testing.events.fireClickEvent(
- target, btn, opt_coords, opt_eventProperties)) &
- goog.testing.events.fireDoubleClickEvent(
- target, opt_coords, opt_eventProperties));
-};
-
-
-/**
- * Simulates a complete keystroke (keydown, keypress, and keyup). Note that
- * if preventDefault is called on the keydown, the keypress will not fire.
- *
- * @param {EventTarget} target The target for the event.
- * @param {number} keyCode The keycode of the key pressed.
- * @param {Object=} opt_eventProperties Event properties to be mixed into the
- * BrowserEvent.
- * @return {boolean} The returnValue of the sequence: false if preventDefault()
- * was called on any of the events, true otherwise.
- */
-goog.testing.events.fireKeySequence = function(
- target, keyCode, opt_eventProperties) {
- return goog.testing.events.fireNonAsciiKeySequence(target, keyCode, keyCode,
- opt_eventProperties);
-};
-
-
-/**
- * Simulates a complete keystroke (keydown, keypress, and keyup) when typing
- * a non-ASCII character. Same as fireKeySequence, the keypress will not fire
- * if preventDefault is called on the keydown.
- *
- * @param {EventTarget} target The target for the event.
- * @param {number} keyCode The keycode of the keydown and keyup events.
- * @param {number} keyPressKeyCode The keycode of the keypress event.
- * @param {Object=} opt_eventProperties Event properties to be mixed into the
- * BrowserEvent.
- * @return {boolean} The returnValue of the sequence: false if preventDefault()
- * was called on any of the events, true otherwise.
- */
-goog.testing.events.fireNonAsciiKeySequence = function(
- target, keyCode, keyPressKeyCode, opt_eventProperties) {
- var keydown =
- new goog.testing.events.Event(goog.events.EventType.KEYDOWN, target);
- var keyup =
- new goog.testing.events.Event(goog.events.EventType.KEYUP, target);
- var keypress =
- new goog.testing.events.Event(goog.events.EventType.KEYPRESS, target);
- keydown.keyCode = keyup.keyCode = keyCode;
- keypress.keyCode = keyPressKeyCode;
-
- if (opt_eventProperties) {
- goog.object.extend(keydown, opt_eventProperties);
- goog.object.extend(keyup, opt_eventProperties);
- goog.object.extend(keypress, opt_eventProperties);
- }
-
- // Fire keydown, keypress, and keyup. Note that if the keydown is
- // prevent-defaulted, then the keypress will not fire on IE.
- var result = true;
- if (!goog.testing.events.isBrokenGeckoMacActionKey_(keydown)) {
- result = goog.testing.events.fireBrowserEvent(keydown);
- }
- if (goog.events.KeyCodes.firesKeyPressEvent(
- keyCode, undefined, keydown.shiftKey, keydown.ctrlKey,
- keydown.altKey) &&
- !(goog.userAgent.IE && !result)) {
- result &= goog.testing.events.fireBrowserEvent(keypress);
- }
- return !!(result & goog.testing.events.fireBrowserEvent(keyup));
-};
-
-
-/**
- * @param {goog.testing.events.Event} e The event.
- * @return {boolean} Whether this is the Gecko/Mac's Meta-C/V/X, which
- * is broken and requires special handling.
- * @private
- */
-goog.testing.events.isBrokenGeckoMacActionKey_ = function(e) {
- return goog.userAgent.MAC && goog.userAgent.GECKO &&
- (e.keyCode == goog.events.KeyCodes.C ||
- e.keyCode == goog.events.KeyCodes.X ||
- e.keyCode == goog.events.KeyCodes.V) && e.metaKey;
-};
-
-
-/**
- * Simulates a mouseover event on the given target.
- * @param {EventTarget} target The target for the event.
- * @param {EventTarget} relatedTarget The related target for the event (e.g.,
- * the node that the mouse is being moved out of).
- * @param {goog.math.Coordinate=} opt_coords Mouse position. Defaults to event's
- * target's position (if available), otherwise (0, 0).
- * @return {boolean} The returnValue of the event: false if preventDefault() was
- * called on it, true otherwise.
- */
-goog.testing.events.fireMouseOverEvent = function(target, relatedTarget,
- opt_coords) {
- var mouseover =
- new goog.testing.events.Event(goog.events.EventType.MOUSEOVER, target);
- mouseover.relatedTarget = relatedTarget;
- goog.testing.events.setEventClientXY_(mouseover, opt_coords);
- return goog.testing.events.fireBrowserEvent(mouseover);
-};
-
-
-/**
- * Simulates a mousemove event on the given target.
- * @param {EventTarget} target The target for the event.
- * @param {goog.math.Coordinate=} opt_coords Mouse position. Defaults to event's
- * target's position (if available), otherwise (0, 0).
- * @return {boolean} The returnValue of the event: false if preventDefault() was
- * called on it, true otherwise.
- */
-goog.testing.events.fireMouseMoveEvent = function(target, opt_coords) {
- var mousemove =
- new goog.testing.events.Event(goog.events.EventType.MOUSEMOVE, target);
-
- goog.testing.events.setEventClientXY_(mousemove, opt_coords);
- return goog.testing.events.fireBrowserEvent(mousemove);
-};
-
-
-/**
- * Simulates a mouseout event on the given target.
- * @param {EventTarget} target The target for the event.
- * @param {EventTarget} relatedTarget The related target for the event (e.g.,
- * the node that the mouse is being moved into).
- * @param {goog.math.Coordinate=} opt_coords Mouse position. Defaults to event's
- * target's position (if available), otherwise (0, 0).
- * @return {boolean} The returnValue of the event: false if preventDefault() was
- * called on it, true otherwise.
- */
-goog.testing.events.fireMouseOutEvent = function(target, relatedTarget,
- opt_coords) {
- var mouseout =
- new goog.testing.events.Event(goog.events.EventType.MOUSEOUT, target);
- mouseout.relatedTarget = relatedTarget;
- goog.testing.events.setEventClientXY_(mouseout, opt_coords);
- return goog.testing.events.fireBrowserEvent(mouseout);
-};
-
-
-/**
- * Simulates a mousedown event on the given target.
- * @param {EventTarget} target The target for the event.
- * @param {goog.events.BrowserEvent.MouseButton=} opt_button Mouse button;
- * defaults to {@code goog.events.BrowserEvent.MouseButton.LEFT}.
- * @param {goog.math.Coordinate=} opt_coords Mouse position. Defaults to event's
- * target's position (if available), otherwise (0, 0).
- * @param {Object=} opt_eventProperties Event properties to be mixed into the
- * BrowserEvent.
- * @return {boolean} The returnValue of the event: false if preventDefault() was
- * called on it, true otherwise.
- */
-goog.testing.events.fireMouseDownEvent =
- function(target, opt_button, opt_coords, opt_eventProperties) {
-
- var button = opt_button || goog.events.BrowserEvent.MouseButton.LEFT;
- button = !goog.events.BrowserFeature.HAS_W3C_BUTTON ?
- goog.events.BrowserEvent.IEButtonMap[button] : button;
- return goog.testing.events.fireMouseButtonEvent_(
- goog.events.EventType.MOUSEDOWN, target, button, opt_coords,
- opt_eventProperties);
-};
-
-
-/**
- * Simulates a mouseup event on the given target.
- * @param {EventTarget} target The target for the event.
- * @param {goog.events.BrowserEvent.MouseButton=} opt_button Mouse button;
- * defaults to {@code goog.events.BrowserEvent.MouseButton.LEFT}.
- * @param {goog.math.Coordinate=} opt_coords Mouse position. Defaults to event's
- * target's position (if available), otherwise (0, 0).
- * @param {Object=} opt_eventProperties Event properties to be mixed into the
- * BrowserEvent.
- * @return {boolean} The returnValue of the event: false if preventDefault() was
- * called on it, true otherwise.
- */
-goog.testing.events.fireMouseUpEvent =
- function(target, opt_button, opt_coords, opt_eventProperties) {
- var button = opt_button || goog.events.BrowserEvent.MouseButton.LEFT;
- button = !goog.events.BrowserFeature.HAS_W3C_BUTTON ?
- goog.events.BrowserEvent.IEButtonMap[button] : button;
- return goog.testing.events.fireMouseButtonEvent_(
- goog.events.EventType.MOUSEUP, target, button, opt_coords,
- opt_eventProperties);
-};
-
-
-/**
- * Simulates a click event on the given target. IE only supports click with
- * the left mouse button.
- * @param {EventTarget} target The target for the event.
- * @param {goog.events.BrowserEvent.MouseButton=} opt_button Mouse button;
- * defaults to {@code goog.events.BrowserEvent.MouseButton.LEFT}.
- * @param {goog.math.Coordinate=} opt_coords Mouse position. Defaults to event's
- * target's position (if available), otherwise (0, 0).
- * @param {Object=} opt_eventProperties Event properties to be mixed into the
- * BrowserEvent.
- * @return {boolean} The returnValue of the event: false if preventDefault() was
- * called on it, true otherwise.
- */
-goog.testing.events.fireClickEvent =
- function(target, opt_button, opt_coords, opt_eventProperties) {
- return goog.testing.events.fireMouseButtonEvent_(goog.events.EventType.CLICK,
- target, opt_button, opt_coords, opt_eventProperties);
-};
-
-
-/**
- * Simulates a double-click event on the given target. Always double-clicks
- * with the left mouse button since no browser supports double-clicking with
- * any other buttons.
- * @param {EventTarget} target The target for the event.
- * @param {goog.math.Coordinate=} opt_coords Mouse position. Defaults to event's
- * target's position (if available), otherwise (0, 0).
- * @param {Object=} opt_eventProperties Event properties to be mixed into the
- * BrowserEvent.
- * @return {boolean} The returnValue of the event: false if preventDefault() was
- * called on it, true otherwise.
- */
-goog.testing.events.fireDoubleClickEvent =
- function(target, opt_coords, opt_eventProperties) {
- return goog.testing.events.fireMouseButtonEvent_(
- goog.events.EventType.DBLCLICK, target,
- goog.events.BrowserEvent.MouseButton.LEFT, opt_coords,
- opt_eventProperties);
-};
-
-
-/**
- * Helper function to fire a mouse event.
- * with the left mouse button since no browser supports double-clicking with
- * any other buttons.
- * @param {string} type The event type.
- * @param {EventTarget} target The target for the event.
- * @param {number=} opt_button Mouse button; defaults to
- * {@code goog.events.BrowserEvent.MouseButton.LEFT}.
- * @param {goog.math.Coordinate=} opt_coords Mouse position. Defaults to event's
- * target's position (if available), otherwise (0, 0).
- * @param {Object=} opt_eventProperties Event properties to be mixed into the
- * BrowserEvent.
- * @return {boolean} The returnValue of the event: false if preventDefault() was
- * called on it, true otherwise.
- * @private
- */
-goog.testing.events.fireMouseButtonEvent_ =
- function(type, target, opt_button, opt_coords, opt_eventProperties) {
- var e =
- new goog.testing.events.Event(type, target);
- e.button = opt_button || goog.events.BrowserEvent.MouseButton.LEFT;
- goog.testing.events.setEventClientXY_(e, opt_coords);
- if (opt_eventProperties) {
- goog.object.extend(e, opt_eventProperties);
- }
- return goog.testing.events.fireBrowserEvent(e);
-};
-
-
-/**
- * Simulates a contextmenu event on the given target.
- * @param {EventTarget} target The target for the event.
- * @param {goog.math.Coordinate=} opt_coords Mouse position. Defaults to event's
- * target's position (if available), otherwise (0, 0).
- * @return {boolean} The returnValue of the event: false if preventDefault() was
- * called on it, true otherwise.
- */
-goog.testing.events.fireContextMenuEvent = function(target, opt_coords) {
- var button = (goog.userAgent.MAC && goog.userAgent.WEBKIT) ?
- goog.events.BrowserEvent.MouseButton.LEFT :
- goog.events.BrowserEvent.MouseButton.RIGHT;
- var contextmenu =
- new goog.testing.events.Event(goog.events.EventType.CONTEXTMENU, target);
- contextmenu.button = !goog.events.BrowserFeature.HAS_W3C_BUTTON ?
- goog.events.BrowserEvent.IEButtonMap[button] : button;
- contextmenu.ctrlKey = goog.userAgent.MAC;
- goog.testing.events.setEventClientXY_(contextmenu, opt_coords);
- return goog.testing.events.fireBrowserEvent(contextmenu);
-};
-
-
-/**
- * Simulates a mousedown, contextmenu, and the mouseup on the given event
- * target, with the right mouse button.
- * @param {EventTarget} target The target for the event.
- * @param {goog.math.Coordinate=} opt_coords Mouse position. Defaults to event's
- * target's position (if available), otherwise (0, 0).
- * @return {boolean} The returnValue of the sequence: false if preventDefault()
- * was called on any of the events, true otherwise.
- */
-goog.testing.events.fireContextMenuSequence = function(target, opt_coords) {
- var props = goog.userAgent.MAC ? {ctrlKey: true} : {};
- var button = (goog.userAgent.MAC && goog.userAgent.WEBKIT) ?
- goog.events.BrowserEvent.MouseButton.LEFT :
- goog.events.BrowserEvent.MouseButton.RIGHT;
-
- var result = goog.testing.events.fireMouseDownEvent(target,
- button, opt_coords, props);
- if (goog.userAgent.WINDOWS) {
- // All browsers are consistent on Windows.
- result &= goog.testing.events.fireMouseUpEvent(target,
- button, opt_coords) &
- goog.testing.events.fireContextMenuEvent(target, opt_coords);
- } else {
- result &= goog.testing.events.fireContextMenuEvent(target, opt_coords);
-
- // GECKO on Mac and Linux always fires the mouseup after the contextmenu.
-
- // WEBKIT is really weird.
- //
- // On Linux, it sometimes fires mouseup, but most of the time doesn't.
- // It's really hard to reproduce consistently. I think there's some
- // internal race condition. If contextmenu is preventDefaulted, then
- // mouseup always fires.
- //
- // On Mac, it always fires mouseup and then fires a click.
- result &= goog.testing.events.fireMouseUpEvent(target,
- button, opt_coords, props);
-
- if (goog.userAgent.WEBKIT && goog.userAgent.MAC) {
- result &= goog.testing.events.fireClickEvent(
- target, button, opt_coords, props);
- }
- }
- return !!result;
-};
-
-
-/**
- * Simulates a popstate event on the given target.
- * @param {EventTarget} target The target for the event.
- * @param {Object} state History state object.
- * @return {boolean} The returnValue of the event: false if preventDefault() was
- * called on it, true otherwise.
- */
-goog.testing.events.firePopStateEvent = function(target, state) {
- var e = new goog.testing.events.Event(goog.events.EventType.POPSTATE, target);
- e.state = state;
- return goog.testing.events.fireBrowserEvent(e);
-};
-
-
-/**
- * Simulate a focus event on the given target.
- * @param {EventTarget} target The target for the event.
- * @return {boolean} The value returned by firing the focus browser event,
- * which returns false iff 'preventDefault' was invoked.
- */
-goog.testing.events.fireFocusEvent = function(target) {
- var e = new goog.testing.events.Event(
- goog.events.EventType.FOCUS, target);
- return goog.testing.events.fireBrowserEvent(e);
-};
-
-
-/**
- * Simulates an event's capturing and bubbling phases.
- * @param {Event} event A simulated native event. It will be wrapped in a
- * normalized BrowserEvent and dispatched to Closure listeners on all
- * ancestors of its target (inclusive).
- * @return {boolean} The returnValue of the event: false if preventDefault() was
- * called on it, true otherwise.
- */
-goog.testing.events.fireBrowserEvent = function(event) {
- event.returnValue_ = true;
-
- // generate a list of ancestors
- var ancestors = [];
- for (var current = event.target; current; current = current.parentNode) {
- ancestors.push(current);
- }
-
- // dispatch capturing listeners
- for (var j = ancestors.length - 1;
- j >= 0 && !event.propagationStopped_;
- j--) {
- goog.events.fireListeners(ancestors[j], event.type, true,
- new goog.events.BrowserEvent(event, ancestors[j]));
- }
-
- // dispatch bubbling listeners
- for (var j = 0;
- j < ancestors.length && !event.propagationStopped_;
- j++) {
- goog.events.fireListeners(ancestors[j], event.type, false,
- new goog.events.BrowserEvent(event, ancestors[j]));
- }
-
- return event.returnValue_;
-};
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/events/.svn/text-base/events_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/events/.svn/text-base/events_test.html.svn-base
deleted file mode 100644
index fd28121..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/events/.svn/text-base/events_test.html.svn-base
+++ /dev/null
@@ -1,434 +0,0 @@
-<!--
-Copyright 2008 The Closure Library Authors. All Rights Reserved.
-
-Use of this source code is governed by the Apache License, Version 2.0.
-See the COPYING file for details.
--->
-<!DOCTYPE html>
-<html lang="en" dir="ltr">
-<head>
-<meta http-equiv="X-UA-Compatible" content="IE=edge">
- <!--
-
- Author: nicksantos@google.com (Nick Santos)
- -->
- <title>Closure Unit Tests - goog.testing.events</title>
- <script src="../../base.js"></script>
- <script>
- goog.require('goog.array');
- goog.require('goog.dom');
- goog.require('goog.math.Coordinate');
- goog.require('goog.string');
- goog.require('goog.testing.PropertyReplacer');
- goog.require('goog.testing.events');
- goog.require('goog.testing.jsunit');
- goog.require('goog.userAgent');
-
-
- </script>
-</head>
-<body>
-<div id="root"></div>
-<input id='testButton' type='input' value='Click Me' />
-<div id='input'>Prevent Default these events:<br/></div>
-<div id='log' style='position:absolute;right:0;top:0'>Logged events:</div>
-<script type="text/javascript">
- var firedEventTypes;
- var firedEventCoordinates;
- var firedScreenCoordinates;
- var firedShiftKeys;
- var firedKeyCodes;
- var root = goog.dom.getElement('root');
- var log = goog.dom.getElement('log');
- var input = goog.dom.getElement('input');
- var testButton = goog.dom.getElement('testButton');
- var coordinate = new goog.math.Coordinate(123, 456);
- var stubs = new goog.testing.PropertyReplacer();
-
- function setUp() {
- stubs.reset();
- goog.events.removeAll();
- root.innerHTML = '';
- firedEventTypes = [];
- firedEventCoordinates = [];
- firedScreenCoordinates = [];
- firedShiftKeys = [];
- firedKeyCodes = [];
-
- for (var key in goog.events.EventType) {
- goog.events.listen(root, goog.events.EventType[key], function(e) {
- firedEventTypes.push(e.type);
- var coord = new goog.math.Coordinate(e.clientX, e.clientY);
- firedEventCoordinates.push(coord);
-
- firedScreenCoordinates.push(
- new goog.math.Coordinate(e.screenX, e.screenY));
-
- firedShiftKeys.push(!!e.shiftKey);
- firedKeyCodes.push(e.keyCode);
- });
- }
- }
-
- function tearDownPage() {
- for (var key in goog.events.EventType) {
- var type = goog.events.EventType[key];
- if (type == 'mousemove' || type == 'mouseout' || type == 'mouseover') {
- continue;
- }
- goog.dom.appendChild(input,
- goog.dom.createDom('label', null,
- goog.dom.createDom('input',
- {'id': type, 'type': 'checkbox'}),
- type,
- goog.dom.createDom('br')));
- goog.events.listen(testButton, type, function(e) {
- if (goog.dom.getElement(e.type).checked) {
- e.preventDefault();
- }
-
- log.innerHTML += goog.string.subs('<br/>%s (%s, %s)',
- e.type, e.clientX, e.clientY);
- });
- }
- }
-
- function testMouseOver() {
- goog.testing.events.fireMouseOverEvent(root, null);
- goog.testing.events.fireMouseOverEvent(root, null, coordinate);
- assertEventTypes(['mouseover', 'mouseover']);
- assertCoordinates([goog.style.getClientPosition(root), coordinate]);
- }
-
- function testMouseOut() {
- goog.testing.events.fireMouseOutEvent(root, null);
- goog.testing.events.fireMouseOutEvent(root, null, coordinate);
- assertEventTypes(['mouseout', 'mouseout']);
- assertCoordinates([goog.style.getClientPosition(root), coordinate]);
- }
-
- function testClickSequence() {
- assertTrue(goog.testing.events.fireClickSequence(root));
- assertEventTypes(['mousedown', 'mouseup', 'click']);
- var rootPosition = goog.style.getClientPosition(root);
- assertCoordinates([rootPosition, rootPosition, rootPosition]);
- }
-
- function testClickSequenceWithCoordinate() {
- assertTrue(goog.testing.events.fireClickSequence(root, null, coordinate));
- assertCoordinates([coordinate, coordinate, coordinate]);
- assertArrayEquals([false, false, false], firedShiftKeys);
- }
-
- function testClickSequenceWithEventProperty() {
- assertTrue(goog.testing.events.fireClickSequence(
- root, null, undefined, { shiftKey: true }));
- assertArrayEquals([true, true, true], firedShiftKeys);
- }
-
- function testClickSequenceCancellingMousedown() {
- preventDefaultEventType('mousedown');
- assertFalse(goog.testing.events.fireClickSequence(root));
- assertEventTypes(['mousedown', 'mouseup', 'click']);
- }
-
- function testClickSequenceCancellingMousedownWithCoordinate() {
- preventDefaultEventType('mousedown');
- assertFalse(goog.testing.events.fireClickSequence(root, null, coordinate));
- assertCoordinates([coordinate, coordinate, coordinate]);
- }
-
- function testClickSequenceCancellingMouseup() {
- preventDefaultEventType('mouseup');
- assertFalse(goog.testing.events.fireClickSequence(root));
- assertEventTypes(['mousedown', 'mouseup', 'click']);
- }
-
- function testClickSequenceCancellingMouseupWithCoordinate() {
- preventDefaultEventType('mouseup');
- assertFalse(goog.testing.events.fireClickSequence(root, null, coordinate));
- assertCoordinates([coordinate, coordinate, coordinate]);
- }
-
- function testClickSequenceCancellingClick() {
- preventDefaultEventType('click');
- assertFalse(goog.testing.events.fireClickSequence(root));
- assertEventTypes(['mousedown', 'mouseup', 'click']);
- }
-
- function testClickSequenceCancellingClickWithCoordinate() {
- preventDefaultEventType('click');
- assertFalse(goog.testing.events.fireClickSequence(root, null, coordinate));
- assertCoordinates([coordinate, coordinate, coordinate]);
- }
-
- // For a double click, IE fires selectstart instead of the second mousedown,
- // but we don't simulate selectstart. Also, IE doesn't fire the second click.
- var DBLCLICK_SEQ = (goog.userAgent.IE ?
- ['mousedown',
- 'mouseup',
- 'click',
- 'mouseup',
- 'dblclick'] :
- ['mousedown',
- 'mouseup',
- 'click',
- 'mousedown',
- 'mouseup',
- 'click',
- 'dblclick']);
-
-
- var DBLCLICK_SEQ_COORDS = goog.array.repeat(coordinate, DBLCLICK_SEQ.length);
-
- function testDoubleClickSequence() {
- assertTrue(goog.testing.events.fireDoubleClickSequence(root));
- assertEventTypes(DBLCLICK_SEQ);
- }
-
- function testDoubleClickSequenceWithCoordinate() {
- assertTrue(goog.testing.events.fireDoubleClickSequence(root, coordinate));
- assertCoordinates(DBLCLICK_SEQ_COORDS);
- }
-
- function testDoubleClickSequenceCancellingMousedown() {
- preventDefaultEventType('mousedown');
- assertFalse(goog.testing.events.fireDoubleClickSequence(root));
- assertEventTypes(DBLCLICK_SEQ);
- }
-
- function testDoubleClickSequenceCancellingMousedownWithCoordinate() {
- preventDefaultEventType('mousedown');
- assertFalse(goog.testing.events.fireDoubleClickSequence(root, coordinate));
- assertCoordinates(DBLCLICK_SEQ_COORDS);
- }
-
- function testDoubleClickSequenceCancellingMouseup() {
- preventDefaultEventType('mouseup');
- assertFalse(goog.testing.events.fireDoubleClickSequence(root));
- assertEventTypes(DBLCLICK_SEQ);
- }
-
- function testDoubleClickSequenceCancellingMouseupWithCoordinate() {
- preventDefaultEventType('mouseup');
- assertFalse(goog.testing.events.fireDoubleClickSequence(root, coordinate));
- assertCoordinates(DBLCLICK_SEQ_COORDS);
- }
-
- function testDoubleClickSequenceCancellingClick() {
- preventDefaultEventType('click');
- assertFalse(goog.testing.events.fireDoubleClickSequence(root));
- assertEventTypes(DBLCLICK_SEQ);
- }
-
- function testDoubleClickSequenceCancellingClickWithCoordinate() {
- preventDefaultEventType('click');
- assertFalse(goog.testing.events.fireDoubleClickSequence(root, coordinate));
- assertCoordinates(DBLCLICK_SEQ_COORDS);
- }
-
- function testDoubleClickSequenceCancellingDoubleClick() {
- preventDefaultEventType('dblclick');
- assertFalse(goog.testing.events.fireDoubleClickSequence(root));
- assertEventTypes(DBLCLICK_SEQ);
- }
-
- function testDoubleClickSequenceCancellingDoubleClickWithCoordinate() {
- preventDefaultEventType('dblclick');
- assertFalse(goog.testing.events.fireDoubleClickSequence(root, coordinate));
- assertCoordinates(DBLCLICK_SEQ_COORDS);
- }
-
- function testKeySequence() {
- assertTrue(goog.testing.events.fireKeySequence(
- root, goog.events.KeyCodes.ZERO));
- assertEventTypes(['keydown', 'keypress', 'keyup']);
- }
-
- function testKeySequenceCancellingKeydown() {
- preventDefaultEventType('keydown');
- assertFalse(goog.testing.events.fireKeySequence(
- root, goog.events.KeyCodes.ZERO));
- if (goog.userAgent.IE) {
- assertEventTypes(['keydown', 'keyup']);
- } else {
- assertEventTypes(['keydown', 'keypress', 'keyup']);
- }
- }
-
- function testKeySequenceCancellingKeypress() {
- preventDefaultEventType('keypress');
- assertFalse(goog.testing.events.fireKeySequence(
- root, goog.events.KeyCodes.ZERO));
- assertEventTypes(['keydown', 'keypress', 'keyup']);
- }
-
- function testKeySequenceCancellingKeyup() {
- preventDefaultEventType('keyup');
- assertFalse(goog.testing.events.fireKeySequence(
- root, goog.events.KeyCodes.ZERO));
- assertEventTypes(['keydown', 'keypress', 'keyup']);
- }
-
- function testKeySequenceWithEscapeKey() {
- assertTrue(goog.testing.events.fireKeySequence(
- root, goog.events.KeyCodes.ESC));
- if (goog.userAgent.WEBKIT && goog.userAgent.isVersion('525')) {
- assertEventTypes(['keydown', 'keyup']);
- } else {
- assertEventTypes(['keydown', 'keypress', 'keyup']);
- }
- }
-
- function testKeySequenceForMacActionKeysNegative() {
- stubs.set(goog.userAgent, 'GECKO', false);
- goog.testing.events.fireKeySequence(
- root, goog.events.KeyCodes.C, {'metaKey': true});
- assertEventTypes(['keydown', 'keypress', 'keyup']);
- }
-
- function testKeySequenceForMacActionKeysPositive() {
- stubs.set(goog.userAgent, 'GECKO', true);
- stubs.set(goog.userAgent, 'MAC', true);
- goog.testing.events.fireKeySequence(
- root, goog.events.KeyCodes.C, {'metaKey': true});
- assertEventTypes(['keypress', 'keyup']);
- }
-
- function testKeySequenceForOptionKeysOnMac() {
- // Mac uses an option (or alt) key to type non-ASCII characters. This test
- // verifies we can emulate key events sent when typing such non-ASCII
- // characters.
- stubs.set(goog.userAgent, 'WEBKIT', true);
- stubs.set(goog.userAgent, 'MAC', true);
-
- var optionKeyCodes = [
- [0xc0, 0x00e6], // option+'
- [0xbc, 0x2264], // option+,
- [0xbd, 0x2013], // option+-
- [0xbe, 0x2265], // option+.
- [0xbf, 0x00f7], // option+/
- [0x30, 0x00ba], // option+0
- [0x31, 0x00a1], // option+1
- [0x32, 0x2122], // option+2
- [0x33, 0x00a3], // option+3
- [0x34, 0x00a2], // option+4
- [0x35, 0x221e], // option+5
- [0x36, 0x00a7], // option+6
- [0x37, 0x00b6], // option+7
- [0x38, 0x2022], // option+8
- [0x39, 0x00aa], // option+9
- [0xba, 0x2026], // option+;
- [0xbb, 0x2260], // option+=
- [0xdb, 0x201c], // option+[
- [0xdc, 0x00ab], // option+\
- [0xdd, 0x2018], // option+]
- [0x41, 0x00e5], // option+a
- [0x42, 0x222b], // option+b
- [0x43, 0x00e7], // option+c
- [0x44, 0x2202], // option+d
- [0x45, 0x00b4], // option+e
- [0x46, 0x0192], // option+f
- [0x47, 0x00a9], // option+g
- [0x48, 0x02d9], // option+h
- [0x49, 0x02c6], // option+i
- [0x4a, 0x2206], // option+j
- [0x4b, 0x02da], // option+k
- [0x4c, 0x00ac], // option+l
- [0x4d, 0x00b5], // option+m
- [0x4e, 0x02dc], // option+n
- [0x4f, 0x00f8], // option+o
- [0x50, 0x03c0], // option+p
- [0x51, 0x0153], // option+q
- [0x52, 0x00ae], // option+r
- [0x53, 0x00df], // option+s
- [0x54, 0x2020], // option+t
- [0x56, 0x221a], // option+v
- [0x57, 0x2211], // option+w
- [0x58, 0x2248], // option+x
- [0x59, 0x00a5], // option+y
- [0x5a, 0x03a9] // option+z
- ];
-
- for (var i = 0; i < optionKeyCodes.length; ++i) {
- firedEventTypes = [];
- firedKeyCodes = [];
- var keyCode = optionKeyCodes[i][0];
- var keyPressKeyCode = optionKeyCodes[i][1];
- goog.testing.events.fireNonAsciiKeySequence(
- root, keyCode, keyPressKeyCode, {'altKey': true});
- assertEventTypes(['keydown', 'keypress', 'keyup']);
- assertArrayEquals([keyCode, keyPressKeyCode, keyCode], firedKeyCodes);
- }
- }
-
- var CONTEXTMENU_SEQ =
- goog.userAgent.WINDOWS ? ['mousedown', 'mouseup', 'contextmenu'] :
- goog.userAgent.GECKO ? ['mousedown', 'contextmenu', 'mouseup'] :
- goog.userAgent.WEBKIT && goog.userAgent.MAC ?
- ['mousedown', 'contextmenu', 'mouseup', 'click'] :
- ['mousedown', 'contextmenu', 'mouseup'];
-
- function testContextMenuSequence() {
- assertTrue(goog.testing.events.fireContextMenuSequence(root));
- assertEventTypes(CONTEXTMENU_SEQ);
- }
-
- function testContextMenuSequenceWithCoordinate() {
- assertTrue(goog.testing.events.fireContextMenuSequence(root, coordinate));
- assertEventTypes(CONTEXTMENU_SEQ);
- assertCoordinates(goog.array.repeat(coordinate, CONTEXTMENU_SEQ.length));
- }
-
- function testContextMenuSequenceCancellingMousedown() {
- preventDefaultEventType('mousedown');
- assertFalse(goog.testing.events.fireContextMenuSequence(root));
- assertEventTypes(CONTEXTMENU_SEQ);
- }
-
- function testContextMenuSequenceCancellingMouseup() {
- preventDefaultEventType('mouseup');
- assertFalse(goog.testing.events.fireContextMenuSequence(root));
- assertEventTypes(CONTEXTMENU_SEQ);
- }
-
- function testContextMenuSequenceCancellingContextMenu() {
- preventDefaultEventType('contextmenu');
- assertFalse(goog.testing.events.fireContextMenuSequence(root));
- assertEventTypes(CONTEXTMENU_SEQ);
- }
-
- function testContextMenuSequenceFakeMacWebkit() {
- stubs.set(goog.userAgent, 'WINDOWS', false);
- stubs.set(goog.userAgent, 'MAC', true);
- stubs.set(goog.userAgent, 'WEBKIT', true);
- assertTrue(goog.testing.events.fireContextMenuSequence(root));
- assertEventTypes(['mousedown', 'contextmenu', 'mouseup', 'click']);
- }
-
- /**
- * Assert that the list of events given was fired, in that order.
- */
- function assertEventTypes(list) {
- assertArrayEquals(list, firedEventTypes);
- }
-
- /**
- * Assert that the list of event coordinates given was caught, in that order.
- */
- function assertCoordinates(list) {
- assertArrayEquals(list, firedEventCoordinates);
- assertArrayEquals(list, firedScreenCoordinates);
- }
-
- /** Prevent default the event of the given type on the root element. */
- function preventDefaultEventType(type) {
- goog.events.listen(root, type, preventDefault);
- }
-
- function preventDefault(e) {
- e.preventDefault();
- }
-</script>
-</body>
-</html>
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/events/.svn/text-base/matchers.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/events/.svn/text-base/matchers.js.svn-base
deleted file mode 100644
index 2566cab..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/events/.svn/text-base/matchers.js.svn-base
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright 2009 The Closure Library Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS-IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/**
- * @fileoverview Mock matchers for event related arguments.
- */
-
-goog.provide('goog.testing.events.EventMatcher');
-
-goog.require('goog.events.Event');
-goog.require('goog.testing.mockmatchers.ArgumentMatcher');
-
-
-
-/**
- * A matcher that verifies that an argument is a {@code goog.events.Event} of a
- * particular type.
- * @param {string} type The single type the event argument must be of.
- * @constructor
- * @extends {goog.testing.mockmatchers.ArgumentMatcher}
- */
-goog.testing.events.EventMatcher = function(type) {
- goog.testing.mockmatchers.ArgumentMatcher.call(this,
- function(obj) {
- return obj instanceof goog.events.Event &&
- obj.type == type;
- }, 'isEventOfType(' + type + ')');
-};
-goog.inherits(goog.testing.events.EventMatcher,
- goog.testing.mockmatchers.ArgumentMatcher);
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/events/.svn/text-base/matchers_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/events/.svn/text-base/matchers_test.html.svn-base
deleted file mode 100644
index 90c1819..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/events/.svn/text-base/matchers_test.html.svn-base
+++ /dev/null
@@ -1,40 +0,0 @@
-<!DOCTYPE html>
-<html>
-<!--
-Copyright 2009 The Closure Library Authors. All Rights Reserved.
-
-Use of this source code is governed by the Apache License, Version 2.0.
-See the COPYING file for details.
--->
-<head>
-<meta http-equiv="X-UA-Compatible" content="IE=edge">
- <!--
-
- -->
- <title>Closure Unit Tests - goog.testing.events.EventMatcher</title>
- <script src="../../base.js"></script>
- <script>
- goog.require('goog.testing.events.EventMatcher');
- goog.require('goog.testing.jsunit');
- </script>
-</head>
-<body>
-<script>
- function testEventMatcher() {
- var matcher = new goog.testing.events.EventMatcher('foo');
- assertFalse(matcher.matches(undefined));
- assertFalse(matcher.matches(null));
- assertFalse(matcher.matches({type: 'foo'}));
- assertFalse(matcher.matches(new goog.events.Event('bar')));
-
- assertTrue(matcher.matches(new goog.events.Event('foo')));
- var FooEvent = function() {
- goog.events.Event.call(this, 'foo');
- };
- goog.inherits(FooEvent, goog.events.Event);
- assertTrue(matcher.matches(new FooEvent()));
- }
-</script>
-</body>
-</html>
-
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/events/eventobserver.js b/contexts/data/lib/closure-library/closure/goog/testing/events/eventobserver.js
index 83d6888..5d43582 100644
--- a/contexts/data/lib/closure-library/closure/goog/testing/events/eventobserver.js
+++ b/contexts/data/lib/closure-library/closure/goog/testing/events/eventobserver.js
@@ -29,6 +29,7 @@
* assertEquals(2, observer.getEvents('submit').length);
* </pre>
*
+ * @author nnaze@google.com (Nathan Naze)
*/
goog.provide('goog.testing.events.EventObserver');
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/events/events.js b/contexts/data/lib/closure-library/closure/goog/testing/events/events.js
index 8928c0b..fc7e578 100644
--- a/contexts/data/lib/closure-library/closure/goog/testing/events/events.js
+++ b/contexts/data/lib/closure-library/closure/goog/testing/events/events.js
@@ -39,7 +39,6 @@ goog.require('goog.events');
goog.require('goog.events.BrowserEvent');
goog.require('goog.events.BrowserEvent.MouseButton');
goog.require('goog.events.BrowserFeature');
-goog.require('goog.events.Event');
goog.require('goog.events.EventType');
goog.require('goog.events.KeyCodes');
goog.require('goog.object');
@@ -51,6 +50,9 @@ goog.require('goog.userAgent');
/**
* goog.events.BrowserEvent expects an Event so we provide one for JSCompiler.
*
+ * This clones a lot of the functionality of goog.events.Event. This used to
+ * use a mixin, but the mixin results in confusing the two types when compiled.
+ *
* @param {string} type Event Type.
* @param {Object=} opt_target Reference to the object that is the target of
* this event.
@@ -58,26 +60,47 @@ goog.require('goog.userAgent');
* @extends {Event}
*/
goog.testing.events.Event = function(type, opt_target) {
- /**
- * Event type.
- * @type {string}
- */
this.type = type;
- /**
- * Target of the event.
- * @type {Object|undefined}
- */
- this.target = opt_target;
+ this.target = /** @type {EventTarget} */ (opt_target || null);
- /**
- * Object that had the listener attached.
- * @type {Object|undefined}
- */
this.currentTarget = this.target;
};
-goog.object.extend(
- goog.testing.events.Event.prototype, goog.events.Event.prototype);
+
+
+/**
+ * Whether to cancel the event in internal capture/bubble processing for IE.
+ * @type {boolean}
+ * @suppress {underscore} Technically public, but referencing this outside
+ * this package is strongly discouraged.
+ */
+goog.testing.events.Event.prototype.propagationStopped_ = false;
+
+
+/** @override */
+goog.testing.events.Event.prototype.defaultPrevented = false;
+
+
+/**
+ * Return value for in internal capture/bubble processing for IE.
+ * @type {boolean}
+ * @suppress {underscore} Technically public, but referencing this outside
+ * this package is strongly discouraged.
+ */
+goog.testing.events.Event.prototype.returnValue_ = true;
+
+
+/** @override */
+goog.testing.events.Event.prototype.stopPropagation = function() {
+ this.propagationStopped_ = true;
+};
+
+
+/** @override */
+goog.testing.events.Event.prototype.preventDefault = function() {
+ this.defaultPrevented = true;
+ this.returnValue_ = false;
+};
/**
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/events/events_test.html b/contexts/data/lib/closure-library/closure/goog/testing/events/events_test.html
index fd28121..b6df9b9 100644
--- a/contexts/data/lib/closure-library/closure/goog/testing/events/events_test.html
+++ b/contexts/data/lib/closure-library/closure/goog/testing/events/events_test.html
@@ -29,9 +29,10 @@ See the COPYING file for details.
</head>
<body>
<div id="root"></div>
-<input id='testButton' type='input' value='Click Me' />
+<input id='testButton' type='input' value='Click Me'>
<div id='input'>Prevent Default these events:<br/></div>
<div id='log' style='position:absolute;right:0;top:0'>Logged events:</div>
+<div id='parentEl'><div id='childEl'>hello!</div></div>
<script type="text/javascript">
var firedEventTypes;
var firedEventCoordinates;
@@ -42,8 +43,11 @@ See the COPYING file for details.
var log = goog.dom.getElement('log');
var input = goog.dom.getElement('input');
var testButton = goog.dom.getElement('testButton');
+ var parentEl = goog.dom.getElement('parentEl');
+ var childEl = goog.dom.getElement('childEl');
var coordinate = new goog.math.Coordinate(123, 456);
var stubs = new goog.testing.PropertyReplacer();
+ var eventCount;
function setUp() {
stubs.reset();
@@ -68,6 +72,38 @@ See the COPYING file for details.
firedKeyCodes.push(e.keyCode);
});
}
+
+ eventCount = {
+ parentBubble: 0,
+ parentCapture: 0,
+ childCapture: 0,
+ childBubble: 0
+ };
+ // Event listeners for the capture/bubble test.
+ goog.events.listen(parentEl, goog.events.EventType.CLICK,
+ function(e) {
+ eventCount.parentCapture++;
+ assertEquals(parentEl, e.currentTarget);
+ assertEquals(childEl, e.target);
+ }, true);
+ goog.events.listen(childEl, goog.events.EventType.CLICK,
+ function(e) {
+ eventCount.childCapture++;
+ assertEquals(childEl, e.currentTarget);
+ assertEquals(childEl, e.target);
+ }, true);
+ goog.events.listen(childEl, goog.events.EventType.CLICK,
+ function(e) {
+ eventCount.childBubble++;
+ assertEquals(childEl, e.currentTarget);
+ assertEquals(childEl, e.target);
+ });
+ goog.events.listen(parentEl, goog.events.EventType.CLICK,
+ function(e) {
+ eventCount.parentBubble++;
+ assertEquals(parentEl, e.currentTarget);
+ assertEquals(childEl, e.target);
+ });
}
function tearDownPage() {
@@ -406,6 +442,86 @@ See the COPYING file for details.
assertEventTypes(['mousedown', 'contextmenu', 'mouseup', 'click']);
}
+ function testCaptureBubble_simple() {
+ assertTrue(goog.testing.events.fireClickEvent(childEl));
+ assertObjectEquals({
+ parentCapture: 1,
+ childCapture: 1,
+ childBubble: 1,
+ parentBubble: 1
+ }, eventCount);
+ }
+
+ function testCaptureBubble_preventDefault() {
+ goog.events.listen(childEl, goog.events.EventType.CLICK,
+ function(e) {
+ e.preventDefault();
+ });
+ assertFalse(goog.testing.events.fireClickEvent(childEl));
+ assertObjectEquals({
+ parentCapture: 1,
+ childCapture: 1,
+ childBubble: 1,
+ parentBubble: 1
+ }, eventCount);
+ }
+
+ function testCaptureBubble_stopPropagationParentCapture() {
+ goog.events.listen(parentEl, goog.events.EventType.CLICK,
+ function(e) {
+ e.stopPropagation();
+ }, true /* capture */);
+ assertTrue(goog.testing.events.fireClickEvent(childEl));
+ assertObjectEquals({
+ parentCapture: 1,
+ childCapture: 0,
+ childBubble: 0,
+ parentBubble: 0
+ }, eventCount);
+ }
+
+ function testCaptureBubble_stopPropagationChildCapture() {
+ goog.events.listen(childEl, goog.events.EventType.CLICK,
+ function(e) {
+ e.stopPropagation();
+ }, true /* capture */);
+ assertTrue(goog.testing.events.fireClickEvent(childEl));
+ assertObjectEquals({
+ parentCapture: 1,
+ childCapture: 1,
+ childBubble: 0,
+ parentBubble: 0
+ }, eventCount);
+ }
+
+ function testCaptureBubble_stopPropagationChildBubble() {
+ goog.events.listen(childEl, goog.events.EventType.CLICK,
+ function(e) {
+ e.stopPropagation();
+ });
+ assertTrue(goog.testing.events.fireClickEvent(childEl));
+ assertObjectEquals({
+ parentCapture: 1,
+ childCapture: 1,
+ childBubble: 1,
+ parentBubble: 0
+ }, eventCount);
+ }
+
+ function testCaptureBubble_stopPropagationParentBubble() {
+ goog.events.listen(parentEl, goog.events.EventType.CLICK,
+ function(e) {
+ e.stopPropagation();
+ });
+ assertTrue(goog.testing.events.fireClickEvent(childEl));
+ assertObjectEquals({
+ parentCapture: 1,
+ childCapture: 1,
+ childBubble: 1,
+ parentBubble: 1
+ }, eventCount);
+ }
+
/**
* Assert that the list of events given was fired, in that order.
*/
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/events/onlinehandler.js b/contexts/data/lib/closure-library/closure/goog/testing/events/onlinehandler.js
new file mode 100644
index 0000000..b135a05
--- /dev/null
+++ b/contexts/data/lib/closure-library/closure/goog/testing/events/onlinehandler.js
@@ -0,0 +1,67 @@
+// Copyright 2012 The Closure Library Authors. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS-IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+/**
+ * @fileoverview Mock of OnlineHandler for unit testing.
+ * @author dbk@google.com (David Barrett-Kahn)
+ */
+
+goog.provide('goog.testing.events.OnlineHandler');
+
+goog.require('goog.events.EventTarget');
+goog.require('goog.events.OnlineHandler.EventType');
+
+
+
+/**
+ * Mock implementation of goog.events.OnlineHandler.
+ * @param {boolean} initialState The initial online state of the mock.
+ * @constructor
+ * @extends {goog.events.EventTarget}
+ */
+goog.testing.events.OnlineHandler = function(initialState) {
+ goog.base(this);
+
+ /**
+ * Whether the mock is online.
+ * @type {boolean}
+ * @private
+ */
+ this.online_ = initialState;
+};
+goog.inherits(goog.testing.events.OnlineHandler, goog.events.EventTarget);
+
+
+/**
+ * Mock implementation of goog.events.OnlineHandler.isOnline.
+ * @return {boolean} Whether the mock is online.
+ */
+goog.testing.events.OnlineHandler.prototype.isOnline = function() {
+ return this.online_;
+};
+
+
+/**
+ * Sets the online state.
+ * @param {boolean} newOnlineState The new online state.
+ */
+goog.testing.events.OnlineHandler.prototype.setOnline =
+ function(newOnlineState) {
+ if (newOnlineState != this.online_) {
+ this.online_ = newOnlineState;
+ this.dispatchEvent(newOnlineState ?
+ goog.events.OnlineHandler.EventType.ONLINE :
+ goog.events.OnlineHandler.EventType.OFFLINE);
+ }
+};
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/events/onlinehandler_test.html b/contexts/data/lib/closure-library/closure/goog/testing/events/onlinehandler_test.html
new file mode 100644
index 0000000..66e6c72
--- /dev/null
+++ b/contexts/data/lib/closure-library/closure/goog/testing/events/onlinehandler_test.html
@@ -0,0 +1,89 @@
+<!DOCTYPE html>
+<!--
+Copyright 2012 The Closure Library Authors. All Rights Reserved.
+
+Use of this source code is governed by the Apache License, Version 2.0.
+See the COPYING file for details.
+-->
+<html>
+<head>
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <!--
+
+ Author: dbk@google.com (David Barrett-Kahn)
+ -->
+ <title>Closure Unit Tests - goog.testing.events</title>
+ <script src="../../base.js"></script>
+ <script>
+ goog.require('goog.events.OnlineHandler.EventType');
+ goog.require('goog.testing.events.EventObserver');
+ goog.require('goog.testing.events.OnlineHandler');
+ goog.require('goog.testing.jsunit');
+ </script>
+</head>
+<body>
+<script>
+ var handler;
+
+ var observer;
+
+ function tearDown() {
+ handler = null;
+ observer = null;
+ }
+
+ function testInitialValue() {
+ createHandler(true);
+ assertEquals(true, handler.isOnline());
+ createHandler(false);
+ assertEquals(false, handler.isOnline());
+ }
+
+ function testStateChange() {
+ createHandler(true);
+ assertEventCounts(0 /* expectedOnlineEvents */,
+ 0 /* expectedOfflineEvents */);
+
+ // Expect no events.
+ handler.setOnline(true);
+ assertEquals(true, handler.isOnline());
+ assertEventCounts(0 /* expectedOnlineEvents */,
+ 0 /* expectedOfflineEvents */);
+
+ // Expect one offline event.
+ handler.setOnline(false);
+ assertEquals(false, handler.isOnline());
+ assertEventCounts(0 /* expectedOnlineEvents */,
+ 1 /* expectedOfflineEvents */);
+
+ // Expect no events.
+ handler.setOnline(false);
+ assertEquals(false, handler.isOnline());
+ assertEventCounts(0 /* expectedOnlineEvents */,
+ 1 /* expectedOfflineEvents */);
+
+ // Expect one online event.
+ handler.setOnline(true);
+ assertEquals(true, handler.isOnline());
+ assertEventCounts(1 /* expectedOnlineEvents */,
+ 1 /* expectedOfflineEvents */);
+ }
+
+ function createHandler(initialValue) {
+ handler = new goog.testing.events.OnlineHandler(initialValue);
+ observer = new goog.testing.events.EventObserver();
+ goog.events.listen(handler,
+ [goog.events.OnlineHandler.EventType.ONLINE,
+ goog.events.OnlineHandler.EventType.OFFLINE],
+ observer);
+ }
+
+ function assertEventCounts(expectedOnlineEvents, expectedOfflineEvents) {
+ assertEquals(expectedOnlineEvents,
+ observer.getEvents(goog.events.OnlineHandler.EventType.ONLINE).length);
+ assertEquals(expectedOfflineEvents,
+ observer.getEvents(goog.events.OnlineHandler.EventType.OFFLINE).length);
+ }
+</script>
+</body>
+</html>
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/all-wcprops b/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/all-wcprops
deleted file mode 100644
index 88cf6d7..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/all-wcprops
+++ /dev/null
@@ -1,101 +0,0 @@
-K 25
-svn:wc:ra_dav:version-url
-V 48
-/svn/!svn/ver/1434/trunk/closure/goog/testing/fs
-END
-blob_test.html
-K 25
-svn:wc:ra_dav:version-url
-V 62
-/svn/!svn/ver/850/trunk/closure/goog/testing/fs/blob_test.html
-END
-progressevent.js
-K 25
-svn:wc:ra_dav:version-url
-V 65
-/svn/!svn/ver/1376/trunk/closure/goog/testing/fs/progressevent.js
-END
-fs.js
-K 25
-svn:wc:ra_dav:version-url
-V 54
-/svn/!svn/ver/1393/trunk/closure/goog/testing/fs/fs.js
-END
-integration_test.html
-K 25
-svn:wc:ra_dav:version-url
-V 70
-/svn/!svn/ver/1434/trunk/closure/goog/testing/fs/integration_test.html
-END
-filewriter.js
-K 25
-svn:wc:ra_dav:version-url
-V 62
-/svn/!svn/ver/1376/trunk/closure/goog/testing/fs/filewriter.js
-END
-directoryentry_test.html
-K 25
-svn:wc:ra_dav:version-url
-V 73
-/svn/!svn/ver/1434/trunk/closure/goog/testing/fs/directoryentry_test.html
-END
-blob.js
-K 25
-svn:wc:ra_dav:version-url
-V 56
-/svn/!svn/ver/1393/trunk/closure/goog/testing/fs/blob.js
-END
-file.js
-K 25
-svn:wc:ra_dav:version-url
-V 55
-/svn/!svn/ver/850/trunk/closure/goog/testing/fs/file.js
-END
-filesystem.js
-K 25
-svn:wc:ra_dav:version-url
-V 61
-/svn/!svn/ver/850/trunk/closure/goog/testing/fs/filesystem.js
-END
-fileentry_test.html
-K 25
-svn:wc:ra_dav:version-url
-V 68
-/svn/!svn/ver/1434/trunk/closure/goog/testing/fs/fileentry_test.html
-END
-entry_test.html
-K 25
-svn:wc:ra_dav:version-url
-V 64
-/svn/!svn/ver/1434/trunk/closure/goog/testing/fs/entry_test.html
-END
-filereader_test.html
-K 25
-svn:wc:ra_dav:version-url
-V 69
-/svn/!svn/ver/1434/trunk/closure/goog/testing/fs/filereader_test.html
-END
-fs_test.html
-K 25
-svn:wc:ra_dav:version-url
-V 61
-/svn/!svn/ver/1434/trunk/closure/goog/testing/fs/fs_test.html
-END
-entry.js
-K 25
-svn:wc:ra_dav:version-url
-V 57
-/svn/!svn/ver/1302/trunk/closure/goog/testing/fs/entry.js
-END
-filereader.js
-K 25
-svn:wc:ra_dav:version-url
-V 62
-/svn/!svn/ver/1376/trunk/closure/goog/testing/fs/filereader.js
-END
-filewriter_test.html
-K 25
-svn:wc:ra_dav:version-url
-V 69
-/svn/!svn/ver/1434/trunk/closure/goog/testing/fs/filewriter_test.html
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/entries b/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/entries
deleted file mode 100644
index b6ba420..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/entries
+++ /dev/null
@@ -1,572 +0,0 @@
-10
-
-dir
-1494
-http://closure-library.googlecode.com/svn/trunk/closure/goog/testing/fs
-http://closure-library.googlecode.com/svn
-
-
-
-2011-11-30T22:16:21.000000Z
-1434
-chrishenry@google.com
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-0b95b8e8-c90f-11de-9d4f-f947ee5921c8
-
-blob_test.html
-file
-
-
-
-
-2011-12-23T22:42:26.767309Z
-b57a9c13facede855d9543a73d8fa57a
-2011-04-12T20:35:47.000000Z
-850
-diegosalas@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-1631
-
-progressevent.js
-file
-
-
-
-
-2011-12-23T22:42:26.768309Z
-44321cd57c43d6ba519663a42835c853
-2011-11-08T21:28:42.000000Z
-1376
-tpayne@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-2125
-
-fs.js
-file
-
-
-
-
-2011-12-23T22:42:26.768309Z
-99cc47f8ee2d76e67b157b00013e532b
-2011-11-15T23:18:54.000000Z
-1393
-tpayne@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-4628
-
-integration_test.html
-file
-
-
-
-
-2011-12-23T22:42:26.769309Z
-7d52be37c2363a6b19e4fcd01ac16661
-2011-11-30T22:16:21.000000Z
-1434
-chrishenry@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-7500
-
-filewriter.js
-file
-
-
-
-
-2011-12-23T22:42:26.769309Z
-aa94708451afea48f8dafabad5a2699b
-2011-11-08T21:28:42.000000Z
-1376
-tpayne@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-7455
-
-directoryentry_test.html
-file
-
-
-
-
-2011-12-23T22:42:26.770309Z
-582c4cf17dda6f044467b8366b4e7e43
-2011-11-30T22:16:21.000000Z
-1434
-chrishenry@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-8848
-
-blob.js
-file
-
-
-
-
-2011-12-23T22:42:26.770309Z
-ff7839abe596b8cd6a45ec53eeebece0
-2011-11-15T23:18:54.000000Z
-1393
-tpayne@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-3011
-
-file.js
-file
-
-
-
-
-2011-12-23T22:42:26.771309Z
-5598b2723cf8e952a7fbf15a1bc754be
-2011-04-12T20:35:47.000000Z
-850
-diegosalas@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-1576
-
-filesystem.js
-file
-
-
-
-
-2011-12-23T22:42:26.772309Z
-e8096b3c124e124cf6cb7b5da267aeb7
-2011-04-12T20:35:47.000000Z
-850
-diegosalas@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-1588
-
-fileentry_test.html
-file
-
-
-
-
-2011-12-23T22:42:26.773309Z
-8bb3790422a827e312dd10b213204c3f
-2011-11-30T22:16:21.000000Z
-1434
-chrishenry@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-1975
-
-entry_test.html
-file
-
-
-
-
-2011-12-23T22:42:26.773309Z
-e1de9d8878f4b2edc01957df1f069211
-2011-11-30T22:16:21.000000Z
-1434
-chrishenry@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-6006
-
-filereader_test.html
-file
-
-
-
-
-2011-12-23T22:42:26.774309Z
-d2ed331f646ab25591e76e6b4dc33ce7
-2011-11-30T22:16:21.000000Z
-1434
-chrishenry@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-8240
-
-fs_test.html
-file
-
-
-
-
-2011-12-23T22:42:26.774309Z
-1e8278a6707adaad6c9d3e50ec0198f2
-2011-11-30T22:16:21.000000Z
-1434
-chrishenry@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-1505
-
-entry.js
-file
-
-
-
-
-2011-12-23T22:42:26.775309Z
-886cd3bdf910b642b81a88b99d8757f3
-2011-09-27T00:20:47.000000Z
-1302
-bmccann@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-18369
-
-filereader.js
-file
-
-
-
-
-2011-12-23T22:42:26.776309Z
-3f310abc4f8fdf55b2ca9336c68f8201
-2011-11-08T21:28:42.000000Z
-1376
-tpayne@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-7203
-
-filewriter_test.html
-file
-
-
-
-
-2011-12-23T22:42:26.776309Z
-3979fa98a50f2bd3cff3cc1fcb01364b
-2011-11-30T22:16:21.000000Z
-1434
-chrishenry@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-11872
-
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/prop-base/blob.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/prop-base/blob.js.svn-base
deleted file mode 100644
index 7febff5..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/prop-base/blob.js.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 22
-application/javascript
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/prop-base/blob_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/prop-base/blob_test.html.svn-base
deleted file mode 100644
index d356868..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/prop-base/blob_test.html.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 9
-text/html
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/prop-base/directoryentry_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/prop-base/directoryentry_test.html.svn-base
deleted file mode 100644
index d356868..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/prop-base/directoryentry_test.html.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 9
-text/html
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/prop-base/entry.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/prop-base/entry.js.svn-base
deleted file mode 100644
index 7febff5..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/prop-base/entry.js.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 22
-application/javascript
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/prop-base/entry_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/prop-base/entry_test.html.svn-base
deleted file mode 100644
index d356868..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/prop-base/entry_test.html.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 9
-text/html
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/prop-base/file.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/prop-base/file.js.svn-base
deleted file mode 100644
index 7febff5..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/prop-base/file.js.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 22
-application/javascript
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/prop-base/fileentry_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/prop-base/fileentry_test.html.svn-base
deleted file mode 100644
index d356868..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/prop-base/fileentry_test.html.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 9
-text/html
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/prop-base/filereader.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/prop-base/filereader.js.svn-base
deleted file mode 100644
index 530636b..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/prop-base/filereader.js.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 15
-text/javascript
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/prop-base/filereader_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/prop-base/filereader_test.html.svn-base
deleted file mode 100644
index d356868..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/prop-base/filereader_test.html.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 9
-text/html
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/prop-base/filesystem.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/prop-base/filesystem.js.svn-base
deleted file mode 100644
index 7febff5..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/prop-base/filesystem.js.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 22
-application/javascript
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/prop-base/filewriter.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/prop-base/filewriter.js.svn-base
deleted file mode 100644
index 7febff5..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/prop-base/filewriter.js.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 22
-application/javascript
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/prop-base/filewriter_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/prop-base/filewriter_test.html.svn-base
deleted file mode 100644
index d356868..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/prop-base/filewriter_test.html.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 9
-text/html
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/prop-base/fs.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/prop-base/fs.js.svn-base
deleted file mode 100644
index 7febff5..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/prop-base/fs.js.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 22
-application/javascript
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/prop-base/fs_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/prop-base/fs_test.html.svn-base
deleted file mode 100644
index d356868..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/prop-base/fs_test.html.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 9
-text/html
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/prop-base/integration_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/prop-base/integration_test.html.svn-base
deleted file mode 100644
index d356868..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/prop-base/integration_test.html.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 9
-text/html
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/prop-base/progressevent.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/prop-base/progressevent.js.svn-base
deleted file mode 100644
index 530636b..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/prop-base/progressevent.js.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 15
-text/javascript
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/text-base/blob.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/text-base/blob.js.svn-base
deleted file mode 100644
index b0408a6..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/text-base/blob.js.svn-base
+++ /dev/null
@@ -1,115 +0,0 @@
-// Copyright 2011 The Closure Library Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS-IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/**
- * @fileoverview Mock blob object.
- *
- */
-
-goog.provide('goog.testing.fs.Blob');
-
-goog.require('goog.crypt.base64');
-
-
-
-/**
- * A mock Blob object. The data is stored as a string.
- *
- * @param {string=} opt_data The string data encapsulated by the blob.
- * @param {string=} opt_type The mime type of the blob.
- * @constructor
- */
-goog.testing.fs.Blob = function(opt_data, opt_type) {
- /**
- * @see http://www.w3.org/TR/FileAPI/#dfn-type
- * @type {string}
- */
- this.type = opt_type || '';
-
- this.setDataInternal(opt_data || '');
-};
-
-
-/**
- * The string data encapsulated by the blob.
- * @type {string}
- * @private
- */
-goog.testing.fs.Blob.prototype.data_;
-
-
-/**
- * @see http://www.w3.org/TR/FileAPI/#dfn-size
- * @type {number}
- */
-goog.testing.fs.Blob.prototype.size;
-
-
-/**
- * @see http://www.w3.org/TR/FileAPI/#dfn-slice
- * @param {number} start The start byte offset.
- * @param {number} length The number of bytes to slice.
- * @param {string=} opt_contentType The type of the resulting Blob.
- * @return {!goog.testing.fs.Blob} The result of the slice operation.
- */
-goog.testing.fs.Blob.prototype.slice = function(
- start, length, opt_contentType) {
- start = Math.max(0, start);
- return new goog.testing.fs.Blob(
- this.data_.substring(start, start + Math.max(length, 0)),
- opt_contentType);
-};
-
-
-/**
- * @return {string} The string data encapsulated by the blob.
- */
-goog.testing.fs.Blob.prototype.toString = function() {
- return this.data_;
-};
-
-
-/**
- * @return {ArrayBuffer} The string data encapsulated by the blob as an
- * ArrayBuffer.
- */
-goog.testing.fs.Blob.prototype.toArrayBuffer = function() {
- var buf = new ArrayBuffer(this.data_.length * 2);
- var arr = new Uint16Array(buf);
- for (var i = 0; i < this.data_.length; i++) {
- arr[i] = this.data_.charCodeAt(i);
- }
- return buf;
-};
-
-
-/**
- * @return {string} The string data encapsulated by the blob as a data: URI.
- */
-goog.testing.fs.Blob.prototype.toDataUrl = function() {
- return 'data:' + this.type + ';base64,' +
- goog.crypt.base64.encodeString(this.data_);
-};
-
-
-/**
- * Sets the internal contents of the blob. This should only be called by other
- * functions inside the {@code goog.testing.fs} namespace.
- *
- * @param {string} data The data for this Blob.
- */
-goog.testing.fs.Blob.prototype.setDataInternal = function(data) {
- this.data_ = data;
- this.size = data.length;
-};
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/text-base/blob_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/text-base/blob_test.html.svn-base
deleted file mode 100644
index f802d75..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/text-base/blob_test.html.svn-base
+++ /dev/null
@@ -1,65 +0,0 @@
-<!DOCTYPE html>
-<html>
-<!--
-Copyright 2011 The Closure Library Authors. All Rights Reserved.
-
-Use of this source code is governed by the Apache License, Version 2.0.
-See the COPYING file for details.
--->
-<!--
--->
-<head>
-<title>Closure Unit Tests - goog.testing.fs.Blob</title>
-<script src="../../base.js"></script>
-<script>
-goog.require('goog.testing.fs.Blob');
-goog.require('goog.testing.jsunit');
-</script>
-</head>
-<body>
-<script>
-
-function testAttributes() {
- var blob = new goog.testing.fs.Blob();
- assertEquals(0, blob.size);
- assertEquals('', blob.type);
-
- blob = new goog.testing.fs.Blob('foo bar baz');
- assertEquals(11, blob.size);
- assertEquals('', blob.type);
-
- blob = new goog.testing.fs.Blob('foo bar baz', 'text/plain');
- assertEquals(11, blob.size);
- assertEquals('text/plain', blob.type);
-}
-
-function testToString() {
- assertEquals('', new goog.testing.fs.Blob().toString());
- assertEquals('foo bar', new goog.testing.fs.Blob('foo bar').toString());
-}
-
-function testSlice() {
- var blob = new goog.testing.fs.Blob('abcdef');
- assertEquals('bc', blob.slice(1, 2).toString());
- assertEquals('def', blob.slice(3, 10).toString());
- assertEquals('', blob.slice(10, 1).toString());
- assertEquals('a', blob.slice(-1, 1).toString());
-
- assertEquals('text/plain', blob.slice(1, 2, 'text/plain').type);
-}
-
-function testSetDataInternal() {
- var blob = new goog.testing.fs.Blob();
-
- blob.setDataInternal('asdf');
- assertEquals('asdf', blob.toString());
- assertEquals(4, blob.size);
-
- blob.setDataInternal('');
- assertEquals('', blob.toString());
- assertEquals(0, blob.size);
-}
-
-</script>
-</body>
-</html>
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/text-base/directoryentry_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/text-base/directoryentry_test.html.svn-base
deleted file mode 100644
index 7fab04a..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/text-base/directoryentry_test.html.svn-base
+++ /dev/null
@@ -1,300 +0,0 @@
-<!DOCTYPE html>
-<html>
-<!--
-Copyright 2011 The Closure Library Authors. All Rights Reserved.
-
-Use of this source code is governed by the Apache License, Version 2.0.
-See the COPYING file for details.
--->
-<!--
--->
-<head>
-<title>Closure Unit Tests - goog.testing.fs.DirectoryEntry</title>
-<script src="../../base.js"></script>
-<script>
-goog.require('goog.fs.DirectoryEntry.Behavior');
-goog.require('goog.fs.Error.ErrorCode');
-goog.require('goog.testing.AsyncTestCase');
-goog.require('goog.testing.MockClock');
-goog.require('goog.testing.fs.FileSystem');
-goog.require('goog.testing.jsunit');
-</script>
-</head>
-<body>
-<script>
-
-var asyncTestCase = goog.testing.AsyncTestCase.createAndInstall();
-var fs, dir, mockClock;
-
-function setUp() {
- mockClock = new goog.testing.MockClock(true);
-
- fs = new goog.testing.fs.FileSystem();
- dir = fs.getRoot().createDirectorySync('foo');
- dir.createDirectorySync('subdir').createFileSync('subfile');
- dir.createFileSync('file');
-}
-
-function tearDown() {
- mockClock.uninstall();
-}
-
-function testIsFile() {
- assertFalse(dir.isFile());
-}
-
-function testIsDirectory() {
- assertTrue(dir.isDirectory());
-}
-
-function testRemoveWithChildren() {
- dir.getFileSync('bar', goog.fs.DirectoryEntry.Behavior.CREATE);
- expectError(dir.remove(), goog.fs.Error.ErrorCode.INVALID_MODIFICATION);
-}
-
-function testRemoveWithoutChildren() {
- var emptyDir = dir.getDirectorySync(
- 'empty', goog.fs.DirectoryEntry.Behavior.CREATE);
- emptyDir.remove().
- addCallback(function() {
- assertTrue(emptyDir.deleted);
- assertFalse(fs.getRoot().hasChild('empty'));
- }).
- addBoth(continueTesting);
- waitForAsync('waiting for file removal');
-}
-
-function testGetFile() {
- // Advance the clock by an arbitrary but known amount.
- mockClock.tick(41);
- dir.getFile('file').
- addCallback(function(file) {
- assertEquals(dir.getFileSync('file'), file);
- assertEquals('file', file.getName());
- assertEquals('/foo/file', file.getFullPath());
- assertTrue(file.isFile())
-
- return dir.getLastModified();
- }).
- addCallback(function(date) {
- assertEquals('Reading a file should not update the modification date.',
- 0, date.getTime());
- }).
- addBoth(continueTesting);
- waitForAsync('waiting for file');
-}
-
-function testGetFileFromSubdir() {
- dir.getFile('subdir/subfile').addCallback(function(file) {
- assertEquals(dir.getDirectorySync('subdir').getFileSync('subfile'), file);
- assertEquals('subfile', file.getName());
- assertEquals('/foo/subdir/subfile', file.getFullPath());
- assertTrue(file.isFile());
- }).
- addBoth(continueTesting);
- waitForAsync('waiting for file');
-}
-
-function testGetAbsolutePaths() {
- fs.getRoot().getFile('/foo/subdir/subfile').
- addCallback(function(subfile) {
- assertEquals('/foo/subdir/subfile', subfile.getFullPath());
- return fs.getRoot().getDirectory('//foo////');
- }).
- addCallback(function(foo) {
- assertEquals('/foo', foo.getFullPath());
- return foo.getDirectory('/');
- }).
- addCallback(function(root) {
- assertEquals('/', root.getFullPath());
- return root.getDirectory('/////');
- }).
- addCallback(function(root) {
- assertEquals('/', root.getFullPath());
- }).
- addBoth(continueTesting);
- waitForAsync('testGetAbsolutePaths');
-}
-
-function testCreateFile() {
- mockClock.tick(43);
- dir.getLastModified().
- addCallback(function(date) { assertEquals(0, date.getTime()); }).
- addCallback(function() {
- return dir.getFile('bar', goog.fs.DirectoryEntry.Behavior.CREATE);
- }).
- addCallback(function(file) {
- mockClock.tick();
- assertEquals('bar', file.getName());
- assertEquals('/foo/bar', file.getFullPath());
- assertEquals(dir, file.parent);
- assertTrue(file.isFile());
-
- return dir.getLastModified();
- }).
- addCallback(function(date) {
- assertEquals(43, date.getTime());
- }).
- addBoth(continueTesting);
- waitForAsync('waiting for file creation');
-}
-
-function testCreateFileThatAlreadyExists() {
- mockClock.tick(47);
- var existingFile = dir.getFileSync('file');
- dir.getFile('file', goog.fs.DirectoryEntry.Behavior.CREATE).
- addCallback(function(file) {
- mockClock.tick();
- assertEquals('file', file.getName());
- assertEquals('/foo/file', file.getFullPath());
- assertEquals(dir, file.parent);
- assertEquals(existingFile, file);
- assertTrue(file.isFile());
-
- return dir.getLastModified();
- }).
- addCallback(function(date) {
- assertEquals(47, date.getTime());
- }).
- addBoth(continueTesting);
- waitForAsync('waiting for file creation');
-}
-
-function testCreateFileInSubdir() {
- dir.getFile('subdir/bar', goog.fs.DirectoryEntry.Behavior.CREATE).
- addCallback(function(file) {
- assertEquals('bar', file.getName());
- assertEquals('/foo/subdir/bar', file.getFullPath());
- assertEquals(dir.getDirectorySync('subdir'), file.parent);
- assertTrue(file.isFile());
- }).
- addBoth(continueTesting);
- waitForAsync('waiting for file creation');
-}
-
-function testCreateFileExclusive() {
- dir.getFile('bar', goog.fs.DirectoryEntry.Behavior.CREATE_EXCLUSIVE).
- addCallback(function(file) {
- assertEquals('bar', file.getName());
- assertEquals('/foo/bar', file.getFullPath());
- assertEquals(dir, file.parent);
- assertTrue(file.isFile());
- }).
- addBoth(continueTesting);
- waitForAsync('waiting for file creation');
-}
-
-function testGetNonExistentFile() {
- expectError(dir.getFile('bar'), goog.fs.Error.ErrorCode.NOT_FOUND);
-}
-
-function testGetNonExistentFileInSubdir() {
- expectError(dir.getFile('subdir/bar'), goog.fs.Error.ErrorCode.NOT_FOUND);
-}
-
-function testGetFileInNonExistentSubdir() {
- expectError(dir.getFile('bar/subfile'), goog.fs.Error.ErrorCode.NOT_FOUND);
-}
-
-function testGetFileThatsActuallyADirectory() {
- expectError(dir.getFile('subdir'), goog.fs.Error.ErrorCode.TYPE_MISMATCH);
-}
-
-function testCreateFileInNonExistentSubdir() {
- expectError(
- dir.getFile('bar/newfile', goog.fs.DirectoryEntry.Behavior.CREATE),
- goog.fs.Error.ErrorCode.NOT_FOUND);
-}
-
-function testCreateFileThatsActuallyADirectory() {
- expectError(
- dir.getFile('subdir', goog.fs.DirectoryEntry.Behavior.CREATE),
- goog.fs.Error.ErrorCode.TYPE_MISMATCH);
-}
-
-function testCreateExclusiveExistingFile() {
- expectError(
- dir.getFile('file', goog.fs.DirectoryEntry.Behavior.CREATE_EXCLUSIVE),
- goog.fs.Error.ErrorCode.PATH_EXISTS);
-}
-
-function testListEmptyDirectory() {
- var emptyDir = fs.getRoot().
- getDirectorySync('empty', goog.fs.DirectoryEntry.Behavior.CREATE);
-
- emptyDir.listDirectory().
- addCallback(function(entryList) {
- assertSameElements([], entryList);
- }).
- addBoth(continueTesting);
- waitForAsync('testListEmptyDirectory');
-}
-
-function testListDirectory() {
- var root = fs.getRoot();
- root.getDirectorySync('dir1', goog.fs.DirectoryEntry.Behavior.CREATE);
- root.getDirectorySync('dir2', goog.fs.DirectoryEntry.Behavior.CREATE);
- root.getFileSync('file1', goog.fs.DirectoryEntry.Behavior.CREATE);
- root.getFileSync('file2', goog.fs.DirectoryEntry.Behavior.CREATE);
-
- fs.getRoot().listDirectory().
- addCallback(function(entryList) {
- assertSameElements([
- 'dir1',
- 'dir2',
- 'file1',
- 'file2',
- 'foo'
- ],
- goog.array.map(entryList, function(entry) {
- return entry.getName();
- }));
- }).
- addBoth(continueTesting);
- waitForAsync('testListDirectory');
-}
-
-function testCreatePath() {
- dir.createPath('baz/bat').
- addCallback(function(batDir) {
- assertEquals('/foo/baz/bat', batDir.getFullPath());
- return batDir.createPath('../zazzle');
- }).
- addCallback(function(zazzleDir) {
- assertEquals('/foo/baz/zazzle', zazzleDir.getFullPath());
- return zazzleDir.createPath('/elements/actinides/neptunium/');
- }).
- addCallback(function(elDir) {
- assertEquals('/elements/actinides/neptunium', elDir.getFullPath());
- }).
- addBoth(continueTesting);
- waitForAsync('testCreatePath');
-}
-
-
-function continueTesting(result) {
- asyncTestCase.continueTesting();
- if (result instanceof Error) {
- throw result;
- }
- mockClock.tick();
-}
-
-function expectError(deferred, code) {
- deferred.
- addCallback(function() { fail('Expected an error'); }).
- addErrback(function(err) {
- assertEquals(code, err.code);
- asyncTestCase.continueTesting();
- });
- waitForAsync('waiting for error');
-}
-
-function waitForAsync(msg) {
- asyncTestCase.waitForAsync(msg);
- mockClock.tick();
-}
-
-</script>
-</body>
-</html>
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/text-base/entry.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/text-base/entry.js.svn-base
deleted file mode 100644
index a17d795..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/text-base/entry.js.svn-base
+++ /dev/null
@@ -1,622 +0,0 @@
-// Copyright 2011 The Closure Library Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS-IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/**
- * @fileoverview Mock filesystem objects. These are all in the same file to
- * avoid circular dependency issues.
- *
- */
-
-goog.provide('goog.testing.fs.DirectoryEntry');
-goog.provide('goog.testing.fs.Entry');
-goog.provide('goog.testing.fs.FileEntry');
-
-goog.require('goog.Timer');
-goog.require('goog.array');
-goog.require('goog.async.Deferred');
-goog.require('goog.fs.DirectoryEntry');
-goog.require('goog.fs.DirectoryEntry.Behavior');
-goog.require('goog.fs.Error');
-goog.require('goog.functions');
-goog.require('goog.object');
-goog.require('goog.string');
-goog.require('goog.testing.fs.File');
-goog.require('goog.testing.fs.FileWriter');
-
-
-
-/**
- * A mock filesystem entry object.
- *
- * @param {!goog.testing.fs.FileSystem} fs The filesystem containing this entry.
- * @param {!goog.testing.fs.DirectoryEntry} parent The directory entry directly
- * containing this entry.
- * @param {string} name The name of this entry.
- * @constructor
- */
-goog.testing.fs.Entry = function(fs, parent, name) {
- /**
- * This entry's filesystem.
- * @type {!goog.testing.fs.FileSystem}
- * @private
- */
- this.fs_ = fs;
-
- /**
- * The name of this entry.
- * @type {string}
- * @private
- */
- this.name_ = name;
-
- /**
- * The parent of this entry.
- * @type {!goog.testing.fs.DirectoryEntry}
- */
- this.parent = parent;
-};
-
-
-/**
- * Whether or not this entry has been deleted.
- * @type {boolean}
- */
-goog.testing.fs.Entry.prototype.deleted = false;
-
-
-/**
- * @see {goog.fs.Entry#isFile}
- * @return {boolean}
- */
-goog.testing.fs.Entry.prototype.isFile = goog.abstractMethod;
-
-
-/**
- * @see {goog.fs.Entry#isDirectory}
- * @return {boolean}
- */
-goog.testing.fs.Entry.prototype.isDirectory = goog.abstractMethod;
-
-
-/**
- * @see {goog.fs.Entry#getName}
- * @return {string}
- */
-goog.testing.fs.Entry.prototype.getName = function() {
- return this.name_;
-};
-
-
-/**
- * @see {goog.fs.Entry#getFullPath}
- * @return {string}
- */
-goog.testing.fs.Entry.prototype.getFullPath = function() {
- if (this.getName() == '' || this.parent.getName() == '') {
- // The root directory has an empty name
- return '/' + this.name_;
- } else {
- return this.parent.getFullPath() + '/' + this.name_;
- }
-};
-
-
-/**
- * @see {goog.fs.Entry#getFileSystem}
- * @return {!goog.testing.fs.FileSystem}
- */
-goog.testing.fs.Entry.prototype.getFileSystem = function() {
- return this.fs_;
-};
-
-
-/**
- * @see {goog.fs.Entry#getLastModified}
- * @return {!goog.async.Deferred}
- */
-goog.testing.fs.Entry.prototype.getLastModified = goog.abstractMethod;
-
-
-/**
- * @see {goog.fs.Entry#moveTo}
- * @param {!goog.testing.fs.DirectoryEntry} parent
- * @param {string=} opt_newName
- * @return {!goog.async.Deferred}
- */
-goog.testing.fs.Entry.prototype.moveTo = function(parent, opt_newName) {
- var msg = 'moving ' + this.getFullPath() + ' into ' + parent.getFullPath() +
- (opt_newName ? ', renaming to ' + opt_newName : '');
- var newFile;
- return this.checkNotDeleted(msg).
- addCallback(function() { return this.copyTo(parent, opt_newName); }).
- addCallback(function(file) {
- newFile = file;
- return this.remove();
- }).addCallback(function() { return newFile; });
-};
-
-
-/**
- * @see {goog.fs.Entry#copyTo}
- * @param {!goog.testing.fs.DirectoryEntry} parent
- * @param {string=} opt_newName
- * @return {!goog.async.Deferred}
- */
-goog.testing.fs.Entry.prototype.copyTo = function(parent, opt_newName) {
- var msg = 'copying ' + this.getFullPath() + ' into ' + parent.getFullPath() +
- (opt_newName ? ', renaming to ' + opt_newName : '');
- return this.checkNotDeleted(msg).addCallback(function() {
- var name = opt_newName || this.getName();
- var entry = this.clone();
- parent.children[name] = entry;
- parent.lastModifiedTimestamp_ = goog.now();
- entry.name_ = name;
- entry.parent = parent;
- return entry;
- });
-};
-
-
-/**
- * @return {!goog.testing.fs.Entry} A shallow copy of this entry object.
- */
-goog.testing.fs.Entry.prototype.clone = goog.abstractMethod;
-
-
-/**
- * @see {goog.fs.Entry#toUrl}
- * @return {string}
- */
-goog.testing.fs.Entry.prototype.toUrl = function(opt_mimetype) {
- return 'fakefilesystem:' + this.getFullPath();
-};
-
-
-/**
- * @see {goog.fs.Entry#remove}
- * @return {!goog.async.Deferred}
- */
-goog.testing.fs.Entry.prototype.remove = function() {
- var msg = 'removing ' + this.getFullPath();
- return this.checkNotDeleted(msg).addCallback(function() {
- delete this.parent.children[this.getName()];
- this.parent.lastModifiedTimestamp_ = goog.now();
- this.deleted = true;
- return;
- });
-};
-
-
-/**
- * @see {goog.fs.Entry#getParent}
- * @return {!goog.async.Deferred}
- */
-goog.testing.fs.Entry.prototype.getParent = function() {
- var msg = 'getting parent of ' + this.getFullPath();
- return this.checkNotDeleted(msg).
- addCallback(function() { return this.parent; });
-};
-
-
-/**
- * Return a deferred that will call its errback if this entry has been deleted.
- * In addition, the deferred will only run after a timeout of 0, and all its
- * callbacks will run with the entry as "this".
- *
- * @param {string} action The name of the action being performed. For error
- * reporting.
- * @return {!goog.async.Deferred} The deferred that will be called after a
- * timeout of 0.
- * @protected
- */
-goog.testing.fs.Entry.prototype.checkNotDeleted = function(action) {
- var d = new goog.async.Deferred(undefined, this);
- goog.Timer.callOnce(function() {
- if (this.deleted) {
- d.errback(new goog.fs.Error(goog.fs.Error.ErrorCode.NOT_FOUND, action));
- } else {
- d.callback();
- }
- }, 0, this);
- return d;
-};
-
-
-
-/**
- * A mock directory entry object.
- *
- * @param {!goog.testing.fs.FileSystem} fs The filesystem containing this entry.
- * @param {goog.testing.fs.DirectoryEntry} parent The directory entry directly
- * containing this entry. If this is null, that means this is the root
- * directory and so is its own parent.
- * @param {string} name The name of this entry.
- * @param {!Object.<!goog.testing.fs.Entry>} children The map of child names to
- * entry objects.
- * @constructor
- * @extends {goog.testing.fs.Entry}
- */
-goog.testing.fs.DirectoryEntry = function(fs, parent, name, children) {
- goog.base(this, fs, parent || this, name);
-
- /**
- * The map of child names to entry objects.
- * @type {!Object.<!goog.testing.fs.Entry>}
- */
- this.children = children;
-
- /**
- * The modification time of the directory. Measured using goog.now, which may
- * be overridden with mock time providers.
- * @type {number}
- * @private
- */
- this.lastModifiedTimestamp_ = goog.now();
-};
-goog.inherits(goog.testing.fs.DirectoryEntry, goog.testing.fs.Entry);
-
-
-/** @override */
-goog.testing.fs.DirectoryEntry.prototype.isFile = function() {
- return false;
-};
-
-
-/** @override */
-goog.testing.fs.DirectoryEntry.prototype.isDirectory = function() {
- return true;
-};
-
-
-/** @override */
-goog.testing.fs.DirectoryEntry.prototype.getLastModified = function() {
- var msg = 'reading last modified date for ' + this.getFullPath();
- return this.checkNotDeleted(msg).
- addCallback(function() {return new Date(this.lastModifiedTimestamp_)});
-};
-
-
-/** @override */
-goog.testing.fs.DirectoryEntry.prototype.clone = function() {
- return new goog.testing.fs.DirectoryEntry(
- this.getFileSystem(), this.parent, this.getName(), this.children);
-};
-
-
-/** @override */
-goog.testing.fs.DirectoryEntry.prototype.remove = function() {
- if (!goog.object.isEmpty(this.children)) {
- var d = new goog.async.Deferred();
- goog.Timer.callOnce(function() {
- d.errback(new goog.fs.Error(
- goog.fs.Error.ErrorCode.INVALID_MODIFICATION,
- 'removing ' + this.getFullPath()));
- }, 0, this);
- return d;
- } else {
- return goog.base(this, 'remove');
- }
-};
-
-
-/**
- * @see {goog.fs.DirectoryEntry#getFile}
- * @param {string} path
- * @param {goog.fs.DirectoryEntry.Behavior=} opt_behavior
- * @return {!goog.async.Deferred}
- */
-goog.testing.fs.DirectoryEntry.prototype.getFile = function(
- path, opt_behavior) {
- var msg = 'loading file ' + path + ' from ' + this.getFullPath();
- opt_behavior = opt_behavior || goog.fs.DirectoryEntry.Behavior.DEFAULT;
- return this.checkNotDeleted(msg).addCallback(function() {
- try {
- return goog.async.Deferred.succeed(this.getFileSync(path, opt_behavior));
- } catch (e) {
- return goog.async.Deferred.fail(e);
- }
- });
-};
-
-
-/**
- * @see {goog.fs.DirectoryEntry#getDirectory}
- * @param {string} path
- * @param {goog.fs.DirectoryEntry.Behavior=} opt_behavior
- * @return {!goog.async.Deferred}
- */
-goog.testing.fs.DirectoryEntry.prototype.getDirectory = function(
- path, opt_behavior) {
- var msg = 'loading directory ' + path + ' from ' + this.getFullPath();
- opt_behavior = opt_behavior || goog.fs.DirectoryEntry.Behavior.DEFAULT;
- return this.checkNotDeleted(msg).addCallback(function() {
- try {
- return goog.async.Deferred.succeed(
- this.getDirectorySync(path, opt_behavior));
- } catch (e) {
- return goog.async.Deferred.fail(e);
- }
- });
-};
-
-
-/**
- * Get a file entry synchronously, without waiting for a Deferred to resolve.
- *
- * @param {string} path The path to the file, relative to this directory.
- * @param {goog.fs.DirectoryEntry.Behavior=} opt_behavior The behavior for
- * loading the file.
- * @return {!goog.testing.fs.FileEntry} The loaded file.
- */
-goog.testing.fs.DirectoryEntry.prototype.getFileSync = function(
- path, opt_behavior) {
- opt_behavior = opt_behavior || goog.fs.DirectoryEntry.Behavior.DEFAULT;
- return (/** @type {!goog.testing.fs.FileEntry} */ (this.getEntry_(
- path, opt_behavior, true /* isFile */,
- goog.bind(function(parent, name) {
- return new goog.testing.fs.FileEntry(
- this.getFileSystem(), parent, name, '');
- }, this))));
-};
-
-
-/**
- * Creates a file synchronously. This is a shorthand for getFileSync, useful for
- * setting up tests.
- *
- * @param {string} path The path to the file, relative to this directory.
- * @return {!goog.testing.fs.FileEntry} The created file.
- */
-goog.testing.fs.DirectoryEntry.prototype.createFileSync = function(path) {
- return this.getFileSync(path, goog.fs.DirectoryEntry.Behavior.CREATE);
-};
-
-
-/**
- * Get a directory synchronously, without waiting for a Deferred to resolve.
- *
- * @param {string} path The path to the directory, relative to this one.
- * @param {goog.fs.DirectoryEntry.Behavior=} opt_behavior The behavior for
- * loading the directory.
- * @return {!goog.testing.fs.DirectoryEntry} The loaded directory.
- */
-goog.testing.fs.DirectoryEntry.prototype.getDirectorySync = function(
- path, opt_behavior) {
- opt_behavior = opt_behavior || goog.fs.DirectoryEntry.Behavior.DEFAULT;
- return (/** @type {!goog.testing.fs.DirectoryEntry} */ (this.getEntry_(
- path, opt_behavior, false /* isFile */,
- goog.bind(function(parent, name) {
- return new goog.testing.fs.DirectoryEntry(
- this.getFileSystem(), parent, name, {});
- }, this))));
-};
-
-
-/**
- * Creates a directory synchronously. This is a shorthand for getFileSync,
- * useful for setting up tests.
- *
- * @param {string} path The path to the directory, relative to this directory.
- * @return {!goog.testing.fs.DirectoryEntry} The created directory.
- */
-goog.testing.fs.DirectoryEntry.prototype.createDirectorySync = function(path) {
- return this.getDirectorySync(path, goog.fs.DirectoryEntry.Behavior.CREATE);
-};
-
-
-/**
- * Get a file or directory entry from a path. This handles parsing the path for
- * subdirectories and throwing appropriate errors should something go wrong.
- *
- * @param {string} path The path to the entry, relative to this directory.
- * @param {goog.fs.DirectoryEntry.Behavior} behavior The behavior for loading
- * the entry.
- * @param {boolean} isFile Whether a file or directory is being loaded.
- * @param {function(!goog.testing.fs.DirectoryEntry, string) :
- * !goog.testing.fs.Entry} createFn
- * The function for creating the entry if it doesn't yet exist. This is
- * passed the parent entry and the name of the new entry.
- * @return {!goog.testing.fs.Entry} The loaded entry.
- * @private
- */
-goog.testing.fs.DirectoryEntry.prototype.getEntry_ = function(
- path, behavior, isFile, createFn) {
- // Filter out leading, trailing, and duplicate slashes.
- var components = goog.array.filter(path.split('/'), goog.functions.identity);
-
- var basename = /** @type {string} */ (goog.array.peek(components)) || '';
- var dir = goog.string.startsWith(path, '/') ?
- this.getFileSystem().getRoot() : this;
-
- goog.array.forEach(components.slice(0, -1), function(p) {
- var subdir = dir.children[p];
- if (!subdir) {
- throw new goog.fs.Error(
- goog.fs.Error.ErrorCode.NOT_FOUND,
- 'loading ' + path + ' from ' + this.getFullPath() + ' (directory ' +
- dir.getFullPath() + '/' + p + ')');
- }
- dir = subdir;
- }, this);
-
- // If there is no basename, the path must resolve to the root directory.
- var entry = basename ? dir.children[basename] : dir;
-
- if (!entry) {
- if (behavior == goog.fs.DirectoryEntry.Behavior.DEFAULT) {
- throw new goog.fs.Error(
- goog.fs.Error.ErrorCode.NOT_FOUND,
- 'loading ' + path + ' from ' + this.getFullPath());
- } else {
- goog.asserts.assert(
- behavior == goog.fs.DirectoryEntry.Behavior.CREATE ||
- behavior == goog.fs.DirectoryEntry.Behavior.CREATE_EXCLUSIVE);
- entry = createFn(dir, basename);
- dir.children[basename] = entry;
- this.lastModifiedTimestamp_ = goog.now();
- return entry;
- }
- } else if (behavior == goog.fs.DirectoryEntry.Behavior.CREATE_EXCLUSIVE) {
- throw new goog.fs.Error(
- goog.fs.Error.ErrorCode.PATH_EXISTS,
- 'loading ' + path + ' from ' + this.getFullPath());
- } else if (entry.isFile() != isFile) {
- throw new goog.fs.Error(
- goog.fs.Error.ErrorCode.TYPE_MISMATCH,
- 'loading ' + path + ' from ' + this.getFullPath());
- } else {
- if (behavior == goog.fs.DirectoryEntry.Behavior.CREATE) {
- this.lastModifiedTimestamp_ = goog.now();
- }
- return entry;
- }
-};
-
-
-/**
- * Returns whether this directory has a child with the given name.
- *
- * @param {string} name The name of the entry to check for.
- * @return {boolean} Whether or not this has a child with the given name.
- */
-goog.testing.fs.DirectoryEntry.prototype.hasChild = function(name) {
- return name in this.children;
-};
-
-
-/**
- * @see {goog.fs.DirectoryEntry.removeRecursively}
- * @return {!goog.async.Deferred}
- */
-goog.testing.fs.DirectoryEntry.prototype.removeRecursively = function() {
- var msg = 'removing ' + this.getFullPath() + ' recursively';
- return this.checkNotDeleted(msg).addCallback(function() {
- var d = goog.async.Deferred.succeed(null);
- goog.object.forEach(this.children, function(child) {
- d.awaitDeferred(
- child.isDirectory() ? child.removeRecursively() : child.remove());
- });
- d.addCallback(function() { return this.remove(); }, this);
- return d;
- });
-};
-
-
-/**
- * @see {goog.fs.DirectoryEntry#listDirectory}
- * @return {!goog.async.Deferred}
- */
-goog.testing.fs.DirectoryEntry.prototype.listDirectory = function() {
- var msg = 'listing ' + this.getFullPath();
- return this.checkNotDeleted(msg).addCallback(function() {
- return goog.object.getValues(this.children);
- });
-};
-
-
-/**
- * @see {goog.fs.DirectoryEntry#createPath}
- * @return {!goog.async.Deferred}
- */
-goog.testing.fs.DirectoryEntry.prototype.createPath =
- goog.fs.DirectoryEntry.prototype.createPath;
-
-
-
-/**
- * A mock file entry object.
- *
- * @param {!goog.testing.fs.FileSystem} fs The filesystem containing this entry.
- * @param {!goog.testing.fs.DirectoryEntry} parent The directory entry directly
- * containing this entry.
- * @param {string} name The name of this entry.
- * @param {string} data The data initially contained in the file.
- * @constructor
- * @extends {goog.testing.fs.Entry}
- */
-goog.testing.fs.FileEntry = function(fs, parent, name, data) {
- goog.base(this, fs, parent, name);
-
- /**
- * The internal file blob referenced by this file entry.
- * @type {!goog.testing.fs.File}
- * @private
- */
- this.file_ = new goog.testing.fs.File(name, new Date(goog.now()), data);
-};
-goog.inherits(goog.testing.fs.FileEntry, goog.testing.fs.Entry);
-
-
-/** @override */
-goog.testing.fs.FileEntry.prototype.isFile = function() {
- return true;
-};
-
-
-/** @override */
-goog.testing.fs.FileEntry.prototype.isDirectory = function() {
- return false;
-};
-
-
-/** @override */
-goog.testing.fs.FileEntry.prototype.clone = function() {
- return new goog.testing.fs.FileEntry(
- this.getFileSystem(), this.parent,
- this.getName(), this.fileSync().toString());
-};
-
-
-/** @override */
-goog.testing.fs.FileEntry.prototype.getLastModified = function() {
- return this.file().addCallback(function(file) {
- return file.lastModifiedDate;
- });
-};
-
-
-/**
- * @see {goog.fs.FileEntry#createWriter}
- * @return {!goog.async.Deferred}
- */
-goog.testing.fs.FileEntry.prototype.createWriter = function() {
- var d = new goog.async.Deferred();
- goog.Timer.callOnce(
- goog.bind(d.callback, d, new goog.testing.fs.FileWriter(this)));
- return d;
-};
-
-
-/**
- * @see {goog.fs.FileEntry#file}
- * @return {!goog.async.Deferred}
- */
-goog.testing.fs.FileEntry.prototype.file = function() {
- var msg = 'getting file for ' + this.getFullPath();
- return this.checkNotDeleted(msg).addCallback(function() {
- return this.fileSync();
- });
-};
-
-
-/**
- * Get the internal file representation synchronously, without waiting for a
- * Deferred to resolve.
- *
- * @return {!goog.testing.fs.File} The internal file blob referenced by this
- * FileEntry.
- */
-goog.testing.fs.FileEntry.prototype.fileSync = function() {
- return this.file_;
-};
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/text-base/entry_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/text-base/entry_test.html.svn-base
deleted file mode 100644
index 09f2fac..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/text-base/entry_test.html.svn-base
+++ /dev/null
@@ -1,203 +0,0 @@
-<!DOCTYPE html>
-<html>
-<!--
-Copyright 2011 The Closure Library Authors. All Rights Reserved.
-
-Use of this source code is governed by the Apache License, Version 2.0.
-See the COPYING file for details.
--->
-<!--
--->
-<head>
-<title>Closure Unit Tests - goog.testing.fs.Entry</title>
-<script src="../../base.js"></script>
-<script>
-goog.require('goog.fs.DirectoryEntry.Behavior');
-goog.require('goog.fs.Error.ErrorCode');
-goog.require('goog.testing.AsyncTestCase');
-goog.require('goog.testing.MockClock');
-goog.require('goog.testing.fs.FileSystem');
-goog.require('goog.testing.jsunit');
-</script>
-</head>
-<body>
-<script>
-
-var asyncTestCase = goog.testing.AsyncTestCase.createAndInstall();
-var fs, file, mockClock;
-
-function setUp() {
- mockClock = new goog.testing.MockClock(true);
-
- fs = new goog.testing.fs.FileSystem();
- file = fs.getRoot().
- getDirectorySync('foo', goog.fs.DirectoryEntry.Behavior.CREATE).
- getFileSync('bar', goog.fs.DirectoryEntry.Behavior.CREATE);
-}
-
-function tearDown() {
- mockClock.uninstall();
-}
-
-function testGetName() {
- assertEquals('bar', file.getName());
-}
-
-function testGetFullPath() {
- assertEquals('/foo/bar', file.getFullPath());
- assertEquals('/', fs.getRoot().getFullPath());
-}
-
-function testGetFileSystem() {
- assertEquals(fs, file.getFileSystem());
-}
-
-function testMoveTo() {
- file.moveTo(fs.getRoot()).addCallback(function(newFile) {
- assertTrue(file.deleted);
- assertFalse(newFile.deleted);
- assertEquals('/bar', newFile.getFullPath());
- assertEquals(fs.getRoot(), newFile.parent);
- assertEquals(newFile, fs.getRoot().getFileSync('bar'));
- assertFalse(fs.getRoot().getDirectorySync('foo').hasChild('bar'));
-
- asyncTestCase.continueTesting();
- });
- waitForAsync('waiting for file move');
-}
-
-function testMoveToNewName() {
- // Advance the clock to an arbitrary, known time.
- mockClock.tick(71);
- file.moveTo(fs.getRoot(), 'baz').
- addCallback(function(newFile) {
- mockClock.tick();
- assertTrue(file.deleted);
- assertFalse(newFile.deleted);
- assertEquals('/baz', newFile.getFullPath());
- assertEquals(fs.getRoot(), newFile.parent);
- assertEquals(newFile, fs.getRoot().getFileSync('baz'));
-
- var oldParentDir = fs.getRoot().getDirectorySync('foo');
- assertFalse(oldParentDir.hasChild('bar'));
- assertFalse(oldParentDir.hasChild('baz'));
-
- return oldParentDir.getLastModified();
- }).
- addCallback(function(lastModifiedDate) {
- assertEquals(71, lastModifiedDate.getTime());
- return fs.getRoot().getLastModified();
- }).
- addCallback(function(rootLastModifiedDate) {
- assertEquals(71, rootLastModifiedDate.getTime());
- asyncTestCase.continueTesting();
- });
- waitForAsync('waiting for file move');
-}
-
-function testMoveDeletedFile() {
- assertFailsWhenDeleted(function() { return file.moveTo(fs.getRoot()); });
-}
-
-function testCopyTo() {
- mockClock.tick(61);
- file.copyTo(fs.getRoot()).
- addCallback(function(newFile) {
- assertFalse(file.deleted);
- assertFalse(newFile.deleted);
- assertEquals('/bar', newFile.getFullPath());
- assertEquals(fs.getRoot(), newFile.parent);
- assertEquals(newFile, fs.getRoot().getFileSync('bar'));
-
- var oldParentDir = fs.getRoot().getDirectorySync('foo');
- assertEquals(file, oldParentDir.getFileSync('bar'));
- return oldParentDir.getLastModified();
- }).
- addCallback(function(lastModifiedDate) {
- assertEquals('The original parent directory was not modified.',
- 0, lastModifiedDate.getTime());
- return fs.getRoot().getLastModified();
- }).
- addCallback(function(rootLastModifiedDate) {
- assertEquals(61, rootLastModifiedDate.getTime());
- asyncTestCase.continueTesting();
- });
- waitForAsync('waiting for file copy');
-}
-
-function testCopyToNewName() {
- file.copyTo(fs.getRoot(), 'baz').addCallback(function(newFile) {
- assertFalse(file.deleted);
- assertFalse(newFile.deleted);
- assertEquals('/baz', newFile.getFullPath());
- assertEquals(fs.getRoot(), newFile.parent);
- assertEquals(newFile, fs.getRoot().getFileSync('baz'));
- assertEquals(file, fs.getRoot().getDirectorySync('foo').getFileSync('bar'));
- assertFalse(fs.getRoot().getDirectorySync('foo').hasChild('baz'));
-
- asyncTestCase.continueTesting();
- });
- waitForAsync('waiting for file copy');
-}
-
-function testCopyDeletedFile() {
- assertFailsWhenDeleted(function() { return file.copyTo(fs.getRoot()); });
-}
-
-function testRemove() {
- mockClock.tick(57);
- file.remove().
- addCallback(function() {
- mockClock.tick();
- var parentDir = fs.getRoot().getDirectorySync('foo');
-
- assertTrue(file.deleted);
- assertFalse(parentDir.hasChild('bar'));
-
- return parentDir.getLastModified();
- }).
- addCallback(function(date) {
- assertEquals(57, date.getTime());
- asyncTestCase.continueTesting();
- });
- waitForAsync('waiting for file removal');
-}
-
-function testRemoveDeletedFile() {
- assertFailsWhenDeleted(function() { return file.remove(); });
-}
-
-function testGetParent() {
- file.getParent().addCallback(function(p) {
- assertEquals(file.parent, p);
- assertEquals(fs.getRoot().getDirectorySync('foo'), p);
- assertEquals('/foo', p.getFullPath());
-
- asyncTestCase.continueTesting();
- });
- waitForAsync('waiting for file parent');
-}
-
-function testGetDeletedFileParent() {
- assertFailsWhenDeleted(function() { return file.getParent(); });
-}
-
-
-function assertFailsWhenDeleted(fn) {
- file.remove().addCallback(fn).
- addCallback(function() { fail('Expected an error'); }).
- addErrback(function(err) {
- assertEquals(goog.fs.Error.ErrorCode.NOT_FOUND, err.code);
- asyncTestCase.continueTesting();
- });
- waitForAsync('waiting for file operation');
-}
-
-function waitForAsync(msg) {
- asyncTestCase.waitForAsync(msg);
- mockClock.tick();
-}
-
-</script>
-</body>
-</html>
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/text-base/file.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/text-base/file.js.svn-base
deleted file mode 100644
index da3b3a1..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/text-base/file.js.svn-base
+++ /dev/null
@@ -1,52 +0,0 @@
-// Copyright 2011 The Closure Library Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS-IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/**
- * @fileoverview Mock file object.
- *
- */
-
-goog.provide('goog.testing.fs.File');
-
-goog.require('goog.testing.fs.Blob');
-
-
-
-/**
- * A mock file object.
- *
- * @param {string} name The name of the file.
- * @param {Date=} opt_lastModified The last modified date for this file. May be
- * null if file modification dates are not supported.
- * @param {string=} opt_data The string data encapsulated by the blob.
- * @param {string=} opt_type The mime type of the blob.
- * @constructor
- * @extends {goog.testing.fs.Blob}
- */
-goog.testing.fs.File = function(name, opt_lastModified, opt_data, opt_type) {
- goog.base(this, opt_data, opt_type);
-
- /**
- * @see http://www.w3.org/TR/FileAPI/#dfn-name
- * @type {string}
- */
- this.name = name;
-
- /**
- * @see http://www.w3.org/TR/FileAPI/#dfn-lastModifiedDate
- * @type {Date}
- */
- this.lastModifiedDate = opt_lastModified || null;
-};
-goog.inherits(goog.testing.fs.File, goog.testing.fs.Blob);
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/text-base/fileentry_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/text-base/fileentry_test.html.svn-base
deleted file mode 100644
index ee4c76d..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/text-base/fileentry_test.html.svn-base
+++ /dev/null
@@ -1,80 +0,0 @@
-<!DOCTYPE html>
-<html>
-<!--
-Copyright 2011 The Closure Library Authors. All Rights Reserved.
-
-Use of this source code is governed by the Apache License, Version 2.0.
-See the COPYING file for details.
--->
-<!--
--->
-<head>
-<title>Closure Unit Tests - goog.testing.fs.FileEntry</title>
-<script src="../../base.js"></script>
-<script>
-goog.require('goog.fs.DirectoryEntry.Behavior');
-goog.require('goog.testing.AsyncTestCase');
-goog.require('goog.testing.MockClock');
-goog.require('goog.testing.fs.FileSystem');
-goog.require('goog.testing.jsunit');
-</script>
-</head>
-<body>
-<script>
-
-var asyncTestCase = goog.testing.AsyncTestCase.createAndInstall();
-var fs, file, fileEntry, mockClock, currentTime;
-
-function setUp() {
- mockClock = new goog.testing.MockClock(true);
-
- fs = new goog.testing.fs.FileSystem();
- fileEntry = fs.getRoot().createDirectorySync('foo').createFileSync('bar');
-}
-
-function tearDown() {
- mockClock.uninstall();
-}
-
-function testIsFile() {
- assertTrue(fileEntry.isFile());
-}
-
-function testIsDirectory() {
- assertFalse(fileEntry.isDirectory());
-}
-
-function testFile() {
- var testFile = new goog.testing.fs.FileEntry(fs, fs.getRoot(),
- 'test', 'hello world');
- testFile.file().addCallback(function(f) {
- assertEquals('test', f.name);
- assertEquals('hello world', f.toString());
-
- asyncTestCase.continueTesting();
- });
- waitForAsync('testFile');
-}
-
-function testGetLastModified() {
- // Advance the clock to a known time.
- mockClock.tick(53);
- var testFile = new goog.testing.fs.FileEntry(fs, fs.getRoot(),
- 'timeTest', 'hello world');
- mockClock.tick();
- testFile.getLastModified().addCallback(function(date) {
- assertEquals(53, date.getTime());
- asyncTestCase.continueTesting();
- });
- waitForAsync('testGetLastModified');
-}
-
-
-function waitForAsync(msg) {
- asyncTestCase.waitForAsync(msg);
- mockClock.tick();
-}
-
-</script>
-</body>
-</html>
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/text-base/filereader.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/text-base/filereader.js.svn-base
deleted file mode 100644
index 8052523..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/text-base/filereader.js.svn-base
+++ /dev/null
@@ -1,272 +0,0 @@
-// Copyright 2011 The Closure Library Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS-IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/**
- * @fileoverview Mock FileReader object.
- *
- */
-
-goog.provide('goog.testing.fs.FileReader');
-
-goog.require('goog.Timer');
-goog.require('goog.events.EventTarget');
-goog.require('goog.fs.Error');
-goog.require('goog.fs.FileReader.EventType');
-goog.require('goog.fs.FileReader.ReadyState');
-goog.require('goog.testing.fs.File');
-goog.require('goog.testing.fs.ProgressEvent');
-
-
-
-/**
- * A mock FileReader object. This emits the same events as
- * {@link goog.fs.FileReader}.
- *
- * @constructor
- * @extends {goog.events.EventTarget}
- */
-goog.testing.fs.FileReader = function() {
- goog.base(this);
-
- /**
- * The current state of the reader.
- * @type {goog.fs.FileReader.ReadyState}
- * @private
- */
- this.readyState_ = goog.fs.FileReader.ReadyState.INIT;
-};
-goog.inherits(goog.testing.fs.FileReader, goog.events.EventTarget);
-
-
-/**
- * The most recent error experienced by this reader.
- * @type {goog.fs.Error}
- * @private
- */
-goog.testing.fs.FileReader.prototype.error_;
-
-
-/**
- * Whether the current operation has been aborted.
- * @type {boolean}
- * @private
- */
-goog.testing.fs.FileReader.prototype.aborted_ = false;
-
-
-/**
- * The blob this reader is reading from.
- * @type {goog.testing.fs.Blob}
- * @private
- */
-goog.testing.fs.FileReader.prototype.blob_;
-
-
-/**
- * The possible return types.
- * @enum {number}
- */
-goog.testing.fs.FileReader.ReturnType = {
- /**
- * Used when reading as text.
- */
- TEXT: 1,
-
- /**
- * Used when reading as binary string.
- */
- BINARY_STRING: 2,
-
- /**
- * Used when reading as array buffer.
- */
- ARRAY_BUFFER: 3,
-
- /**
- * Used when reading as data URL.
- */
- DATA_URL: 4
-};
-
-
-/**
- * The return type we're reading.
- * @type {goog.testing.fs.FileReader.ReturnType}
- * @private
- */
-goog.testing.fs.FileReader.returnType_;
-
-
-/**
- * @see {goog.fs.FileReader#getReadyState}
- * @return {goog.fs.FileReader.ReadyState} The current ready state.
- */
-goog.testing.fs.FileReader.prototype.getReadyState = function() {
- return this.readyState_;
-};
-
-
-/**
- * @see {goog.fs.FileReader#getError}
- * @return {goog.fs.Error} The current error.
- */
-goog.testing.fs.FileReader.prototype.getError = function() {
- return this.error_;
-};
-
-
-/**
- * @see {goog.fs.FileReader#abort}
- */
-goog.testing.fs.FileReader.prototype.abort = function() {
- if (this.readyState_ != goog.fs.FileReader.ReadyState.LOADING) {
- var msg = 'aborting read';
- throw new goog.fs.Error(goog.fs.Error.ErrorCode.INVALID_STATE, msg);
- }
-
- this.aborted_ = true;
-};
-
-
-/**
- * @see {goog.fs.FileReader#getResult}
- * @return {*} The result of the file read.
- */
-goog.testing.fs.FileReader.prototype.getResult = function() {
- if (this.readyState_ != goog.fs.FileReader.ReadyState.DONE) {
- return undefined;
- }
- if (this.error_) {
- return undefined;
- }
- if (this.returnType_ == goog.testing.fs.FileReader.ReturnType.TEXT) {
- return this.blob_.toString();
- } else if (this.returnType_ ==
- goog.testing.fs.FileReader.ReturnType.ARRAY_BUFFER) {
- return this.blob_.toArrayBuffer();
- } else if (this.returnType_ ==
- goog.testing.fs.FileReader.ReturnType.BINARY_STRING) {
- return this.blob_.toString();
- } else if (this.returnType_ ==
- goog.testing.fs.FileReader.ReturnType.DATA_URL) {
- return this.blob_.toDataUrl();
- } else {
- return undefined;
- }
-};
-
-
-/**
- * Fires the read events.
- * @param {!goog.testing.fs.Blob} blob The blob to read from.
- * @private
- */
-goog.testing.fs.FileReader.prototype.read_ = function(blob) {
- this.blob_ = blob;
- if (this.readyState_ == goog.fs.FileReader.ReadyState.LOADING) {
- var msg = 'reading file';
- throw new goog.fs.Error(goog.fs.Error.ErrorCode.INVALID_STATE, msg);
- }
-
- this.readyState_ = goog.fs.FileReader.ReadyState.LOADING;
- goog.Timer.callOnce(function() {
- if (this.aborted_) {
- this.abort_(blob.size);
- return;
- }
-
- this.progressEvent_(goog.fs.FileReader.EventType.LOAD_START, 0, blob.size);
- this.progressEvent_(goog.fs.FileReader.EventType.LOAD, blob.size / 2,
- blob.size);
- this.progressEvent_(goog.fs.FileReader.EventType.LOAD, blob.size,
- blob.size);
- this.readyState_ = goog.fs.FileReader.ReadyState.DONE;
- this.progressEvent_(goog.fs.FileReader.EventType.LOAD, blob.size,
- blob.size);
- this.progressEvent_(goog.fs.FileReader.EventType.LOAD_END, blob.size,
- blob.size);
- }, 0, this);
-};
-
-
-/**
- * @see {goog.fs.FileReader#readAsBinaryString}
- * @param {!goog.testing.fs.Blob} blob The blob to read.
- */
-goog.testing.fs.FileReader.prototype.readAsBinaryString = function(blob) {
- this.returnType_ = goog.testing.fs.FileReader.ReturnType.BINARY_STRING;
- this.read_(blob);
-};
-
-
-/**
- * @see {goog.fs.FileReader#readAsArrayBuffer}
- * @param {!goog.testing.fs.Blob} blob The blob to read.
- */
-goog.testing.fs.FileReader.prototype.readAsArrayBuffer = function(blob) {
- this.returnType_ = goog.testing.fs.FileReader.ReturnType.ARRAY_BUFFER;
- this.read_(blob);
-};
-
-
-/**
- * @see {goog.fs.FileReader#readAsText}
- * @param {!goog.testing.fs.Blob} blob The blob to read.
- * @param {string=} opt_encoding The name of the encoding to use.
- */
-goog.testing.fs.FileReader.prototype.readAsText = function(blob, opt_encoding) {
- this.returnType_ = goog.testing.fs.FileReader.ReturnType.TEXT;
- this.read_(blob);
-};
-
-
-/**
- * @see {goog.fs.FileReader#readAsDataUrl}
- * @param {!goog.testing.fs.Blob} blob The blob to read.
- */
-goog.testing.fs.FileReader.prototype.readAsDataUrl = function(blob) {
- this.returnType_ = goog.testing.fs.FileReader.ReturnType.DATA_URL;
- this.read_(blob);
-};
-
-
-/**
- * Abort the current action and emit appropriate events.
- *
- * @param {number} total The total data that was to be processed, in bytes.
- * @private
- */
-goog.testing.fs.FileReader.prototype.abort_ = function(total) {
- this.error_ = new goog.fs.Error(
- goog.fs.Error.ErrorCode.ABORT, 'reading file');
- this.progressEvent_(goog.fs.FileReader.EventType.ERROR, 0, total);
- this.progressEvent_(goog.fs.FileReader.EventType.ABORT, 0, total);
- this.readyState_ = goog.fs.FileReader.ReadyState.DONE;
- this.progressEvent_(goog.fs.FileReader.EventType.LOAD_END, 0, total);
- this.aborted_ = false;
-};
-
-
-/**
- * Dispatch a progress event.
- *
- * @param {goog.fs.FileReader.EventType} type The event type.
- * @param {number} loaded The number of bytes processed.
- * @param {number} total The total data that was to be processed, in bytes.
- * @private
- */
-goog.testing.fs.FileReader.prototype.progressEvent_ = function(type, loaded,
- total) {
- this.dispatchEvent(new goog.testing.fs.ProgressEvent(type, loaded, total));
-};
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/text-base/filereader_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/text-base/filereader_test.html.svn-base
deleted file mode 100644
index d58e652..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/text-base/filereader_test.html.svn-base
+++ /dev/null
@@ -1,236 +0,0 @@
-<!DOCTYPE html>
-<html>
-<!--
-Copyright 2011 The Closure Library Authors. All Rights Reserved.
-
-Use of this source code is governed by the Apache License, Version 2.0.
-See the COPYING file for details.
--->
-<!--
--->
-<head>
-<title>Closure Unit Tests - goog.testing.fs.FileReader</title>
-<script type="text/javascript" src="../../base.js"></script>
-<script type="text/javascript">
-goog.require('goog.fs.DirectoryEntry.Behavior');
-goog.require('goog.fs.FileReader.EventType');
-goog.require('goog.testing.AsyncTestCase');
-goog.require('goog.testing.fs.FileReader');
-goog.require('goog.testing.fs.FileSystem');
-goog.require('goog.testing.fs.Blob');
-goog.require('goog.testing.jsunit');
-</script>
-</head>
-<body>
-<script type="text/javascript">
-
-var asyncTestCase = goog.testing.AsyncTestCase.createAndInstall();
-var file, deferredReader;
-var hasArrayBuffer = goog.isDef(goog.global.ArrayBuffer);
-
-function setUp() {
- var fs = new goog.testing.fs.FileSystem();
- var fileEntry = fs.getRoot().createDirectorySync('foo').createFileSync('bar');
- file = fileEntry.fileSync();
- file.setDataInternal('test content');
-
- deferredReader = new goog.async.Deferred();
- goog.Timer.callOnce(
- goog.bind(deferredReader.callback, deferredReader,
- new goog.testing.fs.FileReader()));
-}
-
-function testRead() {
- deferredReader.
- addCallback(goog.partial(checkReadyState,
- goog.fs.FileReader.ReadyState.INIT)).
- addCallback(goog.partial(checkResult, undefined)).
- addCallback(goog.partial(readAsText)).
- addCallback(goog.partial(checkReadyState,
- goog.fs.FileReader.ReadyState.LOADING)).
- addCallback(goog.partial(checkResult, undefined)).
- addCallback(goog.partial(waitForEvent,
- goog.fs.FileReader.EventType.LOAD_START)).
- addCallback(goog.partial(checkResult, undefined)).
- addCallback(goog.partial(waitForEvent,
- goog.fs.FileReader.EventType.LOAD)).
- addCallback(goog.partial(checkResult, undefined)).
- addCallback(goog.partial(waitForEvent,
- goog.fs.FileReader.EventType.LOAD_END)).
- addCallback(goog.partial(checkResult, file.toString())).
- addCallback(goog.partial(checkReadyState,
- goog.fs.FileReader.ReadyState.DONE)).
- addBoth(continueTesting);
- waitForAsync('testRead');
-}
-
-function testReadAsArrayBuffer() {
- if (!hasArrayBuffer) {
- // Skip if array buffer is not supported
- return;
- }
- deferredReader.
- addCallback(goog.partial(checkReadyState,
- goog.fs.FileReader.ReadyState.INIT)).
- addCallback(goog.partial(checkResult, undefined)).
- addCallback(goog.partial(readAsArrayBuffer)).
- addCallback(goog.partial(checkReadyState,
- goog.fs.FileReader.ReadyState.LOADING)).
- addCallback(goog.partial(checkResult, undefined)).
- addCallback(goog.partial(waitForEvent,
- goog.fs.FileReader.EventType.LOAD_START)).
- addCallback(goog.partial(checkResult, undefined)).
- addCallback(goog.partial(waitForEvent,
- goog.fs.FileReader.EventType.LOAD)).
- addCallback(goog.partial(checkResult, undefined)).
- addCallback(goog.partial(waitForEvent,
- goog.fs.FileReader.EventType.LOAD_END)).
- addCallback(goog.partial(checkResult, file.toArrayBuffer())).
- addCallback(goog.partial(checkReadyState,
- goog.fs.FileReader.ReadyState.DONE)).
- addBoth(continueTesting);
- waitForAsync('testReadAsArrayBuffer');
-}
-
-function testReadAsDataUrl() {
- deferredReader.
- addCallback(goog.partial(checkReadyState,
- goog.fs.FileReader.ReadyState.INIT)).
- addCallback(goog.partial(checkResult, undefined)).
- addCallback(goog.partial(readAsDataUrl)).
- addCallback(goog.partial(checkReadyState,
- goog.fs.FileReader.ReadyState.LOADING)).
- addCallback(goog.partial(checkResult, undefined)).
- addCallback(goog.partial(waitForEvent,
- goog.fs.FileReader.EventType.LOAD_START)).
- addCallback(goog.partial(checkResult, undefined)).
- addCallback(goog.partial(waitForEvent,
- goog.fs.FileReader.EventType.LOAD)).
- addCallback(goog.partial(checkResult, undefined)).
- addCallback(goog.partial(waitForEvent,
- goog.fs.FileReader.EventType.LOAD_END)).
- addCallback(goog.partial(checkResult, file.toDataUrl())).
- addCallback(goog.partial(checkReadyState,
- goog.fs.FileReader.ReadyState.DONE)).
- addBoth(continueTesting);
- waitForAsync('testReadAsDataUrl');
-}
-
-function testAbort() {
- deferredReader.
- addCallback(goog.partial(readAsText)).
- addCallback(function(reader) { reader.abort(); }).
- addCallback(goog.partial(checkReadyState,
- goog.fs.FileReader.ReadyState.LOADING)).
- addCallback(goog.partial(waitForError, goog.fs.Error.ErrorCode.ABORT)).
- addCallback(goog.partial(checkReadyState,
- goog.fs.FileReader.ReadyState.LOADING)).
- addCallback(goog.partial(waitForEvent,
- goog.fs.FileReader.EventType.ABORT)).
- addCallback(goog.partial(checkReadyState,
- goog.fs.FileReader.ReadyState.LOADING)).
- addCallback(goog.partial(waitForEvent,
- goog.fs.FileReader.EventType.LOAD_END)).
- addCallback(goog.partial(checkReadyState,
- goog.fs.FileReader.ReadyState.DONE)).
- addCallback(goog.partial(checkResult, undefined)).
- addBoth(continueTesting);
- waitForAsync('testAbort');
-}
-
-function testAbortBeforeRead() {
- deferredReader.
- addCallback(function(reader) { reader.abort(); }).
- addErrback(function(err) {
- assertEquals(goog.fs.Error.ErrorCode.INVALID_STATE, err.code);
- return true;
- }).
- addCallback(function(calledErrback) {
- assertTrue(calledErrback);
- }).
- addBoth(continueTesting);
- waitForAsync('testAbortBeforeRead');
-}
-
-function testReadDuringRead() {
- deferredReader.
- addCallback(goog.partial(readAsText)).
- addCallback(goog.partial(readAsText)).
- addErrback(function(err) {
- assertEquals(goog.fs.Error.ErrorCode.INVALID_STATE, err.code);
- return true;
- }).
- addCallback(assertTrue).
- addBoth(continueTesting);
- waitForAsync('testReadDuringRead');
-}
-
-function continueTesting(result) {
- asyncTestCase.continueTesting();
- if (result instanceof Error) {
- throw result;
- }
-}
-
-function waitForAsync(msg) {
- asyncTestCase.waitForAsync(msg);
-}
-
-function waitForEvent(type, target) {
- var d = new goog.async.Deferred();
- goog.events.listenOnce(target, type, goog.bind(d.callback, d, target));
- return d;
-}
-
-function waitForError(type, target) {
- var d = new goog.async.Deferred();
- goog.events.listenOnce(
- target, goog.fs.FileReader.EventType.ERROR, function(e) {
- assertEquals(type, target.getError().code);
- d.callback(target);
- });
- return d;
-}
-
-function readAsText(reader) {
- reader.readAsText(file);
-}
-
-function readAsArrayBuffer(reader) {
- reader.readAsArrayBuffer(file);
-}
-
-function readAsDataUrl(reader) {
- reader.readAsDataUrl(file);
-}
-
-function readAndWait(reader) {
- readAsText(reader);
- return waitForEvent(goog.fs.FileSaver.EventType.LOAD_END, reader);
-}
-
-function checkResult(expectedResult, reader) {
- checkEquals(expectedResult, reader.getResult());
-}
-
-function checkEquals(a, b) {
- if (hasArrayBuffer &&
- a instanceof ArrayBuffer && b instanceof ArrayBuffer) {
- assertEquals(a.byteLength, b.byteLength);
- var viewA = new Uint8Array(a);
- var viewB = new Uint8Array(b);
- for (var i = 0; i < a.byteLength; i++) {
- assertEquals(viewA[i], viewB[i]);
- }
- } else {
- assertEquals(a, b);
- }
-}
-
-function checkReadyState(expectedState, reader) {
- assertEquals(expectedState, reader.getReadyState());
-}
-
-</script>
-</body>
-</html>
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/text-base/filesystem.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/text-base/filesystem.js.svn-base
deleted file mode 100644
index 9e4c915..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/text-base/filesystem.js.svn-base
+++ /dev/null
@@ -1,64 +0,0 @@
-// Copyright 2011 The Closure Library Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS-IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/**
- * @fileoverview Mock filesystem object.
- *
- */
-
-goog.provide('goog.testing.fs.FileSystem');
-
-goog.require('goog.testing.fs.DirectoryEntry');
-
-
-
-/**
- * A mock filesystem object.
- *
- * @param {string=} opt_name The name of the filesystem.
- * @constructor
- */
-goog.testing.fs.FileSystem = function(opt_name) {
- /**
- * The name of the filesystem.
- * @type {string}
- * @private
- */
- this.name_ = opt_name || 'goog.testing.fs.FileSystem';
-
- /**
- * The root entry of the filesystem.
- * @type {!goog.testing.fs.DirectoryEntry}
- * @private
- */
- this.root_ = new goog.testing.fs.DirectoryEntry(this, null, '', {});
-};
-
-
-/**
- * @see {goog.fs.FileSystem#getName}
- * @return {string}
- */
-goog.testing.fs.FileSystem.prototype.getName = function() {
- return this.name_;
-};
-
-
-/**
- * @see {goog.fs.FileSystem#getRoot}
- * @return {!goog.testing.fs.DirectoryEntry}
- */
-goog.testing.fs.FileSystem.prototype.getRoot = function() {
- return this.root_;
-};
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/text-base/filewriter.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/text-base/filewriter.js.svn-base
deleted file mode 100644
index b77690f..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/text-base/filewriter.js.svn-base
+++ /dev/null
@@ -1,261 +0,0 @@
-// Copyright 2011 The Closure Library Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS-IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/**
- * @fileoverview Mock FileWriter object.
- *
- */
-
-goog.provide('goog.testing.fs.FileWriter');
-
-goog.require('goog.Timer');
-goog.require('goog.events.Event');
-goog.require('goog.events.EventTarget');
-goog.require('goog.fs.Error');
-goog.require('goog.fs.FileSaver.EventType');
-goog.require('goog.fs.FileSaver.ReadyState');
-goog.require('goog.string');
-goog.require('goog.testing.fs.File');
-goog.require('goog.testing.fs.ProgressEvent');
-
-
-
-/**
- * A mock FileWriter object. This emits the same events as
- * {@link goog.fs.FileSaver} and {@link goog.fs.FileWriter}.
- *
- * @param {!goog.testing.fs.FileEntry} fileEntry The file entry to write to.
- * @constructor
- * @extends {goog.events.EventTarget}
- */
-goog.testing.fs.FileWriter = function(fileEntry) {
- goog.base(this);
-
- /**
- * The file entry to which to write.
- * @type {!goog.testing.fs.FileEntry}
- * @private
- */
- this.fileEntry_ = fileEntry;
-
- /**
- * The file blob to write to.
- * @type {!goog.testing.fs.File}
- * @private
- */
- this.file_ = fileEntry.fileSync();
-
- /**
- * The current state of the writer.
- * @type {goog.fs.FileSaver.ReadyState}
- * @private
- */
- this.readyState_ = goog.fs.FileSaver.ReadyState.INIT;
-};
-goog.inherits(goog.testing.fs.FileWriter, goog.events.EventTarget);
-
-
-/**
- * The most recent error experienced by this writer.
- * @type {goog.fs.Error}
- * @private
- */
-goog.testing.fs.FileWriter.prototype.error_;
-
-
-/**
- * Whether the current operation has been aborted.
- * @type {boolean}
- * @private
- */
-goog.testing.fs.FileWriter.prototype.aborted_ = false;
-
-
-/**
- * The current position in the file.
- * @type {number}
- * @private
- */
-goog.testing.fs.FileWriter.prototype.position_ = 0;
-
-
-/**
- * @see {goog.fs.FileSaver#getReadyState}
- * @return {goog.fs.FileSaver.ReadyState} The ready state.
- */
-goog.testing.fs.FileWriter.prototype.getReadyState = function() {
- return this.readyState_;
-};
-
-
-/**
- * @see {goog.fs.FileSaver#getError}
- * @return {goog.fs.Error} The error.
- */
-goog.testing.fs.FileWriter.prototype.getError = function() {
- return this.error_;
-};
-
-
-/**
- * @see {goog.fs.FileWriter#getPosition}
- * @return {number} The position.
- */
-goog.testing.fs.FileWriter.prototype.getPosition = function() {
- return this.position_;
-};
-
-
-/**
- * @see {goog.fs.FileWriter#getLength}
- * @return {number} The length.
- */
-goog.testing.fs.FileWriter.prototype.getLength = function() {
- return this.file_.size;
-};
-
-
-/**
- * @see {goog.fs.FileSaver#abort}
- */
-goog.testing.fs.FileWriter.prototype.abort = function() {
- if (this.readyState_ != goog.fs.FileSaver.ReadyState.WRITING) {
- var msg = 'aborting save of ' + this.fileEntry_.getFullPath();
- throw new goog.fs.Error(goog.fs.Error.ErrorCode.INVALID_STATE, msg);
- }
-
- this.aborted_ = true;
-};
-
-
-/**
- * @see {goog.fs.FileWriter#write}
- * @param {!goog.testing.fs.Blob} blob The blob to write.
- */
-goog.testing.fs.FileWriter.prototype.write = function(blob) {
- if (this.readyState_ == goog.fs.FileSaver.ReadyState.WRITING) {
- var msg = 'writing to ' + this.fileEntry_.getFullPath();
- throw new goog.fs.Error(goog.fs.Error.ErrorCode.INVALID_STATE, msg);
- }
-
- this.readyState_ = goog.fs.FileSaver.ReadyState.WRITING;
- goog.Timer.callOnce(function() {
- if (this.aborted_) {
- this.abort_(blob.size);
- return;
- }
-
- this.progressEvent_(goog.fs.FileSaver.EventType.WRITE_START, 0, blob.size);
- var fileString = this.file_.toString();
- this.file_.setDataInternal(
- fileString.substring(0, this.position_) + blob.toString() +
- fileString.substring(this.position_ + blob.size, fileString.length));
- this.position_ += blob.size;
-
- this.progressEvent_(
- goog.fs.FileSaver.EventType.WRITE, blob.size, blob.size);
- this.readyState_ = goog.fs.FileSaver.ReadyState.DONE;
- this.progressEvent_(
- goog.fs.FileSaver.EventType.WRITE_END, blob.size, blob.size);
- }, 0, this);
-};
-
-
-/**
- * @see {goog.fs.FileWriter#truncate}
- * @param {number} size The size to truncate to.
- */
-goog.testing.fs.FileWriter.prototype.truncate = function(size) {
- if (this.readyState_ == goog.fs.FileSaver.ReadyState.WRITING) {
- var msg = 'truncating ' + this.fileEntry_.getFullPath();
- throw new goog.fs.Error(goog.fs.Error.ErrorCode.INVALID_STATE, msg);
- }
-
- this.readyState_ = goog.fs.FileSaver.ReadyState.WRITING;
- goog.Timer.callOnce(function() {
- if (this.aborted_) {
- this.abort_(size);
- return;
- }
-
- this.progressEvent_(goog.fs.FileSaver.EventType.WRITE_START, 0, size);
-
- var fileString = this.file_.toString();
- if (size > fileString.length) {
- this.file_.setDataInternal(
- fileString + goog.string.repeat('\0', size - fileString.length));
- } else {
- this.file_.setDataInternal(fileString.substring(0, size));
- }
- this.position_ = Math.min(this.position_, size);
-
- this.progressEvent_(goog.fs.FileSaver.EventType.WRITE, size, size);
- this.readyState_ = goog.fs.FileSaver.ReadyState.DONE;
- this.progressEvent_(goog.fs.FileSaver.EventType.WRITE_END, size, size);
- }, 0, this);
-};
-
-
-/**
- * @see {goog.fs.FileWriter#seek}
- * @param {number} offset The offset to seek to.
- */
-goog.testing.fs.FileWriter.prototype.seek = function(offset) {
- if (this.readyState_ == goog.fs.FileSaver.ReadyState.WRITING) {
- var msg = 'truncating ' + this.fileEntry_.getFullPath();
- throw new goog.fs.Error(goog.fs.Error.ErrorCode.INVALID_STATE, msg);
- }
-
- if (offset < 0) {
- this.position_ = Math.max(0, this.file_.size + offset);
- } else {
- this.position_ = Math.min(offset, this.file_.size);
- }
-};
-
-
-/**
- * Abort the current action and emit appropriate events.
- *
- * @param {number} total The total data that was to be processed, in bytes.
- * @private
- */
-goog.testing.fs.FileWriter.prototype.abort_ = function(total) {
- this.error_ = new goog.fs.Error(
- goog.fs.Error.ErrorCode.ABORT, 'saving ' + this.fileEntry_.getFullPath());
- this.progressEvent_(goog.fs.FileSaver.EventType.ERROR, 0, total);
- this.progressEvent_(goog.fs.FileSaver.EventType.ABORT, 0, total);
- this.readyState_ = goog.fs.FileSaver.ReadyState.DONE;
- this.progressEvent_(goog.fs.FileSaver.EventType.WRITE_END, 0, total);
- this.aborted_ = false;
-};
-
-
-/**
- * Dispatch a progress event.
- *
- * @param {goog.fs.FileSaver.EventType} type The type of the event.
- * @param {number} loaded The number of bytes processed.
- * @param {number} total The total data that was to be processed, in bytes.
- * @private
- */
-goog.testing.fs.FileWriter.prototype.progressEvent_ = function(
- type, loaded, total) {
- // On write, update the last modified date to the current (real or mock) time.
- if (type == goog.fs.FileSaver.EventType.WRITE) {
- this.file_.lastModifiedDate = new Date(goog.now());
- }
-
- this.dispatchEvent(new goog.testing.fs.ProgressEvent(type, loaded, total));
-};
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/text-base/filewriter_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/text-base/filewriter_test.html.svn-base
deleted file mode 100644
index 7d841b6..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/text-base/filewriter_test.html.svn-base
+++ /dev/null
@@ -1,325 +0,0 @@
-<!DOCTYPE html>
-<html>
-<!--
-Copyright 2011 The Closure Library Authors. All Rights Reserved.
-
-Use of this source code is governed by the Apache License, Version 2.0.
-See the COPYING file for details.
--->
-<!--
--->
-<head>
-<title>Closure Unit Tests - goog.testing.fs.FileWriter</title>
-<script src="../../base.js"></script>
-<script>
-goog.require('goog.fs.DirectoryEntry.Behavior');
-goog.require('goog.fs.FileSaver.EventType');
-goog.require('goog.testing.AsyncTestCase');
-goog.require('goog.testing.MockClock');
-goog.require('goog.testing.fs.FileSystem');
-goog.require('goog.testing.fs.Blob');
-goog.require('goog.testing.jsunit');
-</script>
-</head>
-<body>
-<script>
-
-var asyncTestCase = goog.testing.AsyncTestCase.createAndInstall();
-var file, deferredWriter, mockClock;
-
-function setUp() {
- mockClock = new goog.testing.MockClock(true);
-
- var fs = new goog.testing.fs.FileSystem();
- var fileEntry = fs.getRoot().createDirectorySync('foo').createFileSync('bar');
-
- deferredWriter = fileEntry.createWriter();
- file = fileEntry.fileSync();
- file.setDataInternal('');
-}
-
-function tearDown() {
- mockClock.uninstall();
-}
-
-function testWrite() {
- deferredWriter.
- addCallback(goog.partial(checkReadyState,
- goog.fs.FileSaver.ReadyState.INIT)).
- addCallback(goog.partial(checkPositionAndLength, 0, 0)).
- addCallback(goog.partial(checkLastModified, 0)).
- addCallback(goog.partial(tick, 3)).
- addCallback(goog.partial(writeString, 'hello')).
- addCallback(goog.partial(checkPositionAndLength, 0, 0)).
- addCallback(goog.partial(checkReadyState,
- goog.fs.FileSaver.ReadyState.WRITING)).
- addCallback(goog.partial(checkLastModified, 0)).
- addCallback(goog.partial(waitForEvent,
- goog.fs.FileSaver.EventType.WRITE_START)).
- addCallback(goog.partial(checkLastModified, 0)).
- addCallback(goog.partial(checkPositionAndLength, 0, 0)).
- addCallback(goog.partial(waitForEvent,
- goog.fs.FileSaver.EventType.WRITE)).
- addCallback(function() { assertEquals('hello', file.toString()); }).
- addCallback(goog.partial(checkPositionAndLength, 5, 5)).
- addCallback(goog.partial(checkLastModified, 3)).
- addCallback(tick).
- addCallback(goog.partial(checkReadyState,
- goog.fs.FileSaver.ReadyState.WRITING)).
- addCallback(goog.partial(checkLastModified, 3)).
- addCallback(goog.partial(waitForEvent,
- goog.fs.FileSaver.EventType.WRITE_END)).
- addCallback(goog.partial(checkLastModified, 3)).
- addCallback(goog.partial(checkReadyState,
- goog.fs.FileSaver.ReadyState.DONE)).
- addCallback(goog.partial(checkLastModified, 3)).
- addCallback(goog.partial(writeString, ' world')).
- addCallback(goog.partial(checkPositionAndLength, 5, 5)).
- addCallback(goog.partial(waitForEvent,
- goog.fs.FileSaver.EventType.WRITE)).
- addCallback(function() { assertEquals('hello world', file.toString()); }).
- addCallback(goog.partial(checkPositionAndLength, 11, 11)).
- addCallback(goog.partial(checkLastModified, 4)).
- addBoth(continueTesting);
- waitForAsync('testWrite');
-}
-
-function testSeek() {
- deferredWriter.
- addCallback(goog.partial(tick, 17)).
- addCallback(goog.partial(writeAndWait, 'hello world')).
- addCallback(tick).
- addCallback(goog.partial(checkPositionAndLength, 11, 11)).
-
- addCallback(function(writer) { writer.seek(6); }).
- addCallback(goog.partial(checkPositionAndLength, 6, 11)).
- addCallback(goog.partial(checkLastModified, 17)).
- addCallback(goog.partial(writeAndWait, 'universe')).
- addCallback(tick).
- addCallback(function() {
- assertEquals('hello universe', file.toString());
- }).
- addCallback(goog.partial(checkPositionAndLength, 14, 14)).
-
- addCallback(function(writer) { writer.seek(500); }).
- addCallback(goog.partial(checkPositionAndLength, 14, 14)).
- addCallback(goog.partial(writeAndWait, '!')).
- addCallback(tick).
- addCallback(function() {
- assertEquals('hello universe!',file.toString());
- }).
- addCallback(goog.partial(checkPositionAndLength, 15, 15)).
-
- addCallback(function(writer) { writer.seek(-9); }).
- addCallback(goog.partial(checkPositionAndLength, 6, 15)).
- addCallback(goog.partial(writeAndWait, 'foo')).
- addCallback(tick).
- addCallback(function() {
- assertEquals('hello fooverse!', file.toString());
- }).
- addCallback(goog.partial(checkPositionAndLength, 9, 15)).
-
- addCallback(function(writer) { writer.seek(-500); }).
- addCallback(goog.partial(checkPositionAndLength, 0, 15)).
- addCallback(goog.partial(writeAndWait, 'bye-o')).
- addCallback(tick).
- addCallback(function() {
- assertEquals('bye-o fooverse!', file.toString());
- }).
- addCallback(goog.partial(checkPositionAndLength, 5, 15)).
- addCallback(goog.partial(checkLastModified, 21)).
- addBoth(continueTesting);
- waitForAsync('testSeek');
-}
-
-function testAbort() {
- deferredWriter.
- addCallback(goog.partial(tick, 13)).
- addCallback(goog.partial(writeString, 'hello world')).
- addCallback(function(writer) { writer.abort(); }).
- addCallback(goog.partial(checkReadyState,
- goog.fs.FileSaver.ReadyState.WRITING)).
- addCallback(goog.partial(waitForError, goog.fs.Error.ErrorCode.ABORT)).
- addCallback(goog.partial(checkReadyState,
- goog.fs.FileSaver.ReadyState.WRITING)).
- addCallback(goog.partial(waitForEvent,
- goog.fs.FileSaver.EventType.ABORT)).
- addCallback(goog.partial(checkReadyState,
- goog.fs.FileSaver.ReadyState.WRITING)).
- addCallback(goog.partial(waitForEvent,
- goog.fs.FileSaver.EventType.WRITE_END)).
- addCallback(goog.partial(checkReadyState,
- goog.fs.FileSaver.ReadyState.DONE)).
- addCallback(goog.partial(checkPositionAndLength, 0, 0)).
- addCallback(goog.partial(checkLastModified, 0)).
- addCallback(function() { assertEquals('', file.toString()); }).
- addBoth(continueTesting);
- waitForAsync('testAbort');
-}
-
-function testTruncate() {
- deferredWriter.
- addCallback(goog.partial(writeAndWait, 'hello world')).
- addCallback(goog.partial(checkPositionAndLength, 11, 11)).
- addCallback(function(writer) { writer.truncate(5); }).
- addCallback(goog.partial(checkPositionAndLength, 11, 11)).
- addCallback(goog.partial(checkReadyState,
- goog.fs.FileSaver.ReadyState.WRITING)).
- addCallback(goog.partial(waitForEvent,
- goog.fs.FileSaver.EventType.WRITE_START)).
- addCallback(goog.partial(tick, 7)).
- addCallback(goog.partial(checkPositionAndLength, 11, 11)).
- addCallback(goog.partial(checkLastModified, 0)).
- addCallback(goog.partial(waitForEvent,
- goog.fs.FileSaver.EventType.WRITE)).
- addCallback(goog.partial(checkLastModified, 7)).
- addCallback(tick).
- addCallback(goog.partial(checkReadyState,
- goog.fs.FileSaver.ReadyState.WRITING)).
- addCallback(goog.partial(checkPositionAndLength, 5, 5)).
- addCallback(function() { assertEquals('hello', file.toString()); }).
- addCallback(goog.partial(waitForEvent,
- goog.fs.FileSaver.EventType.WRITE_END)).
- addCallback(goog.partial(checkReadyState,
- goog.fs.FileSaver.ReadyState.DONE)).
-
- addCallback(function(writer) { writer.truncate(10); }).
- addCallback(goog.partial(waitForEvent,
- goog.fs.FileSaver.EventType.WRITE_END)).
- addCallback(goog.partial(checkPositionAndLength, 5, 10)).
- addCallback(goog.partial(checkLastModified, 8)).
- addCallback(function() {
- assertEquals('hello\0\0\0\0\0', file.toString());
- }).
- addBoth(continueTesting);
- waitForAsync('testTruncate');
-}
-
-function testAbortBeforeWrite() {
- deferredWriter.
- addCallback(function(writer) { writer.abort(); }).
- addErrback(function(err) {
- assertEquals(goog.fs.Error.ErrorCode.INVALID_STATE, err.code);
- return true;
- }).
- addCallback(function(calledErrback) {
- assertTrue(calledErrback);
- }).
- addBoth(continueTesting);
- waitForAsync('testAbortBeforeWrite');
-}
-
-function testAbortAfterWrite() {
- deferredWriter.
- addCallback(goog.partial(writeAndWait, 'hello world')).
- addCallback(function(writer) { writer.abort(); }).
- addErrback(function(err) {
- assertEquals(goog.fs.Error.ErrorCode.INVALID_STATE, err.code);
- return true;
- }).
- addCallback(assertTrue).
- addBoth(continueTesting);
- waitForAsync('testAbortAfterWrite');
-}
-
-function testWriteDuringWrite() {
- deferredWriter.
- addCallback(goog.partial(writeString, 'hello world')).
- addCallback(goog.partial(writeString, 'hello world')).
- addErrback(function(err) {
- assertEquals(goog.fs.Error.ErrorCode.INVALID_STATE, err.code);
- return true;
- }).
- addCallback(assertTrue).
- addBoth(continueTesting);
- waitForAsync('testWriteDuringWrite');
-}
-
-function testSeekDuringWrite() {
- deferredWriter.
- addCallback(goog.partial(writeString, 'hello world')).
- addCallback(function(writer) { writer.seek(5); }).
- addErrback(function(err) {
- assertEquals(goog.fs.Error.ErrorCode.INVALID_STATE, err.code);
- return true;
- }).
- addCallback(assertTrue).
- addBoth(continueTesting);
- waitForAsync('testSeekDuringWrite');
-}
-
-function testTruncateDuringWrite() {
- deferredWriter.
- addCallback(goog.partial(writeString, 'hello world')).
- addCallback(function(writer) { writer.truncate(5); }).
- addErrback(function(err) {
- assertEquals(goog.fs.Error.ErrorCode.INVALID_STATE, err.code);
- return true;
- }).
- addCallback(assertTrue).
- addBoth(continueTesting);
- waitForAsync('testTruncateDuringWrite');
-}
-
-
-function tick(opt_tickCount) {
- mockClock.tick(opt_tickCount);
-}
-
-function continueTesting(result) {
- asyncTestCase.continueTesting();
- if (result instanceof Error) {
- throw result;
- }
- mockClock.tick();
-}
-
-function waitForAsync(msg) {
- asyncTestCase.waitForAsync(msg);
-
- // The mock clock must be advanced far enough that all timeouts added during
- // callbacks will be triggered. 1000ms is much more than enough.
- mockClock.tick(1000);
-}
-
-function waitForEvent(type, target) {
- var d = new goog.async.Deferred();
- goog.events.listenOnce(target, type, goog.bind(d.callback, d, target));
- return d;
-}
-
-function waitForError(type, target) {
- var d = new goog.async.Deferred();
- goog.events.listenOnce(
- target, goog.fs.FileSaver.EventType.ERROR, function(e) {
- assertEquals(type, target.getError().code);
- d.callback(target);
- });
- return d;
-}
-
-function checkReadyState(expectedState, writer) {
- assertEquals(expectedState, writer.getReadyState());
-}
-
-function checkPositionAndLength(expectedPosition, expectedLength, writer) {
- assertEquals(expectedPosition, writer.getPosition());
- assertEquals(expectedLength, writer.getLength());
-}
-
-function checkLastModified(expectedTime) {
- assertEquals(expectedTime, file.lastModifiedDate.getTime());
-}
-
-function writeString(str, writer) {
- writer.write(new goog.testing.fs.Blob(str));
-}
-
-function writeAndWait(str, writer) {
- writeString(str, writer);
- return waitForEvent(goog.fs.FileSaver.EventType.WRITE_END, writer);
-}
-
-</script>
-</body>
-</html>
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/text-base/fs.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/text-base/fs.js.svn-base
deleted file mode 100644
index 2150429..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/text-base/fs.js.svn-base
+++ /dev/null
@@ -1,146 +0,0 @@
-// Copyright 2011 The Closure Library Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS-IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/**
- * @fileoverview Mock implementations of the Closure HTML5 FileSystem wrapper
- * classes. These implementations are designed to be usable in any browser, so
- * they use none of the native FileSystem-related objects.
- *
- */
-
-goog.provide('goog.testing.fs');
-
-goog.require('goog.Timer');
-goog.require('goog.array');
-goog.require('goog.fs');
-goog.require('goog.testing.fs.Blob');
-goog.require('goog.testing.fs.FileSystem');
-
-
-/**
- * Get a filesystem object. Since these are mocks, there's no difference between
- * temporary and persistent filesystems.
- *
- * @param {number} size Ignored.
- * @return {!goog.async.Deferred} The deferred
- * {@link goog.testing.fs.FileSystem}.
- */
-goog.testing.fs.getTemporary = function(size) {
- var d = new goog.async.Deferred();
- goog.Timer.callOnce(
- goog.bind(d.callback, d, new goog.testing.fs.FileSystem()));
- return d;
-};
-
-
-/**
- * Get a filesystem object. Since these are mocks, there's no difference between
- * temporary and persistent filesystems.
- *
- * @param {number} size Ignored.
- * @return {!goog.async.Deferred} The deferred
- * {@link goog.testing.fs.FileSystem}.
- */
-goog.testing.fs.getPersistent = function(size) {
- return goog.testing.fs.getTemporary(size);
-};
-
-
-/**
- * Which object URLs have been granted for fake blobs.
- * @type {!Object.<boolean>}
- * @private
- */
-goog.testing.fs.objectUrls_ = {};
-
-
-/**
- * Create a fake object URL for a given fake blob. This can be used as a real
- * URL, and it can be created and revoked normally.
- *
- * @param {!goog.testing.fs.Blob} blob The blob for which to create the URL.
- * @return {string} The URL.
- */
-goog.testing.fs.createObjectUrl = function(blob) {
- var url = blob.toDataUrl();
- goog.testing.fs.objectUrls_[url] = true;
- return url;
-};
-
-
-/**
- * Remove a URL that was created for a fake blob.
- *
- * @param {string} url The URL to revoke.
- */
-goog.testing.fs.revokeObjectUrl = function(url) {
- delete goog.testing.fs.objectUrls_[url];
-};
-
-
-/**
- * Return whether or not a URL has been granted for the given blob.
- *
- * @param {!goog.testing.fs.Blob} blob The blob to check.
- * @return {boolean} Whether a URL has been granted.
- */
-goog.testing.fs.isObjectUrlGranted = function(blob) {
- return (blob.toDataUrl()) in goog.testing.fs.objectUrls_;
-};
-
-
-/**
- * Concatenates one or more values together and converts them to a fake blob.
- *
- * @param {...(string|!goog.testing.fs.Blob)} var_args The values that will make
- * up the resulting blob.
- * @return {!goog.testing.fs.Blob} The blob.
- */
-goog.testing.fs.getBlob = function(var_args) {
- return new goog.testing.fs.Blob(goog.array.map(arguments, String).join(''));
-};
-
-
-/**
- * Returns the string value of a fake blob.
- *
- * @param {!goog.testing.fs.Blob} blob The blob to convert to a string.
- * @param {string=} opt_encoding Ignored.
- * @return {!goog.async.Deferred} The deferred string value of the blob.
- */
-goog.testing.fs.blobToString = function(blob, opt_encoding) {
- var d = new goog.async.Deferred();
- goog.Timer.callOnce(goog.bind(d.callback, d, blob.toString()));
- return d;
-};
-
-
-/**
- * Installs goog.testing.fs in place of the standard goog.fs. After calling
- * this, code that uses goog.fs should work without issue using goog.testing.fs.
- *
- * @param {!goog.testing.PropertyReplacer} stubs The property replacer for
- * stubbing out the original goog.fs functions.
- */
-goog.testing.fs.install = function(stubs) {
- // Prevent warnings that goog.fs may get optimized away. It's true this is
- // unsafe in compiled code, but it's only meant for tests.
- var fs = goog.getObjectByName('goog.fs');
- stubs.replace(fs, 'getTemporary', goog.testing.fs.getTemporary);
- stubs.replace(fs, 'getPersistent', goog.testing.fs.getPersistent);
- stubs.replace(fs, 'createObjectUrl', goog.testing.fs.createObjectUrl);
- stubs.replace(fs, 'revokeObjectUrl', goog.testing.fs.revokeObjectUrl);
- stubs.replace(fs, 'getBlob', goog.testing.fs.getBlob);
- stubs.replace(fs, 'blobToString', goog.testing.fs.blobToString);
-};
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/text-base/fs_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/text-base/fs_test.html.svn-base
deleted file mode 100644
index 74c14d7..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/text-base/fs_test.html.svn-base
+++ /dev/null
@@ -1,53 +0,0 @@
-<!DOCTYPE html>
-<html>
-<!--
-Copyright 2011 The Closure Library Authors. All Rights Reserved.
-
-Use of this source code is governed by the Apache License, Version 2.0.
-See the COPYING file for details.
--->
-<!--
--->
-<head>
-<title>Closure Unit Tests - goog.testing.fs</title>
-<script src="../../base.js"></script>
-<script>
-goog.require('goog.testing.AsyncTestCase');
-goog.require('goog.testing.fs');
-goog.require('goog.testing.fs.Blob');
-goog.require('goog.testing.jsunit');
-</script>
-</head>
-<body>
-<script>
-
-var asyncTestCase = goog.testing.AsyncTestCase.createAndInstall();
-
-function testObjectUrls() {
- var blob = goog.testing.fs.getBlob('foo');
- var url = goog.testing.fs.createObjectUrl(blob);
- assertTrue(goog.testing.fs.isObjectUrlGranted(blob));
- goog.testing.fs.revokeObjectUrl(url);
- assertFalse(goog.testing.fs.isObjectUrlGranted(blob));
-}
-
-function testGetBlob() {
- assertEquals(
- new goog.testing.fs.Blob('foobarbaz').toString(),
- goog.testing.fs.getBlob('foo', 'bar', 'baz').toString());
- assertEquals(
- new goog.testing.fs.Blob('foobarbaz').toString(),
- goog.testing.fs.getBlob('foo', new goog.testing.fs.Blob('bar'), 'baz').
- toString());
-}
-
-function testBlobToString() {
- goog.testing.fs.blobToString(new goog.testing.fs.Blob('foobarbaz')).
- addCallback(goog.partial(assertEquals, 'foobarbaz')).
- addCallback(goog.bind(asyncTestCase.continueTesting, asyncTestCase));
- asyncTestCase.waitForAsync('testBlobToString');
-}
-
-</script>
-</body>
-</html>
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/text-base/integration_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/text-base/integration_test.html.svn-base
deleted file mode 100644
index dbf2f87..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/text-base/integration_test.html.svn-base
+++ /dev/null
@@ -1,223 +0,0 @@
-<!DOCTYPE html>
-<html>
-<!--
-Copyright 2011 The Closure Library Authors. All Rights Reserved.
-
-Use of this source code is governed by the Apache License, Version 2.0.
-See the COPYING file for details.
--->
-<!--
--->
-<head>
-<title>Closure Integration Tests - goog.testing.fs</title>
-<script src="../../base.js"></script>
-<script>
-goog.require('goog.async.Deferred');
-goog.require('goog.async.DeferredList');
-goog.require('goog.testing.fs');
-goog.require('goog.fs.DirectoryEntry.Behavior');
-goog.require('goog.testing.AsyncTestCase');
-goog.require('goog.testing.PropertyReplacer');
-goog.require('goog.testing.jsunit');
-</script>
-</head>
-<body>
-<div id="closureTestRunnerLog"></div>
-<script>
-
-var TEST_DIR = 'goog-fs-test-dir';
-
-var deferredFs = goog.testing.fs.getTemporary();
-var asyncTestCase = goog.testing.AsyncTestCase.createAndInstall();
-
-function setUpPage() {
- goog.testing.fs.install(new goog.testing.PropertyReplacer());
-}
-
-function tearDown() {
- loadTestDir().
- addCallback(function(dir) { return dir.removeRecursively(); }).
- addBoth(continueTesting);
- asyncTestCase.waitForAsync('removing filesystem');
-}
-
-function testWriteFile() {
- loadFile('test', goog.fs.DirectoryEntry.Behavior.CREATE).
- addCallback(goog.partial(writeToFile, 'test content')).
- addCallback(goog.partial(checkFileContent, 'test content')).
- addBoth(continueTesting);
- asyncTestCase.waitForAsync('testWriteFile');
-}
-
-function testRemoveFile() {
- loadFile('test', goog.fs.DirectoryEntry.Behavior.CREATE).
- addCallback(goog.partial(writeToFile, 'test content')).
- addCallback(function(fileEntry) { return fileEntry.remove(); }).
- addCallback(goog.partial(checkFileRemoved, 'test')).
- addBoth(continueTesting);
- asyncTestCase.waitForAsync('testRemoveFile');
-}
-
-function testMoveFile() {
- var deferredSubdir = loadDirectory(
- 'subdir', goog.fs.DirectoryEntry.Behavior.CREATE);
- var deferredWrittenFile =
- loadFile('test', goog.fs.DirectoryEntry.Behavior.CREATE).
- addCallback(goog.partial(writeToFile, 'test content'));
- goog.async.DeferredList.gatherResults([deferredSubdir, deferredWrittenFile]).
- addCallback(splitArgs(function(dir, fileEntry) {
- return fileEntry.moveTo(dir);
- })).
- addCallback(goog.partial(checkFileContent, 'test content')).
- addCallback(goog.partial(checkFileRemoved, 'test')).
- addBoth(continueTesting);
- asyncTestCase.waitForAsync('testMoveFile');
-}
-
-function testCopyFile() {
- var deferredFile = loadFile('test', goog.fs.DirectoryEntry.Behavior.CREATE);
- var deferredSubdir = loadDirectory(
- 'subdir', goog.fs.DirectoryEntry.Behavior.CREATE);
- var deferredWrittenFile = deferredFile.branch().
- addCallback(goog.partial(writeToFile, 'test content'));
- goog.async.DeferredList.gatherResults([deferredSubdir, deferredWrittenFile]).
- addCallback(splitArgs(function(dir, fileEntry) {
- return fileEntry.copyTo(dir);
- })).
- addCallback(goog.partial(checkFileContent, 'test content')).
- awaitDeferred(deferredFile).
- addCallback(goog.partial(checkFileContent, 'test content')).
- addBoth(continueTesting);
- asyncTestCase.waitForAsync('testCopyFile');
-}
-
-function testAbortWrite() {
- var deferredFile = loadFile('test', goog.fs.DirectoryEntry.Behavior.CREATE);
- deferredFile.branch().
- addCallback(goog.partial(startWrite, 'test content')).
- addCallback(function(writer) { writer.abort(); }).
- addCallback(
- goog.partial(waitForEvent, goog.fs.FileSaver.EventType.ABORT)).
- awaitDeferred(deferredFile).
- addCallback(goog.partial(checkFileContent, '')).
- addBoth(continueTesting);
- asyncTestCase.waitForAsync('testAbortWrite');
-}
-
-function testSeek() {
- var deferredFile = loadFile('test', goog.fs.DirectoryEntry.Behavior.CREATE);
- deferredFile.branch().
- addCallback(goog.partial(writeToFile, 'test content')).
- addCallback(function(fileEntry) { return fileEntry.createWriter(); }).
- addCallback(
- goog.partial(checkReadyState, goog.fs.FileSaver.ReadyState.INIT)).
- addCallback(function(writer) {
- writer.seek(5);
- writer.write(goog.fs.getBlob('stuff and things'));
- }).
- addCallback(
- goog.partial(checkReadyState, goog.fs.FileSaver.ReadyState.WRITING)).
- addCallback(
- goog.partial(waitForEvent, goog.fs.FileSaver.EventType.WRITE)).
- awaitDeferred(deferredFile).
- addCallback(goog.partial(checkFileContent, 'test stuff and things')).
- addBoth(continueTesting);
- asyncTestCase.waitForAsync('testSeek');
-}
-
-function testTruncate() {
- var deferredFile = loadFile('test', goog.fs.DirectoryEntry.Behavior.CREATE);
- deferredFile.branch().
- addCallback(goog.partial(writeToFile, 'test content')).
- addCallback(function(fileEntry) { return fileEntry.createWriter(); }).
- addCallback(
- goog.partial(checkReadyState, goog.fs.FileSaver.ReadyState.INIT)).
- addCallback(function(writer) { writer.truncate(4); }).
- addCallback(
- goog.partial(checkReadyState, goog.fs.FileSaver.ReadyState.WRITING)).
- addCallback(
- goog.partial(waitForEvent, goog.fs.FileSaver.EventType.WRITE)).
- awaitDeferred(deferredFile).
- addCallback(goog.partial(checkFileContent, 'test')).
- addBoth(continueTesting);
- asyncTestCase.waitForAsync('testTruncate');
-}
-
-
-function continueTesting(result) {
- asyncTestCase.continueTesting();
- if (result instanceof Error) {
- throw result;
- }
-}
-
-function loadTestDir() {
- return deferredFs.branch().addCallback(function(fs) {
- return fs.getRoot().getDirectory(
- TEST_DIR, goog.fs.DirectoryEntry.Behavior.CREATE);
- });
-}
-
-function loadFile(filename, behavior) {
- return loadTestDir().addCallback(function(dir) {
- return dir.getFile(filename, behavior);
- });
-}
-
-function loadDirectory(filename, behavior) {
- return loadTestDir().addCallback(function(dir) {
- return dir.getDirectory(filename, behavior);
- });
-}
-
-function startWrite(content, fileEntry) {
- return fileEntry.createWriter().
- addCallback(
- goog.partial(checkReadyState, goog.fs.FileSaver.ReadyState.INIT)).
- addCallback(function(writer) {
- writer.write(goog.fs.getBlob(content));
- return writer;
- }).
- addCallback(
- goog.partial(checkReadyState, goog.fs.FileSaver.ReadyState.WRITING));
-}
-
-function waitForEvent(type, target) {
- var d = new goog.async.Deferred();
- goog.events.listenOnce(target, type, d.callback, false, d);
- return d;
-}
-
-function writeToFile(content, fileEntry) {
- return startWrite(content, fileEntry).
- addCallback(
- goog.partial(waitForEvent, goog.fs.FileSaver.EventType.WRITE)).
- addCallback(function() { return fileEntry; });
-}
-
-function checkFileContent(content, fileEntry) {
- return fileEntry.file().
- addCallback(function(blob) { return goog.fs.blobToString(blob); }).
- addCallback(goog.partial(assertEquals, content));
-}
-
-function checkFileRemoved(filename) {
- return loadFile(filename).
- addCallback(goog.partial(fail, 'expected file to be removed')).
- addErrback(function(err) {
- assertEquals(err.code, goog.fs.Error.ErrorCode.NOT_FOUND);
- return true; // Go back to callback path
- });
-}
-
-function checkReadyState(expectedState, writer) {
- assertEquals(expectedState, writer.getReadyState());
-}
-
-function splitArgs(fn) {
- return function(args) { return fn(args[0], args[1]); };
-}
-
-</script>
-</body>
-</html>
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/text-base/progressevent.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/text-base/progressevent.js.svn-base
deleted file mode 100644
index 62ac0a6..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/fs/.svn/text-base/progressevent.js.svn-base
+++ /dev/null
@@ -1,83 +0,0 @@
-// Copyright 2011 Google Inc. All Rights Reserved.
-
-// Copyright 2011 The Closure Library Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS-IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/**
- * @fileoverview Mock ProgressEvent object.
- *
- */
-
-goog.provide('goog.testing.fs.ProgressEvent');
-
-goog.require('goog.events.Event');
-
-
-
-/**
- * A mock progress event.
- *
- * @param {!goog.fs.FileSaver.EventType|!goog.fs.FileReader.EventType} type
- * Event type.
- * @param {number} loaded The number of bytes processed.
- * @param {number} total The total data that was to be processed, in bytes.
- * @constructor
- * @extends {goog.events.Event}
- */
-goog.testing.fs.ProgressEvent = function(type, loaded, total) {
- goog.base(this, type);
-
- /**
- * The number of bytes processed.
- * @type {number}
- * @private
- */
- this.loaded_ = loaded;
-
-
- /**
- * The total data that was to be procesed, in bytes.
- * @type {number}
- * @private
- */
- this.total_ = total;
-};
-goog.inherits(goog.testing.fs.ProgressEvent, goog.events.Event);
-
-
-/**
- * @see {goog.fs.ProgressEvent#isLengthComputable}
- * @return {boolean} True if the length is known.
- */
-goog.testing.fs.ProgressEvent.prototype.isLengthComputable = function() {
- return true;
-};
-
-
-/**
- * @see {goog.fs.ProgressEvent#getLoaded}
- * @return {number} The number of bytes loaded or written.
- */
-goog.testing.fs.ProgressEvent.prototype.getLoaded = function() {
- return this.loaded_;
-};
-
-
-/**
- * @see {goog.fs.ProgressEvent#getTotal}
- * @return {number} The total bytes to load or write.
- */
-goog.testing.fs.ProgressEvent.prototype.getTotal = function() {
- return this.total_;
-};
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/fs/blob.js b/contexts/data/lib/closure-library/closure/goog/testing/fs/blob.js
index b0408a6..8fd5cd7 100644
--- a/contexts/data/lib/closure-library/closure/goog/testing/fs/blob.js
+++ b/contexts/data/lib/closure-library/closure/goog/testing/fs/blob.js
@@ -74,6 +74,7 @@ goog.testing.fs.Blob.prototype.slice = function(
/**
* @return {string} The string data encapsulated by the blob.
+ * @override
*/
goog.testing.fs.Blob.prototype.toString = function() {
return this.data_;
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/fs/directoryentry_test.html b/contexts/data/lib/closure-library/closure/goog/testing/fs/directoryentry_test.html
index 7fab04a..02ad1d5 100644
--- a/contexts/data/lib/closure-library/closure/goog/testing/fs/directoryentry_test.html
+++ b/contexts/data/lib/closure-library/closure/goog/testing/fs/directoryentry_test.html
@@ -78,7 +78,12 @@ function testGetFile() {
}).
addCallback(function(date) {
assertEquals('Reading a file should not update the modification date.',
- 0, date.getTime());
+ 0, date.getTime());
+ return dir.getMetadata();
+ }).
+ addCallback(function(metadata) {
+ assertEquals('Reading a file should not update the metadata.',
+ 0, metadata.modificationTime.getTime());
}).
addBoth(continueTesting);
waitForAsync('waiting for file');
@@ -134,6 +139,10 @@ function testCreateFile() {
}).
addCallback(function(date) {
assertEquals(43, date.getTime());
+ return dir.getMetadata();
+ }).
+ addCallback(function(metadata) {
+ assertEquals(43, metadata.modificationTime.getTime());
}).
addBoth(continueTesting);
waitForAsync('waiting for file creation');
@@ -155,6 +164,10 @@ function testCreateFileThatAlreadyExists() {
}).
addCallback(function(date) {
assertEquals(47, date.getTime());
+ return dir.getMetadata();
+ }).
+ addCallback(function(metadata) {
+ assertEquals(47, metadata.modificationTime.getTime());
}).
addBoth(continueTesting);
waitForAsync('waiting for file creation');
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/fs/entry.js b/contexts/data/lib/closure-library/closure/goog/testing/fs/entry.js
index a17d795..bc4175b 100644
--- a/contexts/data/lib/closure-library/closure/goog/testing/fs/entry.js
+++ b/contexts/data/lib/closure-library/closure/goog/testing/fs/entry.js
@@ -129,6 +129,13 @@ goog.testing.fs.Entry.prototype.getLastModified = goog.abstractMethod;
/**
+ * @see {goog.fs.Entry#getMetadata}
+ * @return {!goog.async.Deferred}
+ */
+goog.testing.fs.Entry.prototype.getMetadata = goog.abstractMethod;
+
+
+/**
* @see {goog.fs.Entry#moveTo}
* @param {!goog.testing.fs.DirectoryEntry} parent
* @param {string=} opt_newName
@@ -267,6 +274,18 @@ goog.testing.fs.DirectoryEntry = function(fs, parent, name, children) {
goog.inherits(goog.testing.fs.DirectoryEntry, goog.testing.fs.Entry);
+/**
+ * Constructs and returns the metadata object for this entry.
+ * @return {{modificationTime: Date}} The metadata object.
+ * @private
+ */
+goog.testing.fs.DirectoryEntry.prototype.getMetadata_ = function() {
+ return {
+ 'modificationTime': new Date(this.lastModifiedTimestamp_)
+ };
+};
+
+
/** @override */
goog.testing.fs.DirectoryEntry.prototype.isFile = function() {
return false;
@@ -288,6 +307,14 @@ goog.testing.fs.DirectoryEntry.prototype.getLastModified = function() {
/** @override */
+goog.testing.fs.DirectoryEntry.prototype.getMetadata = function() {
+ var msg = 'reading metadata for ' + this.getFullPath();
+ return this.checkNotDeleted(msg).
+ addCallback(function() {return this.getMetadata_()});
+};
+
+
+/** @override */
goog.testing.fs.DirectoryEntry.prototype.clone = function() {
return new goog.testing.fs.DirectoryEntry(
this.getFileSystem(), this.parent, this.getName(), this.children);
@@ -530,7 +557,8 @@ goog.testing.fs.DirectoryEntry.prototype.listDirectory = function() {
* @return {!goog.async.Deferred}
*/
goog.testing.fs.DirectoryEntry.prototype.createPath =
- goog.fs.DirectoryEntry.prototype.createPath;
+ // This isn't really type-safe.
+ /** @type {!Function} */ (goog.fs.DirectoryEntry.prototype.createPath);
@@ -554,6 +582,15 @@ goog.testing.fs.FileEntry = function(fs, parent, name, data) {
* @private
*/
this.file_ = new goog.testing.fs.File(name, new Date(goog.now()), data);
+
+ /**
+ * The metadata for file.
+ * @type {{modificationTime: Date}}
+ * @private
+ */
+ this.metadata_ = {
+ 'modificationTime': this.file_.lastModifiedDate
+ };
};
goog.inherits(goog.testing.fs.FileEntry, goog.testing.fs.Entry);
@@ -586,6 +623,15 @@ goog.testing.fs.FileEntry.prototype.getLastModified = function() {
};
+/** @override */
+goog.testing.fs.FileEntry.prototype.getMetadata = function() {
+ var msg = 'getting metadata for ' + this.getFullPath();
+ return this.checkNotDeleted(msg).addCallback(function() {
+ return this.metadata_;
+ });
+};
+
+
/**
* @see {goog.fs.FileEntry#createWriter}
* @return {!goog.async.Deferred}
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/fs/entry_test.html b/contexts/data/lib/closure-library/closure/goog/testing/fs/entry_test.html
index 09f2fac..eed649f 100644
--- a/contexts/data/lib/closure-library/closure/goog/testing/fs/entry_test.html
+++ b/contexts/data/lib/closure-library/closure/goog/testing/fs/entry_test.html
@@ -86,10 +86,19 @@ function testMoveToNewName() {
}).
addCallback(function(lastModifiedDate) {
assertEquals(71, lastModifiedDate.getTime());
+ var oldParentDir = fs.getRoot().getDirectorySync('foo');
+ return oldParentDir.getMetadata();
+ }).
+ addCallback(function(metadata) {
+ assertEquals(71, metadata.modificationTime.getTime());
return fs.getRoot().getLastModified();
}).
addCallback(function(rootLastModifiedDate) {
assertEquals(71, rootLastModifiedDate.getTime());
+ return fs.getRoot().getMetadata();
+ }).
+ addCallback(function(rootMetadata) {
+ assertEquals(71, rootMetadata.modificationTime.getTime());
asyncTestCase.continueTesting();
});
waitForAsync('waiting for file move');
@@ -116,10 +125,20 @@ function testCopyTo() {
addCallback(function(lastModifiedDate) {
assertEquals('The original parent directory was not modified.',
0, lastModifiedDate.getTime());
+ var oldParentDir = fs.getRoot().getDirectorySync('foo');
+ return oldParentDir.getMetadata();
+ }).
+ addCallback(function(metadata) {
+ assertEquals('The original parent directory was not modified.',
+ 0, metadata.modificationTime.getTime());
return fs.getRoot().getLastModified();
}).
addCallback(function(rootLastModifiedDate) {
assertEquals(61, rootLastModifiedDate.getTime());
+ return fs.getRoot().getMetadata();
+ }).
+ addCallback(function(rootMetadata) {
+ assertEquals(61, rootMetadata.modificationTime.getTime());
asyncTestCase.continueTesting();
});
waitForAsync('waiting for file copy');
@@ -158,6 +177,11 @@ function testRemove() {
}).
addCallback(function(date) {
assertEquals(57, date.getTime());
+ var parentDir = fs.getRoot().getDirectorySync('foo');
+ return parentDir.getMetadata();
+ }).
+ addCallback(function(metadata) {
+ assertEquals(57, metadata.modificationTime.getTime());
asyncTestCase.continueTesting();
});
waitForAsync('waiting for file removal');
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/fs/fileentry_test.html b/contexts/data/lib/closure-library/closure/goog/testing/fs/fileentry_test.html
index ee4c76d..00ad1ff 100644
--- a/contexts/data/lib/closure-library/closure/goog/testing/fs/fileentry_test.html
+++ b/contexts/data/lib/closure-library/closure/goog/testing/fs/fileentry_test.html
@@ -69,6 +69,19 @@ function testGetLastModified() {
waitForAsync('testGetLastModified');
}
+function testGetMetadata() {
+ // Advance the clock to a known time.
+ mockClock.tick(54);
+ var testFile = new goog.testing.fs.FileEntry(fs, fs.getRoot(),
+ 'timeTest', 'hello world');
+ mockClock.tick();
+ testFile.getMetadata().addCallback(function(metadata) {
+ assertEquals(54, metadata.modificationTime.getTime());
+ asyncTestCase.continueTesting();
+ });
+ waitForAsync('testGetMetadata');
+}
+
function waitForAsync(msg) {
asyncTestCase.waitForAsync(msg);
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/fs/progressevent.js b/contexts/data/lib/closure-library/closure/goog/testing/fs/progressevent.js
index 62ac0a6..3e7ae2d 100644
--- a/contexts/data/lib/closure-library/closure/goog/testing/fs/progressevent.js
+++ b/contexts/data/lib/closure-library/closure/goog/testing/fs/progressevent.js
@@ -1,5 +1,3 @@
-// Copyright 2011 Google Inc. All Rights Reserved.
-
// Copyright 2011 The Closure Library Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/functionmock.js b/contexts/data/lib/closure-library/closure/goog/testing/functionmock.js
index f00bb61..a9f3031 100644
--- a/contexts/data/lib/closure-library/closure/goog/testing/functionmock.js
+++ b/contexts/data/lib/closure-library/closure/goog/testing/functionmock.js
@@ -39,7 +39,7 @@ goog.require('goog.testing.StrictMock');
* @param {string=} opt_functionName The optional name of the function to mock.
* Set to '[anonymous mocked function]' if not passed in.
* @param {number=} opt_strictness One of goog.testing.Mock.LOOSE or
- * goog.testing.mock.STRICT. The default is STRICT.
+ * goog.testing.Mock.STRICT. The default is STRICT.
* @return {goog.testing.MockInterface} The mocked function.
* @suppress {missingProperties} Mocks do not fit in the type system well.
*/
@@ -63,7 +63,7 @@ goog.testing.FunctionMock = function(opt_functionName, opt_strictness) {
* @param {Object} scope The scope of the method to be mocked out.
* @param {string} functionName The name of the function we're going to mock.
* @param {number=} opt_strictness One of goog.testing.Mock.LOOSE or
- * goog.testing.mock.STRICT. The default is STRICT.
+ * goog.testing.Mock.STRICT. The default is STRICT.
* @return {goog.testing.MockInterface} The mocked method.
*/
goog.testing.MethodMock = function(scope, functionName, opt_strictness) {
@@ -95,7 +95,7 @@ goog.testing.MethodMock.$tearDown = function() {
* in the global scope with the name specified by functionName.
* @param {string} functionName The name of the function we're going to mock.
* @param {number=} opt_strictness One of goog.testing.Mock.LOOSE or
- * goog.testing.mock.STRICT. The default is STRICT.
+ * goog.testing.Mock.STRICT. The default is STRICT.
* @return {goog.testing.MockInterface} The mocked global function.
*/
goog.testing.GlobalFunctionMock = function(functionName, opt_strictness) {
@@ -108,7 +108,7 @@ goog.testing.GlobalFunctionMock = function(functionName, opt_strictness) {
* @param {string=} opt_functionName The optional name of the function to mock
* set to '[anonymous mocked function]' if not passed in.
* @param {number=} opt_strictness One of goog.testing.Mock.LOOSE or
- * goog.testing.mock.STRICT. The default is STRICT.
+ * goog.testing.Mock.STRICT. The default is STRICT.
* @return {goog.testing.MockInterface} The mocked function.
*/
goog.testing.createFunctionMock = function(opt_functionName, opt_strictness) {
@@ -121,7 +121,7 @@ goog.testing.createFunctionMock = function(opt_functionName, opt_strictness) {
* @param {Object} scope The scope of the method to be mocked out.
* @param {string} functionName The name of the function we're going to mock.
* @param {number=} opt_strictness One of goog.testing.Mock.LOOSE or
- * goog.testing.mock.STRICT. The default is STRICT.
+ * goog.testing.Mock.STRICT. The default is STRICT.
* @return {goog.testing.MockInterface} The mocked global function.
*/
goog.testing.createMethodMock = function(scope, functionName, opt_strictness) {
@@ -141,7 +141,7 @@ goog.testing.createMethodMock = function(scope, functionName, opt_strictness) {
* @param {string} constructorName The name of the constructor we're going to
* mock.
* @param {number=} opt_strictness One of goog.testing.Mock.LOOSE or
- * goog.testing.mock.STRICT. The default is STRICT.
+ * goog.testing.Mock.STRICT. The default is STRICT.
* @return {goog.testing.MockInterface} The mocked constructor.
*/
goog.testing.createConstructorMock = function(scope, constructorName,
@@ -169,7 +169,7 @@ goog.testing.createConstructorMock = function(scope, constructorName,
* Convenience method for creating a mocks for a global / top-level function.
* @param {string} functionName The name of the function we're going to mock.
* @param {number=} opt_strictness One of goog.testing.Mock.LOOSE or
- * goog.testing.mock.STRICT. The default is STRICT.
+ * goog.testing.Mock.STRICT. The default is STRICT.
* @return {goog.testing.MockInterface} The mocked global function.
*/
goog.testing.createGlobalFunctionMock = function(functionName, opt_strictness) {
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/jsunit.js b/contexts/data/lib/closure-library/closure/goog/testing/jsunit.js
index 97d343d..d02e747 100644
--- a/contexts/data/lib/closure-library/closure/goog/testing/jsunit.js
+++ b/contexts/data/lib/closure-library/closure/goog/testing/jsunit.js
@@ -51,9 +51,13 @@ goog.testing.jsunit.AUTO_RUN_ONLOAD = true;
(function() {
+ // Increases the maximum number of stack frames in Google Chrome from the
+ // default 10 to 50 to get more useful stack traces.
+ Error.stackTraceLimit = 50;
// Store a reference to the window's timeout so that it can't be overridden
// by tests.
+ /** @type {!Function} */
var realTimeout = window.setTimeout;
// Check for JsUnit's test runner (need to check for >2.2 and <=2.2)
@@ -61,7 +65,7 @@ goog.testing.jsunit.AUTO_RUN_ONLOAD = true;
// Running inside JsUnit so add support code.
var path = goog.basePath + goog.testing.jsunit.CORE_SCRIPT;
document.write('<script type="text/javascript" src="' +
- path + '"></' + 'script>');
+ path + '"></' + 'script>');
} else {
@@ -123,10 +127,10 @@ goog.testing.jsunit.AUTO_RUN_ONLOAD = true;
// onload handler to avoid running the test in JsTestC.
if (goog.testing.jsunit.AUTO_RUN_ONLOAD) {
var onload = window.onload;
- window.onload = function() {
+ window.onload = function(e) {
// Call any existing onload handlers.
if (onload) {
- onload();
+ onload(e);
}
// Wait 500ms longer so that we don't interfere with Selenium.
realTimeout(function() {
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/messaging/.svn/all-wcprops b/contexts/data/lib/closure-library/closure/goog/testing/messaging/.svn/all-wcprops
deleted file mode 100644
index 3988361..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/messaging/.svn/all-wcprops
+++ /dev/null
@@ -1,29 +0,0 @@
-K 25
-svn:wc:ra_dav:version-url
-V 54
-/svn/!svn/ver/850/trunk/closure/goog/testing/messaging
-END
-mockmessagechannel.js
-K 25
-svn:wc:ra_dav:version-url
-V 76
-/svn/!svn/ver/850/trunk/closure/goog/testing/messaging/mockmessagechannel.js
-END
-mockportnetwork.js
-K 25
-svn:wc:ra_dav:version-url
-V 73
-/svn/!svn/ver/850/trunk/closure/goog/testing/messaging/mockportnetwork.js
-END
-mockmessageevent.js
-K 25
-svn:wc:ra_dav:version-url
-V 74
-/svn/!svn/ver/850/trunk/closure/goog/testing/messaging/mockmessageevent.js
-END
-mockmessageport.js
-K 25
-svn:wc:ra_dav:version-url
-V 73
-/svn/!svn/ver/850/trunk/closure/goog/testing/messaging/mockmessageport.js
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/messaging/.svn/entries b/contexts/data/lib/closure-library/closure/goog/testing/messaging/.svn/entries
deleted file mode 100644
index df189b0..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/messaging/.svn/entries
+++ /dev/null
@@ -1,164 +0,0 @@
-10
-
-dir
-1494
-http://closure-library.googlecode.com/svn/trunk/closure/goog/testing/messaging
-http://closure-library.googlecode.com/svn
-
-
-
-2011-04-12T20:35:47.000000Z
-850
-diegosalas@google.com
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-0b95b8e8-c90f-11de-9d4f-f947ee5921c8
-
-mockmessagechannel.js
-file
-
-
-
-
-2011-12-23T22:42:27.079313Z
-4bd696083c0657d2053e46b8fa41e339
-2011-04-12T20:35:47.000000Z
-850
-diegosalas@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-2372
-
-mockportnetwork.js
-file
-
-
-
-
-2011-12-23T22:42:27.080313Z
-ad0e0e3b6e1886034d997d44d17fd981
-2011-04-12T20:35:47.000000Z
-850
-diegosalas@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-1933
-
-mockmessageevent.js
-file
-
-
-
-
-2011-12-23T22:42:27.081313Z
-777f7a49103d7108df6f4d4478814733
-2011-04-12T20:35:47.000000Z
-850
-diegosalas@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-3285
-
-mockmessageport.js
-file
-
-
-
-
-2011-12-23T22:42:27.082313Z
-c4d3fd80f6495ac44b935785e4ad48d8
-2011-04-12T20:35:47.000000Z
-850
-diegosalas@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-2342
-
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/messaging/.svn/prop-base/mockmessagechannel.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/messaging/.svn/prop-base/mockmessagechannel.js.svn-base
deleted file mode 100644
index 530636b..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/messaging/.svn/prop-base/mockmessagechannel.js.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 15
-text/javascript
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/messaging/.svn/prop-base/mockmessageevent.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/messaging/.svn/prop-base/mockmessageevent.js.svn-base
deleted file mode 100644
index 7febff5..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/messaging/.svn/prop-base/mockmessageevent.js.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 22
-application/javascript
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/messaging/.svn/prop-base/mockmessageport.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/messaging/.svn/prop-base/mockmessageport.js.svn-base
deleted file mode 100644
index 530636b..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/messaging/.svn/prop-base/mockmessageport.js.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 15
-text/javascript
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/messaging/.svn/prop-base/mockportnetwork.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/messaging/.svn/prop-base/mockportnetwork.js.svn-base
deleted file mode 100644
index 530636b..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/messaging/.svn/prop-base/mockportnetwork.js.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 15
-text/javascript
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/messaging/.svn/text-base/mockmessagechannel.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/messaging/.svn/text-base/mockmessagechannel.js.svn-base
deleted file mode 100644
index 06e093f..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/messaging/.svn/text-base/mockmessagechannel.js.svn-base
+++ /dev/null
@@ -1,77 +0,0 @@
-// Copyright 2010 The Closure Library Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS-IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/**
- * @fileoverview Mock MessageChannel implementation that can receive fake
- * messages and test that the right messages are sent.
- *
- */
-
-
-goog.provide('goog.testing.messaging.MockMessageChannel');
-
-goog.require('goog.messaging.AbstractChannel');
-goog.require('goog.testing.asserts');
-
-
-
-/**
- * Class for unit-testing code that communicates over a MessageChannel.
- * @param {goog.testing.MockControl} mockControl The mock control used to create
- * the method mock for #send.
- * @extends {goog.messaging.AbstractChannel}
- * @constructor
- */
-goog.testing.messaging.MockMessageChannel = function(mockControl) {
- goog.base(this);
-
- /**
- * Whether the channel has been disposed.
- * @type {boolean}
- */
- this.disposed = false;
-
- mockControl.createMethodMock(this, 'send');
-};
-goog.inherits(goog.testing.messaging.MockMessageChannel,
- goog.messaging.AbstractChannel);
-
-
-/**
- * A mock send function. Actually an instance of
- * {@link goog.testing.FunctionMock}.
- * @param {string} serviceName The name of the remote service to run.
- * @param {string|!Object} payload The payload to send to the remote page.
- */
-goog.testing.messaging.MockMessageChannel.prototype.send = function(
- serviceName, payload) {};
-
-
-/**
- * Sets a flag indicating that this is disposed.
- */
-goog.testing.messaging.MockMessageChannel.prototype.dispose = function() {
- this.disposed = true;
-};
-
-
-/**
- * Mocks the receipt of a message. Passes the payload the appropriate service.
- * @param {string} serviceName The service to run.
- * @param {string|!Object} payload The argument to pass to the service.
- */
-goog.testing.messaging.MockMessageChannel.prototype.receive = function(
- serviceName, payload) {
- this.deliver(serviceName, payload);
-};
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/messaging/.svn/text-base/mockmessageevent.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/messaging/.svn/text-base/mockmessageevent.js.svn-base
deleted file mode 100644
index 41620be..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/messaging/.svn/text-base/mockmessageevent.js.svn-base
+++ /dev/null
@@ -1,100 +0,0 @@
-// Copyright 2010 The Closure Library Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS-IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/**
- * @fileoverview A simple mock class for imitating HTML5 MessageEvents.
- *
- */
-
-goog.provide('goog.testing.messaging.MockMessageEvent');
-
-goog.require('goog.events.BrowserEvent');
-goog.require('goog.events.EventType');
-goog.require('goog.testing.events');
-
-
-
-/**
- * Creates a new fake MessageEvent.
- *
- * @param {*} data The data of the message.
- * @param {string=} opt_origin The origin of the message, for server-sent and
- * cross-document events.
- * @param {string=} opt_lastEventId The last event ID, for server-sent events.
- * @param {Window=} opt_source The proxy for the source window, for
- * cross-document events.
- * @param {Array.<MessagePort>=} opt_ports The Array of ports sent with the
- * message, for cross-document and channel events.
- * @extends {goog.testing.events.Event}
- * @constructor
- */
-goog.testing.messaging.MockMessageEvent = function(
- data, opt_origin, opt_lastEventId, opt_source, opt_ports) {
- goog.base(this, goog.events.EventType.MESSAGE);
-
- /**
- * The data of the message.
- * @type {*}
- */
- this.data = data;
-
- /**
- * The origin of the message, for server-sent and cross-document events.
- * @type {?string}
- */
- this.origin = opt_origin || null;
-
- /**
- * The last event ID, for server-sent events.
- * @type {?string}
- */
- this.lastEventId = opt_lastEventId || null;
-
- /**
- * The proxy for the source window, for cross-document events.
- * @type {Window}
- */
- this.source = opt_source || null;
-
- /**
- * The Array of ports sent with the message, for cross-document and channel
- * events.
- * @type {Array.<!MessagePort>}
- */
- this.ports = opt_ports || null;
-};
-goog.inherits(
- goog.testing.messaging.MockMessageEvent, goog.testing.events.Event);
-
-
-/**
- * Wraps a new fake MessageEvent in a BrowserEvent, like how a real MessageEvent
- * would be wrapped.
- *
- * @param {*} data The data of the message.
- * @param {string=} opt_origin The origin of the message, for server-sent and
- * cross-document events.
- * @param {string=} opt_lastEventId The last event ID, for server-sent events.
- * @param {Window=} opt_source The proxy for the source window, for
- * cross-document events.
- * @param {Array.<MessagePort>=} opt_ports The Array of ports sent with the
- * message, for cross-document and channel events.
- * @return {goog.events.BrowserEvent} The wrapping event.
- */
-goog.testing.messaging.MockMessageEvent.wrap = function(
- data, opt_origin, opt_lastEventId, opt_source, opt_ports) {
- return new goog.events.BrowserEvent(
- new goog.testing.messaging.MockMessageEvent(
- data, opt_origin, opt_lastEventId, opt_source, opt_ports));
-};
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/messaging/.svn/text-base/mockmessageport.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/messaging/.svn/text-base/mockmessageport.js.svn-base
deleted file mode 100644
index c7ffb15..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/messaging/.svn/text-base/mockmessageport.js.svn-base
+++ /dev/null
@@ -1,85 +0,0 @@
-// Copyright 2011 The Closure Library Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS-IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/**
- * @fileoverview A simple dummy class for representing message ports in tests.
- *
- */
-
-goog.provide('goog.testing.messaging.MockMessagePort');
-
-goog.require('goog.events.EventTarget');
-
-
-
-/**
- * Class for unit-testing code that uses MessagePorts.
- * @param {*} id An opaque identifier, used because message ports otherwise have
- * no distinguishing characteristics.
- * @param {goog.testing.MockControl} mockControl The mock control used to create
- * the method mock for #postMessage.
- * @constructor
- * @extends {goog.events.EventTarget}
- */
-goog.testing.messaging.MockMessagePort = function(id, mockControl) {
- goog.base(this);
-
- /**
- * An opaque identifier, used because message ports otherwise have no
- * distinguishing characteristics.
- * @type {*}
- */
- this.id = id;
-
- /**
- * Whether or not the port has been started.
- * @type {boolean}
- */
- this.started = false;
-
- /**
- * Whether or not the port has been closed.
- * @type {boolean}
- */
- this.closed = false;
-
- mockControl.createMethodMock(this, 'postMessage');
-};
-goog.inherits(goog.testing.messaging.MockMessagePort, goog.events.EventTarget);
-
-
-/**
- * A mock postMessage funciton. Actually an instance of
- * {@link goog.testing.FunctionMock}.
- * @param {*} message The message to send.
- * @param {Array.<MessagePort>=} opt_ports Ports to send with the message.
- */
-goog.testing.messaging.MockMessagePort.prototype.postMessage = function(
- message, opt_ports) {};
-
-
-/**
- * Starts the port.
- */
-goog.testing.messaging.MockMessagePort.prototype.start = function() {
- this.started = true;
-};
-
-
-/**
- * Closes the port.
- */
-goog.testing.messaging.MockMessagePort.prototype.close = function() {
- this.closed = true;
-};
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/messaging/.svn/text-base/mockportnetwork.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/messaging/.svn/text-base/mockportnetwork.js.svn-base
deleted file mode 100644
index bdccebf..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/messaging/.svn/text-base/mockportnetwork.js.svn-base
+++ /dev/null
@@ -1,64 +0,0 @@
-// Copyright 2011 The Closure Library Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS-IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/**
- * @fileoverview A fake PortNetwork implementation that simply produces
- * MockMessageChannels for all ports.
- *
- */
-
-goog.provide('goog.testing.messaging.MockPortNetwork');
-
-goog.require('goog.messaging.PortNetwork'); // interface
-goog.require('goog.testing.messaging.MockMessageChannel');
-
-
-
-/**
- * The fake PortNetwork.
- *
- * @param {!goog.testing.MockControl} mockControl The mock control for creating
- * the mock message channels.
- * @constructor
- * @implements {goog.messaging.PortNetwork}
- */
-goog.testing.messaging.MockPortNetwork = function(mockControl) {
- /**
- * The mock control for creating mock message channels.
- * @type {!goog.testing.MockControl}
- * @private
- */
- this.mockControl_ = mockControl;
-
- /**
- * The mock ports that have been created.
- * @type {!Object.<!goog.testing.messaging.MockMessageChannel>}
- * @private
- */
- this.ports_ = {};
-};
-
-
-/**
- * Get the mock port with the given name.
- * @param {string} name The name of the port to get.
- * @return {!goog.testing.messaging.MockMessageChannel} The mock port.
- */
-goog.testing.messaging.MockPortNetwork.prototype.dial = function(name) {
- if (!(name in this.ports_)) {
- this.ports_[name] =
- new goog.testing.messaging.MockMessageChannel(this.mockControl_);
- }
- return this.ports_[name];
-};
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/messaging/mockmessagechannel.js b/contexts/data/lib/closure-library/closure/goog/testing/messaging/mockmessagechannel.js
index 06e093f..ff34717 100644
--- a/contexts/data/lib/closure-library/closure/goog/testing/messaging/mockmessagechannel.js
+++ b/contexts/data/lib/closure-library/closure/goog/testing/messaging/mockmessagechannel.js
@@ -53,6 +53,7 @@ goog.inherits(goog.testing.messaging.MockMessageChannel,
* {@link goog.testing.FunctionMock}.
* @param {string} serviceName The name of the remote service to run.
* @param {string|!Object} payload The payload to send to the remote page.
+ * @override
*/
goog.testing.messaging.MockMessageChannel.prototype.send = function(
serviceName, payload) {};
@@ -60,6 +61,7 @@ goog.testing.messaging.MockMessageChannel.prototype.send = function(
/**
* Sets a flag indicating that this is disposed.
+ * @override
*/
goog.testing.messaging.MockMessageChannel.prototype.dispose = function() {
this.disposed = true;
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/messaging/mockportnetwork.js b/contexts/data/lib/closure-library/closure/goog/testing/messaging/mockportnetwork.js
index bdccebf..692494c 100644
--- a/contexts/data/lib/closure-library/closure/goog/testing/messaging/mockportnetwork.js
+++ b/contexts/data/lib/closure-library/closure/goog/testing/messaging/mockportnetwork.js
@@ -54,6 +54,7 @@ goog.testing.messaging.MockPortNetwork = function(mockControl) {
* Get the mock port with the given name.
* @param {string} name The name of the port to get.
* @return {!goog.testing.messaging.MockMessageChannel} The mock port.
+ * @override
*/
goog.testing.messaging.MockPortNetwork.prototype.dial = function(name) {
if (!(name in this.ports_)) {
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/mock.js b/contexts/data/lib/closure-library/closure/goog/testing/mock.js
index 2312cc5..c0c62f0 100644
--- a/contexts/data/lib/closure-library/closure/goog/testing/mock.js
+++ b/contexts/data/lib/closure-library/closure/goog/testing/mock.js
@@ -39,6 +39,7 @@ goog.provide('goog.testing.Mock');
goog.provide('goog.testing.MockExpectation');
goog.require('goog.array');
+goog.require('goog.object');
goog.require('goog.testing.JsUnitException');
goog.require('goog.testing.MockInterface');
goog.require('goog.testing.mockmatchers');
@@ -210,6 +211,25 @@ goog.testing.Mock.STRICT = 0;
/**
+ * This array contains the name of the functions that are part of the base
+ * Object prototype.
+ * Basically a copy of goog.object.PROTOTYPE_FIELDS_.
+ * @const
+ * @type {!Array.<string>}
+ * @private
+ */
+goog.testing.Mock.PROTOTYPE_FIELDS_ = [
+ 'constructor',
+ 'hasOwnProperty',
+ 'isPrototypeOf',
+ 'propertyIsEnumerable',
+ 'toLocaleString',
+ 'toString',
+ 'valueOf'
+];
+
+
+/**
* A proxy for the mock. This can be used for dependency injection in lieu of
* the mock if the test requires a strict instanceof check.
* @type {Object}
@@ -256,8 +276,25 @@ goog.testing.Mock.prototype.$threwException_ = null;
* @private
*/
goog.testing.Mock.prototype.$initializeFunctions_ = function(objectToMock) {
- // TODO (arv): Implement goog.object.getIterator and replace this loop.
- for (var prop in objectToMock) {
+ // Gets the object properties.
+ var enumerableProperties = goog.object.getKeys(objectToMock);
+
+ // The non enumerable properties are added if they override the ones in the
+ // Object prototype. This is due to the fact that IE8 does not enumerate any
+ // of the prototype Object functions even when overriden and mocking these is
+ // sometimes needed.
+ for (var i = 0; i < goog.testing.Mock.PROTOTYPE_FIELDS_.length; i++) {
+ var prop = goog.testing.Mock.PROTOTYPE_FIELDS_[i];
+ // Look at b/6758711 if you're considering adding ALL properties to ALL
+ // mocks.
+ if (objectToMock[prop] !== Object.prototype[prop]) {
+ enumerableProperties.push(prop);
+ }
+ }
+
+ // Adds the properties to the mock.
+ for (var i = 0; i < enumerableProperties.length; i++) {
+ var prop = enumerableProperties[i];
if (typeof objectToMock[prop] == 'function') {
this[prop] = goog.bind(this.$mockMethod, this, prop);
if (this.$proxy) {
@@ -442,6 +479,7 @@ goog.testing.Mock.prototype.$times = function(times) {
/**
* Switches from recording to replay mode.
+ * @override
*/
goog.testing.Mock.prototype.$replay = function() {
this.$recording_ = false;
@@ -451,6 +489,7 @@ goog.testing.Mock.prototype.$replay = function() {
/**
* Resets the state of this mock object. This clears all pending expectations
* without verifying, and puts the mock in recording mode.
+ * @override
*/
goog.testing.Mock.prototype.$reset = function() {
this.$recording_ = true;
@@ -500,6 +539,7 @@ goog.testing.Mock.prototype.$recordAndThrow = function(ex) {
/**
* Verify that all of the expectations were met. Should be overridden by
* subclasses.
+ * @override
*/
goog.testing.Mock.prototype.$verify = function() {
if (this.$threwException_) {
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/mock_test.html b/contexts/data/lib/closure-library/closure/goog/testing/mock_test.html
index be592a6..2e8c6ec 100644
--- a/contexts/data/lib/closure-library/closure/goog/testing/mock_test.html
+++ b/contexts/data/lib/closure-library/closure/goog/testing/mock_test.html
@@ -14,6 +14,7 @@ See the COPYING file for details.
goog.require('goog.array');
goog.require('goog.object');
goog.require('goog.testing.Mock');
+ goog.require('goog.testing.MockControl');
goog.require('goog.testing.MockExpectation');
goog.require('goog.testing.jsunit');
</script>
@@ -208,6 +209,56 @@ See the COPYING file for details.
'Next expected call was to fn2(number)', msg);
}
+ // This tests that base Object functions which are not enumerable in IE can
+ // be mocked correctly.
+ function testBindNonEnumerableFunctions() {
+ // Create Foo and override non enumerable functions.
+ var Foo = function() {};
+ Foo.prototype.constructor = function() {
+ fail('real object should never be called');
+ };
+ Foo.prototype.hasOwnProperty = function() {
+ fail('real object should never be called');
+ };
+ Foo.prototype.isPrototypeOf = function() {
+ fail('real object should never be called');
+ };
+ Foo.prototype.propertyIsEnumerable = function() {
+ fail('real object should never be called');
+ };
+ Foo.prototype.toLocaleString = function() {
+ fail('real object should never be called');
+ };
+ Foo.prototype.toString = function() {
+ fail('real object should never be called');
+ };
+ Foo.prototype.valueOf = function() {
+ fail('real object should never be called');
+ };
+
+ // Create Mock and set $returns for toString.
+ var mockControl = new goog.testing.MockControl();
+ var mock = mockControl.createLooseMock(Foo);
+ mock.constructor().$returns('constructor');
+ mock.hasOwnProperty().$returns('hasOwnProperty');
+ mock.isPrototypeOf().$returns('isPrototypeOf');
+ mock.propertyIsEnumerable().$returns('propertyIsEnumerable');
+ mock.toLocaleString().$returns('toLocaleString');
+ mock.toString().$returns('toString');
+ mock.valueOf().$returns('valueOf');
+
+ // Execute and assert that the Mock is working correctly.
+ mockControl.$replayAll();
+ assertEquals('constructor', mock.constructor());
+ assertEquals('hasOwnProperty', mock.hasOwnProperty());
+ assertEquals('isPrototypeOf', mock.isPrototypeOf());
+ assertEquals('propertyIsEnumerable', mock.propertyIsEnumerable());
+ assertEquals('toLocaleString', mock.toLocaleString());
+ assertEquals('toString', mock.toString());
+ assertEquals('valueOf', mock.valueOf());
+ mockControl.$verifyAll();
+ }
+
</script>
</body>
</html>
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/mockclock.js b/contexts/data/lib/closure-library/closure/goog/testing/mockclock.js
index 30b62bc..5212c12 100644
--- a/contexts/data/lib/closure-library/closure/goog/testing/mockclock.js
+++ b/contexts/data/lib/closure-library/closure/goog/testing/mockclock.js
@@ -25,6 +25,8 @@ goog.provide('goog.testing.MockClock');
goog.require('goog.Disposable');
goog.require('goog.testing.PropertyReplacer');
+goog.require('goog.testing.events');
+goog.require('goog.testing.events.Event');
@@ -87,6 +89,15 @@ goog.inherits(goog.testing.MockClock, goog.Disposable);
/**
+ * Default wait timeout for mocking requestAnimationFrame (in milliseconds).
+ *
+ * @type {number}
+ * @const
+ */
+goog.testing.MockClock.REQUEST_ANIMATION_FRAME_TIMEOUT = 20;
+
+
+/**
* Count of the number of timeouts made.
* @type {number}
* @private
@@ -132,16 +143,19 @@ goog.testing.MockClock.prototype.timeoutDelay_ = 0;
/**
- * Installs the MockClock by overriding the window object's implementation of
+ * Installs the MockClock by overriding the global object's implementation of
* setTimeout, setInterval, clearTimeout and clearInterval.
*/
goog.testing.MockClock.prototype.install = function() {
if (!this.replacer_) {
var r = this.replacer_ = new goog.testing.PropertyReplacer();
- r.set(window, 'setTimeout', goog.bind(this.setTimeout_, this));
- r.set(window, 'setInterval', goog.bind(this.setInterval_, this));
- r.set(window, 'clearTimeout', goog.bind(this.clearTimeout_, this));
- r.set(window, 'clearInterval', goog.bind(this.clearInterval_, this));
+ r.set(goog.global, 'setTimeout', goog.bind(this.setTimeout_, this));
+ r.set(goog.global, 'setInterval', goog.bind(this.setInterval_, this));
+ r.set(goog.global, 'clearTimeout', goog.bind(this.clearTimeout_, this));
+ r.set(goog.global, 'clearInterval', goog.bind(this.clearInterval_, this));
+
+ // Replace the requestAnimationFrame functions.
+ this.replaceRequestAnimationFrame_();
// PropertyReplacer#set can't be called with renameable functions.
this.oldGoogNow_ = goog.now;
@@ -151,8 +165,42 @@ goog.testing.MockClock.prototype.install = function() {
/**
- * Removes the MockClock's hooks into the window functions and revert to their
- * original values.
+ * Installs the mocks for requestAnimationFrame and cancelRequestAnimationFrame.
+ * @private
+ */
+goog.testing.MockClock.prototype.replaceRequestAnimationFrame_ = function() {
+ var r = this.replacer_;
+ var requestFuncs = ['requestAnimationFrame',
+ 'webkitRequestAnimationFrame',
+ 'mozRequestAnimationFrame',
+ 'oRequestAnimationFrame',
+ 'msRequestAnimationFrame'];
+
+ var cancelFuncs = ['cancelRequestAnimationFrame',
+ 'webkitCancelRequestAnimationFrame',
+ 'mozCancelRequestAnimationFrame',
+ 'oCancelRequestAnimationFrame',
+ 'msCancelRequestAnimationFrame'];
+
+ for (var i = 0; i < requestFuncs.length; ++i) {
+ if (goog.global && goog.global[requestFuncs[i]]) {
+ r.set(goog.global, requestFuncs[i],
+ goog.bind(this.requestAnimationFrame_, this));
+ }
+ }
+
+ for (var i = 0; i < cancelFuncs.length; ++i) {
+ if (goog.global && goog.global[cancelFuncs[i]]) {
+ r.set(goog.global, cancelFuncs[i],
+ goog.bind(this.cancelRequestAnimationFrame_, this));
+ }
+ }
+};
+
+
+/**
+ * Removes the MockClock's hooks into the global object's functions and revert
+ * to their original values.
*/
goog.testing.MockClock.prototype.uninstall = function() {
if (this.replacer_) {
@@ -354,7 +402,7 @@ goog.testing.MockClock.MAX_INT_ = 2147483647;
/**
* Schedules a function to be called after {@code millis} milliseconds.
- * Mock implementation for window.setTimeout
+ * Mock implementation for setTimeout.
* @param {Function} funcToCall The function to call.
* @param {number} millis The number of milliseconds to call it after.
* @return {number} The number of timeouts created.
@@ -375,7 +423,7 @@ goog.testing.MockClock.prototype.setTimeout_ = function(funcToCall, millis) {
/**
* Schedules a function to be called every {@code millis} milliseconds.
- * Mock implementation for window.setInterval
+ * Mock implementation for setInterval.
* @param {Function} funcToCall The function to call.
* @param {number} millis The number of milliseconds between calls.
* @return {number} The number of timeouts created.
@@ -389,22 +437,70 @@ goog.testing.MockClock.prototype.setInterval_ = function(funcToCall, millis) {
/**
+ * Schedules a function to be called when an animation frame is triggered.
+ * Mock implementation for requestAnimationFrame.
+ * @param {Function} funcToCall The function to call.
+ * @return {number} The number of timeouts created.
+ * @private
+ */
+goog.testing.MockClock.prototype.requestAnimationFrame_ = function(funcToCall) {
+ return this.setTimeout_(goog.bind(function() {
+ if (funcToCall) {
+ funcToCall(this.getCurrentTime());
+ } else if (goog.global.mozRequestAnimationFrame) {
+ var event = new goog.testing.events.Event('MozBeforePaint', goog.global);
+ event['timeStamp'] = this.getCurrentTime();
+ goog.testing.events.fireBrowserEvent(event);
+ }
+ }, this), goog.testing.MockClock.REQUEST_ANIMATION_FRAME_TIMEOUT);
+};
+
+
+/**
* Clears a timeout.
- * Mock implementation for window.clearTimeout
+ * Mock implementation for clearTimeout.
* @param {number} timeoutKey The timeout key to clear.
* @private
*/
goog.testing.MockClock.prototype.clearTimeout_ = function(timeoutKey) {
- this.deletedKeys_[timeoutKey] = true;
+ // Some common libraries register static state with timers.
+ // This is bad. It leads to all sorts of crazy test problems where
+ // 1) Test A sets up a new mock clock and a static timer.
+ // 2) Test B sets up a new mock clock, but re-uses the static timer
+ // from Test A.
+ // 3) A timeout key from test A gets cleared, breaking a timeout in
+ // Test B.
+ //
+ // For now, we just hackily fail silently if someone tries to clear a timeout
+ // key before we've allocated it.
+ // Ideally, we should throw an exception if we see this happening.
+ //
+ // TODO(user): We might also try allocating timeout ids from a global
+ // pool rather than a local pool.
+ if (this.isTimeoutSet(timeoutKey)) {
+ this.deletedKeys_[timeoutKey] = true;
+ }
};
/**
* Clears an interval.
- * Mock implementation for window.clearInterval
+ * Mock implementation for clearInterval.
* @param {number} timeoutKey The interval key to clear.
* @private
*/
goog.testing.MockClock.prototype.clearInterval_ = function(timeoutKey) {
- this.deletedKeys_[timeoutKey] = true;
+ this.clearTimeout_(timeoutKey);
+};
+
+
+/**
+ * Clears a requestAnimationFrame.
+ * Mock implementation for cancelRequestAnimationFrame.
+ * @param {number} timeoutKey The requestAnimationFrame key to clear.
+ * @private
+ */
+goog.testing.MockClock.prototype.cancelRequestAnimationFrame_ =
+ function(timeoutKey) {
+ this.clearTimeout_(timeoutKey);
};
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/mockclock_test.html b/contexts/data/lib/closure-library/closure/goog/testing/mockclock_test.html
index f168f83..39e367f 100644
--- a/contexts/data/lib/closure-library/closure/goog/testing/mockclock_test.html
+++ b/contexts/data/lib/closure-library/closure/goog/testing/mockclock_test.html
@@ -11,13 +11,21 @@ See the COPYING file for details.
<title>Closure Unit Tests - goog.testing.MockClock</title>
<script src="../base.js"></script>
<script>
+ goog.require('goog.events');
goog.require('goog.functions');
goog.require('goog.testing.MockClock');
+ goog.require('goog.testing.PropertyReplacer');
goog.require('goog.testing.jsunit');
+ goog.require('goog.testing.recordFunction');
</script>
</head>
<body>
<script>
+ var stubs = new goog.testing.PropertyReplacer();
+
+ function tearDown() {
+ stubs.reset();
+ }
function testMockClockWasInstalled() {
var clock = new goog.testing.MockClock();
@@ -107,6 +115,28 @@ See the COPYING file for details.
}
+ function testRequestAnimationFrame() {
+ goog.global.requestAnimationFrame = function () {
+ };
+ var clock = new goog.testing.MockClock(true);
+ var times = [];
+ var recFunc = goog.testing.recordFunction(function(now) {
+ times.push(now);
+ });
+ goog.global.requestAnimationFrame(recFunc);
+ clock.tick(50);
+ assertEquals(1, recFunc.getCallCount());
+ assertEquals(20, times[0]);
+
+ goog.global.requestAnimationFrame(recFunc);
+ clock.tick(100);
+ assertEquals(2, recFunc.getCallCount());
+ assertEquals(70, times[1]);
+
+ clock.uninstall();
+ }
+
+
function testClearTimeout() {
var clock = new goog.testing.MockClock(true);
var ran = false;
@@ -167,6 +197,23 @@ See the COPYING file for details.
}
+ function testCancelRequestAnimationFrame() {
+ goog.global.requestAnimationFrame = function () {
+ };
+ goog.global.cancelRequestAnimationFrame = function () {
+ };
+ var clock = new goog.testing.MockClock(true);
+ var ran = false;
+ var c = goog.global.requestAnimationFrame(function() { ran = true; });
+ clock.tick(10);
+ assertFalse(ran);
+ goog.global.cancelRequestAnimationFrame(c);
+ clock.tick(20);
+ assertFalse(ran);
+ clock.uninstall();
+ }
+
+
function testMockGoogNow() {
assertNotEquals(0, goog.now());
var clock = new goog.testing.MockClock(true);
@@ -392,20 +439,48 @@ See the COPYING file for details.
}
function testCorrectSetTimeoutIsRestored() {
- var original = window.setTimeout;
var safe = goog.functions.error('should not have been called');
- try {
- window.setTimeout = safe;
- var clock = new goog.testing.MockClock(true);
- assertNotEquals('setTimeout is replaced', safe, window.setTimeout);
- clock.uninstall();
- // NOTE: If this assertion proves to be flaky in IE, the string value of
- // the two functions have to be compared as described in
- // goog.testing.TestCase#finalize.
- assertEquals('setTimeout is restored', safe, window.setTimeout);
- } finally {
- window.setTimeout = original;
- }
+ stubs.set(window, 'setTimeout', safe);
+
+ var clock = new goog.testing.MockClock(true);
+ assertNotEquals('setTimeout is replaced', safe, window.setTimeout);
+ clock.uninstall();
+ // NOTE: If this assertion proves to be flaky in IE, the string value of
+ // the two functions have to be compared as described in
+ // goog.testing.TestCase#finalize.
+ assertEquals('setTimeout is restored', safe, window.setTimeout);
+ }
+
+ function testMozRequestAnimationFrame() {
+ // Setting this function will indirectly tell the mock clock to mock it out.
+ stubs.set(window, 'mozRequestAnimationFrame', goog.nullFunction);
+
+ var clock = new goog.testing.MockClock(true);
+
+ var mozBeforePaint = goog.testing.recordFunction();
+ goog.events.listen(window, 'MozBeforePaint', mozBeforePaint);
+
+ window.mozRequestAnimationFrame(null);
+ assertEquals(0, mozBeforePaint.getCallCount());
+
+ clock.tick(goog.testing.MockClock.REQUEST_ANIMATION_FRAME_TIMEOUT);
+ assertEquals(1, mozBeforePaint.getCallCount());
+ clock.dispose();
+ }
+
+ function testClearBeforeSet() {
+ var clock = new goog.testing.MockClock(true);
+ var expectedId = 1;
+ window.clearTimeout(expectedId);
+
+ var fn = goog.testing.recordFunction();
+ var actualId = window.setTimeout(fn, 0);
+ assertEquals(
+ 'In order for this test to work, we have to guess the ids in advance',
+ expectedId, actualId);
+ clock.tick(1);
+ assertEquals(1, fn.getCallCount());
+ clock.dispose();
}
</script>
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/mockcontrol.js b/contexts/data/lib/closure-library/closure/goog/testing/mockcontrol.js
index b77e19a..937e79a 100644
--- a/contexts/data/lib/closure-library/closure/goog/testing/mockcontrol.js
+++ b/contexts/data/lib/closure-library/closure/goog/testing/mockcontrol.js
@@ -156,7 +156,7 @@ goog.testing.MockControl.prototype.createLooseMock = function(
* @param {string=} opt_functionName The optional name of the function to mock
* set to '[anonymous mocked function]' if not passed in.
* @param {number=} opt_strictness One of goog.testing.Mock.LOOSE or
- * goog.testing.mock.STRICT. The default is STRICT.
+ * goog.testing.Mock.STRICT. The default is STRICT.
* @return {goog.testing.MockInterface} The mocked function.
*/
goog.testing.MockControl.prototype.createFunctionMock = function(
@@ -173,7 +173,7 @@ goog.testing.MockControl.prototype.createFunctionMock = function(
* @param {Object} scope The scope of the method to be mocked out.
* @param {string} functionName The name of the function we're going to mock.
* @param {number=} opt_strictness One of goog.testing.Mock.LOOSE or
- * goog.testing.mock.STRICT. The default is STRICT.
+ * goog.testing.Mock.STRICT. The default is STRICT.
* @return {goog.testing.MockInterface} The mocked method.
*/
goog.testing.MockControl.prototype.createMethodMock = function(
@@ -191,7 +191,7 @@ goog.testing.MockControl.prototype.createMethodMock = function(
* @param {Object} scope The scope of the constructor to be mocked out.
* @param {string} constructorName The name of the function we're going to mock.
* @param {number=} opt_strictness One of goog.testing.Mock.LOOSE or
- * goog.testing.mock.STRICT. The default is STRICT.
+ * goog.testing.Mock.STRICT. The default is STRICT.
* @return {goog.testing.MockInterface} The mocked method.
*/
goog.testing.MockControl.prototype.createConstructorMock = function(
@@ -208,7 +208,7 @@ goog.testing.MockControl.prototype.createConstructorMock = function(
* GlobalFunctionMock constructor.
* @param {string} functionName The name of the function we're going to mock.
* @param {number=} opt_strictness One of goog.testing.Mock.LOOSE or
- * goog.testing.mock.STRICT. The default is STRICT.
+ * goog.testing.Mock.STRICT. The default is STRICT.
* @return {goog.testing.MockInterface} The mocked function.
*/
goog.testing.MockControl.prototype.createGlobalFunctionMock = function(
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/mockmatchers_test.html b/contexts/data/lib/closure-library/closure/goog/testing/mockmatchers_test.html
index c8a9e17..25c8747 100644
--- a/contexts/data/lib/closure-library/closure/goog/testing/mockmatchers_test.html
+++ b/contexts/data/lib/closure-library/closure/goog/testing/mockmatchers_test.html
@@ -120,9 +120,9 @@ See the COPYING file for details.
assertTrue(simpleMatcher.matches({name: 'Bob', age: 42}, mockExpect));
assertEquals(0, mockExpect.getErrorMessageCount());
expectObjectEqualsFailure(simpleMatcher, {name: 'Bill', age: 42},
- 'name expected <Bob> (String) but was <Bill> (String)');
+ 'name: Expected <Bob> (String) but was <Bill> (String)');
expectObjectEqualsFailure(simpleMatcher, {name: 'Bob', age: 21},
- 'age expected <42> (Number) but was <21> (Number)');
+ 'age: Expected <42> (Number) but was <21> (Number)');
expectObjectEqualsFailure(simpleMatcher, {name: 'Bob'},
'property age not present in actual Object');
expectObjectEqualsFailure(simpleMatcher,
@@ -131,8 +131,8 @@ See the COPYING file for details.
// Multiple mismatches should include multiple messages.
expectObjectEqualsFailure(simpleMatcher, {name: 'Jim', age: 36},
- 'name expected <Bob> (String) but was <Jim> (String)\n' +
- ' age expected <42> (Number) but was <36> (Number)');
+ 'name: Expected <Bob> (String) but was <Jim> (String)\n' +
+ ' age: Expected <42> (Number) but was <36> (Number)');
}
function testComplexObjectEquals() {
@@ -142,10 +142,10 @@ See the COPYING file for details.
{a: 'foo', b: 2, c: ['bar', 3], d: {sub1: 'baz', sub2: -1}}));
expectObjectEqualsFailure(complexMatcher,
{a: 'foo', b: 2, c: ['bar', 3], d: {sub1: 'zap', sub2: -1}},
- 'sub1 expected <baz> (String) but was <zap> (String)');
+ 'sub1: Expected <baz> (String) but was <zap> (String)');
expectObjectEqualsFailure(complexMatcher,
{a: 'foo', b: 2, c: ['bar', 6], d: {sub1: 'baz', sub2: -1}},
- 'c[1] expected <3> (Number) but was <6> (Number)');
+ 'c[1]: Expected <3> (Number) but was <6> (Number)');
}
@@ -344,7 +344,7 @@ See the COPYING file for details.
assertEquals(1, mockExpect.errorMessages.length);
assertEquals(
'Expected <anything> (String) but was <12345> (Number)\n' +
- ' expected <anything> (String) but was <12345> (Number)',
+ ' Expected <anything> (String) but was <12345> (Number)',
mockExpect.errorMessages[0]);
// And test we report errors found via the matcher
@@ -357,7 +357,7 @@ See the COPYING file for details.
assertEquals(2, mockExpect.errorMessages.length);
assertEquals(
'Expected <anything> (String) but was <12345> (Number)\n' +
- ' expected <anything> (String) but was <12345> (Number)',
+ ' Expected <anything> (String) but was <12345> (Number)',
mockExpect.errorMessages[0]);
// plus the new error...
assertEquals("Expected: isString but was: <null>",
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/mockrange.js b/contexts/data/lib/closure-library/closure/goog/testing/mockrange.js
index a49389d..06a3b72 100644
--- a/contexts/data/lib/closure-library/closure/goog/testing/mockrange.js
+++ b/contexts/data/lib/closure-library/closure/goog/testing/mockrange.js
@@ -59,7 +59,8 @@ goog.inherits(goog.testing.MockRange.ConcreteRange_, goog.dom.AbstractRange);
/**
* Undefine the iterator so the mock framework can loop through this class'
* properties.
- * @type {undefined}
* @override
*/
-goog.testing.MockRange.ConcreteRange_.prototype.__iterator__ = undefined;
+goog.testing.MockRange.ConcreteRange_.prototype.__iterator__ =
+ // This isn't really type-safe.
+ /** @type {?} */ (undefined);
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/mockstorage.js b/contexts/data/lib/closure-library/closure/goog/testing/mockstorage.js
index 2d191ab..9125dca 100644
--- a/contexts/data/lib/closure-library/closure/goog/testing/mockstorage.js
+++ b/contexts/data/lib/closure-library/closure/goog/testing/mockstorage.js
@@ -52,6 +52,7 @@ goog.testing.MockStorage = function() {
* Sets an item to the storage.
* @param {string} key Storage key.
* @param {*} value Storage value. Must be convertible to string.
+ * @override
*/
goog.testing.MockStorage.prototype.setItem = function(key, value) {
this.store_.set(key, String(value));
@@ -65,6 +66,7 @@ goog.testing.MockStorage.prototype.setItem = function(key, value) {
* string.
* @param {string} key Storage key.
* @return {?string} Storage value for key; null if does not exist.
+ * @override
*/
goog.testing.MockStorage.prototype.getItem = function(key) {
var val = this.store_.get(key);
@@ -76,6 +78,7 @@ goog.testing.MockStorage.prototype.getItem = function(key) {
/**
* Removes and item from the storage.
* @param {string} key Storage key.
+ * @override
*/
goog.testing.MockStorage.prototype.removeItem = function(key) {
this.store_.remove(key);
@@ -85,6 +88,7 @@ goog.testing.MockStorage.prototype.removeItem = function(key) {
/**
* Clears the storage.
+ * @override
*/
goog.testing.MockStorage.prototype.clear = function() {
this.store_.clear();
@@ -96,6 +100,7 @@ goog.testing.MockStorage.prototype.clear = function() {
* Returns the key at the given index.
* @param {number} index The index for the key.
* @return {?string} Key at the given index, null if not found.
+ * @override
*/
goog.testing.MockStorage.prototype.key = function(index) {
return this.store_.getKeys()[index] || null;
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/multitestrunner.js b/contexts/data/lib/closure-library/closure/goog/testing/multitestrunner.js
index 4c94b95..c6040a1 100644
--- a/contexts/data/lib/closure-library/closure/goog/testing/multitestrunner.js
+++ b/contexts/data/lib/closure-library/closure/goog/testing/multitestrunner.js
@@ -845,8 +845,8 @@ goog.testing.MultiTestRunner.prototype.drawTimeHistogram_ = function() {
* Draws a stats histogram.
* @param {string} statsField Field of the stats object to graph.
* @param {number} bucketSize The size for the histogram's buckets.
- * @param {function(*, ...[*]): *} valueTransformFn Function for transforming
- * the x-labels value for display.
+ * @param {function(number, ...[*]): *} valueTransformFn Function for
+ * transforming the x-labels value for display.
* @param {number} width The width in pixels of the graph.
* @param {string} title The graph's title.
* @private
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/net/.svn/all-wcprops b/contexts/data/lib/closure-library/closure/goog/testing/net/.svn/all-wcprops
deleted file mode 100644
index 3d148e1..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/net/.svn/all-wcprops
+++ /dev/null
@@ -1,23 +0,0 @@
-K 25
-svn:wc:ra_dav:version-url
-V 49
-/svn/!svn/ver/1336/trunk/closure/goog/testing/net
-END
-xhrio.js
-K 25
-svn:wc:ra_dav:version-url
-V 58
-/svn/!svn/ver/1336/trunk/closure/goog/testing/net/xhrio.js
-END
-xhrio_test.html
-K 25
-svn:wc:ra_dav:version-url
-V 65
-/svn/!svn/ver/1328/trunk/closure/goog/testing/net/xhrio_test.html
-END
-xhriopool.js
-K 25
-svn:wc:ra_dav:version-url
-V 62
-/svn/!svn/ver/1302/trunk/closure/goog/testing/net/xhriopool.js
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/net/.svn/entries b/contexts/data/lib/closure-library/closure/goog/testing/net/.svn/entries
deleted file mode 100644
index 02619c1..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/net/.svn/entries
+++ /dev/null
@@ -1,130 +0,0 @@
-10
-
-dir
-1494
-http://closure-library.googlecode.com/svn/trunk/closure/goog/testing/net
-http://closure-library.googlecode.com/svn
-
-
-
-2011-10-13T12:17:51.000000Z
-1336
-johnmaguire@google.com
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-0b95b8e8-c90f-11de-9d4f-f947ee5921c8
-
-xhrio.js
-file
-
-
-
-
-2011-12-23T22:42:27.184314Z
-68d12c11c2851f9a9ab465f822fc0275
-2011-10-13T12:17:51.000000Z
-1336
-johnmaguire@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-18513
-
-xhrio_test.html
-file
-
-
-
-
-2011-12-23T22:42:27.185314Z
-748b125cca9cacb7d0b03e612c897ef5
-2011-10-10T15:03:56.000000Z
-1328
-pallosp@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-12935
-
-xhriopool.js
-file
-
-
-
-
-2011-12-23T22:42:27.186314Z
-e9ffd523aee7b86f871d24e0feceb6cf
-2011-09-27T00:20:47.000000Z
-1302
-bmccann@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-1726
-
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/net/.svn/prop-base/xhrio.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/net/.svn/prop-base/xhrio.js.svn-base
deleted file mode 100644
index 530636b..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/net/.svn/prop-base/xhrio.js.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 15
-text/javascript
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/net/.svn/prop-base/xhrio_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/net/.svn/prop-base/xhrio_test.html.svn-base
deleted file mode 100644
index d356868..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/net/.svn/prop-base/xhrio_test.html.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 9
-text/html
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/net/.svn/prop-base/xhriopool.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/net/.svn/prop-base/xhriopool.js.svn-base
deleted file mode 100644
index 530636b..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/net/.svn/prop-base/xhriopool.js.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 15
-text/javascript
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/net/.svn/text-base/xhrio.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/net/.svn/text-base/xhrio.js.svn-base
deleted file mode 100644
index f08f3e3..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/net/.svn/text-base/xhrio.js.svn-base
+++ /dev/null
@@ -1,671 +0,0 @@
-// Copyright 2007 The Closure Library Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS-IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/**
- * @fileoverview Mock of XhrIo for unit testing.
- */
-
-goog.provide('goog.testing.net.XhrIo');
-
-goog.require('goog.array');
-goog.require('goog.dom.xml');
-goog.require('goog.events');
-goog.require('goog.events.EventTarget');
-goog.require('goog.json');
-goog.require('goog.net.ErrorCode');
-goog.require('goog.net.EventType');
-goog.require('goog.net.HttpStatus');
-goog.require('goog.net.XhrIo.ResponseType');
-goog.require('goog.net.XmlHttp');
-goog.require('goog.object');
-goog.require('goog.structs.Map');
-goog.require('goog.uri.utils');
-
-
-
-/**
- * Mock implementation of goog.net.XhrIo. This doesn't provide a mock
- * implementation for all cases, but it's not too hard to add them as needed.
- * @param {goog.testing.TestQueue=} opt_testQueue Test queue for inserting test
- * events.
- * @constructor
- * @extends {goog.events.EventTarget}
- */
-goog.testing.net.XhrIo = function(opt_testQueue) {
- goog.events.EventTarget.call(this);
-
- /**
- * Map of default headers to add to every request, use:
- * XhrIo.headers.set(name, value)
- * @type {goog.structs.Map}
- */
- this.headers = new goog.structs.Map();
-
- /**
- * Queue of events write to.
- * @type {goog.testing.TestQueue?}
- * @private
- */
- this.testQueue_ = opt_testQueue || null;
-};
-goog.inherits(goog.testing.net.XhrIo, goog.events.EventTarget);
-
-
-/**
- * All non-disposed instances of goog.testing.net.XhrIo created
- * by {@link goog.testing.net.XhrIo.send} are in this Array.
- * @see goog.testing.net.XhrIo.cleanup
- * @type {Array.<goog.testing.net.XhrIo>}
- * @private
- */
-goog.testing.net.XhrIo.sendInstances_ = [];
-
-
-/**
- * Returns an Array containing all non-disposed instances of
- * goog.testing.net.XhrIo created by {@link goog.testing.net.XhrIo.send}.
- * @return {Array} Array of goog.testing.net.XhrIo instances.
- */
-goog.testing.net.XhrIo.getSendInstances = function() {
- return goog.testing.net.XhrIo.sendInstances_;
-};
-
-
-/**
- * Disposes all non-disposed instances of goog.testing.net.XhrIo created by
- * {@link goog.testing.net.XhrIo.send}.
- * @see goog.net.XhrIo.cleanup
- */
-goog.testing.net.XhrIo.cleanup = function() {
- var instances = goog.testing.net.XhrIo.sendInstances_;
- while (instances.length) {
- instances.pop().dispose();
- }
-};
-
-
-/**
- * Simulates the static XhrIo send method.
- * @param {string} url Uri to make request to.
- * @param {Function=} opt_callback Callback function for when request is
- * complete.
- * @param {string=} opt_method Send method, default: GET.
- * @param {string=} opt_content Post data.
- * @param {Object|goog.structs.Map=} opt_headers Map of headers to add to the
- * request.
- * @param {number=} opt_timeoutInterval Number of milliseconds after which an
- * incomplete request will be aborted; 0 means no timeout is set.
- */
-goog.testing.net.XhrIo.send = function(url, opt_callback, opt_method,
- opt_content, opt_headers,
- opt_timeoutInterval) {
- var x = new goog.testing.net.XhrIo();
- goog.testing.net.XhrIo.sendInstances_.push(x);
- if (opt_callback) {
- goog.events.listen(x, goog.net.EventType.COMPLETE, opt_callback);
- }
- goog.events.listen(x,
- goog.net.EventType.READY,
- goog.partial(goog.testing.net.XhrIo.cleanupSend_, x));
- if (opt_timeoutInterval) {
- x.setTimeoutInterval(opt_timeoutInterval);
- }
- x.send(url, opt_method, opt_content, opt_headers);
-};
-
-
-/**
- * Disposes of the specified goog.testing.net.XhrIo created by
- * {@link goog.testing.net.XhrIo.send} and removes it from
- * {@link goog.testing.net.XhrIo.pendingStaticSendInstances_}.
- * @param {goog.testing.net.XhrIo} XhrIo An XhrIo created by
- * {@link goog.testing.net.XhrIo.send}.
- * @private
- */
-goog.testing.net.XhrIo.cleanupSend_ = function(XhrIo) {
- XhrIo.dispose();
- goog.array.remove(goog.testing.net.XhrIo.sendInstances_, XhrIo);
-};
-
-
-/**
- * Stores the simulated response headers for the requests which are sent through
- * this XhrIo.
- * @type {Object}
- * @private
- */
-goog.testing.net.XhrIo.prototype.responseHeaders_;
-
-
-/**
- * Whether MockXhrIo is active.
- * @type {boolean}
- * @private
- */
-goog.testing.net.XhrIo.prototype.active_ = false;
-
-
-/**
- * Last URI that was requested.
- * @type {string}
- * @private
- */
-goog.testing.net.XhrIo.prototype.lastUri_ = '';
-
-
-/**
- * Last HTTP method that was requested.
- * @type {string|undefined}
- * @private
- */
-goog.testing.net.XhrIo.prototype.lastMethod_;
-
-
-/**
- * Last POST content that was requested.
- * @type {string|undefined}
- * @private
- */
-goog.testing.net.XhrIo.prototype.lastContent_;
-
-
-/**
- * Additional headers that were requested in the last query.
- * @type {Object|goog.structs.Map|undefined}
- * @private
- */
-goog.testing.net.XhrIo.prototype.lastHeaders_;
-
-
-/**
- * Last error code.
- * @type {goog.net.ErrorCode}
- * @private
- */
-goog.testing.net.XhrIo.prototype.lastErrorCode_ =
- goog.net.ErrorCode.NO_ERROR;
-
-
-/**
- * Last error message.
- * @type {string}
- * @private
- */
-goog.testing.net.XhrIo.prototype.lastError_ = '';
-
-
-/**
- * The response object.
- * @type {string|Document}
- * @private
- */
-goog.testing.net.XhrIo.prototype.response_ = '';
-
-
-/**
- * Mock ready state.
- * @type {number}
- * @private
- */
-goog.testing.net.XhrIo.prototype.readyState_ =
- goog.net.XmlHttp.ReadyState.UNINITIALIZED;
-
-
-/**
- * Number of milliseconds after which an incomplete request will be aborted and
- * a {@link goog.net.EventType.TIMEOUT} event raised; 0 means no timeout is set.
- * @type {number}
- * @private
- */
-goog.testing.net.XhrIo.prototype.timeoutInterval_ = 0;
-
-
-/**
- * Window timeout ID used to cancel the timeout event handler if the request
- * completes successfully.
- * @type {Object}
- * @private
- */
-goog.testing.net.XhrIo.prototype.timeoutId_ = null;
-
-
-/**
- * The requested type for the response. The empty string means use the default
- * XHR behavior.
- * @type {goog.net.XhrIo.ResponseType}
- * @private
- */
-goog.testing.net.XhrIo.prototype.responseType_ =
- goog.net.XhrIo.ResponseType.DEFAULT;
-
-
-/**
- * Whether a "credentialed" request is to be sent (one that is aware of cookies
- * and authentication) . This is applicable only for cross-domain requests and
- * more recent browsers that support this part of the HTTP Access Control
- * standard.
- *
- * @see http://dev.w3.org/2006/webapi/XMLHttpRequest-2/#withcredentials
- *
- * @type {boolean}
- * @private
- */
-goog.testing.net.XhrIo.prototype.withCredentials_ = false;
-
-
-/**
- * Whether there's currently an underlying XHR object.
- * @type {boolean}
- * @private
- */
-goog.testing.net.XhrIo.prototype.xhr_ = false;
-
-
-/**
- * Returns the number of milliseconds after which an incomplete request will be
- * aborted, or 0 if no timeout is set.
- * @return {number} Timeout interval in milliseconds.
- */
-goog.testing.net.XhrIo.prototype.getTimeoutInterval = function() {
- return this.timeoutInterval_;
-};
-
-
-/**
- * Sets the number of milliseconds after which an incomplete request will be
- * aborted and a {@link goog.net.EventType.TIMEOUT} event raised; 0 means no
- * timeout is set.
- * @param {number} ms Timeout interval in milliseconds; 0 means none.
- */
-goog.testing.net.XhrIo.prototype.setTimeoutInterval = function(ms) {
- this.timeoutInterval_ = Math.max(0, ms);
-};
-
-
-/**
- * Causes timeout events to be fired.
- */
-goog.testing.net.XhrIo.prototype.simulateTimeout = function() {
- this.lastErrorCode_ = goog.net.ErrorCode.TIMEOUT;
- this.dispatchEvent(goog.net.EventType.TIMEOUT);
- this.abort(goog.net.ErrorCode.TIMEOUT);
-};
-
-
-/**
- * Sets the desired type for the response. At time of writing, this is only
- * supported in very recent versions of WebKit (10.0.612.1 dev and later).
- *
- * If this is used, the response may only be accessed via {@link #getResponse}.
- *
- * @param {goog.net.XhrIo.ResponseType} type The desired type for the response.
- */
-goog.testing.net.XhrIo.prototype.setResponseType = function(type) {
- this.responseType_ = type;
-};
-
-
-/**
- * Gets the desired type for the response.
- * @return {goog.net.XhrIo.ResponseType} The desired type for the response.
- */
-goog.testing.net.XhrIo.prototype.getResponseType = function() {
- return this.responseType_;
-};
-
-
-/**
- * Sets whether a "credentialed" request that is aware of cookie and
- * authentication information should be made. This option is only supported by
- * browsers that support HTTP Access Control. As of this writing, this option
- * is not supported in IE.
- *
- * @param {boolean} withCredentials Whether this should be a "credentialed"
- * request.
- */
-goog.testing.net.XhrIo.prototype.setWithCredentials =
- function(withCredentials) {
- this.withCredentials_ = withCredentials;
-};
-
-
-/**
- * Gets whether a "credentialed" request is to be sent.
- * @return {boolean} The desired type for the response.
- */
-goog.testing.net.XhrIo.prototype.getWithCredentials = function() {
- return this.withCredentials_;
-};
-
-
-/**
- * Abort the current XMLHttpRequest
- * @param {goog.net.ErrorCode=} opt_failureCode Optional error code to use -
- * defaults to ABORT.
- */
-goog.testing.net.XhrIo.prototype.abort = function(opt_failureCode) {
- if (this.active_) {
- try {
- this.active_ = false;
- this.lastErrorCode_ = opt_failureCode || goog.net.ErrorCode.ABORT;
- this.dispatchEvent(goog.net.EventType.COMPLETE);
- this.dispatchEvent(goog.net.EventType.ABORT);
- } finally {
- this.simulateReady();
- }
- }
-};
-
-
-/**
- * Simulates the XhrIo send.
- * @param {string} url Uri to make request too.
- * @param {string=} opt_method Send method, default: GET.
- * @param {string=} opt_content Post data.
- * @param {Object|goog.structs.Map=} opt_headers Map of headers to add to the
- * request.
- */
-goog.testing.net.XhrIo.prototype.send = function(url, opt_method, opt_content,
- opt_headers) {
- if (this.xhr_) {
- throw Error('[goog.net.XhrIo] Object is active with another request');
- }
-
- this.lastUri_ = url;
- this.lastMethod_ = opt_method || 'GET';
- this.lastContent_ = opt_content;
- this.lastHeaders_ = opt_headers;
-
- if (this.testQueue_) {
- this.testQueue_.enqueue(['s', url, opt_method, opt_content, opt_headers]);
- }
- this.xhr_ = true;
- this.active_ = true;
- this.readyState_ = goog.net.XmlHttp.ReadyState.UNINITIALIZED;
- this.simulateReadyStateChange(goog.net.XmlHttp.ReadyState.LOADING);
-};
-
-
-/**
- * Creates a new XHR object.
- * @return {XMLHttpRequest|GearsHttpRequest} The newly created XHR object.
- * @protected
- */
-goog.testing.net.XhrIo.prototype.createXhr = function() {
- return goog.net.XmlHttp();
-};
-
-
-/**
- * Simulates changing to the new ready state.
- * @param {number} readyState Ready state to change to.
- */
-goog.testing.net.XhrIo.prototype.simulateReadyStateChange =
- function(readyState) {
- if (readyState < this.readyState_) {
- throw Error('Readystate cannot go backwards');
- }
-
- while (this.readyState_ < readyState) {
- this.readyState_++;
- this.dispatchEvent(goog.net.EventType.READY_STATE_CHANGE);
-
- if (this.readyState_ == goog.net.XmlHttp.ReadyState.COMPLETE) {
- this.active_ = false;
- this.dispatchEvent(goog.net.EventType.COMPLETE);
- }
- }
-};
-
-
-/**
- * Simulates receiving a response.
- * @param {number} statusCode Simulated status code.
- * @param {string|Document|null} response Simulated response.
- * @param {Object=} opt_headers Simulated response headers.
- */
-goog.testing.net.XhrIo.prototype.simulateResponse = function(statusCode,
- response, opt_headers) {
- this.statusCode_ = statusCode;
- this.response_ = response || '';
- this.responseHeaders_ = opt_headers || {};
-
- try {
- if (this.isSuccess()) {
- this.simulateReadyStateChange(goog.net.XmlHttp.ReadyState.COMPLETE);
- this.dispatchEvent(goog.net.EventType.SUCCESS);
- } else {
- this.lastErrorCode_ = goog.net.ErrorCode.HTTP_ERROR;
- this.lastError_ = this.getStatusText() + ' [' + this.getStatus() + ']';
- this.simulateReadyStateChange(goog.net.XmlHttp.ReadyState.COMPLETE);
- this.dispatchEvent(goog.net.EventType.ERROR);
- }
- } finally {
- this.simulateReady();
- }
-};
-
-
-/**
- * Simulates the Xhr is ready for the next request.
- */
-goog.testing.net.XhrIo.prototype.simulateReady = function() {
- this.active_ = false;
- this.xhr_ = false;
- this.dispatchEvent(goog.net.EventType.READY);
-};
-
-
-/**
- * @return {boolean} Whether there is an active request.
- */
-goog.testing.net.XhrIo.prototype.isActive = function() {
- return !!this.xhr_;
-};
-
-
-/**
- * Has the request completed.
- * @return {boolean} Whether the request has completed.
- */
-goog.testing.net.XhrIo.prototype.isComplete = function() {
- return this.readyState_ == goog.net.XmlHttp.ReadyState.COMPLETE;
-};
-
-
-/**
- * Has the request compeleted with a success.
- * @return {boolean} Whether the request compeleted successfully.
- */
-goog.testing.net.XhrIo.prototype.isSuccess = function() {
- switch (this.getStatus()) {
- case goog.net.HttpStatus.OK:
- case goog.net.HttpStatus.NO_CONTENT:
- case goog.net.HttpStatus.NOT_MODIFIED:
- return true;
-
- default:
- return false;
- }
-};
-
-
-/**
- * Returns the readystate.
- * @return {number} goog.net.XmlHttp.ReadyState.*.
- */
-goog.testing.net.XhrIo.prototype.getReadyState = function() {
- return this.readyState_;
-};
-
-
-/**
- * Get the status from the Xhr object. Will only return correct result when
- * called from the context of a callback.
- * @return {number} Http status.
- */
-goog.testing.net.XhrIo.prototype.getStatus = function() {
- return this.statusCode_;
-};
-
-
-/**
- * Get the status text from the Xhr object. Will only return correct result
- * when called from the context of a callback.
- * @return {string} Status text.
- */
-goog.testing.net.XhrIo.prototype.getStatusText = function() {
- return '';
-};
-
-
-/**
- * Gets the last error message.
- * @return {goog.net.ErrorCode} Last error code.
- */
-goog.testing.net.XhrIo.prototype.getLastErrorCode = function() {
- return this.lastErrorCode_;
-};
-
-
-/**
- * Gets the last error message.
- * @return {string} Last error message.
- */
-goog.testing.net.XhrIo.prototype.getLastError = function() {
- return this.lastError_;
-};
-
-
-/**
- * Gets the last URI that was requested.
- * @return {string} Last URI.
- */
-goog.testing.net.XhrIo.prototype.getLastUri = function() {
- return this.lastUri_;
-};
-
-
-/**
- * Gets the last HTTP method that was requested.
- * @return {string|undefined} Last HTTP method used by send.
- */
-goog.testing.net.XhrIo.prototype.getLastMethod = function() {
- return this.lastMethod_;
-};
-
-
-/**
- * Gets the last POST content that was requested.
- * @return {string|undefined} Last POST content or undefined if last request was
- * a GET.
- */
-goog.testing.net.XhrIo.prototype.getLastContent = function() {
- return this.lastContent_;
-};
-
-
-/**
- * Gets the headers of the last request.
- * @return {Object|goog.structs.Map|undefined} Last headers manually set in send
- * call or undefined if no additional headers were specified.
- */
-goog.testing.net.XhrIo.prototype.getLastRequestHeaders = function() {
- return this.lastHeaders_;
-};
-
-
-/**
- * Gets the response text from the Xhr object. Will only return correct result
- * when called from the context of a callback.
- * @return {string} Result from the server.
- */
-goog.testing.net.XhrIo.prototype.getResponseText = function() {
- return goog.isString(this.response_) ? this.response_ :
- goog.dom.xml.serialize(this.response_);
-};
-
-
-/**
- * Gets the response and evaluates it as JSON from the Xhr object. Will only
- * return correct result when called from the context of a callback.
- * @param {string=} opt_xssiPrefix Optional XSSI prefix string to use for
- * stripping of the response before parsing. This needs to be set only if
- * your backend server prepends the same prefix string to the JSON response.
- * @return {Object} JavaScript object.
- */
-goog.testing.net.XhrIo.prototype.getResponseJson = function(opt_xssiPrefix) {
- var responseText = this.getResponseText();
- if (opt_xssiPrefix && responseText.indexOf(opt_xssiPrefix) == 0) {
- responseText = responseText.substring(opt_xssiPrefix.length);
- }
-
- return goog.json.parse(responseText);
-};
-
-
-/**
- * Gets the response XML from the Xhr object. Will only return correct result
- * when called from the context of a callback.
- * @return {Document} Result from the server if it was XML.
- */
-goog.testing.net.XhrIo.prototype.getResponseXml = function() {
- // NOTE(user): I haven't found out how to check in Internet Explorer
- // whether the response is XML document, so I do it the other way around.
- return goog.isString(this.response_) ? null : this.response_;
-};
-
-
-/**
- * Get the response as the type specificed by {@link #setResponseType}. At time
- * of writing, this is only supported in very recent versions of WebKit
- * (10.0.612.1 dev and later).
- *
- * @return {*} The response.
- */
-goog.testing.net.XhrIo.prototype.getResponse = function() {
- return this.response_;
-};
-
-
-/**
- * Get the value of the response-header with the given name from the Xhr object
- * Will only return correct result when called from the context of a callback
- * and the request has completed
- * @param {string} key The name of the response-header to retrieve.
- * @return {string|undefined} The value of the response-header named key.
- */
-goog.testing.net.XhrIo.prototype.getResponseHeader = function(key) {
- return this.isComplete() ? this.responseHeaders_[key] : undefined;
-};
-
-
-/**
- * Gets the text of all the headers in the response.
- * Will only return correct result when called from the context of a callback
- * and the request has completed
- * @return {string} The string containing all the response headers.
- */
-goog.testing.net.XhrIo.prototype.getAllResponseHeaders = function() {
- if (!this.isComplete()) {
- return '';
- }
-
- var headers = [];
- goog.object.forEach(this.responseHeaders_, function(value, name) {
- headers.push(name + ': ' + value);
- });
-
- return headers.join('\n');
-};
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/net/.svn/text-base/xhrio_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/net/.svn/text-base/xhrio_test.html.svn-base
deleted file mode 100644
index 109a4d5..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/net/.svn/text-base/xhrio_test.html.svn-base
+++ /dev/null
@@ -1,384 +0,0 @@
-<!DOCTYPE html>
-<html>
-<!--
-Copyright 2008 The Closure Library Authors. All Rights Reserved.
-
-Use of this source code is governed by the Apache License, Version 2.0.
-See the COPYING file for details.
--->
-<head>
-<meta http-equiv="X-UA-Compatible" content="IE=edge">
-<title>Closure Unit Tests - goog.testing.net.XhrIo</title>
-<script src="../../base.js"></script>
-<script>
- goog.require('goog.dom.xml');
- goog.require('goog.events');
- goog.require('goog.events.Event');
- goog.require('goog.net.EventType');
- goog.require('goog.testing.asserts');
- goog.require('goog.testing.jsunit');
- goog.require('goog.testing.net.XhrIo');
- goog.require('goog.testing.mockmatchers.InstanceOf');
- goog.require('goog.testing.MockControl');
-</script>
-</head>
-<body>
-<script>
-
-var mockControl;
-
-function setUp() {
- mockControl = new goog.testing.MockControl();
-}
-
-function testStaticSend() {
- sendInstances = goog.testing.net.XhrIo.getSendInstances();
- goog.testing.net.XhrIo.send('url');
- assertEquals('sendInstances_ after send',
- 1, sendInstances.length);
- xhr = sendInstances[sendInstances.length - 1];
- assertTrue('isActive after request', xhr.isActive());
- assertEquals('readyState after request',
- goog.net.XmlHttp.ReadyState.LOADING,
- xhr.getReadyState());
-
- xhr.simulateResponse(200, '');
- assertFalse('isActive after response', xhr.isActive());
- assertEquals('readyState after response',
- goog.net.XmlHttp.ReadyState.COMPLETE,
- xhr.getReadyState());
-
- xhr.simulateReady();
- assertEquals('sendInstances_ after READY',
- 0, sendInstances.length);
-}
-
-function testStaticSendWithException() {
- goog.testing.net.XhrIo.send('url', function() {
- if (!this.isSuccess()) {
- throw Error('The xhr did not complete successfully!');
- }
- });
- var sendInstances = goog.testing.net.XhrIo.getSendInstances();
- var xhr = sendInstances[sendInstances.length - 1];
- try {
- xhr.simulateResponse(400, '');
- } catch(e) {
- // Do nothing with the exception; we just want to make sure
- // the class cleans itself up properly when an exception is
- // thrown.
- }
- assertEquals('Send instance array not cleaned up properly!',
- 0, sendInstances.length);
-}
-
-function testMultipleSend() {
- var xhr = new goog.testing.net.XhrIo();
- assertFalse('isActive before first request', xhr.isActive());
- assertEquals('readyState before first request',
- goog.net.XmlHttp.ReadyState.UNINITIALIZED,
- xhr.getReadyState());
-
- xhr.send('url');
- assertTrue('isActive after first request', xhr.isActive());
- assertEquals('readyState after first request',
- goog.net.XmlHttp.ReadyState.LOADING,
- xhr.getReadyState());
-
- xhr.simulateResponse(200, '');
- assertFalse('isActive after first response', xhr.isActive());
- assertEquals('readyState after first response',
- goog.net.XmlHttp.ReadyState.COMPLETE,
- xhr.getReadyState());
-
- xhr.send('url');
- assertTrue('isActive after second request', xhr.isActive());
- assertEquals('readyState after second request',
- goog.net.XmlHttp.ReadyState.LOADING,
- xhr.getReadyState());
-}
-
-function testGetLastUri() {
- var xhr = new goog.testing.net.XhrIo();
- assertEquals('nothing sent yet, empty URI', '', xhr.getLastUri());
-
- var requestUrl = 'http://www.example.com/';
- xhr.send(requestUrl);
- assertEquals('message sent, URI saved', requestUrl, xhr.getLastUri());
-}
-
-function testGetLastMethod() {
- var xhr = new goog.testing.net.XhrIo();
- assertUndefined('nothing sent yet, empty method', xhr.getLastMethod());
-
- var method = 'POKE';
- xhr.send('http://www.example.com/', method);
- assertEquals('message sent, method saved', method, xhr.getLastMethod());
- xhr.simulateResponse(200, '');
-
- xhr.send('http://www.example.com/');
- assertEquals('message sent, method saved', 'GET', xhr.getLastMethod());
-}
-
-function testGetLastContent() {
- var xhr = new goog.testing.net.XhrIo();
- assertUndefined('nothing sent yet, empty content', xhr.getLastContent());
-
- var postContent = 'var=value&var2=value2';
- xhr.send('http://www.example.com/', undefined, postContent);
- assertEquals('POST message sent, content saved',
- postContent, xhr.getLastContent());
- xhr.simulateResponse(200, '');
-
- xhr.send('http://www.example.com/');
- assertUndefined('GET message sent, content cleaned', xhr.getLastContent());
-}
-
-function testGetLastRequestHeaders() {
- var xhr = new goog.testing.net.XhrIo();
- assertUndefined('nothing sent yet, empty headers',
- xhr.getLastRequestHeaders());
-
- xhr.send('http://www.example.com/', undefined, undefined,
- {'From': 'page@google.com'});
- assertObjectEquals('Request sent with extra headers, headers saved',
- {'From': 'page@google.com'},
- xhr.getLastRequestHeaders());
- xhr.simulateResponse(200, '');
-
- xhr.send('http://www.example.com');
- assertUndefined('New request sent without extra headers',
- xhr.getLastRequestHeaders());
-}
-
-function testGetResponseText() {
- // Text response came.
- var called = false;
- var xhr = new goog.testing.net.XhrIo();
- goog.events.listen(xhr, goog.net.EventType.SUCCESS, function(e) {
- called = true;
- assertEquals('text', e.target.getResponseText());
- });
- xhr.simulateResponse(200, 'text');
- assertTrue(called);
-
- // XML response came.
- var called = false;
- var xhr = new goog.testing.net.XhrIo();
- var xml = goog.dom.xml.createDocument();
- xml.appendChild(xml.createElement('root'));
- goog.events.listen(xhr, goog.net.EventType.SUCCESS, function(e) {
- called = true;
- var text = e.target.getResponseText();
- assertTrue(/<root ?\/>/.test(text));
- });
- xhr.simulateResponse(200, xml);
- assertTrue(called);
-}
-
-function testGetResponseJson() {
- // Valid JSON response came.
- var called = false;
- var xhr = new goog.testing.net.XhrIo();
- goog.events.listen(xhr, goog.net.EventType.SUCCESS, function(e) {
- called = true;
- assertArrayEquals([0, 1], e.target.getResponseJson());
- });
- xhr.simulateResponse(200, '[0, 1]');
- assertTrue(called);
-
- // Valid JSON response with XSSI prefix encoded came.
- var called = false;
- var xhr = new goog.testing.net.XhrIo();
- goog.events.listen(xhr, goog.net.EventType.SUCCESS, function(e) {
- called = true;
- assertArrayEquals([0, 1], e.target.getResponseJson(')]}\', \n'));
- });
- xhr.simulateResponse(200, ')]}\', \n[0, 1]');
- assertTrue(called);
-
- // Invalid JSON response came.
- var called = false;
- var xhr = new goog.testing.net.XhrIo();
- goog.events.listen(xhr, goog.net.EventType.SUCCESS, function(e) {
- called = true;
- assertThrows(e.target.getResponseJson);
- });
- xhr.simulateResponse(200, '[0, 1');
- assertTrue(called);
-
- // XML response came.
- var called = false;
- var xhr = new goog.testing.net.XhrIo();
- var xml = goog.dom.xml.createDocument();
- xml.appendChild(xml.createElement('root'));
- goog.events.listen(xhr, goog.net.EventType.SUCCESS, function(e) {
- called = true;
- assertThrows(e.target.getResponseJson);
- });
- xhr.simulateResponse(200, xml);
- assertTrue(called);
-}
-
-function testGetResponseXml() {
- // Text response came.
- var called = false;
- var xhr = new goog.testing.net.XhrIo();
- goog.events.listen(xhr, goog.net.EventType.SUCCESS, function(e) {
- called = true;
- assertNull(e.target.getResponseXml());
- });
- xhr.simulateResponse(200, 'text');
- assertTrue(called);
-
- // XML response came.
- var called = false;
- var xhr = new goog.testing.net.XhrIo();
- var xml = goog.dom.xml.createDocument();
- xml.appendChild(xml.createElement('root'));
- goog.events.listen(xhr, goog.net.EventType.SUCCESS, function(e) {
- called = true;
- assertEquals(xml, e.target.getResponseXml());
- });
- xhr.simulateResponse(200, xml);
- assertTrue(called);
-}
-
-function testGetResponseHeaders_noHeadersPresent() {
- var xhr = new goog.testing.net.XhrIo();
- var mockListener = mockControl.createFunctionMock();
- mockListener(new goog.testing.mockmatchers.InstanceOf(goog.events.Event))
- .$does(function(e) {
- assertTrue(e.type == goog.net.EventType.SUCCESS);
- assertUndefined(e.target.getResponseHeader('XHR'));
- });
- mockControl.$replayAll();
- goog.events.listen(xhr, goog.net.EventType.SUCCESS, mockListener);
- xhr.simulateResponse(200, '');
-
- mockControl.$verifyAll();
- mockControl.$resetAll();
-}
-
-function testGetResponseHeaders_headersPresent() {
- var xhr = new goog.testing.net.XhrIo();
- var mockListener = mockControl.createFunctionMock();
- mockListener(new goog.testing.mockmatchers.InstanceOf(goog.events.Event))
- .$does(function(e) {
- assertTrue(e.type == goog.net.EventType.SUCCESS);
- assertUndefined(e.target.getResponseHeader('XHR'));
- assertEquals(e.target.getResponseHeader('Pragma'), 'no-cache');
- });
- mockControl.$replayAll();
- goog.events.listen(xhr, goog.net.EventType.SUCCESS, mockListener);
- xhr.simulateResponse(200, '', {'Pragma': 'no-cache'});
-
- mockControl.$verifyAll();
- mockControl.$resetAll();
-}
-
-function testAbort_WhenNoPendingSentRequests() {
- var xhr = new goog.testing.net.XhrIo();
- var eventListener = mockControl.createFunctionMock();
- mockControl.$replayAll();
-
- goog.events.listen(xhr, goog.net.EventType.COMPLETE, eventListener);
- goog.events.listen(xhr, goog.net.EventType.SUCCESS, eventListener);
- goog.events.listen(xhr, goog.net.EventType.ABORT, eventListener);
- goog.events.listen(xhr, goog.net.EventType.ERROR, eventListener);
- goog.events.listen(xhr, goog.net.EventType.READY, eventListener);
-
- xhr.abort();
-
- mockControl.$verifyAll();
- mockControl.$resetAll();
-}
-
-function testAbort_PendingSentRequest() {
- var xhr = new goog.testing.net.XhrIo();
- var mockListener = mockControl.createFunctionMock();
-
- mockListener(new goog.testing.mockmatchers.InstanceOf(goog.events.Event))
- .$does(function(e) {
- assertTrue(e.type == goog.net.EventType.COMPLETE);
- assertObjectEquals(e.target, xhr);
- assertEquals(e.target.getLastErrorCode(), goog.net.ErrorCode.ABORT);
- assertTrue(e.target.isActive());
- });
- mockListener(new goog.testing.mockmatchers.InstanceOf(goog.events.Event))
- .$does(function(e) {
- assertTrue(e.type == goog.net.EventType.ABORT);
- assertObjectEquals(e.target, xhr);
- assertTrue(e.target.isActive());
- });
- mockListener(new goog.testing.mockmatchers.InstanceOf(goog.events.Event))
- .$does(function(e) {
- assertTrue(e.type == goog.net.EventType.READY);
- assertObjectEquals(e.target, xhr);
- assertFalse(e.target.isActive());
- });
- mockControl.$replayAll();
-
- goog.events.listen(xhr, goog.net.EventType.COMPLETE, mockListener);
- goog.events.listen(xhr, goog.net.EventType.SUCCESS, mockListener);
- goog.events.listen(xhr, goog.net.EventType.ABORT, mockListener);
- goog.events.listen(xhr, goog.net.EventType.ERROR, mockListener);
- goog.events.listen(xhr, goog.net.EventType.READY, mockListener);
- xhr.send('dummyurl');
- xhr.abort();
-
- mockControl.$verifyAll();
- mockControl.$resetAll();
-}
-
-function testEvents_Success() {
- var xhr = new goog.testing.net.XhrIo();
- var mockListener = mockControl.createFunctionMock();
-
- var readyState = goog.net.XmlHttp.ReadyState.UNINITIALIZED;
- function readyStateListener(e) {
- assertEquals(e.type, goog.net.EventType.READY_STATE_CHANGE);
- assertObjectEquals(e.target, xhr);
- readyState++;
- assertEquals(e.target.getReadyState(), readyState);
- assertTrue(e.target.isActive());
- }
-
- mockListener(new goog.testing.mockmatchers.InstanceOf(goog.events.Event))
- .$does(function(e) {
- assertEquals(e.type, goog.net.EventType.COMPLETE);
- assertObjectEquals(e.target, xhr);
- assertEquals(e.target.getLastErrorCode(), goog.net.ErrorCode.NO_ERROR);
- assertTrue(e.target.isActive());
- });
- mockListener(new goog.testing.mockmatchers.InstanceOf(goog.events.Event))
- .$does(function(e) {
- assertEquals(e.type, goog.net.EventType.SUCCESS);
- assertObjectEquals(e.target, xhr);
- assertTrue(e.target.isActive());
- });
- mockListener(new goog.testing.mockmatchers.InstanceOf(goog.events.Event))
- .$does(function(e) {
- assertEquals(e.type, goog.net.EventType.READY);
- assertObjectEquals(e.target, xhr);
- assertFalse(e.target.isActive());
- });
- mockControl.$replayAll();
-
- goog.events.listen(xhr, goog.net.EventType.READY_STATE_CHANGE,
- readyStateListener);
- goog.events.listen(xhr, goog.net.EventType.COMPLETE, mockListener);
- goog.events.listen(xhr, goog.net.EventType.SUCCESS, mockListener);
- goog.events.listen(xhr, goog.net.EventType.ABORT, mockListener);
- goog.events.listen(xhr, goog.net.EventType.ERROR, mockListener);
- goog.events.listen(xhr, goog.net.EventType.READY, mockListener);
- xhr.send('dummyurl');
- xhr.simulateResponse(200, null);
-
- mockControl.$verifyAll();
- mockControl.$resetAll();
-}
-
-</script>
-</body>
-</html>
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/net/.svn/text-base/xhriopool.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/net/.svn/text-base/xhriopool.js.svn-base
deleted file mode 100644
index 8daf968..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/net/.svn/text-base/xhriopool.js.svn-base
+++ /dev/null
@@ -1,61 +0,0 @@
-// Copyright 2011 The Closure Library Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS-IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/**
- * @fileoverview An XhrIo pool that uses a single mock XHR object for testing.
- *
- */
-
-goog.provide('goog.testing.net.XhrIoPool');
-
-goog.require('goog.net.XhrIoPool');
-goog.require('goog.testing.net.XhrIo');
-
-
-
-/**
- * A pool containing a single mock XhrIo object.
- *
- * @param {goog.testing.net.XhrIo=} opt_xhr The mock XhrIo object.
- * @constructor
- * @extends {goog.net.XhrIoPool}
- */
-goog.testing.net.XhrIoPool = function(opt_xhr) {
- /**
- * The mock XhrIo object.
- * @type {!goog.testing.net.XhrIo}
- * @private
- */
- this.xhr_ = opt_xhr || new goog.testing.net.XhrIo();
-
- // Run this after setting xhr_ because xhr_ is used to initialize the pool.
- goog.base(this, undefined, 1, 1);
-};
-goog.inherits(goog.testing.net.XhrIoPool, goog.net.XhrIoPool);
-
-
-/** @override */
-goog.testing.net.XhrIoPool.prototype.createObject = function() {
- return (/** @type {!goog.net.XhrIo} */ (this.xhr_));
-};
-
-
-/**
- * Get the mock XhrIo used by this pool.
- *
- * @return {!goog.testing.net.XhrIo} The mock XhrIo.
- */
-goog.testing.net.XhrIoPool.prototype.getXhr = function() {
- return this.xhr_;
-};
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/net/xhrio.js b/contexts/data/lib/closure-library/closure/goog/testing/net/xhrio.js
index f08f3e3..b59a1d5 100644
--- a/contexts/data/lib/closure-library/closure/goog/testing/net/xhrio.js
+++ b/contexts/data/lib/closure-library/closure/goog/testing/net/xhrio.js
@@ -63,6 +63,13 @@ goog.inherits(goog.testing.net.XhrIo, goog.events.EventTarget);
/**
+ * Alias this enum here to make mocking of goog.net.XhrIo easier.
+ * @enum {string}
+ */
+goog.testing.net.XhrIo.ResponseType = goog.net.XhrIo.ResponseType;
+
+
+/**
* All non-disposed instances of goog.testing.net.XhrIo created
* by {@link goog.testing.net.XhrIo.send} are in this Array.
* @see goog.testing.net.XhrIo.cleanup
@@ -417,6 +424,13 @@ goog.testing.net.XhrIo.prototype.simulateReadyStateChange =
throw Error('Readystate cannot go backwards');
}
+ // INTERACTIVE can be dispatched repeatedly as more data is reported.
+ if (readyState == goog.net.XmlHttp.ReadyState.INTERACTIVE &&
+ readyState == this.readyState_) {
+ this.dispatchEvent(goog.net.EventType.READY_STATE_CHANGE);
+ return;
+ }
+
while (this.readyState_ < readyState) {
this.readyState_++;
this.dispatchEvent(goog.net.EventType.READY_STATE_CHANGE);
@@ -430,6 +444,21 @@ goog.testing.net.XhrIo.prototype.simulateReadyStateChange =
/**
+ * Simulate receiving some bytes but the request not fully completing, and
+ * the XHR entering the 'INTERACTIVE' state.
+ * @param {string} partialResponse A string to append to the response text.
+ * @param {Object=} opt_headers Simulated response headers.
+ */
+goog.testing.net.XhrIo.prototype.simulatePartialResponse =
+ function(partialResponse, opt_headers) {
+ this.response_ += partialResponse;
+ this.responseHeaders_ = opt_headers || {};
+ this.statusCode_ = 200;
+ this.simulateReadyStateChange(goog.net.XmlHttp.ReadyState.INTERACTIVE);
+};
+
+
+/**
* Simulates receiving a response.
* @param {number} statusCode Simulated status code.
* @param {string|Document|null} response Simulated response.
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/performancetable.js b/contexts/data/lib/closure-library/closure/goog/testing/performancetable.js
index 7894837..21b1a23 100644
--- a/contexts/data/lib/closure-library/closure/goog/testing/performancetable.js
+++ b/contexts/data/lib/closure-library/closure/goog/testing/performancetable.js
@@ -132,7 +132,33 @@ goog.testing.PerformanceTable.prototype.round_ = function(num) {
* @param {string=} opt_desc A description to associate with this run.
*/
goog.testing.PerformanceTable.prototype.run = function(fn, opt_desc) {
- var results = this.timer_.run(fn);
+ this.runTask(
+ new goog.testing.PerformanceTimer.Task((/** @type {function()} */ fn)),
+ opt_desc);
+};
+
+
+/**
+ * Run the given task with the performance timer, and show the results.
+ * @param {goog.testing.PerformanceTimer.Task} task The performance timer task
+ * to run.
+ * @param {string=} opt_desc A description to associate with this run.
+ */
+goog.testing.PerformanceTable.prototype.runTask = function(task, opt_desc) {
+ var results = this.timer_.runTask(task);
+ this.recordResults(results, opt_desc);
+};
+
+
+/**
+ * Record a performance timer results object to the performance table. See
+ * {@code goog.testing.PerformanceTimer} for details of the format of this
+ * object.
+ * @param {Object} results The performance timer results object.
+ * @param {string=} opt_desc A description to associate with these results.
+ */
+goog.testing.PerformanceTable.prototype.recordResults = function(
+ results, opt_desc) {
var average = results['average'];
var standardDeviation = results['standardDeviation'];
var isSuspicious = average < 0 || standardDeviation > average * .5;
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/performancetimer.js b/contexts/data/lib/closure-library/closure/goog/testing/performancetimer.js
index 599bf4a..1479ae3 100644
--- a/contexts/data/lib/closure-library/closure/goog/testing/performancetimer.js
+++ b/contexts/data/lib/closure-library/closure/goog/testing/performancetimer.js
@@ -21,6 +21,7 @@
*/
goog.provide('goog.testing.PerformanceTimer');
+goog.provide('goog.testing.PerformanceTimer.Task');
goog.require('goog.array');
goog.require('goog.math');
@@ -137,15 +138,36 @@ goog.testing.PerformanceTimer.prototype.isDiscardOutliers = function() {
* @return {Object} Object containing performance stats.
*/
goog.testing.PerformanceTimer.prototype.run = function(testFn) {
+ return this.runTask(new goog.testing.PerformanceTimer.Task(
+ (/** @type {function()} */ testFn)));
+};
+
+
+/**
+ * Executes the test function of the specified task as described in
+ * {@code run}. In addition, if specified, the set up and tear down functions of
+ * the task are invoked before and after each invocation of the test function.
+ * @see goog.testing.PerformanceTimer#run
+ * @param {goog.testing.PerformanceTimer.Task} task A task describing the test
+ * function to invoke.
+ * @return {Object} Object containing performance stats.
+ */
+goog.testing.PerformanceTimer.prototype.runTask = function(task) {
var samples = [];
var testStart = goog.now();
var totalRunTime = 0;
+ var testFn = task.getTest();
+ var setUpFn = task.getSetUp();
+ var tearDownFn = task.getTearDown();
+
for (var i = 0; i < this.numSamples_ && totalRunTime <= this.timeoutInterval_;
i++) {
+ setUpFn();
var sampleStart = goog.now();
testFn();
var sampleEnd = goog.now();
+ tearDownFn();
samples[i] = sampleEnd - sampleStart;
totalRunTime = sampleEnd - testStart;
}
@@ -155,12 +177,105 @@ goog.testing.PerformanceTimer.prototype.run = function(testFn) {
goog.array.remove(samples, Math.max.apply(null, samples));
}
+ return goog.testing.PerformanceTimer.createResults(samples);
+};
+
+
+/**
+ * Creates a performance timer results object by analyzing a given array of
+ * sample timings.
+ * @param {Array.<number>} samples The samples to analyze.
+ * @return {Object} Object containing performance stats.
+ */
+goog.testing.PerformanceTimer.createResults = function(samples) {
return {
'average': goog.math.average.apply(null, samples),
- 'count': i,
+ 'count': samples.length,
'maximum': Math.max.apply(null, samples),
'minimum': Math.min.apply(null, samples),
'standardDeviation': goog.math.standardDeviation.apply(null, samples),
'total': goog.math.sum.apply(null, samples)
};
};
+
+
+
+/**
+ * A task for the performance timer to measure. Callers can specify optional
+ * setUp and tearDown methods to control state before and after each run of the
+ * test function.
+ * @param {function()} test Test function whose performance is to be measured.
+ * @constructor
+ */
+goog.testing.PerformanceTimer.Task = function(test) {
+ /**
+ * The test function to time.
+ * @type {function()}
+ * @private
+ */
+ this.test_ = test;
+};
+
+
+/**
+ * An optional set up function to run before each invocation of the test
+ * function.
+ * @type {function()}
+ * @private
+ */
+goog.testing.PerformanceTimer.Task.prototype.setUp_ = goog.nullFunction;
+
+
+/**
+ * An optional tear down function to run after each invocation of the test
+ * function.
+ * @type {function()}
+ * @private
+ */
+goog.testing.PerformanceTimer.Task.prototype.tearDown_ = goog.nullFunction;
+
+
+/** @return {function()} The test function to time. */
+goog.testing.PerformanceTimer.Task.prototype.getTest = function() {
+ return this.test_;
+};
+
+
+/**
+ * Specifies a set up function to be invoked before each invocation of the test
+ * function.
+ * @param {function()} setUp The set up function.
+ * @return {goog.testing.PerformanceTimer.Task} This task.
+ */
+goog.testing.PerformanceTimer.Task.prototype.withSetUp = function(setUp) {
+ this.setUp_ = setUp;
+ return this;
+};
+
+
+/**
+ * @return {function()} The set up function or null if none was specified.
+ */
+goog.testing.PerformanceTimer.Task.prototype.getSetUp = function() {
+ return this.setUp_;
+};
+
+
+/**
+ * Specifies a tear down function to be invoked after each invocation of the
+ * test function.
+ * @param {function()} tearDown The tear down function.
+ * @return {goog.testing.PerformanceTimer.Task} This task.
+ */
+goog.testing.PerformanceTimer.Task.prototype.withTearDown = function(tearDown) {
+ this.tearDown_ = tearDown;
+ return this;
+};
+
+
+/**
+ * @return {function()} The tear down function or null if none was specified.
+ */
+goog.testing.PerformanceTimer.Task.prototype.getTearDown = function() {
+ return this.tearDown_;
+};
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/performancetimer_test.html b/contexts/data/lib/closure-library/closure/goog/testing/performancetimer_test.html
index 58e863d..f4727c4 100644
--- a/contexts/data/lib/closure-library/closure/goog/testing/performancetimer_test.html
+++ b/contexts/data/lib/closure-library/closure/goog/testing/performancetimer_test.html
@@ -15,6 +15,7 @@ Author: attila@google.com (Attila Bodis)
<script src="../base.js"></script>
<script>
goog.require('goog.dom');
+ goog.require('goog.math');
goog.require('goog.testing.MockClock');
goog.require('goog.testing.PerformanceTimer');
goog.require('goog.testing.jsunit');
@@ -37,7 +38,7 @@ Author: attila@google.com (Attila Bodis)
}
function setUp() {
- mockClock = new goog.testing.MockClock(false);
+ mockClock = new goog.testing.MockClock(true);
timer = new goog.testing.PerformanceTimer();
}
@@ -56,33 +57,75 @@ Author: attila@google.com (Attila Bodis)
timer.getTimeoutInterval());
}
- function testRun() {
+ function testRun_noSetUpOrTearDown() {
+ runAndAssert(false, false);
+ }
+
+ function testRun_withSetup() {
+ runAndAssert(true, false);
+ }
+
+ function testRun_withTearDown() {
+ runAndAssert(false, true);
+ }
+
+ function testRun_withSetUpAndTearDown() {
+ runAndAssert(true, true);
+ }
+
+ function runAndAssert(useSetUp, useTearDown) {
+ var fakeExecutionTime = [100, 95, 98, 104, 130, 101, 96, 98, 90, 103]
+ var count = 0;
+ var testFunction = function() {
+ mockClock.tick(fakeExecutionTime[count++]);
+ };
+
+ var setUpCount = 0;
+ var setUpFunction = function() {
+ // Should have no effect on total time.
+ mockClock.tick(7);
+ setUpCount++;
+ };
+
+ var tearDownCount = 0;
+ var tearDownFunction = function() {
+ // Should have no effect on total time.
+ mockClock.tick(11);
+ tearDownCount++;
+ };
+
// Fast test function should complete successfully in under 5 seconds...
- var results = timer.run(fastTestFunction);
-
- assertNotNull('Results must be available',
- results);
- assertTrue('Average must be a nonnegative number',
- results['average'] >= 0);
- assertEquals('Count must be as expected', 10,
- results['count']);
- assertTrue('Maximum must be a nonnegative number',
- results['maximum'] >= 0);
- assertTrue('Mimimum must be a nonnegative number',
- results['minimum'] >= 0);
- assertTrue('Standard deviation must be a nonnegative number',
- results['standardDeviation'] >= 0);
- assertTrue('Total must be a nonnegative number',
- results['total'] >= 0);
- assertTrue('Average must be between minimum and maximum',
- results['minimum'] <= results['average'] &&
- results['average'] <= results['maximum']);
+ var task = new goog.testing.PerformanceTimer.Task(testFunction);
+ if (useSetUp) {
+ task.withSetUp(setUpFunction);
+ }
+ if (useTearDown) {
+ task.withTearDown(tearDownFunction);
+ }
+ var results = timer.runTask(task);
+
+ assertNotNull('Results must be available.', results);
+
+ assertEquals('Average is wrong.',
+ goog.math.average.apply(null, fakeExecutionTime), results['average']);
+ assertEquals('Standard deviation is wrong.',
+ goog.math.standardDeviation.apply(null, fakeExecutionTime),
+ results['standardDeviation']);
+
+ assertEquals('Count must be as expected.', 10, results['count']);
+ assertEquals('Maximum is wrong.', 130, results['maximum']);
+ assertEquals('Mimimum is wrong.', 90, results['minimum']);
+ assertEquals('Total must be a nonnegative number.',
+ goog.math.sum.apply(null, fakeExecutionTime), results['total']);
+
+ assertEquals('Set up count must be as expected.',
+ useSetUp ? 10 : 0, setUpCount);
+ assertEquals('Tear down count must be as expected.',
+ useTearDown ? 10 : 0, tearDownCount);
}
function testTimeout() {
- mockClock.install();
var count = 0;
-
var testFunction = function() {
mockClock.tick(100);
++count;
@@ -97,6 +140,21 @@ Author: attila@google.com (Attila Bodis)
assertTrue('Count must less than expected',
results['count'] < timer.getNumSamples());
}
+
+ function testCreateResults() {
+ var samples = [53, 0, 103];
+ var expectedResults = {
+ 'average': 52,
+ 'count': 3,
+ 'maximum': 103,
+ 'minimum': 0,
+ 'standardDeviation': goog.math.standardDeviation.apply(null, samples),
+ 'total': 156
+ };
+ assertObjectEquals(
+ expectedResults,
+ goog.testing.PerformanceTimer.createResults(samples));
+ }
</script>
</body>
</html>
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/proto2/proto2.js b/contexts/data/lib/closure-library/closure/goog/testing/proto2/proto2.js
new file mode 100644
index 0000000..9614386
--- /dev/null
+++ b/contexts/data/lib/closure-library/closure/goog/testing/proto2/proto2.js
@@ -0,0 +1,127 @@
+// Copyright 2012 The Closure Library Authors. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS-IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+/**
+ * @fileoverview Test helpers to compare goog.proto2.Messages.
+ *
+ */
+
+goog.provide('goog.testing.proto2');
+
+goog.require('goog.proto2.Message');
+goog.require('goog.testing.asserts');
+
+
+/**
+ * Compares two goog.proto2.Message instances of the same type.
+ * @param {!goog.proto2.Message} expected First message.
+ * @param {!goog.proto2.Message} actual Second message.
+ * @param {string} path Path to the messages.
+ * @return {string} A string describing where they differ. Empty string if they
+ * are equal.
+ * @private
+ */
+goog.testing.proto2.findDifferences_ = function(expected, actual, path) {
+ var fields = expected.getDescriptor().getFields();
+ for (var i = 0; i < fields.length; i++) {
+ var field = fields[i];
+ var newPath = (path ? path + '/' : '') + field.getName();
+
+ if (expected.has(field) && !actual.has(field)) {
+ return newPath + ' should be present';
+ }
+ if (!expected.has(field) && actual.has(field)) {
+ return newPath + ' should not be present';
+ }
+
+ if (expected.has(field)) {
+ var isComposite = field.isCompositeType();
+
+ if (field.isRepeated()) {
+ var expectedCount = expected.countOf(field);
+ var actualCount = actual.countOf(field);
+ if (expectedCount != actualCount) {
+ return newPath + ' should have ' + expectedCount + ' items, ' +
+ 'but has ' + actualCount;
+ }
+
+ for (var j = 0; j < expectedCount; j++) {
+ var expectedItem = expected.get(field, j);
+ var actualItem = actual.get(field, j);
+ if (isComposite) {
+ var itemDiff = goog.testing.proto2.findDifferences_(
+ /** @type {!goog.proto2.Message} */ (expectedItem),
+ /** @type {!goog.proto2.Message} */ (actualItem),
+ newPath + '[' + j + ']');
+ if (itemDiff) {
+ return itemDiff;
+ }
+ } else {
+ if (expectedItem != actualItem) {
+ return newPath + '[' + j + '] should be ' + expectedItem +
+ ', but was ' + actualItem;
+ }
+ }
+ }
+ } else {
+ var expectedValue = expected.get(field);
+ var actualValue = actual.get(field);
+ if (isComposite) {
+ var diff = goog.testing.proto2.findDifferences_(
+ /** @type {!goog.proto2.Message} */ (expectedValue),
+ /** @type {!goog.proto2.Message} */ (actualValue),
+ newPath);
+ if (diff) {
+ return diff;
+ }
+ } else {
+ if (expectedValue != actualValue) {
+ return newPath + ' should be ' + expectedValue + ', but was ' +
+ actualValue;
+ }
+ }
+ }
+ }
+ }
+
+ return '';
+};
+
+
+/**
+ * Compares two goog.proto2.Message objects. Gives more readable output than
+ * assertObjectEquals on mismatch.
+ * @param {!goog.proto2.Message} expected Expected proto2 message.
+ * @param {!goog.proto2.Message} actual Actual proto2 message.
+ * @param {string=} opt_failureMessage Failure message when the values don't
+ * match.
+ */
+goog.testing.proto2.assertEquals = function(expected, actual,
+ opt_failureMessage) {
+ var failureSummary = opt_failureMessage || '';
+ if (!(expected instanceof goog.proto2.Message) ||
+ !(actual instanceof goog.proto2.Message)) {
+ goog.testing.asserts.raiseException(failureSummary,
+ 'Bad arguments were passed to goog.testing.proto2.assertEquals');
+ }
+ if (expected.constructor != actual.constructor) {
+ goog.testing.asserts.raiseException(failureSummary,
+ 'Message type mismatch: ' + expected.getDescriptor().getFullName() +
+ ' != ' + actual.getDescriptor().getFullName());
+ }
+ var diff = goog.testing.proto2.findDifferences_(expected, actual, '');
+ if (diff) {
+ goog.testing.asserts.raiseException(failureSummary, diff);
+ }
+};
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/proto2/proto2_test.html b/contexts/data/lib/closure-library/closure/goog/testing/proto2/proto2_test.html
new file mode 100644
index 0000000..1e4e3ce
--- /dev/null
+++ b/contexts/data/lib/closure-library/closure/goog/testing/proto2/proto2_test.html
@@ -0,0 +1,117 @@
+<!DOCTYPE html>
+<html>
+<!--
+Copyright 2012 The Closure Library Authors. All Rights Reserved.
+
+Use of this source code is governed by the Apache License, Version 2.0.
+See the COPYING file for details.
+-->
+<head>
+<meta http-equiv="X-UA-Compatible" content="IE=edge">
+<title>Closure Unit Tests - goog.testing.proto2</title>
+<script src="../../base.js"></script>
+<script>
+ goog.require('goog.testing.jsunit');
+ goog.require('goog.testing.proto2');
+ goog.require('proto2.TestAllTypes');
+</script>
+</head>
+<body>
+<script>
+
+function testAssertEquals() {
+ var assertProto2Equals = goog.testing.proto2.assertEquals;
+ assertProto2Equals(new proto2.TestAllTypes, new proto2.TestAllTypes);
+ assertProto2Equals(new proto2.TestAllTypes, new proto2.TestAllTypes, 'oops');
+
+ var ex = assertThrows(goog.partial(assertProto2Equals,
+ new proto2.TestAllTypes, new proto2.TestAllTypes.NestedMessage));
+ assertEquals(
+ 'Message type mismatch: TestAllTypes != TestAllTypes.NestedMessage',
+ ex.message);
+
+ var message = new proto2.TestAllTypes;
+ message.setOptionalInt32(1);
+ ex = assertThrows(goog.partial(assertProto2Equals,
+ new proto2.TestAllTypes, message));
+ assertEquals('optional_int32 should not be present', ex.message);
+
+ ex = assertThrows(goog.partial(assertProto2Equals,
+ new proto2.TestAllTypes, message, 'oops'));
+ assertEquals('oops\noptional_int32 should not be present', ex.message);
+}
+
+function testFindDifferences_EmptyMessages() {
+ assertEquals('', goog.testing.proto2.findDifferences_(
+ new proto2.TestAllTypes, new proto2.TestAllTypes, ''));
+}
+
+function testFindDifferences_FieldNotPresent() {
+ var message = new proto2.TestAllTypes;
+ message.setOptionalInt32(0);
+ var empty = new proto2.TestAllTypes;
+ assertEquals('optional_int32 should not be present',
+ goog.testing.proto2.findDifferences_(empty, message, ''));
+ assertEquals('optional_int32 should be present',
+ goog.testing.proto2.findDifferences_(message, empty, ''));
+ assertEquals('path/optional_int32 should be present',
+ goog.testing.proto2.findDifferences_(message, empty, 'path'));
+}
+
+function testFindDifferences_IntFieldDiffers() {
+ var message1 = new proto2.TestAllTypes;
+ message1.setOptionalInt32(1);
+ var message2 = new proto2.TestAllTypes;
+ message2.setOptionalInt32(2);
+ assertEquals('optional_int32 should be 1, but was 2',
+ goog.testing.proto2.findDifferences_(message1, message2, ''));
+}
+
+function testFindDifferences_NestedIntFieldDiffers() {
+ var message1 = new proto2.TestAllTypes;
+ var nested1 = new proto2.TestAllTypes.NestedMessage();
+ nested1.setB(1);
+ message1.setOptionalNestedMessage(nested1);
+ var message2 = new proto2.TestAllTypes;
+ var nested2 = new proto2.TestAllTypes.NestedMessage();
+ nested2.setB(2);
+ message2.setOptionalNestedMessage(nested2);
+ assertEquals('optional_nested_message/b should be 1, but was 2',
+ goog.testing.proto2.findDifferences_(message1, message2, ''));
+}
+
+function testFindDifferences_RepeatedFieldLengthDiffers() {
+ var message1 = new proto2.TestAllTypes;
+ message1.addRepeatedInt32(1);
+ var message2 = new proto2.TestAllTypes;
+ message2.addRepeatedInt32(1);
+ message2.addRepeatedInt32(2);
+ assertEquals('repeated_int32 should have 1 items, but has 2',
+ goog.testing.proto2.findDifferences_(message1, message2, ''));
+}
+
+function testFindDifferences_RepeatedFieldItemDiffers() {
+ var message1 = new proto2.TestAllTypes;
+ message1.addRepeatedInt32(1);
+ var message2 = new proto2.TestAllTypes;
+ message2.addRepeatedInt32(2);
+ assertEquals('repeated_int32[0] should be 1, but was 2',
+ goog.testing.proto2.findDifferences_(message1, message2, ''));
+}
+
+function testFindDifferences_RepeatedNestedMessageDiffers() {
+ var message1 = new proto2.TestAllTypes;
+ var nested1 = new proto2.TestAllTypes.NestedMessage();
+ nested1.setB(1);
+ message1.addRepeatedNestedMessage(nested1);
+ var message2 = new proto2.TestAllTypes;
+ var nested2 = new proto2.TestAllTypes.NestedMessage();
+ nested2.setB(2);
+ message2.addRepeatedNestedMessage(nested2);
+ assertEquals('repeated_nested_message[0]/b should be 1, but was 2',
+ goog.testing.proto2.findDifferences_(message1, message2, ''));
+}
+
+</script>
+</body>
+</html>
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/shardingtestcase.js b/contexts/data/lib/closure-library/closure/goog/testing/shardingtestcase.js
index 2798b43..46cdc24 100644
--- a/contexts/data/lib/closure-library/closure/goog/testing/shardingtestcase.js
+++ b/contexts/data/lib/closure-library/closure/goog/testing/shardingtestcase.js
@@ -80,6 +80,7 @@ goog.testing.ShardingTestCase.prototype.sharded_ = false;
/**
* Installs a runTests global function that goog.testing.JsUnit will use to
* run tests, which will run a single shard of the tests present on the page.
+ * @override
*/
goog.testing.ShardingTestCase.prototype.runTests = function() {
if (!this.sharded_) {
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/singleton.js b/contexts/data/lib/closure-library/closure/goog/testing/singleton.js
index 73187c2..03f1043 100644
--- a/contexts/data/lib/closure-library/closure/goog/testing/singleton.js
+++ b/contexts/data/lib/closure-library/closure/goog/testing/singleton.js
@@ -13,70 +13,34 @@
// limitations under the License.
/**
- * @fileoverview This module simplifies testing code which uses many stateful
- * singletons. The {@link goog.testing.singleton.addSingletonGetter} function
- * adds a static {@code getInstance} method to the class, which in addition to
- * creating and returning a singleton instance, registers it in a global
- * repository. This way the effect of all {@code getInstance} calls can be
- * simply reset in {@code tearDown} without knowing what singletons were
- * instantiated in the tests.
+ * @fileoverview This module simplifies testing code which uses stateful
+ * singletons. {@code goog.testing.singleton.reset} resets all instances, so
+ * next time when {@code getInstance} is called, a new instance is created.
+ * It's recommended to reset the singletons in {@code tearDown} to prevent
+ * interference between subsequent tests.
*
- * Usage:
- * <ol>
- * <li>Load {@code base.js}.
- * <li>Load {@code goog.testing.singleton}. It overrides
- * {@link goog.addSingletonGetter} by
- * {@link goog.testing.addSingletonGetter}.
- * <li>Load the code to test.
- * <li>Call {@link goog.testing.singleton.reset} in the {@code tearDown}.
- * </ol>
+ * The {@code goog.testing.singleton} functions expect that the goog.DEBUG flag
+ * is enabled, and the tests are either uncompiled or compiled without renaming.
*
*/
goog.provide('goog.testing.singleton');
-goog.require('goog.array');
-
-
-/**
- * List of all singleton classes for which the instance has been created.
- * @type {Array.<!Function>}
- * @private
- */
-goog.testing.singletons_ = [];
-
-
-/**
- * Adds a {@code getInstance} static method to the given class which in addition
- * to always returning the same instance object, registers the constructor in a
- * global array.
- * @param {!Function} ctor The constructor for the class to add the static
- * method to.
- */
-goog.testing.singleton.addSingletonGetter = function(ctor) {
- ctor.getInstance = function() {
- if (!ctor.instance_) {
- ctor.instance_ = new ctor();
- goog.testing.singletons_.push(ctor);
- }
- return ctor.instance_;
- };
-};
-
/**
* Deletes all singleton instances, so {@code getInstance} will return a new
* instance on next call.
*/
goog.testing.singleton.reset = function() {
- goog.array.forEach(goog.testing.singletons_, function(ctor) {
+ var singletons = goog.getObjectByName('goog.instantiatedSingletons_');
+ var ctor;
+ while (ctor = singletons.pop()) {
delete ctor.instance_;
- });
- goog.array.clear(goog.testing.singletons_);
+ }
};
/**
- * Overrides {@code goog.addSingletonGetter} in {@code base.js}.
+ * @deprecated Please use {@code goog.addSingletonGetter}.
*/
-goog.addSingletonGetter = goog.testing.singleton.addSingletonGetter;
+goog.testing.singleton.addSingletonGetter = goog.addSingletonGetter;
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/stacktrace.js b/contexts/data/lib/closure-library/closure/goog/testing/stacktrace.js
index 4159135..040108a 100644
--- a/contexts/data/lib/closure-library/closure/goog/testing/stacktrace.js
+++ b/contexts/data/lib/closure-library/closure/goog/testing/stacktrace.js
@@ -208,6 +208,46 @@ goog.testing.stacktrace.FIREFOX_STACK_FRAME_REGEXP_ = new RegExp('^' +
/**
+ * RegExp pattern for an anonymous function call in an Opera stack frame.
+ * Creates 2 (optional) submatches: the context object and function name.
+ * @type {string}
+ * @const
+ * @private
+ */
+goog.testing.stacktrace.OPERA_ANONYMOUS_FUNCTION_NAME_PATTERN_ =
+ '<anonymous function(?:\\: ' +
+ '(?:(' + goog.testing.stacktrace.IDENTIFIER_PATTERN_ +
+ '(?:\\.' + goog.testing.stacktrace.IDENTIFIER_PATTERN_ + ')*)\\.)?' +
+ '(' + goog.testing.stacktrace.IDENTIFIER_PATTERN_ + '))?>';
+
+
+/**
+ * RegExp pattern for a function call in an Opera stack frame.
+ * Creates 4 (optional) submatches: the function name (if not anonymous),
+ * the aliased context object and function name (if anonymous), and the
+ * function call arguments.
+ * @type {string}
+ * @const
+ * @private
+ */
+goog.testing.stacktrace.OPERA_FUNCTION_CALL_PATTERN_ =
+ '(?:(?:(' + goog.testing.stacktrace.IDENTIFIER_PATTERN_ + ')|' +
+ goog.testing.stacktrace.OPERA_ANONYMOUS_FUNCTION_NAME_PATTERN_ +
+ ')(\\(.*\\)))?@';
+
+
+/**
+ * Regular expression for parsing on stack frame in Opera 11.68+
+ * @type {!RegExp}
+ * @const
+ * @private
+ */
+goog.testing.stacktrace.OPERA_STACK_FRAME_REGEXP_ = new RegExp('^' +
+ goog.testing.stacktrace.OPERA_FUNCTION_CALL_PATTERN_ +
+ goog.testing.stacktrace.URL_PATTERN_ + '?$');
+
+
+/**
* Regular expression for finding the function name in its source.
* @type {!RegExp}
* @private
@@ -299,6 +339,12 @@ goog.testing.stacktrace.parseStackFrame_ = function(frameStr) {
m[3] || '');
}
+ m = frameStr.match(goog.testing.stacktrace.OPERA_STACK_FRAME_REGEXP_);
+ if (m) {
+ return new goog.testing.stacktrace.Frame(m[2] || '', m[1] || m[3] || '',
+ '', m[4] || '', m[5] || '');
+ }
+
return null;
};
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/stacktrace_test.html b/contexts/data/lib/closure-library/closure/goog/testing/stacktrace_test.html
index 28171c1..3283495 100644
--- a/contexts/data/lib/closure-library/closure/goog/testing/stacktrace_test.html
+++ b/contexts/data/lib/closure-library/closure/goog/testing/stacktrace_test.html
@@ -87,6 +87,73 @@ function testParseStackFrameInChrome() {
assertObjectEquals('eval', expected, frame);
}
+function testParseStackFrameInOpera() {
+ var frameString = '@';
+ var frame = goog.testing.stacktrace.parseStackFrame_(frameString);
+ var expected = new goog.testing.stacktrace.Frame('', '', '', '', '');
+ assertObjectEquals('empty frame', expected, frame);
+
+ frameString = '@javascript:console.log(Error().stack):1';
+ frame = goog.testing.stacktrace.parseStackFrame_(frameString);
+ expected = new goog.testing.stacktrace.Frame('', '', '', '',
+ 'javascript:console.log(Error().stack):1');
+ assertObjectEquals('javascript path only', expected, frame);
+
+ frameString = '@file:///foo:42';
+ frame = goog.testing.stacktrace.parseStackFrame_(frameString);
+ expected = new goog.testing.stacktrace.Frame('', '', '', '',
+ 'file:///foo:42');
+ assertObjectEquals('path only', expected, frame);
+
+ // (function go() { throw Error() })()
+ // var c = go; c()
+ frameString = 'go([arguments not available])@';
+ frame = goog.testing.stacktrace.parseStackFrame_(frameString);
+ expected = new goog.testing.stacktrace.Frame('', 'go', '',
+ '([arguments not available])', '');
+ assertObjectEquals('name and empty path', expected, frame);
+
+ frameString = 'go([arguments not available])@file:///foo:42';
+ frame = goog.testing.stacktrace.parseStackFrame_(frameString);
+ expected = new goog.testing.stacktrace.Frame('', 'go', '',
+ '([arguments not available])', 'file:///foo:42');
+ assertObjectEquals('name and path', expected, frame);
+
+ // (function() { throw Error() })()
+ frameString =
+ '<anonymous function>([arguments not available])@file:///foo:42';
+ frame = goog.testing.stacktrace.parseStackFrame_(frameString);
+ expected = new goog.testing.stacktrace.Frame('', '', '',
+ '([arguments not available])', 'file:///foo:42');
+ assertObjectEquals('anonymous function', expected, frame);
+
+ // var b = {foo: function() { throw Error() }}
+ frameString = '<anonymous function: foo>()@file:///foo:42';
+ frame = goog.testing.stacktrace.parseStackFrame_(frameString);
+ expected = new goog.testing.stacktrace.Frame(
+ '', 'foo', '', '()', 'file:///foo:42');
+ assertObjectEquals('object literal function', expected, frame);
+
+ // var c = {}; c.foo = function() { throw Error() }
+ frameString = '<anonymous function: c.foo>()@file:///foo:42';
+ frame = goog.testing.stacktrace.parseStackFrame_(frameString);
+ expected = new goog.testing.stacktrace.Frame(
+ 'c', 'foo', '', '()', 'file:///foo:42');
+ assertObjectEquals('named object literal function', expected, frame);
+
+ frameString = '<anonymous function: Foo.prototype.bar>()@';
+ frame = goog.testing.stacktrace.parseStackFrame_(frameString);
+ expected = new goog.testing.stacktrace.Frame(
+ 'Foo.prototype', 'bar', '', '()', '');
+ assertObjectEquals('prototype function', expected, frame);
+
+ frameString = '<anonymous function: goog.Foo.prototype.bar>()@';
+ frame = goog.testing.stacktrace.parseStackFrame_(frameString);
+ expected = new goog.testing.stacktrace.Frame(
+ 'goog.Foo.prototype', 'bar', '', '()', '');
+ assertObjectEquals('namespaced prototype function', expected, frame);
+}
+
// All test strings are parsed with the conventional and long
// frame algorithms.
function testParseStackFrameInFirefox() {
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/storage/fakemechanism.js b/contexts/data/lib/closure-library/closure/goog/testing/storage/fakemechanism.js
new file mode 100644
index 0000000..80a0e68
--- /dev/null
+++ b/contexts/data/lib/closure-library/closure/goog/testing/storage/fakemechanism.js
@@ -0,0 +1,66 @@
+// Copyright 2012 The Closure Library Authors. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS-IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+/**
+ * @fileoverview Provides a fake storage mechanism for testing.
+ */
+
+goog.provide('goog.testing.storage.FakeMechanism');
+goog.setTestOnly('goog.testing.storage.FakeMechanism');
+
+goog.require('goog.storage.mechanism.IterableMechanism');
+goog.require('goog.structs.Map');
+
+
+
+/**
+ * Creates a fake iterable mechanism.
+ *
+ * @constructor
+ * @extends {goog.storage.mechanism.IterableMechanism}
+ */
+goog.testing.storage.FakeMechanism = function() {
+ /**
+ * @type {goog.structs.Map}
+ * @private
+ */
+ this.storage_ = new goog.structs.Map();
+};
+goog.inherits(goog.testing.storage.FakeMechanism,
+ goog.storage.mechanism.IterableMechanism);
+
+
+/** @override */
+goog.testing.storage.FakeMechanism.prototype.set = function(key, value) {
+ this.storage_.set(key, value);
+};
+
+
+/** @override */
+goog.testing.storage.FakeMechanism.prototype.get = function(key) {
+ return /** @type {?string} */ (
+ this.storage_.get(key, null /* default value */));
+};
+
+
+/** @override */
+goog.testing.storage.FakeMechanism.prototype.remove = function(key) {
+ this.storage_.remove(key);
+};
+
+
+/** @override */
+goog.testing.storage.FakeMechanism.prototype.__iterator__ = function(opt_keys) {
+ return this.storage_.__iterator__(opt_keys);
+};
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/style/.svn/all-wcprops b/contexts/data/lib/closure-library/closure/goog/testing/style/.svn/all-wcprops
deleted file mode 100644
index 4342ab7..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/style/.svn/all-wcprops
+++ /dev/null
@@ -1,29 +0,0 @@
-K 25
-svn:wc:ra_dav:version-url
-V 51
-/svn/!svn/ver/1291/trunk/closure/goog/testing/style
-END
-style_test.html
-K 25
-svn:wc:ra_dav:version-url
-V 67
-/svn/!svn/ver/1291/trunk/closure/goog/testing/style/style_test.html
-END
-layoutasserts_test.html
-K 25
-svn:wc:ra_dav:version-url
-V 74
-/svn/!svn/ver/850/trunk/closure/goog/testing/style/layoutasserts_test.html
-END
-style.js
-K 25
-svn:wc:ra_dav:version-url
-V 60
-/svn/!svn/ver/1291/trunk/closure/goog/testing/style/style.js
-END
-layoutasserts.js
-K 25
-svn:wc:ra_dav:version-url
-V 68
-/svn/!svn/ver/1291/trunk/closure/goog/testing/style/layoutasserts.js
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/style/.svn/entries b/contexts/data/lib/closure-library/closure/goog/testing/style/.svn/entries
deleted file mode 100644
index 4f07eb8..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/style/.svn/entries
+++ /dev/null
@@ -1,164 +0,0 @@
-10
-
-dir
-1494
-http://closure-library.googlecode.com/svn/trunk/closure/goog/testing/style
-http://closure-library.googlecode.com/svn
-
-
-
-2011-09-21T14:15:04.000000Z
-1291
-erikwright@google.com
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-0b95b8e8-c90f-11de-9d4f-f947ee5921c8
-
-style_test.html
-file
-
-
-
-
-2011-12-23T22:42:27.244315Z
-7bbbce9808659dc1c60795f254eaf8d7
-2011-09-21T14:15:04.000000Z
-1291
-erikwright@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-3021
-
-layoutasserts_test.html
-file
-
-
-
-
-2011-12-23T22:42:27.245315Z
-f873c37a1222fe1b510129f2052a43e5
-2011-04-12T20:35:47.000000Z
-850
-diegosalas@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-7789
-
-style.js
-file
-
-
-
-
-2011-12-23T22:42:27.246315Z
-5d32523794d60b9c1c34feb1f773b9cf
-2011-09-21T14:15:04.000000Z
-1291
-erikwright@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-2989
-
-layoutasserts.js
-file
-
-
-
-
-2011-12-23T22:42:27.246315Z
-0364c4fc6fb17db54d0f03de4067f32f
-2011-09-21T14:15:04.000000Z
-1291
-erikwright@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-11347
-
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/style/.svn/prop-base/layoutasserts.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/style/.svn/prop-base/layoutasserts.js.svn-base
deleted file mode 100644
index 530636b..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/style/.svn/prop-base/layoutasserts.js.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 15
-text/javascript
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/style/.svn/prop-base/layoutasserts_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/style/.svn/prop-base/layoutasserts_test.html.svn-base
deleted file mode 100644
index d356868..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/style/.svn/prop-base/layoutasserts_test.html.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 9
-text/html
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/style/.svn/prop-base/style.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/style/.svn/prop-base/style.js.svn-base
deleted file mode 100644
index 530636b..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/style/.svn/prop-base/style.js.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 15
-text/javascript
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/style/.svn/prop-base/style_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/style/.svn/prop-base/style_test.html.svn-base
deleted file mode 100644
index d356868..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/style/.svn/prop-base/style_test.html.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 9
-text/html
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/style/.svn/text-base/layoutasserts.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/style/.svn/text-base/layoutasserts.js.svn-base
deleted file mode 100644
index f479353..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/style/.svn/text-base/layoutasserts.js.svn-base
+++ /dev/null
@@ -1,310 +0,0 @@
-// Copyright 2009 The Closure Library Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS-IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/**
- * @fileoverview A utility class for making layout assertions. This is a port
- * of http://go/layoutbot.java
- * See {@link http://go/layouttesting}.
- */
-
-goog.provide('goog.testing.style.layoutasserts');
-
-goog.require('goog.style');
-goog.require('goog.testing.asserts');
-goog.require('goog.testing.style');
-
-
-/**
- * Asserts that an element has:
- * 1 - a CSS rendering the makes the element visible.
- * 2 - a non-zero width and height.
- * @param {Element|string} a The element or optionally the comment string.
- * @param {Element=} opt_b The element when a comment string is present.
- */
-function assertIsVisible(a, opt_b) {
- _validateArguments(1, arguments);
- var element = nonCommentArg(1, 1, arguments);
-
- _assert(commentArg(1, arguments),
- goog.testing.style.isVisible(element) &&
- goog.testing.style.hasVisibleDimensions(element),
- 'Specified element should be visible.');
-}
-
-
-/**
- * The counter assertion of assertIsVisible().
- * @param {Element|string} a The element or optionally the comment string.
- * @param {Element=} opt_b The element when a comment string is present.
- */
-function assertNotVisible(a, opt_b) {
- _validateArguments(1, arguments);
- var element = nonCommentArg(1, 1, arguments);
- if (!element) {
- return;
- }
-
- _assert(commentArg(1, arguments),
- !goog.testing.style.isVisible(element) ||
- !goog.testing.style.hasVisibleDimensions(element),
- 'Specified element should not be visible.');
-}
-
-
-/**
- * Asserts that the two specified elements intersect.
- * @param {Element|string} a The first element or optionally the comment string.
- * @param {Element} b The second element or the first element if comment string
- * is present.
- * @param {Element=} opt_c The second element if comment string is present.
- */
-function assertIntersect(a, b, opt_c) {
- _validateArguments(2, arguments);
- var element = nonCommentArg(1, 2, arguments);
- var otherElement = nonCommentArg(2, 2, arguments);
-
- _assert(commentArg(1, arguments),
- goog.testing.style.intersects(element, otherElement),
- 'Elements should intersect.');
-}
-
-
-/**
- * Asserts that the two specified elements do not intersect.
- * @param {Element|string} a The first element or optionally the comment string.
- * @param {Element} b The second element or the first element if comment string
- * is present.
- * @param {Element=} opt_c The second element if comment string is present.
- */
-function assertNoIntersect(a, b, opt_c) {
- _validateArguments(2, arguments);
- var element = nonCommentArg(1, 2, arguments);
- var otherElement = nonCommentArg(2, 2, arguments);
-
- _assert(commentArg(1, arguments),
- !goog.testing.style.intersects(element, otherElement),
- 'Elements should not intersect.');
-}
-
-
-/**
- * Asserts that the element must have the specified width.
- * @param {Element|string} a The first element or optionally the comment string.
- * @param {Element} b The second element or the first element if comment string
- * is present.
- * @param {Element=} opt_c The second element if comment string is present.
- */
-function assertWidth(a, b, opt_c) {
- _validateArguments(2, arguments);
- var element = nonCommentArg(1, 2, arguments);
- var width = nonCommentArg(2, 2, arguments);
- var size = goog.style.getSize(element);
- var elementWidth = size.width;
-
- _assert(commentArg(1, arguments),
- goog.testing.style.layoutasserts.isWithinThreshold_(
- width, elementWidth, 0 /* tolerance */),
- 'Element should have width ' + width + ' but was ' + elementWidth + '.');
-}
-
-
-/**
- * Asserts that the element must have the specified width within the specified
- * tolerance.
- * @param {Element|string} a The element or optionally the comment string.
- * @param {number|Element} b The height or the element if comment string is
- * present.
- * @param {number} c The tolerance or the height if comment string is
- * present.
- * @param {number=} opt_d The tolerance if comment string is present.
- */
-function assertWidthWithinTolerance(a, b, c, opt_d) {
- _validateArguments(3, arguments);
- var element = nonCommentArg(1, 3, arguments);
- var width = nonCommentArg(2, 3, arguments);
- var tolerance = nonCommentArg(3, 3, arguments);
- var size = goog.style.getSize(element);
- var elementWidth = size.width;
-
- _assert(commentArg(1, arguments),
- goog.testing.style.layoutasserts.isWithinThreshold_(
- width, elementWidth, tolerance),
- 'Element width(' + elementWidth + ') should be within given width(' +
- width + ') with tolerance value of ' + tolerance + '.');
-}
-
-
-/**
- * Asserts that the element must have the specified height.
- * @param {Element|string} a The first element or optionally the comment string.
- * @param {Element} b The second element or the first element if comment string
- * is present.
- * @param {Element=} opt_c The second element if comment string is present.
- */
-function assertHeight(a, b, opt_c) {
- _validateArguments(2, arguments);
- var element = nonCommentArg(1, 2, arguments);
- var height = nonCommentArg(2, 2, arguments);
- var size = goog.style.getSize(element);
- var elementHeight = size.height;
-
- _assert(commentArg(1, arguments),
- goog.testing.style.layoutasserts.isWithinThreshold_(
- height, elementHeight, 0 /* tolerance */),
- 'Element should have height ' + height + '.');
-}
-
-
-/**
- * Asserts that the element must have the specified height within the specified
- * tolerance.
- * @param {Element|string} a The element or optionally the comment string.
- * @param {number|Element} b The height or the element if comment string is
- * present.
- * @param {number} c The tolerance or the height if comment string is
- * present.
- * @param {number=} opt_d The tolerance if comment string is present.
- */
-function assertHeightWithinTolerance(a, b, c, opt_d) {
- _validateArguments(3, arguments);
- var element = nonCommentArg(1, 3, arguments);
- var height = nonCommentArg(2, 3, arguments);
- var tolerance = nonCommentArg(3, 3, arguments);
- var size = goog.style.getSize(element);
- var elementHeight = size.height;
-
- _assert(commentArg(1, arguments),
- goog.testing.style.layoutasserts.isWithinThreshold_(
- height, elementHeight, tolerance),
- 'Element width(' + elementHeight + ') should be within given width(' +
- height + ') with tolerance value of ' + tolerance + '.');
-}
-
-
-/**
- * Asserts that the first element is to the left of the second element.
- * @param {Element|string} a The first element or optionally the comment string.
- * @param {Element} b The second element or the first element if comment string
- * is present.
- * @param {Element=} opt_c The second element if comment string is present.
- */
-function assertIsLeftOf(a, b, opt_c) {
- _validateArguments(2, arguments);
- var element = nonCommentArg(1, 2, arguments);
- var otherElement = nonCommentArg(2, 2, arguments);
- var elementRect = goog.style.getBounds(element);
- var otherElementRect = goog.style.getBounds(otherElement);
-
- _assert(commentArg(1, arguments),
- elementRect.left < otherElementRect.left,
- 'Elements should be left to right.');
-}
-
-
-/**
- * Asserts that the first element is strictly left of the second element.
- * @param {Element|string} a The first element or optionally the comment string.
- * @param {Element} b The second element or the first element if comment string
- * is present.
- * @param {Element=} opt_c The second element if comment string is present.
- */
-function assertIsStrictlyLeftOf(a, b, opt_c) {
- _validateArguments(2, arguments);
- var element = nonCommentArg(1, 2, arguments);
- var otherElement = nonCommentArg(2, 2, arguments);
- var elementRect = goog.style.getBounds(element);
- var otherElementRect = goog.style.getBounds(otherElement);
-
- _assert(commentArg(1, arguments),
- elementRect.left + elementRect.width < otherElementRect.left,
- 'Elements should be strictly left to right.');
-}
-
-
-/**
- * Asserts that the first element is higher than the second element.
- * @param {Element|string} a The first element or optionally the comment string.
- * @param {Element} b The second element or the first element if comment string
- * is present.
- * @param {Element=} opt_c The second element if comment string is present.
- */
-function assertIsAbove(a, b, opt_c) {
- _validateArguments(2, arguments);
- var element = nonCommentArg(1, 2, arguments);
- var otherElement = nonCommentArg(2, 2, arguments);
- var elementRect = goog.style.getBounds(element);
- var otherElementRect = goog.style.getBounds(otherElement);
-
- _assert(commentArg(1, arguments),
- elementRect.top < otherElementRect.top,
- 'Elements should be top to bottom.');
-}
-
-
-/**
- * Asserts that the first element is strictly higher than the second element.
- * @param {Element|string} a The first element or optionally the comment string.
- * @param {Element} b The second element or the first element if comment string
- * is present.
- * @param {Element=} opt_c The second element if comment string is present.
- */
-function assertIsStrictlyAbove(a, b, opt_c) {
- _validateArguments(2, arguments);
- var element = nonCommentArg(1, 2, arguments);
- var otherElement = nonCommentArg(2, 2, arguments);
- var elementRect = goog.style.getBounds(element);
- var otherElementRect = goog.style.getBounds(otherElement);
-
- _assert(commentArg(1, arguments),
- elementRect.top + elementRect.height < otherElementRect.top,
- 'Elements should be strictly top to bottom.');
-}
-
-
-/**
- * Asserts that the first element's bounds contain the bounds of the second
- * element.
- * @param {Element|string} a The first element or optionally the comment string.
- * @param {Element} b The second element or the first element if comment string
- * is present.
- * @param {Element=} opt_c The second element if comment string is present.
- */
-function assertContained(a, b, opt_c) {
- _validateArguments(2, arguments);
- var element = nonCommentArg(1, 2, arguments);
- var otherElement = nonCommentArg(2, 2, arguments);
- var elementRect = goog.style.getBounds(element);
- var otherElementRect = goog.style.getBounds(otherElement);
-
- _assert(commentArg(1, arguments),
- elementRect.contains(otherElementRect),
- 'Element should be contained within the other element.');
-}
-
-
-/**
- * Returns true if the difference between val1 and val2 is less than or equal to
- * the threashold.
- * @param {number} val1 The first value.
- * @param {number} val2 The second value.
- * @param {number} threshold The threshold value.
- * @return {boolean} Whether or not the the values are within the threshold.
- * @private
- */
-goog.testing.style.layoutasserts.isWithinThreshold_ = function(
- val1, val2, threshold) {
- return Math.abs(val1 - val2) <= threshold;
-};
-
-
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/style/.svn/text-base/layoutasserts_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/style/.svn/text-base/layoutasserts_test.html.svn-base
deleted file mode 100644
index c497805..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/style/.svn/text-base/layoutasserts_test.html.svn-base
+++ /dev/null
@@ -1,269 +0,0 @@
-<!DOCTYPE html>
-
-<!--
- All Rights Reserved.
--->
-
-<html>
-<!--
-Copyright 2009 The Closure Library Authors. All Rights Reserved.
-
-Use of this source code is governed by the Apache License, Version 2.0.
-See the COPYING file for details.
--->
-<head>
-<meta http-equiv="X-UA-Compatible" content="IE=edge">
- <title>goog.testing.style.layoutasserts Tests</title>
- <script src="../../base.js"></script>
- <script>
- goog.require('goog.dom');
- goog.require('goog.style');
- goog.require('goog.testing.jsunit');
- goog.require('goog.testing.style.layoutasserts');
- </script>
-</head>
-<body>
- <div id="element1">
- </div>
- <div id="element2">
- </div>
- <script>
-
- var div1;
- var div2;
- var DEFAULT_WIDTH = 200;
- var DEFAULT_HEIGHT = 100;
-
- function setUp() {
- div1 = goog.dom.createDom(
- 'div',
- {
- id: 'test',
- className: 'test',
- style: 'position:absolute;top:0;left:0;' +
- 'width:' + DEFAULT_WIDTH + 'px;' +
- 'height:' + DEFAULT_HEIGHT + 'px;' +
- 'background-color:#EEE',
- innerHTML: 'abc'
- });
- div2 = goog.dom.createDom('div',
- {
- id: 'test2',
- className: 'test2',
- style: 'position:absolute;' +
- 'top:0;left:0;' +
- 'width:' + DEFAULT_WIDTH + 'px;' +
- 'height:' + DEFAULT_HEIGHT + 'px;' +
- 'background-color:#F00',
- innerHTML: 'abc'
- });
-
- }
-
-
- function tearDown() {
- div1 = null;
- div2 = null;
- }
-
-
- /**
- * Tests assertIsVisible.
- */
- function testAssertIsVisible() {
- assertThrows('Exception should be thrown when asserting visibility.',
- goog.bind(assertIsVisible, null, null)); // assertIsVisible(null)
-
- // Attach it to BODY tag and assert that it is visible.
- document.body.appendChild(div1);
- assertIsVisible('Div should be visible.', div1);
-
- // Tests with hidden element
- failed = false;
- goog.style.showElement(div1, false /* display */);
- assertThrows('Exception should be thrown when asserting visibility.',
- goog.bind(assertIsVisible, null, div1));
-
- // Clean up.
- document.body.removeChild(div1);
- }
-
-
- /**
- * Tests assertNotVisible.
- */
- function testAssertNotVisible() {
- // Tests null as a parameter.
- var element = null;
- assertNotVisible(element);
-
- // Attach the element to BODY element, assert should fail.
- document.body.appendChild(div1);
- assertThrows('Exception should be thrown when asserting non-visibility.',
- goog.bind(assertNotVisible, null, div1));
-
- // Clean up.
- document.body.removeChild(div1);
- }
-
-
- /**
- * Tests assertIsIntersect.
- */
- function testAssertIntersect() {
- document.body.appendChild(div1);
- document.body.appendChild(div2);
-
- // No intersection
- goog.style.setPosition(div1, 0, 0);
- goog.style.setPosition(div2, 500, 500);
- assertThrows('Exception should be thrown when asserting intersection.',
- goog.bind(assertIntersect, null, div1, div2));
- assertNoIntersect(div1,div2);
-
- // Some intersection
- goog.style.setPosition(div1, 0, 0);
- goog.style.setPosition(div2, 50, 50);
- assertThrows('Exception should be thrown when asserting no intersection.',
- goog.bind(assertNoIntersect, null, div1, div2));
- assertIntersect(div1, div2);
-
- // Completely superimposed.
- goog.style.setPosition(div1, 0, 0);
- goog.style.setPosition(div2, 0, 0);
- assertThrows('Exception should be thrown when asserting no intersection.',
- goog.bind(assertNoIntersect, null, div1, div2));
- assertIntersect(div1, div2)
- }
-
-
- /**
- * Tests assertWidth.
- */
- function testAssertWidth() {
- document.body.appendChild(div1);
-
- // Test correct width
- assertWidth(div1, DEFAULT_WIDTH);
-
- // Test wrong width
- assertThrows('Exception should be thrown when elements has wrong width',
- goog.bind(assertWidth, null, div1, 400));
-
- // Test a valid tolerance value
- assertWidthWithinTolerance(div1, 180, 20);
-
- // Test exceeding tolerance value
- assertThrows(
- 'Exception should be thrown when element\'s width exceeds tolerance',
- goog.bind(assertWidthWithinTolerance, null, div1, 100, 0.1));
- }
-
-
- /**
- * Tests assertHeight.
- */
- function testAssertHeight() {
- document.body.appendChild(div1);
-
- // Test correct height
- assertHeight(div1, DEFAULT_HEIGHT);
-
- // Test wrong height
- assertThrows('Exception should be thrown when element has wrong height.',
- goog.bind(assertHeightWithinTolerance, null, div1, 300));
-
- // Test a valid tolerance value
- assertHeightWithinTolerance(div1, 90, 10);
-
- // Test exceeding tolerance value
- assertThrows(
- 'Exception should be thrown when element\'s height exceeds tolerance',
- goog.bind(assertHeight, null, div1, 50, 0.2));
- }
-
-
- /**
- * Tests assertIsLeftOf.
- */
- function testAssertIsLeftOf() {
- document.body.appendChild(div1);
- document.body.appendChild(div2);
-
- // Test elements of same size & location
- assertThrows('Exception should be thrown when elements intersect.',
- goog.bind(assertIsLeftOf, null, div1, div2));
- assertThrows('Exception should be thrown when elements intersect.',
- goog.bind(
- assertIsStrictlyLeftOf, null, div1, div2));
-
- // Test elements that are not left to right
- goog.style.setPosition(div1, 100, 0);
- goog.style.setPosition(div2, 0, 0);
- assertThrows(
- 'Exception should be thrown when elements are not left to right.',
- goog.bind(assertIsLeftOf, null, div1, div2));
- assertThrows(
- 'Exception should be thrown when elements are not left to right.',
- goog.bind(
- assertIsStrictlyLeftOf, null, div1, div2));
-
- // Test elements that intersect, but is left to right
- goog.style.setPosition(div1, 0, 0);
- goog.style.setPosition(div2, 100, 0);
- assertIsLeftOf(div1, div2);
- assertThrows('Exception should be thrown when elements intersect.',
- goog.bind(
- assertIsStrictlyLeftOf, null, div1, div2));
-
- // Test elements that are strictly left to right
- goog.style.setPosition(div1, 0, 0);
- goog.style.setPosition(div2, 999, 0);
- assertIsLeftOf(div1, div2);
- assertIsStrictlyLeftOf(div1, div2);
- }
-
-
- /**
- * Tests assertIsAbove.
- */
- function testAssertIsAbove() {
- document.body.appendChild(div1);
- document.body.appendChild(div2);
-
- // Test elements of same size & location
- assertThrows('Exception should be thrown when elements intersect.',
- goog.bind(assertIsAbove, null, div1, div2));
- assertThrows('Exception should be thrown when elements intersect.',
- goog.bind(
- assertIsStrictlyAbove, null, div1, div2));
-
- // Test elements that are not top to bottom
- goog.style.setPosition(div1, 0, 999);
- goog.style.setPosition(div2, 0, 0);
- assertThrows(
- 'Exception should be thrown when elements are not top to bottom.',
- goog.bind(assertIsAbove, null, div1, div2));
- assertThrows(
- 'Exception should be thrown when elements are not top to bottom.',
- goog.bind(
- assertIsStrictlyAbove, null, div1, div2));
-
- // Test elements that intersect, but is top to bottom
- goog.style.setPosition(div1, 0, 0);
- goog.style.setPosition(div2, 0, 50);
- assertIsAbove(div1, div2);
- assertThrows('Exception should be thrown when elements intersect.',
- goog.bind(
- assertIsStrictlyAbove, null, div1, div2));
-
- // Test elements that are top to bottom
- goog.style.setPosition(div1, 0, 0);
- goog.style.setPosition(div2, 0, 999);
- assertIsAbove(div1, div2);
- assertIsStrictlyAbove(div1, div2);
- }
-
- </script>
-</body>
-</html>
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/style/.svn/text-base/style.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/style/.svn/text-base/style.js.svn-base
deleted file mode 100644
index 85a5a98..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/style/.svn/text-base/style.js.svn-base
+++ /dev/null
@@ -1,86 +0,0 @@
-// Copyright 2011 The Closure Library Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS-IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/**
- * @fileoverview Utilities for inspecting page layout. This is a port of
- * http://go/layoutbot.java
- * See {@link http://go/layouttesting}.
- */
-
-goog.provide('goog.testing.style');
-
-goog.require('goog.math.Rect');
-goog.require('goog.style');
-
-
-/**
- * Determines whether the bounding rectangles of the given elements intersect.
- * @param {Element} element The first element.
- * @param {Element} otherElement The second element.
- * @return {boolean} Whether the bounding rectangles of the given elements
- * intersect.
- */
-goog.testing.style.intersects = function(element, otherElement) {
- var elementRect = goog.style.getBounds(element);
- var otherElementRect = goog.style.getBounds(otherElement);
- return goog.math.Rect.intersects(elementRect, otherElementRect);
-};
-
-
-/**
- * Determines whether the element has visible dimensions, i.e. x > 0 && y > 0.
- * @param {Element} element The element to check.
- * @return {boolean} Whether the element has visible dimensions.
- */
-goog.testing.style.hasVisibleDimensions = function(element) {
- var elSize = goog.style.getSize(element);
- var shortest = elSize.getShortest();
- if (shortest <= 0) {
- return false;
- }
-
- return true;
-};
-
-
-/**
- * Determines whether the CSS style of the element renders it visible.
- * @param {!Element} element The element to check.
- * @return {boolean} Whether the CSS style of the element renders it visible.
- */
-goog.testing.style.isVisible = function(element) {
- var visibilityStyle =
- goog.testing.style.getAvailableStyle_(element, 'visibility');
- var displayStyle =
- goog.testing.style.getAvailableStyle_(element, 'display');
-
- return (visibilityStyle != 'hidden' && displayStyle != 'none');
-};
-
-
-/**
- * This is essentially goog.style.getStyle_. goog.style.getStyle_ is private
- * and is not a recommended way for general purpose style extractor. For the
- * purposes of layout testing, we only use this function for retrieving
- * 'visiblity' and 'display' style.
- * @param {!Element} element The element to retrieve the style from.
- * @param {string} style Style property name.
- * @return {string} Style value.
- * @private
- */
-goog.testing.style.getAvailableStyle_ = function(element, style) {
- return goog.style.getComputedStyle(element, style) ||
- goog.style.getCascadedStyle(element, style) ||
- goog.style.getStyle(element, style);
-};
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/style/.svn/text-base/style_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/style/.svn/text-base/style_test.html.svn-base
deleted file mode 100644
index c74fa92..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/style/.svn/text-base/style_test.html.svn-base
+++ /dev/null
@@ -1,105 +0,0 @@
-<!DOCTYPE html>
-<html>
-<!--
-Copyright 2011 The Closure Library Authors. All Rights Reserved.
-
-Use of this source code is governed by the Apache License, Version 2.0.
-See the COPYING file for details.
-
--->
-<head>
-<meta http-equiv="X-UA-Compatible" content="IE=edge">
- <title>goog.testing.style Tests</title>
- <script src="../../base.js"></script>
- <script>
- goog.require('goog.dom');
- goog.require('goog.style');
- goog.require('goog.testing.jsunit');
- goog.require('goog.testing.style');
- </script>
-</head>
-<body>
- <script>
-
- var div1;
- var div2;
-
- function setUp() {
- var createDiv = function(color) {
- var div = goog.dom.createDom(
- 'div',
- {
- style: 'position:absolute;top:0;left:0;' +
- 'width:200px;height:100px;' +
- 'background-color:' + color,
- innerHTML: 'abc'
- });
- document.body.appendChild(div);
- return div;
- };
-
- div1 = createDiv('#EEE');
- div2 = createDiv('#F00');
- }
-
-
- function tearDown() {
- if (div1.parentNode)
- div1.parentNode.removeChild(div1);
- if (div2.parentNode)
- div2.parentNode.removeChild(div2);
-
- div1 = null;
- div2 = null;
- }
-
-
- function testIsVisible() {
- assertTrue('The div should be detected as visible.',
- goog.testing.style.isVisible(div1));
-
- // Tests with hidden element
- goog.style.showElement(div1, false /* display */);
- assertFalse('The div should be detected as not visible.',
- goog.testing.style.isVisible(div1));
- }
-
-
- function testHasVisibleDimensions() {
- goog.style.setSize(div1, 0, 0);
- assertFalse('0x0 should not be considered visible dimensions.',
- goog.testing.style.hasVisibleDimensions(div1));
- goog.style.setSize(div1, 10, 0);
- assertFalse('10x0 should not be considered visible dimensions.',
- goog.testing.style.hasVisibleDimensions(div1));
- goog.style.setSize(div1, 10, 10);
- assertTrue('10x10 should be considered visible dimensions.',
- goog.testing.style.hasVisibleDimensions(div1));
- goog.style.setSize(div1, 0, 10);
- assertFalse('0x10 should not be considered visible dimensions.',
- goog.testing.style.hasVisibleDimensions(div1));
- }
-
- function testIntersects() {
- // No intersection
- goog.style.setPosition(div1, 0, 0);
- goog.style.setPosition(div2, 500, 500);
- assertFalse('The divs should not be determined to itersect.',
- goog.testing.style.intersects(div1, div2));
-
- // Some intersection
- goog.style.setPosition(div1, 0, 0);
- goog.style.setPosition(div2, 50, 50);
- assertTrue('The divs should be determined to itersect.',
- goog.testing.style.intersects(div1, div2));
-
- // Completely superimposed.
- goog.style.setPosition(div1, 0, 0);
- goog.style.setPosition(div2, 0, 0);
- assertTrue('The divs should be determined to itersect.',
- goog.testing.style.intersects(div1, div2));
- }
-
- </script>
-</body>
-</html>
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/style/layoutasserts.js b/contexts/data/lib/closure-library/closure/goog/testing/style/layoutasserts.js
index f479353..2f9cb34 100644
--- a/contexts/data/lib/closure-library/closure/goog/testing/style/layoutasserts.js
+++ b/contexts/data/lib/closure-library/closure/goog/testing/style/layoutasserts.js
@@ -32,7 +32,7 @@ goog.require('goog.testing.style');
* @param {Element|string} a The element or optionally the comment string.
* @param {Element=} opt_b The element when a comment string is present.
*/
-function assertIsVisible(a, opt_b) {
+var assertIsVisible = function(a, opt_b) {
_validateArguments(1, arguments);
var element = nonCommentArg(1, 1, arguments);
@@ -40,7 +40,7 @@ function assertIsVisible(a, opt_b) {
goog.testing.style.isVisible(element) &&
goog.testing.style.hasVisibleDimensions(element),
'Specified element should be visible.');
-}
+};
/**
@@ -48,7 +48,7 @@ function assertIsVisible(a, opt_b) {
* @param {Element|string} a The element or optionally the comment string.
* @param {Element=} opt_b The element when a comment string is present.
*/
-function assertNotVisible(a, opt_b) {
+var assertNotVisible = function(a, opt_b) {
_validateArguments(1, arguments);
var element = nonCommentArg(1, 1, arguments);
if (!element) {
@@ -59,7 +59,7 @@ function assertNotVisible(a, opt_b) {
!goog.testing.style.isVisible(element) ||
!goog.testing.style.hasVisibleDimensions(element),
'Specified element should not be visible.');
-}
+};
/**
@@ -69,7 +69,7 @@ function assertNotVisible(a, opt_b) {
* is present.
* @param {Element=} opt_c The second element if comment string is present.
*/
-function assertIntersect(a, b, opt_c) {
+var assertIntersect = function(a, b, opt_c) {
_validateArguments(2, arguments);
var element = nonCommentArg(1, 2, arguments);
var otherElement = nonCommentArg(2, 2, arguments);
@@ -77,7 +77,7 @@ function assertIntersect(a, b, opt_c) {
_assert(commentArg(1, arguments),
goog.testing.style.intersects(element, otherElement),
'Elements should intersect.');
-}
+};
/**
@@ -87,7 +87,7 @@ function assertIntersect(a, b, opt_c) {
* is present.
* @param {Element=} opt_c The second element if comment string is present.
*/
-function assertNoIntersect(a, b, opt_c) {
+var assertNoIntersect = function(a, b, opt_c) {
_validateArguments(2, arguments);
var element = nonCommentArg(1, 2, arguments);
var otherElement = nonCommentArg(2, 2, arguments);
@@ -95,7 +95,7 @@ function assertNoIntersect(a, b, opt_c) {
_assert(commentArg(1, arguments),
!goog.testing.style.intersects(element, otherElement),
'Elements should not intersect.');
-}
+};
/**
@@ -105,7 +105,7 @@ function assertNoIntersect(a, b, opt_c) {
* is present.
* @param {Element=} opt_c The second element if comment string is present.
*/
-function assertWidth(a, b, opt_c) {
+var assertWidth = function(a, b, opt_c) {
_validateArguments(2, arguments);
var element = nonCommentArg(1, 2, arguments);
var width = nonCommentArg(2, 2, arguments);
@@ -116,7 +116,7 @@ function assertWidth(a, b, opt_c) {
goog.testing.style.layoutasserts.isWithinThreshold_(
width, elementWidth, 0 /* tolerance */),
'Element should have width ' + width + ' but was ' + elementWidth + '.');
-}
+};
/**
@@ -129,7 +129,7 @@ function assertWidth(a, b, opt_c) {
* present.
* @param {number=} opt_d The tolerance if comment string is present.
*/
-function assertWidthWithinTolerance(a, b, c, opt_d) {
+var assertWidthWithinTolerance = function(a, b, c, opt_d) {
_validateArguments(3, arguments);
var element = nonCommentArg(1, 3, arguments);
var width = nonCommentArg(2, 3, arguments);
@@ -142,7 +142,7 @@ function assertWidthWithinTolerance(a, b, c, opt_d) {
width, elementWidth, tolerance),
'Element width(' + elementWidth + ') should be within given width(' +
width + ') with tolerance value of ' + tolerance + '.');
-}
+};
/**
@@ -152,7 +152,7 @@ function assertWidthWithinTolerance(a, b, c, opt_d) {
* is present.
* @param {Element=} opt_c The second element if comment string is present.
*/
-function assertHeight(a, b, opt_c) {
+var assertHeight = function(a, b, opt_c) {
_validateArguments(2, arguments);
var element = nonCommentArg(1, 2, arguments);
var height = nonCommentArg(2, 2, arguments);
@@ -163,7 +163,7 @@ function assertHeight(a, b, opt_c) {
goog.testing.style.layoutasserts.isWithinThreshold_(
height, elementHeight, 0 /* tolerance */),
'Element should have height ' + height + '.');
-}
+};
/**
@@ -176,7 +176,7 @@ function assertHeight(a, b, opt_c) {
* present.
* @param {number=} opt_d The tolerance if comment string is present.
*/
-function assertHeightWithinTolerance(a, b, c, opt_d) {
+var assertHeightWithinTolerance = function(a, b, c, opt_d) {
_validateArguments(3, arguments);
var element = nonCommentArg(1, 3, arguments);
var height = nonCommentArg(2, 3, arguments);
@@ -189,7 +189,7 @@ function assertHeightWithinTolerance(a, b, c, opt_d) {
height, elementHeight, tolerance),
'Element width(' + elementHeight + ') should be within given width(' +
height + ') with tolerance value of ' + tolerance + '.');
-}
+};
/**
@@ -199,7 +199,7 @@ function assertHeightWithinTolerance(a, b, c, opt_d) {
* is present.
* @param {Element=} opt_c The second element if comment string is present.
*/
-function assertIsLeftOf(a, b, opt_c) {
+var assertIsLeftOf = function(a, b, opt_c) {
_validateArguments(2, arguments);
var element = nonCommentArg(1, 2, arguments);
var otherElement = nonCommentArg(2, 2, arguments);
@@ -209,7 +209,7 @@ function assertIsLeftOf(a, b, opt_c) {
_assert(commentArg(1, arguments),
elementRect.left < otherElementRect.left,
'Elements should be left to right.');
-}
+};
/**
@@ -219,7 +219,7 @@ function assertIsLeftOf(a, b, opt_c) {
* is present.
* @param {Element=} opt_c The second element if comment string is present.
*/
-function assertIsStrictlyLeftOf(a, b, opt_c) {
+var assertIsStrictlyLeftOf = function(a, b, opt_c) {
_validateArguments(2, arguments);
var element = nonCommentArg(1, 2, arguments);
var otherElement = nonCommentArg(2, 2, arguments);
@@ -229,7 +229,7 @@ function assertIsStrictlyLeftOf(a, b, opt_c) {
_assert(commentArg(1, arguments),
elementRect.left + elementRect.width < otherElementRect.left,
'Elements should be strictly left to right.');
-}
+};
/**
@@ -239,7 +239,7 @@ function assertIsStrictlyLeftOf(a, b, opt_c) {
* is present.
* @param {Element=} opt_c The second element if comment string is present.
*/
-function assertIsAbove(a, b, opt_c) {
+var assertIsAbove = function(a, b, opt_c) {
_validateArguments(2, arguments);
var element = nonCommentArg(1, 2, arguments);
var otherElement = nonCommentArg(2, 2, arguments);
@@ -249,7 +249,7 @@ function assertIsAbove(a, b, opt_c) {
_assert(commentArg(1, arguments),
elementRect.top < otherElementRect.top,
'Elements should be top to bottom.');
-}
+};
/**
@@ -259,7 +259,7 @@ function assertIsAbove(a, b, opt_c) {
* is present.
* @param {Element=} opt_c The second element if comment string is present.
*/
-function assertIsStrictlyAbove(a, b, opt_c) {
+var assertIsStrictlyAbove = function(a, b, opt_c) {
_validateArguments(2, arguments);
var element = nonCommentArg(1, 2, arguments);
var otherElement = nonCommentArg(2, 2, arguments);
@@ -269,7 +269,7 @@ function assertIsStrictlyAbove(a, b, opt_c) {
_assert(commentArg(1, arguments),
elementRect.top + elementRect.height < otherElementRect.top,
'Elements should be strictly top to bottom.');
-}
+};
/**
@@ -280,7 +280,7 @@ function assertIsStrictlyAbove(a, b, opt_c) {
* is present.
* @param {Element=} opt_c The second element if comment string is present.
*/
-function assertContained(a, b, opt_c) {
+var assertContained = function(a, b, opt_c) {
_validateArguments(2, arguments);
var element = nonCommentArg(1, 2, arguments);
var otherElement = nonCommentArg(2, 2, arguments);
@@ -290,7 +290,7 @@ function assertContained(a, b, opt_c) {
_assert(commentArg(1, arguments),
elementRect.contains(otherElementRect),
'Element should be contained within the other element.');
-}
+};
/**
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/style/style.js b/contexts/data/lib/closure-library/closure/goog/testing/style/style.js
index 85a5a98..636d8b6 100644
--- a/contexts/data/lib/closure-library/closure/goog/testing/style/style.js
+++ b/contexts/data/lib/closure-library/closure/goog/testing/style/style.js
@@ -20,6 +20,7 @@
goog.provide('goog.testing.style');
+goog.require('goog.dom');
goog.require('goog.math.Rect');
goog.require('goog.style');
@@ -68,6 +69,19 @@ goog.testing.style.isVisible = function(element) {
return (visibilityStyle != 'hidden' && displayStyle != 'none');
};
+/**
+ * Test whether the given element is on screen.
+ * @param {!Element} el The element to test.
+ * @return {boolean} Whether the element is on the screen.
+ */
+goog.testing.style.isOnScreen = function(el) {
+ var doc = goog.dom.getDomHelper(el).getDocument();
+ var viewport = goog.style.getVisibleRectForElement(doc.body);
+ var viewportRect = goog.math.Rect.createFromBox(viewport);
+ return goog.dom.contains(doc, el) &&
+ goog.style.getBounds(el).intersects(viewportRect);
+};
+
/**
* This is essentially goog.style.getStyle_. goog.style.getStyle_ is private
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/style/style_test.html b/contexts/data/lib/closure-library/closure/goog/testing/style/style_test.html
index c74fa92..70748ff 100644
--- a/contexts/data/lib/closure-library/closure/goog/testing/style/style_test.html
+++ b/contexts/data/lib/closure-library/closure/goog/testing/style/style_test.html
@@ -64,6 +64,63 @@ See the COPYING file for details.
goog.testing.style.isVisible(div1));
}
+ function testIsOnScreen() {
+ var el = document.createElement('div');
+ document.body.appendChild(el);
+
+ var dom = goog.dom.getDomHelper(el);
+ var winScroll = dom.getDocumentScroll();
+ var winSize = dom.getViewportSize();
+
+ el.style.position = 'absolute';
+ goog.style.setSize(el, 100, 100);
+
+ goog.style.setPosition(el, winScroll.x, winScroll.y);
+ assertTrue("An element fully on the screen is on screen.",
+ goog.testing.style.isOnScreen(el));
+
+ goog.style.setPosition(el, winScroll.x - 10, winScroll.y - 10);
+ assertTrue(
+ "An element partially off the top-left of the screen is on screen.",
+ goog.testing.style.isOnScreen(el));
+
+ goog.style.setPosition(el, winScroll.x - 150, winScroll.y - 10);
+ assertFalse(
+ "An element completely off the top of the screen is off screen.",
+ goog.testing.style.isOnScreen(el));
+
+ goog.style.setPosition(el, winScroll.x - 10, winScroll.y - 150);
+ assertFalse(
+ "An element completely off the left of the screen is off screen.",
+ goog.testing.style.isOnScreen(el));
+
+ goog.style.setPosition(el, winScroll.x + winSize.width + 1, winScroll.y);
+ assertFalse(
+ "An element completely off the right of the screen is off screen.",
+ goog.testing.style.isOnScreen(el));
+
+ goog.style.setPosition(el, winScroll.x, winScroll.y + winSize.height + 1);
+ assertFalse(
+ "An element completely off the bottom of the screen is off screen.",
+ goog.testing.style.isOnScreen(el));
+
+ goog.style.setPosition(el, winScroll.x + winSize.width - 10, winScroll.y);
+ assertTrue(
+ "An element partially off the right of the screen is on screen.",
+ goog.testing.style.isOnScreen(el));
+
+ goog.style.setPosition(el, winScroll.x, winScroll.y + winSize.height - 10);
+ assertTrue(
+ "An element partially off the bottom of the screen is on screen.",
+ goog.testing.style.isOnScreen(el));
+
+ var el2 = document.createElement('div');
+ el2.style.position = 'absolute';
+ goog.style.setSize(el2, 100, 100);
+ goog.style.setPosition(el2, winScroll.x, winScroll.y);
+ assertFalse("An element not in the DOM is not on screen.",
+ goog.testing.style.isOnScreen(el2));
+ }
function testHasVisibleDimensions() {
goog.style.setSize(div1, 0, 0);
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/testcase.js b/contexts/data/lib/closure-library/closure/goog/testing/testcase.js
index 4d4186c..d896212 100644
--- a/contexts/data/lib/closure-library/closure/goog/testing/testcase.js
+++ b/contexts/data/lib/closure-library/closure/goog/testing/testcase.js
@@ -29,6 +29,7 @@ goog.provide('goog.testing.TestCase.Order');
goog.provide('goog.testing.TestCase.Result');
goog.provide('goog.testing.TestCase.Test');
+goog.require('goog.object');
goog.require('goog.testing.asserts');
goog.require('goog.testing.stacktrace');
@@ -90,7 +91,10 @@ goog.testing.TestCase = function(opt_name) {
*/
this.testsToRun_ = null;
- var search = window.location.search;
+ var search = '';
+ if (goog.global.location) {
+ search = goog.global.location.search;
+ }
// Parse the 'runTests' query parameter into a set of test names and/or
// test indices.
@@ -160,22 +164,31 @@ goog.testing.TestCase.prototype.order = goog.testing.TestCase.Order.SORTED;
/**
- * Save a reference to window.timeout, so any code that overrides the default
- * behavior (e.g. MockClock) doesn't affect our runner.
+ * Save a reference to {@code window.setTimeout}, so any code that overrides the
+ * default behavior (the MockClock, for example) doesn't affect our runner.
* @type {function((Function|string), number, *=): number}
* @private
*/
-goog.testing.TestCase.protectedTimeout_ = window.setTimeout;
+goog.testing.TestCase.protectedSetTimeout_ = goog.global.setTimeout;
+
+
+/**
+ * Save a reference to {@code window.clearTimeout}, so any code that overrides
+ * the default behavior (e.g. MockClock) doesn't affect our runner.
+ * @type {function((null|number|undefined)): void}
+ * @private
+ */
+goog.testing.TestCase.protectedClearTimeout_ = goog.global.clearTimeout;
/**
- * Saved string referencing window.setTimeout's string serialization. IE
+ * Saved string referencing goog.global.setTimeout's string serialization. IE
* sometimes fails to uphold equality for setTimeout, but the string version
* stays the same.
* @type {string}
* @private
*/
-goog.testing.TestCase.setTimeoutAsString_ = String(window.setTimeout);
+goog.testing.TestCase.setTimeoutAsString_ = String(goog.global.setTimeout);
/**
@@ -191,8 +204,17 @@ goog.testing.TestCase.currentTestName = null;
* the browser is IE.
* @type {boolean}
*/
-goog.testing.TestCase.IS_IE = typeof opera == 'undefined' && !!navigator &&
- navigator.userAgent.indexOf('MSIE') != -1;
+goog.testing.TestCase.IS_IE = typeof opera == 'undefined' &&
+ !!goog.global.navigator &&
+ goog.global.navigator.userAgent.indexOf('MSIE') != -1;
+
+
+/**
+ * Exception object that was detected before a test runs.
+ * @type {*}
+ * @protected
+ */
+goog.testing.TestCase.prototype.exceptionBeforeTest;
/**
@@ -290,6 +312,16 @@ goog.testing.TestCase.prototype.getCount = function() {
/**
+ * Returns the number of tests actually run in the test case, i.e. subtracting
+ * any which are skipped.
+ * @return {number} The number of un-ignored tests.
+ */
+goog.testing.TestCase.prototype.getActuallyRunCount = function() {
+ return this.testsToRun_ ? goog.object.getCount(this.testsToRun_) : 0;
+};
+
+
+/**
* Returns the current test and increments the pointer.
* @return {goog.testing.TestCase.Test?} The current test case.
*/
@@ -351,7 +383,7 @@ goog.testing.TestCase.prototype.shouldRunTests = function() {
goog.testing.TestCase.prototype.execute = function() {
this.started = true;
this.reset();
- this.startTime_ = this.now_();
+ this.startTime_ = this.now();
this.running = true;
this.result_.totalCount = this.getCount();
@@ -376,22 +408,25 @@ goog.testing.TestCase.prototype.finalize = function() {
this.tearDownPage();
var restoredSetTimeout =
- goog.testing.TestCase.protectedTimeout_ == window.setTimeout;
+ goog.testing.TestCase.protectedSetTimeout_ == goog.global.setTimeout &&
+ goog.testing.TestCase.protectedClearTimeout_ == goog.global.clearTimeout;
if (!restoredSetTimeout && goog.testing.TestCase.IS_IE &&
- String(window.setTimeout) == goog.testing.TestCase.setTimeoutAsString_) {
+ String(goog.global.setTimeout) ==
+ goog.testing.TestCase.setTimeoutAsString_) {
// In strange cases, IE's value of setTimeout *appears* to change, but
// the string representation stays stable.
restoredSetTimeout = true;
}
if (!restoredSetTimeout) {
- var message = 'ERROR: Test did not restore setTimeout';
+ var message = 'ERROR: Test did not restore setTimeout and clearTimeout';
this.saveMessage(message);
var err = new goog.testing.TestCase.Error(this.name_, message);
this.result_.errors.push(err);
}
- window.setTimeout = goog.testing.TestCase.protectedTimeout_;
- this.endTime_ = this.now_();
+ goog.global.clearTimeout = goog.testing.TestCase.protectedClearTimeout_;
+ goog.global.setTimeout = goog.testing.TestCase.protectedSetTimeout_;
+ this.endTime_ = this.now();
this.running = false;
this.result_.runTime = this.endTime_ - this.startTime_;
this.result_.numFilesLoaded = this.countNumFilesLoaded_();
@@ -436,7 +471,7 @@ goog.testing.TestCase.prototype.isInsideMultiTestRunner = function() {
* @param {*} val The value to log. Will be ToString'd.
*/
goog.testing.TestCase.prototype.log = function(val) {
- if (!this.isInsideMultiTestRunner() && window.console) {
+ if (!this.isInsideMultiTestRunner() && goog.global.console) {
if (typeof val == 'string') {
val = this.getTimeStamp_() + ' : ' + val;
}
@@ -445,11 +480,11 @@ goog.testing.TestCase.prototype.log = function(val) {
// (http://code.google.com/p/chromium/issues/detail?id=50316).
// This is an acute problem for Errors, which almost never survive.
// Grab references to the immutable strings so they survive.
- window.console.log(val, val.message, val.stack);
+ goog.global.console.log(val, val.message, val.stack);
// TODO(gboyer): Consider for Chrome cloning any object if we can ensure
// there are no circular references.
} else {
- window.console.log(val);
+ goog.global.console.log(val);
}
}
};
@@ -477,7 +512,9 @@ goog.testing.TestCase.prototype.getReport = function(opt_verbose) {
var success = this.result_.isSuccess() && !this.testRunner_.hasErrors();
rv.push(this.name_ + ' [' + (success ? 'PASSED' : 'FAILED') + ']');
}
- rv.push(this.trimPath_(window.location.href));
+ if (goog.global.location) {
+ rv.push(this.trimPath_(goog.global.location.href));
+ }
rv.push(this.result_.getSummary());
if (opt_verbose) {
rv.push('.', this.result_.messages.join('\n'));
@@ -514,7 +551,11 @@ goog.testing.TestCase.prototype.getNumFilesLoaded = function() {
* by the test to indicate it has finished.
*/
goog.testing.TestCase.prototype.runTests = function() {
- this.setUpPage();
+ try {
+ this.setUpPage();
+ } catch (e) {
+ this.exceptionBeforeTest = e;
+ }
this.execute();
};
@@ -549,7 +590,7 @@ goog.testing.TestCase.prototype.orderTests_ = function(tests) {
});
break;
- // Do nothing for NATURAL.
+ // Do nothing for NATURAL.
}
};
@@ -666,8 +707,8 @@ goog.testing.TestCase.prototype.autoDiscoverTests = function() {
try {
var ref = testSource[name];
} catch (ex) {
- // NOTE(user): When running tests from a file:// URL on Firefox 3.5
- // for Windows, any reference to window.sessionStorage raises
+ // NOTE(brenneman): When running tests from a file:// URL on Firefox 3.5
+ // for Windows, any reference to goog.global.sessionStorage raises
// an "Operation is not supported" exception. Ignore any exceptions raised
// by simply accessing global properties.
}
@@ -707,12 +748,33 @@ goog.testing.TestCase.prototype.autoDiscoverTests = function() {
/**
+ * Checks to see if the test should be marked as failed before it is run.
+ *
+ * If there was an error in setUpPage, we treat that as a failure for all tests
+ * and mark them all as having failed.
+ *
+ * @param {goog.testing.TestCase.Test} testCase The current test case.
+ * @return {boolean} Whether the test was marked as failed.
+ * @protected
+ */
+goog.testing.TestCase.prototype.maybeFailTestEarly = function(testCase) {
+ if (this.exceptionBeforeTest) {
+ // We just use the first error to report an error on a failed test.
+ testCase.name = 'setUpPage for ' + testCase.name;
+ this.doError(testCase, this.exceptionBeforeTest);
+ return true;
+ }
+ return false;
+};
+
+
+/**
* Cycles through the tests, breaking out using a setTimeout if the execution
* time has execeeded {@link #MAX_RUN_TIME}.
*/
goog.testing.TestCase.prototype.cycleTests = function() {
this.saveMessage('Start');
- this.batchTime_ = this.now_();
+ this.batchTime_ = this.now();
var nextTest;
while ((nextTest = this.next()) && this.running) {
this.result_.runCount++;
@@ -723,15 +785,19 @@ goog.testing.TestCase.prototype.cycleTests = function() {
try {
this.log('Running test: ' + nextTest.name);
- goog.testing.TestCase.currentTestName = nextTest.name;
- this.setUp();
- nextTest.execute();
- this.tearDown();
- goog.testing.TestCase.currentTestName = null;
+ if (this.maybeFailTestEarly(nextTest)) {
+ cleanedUp = true;
+ } else {
+ goog.testing.TestCase.currentTestName = nextTest.name;
+ this.setUp();
+ nextTest.execute();
+ this.tearDown();
+ goog.testing.TestCase.currentTestName = null;
- cleanedUp = true;
+ cleanedUp = true;
- this.doSuccess(nextTest);
+ this.doSuccess(nextTest);
+ }
} catch (e) {
this.doError(nextTest, e);
@@ -745,7 +811,7 @@ goog.testing.TestCase.prototype.cycleTests = function() {
// If the max run time is exceeded call this function again async so as not
// to block the browser.
if (this.currentTestPointer_ < this.tests_.length &&
- this.now_() - this.batchTime_ > goog.testing.TestCase.MAX_RUN_TIME) {
+ this.now() - this.batchTime_ > goog.testing.TestCase.MAX_RUN_TIME) {
this.saveMessage('Breaking async');
this.timeout(goog.bind(this.cycleTests, this), 100);
return;
@@ -782,17 +848,32 @@ goog.testing.TestCase.prototype.countNumFilesLoaded_ = function() {
* @protected
*/
goog.testing.TestCase.prototype.timeout = function(fn, time) {
- var protectedTimeout = goog.testing.TestCase.protectedTimeout_;
- return protectedTimeout(fn, time);
+ // NOTE: invoking protectedSetTimeout_ as a member of goog.testing.TestCase
+ // would result in an Illegal Invocation error. The method must be executed
+ // with the global context.
+ var protectedSetTimeout = goog.testing.TestCase.protectedSetTimeout_;
+ return protectedSetTimeout(fn, time);
+};
+
+
+/**
+ * Clears a timeout created by {@code this.timeout()}.
+ * @param {number} id A timeout id.
+ * @protected
+ */
+goog.testing.TestCase.prototype.clearTimeout = function(id) {
+ // NOTE: see execution note for protectedSetTimeout above.
+ var protectedClearTimeout = goog.testing.TestCase.protectedClearTimeout_;
+ protectedClearTimeout(id);
};
/**
* @return {number} The current time in milliseconds, don't use goog.now as some
* tests override it.
- * @private
+ * @protected
*/
-goog.testing.TestCase.prototype.now_ = function() {
+goog.testing.TestCase.prototype.now = function() {
return new Date().getTime();
};
@@ -1032,8 +1113,17 @@ goog.testing.TestCase.Result.prototype.getSummary = function() {
'Call G_testRunner.setStrict(false) if this is expected behavior. ';
}
} else {
+ var failures = this.totalCount - this.successCount;
+ var suppressionMessage = '';
+
+ var countOfRunTests = this.testCase_.getActuallyRunCount();
+ if (countOfRunTests) {
+ failures = countOfRunTests - this.successCount;
+ suppressionMessage = ', ' +
+ (this.totalCount - countOfRunTests) + ' suppressed by querystring';
+ }
summary += this.successCount + ' passed, ' +
- (this.totalCount - this.successCount) + ' failed.\n' +
+ failures + ' failed' + suppressionMessage + '.\n' +
Math.round(this.runTime / this.runCount) + ' ms/test. ' +
this.numFilesLoaded + ' files loaded.';
}
@@ -1099,6 +1189,7 @@ goog.testing.TestCase.Error = function(source, message, opt_stack) {
/**
* Returns a string representing the error object.
* @return {string} A string representation of the error.
+ * @override
*/
goog.testing.TestCase.Error.prototype.toString = function() {
return 'ERROR in ' + this.source + '\n' +
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/testrunner.js b/contexts/data/lib/closure-library/closure/goog/testing/testrunner.js
index a80743a..8d1b282 100644
--- a/contexts/data/lib/closure-library/closure/goog/testing/testrunner.js
+++ b/contexts/data/lib/closure-library/closure/goog/testing/testrunner.js
@@ -97,15 +97,6 @@ goog.testing.TestRunner.prototype.strict_ = true;
* @param {goog.testing.TestCase} testCase The test case to initialize with.
*/
goog.testing.TestRunner.prototype.initialize = function(testCase) {
- if (!this.logEl_) {
- var el = document.getElementById('closureTestRunnerLog');
- if (el == null) {
- el = document.createElement('div');
- document.body.appendChild(el);
- }
- this.logEl_ = el;
- }
-
if (this.testCase && this.testCase.running) {
throw Error('The test runner is already waiting for a test to complete');
}
@@ -277,12 +268,22 @@ goog.testing.TestRunner.prototype.onComplete_ = function() {
log += '\n' + this.errors.join('\n');
}
+ if (!this.logEl_) {
+ var el = document.getElementById('closureTestRunnerLog');
+ if (el == null) {
+ el = document.createElement('div');
+ document.body.appendChild(el);
+ }
+ this.logEl_ = el;
+ }
+
// Remove all children from the log element.
var logEl = this.logEl_;
while (logEl.firstChild) {
logEl.removeChild(logEl.firstChild);
}
+ // Highlight the page to indicate the overall outcome.
this.writeLog(log);
var runAgainLink = document.createElement('a');
@@ -363,11 +364,23 @@ goog.testing.TestRunner.prototype.writeLog = function(log) {
div.style.color = color;
div.style.font = 'normal 100% monospace';
+ if (i == 0) {
+ // Highlight the first line as a header that indicates the test outcome.
+ div.style.padding = '20px';
+ div.style.marginBottom = '10px';
+ if (isFailOrError) {
+ div.style.border = '5px solid ' + color;
+ div.style.backgroundColor = '#ffeeee';
+ } else {
+ div.style.border = '1px solid black';
+ div.style.backgroundColor = '#eeffee';
+ }
+ }
try {
div.style.whiteSpace = 'pre-wrap';
} catch (e) {
- // NOTE(user): IE raises an exception when assigning to pre-wrap.
+ // NOTE(brenneman): IE raises an exception when assigning to pre-wrap.
// Thankfully, it doesn't collapse whitespace when using monospace fonts,
// so it will display correctly if we ignore the exception.
}
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/ui/.svn/all-wcprops b/contexts/data/lib/closure-library/closure/goog/testing/ui/.svn/all-wcprops
deleted file mode 100644
index d1d34f7..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/ui/.svn/all-wcprops
+++ /dev/null
@@ -1,41 +0,0 @@
-K 25
-svn:wc:ra_dav:version-url
-V 48
-/svn/!svn/ver/1293/trunk/closure/goog/testing/ui
-END
-style_reference.html
-K 25
-svn:wc:ra_dav:version-url
-V 68
-/svn/!svn/ver/850/trunk/closure/goog/testing/ui/style_reference.html
-END
-style_test.html
-K 25
-svn:wc:ra_dav:version-url
-V 63
-/svn/!svn/ver/850/trunk/closure/goog/testing/ui/style_test.html
-END
-rendererharness.js
-K 25
-svn:wc:ra_dav:version-url
-V 67
-/svn/!svn/ver/1024/trunk/closure/goog/testing/ui/rendererharness.js
-END
-rendererasserts.js
-K 25
-svn:wc:ra_dav:version-url
-V 67
-/svn/!svn/ver/1293/trunk/closure/goog/testing/ui/rendererasserts.js
-END
-style.js
-K 25
-svn:wc:ra_dav:version-url
-V 56
-/svn/!svn/ver/850/trunk/closure/goog/testing/ui/style.js
-END
-rendererasserts_test.html
-K 25
-svn:wc:ra_dav:version-url
-V 74
-/svn/!svn/ver/1293/trunk/closure/goog/testing/ui/rendererasserts_test.html
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/ui/.svn/entries b/contexts/data/lib/closure-library/closure/goog/testing/ui/.svn/entries
deleted file mode 100644
index e4d5996..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/ui/.svn/entries
+++ /dev/null
@@ -1,232 +0,0 @@
-10
-
-dir
-1494
-http://closure-library.googlecode.com/svn/trunk/closure/goog/testing/ui
-http://closure-library.googlecode.com/svn
-
-
-
-2011-09-22T21:01:37.000000Z
-1293
-nicksantos@google.com
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-0b95b8e8-c90f-11de-9d4f-f947ee5921c8
-
-style_reference.html
-file
-
-
-
-
-2011-12-23T22:42:27.285315Z
-8761f4580aec66c5c6215645781765c7
-2011-04-12T20:35:47.000000Z
-850
-diegosalas@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-560
-
-style_test.html
-file
-
-
-
-
-2011-12-23T22:42:27.286315Z
-5f6d2abbc2f0bc637e3933d5d0883db3
-2011-04-12T20:35:47.000000Z
-850
-diegosalas@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-3754
-
-rendererharness.js
-file
-
-
-
-
-2011-12-23T22:42:27.286315Z
-b81b82e5210eff653a307c126ed71369
-2011-06-10T12:08:17.000000Z
-1024
-pallosp@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-4777
-
-rendererasserts.js
-file
-
-
-
-
-2011-12-23T22:42:27.287315Z
-0f3f9c6a8c37cc3e873655e5c1a2fc0b
-2011-09-22T21:01:37.000000Z
-1293
-nicksantos@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-1780
-
-style.js
-file
-
-
-
-
-2011-12-23T22:42:27.287315Z
-de519257849a4600b992b4dcc9f7e35a
-2011-04-12T20:35:47.000000Z
-850
-diegosalas@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-5233
-
-rendererasserts_test.html
-file
-
-
-
-
-2011-12-23T22:42:27.287315Z
-c4347cff9328fb07cb152da340ea3595
-2011-09-22T21:01:37.000000Z
-1293
-nicksantos@google.com
-has-props
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-1519
-
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/ui/.svn/prop-base/rendererasserts.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/ui/.svn/prop-base/rendererasserts.js.svn-base
deleted file mode 100644
index 530636b..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/ui/.svn/prop-base/rendererasserts.js.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 15
-text/javascript
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/ui/.svn/prop-base/rendererasserts_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/ui/.svn/prop-base/rendererasserts_test.html.svn-base
deleted file mode 100644
index d356868..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/ui/.svn/prop-base/rendererasserts_test.html.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 9
-text/html
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/ui/.svn/prop-base/rendererharness.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/ui/.svn/prop-base/rendererharness.js.svn-base
deleted file mode 100644
index 530636b..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/ui/.svn/prop-base/rendererharness.js.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 15
-text/javascript
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/ui/.svn/prop-base/style.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/ui/.svn/prop-base/style.js.svn-base
deleted file mode 100644
index 530636b..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/ui/.svn/prop-base/style.js.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 15
-text/javascript
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/ui/.svn/prop-base/style_reference.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/ui/.svn/prop-base/style_reference.html.svn-base
deleted file mode 100644
index d356868..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/ui/.svn/prop-base/style_reference.html.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 9
-text/html
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/ui/.svn/prop-base/style_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/ui/.svn/prop-base/style_test.html.svn-base
deleted file mode 100644
index d356868..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/ui/.svn/prop-base/style_test.html.svn-base
+++ /dev/null
@@ -1,5 +0,0 @@
-K 13
-svn:mime-type
-V 9
-text/html
-END
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/ui/.svn/text-base/rendererasserts.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/ui/.svn/text-base/rendererasserts.js.svn-base
deleted file mode 100644
index 7d17c76..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/ui/.svn/text-base/rendererasserts.js.svn-base
+++ /dev/null
@@ -1,55 +0,0 @@
-// Copyright 2009 The Closure Library Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS-IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/**
- * @fileoverview Additional asserts for testing ControlRenderers.
- *
- * @author mkretzschmar@google.com (Martin Kretzschmar)
- */
-
-goog.provide('goog.testing.ui.rendererasserts');
-
-goog.require('goog.testing.asserts');
-
-
-/**
- * Assert that a control renderer constructor doesn't call getCssClass.
- *
- * @param {?function(new:goog.ui.ControlRenderer)} rendererClassUnderTest The
- * renderer constructor to test.
- */
-goog.testing.ui.rendererasserts.assertNoGetCssClassCallsInConstructor =
- function(rendererClassUnderTest) {
- var getCssClassCalls = 0;
-
- /**
- * @constructor
- * @extends {goog.ui.ControlRenderer}
- */
- function TestControlRenderer() {
- rendererClassUnderTest.call(this);
- }
- goog.inherits(TestControlRenderer, rendererClassUnderTest);
-
- TestControlRenderer.prototype.getCssClass = function() {
- getCssClassCalls++;
- return TestControlRenderer.superClass_.getCssClass.call(this);
- };
-
- var testControlRenderer = new TestControlRenderer();
-
- assertEquals('Constructors should not call getCssClass, ' +
- 'getCustomRenderer must be able to override it post construction.',
- 0, getCssClassCalls);
-};
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/ui/.svn/text-base/rendererasserts_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/ui/.svn/text-base/rendererasserts_test.html.svn-base
deleted file mode 100644
index 01da171..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/ui/.svn/text-base/rendererasserts_test.html.svn-base
+++ /dev/null
@@ -1,52 +0,0 @@
-<!DOCTYPE html>
-<html>
-<!--
-Copyright 2009 The Closure Library Authors. All Rights Reserved.
-
-Use of this source code is governed by the Apache License, Version 2.0.
-See the COPYING file for details.
--->
-<!--
-Author: mkretzschmar@google.com (Martin Kretzschmar)
--->
-
-<head>
-<meta http-equiv="X-UA-Compatible" content="IE=edge">
- <title>Closure Unit Tests - goog.testing.ui.rendererasserts</title>
- <script src="../../base.js"></script>
- <script>
- goog.require('goog.ui.ControlRenderer');
- goog.require('goog.testing.ui.rendererasserts');
- goog.require('goog.testing.asserts');
- goog.require('goog.testing.jsunit');
- </script>
-</head>
-<body>
- <script>
- function testSuccess() {
- function GoodRenderer() {}
-
- goog.testing.ui.rendererasserts.
- assertNoGetCssClassCallsInConstructor(GoodRenderer);
- }
-
- function testFailure() {
- function BadRenderer() {
- goog.ui.ControlRenderer.call(this);
- this.myClass = this.getCssClass();
- }
- goog.inherits(BadRenderer, goog.ui.ControlRenderer);
-
- var ex = assertThrows(
- 'Expected assertNoGetCssClassCallsInConstructor to fail.',
- function() {
- goog.testing.ui.rendererasserts.
- assertNoGetCssClassCallsInConstructor(BadRenderer);
- });
- assertTrue('Expected assertNoGetCssClassCallsInConstructor to throw a' +
- ' jsunit exception', ex.isJsUnitException);
- assertContains('getCssClass', ex.message);
- }
- </script>
-</body>
-</html>
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/ui/.svn/text-base/rendererharness.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/ui/.svn/text-base/rendererharness.js.svn-base
deleted file mode 100644
index edd3405..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/ui/.svn/text-base/rendererharness.js.svn-base
+++ /dev/null
@@ -1,176 +0,0 @@
-// Copyright 2009 The Closure Library Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS-IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-// All Rights Reserved
-
-/**
- * @fileoverview A driver for testing renderers.
- *
- * @author nicksantos@google.com (Nick Santos)
- */
-
-goog.provide('goog.testing.ui.RendererHarness');
-
-goog.require('goog.Disposable');
-goog.require('goog.dom.NodeType');
-goog.require('goog.testing.asserts');
-
-
-
-/**
- * A driver for testing renderers.
- *
- * @param {goog.ui.ControlRenderer} renderer A renderer to test.
- * @param {Element} renderParent The parent of the element where controls will
- * be rendered.
- * @param {Element} decorateParent The parent of the element where controls will
- * be decorated.
- * @constructor
- * @extends {goog.Disposable}
- */
-goog.testing.ui.RendererHarness = function(renderer, renderParent,
- decorateParent) {
- goog.Disposable.call(this);
-
- /**
- * The renderer under test.
- * @type {goog.ui.ControlRenderer}
- * @private
- */
- this.renderer_ = renderer;
-
- /**
- * The parent of the element where controls will be rendered.
- * @type {Element}
- * @private
- */
- this.renderParent_ = renderParent;
-
- /**
- * The original HTML of the render element.
- * @type {string}
- * @private
- */
- this.renderHtml_ = renderParent.innerHTML;
-
- /**
- * Teh parent of the element where controls will be decorated.
- * @type {Element}
- * @private
- */
- this.decorateParent_ = decorateParent;
-
- /**
- * The original HTML of the decorated element.
- * @type {string}
- * @private
- */
- this.decorateHtml_ = decorateParent.innerHTML;
-};
-goog.inherits(goog.testing.ui.RendererHarness, goog.Disposable);
-
-
-/**
- * A control to create by decoration.
- * @type {goog.ui.Control}
- * @private
- */
-goog.testing.ui.RendererHarness.prototype.decorateControl_;
-
-
-/**
- * A control to create by rendering.
- * @type {goog.ui.Control}
- * @private
- */
-goog.testing.ui.RendererHarness.prototype.renderControl_;
-
-
-/**
- * Whether all the necessary assert methods have been called.
- * @type {boolean}
- * @private
- */
-goog.testing.ui.RendererHarness.prototype.verified_ = false;
-
-
-/**
- * Attach a control and render its DOM.
- * @param {goog.ui.Control} control A control.
- * @return {Element} The element created.
- */
-goog.testing.ui.RendererHarness.prototype.attachControlAndRender =
- function(control) {
- this.renderControl_ = control;
-
- control.setRenderer(this.renderer_);
- control.render(this.renderParent_);
- return control.getElement();
-};
-
-
-/**
- * Attach a control and decorate the element given in the constructor.
- * @param {goog.ui.Control} control A control.
- * @return {Element} The element created.
- */
-goog.testing.ui.RendererHarness.prototype.attachControlAndDecorate =
- function(control) {
- this.decorateControl_ = control;
-
- control.setRenderer(this.renderer_);
-
- var child = this.decorateParent_.firstChild;
- assertEquals('The decorated node must be an element',
- goog.dom.NodeType.ELEMENT, child.nodeType);
- control.decorate(/** @type {Element} */ (child));
- return control.getElement();
-};
-
-
-/**
- * Assert that the rendered element and the decorated element match.
- */
-goog.testing.ui.RendererHarness.prototype.assertDomMatches = function() {
- assert('Both elements were not generated',
- !!(this.renderControl_ && this.decorateControl_));
- assertHTMLEquals(
- 'Rendered control and decorated control produced different HTML',
- this.renderControl_.getElement().innerHTML,
- this.decorateControl_.getElement().innerHTML);
- this.verified_ = true;
-};
-
-
-/**
- * Destroy the harness, verifying that all assertions had been checked.
- * @override
- * @protected
- */
-goog.testing.ui.RendererHarness.prototype.disposeInternal = function() {
- // If the harness was not verified appropriately, throw an exception.
- assert('Expected assertDomMatches to be called',
- this.verified_ || !this.renderControl_ || !this.decorateControl_);
-
- if (this.decorateControl_) {
- this.decorateControl_.dispose();
- }
- if (this.renderControl_) {
- this.renderControl_.dispose();
- }
-
- this.renderParent_.innerHTML = this.renderHtml_;
- this.decorateParent_.innerHTML = this.decorateHtml_;
-
- goog.testing.ui.RendererHarness.superClass_.disposeInternal.call(this);
-};
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/ui/.svn/text-base/style.js.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/ui/.svn/text-base/style.js.svn-base
deleted file mode 100644
index 64e935c..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/ui/.svn/text-base/style.js.svn-base
+++ /dev/null
@@ -1,137 +0,0 @@
-// Copyright 2008 The Closure Library Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS-IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-/**
- * @fileoverview Tools for testing Closure renderers against static markup
- * spec pages.
- *
- */
-
-goog.provide('goog.testing.ui.style');
-
-goog.require('goog.array');
-goog.require('goog.dom');
-goog.require('goog.dom.classes');
-goog.require('goog.testing.asserts');
-
-
-/**
- * Uses document.write to add an iFrame to the page with the reference path in
- * the src attribute. Used for loading an html file containing reference
- * structures to test against into the page. Should be called within the body of
- * the jsunit test page.
- * @param {string} referencePath A path to a reference HTML file.
- */
-goog.testing.ui.style.writeReferenceFrame = function(referencePath) {
- document.write('<iframe id="reference" name="reference" ' +
- 'src="' + referencePath + '"></iframe>');
-};
-
-
-/**
- * Returns a reference to the first element child of a node with the given id
- * from the page loaded into the reference iFrame. Used to retrieve a particular
- * reference DOM structure to test against.
- * @param {string} referenceId The id of a container element for a reference
- * structure in the reference page.
- * @return {Node} The root element of the reference structure.
- */
-goog.testing.ui.style.getReferenceNode = function(referenceId) {
- return goog.dom.getFirstElementChild(
- window.frames['reference'].document.getElementById(referenceId));
-};
-
-
-/**
- * Returns an array of all element children of a given node.
- * @param {Node} element The node to get element children of.
- * @return {Array.<Node>} An array of all the element children.
- */
-goog.testing.ui.style.getElementChildren = function(element) {
- var first = goog.dom.getFirstElementChild(element);
- if (!first) {
- return [];
- }
- var children = [first], next;
- while (next = goog.dom.getNextElementSibling(children[children.length - 1])) {
- children.push(next);
- }
- return children;
-};
-
-
-/**
- * Tests whether a given node is a "content" node of a reference structure,
- * which means it is allowed to have arbitrary children.
- * @param {Node} element The node to test.
- * @return {boolean} Whether the given node is a content node or not.
- */
-goog.testing.ui.style.isContentNode = function(element) {
- return element.className.indexOf('content') != -1;
-};
-
-
-/**
- * Tests that the structure, node names, and classes of the given element are
- * the same as the reference structure with the given id. Throws an error if the
- * element doesn't have the same nodes at each level of the DOM with the same
- * classes on each. The test ignores all DOM structure within content nodes.
- * @param {Node} element The root node of the DOM structure to test.
- * @param {string} referenceId The id of the container for the reference
- * structure to test against.
- */
-goog.testing.ui.style.assertStructureMatchesReference = function(element,
- referenceId) {
- goog.testing.ui.style.assertStructureMatchesReferenceInner_(element,
- goog.testing.ui.style.getReferenceNode(referenceId));
-};
-
-
-/**
- * A recursive function for comparing structure, node names, and classes between
- * a test and reference DOM structure. Throws an error if one of these things
- * doesn't match. Used internally by
- * {@link goog.testing.ui.style.assertStructureMatchesReference}.
- * @param {Node} element DOM element to test.
- * @param {Node} reference DOM element to use as a reference (test against).
- * @private
- */
-goog.testing.ui.style.assertStructureMatchesReferenceInner_ = function(element,
- reference) {
- if (!element && !reference) {
- return;
- }
- assertTrue('Expected two elements.', !!element && !!reference);
- assertEquals('Expected nodes to have the same nodeName.',
- element.nodeName, reference.nodeName);
- var elementClasses = goog.dom.classes.get(element);
- goog.array.forEach(goog.dom.classes.get(reference), function(referenceClass) {
- assertContains('Expected test node to have all reference classes.',
- referenceClass, elementClasses);
- });
- // Call assertStructureMatchesReferenceInner_ on all element children
- // unless this is a content node
- var elChildren = goog.testing.ui.style.getElementChildren(element),
- refChildren = goog.testing.ui.style.getElementChildren(reference);
- if (!goog.testing.ui.style.isContentNode(reference)) {
- if (elChildren.length != refChildren.length) {
- assertEquals('Expected same number of children for a non-content node.',
- elChildren.length, refChildren.length);
- }
- for (var i = 0; i < elChildren.length; i++) {
- goog.testing.ui.style.assertStructureMatchesReferenceInner_(elChildren[i],
- refChildren[i]);
- }
- }
-};
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/ui/.svn/text-base/style_reference.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/ui/.svn/text-base/style_reference.html.svn-base
deleted file mode 100644
index c60a51f..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/ui/.svn/text-base/style_reference.html.svn-base
+++ /dev/null
@@ -1,27 +0,0 @@
-<!DOCTYPE html>
-<html>
-<!--
-Copyright 2008 The Closure Library Authors. All Rights Reserved.
-
-Use of this source code is governed by the Apache License, Version 2.0.
-See the COPYING file for details.
--->
-<!--
--->
-<head>
-<meta http-equiv="X-UA-Compatible" content="IE=edge">
- <title>Closure Unit Tests - goog.testing.ui.style Reference HTML</title>
-</head>
-<body>
-
- <div id="reference">
- <div class="one two three">
- <div class="four five"></div>
- <div class="six seven content">
- Content
- </div>
- </div>
- </div>
-
-</body>
-</html>
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/ui/.svn/text-base/style_test.html.svn-base b/contexts/data/lib/closure-library/closure/goog/testing/ui/.svn/text-base/style_test.html.svn-base
deleted file mode 100644
index 0d0b186..0000000
--- a/contexts/data/lib/closure-library/closure/goog/testing/ui/.svn/text-base/style_test.html.svn-base
+++ /dev/null
@@ -1,130 +0,0 @@
-<!DOCTYPE html>
-<html>
-<!--
-Copyright 2008 The Closure Library Authors. All Rights Reserved.
-
-Use of this source code is governed by the Apache License, Version 2.0.
-See the COPYING file for details.
--->
-<!--
--->
-<head>
-<meta http-equiv="X-UA-Compatible" content="IE=edge">
- <title>Closure Unit Tests - goog.testing.ui.style</title>
- <script src="../../base.js"></script>
- <script>
- goog.require('goog.dom');
- goog.require('goog.testing.jsunit');
- goog.require('goog.testing.ui.style');
- </script>
-</head>
-<body>
- <script>
- // Write iFrame tag to load reference FastUI markup. Then, our tests will
- // compare the generated markup to the reference markup.
- var refPath = 'style_reference.html';
- goog.testing.ui.style.writeReferenceFrame(refPath);
-
- // assertStructureMatchesReference should succeed if the structure, node
- // names, and classes match.
- function testCorrect() {
- var el = goog.dom.getFirstElementChild(goog.dom.getElement('correct'));
- goog.testing.ui.style.assertStructureMatchesReference(el, 'reference');
- }
-
- // assertStructureMatchesReference should fail if one of the nodes is
- // missing a class.
- function testMissingClass() {
- var el = goog.dom.getFirstElementChild(
- goog.dom.getElement('missing-class'));
- var e = assertThrows(function() {
- goog.testing.ui.style.assertStructureMatchesReference(el, 'reference');
- });
- assertContains('all reference classes', e.message);
- }
-
- // assertStructureMatchesReference should NOT fail if one of the nodes has
- // an additional class.
- function testExtraClass() {
- var el = goog.dom.getFirstElementChild(
- goog.dom.getElement('extra-class'));
- goog.testing.ui.style.assertStructureMatchesReference(el, 'reference');
- }
-
- // assertStructureMatchesReference should fail if there is a missing child
- // node somewhere in the DOM structure.
- function testMissingChild() {
- var el = goog.dom.getFirstElementChild(
- goog.dom.getElement('missing-child'));
- var e = assertThrows(function() {
- goog.testing.ui.style.assertStructureMatchesReference(el, 'reference');
- });
- assertContains('same number of children', e.message);
- }
-
- // assertStructureMatchesReference should fail if there is an extra child
- // node somewhere in the DOM structure.
- function testExtraChild() {
- var el = goog.dom.getFirstElementChild(
- goog.dom.getElement('extra-child'));
- var e = assertThrows(function() {
- goog.testing.ui.style.assertStructureMatchesReference(el, 'reference');
- });
- assertContains('same number of children', e.message);
- }
-
- </script>
-
- <div id="correct">
- <div class="one two three">
- <div class="four five"></div>
- <div class="six seven content">
- <div></div>
- Blah
- </div>
- </div>
- </div>
-
- <div id="missing-class">
- <div class="one two three">
- <div class="five"></div>
- <div class="six seven content">
- <div></div>
- Blah
- </div>
- </div>
- </div>
-
- <div id="extra-class">
- <div class="one two three">
- <div class="four five five-point-five"></div>
- <div class="six seven content">
- <div></div>
- Blah
- </div>
- </div>
- </div>
-
- <div id="missing-child">
- <div class="one two three">
- <div class="six seven content">
- <div></div>
- Blah
- </div>
- </div>
- </div>
-
- <div id="extra-child">
- <div class="one two three">
- <div class="four five">
- <div class="five-point-five"></div>
- </div>
- <div class="six seven content">
- <div></div>
- Blah
- </div>
- </div>
- </div>
-
-</body>
-</html>
diff --git a/contexts/data/lib/closure-library/closure/goog/testing/ui/rendererasserts.js b/contexts/data/lib/closure-library/closure/goog/testing/ui/rendererasserts.js
index 7d17c76..ebe5d26 100644
--- a/contexts/data/lib/closure-library/closure/goog/testing/ui/rendererasserts.js
+++ b/contexts/data/lib/closure-library/closure/goog/testing/ui/rendererasserts.js
@@ -42,6 +42,7 @@ goog.testing.ui.rendererasserts.assertNoGetCssClassCallsInConstructor =
}
goog.inherits(TestControlRenderer, rendererClassUnderTest);
+ /** @override */
TestControlRenderer.prototype.getCssClass = function() {
getCssClassCalls++;
return TestControlRenderer.superClass_.getCssClass.call(this);