diff options
Diffstat (limited to 'chromeos')
-rw-r--r-- | chromeos/dbus/flimflam_manager_client.cc | 11 | ||||
-rw-r--r-- | chromeos/dbus/flimflam_manager_client.h | 8 | ||||
-rw-r--r-- | chromeos/dbus/flimflam_manager_client_unittest.cc | 27 | ||||
-rw-r--r-- | chromeos/dbus/mock_flimflam_manager_client.h | 1 |
4 files changed, 47 insertions, 0 deletions
diff --git a/chromeos/dbus/flimflam_manager_client.cc b/chromeos/dbus/flimflam_manager_client.cc index 2374854..d09d34d 100644 --- a/chromeos/dbus/flimflam_manager_client.cc +++ b/chromeos/dbus/flimflam_manager_client.cc @@ -73,6 +73,12 @@ class FlimflamManagerClientImpl : public FlimflamManagerClient { helper_.CallDictionaryValueMethod(&method_call, callback); } + virtual base::DictionaryValue* CallGetPropertiesAndBlock() OVERRIDE { + dbus::MethodCall method_call(flimflam::kFlimflamManagerInterface, + flimflam::kGetPropertiesFunction); + return helper_.CallDictionaryValueMethodAndBlock(&method_call); + } + virtual void SetProperty(const std::string& name, const base::Value& value, const VoidCallback& callback) OVERRIDE { @@ -162,6 +168,11 @@ class FlimflamManagerClientStubImpl : public FlimflamManagerClient { } // FlimflamManagerClient override. + virtual base::DictionaryValue* CallGetPropertiesAndBlock() OVERRIDE { + return new base::DictionaryValue; + } + + // FlimflamManagerClient override. virtual void SetProperty(const std::string& name, const base::Value& value, const VoidCallback& callback) OVERRIDE { diff --git a/chromeos/dbus/flimflam_manager_client.h b/chromeos/dbus/flimflam_manager_client.h index 45b6806..b767703 100644 --- a/chromeos/dbus/flimflam_manager_client.h +++ b/chromeos/dbus/flimflam_manager_client.h @@ -49,6 +49,14 @@ class CHROMEOS_EXPORT FlimflamManagerClient { // |callback| is called after the method call succeeds. virtual void GetProperties(const DictionaryValueCallback& callback) = 0; + // DEPRECATED DO NOT USE: Calls GetProperties method and blocks until the + // method call finishes. The caller is responsible to delete the result. + // Thie method returns NULL when method call fails. + // + // TODO(hashimoto): Refactor CrosGetWifiAccessPoints and remove this method. + // crosbug.com/29902 + virtual base::DictionaryValue* CallGetPropertiesAndBlock() = 0; + // Calls SetProperty method. // |callback| is called after the method call succeeds. virtual void SetProperty(const std::string& name, diff --git a/chromeos/dbus/flimflam_manager_client_unittest.cc b/chromeos/dbus/flimflam_manager_client_unittest.cc index 6dcc0df..502f67f 100644 --- a/chromeos/dbus/flimflam_manager_client_unittest.cc +++ b/chromeos/dbus/flimflam_manager_client_unittest.cc @@ -169,6 +169,33 @@ TEST_F(FlimflamManagerClientTest, GetProperties) { message_loop_.RunAllPending(); } +TEST_F(FlimflamManagerClientTest, CallGetPropertiesAndBlock) { + // Create response. + scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); + dbus::MessageWriter writer(response.get()); + dbus::MessageWriter array_writer(NULL); + writer.OpenArray("{sv}", &array_writer); + dbus::MessageWriter entry_writer(NULL); + array_writer.OpenDictEntry(&entry_writer); + entry_writer.AppendString(flimflam::kOfflineModeProperty); + entry_writer.AppendVariantOfBool(true); + array_writer.CloseContainer(&entry_writer); + writer.CloseContainer(&array_writer); + + // Create the expected value. + base::DictionaryValue value; + value.SetWithoutPathExpansion(flimflam::kOfflineModeProperty, + base::Value::CreateBooleanValue(true)); + // Set expectations. + PrepareForMethodCall(flimflam::kGetPropertiesFunction, + base::Bind(&ExpectNoArgument), + response.get()); + // Call method. + scoped_ptr<base::DictionaryValue> result( + client_->CallGetPropertiesAndBlock()); + EXPECT_TRUE(value.Equals(result.get())); +} + TEST_F(FlimflamManagerClientTest, SetProperty) { // Create response. scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); diff --git a/chromeos/dbus/mock_flimflam_manager_client.h b/chromeos/dbus/mock_flimflam_manager_client.h index ca50f9b..f412ff8 100644 --- a/chromeos/dbus/mock_flimflam_manager_client.h +++ b/chromeos/dbus/mock_flimflam_manager_client.h @@ -20,6 +20,7 @@ class MockFlimflamManagerClient : public FlimflamManagerClient { const PropertyChangedHandler& handler)); MOCK_METHOD0(ResetPropertyChangedHandler, void()); MOCK_METHOD1(GetProperties, void(const DictionaryValueCallback& callback)); + MOCK_METHOD0(CallGetPropertiesAndBlock, base::DictionaryValue*()); MOCK_METHOD3(SetProperty, void(const std::string& name, const base::Value& value, const VoidCallback& callback)); |