Reimplement CrosSetOfflineMode without Libcros

BUG=chromium-os:16557
TEST=unit_tests --gtest_filter="CrosNetworkFunctions*"

Review URL: https://chromiumcodereview.appspot.com/10177001

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133909 0039d316-1c4b-4281-b951-d872f2087c98
parent ddf1a01a
...@@ -714,7 +714,14 @@ void CrosRequestCellularRegister(const std::string& device_path, ...@@ -714,7 +714,14 @@ void CrosRequestCellularRegister(const std::string& device_path,
} }
bool CrosSetOfflineMode(bool offline) { bool CrosSetOfflineMode(bool offline) {
return chromeos::SetOfflineMode(offline); if (g_libcros_network_functions_enabled) {
return chromeos::SetOfflineMode(offline);
} else {
base::FundamentalValue value(offline);
DBusThreadManager::Get()->GetFlimflamManagerClient()->SetProperty(
flimflam::kOfflineModeProperty, value, base::Bind(&DoNothing));
return true;
}
} }
IPConfigStatus* CrosListIPConfigs(const std::string& device_path) { IPConfigStatus* CrosListIPConfigs(const std::string& device_path) {
......
...@@ -686,6 +686,12 @@ TEST_F(CrosNetworkFunctionsLibcrosTest, CrosRequestCellularRegister) { ...@@ -686,6 +686,12 @@ TEST_F(CrosNetworkFunctionsLibcrosTest, CrosRequestCellularRegister) {
object); object);
} }
TEST_F(CrosNetworkFunctionsLibcrosTest, CrosSetOfflineMode) {
const bool kOffline = true;
EXPECT_CALL(*MockChromeOSNetwork::Get(), SetOfflineMode(kOffline)).Times(1);
CrosSetOfflineMode(kOffline);
}
TEST_F(CrosNetworkFunctionsLibcrosTest, CrosAddIPConfig) { TEST_F(CrosNetworkFunctionsLibcrosTest, CrosAddIPConfig) {
const std::string device_path = "/device/path"; const std::string device_path = "/device/path";
EXPECT_CALL(*MockChromeOSNetwork::Get(), EXPECT_CALL(*MockChromeOSNetwork::Get(),
...@@ -1316,6 +1322,14 @@ TEST_F(CrosNetworkFunctionsTest, CrosRequestCellularRegister) { ...@@ -1316,6 +1322,14 @@ TEST_F(CrosNetworkFunctionsTest, CrosRequestCellularRegister) {
callback.Run(); callback.Run();
} }
TEST_F(CrosNetworkFunctionsTest, CrosSetOfflineMode) {
const bool kOffline = true;
const base::FundamentalValue value(kOffline);
EXPECT_CALL(*mock_manager_client_, SetProperty(
flimflam::kOfflineModeProperty, IsEqualTo(&value), _)).Times(1);
CrosSetOfflineMode(kOffline);
}
TEST_F(CrosNetworkFunctionsTest, CrosAddIPConfig) { TEST_F(CrosNetworkFunctionsTest, CrosAddIPConfig) {
const std::string device_path = "/device/path"; const std::string device_path = "/device/path";
const dbus::ObjectPath result_path("/result/path"); const dbus::ObjectPath result_path("/result/path");
......
...@@ -259,6 +259,11 @@ void CallMockRequestCellularRegister(const char* device_path, ...@@ -259,6 +259,11 @@ void CallMockRequestCellularRegister(const char* device_path,
callback, object); callback, object);
} }
// Calls mock SetOfflineMode.
bool CallMockSetOfflineMode(bool offline) {
return g_mock_chromeos_network->SetOfflineMode(offline);
}
// Calls mock AddIPConfig. // Calls mock AddIPConfig.
bool CallMockAddIPConfig(const char* device_path, IPConfigType type) { bool CallMockAddIPConfig(const char* device_path, IPConfigType type) {
return g_mock_chromeos_network->AddIPConfig(device_path, type); return g_mock_chromeos_network->AddIPConfig(device_path, type);
...@@ -357,6 +362,7 @@ void MockChromeOSNetwork::Initialize() { ...@@ -357,6 +362,7 @@ void MockChromeOSNetwork::Initialize() {
chromeos::RequestChangePin = &CallMockRequestChangePin; chromeos::RequestChangePin = &CallMockRequestChangePin;
chromeos::ProposeScan = &CallMockProposeScan; chromeos::ProposeScan = &CallMockProposeScan;
chromeos::RequestCellularRegister = &CallMockRequestCellularRegister; chromeos::RequestCellularRegister = &CallMockRequestCellularRegister;
chromeos::SetOfflineMode = &CallMockSetOfflineMode;
chromeos::AddIPConfig = &CallMockAddIPConfig; chromeos::AddIPConfig = &CallMockAddIPConfig;
chromeos::RemoveIPConfig = &CallMockRemoveIPConfig; chromeos::RemoveIPConfig = &CallMockRemoveIPConfig;
chromeos::GetDeviceNetworkList = &CallMockGetDeviceNetworkList; chromeos::GetDeviceNetworkList = &CallMockGetDeviceNetworkList;
...@@ -403,6 +409,7 @@ void MockChromeOSNetwork::Shutdown() { ...@@ -403,6 +409,7 @@ void MockChromeOSNetwork::Shutdown() {
chromeos::RequestChangePin = NULL; chromeos::RequestChangePin = NULL;
chromeos::ProposeScan = NULL; chromeos::ProposeScan = NULL;
chromeos::RequestCellularRegister = NULL; chromeos::RequestCellularRegister = NULL;
chromeos::SetOfflineMode = NULL;
chromeos::AddIPConfig = NULL; chromeos::AddIPConfig = NULL;
chromeos::RemoveIPConfig = NULL; chromeos::RemoveIPConfig = NULL;
chromeos::GetDeviceNetworkList = NULL; chromeos::GetDeviceNetworkList = NULL;
......
...@@ -128,6 +128,7 @@ class MockChromeOSNetwork { ...@@ -128,6 +128,7 @@ class MockChromeOSNetwork {
const char* network_id, const char* network_id,
NetworkActionCallback callback, NetworkActionCallback callback,
void* object)); void* object));
MOCK_METHOD1(SetOfflineMode, bool(bool offline));
MOCK_METHOD2(AddIPConfig, bool(const char* device_path, IPConfigType type)); MOCK_METHOD2(AddIPConfig, bool(const char* device_path, IPConfigType type));
MOCK_METHOD1(RemoveIPConfig, bool(IPConfig* config)); MOCK_METHOD1(RemoveIPConfig, bool(IPConfig* config));
MOCK_METHOD0(GetDeviceNetworkList, DeviceNetworkList*()); MOCK_METHOD0(GetDeviceNetworkList, DeviceNetworkList*());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment