blob: 55d61d9de75c829f5d60a236f751b22a4f03258f [file] [log] [blame]
// 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_service.h"
#include <chromeos/dbus/service_constants.h>
#include <gtest/gtest.h>
#include "shill/nice_mock_control.h"
#include "shill/mock_adaptors.h"
using testing::NiceMock;
namespace shill {
class CellularServiceTest : public testing::Test {
public:
CellularServiceTest()
: service_(new CellularService(&control_, NULL, NULL, NULL)),
adaptor_(NULL) {}
virtual ~CellularServiceTest() {
adaptor_ = NULL;
}
virtual void SetUp() {
adaptor_ =
dynamic_cast<NiceMock<ServiceMockAdaptor> *>(service_->adaptor());
}
protected:
NiceMockControl control_;
CellularServiceRefPtr service_;
NiceMock<ServiceMockAdaptor> *adaptor_; // Owned by |service_|.
};
TEST_F(CellularServiceTest, SetNetworkTechnology) {
EXPECT_CALL(*adaptor_, EmitStringChanged(flimflam::kNetworkTechnologyProperty,
flimflam::kNetworkTechnologyUmts));
EXPECT_TRUE(service_->network_technology().empty());
service_->SetNetworkTechnology(flimflam::kNetworkTechnologyUmts);
EXPECT_EQ(flimflam::kNetworkTechnologyUmts, service_->network_technology());
service_->SetNetworkTechnology(flimflam::kNetworkTechnologyUmts);
}
TEST_F(CellularServiceTest, SetRoamingState) {
EXPECT_CALL(*adaptor_, EmitStringChanged(flimflam::kRoamingStateProperty,
flimflam::kRoamingStateHome));
EXPECT_TRUE(service_->roaming_state().empty());
service_->SetRoamingState(flimflam::kRoamingStateHome);
EXPECT_EQ(flimflam::kRoamingStateHome, service_->roaming_state());
service_->SetRoamingState(flimflam::kRoamingStateHome);
}
} // namespace shill