Hello andreip,
I'd like you to do a code review. Please execute
g4 diff -c 10126303
or point your web browser to
http://mondrian/10126303
(this changelist has been uploaded to Mondrian)
to review the following code:
Change 10126303 by stevebl...@steveblock-gearslinux1 on 2009/02/12 17:35:50
*pending*
Adds a HttpRequest test to check that onreadystatechange is called with
all states in sequence.
PRESUBMIT=passed
R=andreip
[email protected]
DELTA=48 (48 added, 0 deleted, 0 changed)
OCL=10126303
Affected files ...
...
//depot/googleclient/gears/opensource/gears/test/testcases/httprequest_tests.js#17
edit
48 delta lines: 48 added, 0 deleted, 0 changed
Also consider running:
g4 lint -c 10126303
which verifies that the changelist doesn't introduce new style violations.
If you can't do the review, please let me know as soon as possible. During
your review, please ensure that all new code has corresponding unit tests and
that existing unit tests are updated appropriately. Visit
http://www/eng/code_review.html for more information.
This is a semiautomated message from "g4 mail". Complaints or suggestions?
Mail [email protected].
Change 10126303 by stevebl...@steveblock-gearslinux1 on 2009/02/12 17:35:50
*pending*
Adds a HttpRequest test to check that onreadystatechange is called with
all states in sequence.
Affected files ...
...
//depot/googleclient/gears/opensource/gears/test/testcases/httprequest_tests.js#17
edit
====
//depot/googleclient/gears/opensource/gears/test/testcases/httprequest_tests.js#17
-
/home/steveblock/GearsLinux1/googleclient/gears/opensource/gears/test/testcases/httprequest_tests.js
====
# action=edit type=text
--- googleclient/gears/opensource/gears/test/testcases/httprequest_tests.js
2009-02-12 15:50:59.000000000 +0000
+++ googleclient/gears/opensource/gears/test/testcases/httprequest_tests.js
2009-02-12 17:33:38.000000000 +0000
@@ -510,3 +510,51 @@
request.upload.onprogress = handleProgress;
assertEqual(handleProgress, request.upload.onprogress);
}
+
+function testReadyStates() {
+ // Tests that a request goes through all ready states in order.
+ var UNSENT = 0;
+ var OPENED = 1;
+ var HEADERS_RECEIVED = 2;
+ var LOADING = 3;
+ var DONE = 4;
+
+ var urlbase = '/testcases/cgi/send_response_of_size.py?write_slowly=1&size=';
+ var request = google.gears.factory.create('beta.httprequest');
+ var previousReadyState = UNSENT;
+ var isSendNotCalled = true;
+ var isSendCalled = false;
+ request.onreadystatechange = function() {
+ switch (request.readyState) {
+ case 1:
+ assert(isSendNotCalled);
+ assertEqual(UNSENT, previousReadyState);
+ break;
+ case HEADERS_RECEIVED:
+ assert(isSendCalled);
+ assertEqual(OPENED, previousReadyState);
+ break;
+ case LOADING:
+ assert(isSendCalled);
+ assert(HEADERS_RECEIVED == previousReadyState ||
+ LOADING == previousReadyState);
+ break;
+ case DONE:
+ assert(isSendCalled);
+ assertEqual(LOADING, previousReadyState);
+ completeAsync();
+ break;
+ default:
+ assert(false, 'Unexpected readyState');
+ }
+ previousReadyState = request.readyState;
+ }
+
+ startAsync();
+ assertEqual(UNSENT, request.readyState);
+ request.open('GET', urlbase + 1000000, true);
+ assertEqual(OPENED, request.readyState);
+ isSendCalled = true;
+ request.send();
+ isSendNotCalled = false;
+}