// Copyright (c) 2011 The Chromium OS 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 "shill/cellular.h" #include #include #include #include #include #include #include #include "shill/dbus_adaptor.h" #include "shill/manager.h" #include "shill/mock_control.h" #include "shill/mock_device.h" #include "shill/property_store_unittest.h" using std::map; using std::string; using std::vector; using ::testing::_; using ::testing::NiceMock; using ::testing::Return; using ::testing::Test; namespace shill { class CellularTest : public PropertyStoreTest { public: CellularTest() : device_(new Cellular(&control_interface_, NULL, &manager_, "3G", 0)) { } virtual ~CellularTest() {} protected: DeviceRefPtr device_; }; TEST_F(CellularTest, Contains) { EXPECT_TRUE(device_->store()->Contains(flimflam::kNameProperty)); EXPECT_FALSE(device_->store()->Contains("")); } TEST_F(CellularTest, Dispatch) { { ::DBus::Error error; EXPECT_TRUE(DBusAdaptor::DispatchOnType( device_->store(), flimflam::kCellularAllowRoamingProperty, PropertyStoreTest::kBoolV, &error)); } { ::DBus::Error error; EXPECT_TRUE(DBusAdaptor::DispatchOnType(device_->store(), flimflam::kScanIntervalProperty, PropertyStoreTest::kUint16V, &error)); } // Ensure that attempting to write a R/O property returns InvalidArgs error. { ::DBus::Error error; EXPECT_FALSE(DBusAdaptor::DispatchOnType(device_->store(), flimflam::kAddressProperty, PropertyStoreTest::kStringV, &error)); EXPECT_EQ(invalid_args_, error.name()); } { ::DBus::Error error; EXPECT_FALSE(DBusAdaptor::DispatchOnType(device_->store(), flimflam::kCarrierProperty, PropertyStoreTest::kStringV, &error)); EXPECT_EQ(invalid_args_, error.name()); } { ::DBus::Error error; EXPECT_FALSE(DBusAdaptor::DispatchOnType(device_->store(), flimflam::kPRLVersionProperty, PropertyStoreTest::kInt16V, &error)); EXPECT_EQ(invalid_args_, error.name()); } } } // namespace shill