aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Vakulenko <avakulenko@google.com>2015-12-09 08:10:38 -0800
committerandroid-build-merger <android-build-merger@google.com>2015-12-09 08:10:38 -0800
commit3ac6a0974fada57b6e0017bb9d2ec362804feefe (patch)
treee71b57ae3ecdb73aabe8d59293b6bc05f3c3af45
parent2216f94adae0ef69894538e84d680872b2993571 (diff)
parentbae6c02cd98daa7b731c75d972a818b06997a9e4 (diff)
downloadweaved-3ac6a0974fada57b6e0017bb9d2ec362804feefe.tar.gz
Fix weaved to make it work with the new libweave
am: bae6c02cd9 * commit 'bae6c02cd98daa7b731c75d972a818b06997a9e4': Fix weaved to make it work with the new libweave
-rw-r--r--buffet/dbus_command_proxy.cc10
-rw-r--r--buffet/dbus_command_proxy_unittest.cc20
-rw-r--r--buffet/manager.cc10
3 files changed, 20 insertions, 20 deletions
diff --git a/buffet/dbus_command_proxy.cc b/buffet/dbus_command_proxy.cc
index d0eeb15..b7e82c1 100644
--- a/buffet/dbus_command_proxy.cc
+++ b/buffet/dbus_command_proxy.cc
@@ -64,12 +64,12 @@ void DBusCommandProxy::RegisterAsync(
dbus_adaptor_.SetId(command->GetID());
dbus_adaptor_.SetState(EnumToString(command->GetState()));
dbus_adaptor_.SetProgress(
- DictionaryToDBusVariantDictionary(*command->GetProgress()));
+ DictionaryToDBusVariantDictionary(command->GetProgress()));
dbus_adaptor_.SetOrigin(EnumToString(command->GetOrigin()));
dbus_adaptor_.SetParameters(
- DictionaryToDBusVariantDictionary(*command->GetParameters()));
+ DictionaryToDBusVariantDictionary(command->GetParameters()));
dbus_adaptor_.SetResults(
- DictionaryToDBusVariantDictionary(*command->GetResults()));
+ DictionaryToDBusVariantDictionary(command->GetResults()));
// Register the command DBus object and expose its methods and properties.
dbus_object_.RegisterAsync(completion_callback);
@@ -93,7 +93,7 @@ bool DBusCommandProxy::SetProgress(
return false;
}
dbus_adaptor_.SetProgress(
- DictionaryToDBusVariantDictionary(*command->GetProgress()));
+ DictionaryToDBusVariantDictionary(command->GetProgress()));
dbus_adaptor_.SetState(EnumToString(command->GetState()));
return true;
}
@@ -115,7 +115,7 @@ bool DBusCommandProxy::Complete(brillo::ErrorPtr* error,
return false;
}
dbus_adaptor_.SetResults(
- DictionaryToDBusVariantDictionary(*command->GetResults()));
+ DictionaryToDBusVariantDictionary(command->GetResults()));
dbus_adaptor_.SetState(EnumToString(command->GetState()));
return true;
}
diff --git a/buffet/dbus_command_proxy_unittest.cc b/buffet/dbus_command_proxy_unittest.cc
index 410aa58..0aa701d 100644
--- a/buffet/dbus_command_proxy_unittest.cc
+++ b/buffet/dbus_command_proxy_unittest.cc
@@ -36,6 +36,7 @@ namespace buffet {
using ::testing::_;
using ::testing::AnyNumber;
using ::testing::Return;
+using ::testing::ReturnRef;
using ::testing::ReturnRefOfCopy;
using ::testing::StrictMock;
@@ -71,6 +72,8 @@ class DBusCommandProxyTest : public ::testing::Test {
EXPECT_CALL(*bus_, AssertOnOriginThread()).Times(AnyNumber());
EXPECT_CALL(*bus_, AssertOnDBusThread()).Times(AnyNumber());
+ expected_result_dict_.SetInteger("height", 53);
+ expected_result_dict_.SetString("_jumpType", "_withKick");
EXPECT_CALL(*command_, GetID())
.WillOnce(ReturnRefOfCopy<std::string>(kTestCommandId));
// Use WillRepeatedly because GetName is used for logging.
@@ -80,15 +83,12 @@ class DBusCommandProxyTest : public ::testing::Test {
.WillRepeatedly(Return(weave::Command::State::kQueued));
EXPECT_CALL(*command_, GetOrigin())
.WillOnce(Return(weave::Command::Origin::kLocal));
- EXPECT_CALL(*command_, MockGetParameters())
- .WillOnce(ReturnRefOfCopy<std::string>(R"({
- 'height': 53,
- '_jumpType': '_withKick'
- })"));
- EXPECT_CALL(*command_, MockGetProgress())
- .WillRepeatedly(ReturnRefOfCopy<std::string>("{}"));
- EXPECT_CALL(*command_, MockGetResults())
- .WillRepeatedly(ReturnRefOfCopy<std::string>("{}"));
+ EXPECT_CALL(*command_, GetParameters())
+ .WillOnce(ReturnRef(expected_result_dict_));
+ EXPECT_CALL(*command_, GetProgress())
+ .WillRepeatedly(ReturnRef(empty_dict_));
+ EXPECT_CALL(*command_, GetResults())
+ .WillRepeatedly(ReturnRef(empty_dict_));
// Set up a mock ExportedObject to be used with the DBus command proxy.
std::string cmd_path = buffet::dbus_constants::kCommandServicePathPrefix;
@@ -133,6 +133,8 @@ class DBusCommandProxyTest : public ::testing::Test {
scoped_refptr<dbus::MockExportedObject> mock_exported_object_command_;
scoped_refptr<dbus::MockBus> bus_;
+ base::DictionaryValue empty_dict_;
+ base::DictionaryValue expected_result_dict_;
std::shared_ptr<StrictMock<weave::test::MockCommand>> command_;
std::unique_ptr<DBusCommandProxy> proxy_;
diff --git a/buffet/manager.cc b/buffet/manager.cc
index 00e6dc8..61a5d7a 100644
--- a/buffet/manager.cc
+++ b/buffet/manager.cc
@@ -284,10 +284,9 @@ void Manager::UpdateState(DBusMethodResponsePtr<> response,
}
bool Manager::GetState(brillo::ErrorPtr* error, std::string* state) {
- auto json = device_->GetState();
- CHECK(json);
+ const base::DictionaryValue& json = device_->GetState();
base::JSONWriter::WriteWithOptions(
- *json, base::JSONWriter::OPTIONS_PRETTY_PRINT, state);
+ json, base::JSONWriter::OPTIONS_PRETTY_PRINT, state);
return true;
}
@@ -322,11 +321,10 @@ std::string Manager::TestMethod(const std::string& message) {
}
void Manager::OnStateChanged() {
- auto state = device_->GetState();
- CHECK(state);
+ const base::DictionaryValue& state = device_->GetState();
std::string json;
base::JSONWriter::WriteWithOptions(
- *state, base::JSONWriter::OPTIONS_PRETTY_PRINT, &json);
+ state, base::JSONWriter::OPTIONS_PRETTY_PRINT, &json);
dbus_adaptor_.SetState(json);
}