cloudtrends / chromiumembedded

Automatically exported from code.google.com/p/chromiumembedded
1 stars 1 forks source link

Add unit tests for custom scheme handlers #221

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Custom scheme handlers current have no unit tests. Tests need to be developed 
before additional scheme-related functionality can be added.

Original issue reported on code.google.com by magreenb...@gmail.com on 18 Apr 2011 at 2:49

GoogleCodeExporter commented 9 years ago

Original comment by magreenb...@gmail.com on 18 Apr 2011 at 2:49

GoogleCodeExporter commented 9 years ago

Original comment by magreenb...@gmail.com on 18 Apr 2011 at 2:50

GoogleCodeExporter commented 9 years ago
How complex do you want the unit tests to be? I assume create a 
schemehandler_unittext.cc add the custom scheme handler and make sure it's 
called similar to HandleBeforeResourceLoad? Also set the data size in 
ProcessRequest and make sure the same size is requested through the calls to 
ReadResponse?

I'm trying to see how I can catch the response specific data, but not seeing 
it.  Would love to get this wrapped up if you can point me in the general 
direction.

Original comment by crazy.fu...@gmail.com on 19 Apr 2011 at 8:20

GoogleCodeExporter commented 9 years ago
You have the right idea. The tests should verify that the expected method 
calls/arguments are received for each callback method. It should test both 
standard and non-standard schemes and verify that the host name filtering is 
working as expected. Existing unit tests like web_urlrequest_unittest.cc 
provide a good example on how to structure the code.

Original comment by magreenb...@gmail.com on 19 Apr 2011 at 8:32

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
> I'm trying to see how I can catch the response specific data, but not seeing 
it.

You can use CefWebURLRequest to capture the data returned by the ReadResponse 
method.

Original comment by magreenb...@gmail.com on 19 Apr 2011 at 8:37

GoogleCodeExporter commented 9 years ago
Okay, so here is a start to make sure I'm going in the right direction.

One odd thing. You'll notice all the 'unused' vars in TestResults.  If I don't 
have these, I get crashes running the test tool, tr is getting overwritten 
(line 150)

Original comment by crazy.fu...@gmail.com on 20 Apr 2011 at 12:08

Attachments:

GoogleCodeExporter commented 9 years ago
In your code the TestResults object is local to 
SchemeHandlerTest.RegisterScheme. It will not be valid when the other tests are 
executed. Also, there's no guarantee about the order in which the tests will be 
executed.

I've committed the corrected code with some additional tests as revision 222.

Original comment by magreenb...@gmail.com on 21 Apr 2011 at 4:48