summaryrefslogtreecommitdiffstats
path: root/chromeos
diff options
context:
space:
mode:
authorhashimoto@chromium.org <hashimoto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-25 13:57:53 +0000
committerhashimoto@chromium.org <hashimoto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-25 13:57:53 +0000
commitd5e5ec8ec8319c73eb0bca7aea869a06491345d2 (patch)
treeb40ea0b154d94c9585139a11c4f483e8f9ae4c5f /chromeos
parentb150da68f1f661ff8ec6c679b63ff106722a0bab (diff)
downloadchromium_src-d5e5ec8ec8319c73eb0bca7aea869a06491345d2.zip
chromium_src-d5e5ec8ec8319c73eb0bca7aea869a06491345d2.tar.gz
chromium_src-d5e5ec8ec8319c73eb0bca7aea869a06491345d2.tar.bz2
Reimplement CrosGetWifiAccessPoints without Libcros
BUG=chromium-os:16557 TEST=unit_tests --gtest_filter="CrosNetworkFunctionsTest.CrosGetWifiAccessPoints" Review URL: http://codereview.chromium.org/10202009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133902 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chromeos')
-rw-r--r--chromeos/dbus/flimflam_manager_client.cc11
-rw-r--r--chromeos/dbus/flimflam_manager_client.h8
-rw-r--r--chromeos/dbus/flimflam_manager_client_unittest.cc27
-rw-r--r--chromeos/dbus/mock_flimflam_manager_client.h1
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));