blob: b7b6ed55cba5e3cf2b5858d8145d2013b693e23d [file] [log] [blame]
// Copyright 2021 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 "rmad/system/fake_shill_client.h"
#include "rmad/system/shill_client_impl.h"
#include <memory>
#include <dbus/shill/dbus-constants.h>
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <shill/dbus-proxy-mocks.h>
using testing::_;
using testing::Eq;
using testing::Return;
using testing::StrictMock;
namespace rmad {
// Tests for |ShillClientImpl|.
class ShillClientTest : public testing::Test {
public:
ShillClientTest() = default;
~ShillClientTest() override = default;
};
TEST_F(ShillClientTest, DisableCellular_Success) {
auto mock_flimflam_manager_proxy =
std::make_unique<StrictMock<org::chromium::flimflam::ManagerProxyMock>>();
EXPECT_CALL(*mock_flimflam_manager_proxy,
DisableTechnology(Eq(shill::kTypeCellular), _, _))
.WillOnce(Return(true));
auto shill_client =
std::make_unique<ShillClientImpl>(std::move(mock_flimflam_manager_proxy));
EXPECT_TRUE(shill_client->DisableCellular());
}
TEST_F(ShillClientTest, DisableCellular_NoResponse) {
auto mock_flimflam_manager_proxy =
std::make_unique<StrictMock<org::chromium::flimflam::ManagerProxyMock>>();
EXPECT_CALL(*mock_flimflam_manager_proxy,
DisableTechnology(Eq(shill::kTypeCellular), _, _))
.WillOnce(Return(false));
auto shill_client =
std::make_unique<ShillClientImpl>(std::move(mock_flimflam_manager_proxy));
EXPECT_FALSE(shill_client->DisableCellular());
}
namespace fake {
// Tests for |FakeShillClient|.
class FakeShillClientTest : public testing::Test {
public:
FakeShillClientTest() = default;
~FakeShillClientTest() override = default;
};
TEST_F(FakeShillClientTest, DisableCellular) {
auto fake_shill_client = std::make_unique<FakeShillClient>();
EXPECT_TRUE(fake_shill_client->DisableCellular());
}
} // namespace fake
} // namespace rmad