| // 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/wifi.h" |
| |
| #include <map> |
| #include <string> |
| #include <vector> |
| |
| #include <dbus-c++/dbus.h> |
| #include <chromeos/dbus/service_constants.h> |
| #include <gtest/gtest.h> |
| #include <gmock/gmock.h> |
| |
| #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 WiFiTest : public PropertyStoreTest { |
| public: |
| WiFiTest() |
| : device_(new WiFi(&control_interface_, NULL, NULL, "wifi", 0)) { |
| } |
| virtual ~WiFiTest() {} |
| |
| protected: |
| DeviceRefPtr device_; |
| }; |
| |
| TEST_F(WiFiTest, Contains) { |
| EXPECT_TRUE(device_->store()->Contains(flimflam::kNameProperty)); |
| EXPECT_FALSE(device_->store()->Contains("")); |
| } |
| |
| TEST_F(WiFiTest, Dispatch) { |
| { |
| ::DBus::Error error; |
| EXPECT_TRUE(DBusAdaptor::DispatchOnType(device_->store(), |
| flimflam::kBgscanMethodProperty, |
| PropertyStoreTest::kStringV, |
| &error)); |
| } |
| { |
| ::DBus::Error error; |
| EXPECT_TRUE(DBusAdaptor::DispatchOnType( |
| device_->store(), |
| flimflam::kBgscanSignalThresholdProperty, |
| PropertyStoreTest::kInt32V, |
| &error)); |
| } |
| { |
| ::DBus::Error error; |
| EXPECT_TRUE(DBusAdaptor::DispatchOnType(device_->store(), |
| flimflam::kScanIntervalProperty, |
| PropertyStoreTest::kUint16V, |
| &error)); |
| } |
| // Ensure that an attempt to write a R/O property returns InvalidArgs error. |
| { |
| ::DBus::Error error; |
| EXPECT_FALSE(DBusAdaptor::DispatchOnType(device_->store(), |
| flimflam::kScanningProperty, |
| PropertyStoreTest::kBoolV, |
| &error)); |
| EXPECT_EQ(invalid_args_, error.name()); |
| } |
| } |
| |
| } // namespace shill |