chromeos-dbus-bindings: Added proxy mock generation

Now it is possible to generate Mocks for D-Bus proxy objects to
mock out the D-Bus interfaces in tests.

A new option --mock=<file> is added to the generator to specify
the output file for the mock objects. If used with --proxy,
the mock header file will include the proxy header file to share
the definition of the common interface proxy abstract interface.
Otherwise, the mock header file will provide its own definition
of that abstract interface.

As a result, the proxy generation has been changed to include
the base abstract interface for the D-Bus interface proxy class
which the proxy and/or mock objects derive from.

The code using the proxy objects can be updated to pass around
the abstract interface instead of concrete proxy classes which
will make it possible to substruture proxies with mocks and
facilitate testing of the code using D-Bus proxies.

GYP action now has another variable 'mock_output_file' which
can be used along with 'proxy_output_file' to control the
location of the generated mock header file:

'actions': [
  {
    'action_name': 'generate-buffet-proxies',
    'variables': {
      'dbus_service_config': 'dbus_bindings/dbus-service-config.json',
      'proxy_output_file': 'include/buffet/dbus-proxies.h'
      'mock_output_file': 'include/buffet/dbus-mocks.h'
    },
    'sources': [
      'dbus_bindings/org.chromium.Buffet.Command.xml',
      'dbus_bindings/org.chromium.Buffet.Manager.xml',
    ],
    'includes': ['../common-mk/generate-dbus-proxies.gypi'],
  },
],

BUG=chromium:449176
TEST=FEATURES=test emerge-link chromeos-dbus-bindings
     Manually tested the generated proxy and mock classes with
     buffet.

Change-Id: I1fb84cfbfd751793df72ad5b050ee1cf00a64d62
Reviewed-on: https://chromium-review.googlesource.com/242276
Reviewed-by: Alex Vakulenko <avakulenko@chromium.org>
Commit-Queue: Alex Vakulenko <avakulenko@chromium.org>
Tested-by: Alex Vakulenko <avakulenko@chromium.org>
6 files changed
tree: af8bfbd9719e268aa93afe24d5423cd23a562a85
  1. chromeos-dbus-bindings/