Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Unified Diff: chrome/browser/chromeos/cros/cros_network_functions_unittest.cc

Issue 10134027: Reimplement RequestNetworkServiceConnect, RequestRequirePin, RequestEnterPin, RequestEnterPin, Requ… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove reinterpret_cast Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 5a00814864912e5be7c11812d954ef11299cdc76..1afe3b5a63d775e720f02b555902d73ac273adc2 100644
--- a/chrome/browser/chromeos/cros/cros_network_functions_unittest.cc
+++ b/chrome/browser/chromeos/cros/cros_network_functions_unittest.cc
@@ -176,6 +176,17 @@ class CrosNetworkFunctionsLibcrosTest : public testing::Test {
NetworkMethodErrorType error,
const char* error_message) {}
+ // Does nothing. Used as an argument.
+ static void OnDataPlansUpdate(void* object,
+ const char* modem_service_path,
+ const CellularDataPlanList* dataplan) {}
+
+ // Does nothing. Used as an argument.
+ static void OnSmsReceived(void* object,
+ const char* modem_device_path,
+ const SMS* message) {}
+
+
protected:
ScopedGValue argument_gvalue_;
ScopedGHashTable argument_ghash_table_;
@@ -356,9 +367,8 @@ TEST_F(CrosNetworkFunctionsLibcrosTest, CrosMonitorNetworkDeviceProperties) {
}
TEST_F(CrosNetworkFunctionsLibcrosTest, CrosMonitorCellularDataPlan) {
- MonitorDataPlanCallback callback =
- reinterpret_cast<MonitorDataPlanCallback>(42); // Dummy value.
- void* object = reinterpret_cast<void*>(84); // Dummy value.
+ MonitorDataPlanCallback callback = &OnDataPlansUpdate;
satorux1 2012/04/24 06:05:55 maybe safer to add the class name ? &CrosNetworkF
hashimoto 2012/04/24 06:57:06 Done.
+ void* object = this;
// Start monitoring.
EXPECT_CALL(*MockChromeOSNetwork::Get(),
@@ -373,9 +383,8 @@ TEST_F(CrosNetworkFunctionsLibcrosTest, CrosMonitorCellularDataPlan) {
TEST_F(CrosNetworkFunctionsLibcrosTest, CrosMonitorSMS) {
const std::string modem_device_path = "/modem/device/path";
- MonitorSMSCallback callback =
- reinterpret_cast<MonitorSMSCallback>(42); // Dummy value.
- void* object = reinterpret_cast<void*>(84); // Dummy value.
+ MonitorSMSCallback callback = &OnSmsReceived;
+ void* object = this;
// Start monitoring.
EXPECT_CALL(*MockChromeOSNetwork::Get(),
@@ -390,6 +399,16 @@ TEST_F(CrosNetworkFunctionsLibcrosTest, CrosMonitorSMS) {
delete watcher;
}
+TEST_F(CrosNetworkFunctionsLibcrosTest, CrosRequestNetworkServiceConnect) {
+ const std::string service_path = "service path";
+ void* object = this;
satorux1 2012/04/24 06:05:55 I like this idea. cool
+ 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 +615,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 = this;
+ 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 = this;
+ 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 = this;
+ 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 = this;
+ 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 = this;
+ 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 +795,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_;
@@ -1100,6 +1186,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");
« no previous file with comments | « chrome/browser/chromeos/cros/cros_network_functions.cc ('k') | chrome/browser/chromeos/cros/mock_chromeos_network.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698