Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1720)

Issue 10702138: Instrument serial API code to make testing easier. (Closed)

Created:
8 years, 5 months ago by miket_OOO
Modified:
8 years, 5 months ago
CC:
chromium-reviews, Aaron Boodman, mihaip-chromium-reviews_chromium.org
Visibility:
Public.

Description

Instrument serial API code to make testing easier. After a good lunchtime discussion, I went off to implement some sort of overriding functionality in ExtensionFunctionDispatcher, so that I could tell it to instantiate Function' instead of Function when an extension/app asked for function. I then discovered ExtensionFunctionDispatcher::OverrideFunction(), which was pretty much exactly what I wanted. Using this facility, added a fake SerialOpenFunction that overrides a new CreateSerialConnection method to instantiate a FakeEchoSerialConnection. As its name implies, this class pretends to echo bytes over a serial port. The practical outcome of this CL is we test more of our code without having a physical serial device attached to the machine. BUG=135656 TEST=this lays the ground work for testing of crrev.com/10759004 Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=145988

Patch Set 1 #

Total comments: 1
Unified diffs Side-by-side diffs Delta from patch set Stats (+164 lines, -53 lines) Patch
M chrome/browser/extensions/api/serial/serial_api.h View 2 chunks +8 lines, -0 lines 1 comment Download
M chrome/browser/extensions/api/serial/serial_api.cc View 2 chunks +15 lines, -2 lines 0 comments Download
M chrome/browser/extensions/api/serial/serial_apitest.cc View 2 chunks +133 lines, -29 lines 0 comments Download
M chrome/browser/extensions/api/serial/serial_connection.h View 1 chunk +5 lines, -5 lines 0 comments Download
M chrome/test/data/extensions/api_test/serial/api/background.js View 2 chunks +3 lines, -17 lines 0 comments Download

Messages

Total messages: 6 (0 generated)
miket_OOO
8 years, 5 months ago (2012-07-10 21:30:11 UTC) #1
asargent_no_longer_on_chrome
Cool, LGTM.
8 years, 5 months ago (2012-07-10 23:30:49 UTC) #2
Mihai Parparita -not on Chrome
http://codereview.chromium.org/10702138/diff/1/chrome/browser/extensions/api/serial/serial_api.h File chrome/browser/extensions/api/serial/serial_api.h (right): http://codereview.chromium.org/10702138/diff/1/chrome/browser/extensions/api/serial/serial_api.h#newcode53 chrome/browser/extensions/api/serial/serial_api.h:53: // Overrideable for testing. FWIW, the delegate pattern that ...
8 years, 5 months ago (2012-07-11 00:45:45 UTC) #3
miket_OOO
> FWIW, the delegate pattern that Antony and I mentioned would be to move these ...
8 years, 5 months ago (2012-07-11 16:06:10 UTC) #4
Mihai Parparita -not on Chrome
On Wed, Jul 11, 2012 at 9:06 AM, <miket@chromium.org> wrote: > If you think the ...
8 years, 5 months ago (2012-07-11 16:12:42 UTC) #5
miket_OOO
8 years, 5 months ago (2012-07-11 16:25:02 UTC) #6
OK, thanks. So let's let this one lie as-is because it's so
test-centric, and to the extent this pattern gets followed in the
future, we'll make sure at review time that class documentation helps
group test-centric methods in order to address your concerns about
cohesion of functionality.

On Wed, Jul 11, 2012 at 9:12 AM, Mihai Parparita <mihaip@chromium.org> wrote:
> On Wed, Jul 11, 2012 at 9:06 AM, <miket@chromium.org> wrote:
>>
>> If you think the predominant approach in Chromium is the delegate class, I
>> can
>> easily refactor this code to conform. What do you think?
>
>
> Delegate classes are often used to reduce coupling between components (e.g.
> between content/ and chrome/), but I see them less often in tests. I think
> what you have is fine.
>
> Mihai



-- 
@sowbug

Powered by Google App Engine
This is Rietveld 408576698