Skip to content

Commit

Permalink
dbus: Add FakeBus
Browse files Browse the repository at this point in the history
BUG=234078
TEST=trybots

Review URL: https://chromiumcodereview.appspot.com/14493004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@196352 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
haruki@chromium.org committed Apr 25, 2013
1 parent 30551e7 commit 9cf45f5
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 4 deletions.
1 change: 1 addition & 0 deletions chromeos/chromeos.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@
'type': 'static_library',
'dependencies': [
'../build/linux/system.gyp:dbus',
'../dbus/dbus.gyp:dbus_test_support',
'chromeos',
'power_manager_proto',
],
Expand Down
5 changes: 3 additions & 2 deletions chromeos/dbus/mock_dbus_thread_manager_without_gmock.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "chromeos/dbus/ibus/mock_ibus_engine_service.h"
#include "chromeos/dbus/ibus/mock_ibus_input_context_client.h"
#include "chromeos/dbus/ibus/mock_ibus_panel_service.h"
#include "dbus/fake_bus.h"

namespace chromeos {

Expand Down Expand Up @@ -53,8 +54,8 @@ void MockDBusThreadManagerWithoutGMock::RemoveObserver(
void MockDBusThreadManagerWithoutGMock::InitIBusBus(
const std::string& ibus_address,
const base::Closure& closure) {
// Non-null bus address is used to ensure the connection to ibus-daemon.
ibus_bus_ = reinterpret_cast<dbus::Bus*>(0xdeadbeef);
dbus::Bus::Options options;
ibus_bus_ = new dbus::FakeBus(options);
}

dbus::Bus* MockDBusThreadManagerWithoutGMock::GetSystemBus() {
Expand Down
6 changes: 4 additions & 2 deletions dbus/dbus.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@
'includes': [ '../build/protoc.gypi' ],
},
{
# This target contains mocks that can be used to write unit tests
# without issuing actual D-Bus calls.
# This target contains mocks and fakes that can be used to write unit
# tests without issuing actual D-Bus calls.
'target_name': 'dbus_test_support',
'type': 'static_library',
'dependencies': [
Expand All @@ -69,6 +69,8 @@
'dbus',
],
'sources': [
'fake_bus.cc',
'fake_bus.h',
'mock_bus.cc',
'mock_bus.h',
'mock_exported_object.cc',
Expand Down
17 changes: 17 additions & 0 deletions dbus/fake_bus.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "dbus/fake_bus.h"

#include "base/location.h"

namespace dbus {

FakeBus::FakeBus(const Bus::Options& options) : Bus(options) {
}

FakeBus::~FakeBus() {
}

} // namespace dbus
23 changes: 23 additions & 0 deletions dbus/fake_bus.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef DBUS_FAKE_BUS_H_
#define DBUS_FAKE_BUS_H_

#include "dbus/bus.h"

namespace dbus {

// A fake implementation of Bus, which does nothing.
class FakeBus : public Bus {
public:
FakeBus(const Bus::Options& options);

protected:
virtual ~FakeBus();
};

} // namespace dbus

#endif // DBUS_FAKE_BUS_H_

0 comments on commit 9cf45f5

Please sign in to comment.