shill: Refactor SIM lock status properties into the GSM delegate.
BUG=chromium-os:18735
TEST=unit tests (old and new)
Change-Id: I829eb6cee67cb1ab418cf16a32c2195e3446a22b
Reviewed-on: https://gerrit.chromium.org/gerrit/11765
Tested-by: Darin Petkov <petkov@chromium.org>
Reviewed-by: Jason Glasgow <jglasgow@chromium.org>
Commit-Ready: Darin Petkov <petkov@chromium.org>
diff --git a/modem_unittest.cc b/modem_unittest.cc
index 4f99d90..ed19523 100644
--- a/modem_unittest.cc
+++ b/modem_unittest.cc
@@ -11,6 +11,7 @@
#include <sys/ioctl.h>
#include "shill/cellular.h"
+#include "shill/cellular_capability_gsm.h"
#include "shill/event_dispatcher.h"
#include "shill/manager.h"
#include "shill/mock_control.h"
@@ -85,6 +86,11 @@
static const char kOwner[];
static const char kPath[];
+ CellularCapabilityGSM *GetCapabilityGSM() {
+ return dynamic_cast<CellularCapabilityGSM *>(
+ modem_.device_->capability_.get());
+ }
+
MockGLib glib_;
MockControl control_interface_;
EventDispatcher dispatcher_;
@@ -163,14 +169,22 @@
modem_.CreateCellularDevice(props);
EXPECT_FALSE(modem_.device_.get());
- props[Modem::kPropertyType].writer().append_uint32(MM_MODEM_TYPE_CDMA);
+ props[Modem::kPropertyType].writer().append_uint32(MM_MODEM_TYPE_GSM);
props[Modem::kPropertyState].writer().append_uint32(
Cellular::kModemStateDisabled);
+ static const char kLockType[] = "sim-pin";
+ const int kRetries = 2;
+ props[CellularCapabilityGSM::kPropertyUnlockRequired].writer().append_string(
+ kLockType);
+ props[CellularCapabilityGSM::kPropertyUnlockRetries].writer().append_uint32(
+ kRetries);
modem_.CreateCellularDevice(props);
ASSERT_TRUE(modem_.device_.get());
EXPECT_EQ(kLinkName, modem_.device_->link_name());
EXPECT_EQ(kTestInterfaceIndex, modem_.device_->interface_index());
EXPECT_EQ(Cellular::kModemStateDisabled, modem_.device_->modem_state());
+ EXPECT_EQ(kLockType, GetCapabilityGSM()->sim_lock_type());
+ EXPECT_EQ(kRetries, GetCapabilityGSM()->sim_lock_retries_left());
vector<DeviceRefPtr> devices;
manager_.FilterByTechnology(Technology::kCellular, &devices);