Re-land "[shill] Add hardware address to Device objects."
Forgot some headers...
BUG=chromium-os:17744
TEST=unit
This reverts commit 0fda552b0fec3498403336acb9e89dd7799cac74.
Change-Id: I1cd05e47d29bc7ea2a065cabf1d81dd37f74c0f8
Reviewed-on: http://gerrit.chromium.org/gerrit/6270
Reviewed-by: Chris Masone <cmasone@chromium.org>
Tested-by: Chris Masone <cmasone@chromium.org>
diff --git a/modem_unittest.cc b/modem_unittest.cc
index fb0b217..781c052 100644
--- a/modem_unittest.cc
+++ b/modem_unittest.cc
@@ -4,6 +4,7 @@
#include <vector>
+#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <mm/mm-modem.h>
#include <net/if.h>
@@ -12,8 +13,10 @@
#include "shill/cellular.h"
#include "shill/manager.h"
#include "shill/mock_control.h"
+#include "shill/mock_device_info.h"
#include "shill/mock_dbus_properties_proxy.h"
#include "shill/mock_glib.h"
+#include "shill/mock_manager.h"
#include "shill/mock_sockets.h"
#include "shill/modem.h"
#include "shill/proxy_factory.h"
@@ -25,6 +28,7 @@
using testing::_;
using testing::DoAll;
using testing::Return;
+using testing::SetArgumentPointee;
using testing::StrictMock;
using testing::Test;
@@ -79,7 +83,7 @@
MockGLib glib_;
MockControl control_interface_;
EventDispatcher dispatcher_;
- Manager manager_;
+ MockManager manager_;
scoped_ptr<MockDBusPropertiesProxy> proxy_;
TestProxyFactory proxy_factory_;
Modem modem_;
@@ -133,6 +137,7 @@
EXPECT_FALSE(modem_.device_.get());
static const char kLinkName[] = "usb0";
+ static const unsigned char kAddress[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05};
const int kTestSocket = 10;
props[Modem::kPropertyLinkName].writer().append_string(kLinkName);
EXPECT_CALL(sockets_, Socket(PF_INET, SOCK_DGRAM, 0))
@@ -142,6 +147,14 @@
.WillRepeatedly(DoAll(SetInterfaceIndex(), Return(0)));
EXPECT_CALL(sockets_, Close(kTestSocket))
.WillRepeatedly(Return(0));
+
+ ByteString expected_address(kAddress, arraysize(kAddress));
+ MockDeviceInfo info_(&control_interface_, &dispatcher_, &manager_);
+ EXPECT_CALL(info_, GetAddress(kTestInterfaceIndex, _))
+ .WillOnce(DoAll(SetArgumentPointee<1>(expected_address), Return(true)))
+ .WillOnce(DoAll(SetArgumentPointee<1>(expected_address), Return(true)));
+ EXPECT_CALL(manager_, device_info()).WillRepeatedly(Return(&info_));
+
modem_.CreateCellularDevice(props);
EXPECT_FALSE(modem_.device_.get());