Commit abb833ee authored by stevenjb@chromium.org's avatar stevenjb@chromium.org

Implement networkingPrivate.setWifiTDLSEnabledState

BUG=329738

Review URL: https://codereview.chromium.org/156353002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@251501 0039d316-1c4b-4281-b951-d872f2087c98
parent 1953e607
...@@ -335,4 +335,48 @@ class NetworkingPrivateVerifyAndEncryptDataFunction ...@@ -335,4 +335,48 @@ class NetworkingPrivateVerifyAndEncryptDataFunction
DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateVerifyAndEncryptDataFunction); DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateVerifyAndEncryptDataFunction);
}; };
// Implements the chrome.networkingPrivate.setWifiTDLSEnabledState method.
class NetworkingPrivateSetWifiTDLSEnabledStateFunction
: public ChromeAsyncExtensionFunction {
public:
NetworkingPrivateSetWifiTDLSEnabledStateFunction() {}
DECLARE_EXTENSION_FUNCTION("networkingPrivate.setWifiTDLSEnabledState",
NETWORKINGPRIVATE_SETWIFITDLSENABLEDSTATE);
protected:
virtual ~NetworkingPrivateSetWifiTDLSEnabledStateFunction();
// AsyncExtensionFunction overrides.
virtual bool RunImpl() OVERRIDE;
void Success(const std::string& result);
void Failure(const std::string& error_name,
scoped_ptr<base::DictionaryValue> error_data);
private:
DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateSetWifiTDLSEnabledStateFunction);
};
// Implements the chrome.networkingPrivate.getWifiTDLSStatus method.
class NetworkingPrivateGetWifiTDLSStatusFunction
: public ChromeAsyncExtensionFunction {
public:
NetworkingPrivateGetWifiTDLSStatusFunction() {}
DECLARE_EXTENSION_FUNCTION("networkingPrivate.getWifiTDLSStatus",
NETWORKINGPRIVATE_GETWIFITDLSSTATUS);
protected:
virtual ~NetworkingPrivateGetWifiTDLSStatusFunction();
// AsyncExtensionFunction overrides.
virtual bool RunImpl() OVERRIDE;
void Success(const std::string& result);
void Failure(const std::string& error_name,
scoped_ptr<base::DictionaryValue> error_data);
private:
DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateGetWifiTDLSStatusFunction);
};
#endif // CHROME_BROWSER_EXTENSIONS_API_NETWORKING_PRIVATE_NETWORKING_PRIVATE_API_H_ #endif // CHROME_BROWSER_EXTENSIONS_API_NETWORKING_PRIVATE_NETWORKING_PRIVATE_API_H_
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "chromeos/dbus/shill_manager_client.h" #include "chromeos/dbus/shill_manager_client.h"
#include "chromeos/network/managed_network_configuration_handler.h" #include "chromeos/network/managed_network_configuration_handler.h"
#include "chromeos/network/network_connection_handler.h" #include "chromeos/network/network_connection_handler.h"
#include "chromeos/network/network_device_handler.h"
#include "chromeos/network/network_state.h" #include "chromeos/network/network_state.h"
#include "chromeos/network/network_state_handler.h" #include "chromeos/network/network_state_handler.h"
#include "chromeos/network/onc/onc_signature.h" #include "chromeos/network/onc/onc_signature.h"
...@@ -604,7 +605,86 @@ void NetworkingPrivateVerifyAndEncryptDataFunction::ResultCallback( ...@@ -604,7 +605,86 @@ void NetworkingPrivateVerifyAndEncryptDataFunction::ResultCallback(
} }
void NetworkingPrivateVerifyAndEncryptDataFunction::ErrorCallback( void NetworkingPrivateVerifyAndEncryptDataFunction::ErrorCallback(
const std::string& error_name, const std::string& error) { const std::string& error_name,
const std::string& error) {
error_ = error_name;
SendResponse(false);
}
////////////////////////////////////////////////////////////////////////////////
// NetworkingPrivateSetWifiTDLSEnabledStateFunction
NetworkingPrivateSetWifiTDLSEnabledStateFunction::
~NetworkingPrivateSetWifiTDLSEnabledStateFunction() {
}
bool NetworkingPrivateSetWifiTDLSEnabledStateFunction::RunImpl() {
scoped_ptr<api::SetWifiTDLSEnabledState::Params> params =
api::SetWifiTDLSEnabledState::Params::Create(*args_);
EXTENSION_FUNCTION_VALIDATE(params);
std::string ip_or_mac_address = params->ip_or_mac_address;
bool enable = params->enabled;
NetworkHandler::Get()->network_device_handler()->
SetWifiTDLSEnabled(
ip_or_mac_address,
enable,
base::Bind(&NetworkingPrivateSetWifiTDLSEnabledStateFunction::Success,
this),
base::Bind(&NetworkingPrivateSetWifiTDLSEnabledStateFunction::Failure,
this));
return true;
}
void NetworkingPrivateSetWifiTDLSEnabledStateFunction::Success(
const std::string& result) {
results_ = api::SetWifiTDLSEnabledState::Results::Create(result);
SendResponse(true);
}
void NetworkingPrivateSetWifiTDLSEnabledStateFunction::Failure(
const std::string& error_name,
scoped_ptr<base::DictionaryValue> error_data) {
error_ = error_name;
SendResponse(false);
}
////////////////////////////////////////////////////////////////////////////////
// NetworkingPrivateGetWifiTDLSStatusFunction
NetworkingPrivateGetWifiTDLSStatusFunction::
~NetworkingPrivateGetWifiTDLSStatusFunction() {
}
bool NetworkingPrivateGetWifiTDLSStatusFunction::RunImpl() {
scoped_ptr<api::GetWifiTDLSStatus::Params> params =
api::GetWifiTDLSStatus::Params::Create(*args_);
EXTENSION_FUNCTION_VALIDATE(params);
std::string ip_or_mac_address = params->ip_or_mac_address;
NetworkHandler::Get()->network_device_handler()->
GetWifiTDLSStatus(
ip_or_mac_address,
base::Bind(&NetworkingPrivateGetWifiTDLSStatusFunction::Success,
this),
base::Bind(&NetworkingPrivateGetWifiTDLSStatusFunction::Failure,
this));
return true;
}
void NetworkingPrivateGetWifiTDLSStatusFunction::Success(
const std::string& result) {
results_ = api::GetWifiTDLSStatus::Results::Create(result);
SendResponse(true);
}
void NetworkingPrivateGetWifiTDLSStatusFunction::Failure(
const std::string& error_name,
scoped_ptr<base::DictionaryValue> error_data) {
error_ = error_name; error_ = error_name;
SendResponse(false); SendResponse(false);
} }
...@@ -450,3 +450,33 @@ void NetworkingPrivateVerifyAndEncryptDataFunction::ErrorCallback( ...@@ -450,3 +450,33 @@ void NetworkingPrivateVerifyAndEncryptDataFunction::ErrorCallback(
error_ = error_name; error_ = error_name;
SendResponse(false); SendResponse(false);
} }
////////////////////////////////////////////////////////////////////////////////
// NetworkingPrivateSetWifiTDLSEnabledStateFunction
NetworkingPrivateSetWifiTDLSEnabledStateFunction::
~NetworkingPrivateSetWifiTDLSEnabledStateFunction() {
}
bool NetworkingPrivateSetWifiTDLSEnabledStateFunction::RunImpl() {
scoped_ptr<api::SetWifiTDLSEnabledState::Params> params =
api::SetWifiTDLSEnabledState::Params::Create(*args_);
EXTENSION_FUNCTION_VALIDATE(params);
SetError("not-implemented");
return false;
}
////////////////////////////////////////////////////////////////////////////////
// NetworkingPrivateGetWifiTDLSStatusFunction
NetworkingPrivateGetWifiTDLSStatusFunction::
~NetworkingPrivateGetWifiTDLSStatusFunction() {
}
bool NetworkingPrivateGetWifiTDLSStatusFunction::RunImpl() {
scoped_ptr<api::GetWifiTDLSStatus::Params> params =
api::GetWifiTDLSStatus::Params::Create(*args_);
EXTENSION_FUNCTION_VALIDATE(params);
SetError("not-implemented");
return false;
}
...@@ -432,9 +432,21 @@ IN_PROC_BROWSER_TEST_P(ExtensionNetworkingPrivateApiTest, ...@@ -432,9 +432,21 @@ IN_PROC_BROWSER_TEST_P(ExtensionNetworkingPrivateApiTest,
EXPECT_TRUE(RunNetworkingSubtest("verifyAndEncryptData")) << message_; EXPECT_TRUE(RunNetworkingSubtest("verifyAndEncryptData")) << message_;
} }
#if defined(OS_CHROMEOS)
// Currently TDLS support is only enabled for Chrome OS.
IN_PROC_BROWSER_TEST_P(ExtensionNetworkingPrivateApiTest,
SetWifiTDLSEnabledState) {
EXPECT_TRUE(RunNetworkingSubtest("setWifiTDLSEnabledState")) << message_;
}
IN_PROC_BROWSER_TEST_P(ExtensionNetworkingPrivateApiTest,
GetWifiTDLSStatus) {
EXPECT_TRUE(RunNetworkingSubtest("getWifiTDLSStatus")) << message_;
}
#endif
INSTANTIATE_TEST_CASE_P(ExtensionNetworkingPrivateApiTestInstantiation, INSTANTIATE_TEST_CASE_P(ExtensionNetworkingPrivateApiTestInstantiation,
ExtensionNetworkingPrivateApiTest, ExtensionNetworkingPrivateApiTest,
testing::Bool()); testing::Bool());
} // namespace } // namespace
...@@ -746,6 +746,8 @@ enum HistogramValue { ...@@ -746,6 +746,8 @@ enum HistogramValue {
DEVELOPERPRIVATE_REQUESTFILESOURCE, DEVELOPERPRIVATE_REQUESTFILESOURCE,
DEVELOPERPRIVATE_OPENDEVTOOLS, DEVELOPERPRIVATE_OPENDEVTOOLS,
ACTIVITYLOGPRIVATE_DELETEACTIVITIES, ACTIVITYLOGPRIVATE_DELETEACTIVITIES,
NETWORKINGPRIVATE_SETWIFITDLSENABLEDSTATE,
NETWORKINGPRIVATE_GETWIFITDLSSTATUS,
ENUM_BOUNDARY // Last entry: Add new entries above. ENUM_BOUNDARY // Last entry: Add new entries above.
}; };
......
...@@ -353,6 +353,55 @@ ...@@ -353,6 +353,55 @@
"description": "A callback function that receives base64-encoded encrypted data to send to a trusted device." "description": "A callback function that receives base64-encoded encrypted data to send to a trusted device."
} }
] ]
},
{
"name": "setWifiTDLSEnabledState",
"description": "Enables TDLS for wifi traffic with a specified peer if available.",
"parameters": [
{
"name": "ip_or_mac_address",
"type": "string",
"description": "The IP or MAC address of the peer with which to enable a TDLS connection."
},
{
"name": "enabled",
"type": "boolean",
"description": "If true, enable TDLS, otherwise disable TDLS."
},
{
"name": "callback",
"type": "function",
"parameters": [
{
"name": "status",
"type": "string"
}
],
"description": "A callback function that receives a string with an error or the current TDLS status. 'Failed' indicates that the request failed (e.g. MAC address lookup failed). 'Timeout' indicates that the lookup timed out. Otherwise a valid status is returned (see getWifiTDLSStatus)."
}
]
},
{
"name": "getWifiTDLSStatus",
"description": "Returns the current TDLS status for the specified peer.",
"parameters": [
{
"name": "ip_or_mac_address",
"type": "string",
"description": "The IP or MAC address of the peer."
},
{
"name": "callback",
"type": "function",
"parameters": [
{
"name": "status",
"type": "string"
}
],
"description": "A callback function that receives a string with the current TDLS status which can be 'Connected', 'Disabled', 'Disconnected', 'Nonexistent', or 'Unknown'"
}
]
} }
], ],
"events": [ "events": [
......
...@@ -366,6 +366,21 @@ var availableTests = [ ...@@ -366,6 +366,21 @@ var availableTests = [
callbackPass(function(result) { callbackPass(function(result) {
assertEq("encrypted_data", result); assertEq("encrypted_data", result);
})); }));
},
function setWifiTDLSEnabledState() {
chrome.networkingPrivate.setWifiTDLSEnabledState(
"aa:bb:cc:dd:ee:ff",
true,
callbackPass(function(result) {
assertEq("Connected", result);
}));
},
function getWifiTDLSStatus() {
chrome.networkingPrivate.getWifiTDLSStatus(
"aa:bb:cc:dd:ee:ff",
callbackPass(function(result) {
assertEq("Connected", result);
}));
} }
]; ];
......
...@@ -32,15 +32,17 @@ void ErrorFunction(const std::string& device_path, ...@@ -32,15 +32,17 @@ void ErrorFunction(const std::string& device_path,
void PostDeviceNotFoundError( void PostDeviceNotFoundError(
const ShillDeviceClient::ErrorCallback& error_callback) { const ShillDeviceClient::ErrorCallback& error_callback) {
std::string error_name("org.chromium.flimflam.Error.Failure");
std::string error_message("Failed"); std::string error_message("Failed");
base::MessageLoop::current()->PostTask( base::MessageLoop::current()->PostTask(
FROM_HERE, base::Bind(error_callback, error_name, error_message)); FROM_HERE,
base::Bind(error_callback, shill::kErrorResultNotFound, error_message));
} }
} // namespace } // namespace
FakeShillDeviceClient::FakeShillDeviceClient() : weak_ptr_factory_(this) { FakeShillDeviceClient::FakeShillDeviceClient()
: tdls_busy_count_(0),
weak_ptr_factory_(this) {
} }
FakeShillDeviceClient::~FakeShillDeviceClient() { FakeShillDeviceClient::~FakeShillDeviceClient() {
...@@ -202,6 +204,32 @@ void FakeShillDeviceClient::Reset(const dbus::ObjectPath& device_path, ...@@ -202,6 +204,32 @@ void FakeShillDeviceClient::Reset(const dbus::ObjectPath& device_path,
base::MessageLoop::current()->PostTask(FROM_HERE, callback); base::MessageLoop::current()->PostTask(FROM_HERE, callback);
} }
void FakeShillDeviceClient::PerformTDLSOperation(
const dbus::ObjectPath& device_path,
const std::string& operation,
const std::string& peer,
const StringCallback& callback,
const ErrorCallback& error_callback) {
if (!stub_devices_.HasKey(device_path.value())) {
PostDeviceNotFoundError(error_callback);
return;
}
if (tdls_busy_count_) {
--tdls_busy_count_;
std::string error_message("In-Progress");
base::MessageLoop::current()->PostTask(
FROM_HERE,
base::Bind(error_callback,
shill::kErrorResultInProgress, error_message));
return;
}
std::string result;
if (operation == shill::kTDLSStatusOperation)
result = shill::kTDLSConnectedState;
base::MessageLoop::current()->PostTask(FROM_HERE,
base::Bind(callback, result));
}
ShillDeviceClient::TestInterface* FakeShillDeviceClient::GetTestInterface() { ShillDeviceClient::TestInterface* FakeShillDeviceClient::GetTestInterface() {
return this; return this;
} }
......
...@@ -76,6 +76,13 @@ class CHROMEOS_EXPORT FakeShillDeviceClient ...@@ -76,6 +76,13 @@ class CHROMEOS_EXPORT FakeShillDeviceClient
virtual void Reset(const dbus::ObjectPath& device_path, virtual void Reset(const dbus::ObjectPath& device_path,
const base::Closure& callback, const base::Closure& callback,
const ErrorCallback& error_callback) OVERRIDE; const ErrorCallback& error_callback) OVERRIDE;
virtual void PerformTDLSOperation(
const dbus::ObjectPath& device_path,
const std::string& operation,
const std::string& peer,
const StringCallback& callback,
const ErrorCallback& error_callback) OVERRIDE;
virtual ShillDeviceClient::TestInterface* GetTestInterface() OVERRIDE; virtual ShillDeviceClient::TestInterface* GetTestInterface() OVERRIDE;
// ShillDeviceClient::TestInterface overrides. // ShillDeviceClient::TestInterface overrides.
...@@ -89,6 +96,8 @@ class CHROMEOS_EXPORT FakeShillDeviceClient ...@@ -89,6 +96,8 @@ class CHROMEOS_EXPORT FakeShillDeviceClient
const base::Value& value) OVERRIDE; const base::Value& value) OVERRIDE;
virtual std::string GetDevicePathForType(const std::string& type) OVERRIDE; virtual std::string GetDevicePathForType(const std::string& type) OVERRIDE;
void set_tdls_busy_count(int count) { tdls_busy_count_ = count; }
private: private:
typedef ObserverList<ShillPropertyChangedObserver> PropertyObserverList; typedef ObserverList<ShillPropertyChangedObserver> PropertyObserverList;
...@@ -110,6 +119,8 @@ class CHROMEOS_EXPORT FakeShillDeviceClient ...@@ -110,6 +119,8 @@ class CHROMEOS_EXPORT FakeShillDeviceClient
// Observer list for each device. // Observer list for each device.
std::map<dbus::ObjectPath, PropertyObserverList*> observer_list_; std::map<dbus::ObjectPath, PropertyObserverList*> observer_list_;
int tdls_busy_count_; // Number of times to return InProgress for TDLS.
// Note: This should remain the last member so it'll be destroyed and // Note: This should remain the last member so it'll be destroyed and
// invalidate its weak pointers before any other members are destroyed. // invalidate its weak pointers before any other members are destroyed.
base::WeakPtrFactory<FakeShillDeviceClient> weak_ptr_factory_; base::WeakPtrFactory<FakeShillDeviceClient> weak_ptr_factory_;
......
...@@ -536,6 +536,16 @@ void FakeShillManagerClient::NotifyObserversPropertyChanged( ...@@ -536,6 +536,16 @@ void FakeShillManagerClient::NotifyObserversPropertyChanged(
OnPropertyChanged(property, *(services.get()))); OnPropertyChanged(property, *(services.get())));
return; return;
} }
if (property == shill::kDevicesProperty) {
base::ListValue* devices = NULL;
if (stub_properties_.GetListWithoutPathExpansion(
shill::kDevicesProperty, &devices)) {
FOR_EACH_OBSERVER(ShillPropertyChangedObserver,
observer_list_,
OnPropertyChanged(property, *devices));
}
return;
}
base::Value* value = NULL; base::Value* value = NULL;
if (!stub_properties_.GetWithoutPathExpansion(property, &value)) { if (!stub_properties_.GetWithoutPathExpansion(property, &value)) {
LOG(ERROR) << "Notify for unknown property: " << property; LOG(ERROR) << "Notify for unknown property: " << property;
......
...@@ -191,6 +191,21 @@ class ShillDeviceClientImpl : public ShillDeviceClient { ...@@ -191,6 +191,21 @@ class ShillDeviceClientImpl : public ShillDeviceClient {
&method_call, callback, error_callback); &method_call, callback, error_callback);
} }
virtual void PerformTDLSOperation(
const dbus::ObjectPath& device_path,
const std::string& operation,
const std::string& peer,
const StringCallback& callback,
const ErrorCallback& error_callback) OVERRIDE {
dbus::MethodCall method_call(shill::kFlimflamDeviceInterface,
shill::kPerformTDLSOperationFunction);
dbus::MessageWriter writer(&method_call);
writer.AppendString(operation);
writer.AppendString(peer);
GetHelper(device_path)->CallStringMethodWithErrorCallback(
&method_call, callback, error_callback);
}
virtual TestInterface* GetTestInterface() OVERRIDE { virtual TestInterface* GetTestInterface() OVERRIDE {
return NULL; return NULL;
} }
......
...@@ -37,6 +37,7 @@ class CHROMEOS_EXPORT ShillDeviceClient : public DBusClient { ...@@ -37,6 +37,7 @@ class CHROMEOS_EXPORT ShillDeviceClient : public DBusClient {
public: public:
typedef ShillClientHelper::PropertyChangedHandler PropertyChangedHandler; typedef ShillClientHelper::PropertyChangedHandler PropertyChangedHandler;
typedef ShillClientHelper::DictionaryValueCallback DictionaryValueCallback; typedef ShillClientHelper::DictionaryValueCallback DictionaryValueCallback;
typedef ShillClientHelper::StringCallback StringCallback;
typedef ShillClientHelper::ErrorCallback ErrorCallback; typedef ShillClientHelper::ErrorCallback ErrorCallback;
// Interface for setting up devices for testing. // Interface for setting up devices for testing.
...@@ -151,8 +152,16 @@ class CHROMEOS_EXPORT ShillDeviceClient : public DBusClient { ...@@ -151,8 +152,16 @@ class CHROMEOS_EXPORT ShillDeviceClient : public DBusClient {
// Calls the Reset method. // Calls the Reset method.
// |callback| is called after the method call finishes. // |callback| is called after the method call finishes.
virtual void Reset(const dbus::ObjectPath& device_path, virtual void Reset(const dbus::ObjectPath& device_path,
const base::Closure& callback, const base::Closure& callback,
const ErrorCallback& error_callback) = 0; const ErrorCallback& error_callback) = 0;
// Calls the PerformTDLSOperation method.
// |callback| is called after the method call finishes.
virtual void PerformTDLSOperation(const dbus::ObjectPath& device_path,
const std::string& operation,
const std::string& peer,
const StringCallback& callback,
const ErrorCallback& error_callback) = 0;
// Returns an interface for testing (stub only), or returns NULL. // Returns an interface for testing (stub only), or returns NULL.
virtual TestInterface* GetTestInterface() = 0; virtual TestInterface* GetTestInterface() = 0;
......
...@@ -73,4 +73,15 @@ void FakeNetworkDeviceHandler::ChangePin( ...@@ -73,4 +73,15 @@ void FakeNetworkDeviceHandler::ChangePin(
void FakeNetworkDeviceHandler::SetCellularAllowRoaming(bool allow_roaming) {} void FakeNetworkDeviceHandler::SetCellularAllowRoaming(bool allow_roaming) {}
void FakeNetworkDeviceHandler::SetWifiTDLSEnabled(
const std::string& ip_or_mac_address,
bool enabled,
const network_handler::StringResultCallback& callback,
const network_handler::ErrorCallback& error_callback) {}
void FakeNetworkDeviceHandler::GetWifiTDLSStatus(
const std::string& ip_or_mac_address,
const network_handler::StringResultCallback& callback,
const network_handler::ErrorCallback& error_callback) {}
} // namespace chromeos } // namespace chromeos
...@@ -83,6 +83,17 @@ class CHROMEOS_EXPORT FakeNetworkDeviceHandler : public NetworkDeviceHandler { ...@@ -83,6 +83,17 @@ class CHROMEOS_EXPORT FakeNetworkDeviceHandler : public NetworkDeviceHandler {
virtual void SetCellularAllowRoaming(bool allow_roaming) OVERRIDE; virtual void SetCellularAllowRoaming(bool allow_roaming) OVERRIDE;
virtual void SetWifiTDLSEnabled(
const std::string& ip_or_mac_address,
bool enabled,
const network_handler::StringResultCallback& callback,
const network_handler::ErrorCallback& error_callback) OVERRIDE;
virtual void GetWifiTDLSStatus(
const std::string& ip_or_mac_address,
const network_handler::StringResultCallback& callback,
const network_handler::ErrorCallback& error_callback) OVERRIDE;
private: private:
DISALLOW_COPY_AND_ASSIGN(FakeNetworkDeviceHandler); DISALLOW_COPY_AND_ASSIGN(FakeNetworkDeviceHandler);
}; };
......
...@@ -6,11 +6,13 @@ ...@@ -6,11 +6,13 @@
namespace chromeos { namespace chromeos {
const char NetworkDeviceHandler::kErrorDeviceMissing[] = "device-missing";
const char NetworkDeviceHandler::kErrorFailure[] = "failure"; const char NetworkDeviceHandler::kErrorFailure[] = "failure";
const char NetworkDeviceHandler::kErrorIncorrectPin[] = "incorrect-pin"; const char NetworkDeviceHandler::kErrorIncorrectPin[] = "incorrect-pin";
const char NetworkDeviceHandler::kErrorNotSupported[] = "not-supported"; const char NetworkDeviceHandler::kErrorNotSupported[] = "not-supported";
const char NetworkDeviceHandler::kErrorPinBlocked[] = "pin-blocked"; const char NetworkDeviceHandler::kErrorPinBlocked[] = "pin-blocked";
const char NetworkDeviceHandler::kErrorPinRequired[] = "pin-required"; const char NetworkDeviceHandler::kErrorPinRequired[] = "pin-required";
const char NetworkDeviceHandler::kErrorTimeout[] = "timeout";
const char NetworkDeviceHandler::kErrorUnknown[] = "unknown"; const char NetworkDeviceHandler::kErrorUnknown[] = "unknown";
NetworkDeviceHandler::NetworkDeviceHandler() { NetworkDeviceHandler::NetworkDeviceHandler() {
......
...@@ -33,12 +33,14 @@ namespace chromeos { ...@@ -33,12 +33,14 @@ namespace chromeos {
class CHROMEOS_EXPORT NetworkDeviceHandler { class CHROMEOS_EXPORT NetworkDeviceHandler {
public: public:
// Constants for |error_name| from |error_callback|. // Constants for |error_name| from |error_callback|.
static const char kErrorDeviceMissing[];
static const char kErrorFailure[]; static const char kErrorFailure[];
static const char kErrorIncorrectPin[]; static const char kErrorIncorrectPin[];
static const char kErrorNotFound[]; static const char kErrorNotFound[];
static const char kErrorNotSupported[]; static const char kErrorNotSupported[];
static const char kErrorPinBlocked[]; static const char kErrorPinBlocked[];
static const char kErrorPinRequired[]; static const char kErrorPinRequired[];
static const char kErrorTimeout[];
static const char kErrorUnknown[]; static const char kErrorUnknown[];
NetworkDeviceHandler(); NetworkDeviceHandler();
...@@ -192,6 +194,21 @@ class CHROMEOS_EXPORT NetworkDeviceHandler { ...@@ -192,6 +194,21 @@ class CHROMEOS_EXPORT NetworkDeviceHandler {
// available in the future. // available in the future.
virtual void SetCellularAllowRoaming(bool allow_roaming) = 0; virtual void SetCellularAllowRoaming(bool allow_roaming) = 0;
// Attempts to enable or disable TDLS for the specified IP or MAC address for
// the active wifi device.
virtual void SetWifiTDLSEnabled(
const std::string& ip_or_mac_address,
bool enabled,
const network_handler::StringResultCallback& callback,
const network_handler::ErrorCallback& error_callback) = 0;
// Returns the TDLS status for the specified IP or MAC address for
// the active wifi device.
virtual void GetWifiTDLSStatus(
const std::string& ip_or_mac_address,
const network_handler::StringResultCallback& callback,
const network_handler::ErrorCallback& error_callback) = 0;
private: private:
DISALLOW_COPY_AND_ASSIGN(NetworkDeviceHandler); DISALLOW_COPY_AND_ASSIGN(NetworkDeviceHandler);
}; };
......
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/location.h" #include "base/location.h"
#include "base/message_loop/message_loop_proxy.h"
#include "base/time/time.h"
#include "base/values.h" #include "base/values.h"
#include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/shill_device_client.h" #include "chromeos/dbus/shill_device_client.h"
...@@ -33,6 +35,8 @@ std::string GetErrorNameForShillError(const std::string& shill_error_name) { ...@@ -33,6 +35,8 @@ std::string GetErrorNameForShillError(const std::string& shill_error_name) {
return NetworkDeviceHandler::kErrorPinBlocked; return NetworkDeviceHandler::kErrorPinBlocked;
if (shill_error_name == shill::kErrorResultPinRequired) if (shill_error_name == shill::kErrorResultPinRequired)
return NetworkDeviceHandler::kErrorPinRequired; return NetworkDeviceHandler::kErrorPinRequired;
if (shill_error_name == shill::kErrorResultNotFound)
return NetworkDeviceHandler::kErrorDeviceMissing;
return NetworkDeviceHandler::kErrorUnknown; return NetworkDeviceHandler::kErrorUnknown;
} }
...@@ -134,6 +138,118 @@ void SetDevicePropertyInternal( ...@@ -134,6 +138,118 @@ void SetDevicePropertyInternal(
base::Bind(&HandleShillCallFailure, device_path, error_callback)); base::Bind(&HandleShillCallFailure, device_path, error_callback));
} }
// Struct containing TDLS Operation parameters.
struct TDLSOperationParams {
TDLSOperationParams() : retry_count(0) {}
std::string operation;
std::string ip_or_mac_address;
int retry_count;
};
// Forward declare for PostDelayedTask.
void CallPerformTDLSOperation(
const std::string& device_path,
const TDLSOperationParams& params,
const network_handler::StringResultCallback& callback,
const network_handler::ErrorCallback& error_callback);
void TDLSSuccessCallback(
const std::string& device_path,
const TDLSOperationParams& params,
const network_handler::StringResultCallback& callback,
const network_handler::ErrorCallback& error_callback,
const std::string& result) {
std::string event_desc = "TDLSSuccessCallback: " + params.operation;
if (!result.empty())
event_desc += ": " + result;
NET_LOG_EVENT(event_desc, device_path);
if (params.operation != shill::kTDLSSetupOperation) {
if (!callback.is_null())
callback.Run(result);
return;
}
if (!result.empty())
NET_LOG_ERROR("Unexpected TDLS result: " + result, device_path);
// Send a delayed Status request after a successful Setup call.
TDLSOperationParams status_params;
status_params.operation = shill::kTDLSStatusOperation;
status_params.ip_or_mac_address = params.ip_or_mac_address;
const int64 kRequestStatusDelayMs = 500;
base::TimeDelta request_delay;
if (!DBusThreadManager::Get()->GetShillDeviceClient()->GetTestInterface())
request_delay = base::TimeDelta::FromMilliseconds(kRequestStatusDelayMs);
base::MessageLoopProxy::current()->PostDelayedTask(
FROM_HERE,
base::Bind(&CallPerformTDLSOperation,
device_path, status_params, callback, error_callback),
request_delay);
}
void TDLSErrorCallback(
const std::string& device_path,
const TDLSOperationParams& params,
const network_handler::StringResultCallback& callback,
const network_handler::ErrorCallback& error_callback,
const std::string& dbus_error_name,
const std::string& dbus_error_message) {
// If a Setup operation receives an InProgress error, retry.
const int kMaxRetries = 5;
if (params.operation == shill::kTDLSSetupOperation &&
dbus_error_name == shill::kErrorResultInProgress &&
params.retry_count < kMaxRetries) {
TDLSOperationParams retry_params = params;
++retry_params.retry_count;
NET_LOG_EVENT(base::StringPrintf("TDLS Retry: %d", params.retry_count),
device_path);
const int64 kReRequestDelayMs = 1000;
base::TimeDelta request_delay;
if (!DBusThreadManager::Get()->GetShillDeviceClient()->GetTestInterface())
request_delay = base::TimeDelta::FromMilliseconds(kReRequestDelayMs);
base::MessageLoopProxy::current()->PostDelayedTask(
FROM_HERE,
base::Bind(&CallPerformTDLSOperation,
device_path, retry_params, callback, error_callback),
request_delay);
return;
}
NET_LOG_ERROR("TDLS Error:" + dbus_error_name + ":" + dbus_error_message,
device_path);
if (error_callback.is_null())
return;
const std::string error_name =
dbus_error_name == shill::kErrorResultInProgress ?
NetworkDeviceHandler::kErrorTimeout : NetworkDeviceHandler::kErrorUnknown;
const std::string& error_detail = params.ip_or_mac_address;
scoped_ptr<base::DictionaryValue> error_data(
network_handler::CreateDBusErrorData(
device_path, error_name, error_detail,
dbus_error_name, dbus_error_message));
error_callback.Run(error_name, error_data.Pass());
}
void CallPerformTDLSOperation(
const std::string& device_path,
const TDLSOperationParams& params,
const network_handler::StringResultCallback& callback,
const network_handler::ErrorCallback& error_callback) {
NET_LOG_EVENT("CallPerformTDLSOperation: " + params.operation, device_path);
DBusThreadManager::Get()->GetShillDeviceClient()->PerformTDLSOperation(
dbus::ObjectPath(device_path),
params.operation,
params.ip_or_mac_address,
base::Bind(&TDLSSuccessCallback,
device_path, params, callback, error_callback),
base::Bind(&TDLSErrorCallback,
device_path, params, callback, error_callback));
}
} // namespace } // namespace
NetworkDeviceHandlerImpl::~NetworkDeviceHandlerImpl() { NetworkDeviceHandlerImpl::~NetworkDeviceHandlerImpl() {
...@@ -278,6 +394,50 @@ void NetworkDeviceHandlerImpl::SetCellularAllowRoaming( ...@@ -278,6 +394,50 @@ void NetworkDeviceHandlerImpl::SetCellularAllowRoaming(
ApplyCellularAllowRoamingToShill(); ApplyCellularAllowRoamingToShill();
} }
void NetworkDeviceHandlerImpl::SetWifiTDLSEnabled(
const std::string& ip_or_mac_address,
bool enabled,
const network_handler::StringResultCallback& callback,
const network_handler::ErrorCallback& error_callback) {
const DeviceState* device_state =
network_state_handler_->GetDeviceStateByType(NetworkTypePattern::WiFi());
if (!device_state) {
if (error_callback.is_null())
return;
scoped_ptr<base::DictionaryValue> error_data(new base::DictionaryValue);
error_data->SetString(network_handler::kErrorName, kErrorDeviceMissing);
error_callback.Run(kErrorDeviceMissing, error_data.Pass());
return;
}
TDLSOperationParams params;
params.operation = enabled ? shill::kTDLSSetupOperation
: shill::kTDLSTeardownOperation;
params.ip_or_mac_address = ip_or_mac_address;
CallPerformTDLSOperation(
device_state->path(), params, callback, error_callback);
}
void NetworkDeviceHandlerImpl::GetWifiTDLSStatus(
const std::string& ip_or_mac_address,
const network_handler::StringResultCallback& callback,
const network_handler::ErrorCallback& error_callback) {
const DeviceState* device_state =
network_state_handler_->GetDeviceStateByType(NetworkTypePattern::WiFi());
if (!device_state) {
if (error_callback.is_null())
return;
scoped_ptr<base::DictionaryValue> error_data(new base::DictionaryValue);
error_data->SetString(network_handler::kErrorName, kErrorDeviceMissing);
error_callback.Run(kErrorDeviceMissing, error_data.Pass());
return;
}
TDLSOperationParams params;
params.operation = shill::kTDLSStatusOperation;
params.ip_or_mac_address = ip_or_mac_address;
CallPerformTDLSOperation(
device_state->path(), params, callback, error_callback);
}
void NetworkDeviceHandlerImpl::DeviceListChanged() { void NetworkDeviceHandlerImpl::DeviceListChanged() {
ApplyCellularAllowRoamingToShill(); ApplyCellularAllowRoamingToShill();
} }
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#ifndef CHROMEOS_NETWORK_NETWORK_DEVICE_HANDLER_IMPL_H_ #ifndef CHROMEOS_NETWORK_NETWORK_DEVICE_HANDLER_IMPL_H_
#define CHROMEOS_NETWORK_NETWORK_DEVICE_HANDLER_IMPL_H_ #define CHROMEOS_NETWORK_NETWORK_DEVICE_HANDLER_IMPL_H_
#include <map>
#include <string> #include <string>
#include "base/basictypes.h" #include "base/basictypes.h"
...@@ -90,6 +91,17 @@ class CHROMEOS_EXPORT NetworkDeviceHandlerImpl ...@@ -90,6 +91,17 @@ class CHROMEOS_EXPORT NetworkDeviceHandlerImpl
virtual void SetCellularAllowRoaming(bool allow_roaming) OVERRIDE; virtual void SetCellularAllowRoaming(bool allow_roaming) OVERRIDE;
virtual void SetWifiTDLSEnabled(
const std::string& ip_or_mac_address,
bool enabled,
const network_handler::StringResultCallback& callback,
const network_handler::ErrorCallback& error_callback) OVERRIDE;
virtual void GetWifiTDLSStatus(
const std::string& ip_or_mac_address,
const network_handler::StringResultCallback& callback,
const network_handler::ErrorCallback& error_callback) OVERRIDE;
// NetworkStateHandlerObserver overrides // NetworkStateHandlerObserver overrides
virtual void DeviceListChanged() OVERRIDE; virtual void DeviceListChanged() OVERRIDE;
...@@ -106,7 +118,6 @@ class CHROMEOS_EXPORT NetworkDeviceHandlerImpl ...@@ -106,7 +118,6 @@ class CHROMEOS_EXPORT NetworkDeviceHandlerImpl
void ApplyCellularAllowRoamingToShill(); void ApplyCellularAllowRoamingToShill();
NetworkStateHandler* network_state_handler_; NetworkStateHandler* network_state_handler_;
bool cellular_allow_roaming_; bool cellular_allow_roaming_;
DISALLOW_COPY_AND_ASSIGN(NetworkDeviceHandlerImpl); DISALLOW_COPY_AND_ASSIGN(NetworkDeviceHandlerImpl);
......
...@@ -39,22 +39,14 @@ class NetworkDeviceHandlerTest : public testing::Test { ...@@ -39,22 +39,14 @@ class NetworkDeviceHandlerTest : public testing::Test {
scoped_ptr<ShillDeviceClient>(fake_device_client_)); scoped_ptr<ShillDeviceClient>(fake_device_client_));
DBusThreadManager::InitializeForTesting(dbus_manager); DBusThreadManager::InitializeForTesting(dbus_manager);
ShillDeviceClient::TestInterface* device_test =
fake_device_client_->GetTestInterface();
device_test->AddDevice(
kDefaultCellularDevicePath, shill::kTypeCellular, "cellular1");
device_test->AddDevice(kDefaultWifiDevicePath, shill::kTypeWifi, "wifi1");
base::ListValue test_ip_configs;
test_ip_configs.AppendString("ip_config1");
device_test->SetDeviceProperty(
kDefaultWifiDevicePath, shill::kIPConfigsProperty, test_ip_configs);
success_callback_ = base::Bind(&NetworkDeviceHandlerTest::SuccessCallback, success_callback_ = base::Bind(&NetworkDeviceHandlerTest::SuccessCallback,
base::Unretained(this)); base::Unretained(this));
properties_success_callback_ = properties_success_callback_ =
base::Bind(&NetworkDeviceHandlerTest::PropertiesSuccessCallback, base::Bind(&NetworkDeviceHandlerTest::PropertiesSuccessCallback,
base::Unretained(this)); base::Unretained(this));
string_success_callback_ =
base::Bind(&NetworkDeviceHandlerTest::StringSuccessCallback,
base::Unretained(this));
error_callback_ = base::Bind(&NetworkDeviceHandlerTest::ErrorCallback, error_callback_ = base::Bind(&NetworkDeviceHandlerTest::ErrorCallback,
base::Unretained(this)); base::Unretained(this));
...@@ -62,6 +54,20 @@ class NetworkDeviceHandlerTest : public testing::Test { ...@@ -62,6 +54,20 @@ class NetworkDeviceHandlerTest : public testing::Test {
NetworkDeviceHandlerImpl* device_handler = new NetworkDeviceHandlerImpl; NetworkDeviceHandlerImpl* device_handler = new NetworkDeviceHandlerImpl;
device_handler->Init(network_state_handler_.get()); device_handler->Init(network_state_handler_.get());
network_device_handler_.reset(device_handler); network_device_handler_.reset(device_handler);
// Add devices after handlers have been initialized.
ShillDeviceClient::TestInterface* device_test =
fake_device_client_->GetTestInterface();
device_test->AddDevice(
kDefaultCellularDevicePath, shill::kTypeCellular, "cellular1");
device_test->AddDevice(kDefaultWifiDevicePath, shill::kTypeWifi, "wifi1");
base::ListValue test_ip_configs;
test_ip_configs.AppendString("ip_config1");
device_test->SetDeviceProperty(
kDefaultWifiDevicePath, shill::kIPConfigsProperty, test_ip_configs);
message_loop_.RunUntilIdle();
} }
virtual void TearDown() OVERRIDE { virtual void TearDown() OVERRIDE {
...@@ -72,6 +78,7 @@ class NetworkDeviceHandlerTest : public testing::Test { ...@@ -72,6 +78,7 @@ class NetworkDeviceHandlerTest : public testing::Test {
void ErrorCallback(const std::string& error_name, void ErrorCallback(const std::string& error_name,
scoped_ptr<base::DictionaryValue> error_data) { scoped_ptr<base::DictionaryValue> error_data) {
LOG(ERROR) << "ErrorCallback: " << error_name;
result_ = error_name; result_ = error_name;
} }
...@@ -85,6 +92,11 @@ class NetworkDeviceHandlerTest : public testing::Test { ...@@ -85,6 +92,11 @@ class NetworkDeviceHandlerTest : public testing::Test {
properties_.reset(properties.DeepCopy()); properties_.reset(properties.DeepCopy());
} }
void StringSuccessCallback(const std::string& result) {
LOG(ERROR) << "StringSuccessCallback: " << result;
result_ = kResultSuccess;
}
protected: protected:
std::string result_; std::string result_;
...@@ -94,6 +106,7 @@ class NetworkDeviceHandlerTest : public testing::Test { ...@@ -94,6 +106,7 @@ class NetworkDeviceHandlerTest : public testing::Test {
base::MessageLoopForUI message_loop_; base::MessageLoopForUI message_loop_;
base::Closure success_callback_; base::Closure success_callback_;
network_handler::DictionaryResultCallback properties_success_callback_; network_handler::DictionaryResultCallback properties_success_callback_;
network_handler::StringResultCallback string_success_callback_;
network_handler::ErrorCallback error_callback_; network_handler::ErrorCallback error_callback_;
scoped_ptr<base::DictionaryValue> properties_; scoped_ptr<base::DictionaryValue> properties_;
...@@ -158,7 +171,7 @@ TEST_F(NetworkDeviceHandlerTest, SetDeviceProperty) { ...@@ -158,7 +171,7 @@ TEST_F(NetworkDeviceHandlerTest, SetDeviceProperty) {
success_callback_, success_callback_,
error_callback_); error_callback_);
message_loop_.RunUntilIdle(); message_loop_.RunUntilIdle();
EXPECT_EQ(NetworkDeviceHandler::kErrorFailure, result_); EXPECT_EQ(NetworkDeviceHandler::kErrorDeviceMissing, result_);
// Setting a owner-protected device property through SetDeviceProperty must // Setting a owner-protected device property through SetDeviceProperty must
// fail. // fail.
...@@ -209,6 +222,57 @@ TEST_F(NetworkDeviceHandlerTest, CellularAllowRoaming) { ...@@ -209,6 +222,57 @@ TEST_F(NetworkDeviceHandlerTest, CellularAllowRoaming) {
EXPECT_FALSE(allow_roaming); EXPECT_FALSE(allow_roaming);
} }
TEST_F(NetworkDeviceHandlerTest, SetWifiTDLSEnabled) {
// We add a wifi device by default, initial call should succeed.
network_device_handler_->SetWifiTDLSEnabled(
"fake_ip_address", true, string_success_callback_, error_callback_);
message_loop_.RunUntilIdle();
EXPECT_EQ(kResultSuccess, result_);
}
TEST_F(NetworkDeviceHandlerTest, SetWifiTDLSEnabledMissing) {
// Remove the wifi device. Call should fail with "device missing" error.
fake_device_client_->GetTestInterface()->RemoveDevice(kDefaultWifiDevicePath);
message_loop_.RunUntilIdle();
network_device_handler_->SetWifiTDLSEnabled(
"fake_ip_address", true, string_success_callback_, error_callback_);
message_loop_.RunUntilIdle();
EXPECT_EQ(NetworkDeviceHandler::kErrorDeviceMissing, result_);
}
TEST_F(NetworkDeviceHandlerTest, SetWifiTDLSEnabledBusy) {
// Set the busy count, call should succeed after repeat attempt.
fake_device_client_->set_tdls_busy_count(1);
network_device_handler_->SetWifiTDLSEnabled(
"fake_ip_address", true, string_success_callback_, error_callback_);
message_loop_.RunUntilIdle();
EXPECT_EQ(kResultSuccess, result_);
// Set the busy count to a large number, call should fail after max number
// of repeat attempt.
fake_device_client_->set_tdls_busy_count(100000);
network_device_handler_->SetWifiTDLSEnabled(
"fake_ip_address", true, string_success_callback_, error_callback_);
message_loop_.RunUntilIdle();
EXPECT_EQ(NetworkDeviceHandler::kErrorTimeout, result_);
}
TEST_F(NetworkDeviceHandlerTest, GetWifiTDLSStatus) {
// We add a wifi device by default, initial call should succeed.
network_device_handler_->GetWifiTDLSStatus(
"fake_ip_address", string_success_callback_, error_callback_);
message_loop_.RunUntilIdle();
EXPECT_EQ(kResultSuccess, result_);
// Remove the wifi device. Call should fail with "device missing" error.
fake_device_client_->GetTestInterface()->RemoveDevice(kDefaultWifiDevicePath);
message_loop_.RunUntilIdle();
network_device_handler_->GetWifiTDLSStatus(
"fake_ip_address", string_success_callback_, error_callback_);
message_loop_.RunUntilIdle();
EXPECT_EQ(NetworkDeviceHandler::kErrorDeviceMissing, result_);
}
TEST_F(NetworkDeviceHandlerTest, RequestRefreshIPConfigs) { TEST_F(NetworkDeviceHandlerTest, RequestRefreshIPConfigs) {
network_device_handler_->RequestRefreshIPConfigs( network_device_handler_->RequestRefreshIPConfigs(
kDefaultWifiDevicePath, success_callback_, error_callback_); kDefaultWifiDevicePath, success_callback_, error_callback_);
...@@ -231,7 +295,7 @@ TEST_F(NetworkDeviceHandlerTest, SetCarrier) { ...@@ -231,7 +295,7 @@ TEST_F(NetworkDeviceHandlerTest, SetCarrier) {
network_device_handler_->SetCarrier( network_device_handler_->SetCarrier(
kUnknownCellularDevicePath, kCarrier, success_callback_, error_callback_); kUnknownCellularDevicePath, kCarrier, success_callback_, error_callback_);
message_loop_.RunUntilIdle(); message_loop_.RunUntilIdle();
EXPECT_EQ(NetworkDeviceHandler::kErrorFailure, result_); EXPECT_EQ(NetworkDeviceHandler::kErrorDeviceMissing, result_);
} }
TEST_F(NetworkDeviceHandlerTest, RequirePin) { TEST_F(NetworkDeviceHandlerTest, RequirePin) {
...@@ -253,7 +317,7 @@ TEST_F(NetworkDeviceHandlerTest, RequirePin) { ...@@ -253,7 +317,7 @@ TEST_F(NetworkDeviceHandlerTest, RequirePin) {
success_callback_, success_callback_,
error_callback_); error_callback_);
message_loop_.RunUntilIdle(); message_loop_.RunUntilIdle();
EXPECT_EQ(NetworkDeviceHandler::kErrorFailure, result_); EXPECT_EQ(NetworkDeviceHandler::kErrorDeviceMissing, result_);
} }
TEST_F(NetworkDeviceHandlerTest, EnterPin) { TEST_F(NetworkDeviceHandlerTest, EnterPin) {
...@@ -269,7 +333,7 @@ TEST_F(NetworkDeviceHandlerTest, EnterPin) { ...@@ -269,7 +333,7 @@ TEST_F(NetworkDeviceHandlerTest, EnterPin) {
network_device_handler_->EnterPin( network_device_handler_->EnterPin(
kUnknownCellularDevicePath, kPin, success_callback_, error_callback_); kUnknownCellularDevicePath, kPin, success_callback_, error_callback_);
message_loop_.RunUntilIdle(); message_loop_.RunUntilIdle();
EXPECT_EQ(NetworkDeviceHandler::kErrorFailure, result_); EXPECT_EQ(NetworkDeviceHandler::kErrorDeviceMissing, result_);
} }
TEST_F(NetworkDeviceHandlerTest, UnblockPin) { TEST_F(NetworkDeviceHandlerTest, UnblockPin) {
...@@ -292,7 +356,7 @@ TEST_F(NetworkDeviceHandlerTest, UnblockPin) { ...@@ -292,7 +356,7 @@ TEST_F(NetworkDeviceHandlerTest, UnblockPin) {
success_callback_, success_callback_,
error_callback_); error_callback_);
message_loop_.RunUntilIdle(); message_loop_.RunUntilIdle();
EXPECT_EQ(NetworkDeviceHandler::kErrorFailure, result_); EXPECT_EQ(NetworkDeviceHandler::kErrorDeviceMissing, result_);
} }
TEST_F(NetworkDeviceHandlerTest, ChangePin) { TEST_F(NetworkDeviceHandlerTest, ChangePin) {
...@@ -315,7 +379,7 @@ TEST_F(NetworkDeviceHandlerTest, ChangePin) { ...@@ -315,7 +379,7 @@ TEST_F(NetworkDeviceHandlerTest, ChangePin) {
success_callback_, success_callback_,
error_callback_); error_callback_);
message_loop_.RunUntilIdle(); message_loop_.RunUntilIdle();
EXPECT_EQ(NetworkDeviceHandler::kErrorFailure, result_); EXPECT_EQ(NetworkDeviceHandler::kErrorDeviceMissing, result_);
} }
} // namespace chromeos } // namespace chromeos
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