[shill] Enable objects to query an opaque RPC-system ID from Adaptors
This is needed for some properties. For example Service has a property called Device, which is expected
to return a (in the current impl) a DBus path for the associated Device object.
BUG=chromium-os:16343
TEST=unit tests
Change-Id: I8bd32ab483331efabbfee05dbdeba045c7cb20da
Reviewed-on: http://gerrit.chromium.org/gerrit/3417
Reviewed-by: Chris Masone <cmasone@chromium.org>
Tested-by: Chris Masone <cmasone@chromium.org>
diff --git a/service_unittest.cc b/service_unittest.cc
index 5a8014c..1fdfbab 100644
--- a/service_unittest.cc
+++ b/service_unittest.cc
@@ -16,6 +16,7 @@
#include "shill/dbus_adaptor.h"
#include "shill/ethernet_service.h"
#include "shill/manager.h"
+#include "shill/mock_adaptors.h"
#include "shill/mock_control.h"
#include "shill/mock_service.h"
#include "shill/property_store_unittest.h"
@@ -34,19 +35,29 @@
class ServiceTest : public PropertyStoreTest {
public:
+ static const char kMockServiceName[];
+ static const char kMockDeviceRpcId[];
+
ServiceTest()
: service_(new MockService(&control_interface_,
&dispatcher_,
- "mock-service")) {
+ kMockServiceName)) {
}
virtual ~ServiceTest() {}
protected:
- ServiceRefPtr service_;
+ scoped_refptr<MockService> service_;
};
+const char ServiceTest::kMockServiceName[] = "mock-service";
+
+const char ServiceTest::kMockDeviceRpcId[] = "mock-device-rpc";
+
TEST_F(ServiceTest, GetProperties) {
+ EXPECT_CALL(*service_.get(), CalculateState()).WillRepeatedly(Return(""));
+ EXPECT_CALL(*service_.get(), GetDeviceRpcId())
+ .WillRepeatedly(Return(ServiceTest::kMockDeviceRpcId));
map<string, ::DBus::Variant> props;
Error error(Error::kInvalidProperty, "");
{
@@ -84,6 +95,13 @@
EXPECT_EQ(props[flimflam::kPriorityProperty].reader().get_int32(),
expected);
}
+ {
+ ::DBus::Error dbus_error;
+ DBusAdaptor::GetProperties(service_.get(), &props, &dbus_error);
+ ASSERT_FALSE(props.find(flimflam::kDeviceProperty) == props.end());
+ EXPECT_EQ(props[flimflam::kDeviceProperty].reader().get_string(),
+ string(ServiceTest::kMockDeviceRpcId));
+ }
}
TEST_F(ServiceTest, Dispatch) {