Index: chrome/browser/chromeos/cros/cros_network_functions_unittest.cc |
diff --git a/chrome/browser/chromeos/cros/cros_network_functions_unittest.cc b/chrome/browser/chromeos/cros/cros_network_functions_unittest.cc |
index 30f05c1c61e5853367c1ac1d2d7c4dcd16189e0c..63f926aa95f77d2685b68ee78e2d5ecba937586f 100644 |
--- a/chrome/browser/chromeos/cros/cros_network_functions_unittest.cc |
+++ b/chrome/browser/chromeos/cros/cros_network_functions_unittest.cc |
@@ -390,6 +390,16 @@ TEST_F(CrosNetworkFunctionsLibcrosTest, CrosMonitorSMS) { |
delete watcher; |
} |
+TEST_F(CrosNetworkFunctionsLibcrosTest, CrosRequestNetworkServiceConnect) { |
+ const std::string service_path = "service path"; |
+ void* object = reinterpret_cast<void*>(42); // dummy |
satorux1
2012/04/23 17:15:20
I'm guessing that you are using 42 because you can
hashimoto
2012/04/24 04:29:46
I can pass NULL, but I just want to make sure that
|
+ EXPECT_CALL(*MockChromeOSNetwork::Get(), |
+ RequestNetworkServiceConnect(StrEq(service_path), |
+ &OnNetworkAction, |
+ object)).Times(1); |
+ CrosRequestNetworkServiceConnect(service_path, &OnNetworkAction, object); |
+} |
+ |
TEST_F(CrosNetworkFunctionsLibcrosTest, CrosRequestNetworkManagerProperties) { |
const std::string key1 = "key1"; |
const std::string value1 = "value1"; |
@@ -596,6 +606,60 @@ TEST_F(CrosNetworkFunctionsLibcrosTest, CrosRequestNetworkDeviceEnable) { |
CrosRequestNetworkDeviceEnable(flimflam::kTypeWifi, kEnable); |
} |
+TEST_F(CrosNetworkFunctionsLibcrosTest, CrosRequestRequirePin) { |
+ const std::string device_path = "/device/path"; |
+ const std::string pin = "123456"; |
+ const bool kEnable = true; |
+ void* object = reinterpret_cast<void*>(42); // dummy |
+ EXPECT_CALL(*MockChromeOSNetwork::Get(), RequestRequirePin( |
+ StrEq(device_path), StrEq(pin), kEnable, &OnNetworkAction, object)) |
+ .Times(1); |
+ CrosRequestRequirePin(device_path, pin, kEnable, &OnNetworkAction, object); |
+} |
+ |
+TEST_F(CrosNetworkFunctionsLibcrosTest, CrosRequestEnterPin) { |
+ const std::string device_path = "/device/path"; |
+ const std::string pin = "123456"; |
+ void* object = reinterpret_cast<void*>(42); // dummy |
+ EXPECT_CALL(*MockChromeOSNetwork::Get(), RequestEnterPin( |
+ StrEq(device_path), StrEq(pin), &OnNetworkAction, object)).Times(1); |
+ CrosRequestEnterPin(device_path, pin, &OnNetworkAction, object); |
+} |
+ |
+TEST_F(CrosNetworkFunctionsLibcrosTest, CrosRequestUnblockPin) { |
+ const std::string device_path = "/device/path"; |
+ const std::string unblock_code = "987654"; |
+ const std::string pin = "123456"; |
+ void* object = reinterpret_cast<void*>(42); // dummy |
+ EXPECT_CALL(*MockChromeOSNetwork::Get(), RequestUnblockPin( |
+ StrEq(device_path), StrEq(unblock_code), StrEq(pin), &OnNetworkAction, |
+ object)).Times(1); |
+ CrosRequestUnblockPin(device_path, unblock_code, pin, &OnNetworkAction, |
+ object); |
+} |
+ |
+TEST_F(CrosNetworkFunctionsLibcrosTest, CrosRequestChangePin) { |
+ const std::string device_path = "/device/path"; |
+ const std::string old_pin = "123456"; |
+ const std::string new_pin = "234567"; |
+ void* object = reinterpret_cast<void*>(42); // dummy |
+ EXPECT_CALL(*MockChromeOSNetwork::Get(), RequestChangePin( |
+ StrEq(device_path), StrEq(old_pin), StrEq(new_pin), &OnNetworkAction, |
+ object)).Times(1); |
+ CrosRequestChangePin(device_path, old_pin, new_pin, &OnNetworkAction, object); |
+} |
+ |
+TEST_F(CrosNetworkFunctionsLibcrosTest, CrosRequestCellularRegister) { |
+ const std::string device_path = "/device/path"; |
+ const std::string network_id = "networkid"; |
+ void* object = reinterpret_cast<void*>(42); // dummy |
+ EXPECT_CALL(*MockChromeOSNetwork::Get(), RequestCellularRegister( |
+ StrEq(device_path), StrEq(network_id), &OnNetworkAction, object)) |
+ .Times(1); |
+ CrosRequestCellularRegister(device_path, network_id, &OnNetworkAction, |
+ object); |
+} |
+ |
TEST_F(CrosNetworkFunctionsLibcrosTest, CrosAddIPConfig) { |
const std::string device_path = "/device/path"; |
EXPECT_CALL(*MockChromeOSNetwork::Get(), |
@@ -722,6 +786,19 @@ class CrosNetworkFunctionsTest : public testing::Test { |
callback.Run(DBUS_METHOD_CALL_SUCCESS, *dictionary_value_result_); |
} |
+ // Mock NetworkActionCallback. |
+ MOCK_METHOD4(MockNetworkActionCallback, void(void* object, |
+ const char* path, |
+ NetworkMethodErrorType error, |
+ const char* error_message)); |
+ static void MockNetworkActionCallbackThunk(void* object, |
+ const char* path, |
+ NetworkMethodErrorType error, |
+ const char* error_message) { |
+ static_cast<CrosNetworkFunctionsTest*>(object)->MockNetworkActionCallback( |
+ object, path, error, error_message); |
+ } |
+ |
protected: |
MockCashewClient* mock_cashew_client_; |
MockFlimflamDeviceClient* mock_device_client_; |
@@ -1008,6 +1085,99 @@ TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkDeviceEnable) { |
CrosRequestNetworkDeviceEnable(flimflam::kTypeWifi, kDisable); |
} |
+TEST_F(CrosNetworkFunctionsTest, CrosRequestRequirePin) { |
+ const std::string device_path = "/device/path"; |
+ const std::string pin = "123456"; |
+ const bool kRequire = true; |
+ void* object = this; |
+ |
+ // Set expectations. |
+ base::Closure callback; |
+ EXPECT_CALL(*mock_device_client_, |
+ RequirePin(dbus::ObjectPath(device_path), pin, kRequire, _, _)) |
+ .WillOnce(SaveArg<3>(&callback)); |
+ EXPECT_CALL(*this, MockNetworkActionCallback( |
+ object, StrEq(device_path), NETWORK_METHOD_ERROR_NONE, _)).Times(1); |
+ CrosRequestRequirePin(device_path, pin, kRequire, |
+ &MockNetworkActionCallbackThunk, this); |
+ // Run saved callback. |
+ callback.Run(); |
+} |
+ |
+TEST_F(CrosNetworkFunctionsTest, CrosRequestEnterPin) { |
+ const std::string device_path = "/device/path"; |
+ const std::string pin = "123456"; |
+ void* object = this; |
+ |
+ // Set expectations. |
+ base::Closure callback; |
+ EXPECT_CALL(*mock_device_client_, |
+ EnterPin(dbus::ObjectPath(device_path), pin, _, _)) |
+ .WillOnce(SaveArg<2>(&callback)); |
+ EXPECT_CALL(*this, MockNetworkActionCallback( |
+ object, StrEq(device_path), NETWORK_METHOD_ERROR_NONE, _)).Times(1); |
+ CrosRequestEnterPin(device_path, pin, &MockNetworkActionCallbackThunk, this); |
+ // Run saved callback. |
+ callback.Run(); |
+} |
+ |
+TEST_F(CrosNetworkFunctionsTest, CrosRequestUnblockPin) { |
+ const std::string device_path = "/device/path"; |
+ const std::string unblock_code = "987654"; |
+ const std::string pin = "123456"; |
+ void* object = this; |
+ |
+ // Set expectations. |
+ base::Closure callback; |
+ EXPECT_CALL( |
+ *mock_device_client_, |
+ UnblockPin(dbus::ObjectPath(device_path), unblock_code, pin, _, _)) |
+ .WillOnce(SaveArg<3>(&callback)); |
+ EXPECT_CALL(*this, MockNetworkActionCallback( |
+ object, StrEq(device_path), NETWORK_METHOD_ERROR_NONE, _)).Times(1); |
+ CrosRequestUnblockPin(device_path, unblock_code, pin, |
+ &MockNetworkActionCallbackThunk, object); |
+ // Run saved callback. |
+ callback.Run(); |
+} |
+ |
+TEST_F(CrosNetworkFunctionsTest, CrosRequestChangePin) { |
+ const std::string device_path = "/device/path"; |
+ const std::string old_pin = "123456"; |
+ const std::string new_pin = "234567"; |
+ void* object = this; |
+ |
+ // Set expectations. |
+ base::Closure callback; |
+ EXPECT_CALL(*mock_device_client_, |
+ ChangePin(dbus::ObjectPath(device_path), old_pin, new_pin, _, _)) |
+ .WillOnce(SaveArg<3>(&callback)); |
+ EXPECT_CALL(*this, MockNetworkActionCallback( |
+ object, StrEq(device_path), NETWORK_METHOD_ERROR_NONE, _)).Times(1); |
+ CrosRequestChangePin(device_path, old_pin, new_pin, |
+ &MockNetworkActionCallbackThunk, object); |
+ // Run saved callback. |
+ callback.Run(); |
+} |
+ |
+TEST_F(CrosNetworkFunctionsTest, CrosRequestCellularRegister) { |
+ const std::string device_path = "/device/path"; |
+ const std::string network_id = "networkid"; |
+ void* object = this; |
+ |
+ // Set expectations. |
+ base::Closure callback; |
+ EXPECT_CALL(*mock_device_client_, |
+ Register(dbus::ObjectPath(device_path), network_id, _, _)) |
+ .WillOnce(SaveArg<2>(&callback)); |
+ EXPECT_CALL(*this, MockNetworkActionCallback( |
+ object, StrEq(device_path), NETWORK_METHOD_ERROR_NONE, _)).Times(1); |
+ CrosRequestCellularRegister(device_path, network_id, |
+ &MockNetworkActionCallbackThunk, object); |
+ // Run saved callback. |
+ callback.Run(); |
+} |
+ |
TEST_F(CrosNetworkFunctionsTest, CrosAddIPConfig) { |
const std::string device_path = "/device/path"; |
const dbus::ObjectPath result_path("/result/path"); |