aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.clang-format3
-rw-r--r--examples/daemon/common/daemon.h3
-rw-r--r--examples/daemon/light/light.cc4
-rw-r--r--examples/daemon/lock/lock.cc4
-rw-r--r--examples/daemon/oven/oven.cc6
-rw-r--r--examples/provider/curl_http_client.cc8
-rw-r--r--examples/provider/curl_http_client.h3
-rw-r--r--examples/provider/event_http_client.cc3
-rw-r--r--examples/provider/event_network.cc2
-rw-r--r--examples/provider/event_task_runner.h3
-rw-r--r--examples/provider/file_config_store.cc6
-rw-r--r--include/weave/device.h47
-rw-r--r--include/weave/enum_to_string.h2
-rw-r--r--include/weave/error.h4
-rw-r--r--include/weave/provider/test/fake_task_runner.h3
-rw-r--r--include/weave/test/mock_device.h37
-rw-r--r--src/base_api_handler.cc3
-rw-r--r--src/base_api_handler_unittest.cc20
-rw-r--r--src/commands/cloud_command_proxy_unittest.cc4
-rw-r--r--src/commands/command_instance.h11
-rw-r--r--src/commands/command_queue_unittest.cc4
-rw-r--r--src/component_manager.h12
-rw-r--r--src/component_manager_impl.cc42
-rw-r--r--src/component_manager_impl.h7
-rw-r--r--src/component_manager_unittest.cc4
-rw-r--r--src/config.cc3
-rw-r--r--src/device_manager.cc29
-rw-r--r--src/device_registration_info.cc42
-rw-r--r--src/device_registration_info_unittest.cc200
-rw-r--r--src/mock_component_manager.h42
-rw-r--r--src/notification/notification_parser.cc3
-rw-r--r--src/notification/notification_parser_unittest.cc5
-rw-r--r--src/notification/xmpp_iq_stanza_handler.h2
-rw-r--r--src/notification/xmpp_stream_parser_unittest.cc2
-rw-r--r--src/privet/cloud_delegate.cc35
-rw-r--r--src/privet/cloud_delegate.h5
-rw-r--r--src/privet/device_delegate.cc11
-rw-r--r--src/privet/device_ui_kind.cc5
-rw-r--r--src/privet/mock_delegates.h11
-rw-r--r--src/privet/privet_handler.cc8
-rw-r--r--src/privet/privet_handler_unittest.cc46
-rw-r--r--src/privet/privet_manager.cc4
-rw-r--r--src/privet/wifi_bootstrap_manager.cc2
-rw-r--r--src/states/state_change_queue.h5
-rw-r--r--src/states/state_change_queue_unittest.cc11
-rw-r--r--src/streams_unittest.cc1
-rw-r--r--src/string_utils.cc2
-rw-r--r--src/test/fake_stream.cc5
-rw-r--r--src/weave_unittest.cc72
49 files changed, 407 insertions, 389 deletions
diff --git a/.clang-format b/.clang-format
index 685c597..cff09b2 100644
--- a/.clang-format
+++ b/.clang-format
@@ -2,4 +2,7 @@
Language: Cpp
# Usage: git clang-format -f m/master --style=file
BasedOnStyle: Chromium
+AllowShortFunctionsOnASingleLine: Inline
+AllowShortIfStatementsOnASingleLine: false
+AllowShortLoopsOnASingleLine: false
...
diff --git a/examples/daemon/common/daemon.h b/examples/daemon/common/daemon.h
index 5a90988..4cccff3 100644
--- a/examples/daemon/common/daemon.h
+++ b/examples/daemon/common/daemon.h
@@ -70,7 +70,8 @@ class Daemon {
Daemon(const Options& opts)
: config_store_{new weave::examples::FileConfigStore(
- opts.disable_security_, opts.model_id_)},
+ opts.disable_security_,
+ opts.model_id_)},
task_runner_{new weave::examples::EventTaskRunner},
http_client_{new weave::examples::CurlHttpClient(task_runner_.get())},
network_{new weave::examples::EventNetworkImpl(task_runner_.get())},
diff --git a/examples/daemon/light/light.cc b/examples/daemon/light/light.cc
index eaf9392..035ef4e 100644
--- a/examples/daemon/light/light.cc
+++ b/examples/daemon/light/light.cc
@@ -159,8 +159,8 @@ class LightHandler {
device->AddTraitDefinitionsFromJson(kTraits);
CHECK(device->AddComponent(kComponent, {"onOff", "brightness", "colorXY"},
nullptr));
- CHECK(device->SetStatePropertiesFromJson(kComponent, kDefaultState,
- nullptr));
+ CHECK(
+ device->SetStatePropertiesFromJson(kComponent, kDefaultState, nullptr));
UpdateLightState();
device->AddCommandHandler(kComponent, "onOff.setConfig",
diff --git a/examples/daemon/lock/lock.cc b/examples/daemon/lock/lock.cc
index 61961f0..1137b92 100644
--- a/examples/daemon/lock/lock.cc
+++ b/examples/daemon/lock/lock.cc
@@ -68,8 +68,8 @@ class LockHandler {
device->AddTraitDefinitionsFromJson(kTraits);
CHECK(device->AddComponent(kComponent, {"lock"}, nullptr));
- CHECK(device->SetStatePropertiesFromJson(kComponent, kDefaultState,
- nullptr));
+ CHECK(
+ device->SetStatePropertiesFromJson(kComponent, kDefaultState, nullptr));
UpdateLockState();
device->AddCommandHandler(kComponent, "lock.setConfig",
diff --git a/examples/daemon/oven/oven.cc b/examples/daemon/oven/oven.cc
index 79fc925..151561d 100644
--- a/examples/daemon/oven/oven.cc
+++ b/examples/daemon/oven/oven.cc
@@ -136,7 +136,7 @@ class OvenHandler {
weak_ptr_factory_.GetWeakPtr()));
}
-private:
+ private:
void OnSetTempCommand(const std::weak_ptr<weave::Command>& command) {
auto cmd = command.lock();
if (!cmd)
@@ -158,8 +158,8 @@ private:
LOG(INFO) << cmd->GetName() << " updated oven, matching temp";
if (target_temperature_ != current_temperature_ && !is_match_ticking_) {
- double tickIncrement = ((target_temperature_ - current_temperature_) /
- kWarmUpTime);
+ double tickIncrement =
+ ((target_temperature_ - current_temperature_) / kWarmUpTime);
DoTick(tickIncrement);
}
return;
diff --git a/examples/provider/curl_http_client.cc b/examples/provider/curl_http_client.cc
index 6f0ba64..2bf10f5 100644
--- a/examples/provider/curl_http_client.cc
+++ b/examples/provider/curl_http_client.cc
@@ -29,8 +29,8 @@ struct ResponseImpl : public provider::HttpClient::Response {
};
size_t WriteFunction(void* contents, size_t size, size_t nmemb, void* userp) {
- static_cast<std::string*>(userp)
- ->append(static_cast<const char*>(contents), size * nmemb);
+ static_cast<std::string*>(userp)->append(static_cast<const char*>(contents),
+ size * nmemb);
return size * nmemb;
}
@@ -49,8 +49,8 @@ size_t HeaderFunction(void* contents, size_t size, size_t nmemb, void* userp) {
header_pair.second = header.substr(pos, last_non_space - pos + 1);
}
- static_cast<provider::HttpClient::Headers*>(userp)
- ->emplace_back(std::move(header_pair));
+ static_cast<provider::HttpClient::Headers*>(userp)->emplace_back(
+ std::move(header_pair));
}
return size * nmemb;
}
diff --git a/examples/provider/curl_http_client.h b/examples/provider/curl_http_client.h
index c342076..8c5ccac 100644
--- a/examples/provider/curl_http_client.h
+++ b/examples/provider/curl_http_client.h
@@ -37,7 +37,8 @@ class CurlHttpClient : public provider::HttpClient {
std::vector<
std::pair<std::future<std::pair<std::unique_ptr<Response>, ErrorPtr>>,
- SendRequestCallback>> pending_tasks_;
+ SendRequestCallback>>
+ pending_tasks_;
provider::TaskRunner* task_runner_{nullptr};
base::WeakPtrFactory<CurlHttpClient> weak_ptr_factory_{this};
diff --git a/examples/provider/event_http_client.cc b/examples/provider/event_http_client.cc
index 1931547..fbfc6d8 100644
--- a/examples/provider/event_http_client.cc
+++ b/examples/provider/event_http_client.cc
@@ -5,10 +5,9 @@
#include "examples/provider/event_http_client.h"
#include "examples/provider/event_task_runner.h"
-
#include <base/bind.h>
-#include <event2/bufferevent.h>
#include <event2/buffer.h>
+#include <event2/bufferevent.h>
#include <event2/http.h>
#include <weave/enum_to_string.h>
diff --git a/examples/provider/event_network.cc b/examples/provider/event_network.cc
index ba03e8f..0b18a0a 100644
--- a/examples/provider/event_network.cc
+++ b/examples/provider/event_network.cc
@@ -7,8 +7,8 @@
#include <weave/enum_to_string.h>
#include <base/bind.h>
-#include <event2/dns.h>
#include <event2/bufferevent.h>
+#include <event2/dns.h>
#include "examples/provider/event_task_runner.h"
#include "examples/provider/ssl_stream.h"
diff --git a/examples/provider/event_task_runner.h b/examples/provider/event_task_runner.h
index 7291314..97f9db9 100644
--- a/examples/provider/event_task_runner.h
+++ b/examples/provider/event_task_runner.h
@@ -83,7 +83,8 @@ class EventTaskRunner : public provider::TaskRunner {
std::priority_queue<QueueItem,
std::vector<QueueItem>,
- EventTaskRunner::Greater> queue_;
+ EventTaskRunner::Greater>
+ queue_;
EventPtr<event_base> base_{event_base_new()};
diff --git a/examples/provider/file_config_store.cc b/examples/provider/file_config_store.cc
index 2214be8..6faa242 100644
--- a/examples/provider/file_config_store.cc
+++ b/examples/provider/file_config_store.cc
@@ -17,8 +17,10 @@ namespace examples {
const char kSettingsDir[] = "/var/lib/weave/";
-FileConfigStore::FileConfigStore(bool disable_security, const std::string& model_id)
- : disable_security_{disable_security}, model_id_{model_id},
+FileConfigStore::FileConfigStore(bool disable_security,
+ const std::string& model_id)
+ : disable_security_{disable_security},
+ model_id_{model_id},
settings_path_{"/var/lib/weave/weave_settings_" + model_id + ".json"} {}
bool FileConfigStore::LoadDefaults(Settings* settings) {
diff --git a/include/weave/device.h b/include/weave/device.h
index 99035f4..069e688 100644
--- a/include/weave/device.h
+++ b/include/weave/device.h
@@ -54,8 +54,7 @@ class Device {
virtual const base::DictionaryValue& GetTraits() const = 0;
// Sets callback which is called when new trait definitions are added.
- virtual void AddTraitDefsChangedCallback(
- const base::Closure& callback) = 0;
+ virtual void AddTraitDefsChangedCallback(const base::Closure& callback) = 0;
// Adds a new component instance to device. Traits used by this component
// must be already defined.
@@ -77,29 +76,25 @@ class Device {
// "{'base':{'firmwareVersion':'123'}}")
// Method completely replaces properties included |json| or |dict|.
// Properties of the state not included |json| or |dict| will stay unchanged.
- virtual bool SetStatePropertiesFromJson(
- const std::string& component,
- const std::string& json,
- ErrorPtr* error) = 0;
- virtual bool SetStateProperties(
- const std::string& component,
- const base::DictionaryValue& dict,
- ErrorPtr* error) = 0;
+ virtual bool SetStatePropertiesFromJson(const std::string& component,
+ const std::string& json,
+ ErrorPtr* error) = 0;
+ virtual bool SetStateProperties(const std::string& component,
+ const base::DictionaryValue& dict,
+ ErrorPtr* error) = 0;
// Returns value of the single property.
// |name| is full property name, including trait name. e.g. "base.network".
- virtual const base::Value* GetStateProperty(
- const std::string& component,
- const std::string& name,
- ErrorPtr* error) const = 0;
+ virtual const base::Value* GetStateProperty(const std::string& component,
+ const std::string& name,
+ ErrorPtr* error) const = 0;
// Sets value of the single property.
// |name| is full property name, including trait name. e.g. "base.network".
- virtual bool SetStateProperty(
- const std::string& component,
- const std::string& name,
- const base::Value& value,
- ErrorPtr* error) = 0;
+ virtual bool SetStateProperty(const std::string& component,
+ const std::string& name,
+ const base::Value& value,
+ ErrorPtr* error) = 0;
// Callback type for AddCommandHandler.
using CommandHandlerCallback =
@@ -113,10 +108,9 @@ class Device {
// Empty |component| and |command_name| sets default handler for all unhanded
// commands.
// No new command handlers can be set after default handler was set.
- virtual void AddCommandHandler(
- const std::string& component,
- const std::string& command_name,
- const CommandHandlerCallback& callback) = 0;
+ virtual void AddCommandHandler(const std::string& component,
+ const std::string& command_name,
+ const CommandHandlerCallback& callback) = 0;
// Adds a new command to the command queue.
virtual bool AddCommand(const base::DictionaryValue& command,
@@ -225,10 +219,9 @@ class Device {
// Sets value of the single property.
// |name| is full property name, including package name. e.g. "base.network".
// DO NOT USE IN YOUR CODE: use SetStateProperty() with component parameter.
- LIBWEAVE_DEPRECATED virtual bool SetStateProperty(
- const std::string& name,
- const base::Value& value,
- ErrorPtr* error) = 0;
+ LIBWEAVE_DEPRECATED virtual bool SetStateProperty(const std::string& name,
+ const base::Value& value,
+ ErrorPtr* error) = 0;
// Returns aggregated state properties across all registered packages.
// DO NOT USE IN YOUR CODE: use GetComponents() instead.
diff --git a/include/weave/enum_to_string.h b/include/weave/enum_to_string.h
index 67d6154..b6cfca3 100644
--- a/include/weave/enum_to_string.h
+++ b/include/weave/enum_to_string.h
@@ -37,7 +37,7 @@ class EnumToStringMap final {
private:
template <size_t size>
- explicit EnumToStringMap(const Map(&map)[size])
+ explicit EnumToStringMap(const Map (&map)[size])
: begin_(map), end_(map + size) {}
const Map* begin_;
diff --git a/include/weave/error.h b/include/weave/error.h
index 6687d98..14a85be 100644
--- a/include/weave/error.h
+++ b/include/weave/error.h
@@ -9,9 +9,9 @@
#include <string>
#include <base/callback.h>
-#include <base/macros.h>
-#include <base/location.h>
#include <base/compiler_specific.h>
+#include <base/location.h>
+#include <base/macros.h>
#include <weave/export.h>
namespace weave {
diff --git a/include/weave/provider/test/fake_task_runner.h b/include/weave/provider/test/fake_task_runner.h
index 06ccd6b..bb79455 100644
--- a/include/weave/provider/test/fake_task_runner.h
+++ b/include/weave/provider/test/fake_task_runner.h
@@ -53,7 +53,8 @@ class FakeTaskRunner : public TaskRunner {
std::priority_queue<QueueItem,
std::vector<QueueItem>,
- FakeTaskRunner::Greater> queue_;
+ FakeTaskRunner::Greater>
+ queue_;
};
} // namespace test
diff --git a/include/weave/test/mock_device.h b/include/weave/test/mock_device.h
index 612afb9..ddd3f59 100644
--- a/include/weave/test/mock_device.h
+++ b/include/weave/test/mock_device.h
@@ -26,29 +26,34 @@ class MockDevice : public Device {
MOCK_CONST_METHOD0(GetTraits, const base::DictionaryValue&());
MOCK_METHOD1(AddTraitDefsChangedCallback,
void(const base::Closure& callback));
- MOCK_METHOD3(AddComponent, bool(const std::string& name,
- const std::vector<std::string>& traits,
- ErrorPtr* error));
+ MOCK_METHOD3(AddComponent,
+ bool(const std::string& name,
+ const std::vector<std::string>& traits,
+ ErrorPtr* error));
MOCK_METHOD1(AddComponentTreeChangedCallback,
void(const base::Closure& callback));
MOCK_CONST_METHOD0(GetComponents, const base::DictionaryValue&());
- MOCK_METHOD3(SetStatePropertiesFromJson, bool(const std::string& component,
- const std::string& json,
- ErrorPtr* error));
- MOCK_METHOD3(SetStateProperties, bool(const std::string& component,
- const base::DictionaryValue& dict,
- ErrorPtr* error));
+ MOCK_METHOD3(SetStatePropertiesFromJson,
+ bool(const std::string& component,
+ const std::string& json,
+ ErrorPtr* error));
+ MOCK_METHOD3(SetStateProperties,
+ bool(const std::string& component,
+ const base::DictionaryValue& dict,
+ ErrorPtr* error));
MOCK_CONST_METHOD3(GetStateProperty,
const base::Value*(const std::string& component,
const std::string& name,
ErrorPtr* error));
- MOCK_METHOD4(SetStateProperty, bool(const std::string& component,
- const std::string& name,
- const base::Value& value,
- ErrorPtr* error));
- MOCK_METHOD3(AddCommandHandler, void(const std::string& component,
- const std::string& command_name,
- const CommandHandlerCallback& callback));
+ MOCK_METHOD4(SetStateProperty,
+ bool(const std::string& component,
+ const std::string& name,
+ const base::Value& value,
+ ErrorPtr* error));
+ MOCK_METHOD3(AddCommandHandler,
+ void(const std::string& component,
+ const std::string& command_name,
+ const CommandHandlerCallback& callback));
MOCK_METHOD3(AddCommand,
bool(const base::DictionaryValue&, std::string*, ErrorPtr*));
MOCK_METHOD1(FindCommand, Command*(const std::string&));
diff --git a/src/base_api_handler.cc b/src/base_api_handler.cc
index 6808949..9c64463 100644
--- a/src/base_api_handler.cc
+++ b/src/base_api_handler.cc
@@ -76,8 +76,7 @@ BaseApiHandler::BaseApiHandler(DeviceRegistrationInfo* device_info,
nullptr));
device_->AddCommandHandler(
- kBaseComponent,
- "base.updateBaseConfiguration",
+ kBaseComponent, "base.updateBaseConfiguration",
base::Bind(&BaseApiHandler::UpdateBaseConfiguration,
weak_ptr_factory_.GetWeakPtr()));
diff --git a/src/base_api_handler_unittest.cc b/src/base_api_handler_unittest.cc
index 14421b0..e0ebf88 100644
--- a/src/base_api_handler_unittest.cc
+++ b/src/base_api_handler_unittest.cc
@@ -35,11 +35,11 @@ class BaseApiHandlerTest : public ::testing::Test {
EXPECT_TRUE(component_manager_.LoadTraits(json, nullptr));
}));
EXPECT_CALL(device_, SetStateProperties(_, _, _))
- .WillRepeatedly(Invoke(&component_manager_,
- &ComponentManager::SetStateProperties));
+ .WillRepeatedly(
+ Invoke(&component_manager_, &ComponentManager::SetStateProperties));
EXPECT_CALL(device_, SetStateProperty(_, _, _, _))
- .WillRepeatedly(Invoke(&component_manager_,
- &ComponentManager::SetStateProperty));
+ .WillRepeatedly(
+ Invoke(&component_manager_, &ComponentManager::SetStateProperty));
EXPECT_CALL(device_, AddComponent(_, _, _))
.WillRepeatedly(Invoke([this](const std::string& name,
const std::vector<std::string>& traits,
@@ -47,12 +47,12 @@ class BaseApiHandlerTest : public ::testing::Test {
return component_manager_.AddComponent("", name, traits, error);
}));
- EXPECT_CALL(device_, AddCommandHandler(_,
- AnyOf("base.updateBaseConfiguration",
- "base.updateDeviceInfo"),
- _))
- .WillRepeatedly(Invoke(&component_manager_,
- &ComponentManager::AddCommandHandler));
+ EXPECT_CALL(device_,
+ AddCommandHandler(_, AnyOf("base.updateBaseConfiguration",
+ "base.updateDeviceInfo"),
+ _))
+ .WillRepeatedly(
+ Invoke(&component_manager_, &ComponentManager::AddCommandHandler));
config_.Load();
dev_reg_.reset(new DeviceRegistrationInfo(&config_, &component_manager_,
diff --git a/src/commands/cloud_command_proxy_unittest.cc b/src/commands/cloud_command_proxy_unittest.cc
index d3a9965..0e998ef 100644
--- a/src/commands/cloud_command_proxy_unittest.cc
+++ b/src/commands/cloud_command_proxy_unittest.cc
@@ -66,8 +66,8 @@ class CloudCommandProxyTest : public ::testing::Test {
protected:
void SetUp() override {
// Set up the test ComponentManager.
- auto callback =
- [this](const base::Callback<void(ComponentManager::UpdateID)>& call) {
+ auto callback = [this](
+ const base::Callback<void(ComponentManager::UpdateID)>& call) {
return callbacks_.Add(call).release();
};
EXPECT_CALL(component_manager_, MockAddServerStateUpdatedCallback(_))
diff --git a/src/commands/command_instance.h b/src/commands/command_instance.h
index 15f3ac2..b1028d0 100644
--- a/src/commands/command_instance.h
+++ b/src/commands/command_instance.h
@@ -12,8 +12,8 @@
#include <base/macros.h>
#include <base/observer_list.h>
-#include <weave/error.h>
#include <weave/command.h>
+#include <weave/error.h>
namespace base {
class Value;
@@ -72,11 +72,10 @@ class CommandInstance final : public Command {
// The command ID extracted (if present in the JSON object) even if other
// parsing/validation error occurs and command instance is not constructed.
// This is used to report parse failures back to the server.
- static std::unique_ptr<CommandInstance> FromJson(
- const base::Value* value,
- Command::Origin origin,
- std::string* command_id,
- ErrorPtr* error);
+ static std::unique_ptr<CommandInstance> FromJson(const base::Value* value,
+ Command::Origin origin,
+ std::string* command_id,
+ ErrorPtr* error);
std::unique_ptr<base::DictionaryValue> ToJson() const;
diff --git a/src/commands/command_queue_unittest.cc b/src/commands/command_queue_unittest.cc
index 08e8102..b4c5938 100644
--- a/src/commands/command_queue_unittest.cc
+++ b/src/commands/command_queue_unittest.cc
@@ -21,8 +21,8 @@ class CommandQueueTest : public testing::Test {
std::unique_ptr<CommandInstance> CreateDummyCommandInstance(
const std::string& name,
const std::string& id) {
- std::unique_ptr<CommandInstance> cmd{new CommandInstance{
- name, Command::Origin::kLocal, {}}};
+ std::unique_ptr<CommandInstance> cmd{
+ new CommandInstance{name, Command::Origin::kLocal, {}}};
cmd->SetID(id);
return cmd;
}
diff --git a/src/component_manager.h b/src/component_manager.h
index 5f16ac4..cf16720 100644
--- a/src/component_manager.h
+++ b/src/component_manager.h
@@ -34,7 +34,8 @@ struct ComponentStateChange {
ComponentStateChange(base::Time time,
const std::string& path,
std::unique_ptr<base::DictionaryValue> properties)
- : timestamp{time}, component{path},
+ : timestamp{time},
+ component{path},
changed_properties{std::move(properties)} {}
base::Time timestamp;
std::string component;
@@ -91,8 +92,8 @@ class ComponentManager {
// Adds a new command instance to the command queue. The command specified in
// |command_instance| must be fully initialized and have its name, component,
// id populated.
- virtual void AddCommand(
- std::unique_ptr<CommandInstance> command_instance) = 0;
+ virtual void
+ AddCommand(std::unique_ptr<CommandInstance> command_instance) = 0;
// Parses the command definition from a json dictionary. The resulting command
// instance is populated with all the required fields and partially validated
@@ -125,9 +126,8 @@ class ComponentManager {
const Device::CommandHandlerCallback& callback) = 0;
// Finds a component instance by its full path.
- virtual const base::DictionaryValue* FindComponent(
- const std::string& path,
- ErrorPtr* error) const = 0;
+ virtual const base::DictionaryValue* FindComponent(const std::string& path,
+ ErrorPtr* error) const = 0;
// Finds a definition of trait with the given |name|.
virtual const base::DictionaryValue* FindTraitDefinition(
const std::string& name) const = 0;
diff --git a/src/component_manager_impl.cc b/src/component_manager_impl.cc
index 89ca0cd..b1f3289 100644
--- a/src/component_manager_impl.cc
+++ b/src/component_manager_impl.cc
@@ -4,9 +4,9 @@
#include "src/component_manager_impl.h"
-#include <base/strings/stringprintf.h>
#include <base/strings/string_number_conversions.h>
#include <base/strings/string_util.h>
+#include <base/strings/stringprintf.h>
#include "src/commands/schema_constants.h"
#include "src/json_error_codes.h"
@@ -124,8 +124,7 @@ bool ComponentManagerImpl::LoadTraits(const base::DictionaryValue& dict,
if (!existing_def->Equals(&it.value())) {
Error::AddToPrintf(error, FROM_HERE, errors::commands::kDomain,
errors::commands::kTypeMismatch,
- "Trait '%s' cannot be redefined",
- it.key().c_str());
+ "Trait '%s' cannot be redefined", it.key().c_str());
result = false;
break;
}
@@ -168,8 +167,8 @@ std::unique_ptr<CommandInstance> ComponentManagerImpl::ParseCommandInstance(
std::string* id,
ErrorPtr* error) {
std::string command_id;
- auto command_instance = CommandInstance::FromJson(&command, command_origin,
- &command_id, error);
+ auto command_instance =
+ CommandInstance::FromJson(&command, command_origin, &command_id, error);
// If we fail to validate the command definition, but there was a command ID
// specified there, return it to the caller when requested. This will be
// used to abort cloud commands.
@@ -195,14 +194,15 @@ std::unique_ptr<CommandInstance> ComponentManagerImpl::ParseCommandInstance(
if (component_path.empty()) {
// Find the component to which to route this command. Get the trait name
// from the command name and find the first component that has this trait.
- auto trait_name = SplitAtFirst(command_instance->GetName(), ".", true).first;
+ auto trait_name =
+ SplitAtFirst(command_instance->GetName(), ".", true).first;
component_path = FindComponentWithTrait(trait_name);
if (component_path.empty()) {
Error::AddToPrintf(
error, FROM_HERE, errors::commands::kDomain, "unrouted_command",
"Unable route command '%s' because there is no component supporting"
- "trait '%s'", command_instance->GetName().c_str(),
- trait_name.c_str());
+ "trait '%s'",
+ command_instance->GetName().c_str(), trait_name.c_str());
return nullptr;
}
command_instance->SetComponent(component_path);
@@ -267,14 +267,15 @@ void ComponentManagerImpl::AddCommandHandler(
// If both component_path and command_name are empty, we are adding the
// default handler for all commands.
if (!component_path.empty() || !command_name.empty()) {
- CHECK(FindCommandDefinition(command_name))
- << "Command undefined: " << command_name;
+ CHECK(FindCommandDefinition(command_name)) << "Command undefined: "
+ << command_name;
}
command_queue_.AddCommandHandler(component_path, command_name, callback);
}
const base::DictionaryValue* ComponentManagerImpl::FindComponent(
- const std::string& path, ErrorPtr* error) const {
+ const std::string& path,
+ ErrorPtr* error) const {
return FindComponentAt(&components_, path, error);
}
@@ -488,8 +489,8 @@ bool ComponentManagerImpl::AddLegacyCommandDefinitions(
if (traits_.GetDictionary(key, nullptr)) {
Error::AddToPrintf(error, FROM_HERE, errors::commands::kDomain,
errors::commands::kInvalidPropValue,
- "Redefining command '%s.%s'",
- it.key().c_str(), it_def.key().c_str());
+ "Redefining command '%s.%s'", it.key().c_str(),
+ it_def.key().c_str());
result = false;
continue;
}
@@ -559,8 +560,8 @@ const base::DictionaryValue& ComponentManagerImpl::GetLegacyState() const {
return legacy_state_;
}
-const base::DictionaryValue&
-ComponentManagerImpl::GetLegacyCommandDefinitions() const {
+const base::DictionaryValue& ComponentManagerImpl::GetLegacyCommandDefinitions()
+ const {
legacy_command_defs_.Clear();
// Build commandDefs from traits.
for (base::DictionaryValue::Iterator it(traits_); !it.IsAtEnd();
@@ -603,7 +604,8 @@ void ComponentManagerImpl::AddTraitToLegacyComponent(const std::string& trait) {
}
base::DictionaryValue* ComponentManagerImpl::FindComponentGraftNode(
- const std::string& path, ErrorPtr* error) {
+ const std::string& path,
+ ErrorPtr* error) {
base::DictionaryValue* root = nullptr;
base::DictionaryValue* component = FindMutableComponent(path, error);
if (component && !component->GetDictionary("components", &root)) {
@@ -680,15 +682,15 @@ const base::DictionaryValue* ComponentManagerImpl::FindComponentAt(
if (value->GetType() == base::Value::TYPE_LIST && array_index < 0) {
Error::AddToPrintf(error, FROM_HERE, errors::commands::kDomain,
errors::commands::kTypeMismatch,
- "Element '%s.%s' is an array",
- root_path.c_str(), element.first.c_str());
+ "Element '%s.%s' is an array", root_path.c_str(),
+ element.first.c_str());
return nullptr;
}
if (value->GetType() == base::Value::TYPE_DICTIONARY && array_index >= 0) {
Error::AddToPrintf(error, FROM_HERE, errors::commands::kDomain,
errors::commands::kTypeMismatch,
- "Element '%s.%s' is not an array",
- root_path.c_str(), element.first.c_str());
+ "Element '%s.%s' is not an array", root_path.c_str(),
+ element.first.c_str());
return nullptr;
}
diff --git a/src/component_manager_impl.h b/src/component_manager_impl.h
index 6b8ff13..97d302d 100644
--- a/src/component_manager_impl.h
+++ b/src/component_manager_impl.h
@@ -53,8 +53,7 @@ class ComponentManagerImpl final : public ComponentManager {
// Adds a new command instance to the command queue. The command specified in
// |command_instance| must be fully initialized and have its name, component,
// id populated.
- void AddCommand(
- std::unique_ptr<CommandInstance> command_instance) override;
+ void AddCommand(std::unique_ptr<CommandInstance> command_instance) override;
// Parses the command definition from a json dictionary. The resulting command
// instance is populated with all the required fields and partially validated
@@ -199,7 +198,7 @@ class ComponentManagerImpl final : public ComponentManager {
// This member must be defined before |command_queue_|.
base::CallbackList<void(UpdateID)> on_server_state_updated_;
- base::DictionaryValue traits_; // Trait definitions.
+ base::DictionaryValue traits_; // Trait definitions.
base::DictionaryValue components_; // Component instances.
CommandQueue command_queue_; // Command queue containing command instances.
std::vector<base::Closure> on_trait_changed_;
@@ -209,7 +208,7 @@ class ComponentManagerImpl final : public ComponentManager {
std::map<std::string, std::unique_ptr<StateChangeQueue>> state_change_queues_;
// Legacy API support.
- mutable base::DictionaryValue legacy_state_; // Device state.
+ mutable base::DictionaryValue legacy_state_; // Device state.
mutable base::DictionaryValue legacy_command_defs_; // Command definitions.
DISALLOW_COPY_AND_ASSIGN(ComponentManagerImpl);
diff --git a/src/component_manager_unittest.cc b/src/component_manager_unittest.cc
index c3cf445..6b660b1 100644
--- a/src/component_manager_unittest.cc
+++ b/src/component_manager_unittest.cc
@@ -957,8 +957,8 @@ TEST_F(ComponentManagerTest, SetStatePropertiesFromJson) {
CreateTestComponentTree(&manager_);
ASSERT_TRUE(manager_.SetStatePropertiesFromJson(
- "comp1.comp2[1].comp3.comp4", R"({"t5": {"p1": 3}, "t6": {"p2": 5}})",
- nullptr));
+ "comp1.comp2[1].comp3.comp4",
+ R"({"t5": {"p1": 3}, "t6": {"p2": 5}})", nullptr));
const char kExpected[] = R"({
"comp1": {
diff --git a/src/config.cc b/src/config.cc
index 18e50b5..442a87a 100644
--- a/src/config.cc
+++ b/src/config.cc
@@ -85,8 +85,7 @@ LIBWEAVE_EXPORT EnumToStringMap<RootClientTokenOwner>::EnumToStringMap()
: EnumToStringMap(kRootClientTokenOwnerMap) {}
Config::Config(provider::ConfigStore* config_store)
- : settings_{CreateDefaultSettings()}, config_store_{config_store} {
-}
+ : settings_{CreateDefaultSettings()}, config_store_{config_store} {}
void Config::AddOnChangedCallback(const OnChangedCallback& callback) {
on_changed_.push_back(callback);
diff --git a/src/device_manager.cc b/src/device_manager.cc
index 88256da..ab2e225 100644
--- a/src/device_manager.cc
+++ b/src/device_manager.cc
@@ -129,10 +129,9 @@ bool DeviceManager::SetStateProperties(const std::string& component,
return component_manager_->SetStateProperties(component, dict, error);
}
-const base::Value* DeviceManager::GetStateProperty(
- const std::string& component,
- const std::string& name,
- ErrorPtr* error) const {
+const base::Value* DeviceManager::GetStateProperty(const std::string& component,
+ const std::string& name,
+ ErrorPtr* error) const {
return component_manager_->GetStateProperty(component, name, error);
}
@@ -162,9 +161,8 @@ void DeviceManager::AddCommandDefinitions(const base::DictionaryValue& dict) {
bool DeviceManager::AddCommand(const base::DictionaryValue& command,
std::string* id,
ErrorPtr* error) {
- auto command_instance =
- component_manager_->ParseCommandInstance(command, Command::Origin::kLocal,
- UserRole::kOwner, id, error);
+ auto command_instance = component_manager_->ParseCommandInstance(
+ command, Command::Origin::kLocal, UserRole::kOwner, id, error);
if (!command_instance)
return false;
component_manager_->AddCommand(std::move(command_instance));
@@ -212,10 +210,12 @@ bool DeviceManager::SetStateProperties(const base::DictionaryValue& dict,
std::string component =
component_manager_->FindComponentWithTrait(it.key());
if (component.empty()) {
- Error::AddToPrintf(
- error, FROM_HERE, errors::commands::kDomain, "unrouted_state",
- "Unable to set property value because there is no component supporting "
- "trait '%s'", it.key().c_str());
+ Error::AddToPrintf(error, FROM_HERE, errors::commands::kDomain,
+ "unrouted_state",
+ "Unable to set property value because there is no "
+ "component supporting "
+ "trait '%s'",
+ it.key().c_str());
return false;
}
base::DictionaryValue trait_state;
@@ -242,9 +242,10 @@ bool DeviceManager::SetStateProperty(const std::string& name,
std::string component = component_manager_->FindComponentWithTrait(trait);
if (component.empty()) {
Error::AddToPrintf(
- error, FROM_HERE, errors::commands::kDomain, "unrouted_state",
- "Unable set value of state property '%s' because there is no component "
- "supporting trait '%s'", name.c_str(), trait.c_str());
+ error, FROM_HERE, errors::commands::kDomain, "unrouted_state",
+ "Unable set value of state property '%s' because there is no component "
+ "supporting trait '%s'",
+ name.c_str(), trait.c_str());
return false;
}
return component_manager_->SetStateProperty(component, name, value, error);
diff --git a/src/device_registration_info.cc b/src/device_registration_info.cc
index 59a49b2..57e419c 100644
--- a/src/device_registration_info.cc
+++ b/src/device_registration_info.cc
@@ -277,12 +277,11 @@ DeviceRegistrationInfo::DeviceRegistrationInfo(
gcd_state_ =
revoked ? GcdState::kInvalidCredentials : GcdState::kUnconfigured;
- component_manager_->AddTraitDefChangedCallback(
- base::Bind(&DeviceRegistrationInfo::OnTraitDefsChanged,
+ component_manager_->AddTraitDefChangedCallback(base::Bind(
+ &DeviceRegistrationInfo::OnTraitDefsChanged, weak_factory_.GetWeakPtr()));
+ component_manager_->AddComponentTreeChangedCallback(
+ base::Bind(&DeviceRegistrationInfo::OnComponentTreeChanged,
weak_factory_.GetWeakPtr()));
- component_manager_->AddComponentTreeChangedCallback(base::Bind(
- &DeviceRegistrationInfo::OnComponentTreeChanged,
- weak_factory_.GetWeakPtr()));
component_manager_->AddStateChangedCallback(base::Bind(
&DeviceRegistrationInfo::OnStateChanged, weak_factory_.GetWeakPtr()));
}
@@ -611,12 +610,11 @@ void DeviceRegistrationInfo::RegisterDeviceOnTicketFinalized(
// Now get access_token and refresh_token
RequestSender sender2{HttpClient::Method::kPost, GetOAuthURL("token"),
http_client_};
- sender2.SetFormData(
- {{"code", auth_code},
- {"client_id", GetSettings().client_id},
- {"client_secret", GetSettings().client_secret},
- {"redirect_uri", "oob"},
- {"grant_type", "authorization_code"}});
+ sender2.SetFormData({{"code", auth_code},
+ {"client_id", GetSettings().client_id},
+ {"client_secret", GetSettings().client_secret},
+ {"redirect_uri", "oob"},
+ {"grant_type", "authorization_code"}});
sender2.Send(base::Bind(&DeviceRegistrationInfo::RegisterDeviceOnAuthCodeSent,
weak_factory_.GetWeakPtr(), cloud_id, robot_account,
callback));
@@ -715,9 +713,8 @@ void DeviceRegistrationInfo::OnCloudRequestDone(
int status_code = response->GetStatusCode();
if (status_code == http::kDenied) {
cloud_backoff_entry_->InformOfRequest(true);
- RefreshAccessToken(
- base::Bind(&DeviceRegistrationInfo::OnAccessTokenRefreshed, AsWeakPtr(),
- data));
+ RefreshAccessToken(base::Bind(
+ &DeviceRegistrationInfo::OnAccessTokenRefreshed, AsWeakPtr(), data));
return;
}
@@ -813,7 +810,8 @@ void DeviceRegistrationInfo::OnConnectedToCloud(ErrorPtr error) {
LOG(INFO) << "Device connected to cloud server";
connected_to_cloud_ = true;
FetchCommands(base::Bind(&DeviceRegistrationInfo::ProcessInitialCommandList,
- AsWeakPtr()), fetch_reason::kDeviceStart);
+ AsWeakPtr()),
+ fetch_reason::kDeviceStart);
// In case there are any pending state updates since we sent off the initial
// UpdateDeviceResource() request, update the server with any state changes.
PublishStateUpdates();
@@ -1065,8 +1063,8 @@ void DeviceRegistrationInfo::FetchCommands(
fetch_commands_request_queued_ = false;
DoCloudRequest(
HttpClient::Method::kGet,
- GetServiceURL("commands/queue", {{"deviceId", GetSettings().cloud_id},
- {"reason", reason}}),
+ GetServiceURL("commands/queue",
+ {{"deviceId", GetSettings().cloud_id}, {"reason", reason}}),
nullptr, base::Bind(&DeviceRegistrationInfo::OnFetchCommandsDone,
AsWeakPtr(), callback));
}
@@ -1155,9 +1153,9 @@ void DeviceRegistrationInfo::PublishCommand(
<< "' arrived, ID: " << command_instance->GetID();
std::unique_ptr<BackoffEntry> backoff_entry{
new BackoffEntry{cloud_backoff_policy_.get()}};
- std::unique_ptr<CloudCommandProxy> cloud_proxy{new CloudCommandProxy{
- command_instance.get(), this, component_manager_,
- std::move(backoff_entry), task_runner_}};
+ std::unique_ptr<CloudCommandProxy> cloud_proxy{
+ new CloudCommandProxy{command_instance.get(), this, component_manager_,
+ std::move(backoff_entry), task_runner_}};
// CloudCommandProxy::CloudCommandProxy() subscribe itself to Command
// notifications. When Command is being destroyed it sends
// ::OnCommandDestroyed() and CloudCommandProxy deletes itself.
@@ -1309,8 +1307,8 @@ void DeviceRegistrationInfo::OnCommandCreated(
// channel (XMPP) is active, we are doing a backup poll, so mark the request
// appropriately.
bool just_in_case =
- (channel_name == kPullChannelName) &&
- (current_notification_channel_ == primary_notification_channel_.get());
+ (channel_name == kPullChannelName) &&
+ (current_notification_channel_ == primary_notification_channel_.get());
std::string reason =
just_in_case ? fetch_reason::kJustInCase : fetch_reason::kNewCommand;
diff --git a/src/device_registration_info_unittest.cc b/src/device_registration_info_unittest.cc
index 66a9b1d..8be0c97 100644
--- a/src/device_registration_info_unittest.cc
+++ b/src/device_registration_info_unittest.cc
@@ -244,22 +244,22 @@ TEST_F(DeviceRegistrationInfoTest, HaveRegistrationCredentials) {
http_client_,
SendRequest(HttpClient::Method::kPost, dev_reg_->GetOAuthURL("token"),
HttpClient::Headers{GetFormHeader()}, _, _))
- .WillOnce(WithArgs<3, 4>(Invoke([](
- const std::string& data,
- const HttpClient::SendRequestCallback& callback) {
- EXPECT_EQ("refresh_token", GetFormField(data, "grant_type"));
- EXPECT_EQ(test_data::kRefreshToken,
- GetFormField(data, "refresh_token"));
- EXPECT_EQ(test_data::kClientId, GetFormField(data, "client_id"));
- EXPECT_EQ(test_data::kClientSecret,
- GetFormField(data, "client_secret"));
+ .WillOnce(WithArgs<3, 4>(
+ Invoke([](const std::string& data,
+ const HttpClient::SendRequestCallback& callback) {
+ EXPECT_EQ("refresh_token", GetFormField(data, "grant_type"));
+ EXPECT_EQ(test_data::kRefreshToken,
+ GetFormField(data, "refresh_token"));
+ EXPECT_EQ(test_data::kClientId, GetFormField(data, "client_id"));
+ EXPECT_EQ(test_data::kClientSecret,
+ GetFormField(data, "client_secret"));
- base::DictionaryValue json;
- json.SetString("access_token", test_data::kAccessToken);
- json.SetInteger("expires_in", 3600);
+ base::DictionaryValue json;
+ json.SetString("access_token", test_data::kAccessToken);
+ json.SetInteger("expires_in", 3600);
- callback.Run(ReplyWithJson(200, json), nullptr);
- })));
+ callback.Run(ReplyWithJson(200, json), nullptr);
+ })));
EXPECT_CALL(
http_client_,
@@ -288,20 +288,20 @@ TEST_F(DeviceRegistrationInfoTest, CheckAuthenticationFailure) {
http_client_,
SendRequest(HttpClient::Method::kPost, dev_reg_->GetOAuthURL("token"),
HttpClient::Headers{GetFormHeader()}, _, _))
- .WillOnce(WithArgs<3, 4>(Invoke([](
- const std::string& data,
- const HttpClient::SendRequestCallback& callback) {
- EXPECT_EQ("refresh_token", GetFormField(data, "grant_type"));
- EXPECT_EQ(test_data::kRefreshToken,
- GetFormField(data, "refresh_token"));
- EXPECT_EQ(test_data::kClientId, GetFormField(data, "client_id"));
- EXPECT_EQ(test_data::kClientSecret,
- GetFormField(data, "client_secret"));
+ .WillOnce(WithArgs<3, 4>(
+ Invoke([](const std::string& data,
+ const HttpClient::SendRequestCallback& callback) {
+ EXPECT_EQ("refresh_token", GetFormField(data, "grant_type"));
+ EXPECT_EQ(test_data::kRefreshToken,
+ GetFormField(data, "refresh_token"));
+ EXPECT_EQ(test_data::kClientId, GetFormField(data, "client_id"));
+ EXPECT_EQ(test_data::kClientSecret,
+ GetFormField(data, "client_secret"));
- base::DictionaryValue json;
- json.SetString("error", "unable_to_authenticate");
- callback.Run(ReplyWithJson(400, json), nullptr);
- })));
+ base::DictionaryValue json;
+ json.SetString("error", "unable_to_authenticate");
+ callback.Run(ReplyWithJson(400, json), nullptr);
+ })));
ErrorPtr error;
EXPECT_FALSE(RefreshAccessToken(&error));
@@ -317,20 +317,20 @@ TEST_F(DeviceRegistrationInfoTest, CheckDeregistration) {
http_client_,
SendRequest(HttpClient::Method::kPost, dev_reg_->GetOAuthURL("token"),
HttpClient::Headers{GetFormHeader()}, _, _))
- .WillOnce(WithArgs<3, 4>(Invoke([](
- const std::string& data,
- const HttpClient::SendRequestCallback& callback) {
- EXPECT_EQ("refresh_token", GetFormField(data, "grant_type"));
- EXPECT_EQ(test_data::kRefreshToken,
- GetFormField(data, "refresh_token"));
- EXPECT_EQ(test_data::kClientId, GetFormField(data, "client_id"));
- EXPECT_EQ(test_data::kClientSecret,
- GetFormField(data, "client_secret"));
+ .WillOnce(WithArgs<3, 4>(
+ Invoke([](const std::string& data,
+ const HttpClient::SendRequestCallback& callback) {
+ EXPECT_EQ("refresh_token", GetFormField(data, "grant_type"));
+ EXPECT_EQ(test_data::kRefreshToken,
+ GetFormField(data, "refresh_token"));
+ EXPECT_EQ(test_data::kClientId, GetFormField(data, "client_id"));
+ EXPECT_EQ(test_data::kClientSecret,
+ GetFormField(data, "client_secret"));
- base::DictionaryValue json;
- json.SetString("error", "invalid_grant");
- callback.Run(ReplyWithJson(400, json), nullptr);
- })));
+ base::DictionaryValue json;
+ json.SetString("error", "invalid_grant");
+ callback.Run(ReplyWithJson(400, json), nullptr);
+ })));
ErrorPtr error;
EXPECT_FALSE(RefreshAccessToken(&error));
@@ -396,8 +396,8 @@ TEST_F(DeviceRegistrationInfoTest, RegisterDevice) {
}
})");
EXPECT_TRUE(component_manager_.LoadTraits(*json_traits, nullptr));
- EXPECT_TRUE(component_manager_.AddComponent("", "comp", {"base", "robot"},
- nullptr));
+ EXPECT_TRUE(
+ component_manager_.AddComponent("", "comp", {"base", "robot"}, nullptr));
base::StringValue ver{"1.0"};
EXPECT_TRUE(component_manager_.SetStateProperty(
"comp", "base.firmwareVersion", ver, nullptr));
@@ -408,30 +408,30 @@ TEST_F(DeviceRegistrationInfoTest, RegisterDevice) {
SendRequest(HttpClient::Method::kPatch,
ticket_url + "?key=" + test_data::kApiKey,
HttpClient::Headers{GetJsonHeader()}, _, _))
- .WillOnce(WithArgs<3, 4>(Invoke([](
- const std::string& data,
- const HttpClient::SendRequestCallback& callback) {
- auto json = test::CreateDictionaryValue(data);
- EXPECT_NE(nullptr, json.get());
- std::string value;
- EXPECT_TRUE(json->GetString("id", &value));
- EXPECT_EQ(test_data::kClaimTicketId, value);
- EXPECT_TRUE(
- json->GetString("deviceDraft.channel.supportedType", &value));
- EXPECT_EQ("pull", value);
- EXPECT_TRUE(json->GetString("oauthClientId", &value));
- EXPECT_EQ(test_data::kClientId, value);
- EXPECT_TRUE(json->GetString("deviceDraft.description", &value));
- EXPECT_EQ("Easy to clean", value);
- EXPECT_TRUE(json->GetString("deviceDraft.location", &value));
- EXPECT_EQ("Kitchen", value);
- EXPECT_TRUE(json->GetString("deviceDraft.modelManifestId", &value));
- EXPECT_EQ("AAAAA", value);
- EXPECT_TRUE(json->GetString("deviceDraft.name", &value));
- EXPECT_EQ("Coffee Pot", value);
- base::DictionaryValue* dict = nullptr;
- EXPECT_TRUE(json->GetDictionary("deviceDraft.commandDefs", &dict));
- auto expectedCommandDefs = R"({
+ .WillOnce(WithArgs<3, 4>(
+ Invoke([](const std::string& data,
+ const HttpClient::SendRequestCallback& callback) {
+ auto json = test::CreateDictionaryValue(data);
+ EXPECT_NE(nullptr, json.get());
+ std::string value;
+ EXPECT_TRUE(json->GetString("id", &value));
+ EXPECT_EQ(test_data::kClaimTicketId, value);
+ EXPECT_TRUE(
+ json->GetString("deviceDraft.channel.supportedType", &value));
+ EXPECT_EQ("pull", value);
+ EXPECT_TRUE(json->GetString("oauthClientId", &value));
+ EXPECT_EQ(test_data::kClientId, value);
+ EXPECT_TRUE(json->GetString("deviceDraft.description", &value));
+ EXPECT_EQ("Easy to clean", value);
+ EXPECT_TRUE(json->GetString("deviceDraft.location", &value));
+ EXPECT_EQ("Kitchen", value);
+ EXPECT_TRUE(json->GetString("deviceDraft.modelManifestId", &value));
+ EXPECT_EQ("AAAAA", value);
+ EXPECT_TRUE(json->GetString("deviceDraft.name", &value));
+ EXPECT_EQ("Coffee Pot", value);
+ base::DictionaryValue* dict = nullptr;
+ EXPECT_TRUE(json->GetDictionary("deviceDraft.commandDefs", &dict));
+ auto expectedCommandDefs = R"({
'base': {
'reboot': {
'parameters': {
@@ -454,18 +454,18 @@ TEST_F(DeviceRegistrationInfoTest, RegisterDevice) {
}
}
})";
- EXPECT_JSON_EQ(expectedCommandDefs, *dict);
+ EXPECT_JSON_EQ(expectedCommandDefs, *dict);
- EXPECT_TRUE(json->GetDictionary("deviceDraft.state", &dict));
- auto expectedState = R"({
+ EXPECT_TRUE(json->GetDictionary("deviceDraft.state", &dict));
+ auto expectedState = R"({
'base': {
'firmwareVersion': '1.0'
}
})";
- EXPECT_JSON_EQ(expectedState, *dict);
+ EXPECT_JSON_EQ(expectedState, *dict);
- EXPECT_TRUE(json->GetDictionary("deviceDraft.traits", &dict));
- auto expectedTraits = R"({
+ EXPECT_TRUE(json->GetDictionary("deviceDraft.traits", &dict));
+ auto expectedTraits = R"({
'base': {
'commands': {
'reboot': {
@@ -486,10 +486,10 @@ TEST_F(DeviceRegistrationInfoTest, RegisterDevice) {
}
}
})";
- EXPECT_JSON_EQ(expectedTraits, *dict);
+ EXPECT_JSON_EQ(expectedTraits, *dict);
- EXPECT_TRUE(json->GetDictionary("deviceDraft.components", &dict));
- auto expectedComponents = R"({
+ EXPECT_TRUE(json->GetDictionary("deviceDraft.components", &dict));
+ auto expectedComponents = R"({
'comp': {
'traits': ['base', 'robot'],
'state': {
@@ -497,21 +497,21 @@ TEST_F(DeviceRegistrationInfoTest, RegisterDevice) {
}
}
})";
- EXPECT_JSON_EQ(expectedComponents, *dict);
-
- base::DictionaryValue json_resp;
- json_resp.SetString("id", test_data::kClaimTicketId);
- json_resp.SetString("kind", "weave#registrationTicket");
- json_resp.SetString("oauthClientId", test_data::kClientId);
- base::DictionaryValue* device_draft = nullptr;
- EXPECT_TRUE(json->GetDictionary("deviceDraft", &device_draft));
- device_draft = device_draft->DeepCopy();
- device_draft->SetString("id", test_data::kCloudId);
- device_draft->SetString("kind", "weave#device");
- json_resp.Set("deviceDraft", device_draft);
-
- callback.Run(ReplyWithJson(200, json_resp), nullptr);
- })));
+ EXPECT_JSON_EQ(expectedComponents, *dict);
+
+ base::DictionaryValue json_resp;
+ json_resp.SetString("id", test_data::kClaimTicketId);
+ json_resp.SetString("kind", "weave#registrationTicket");
+ json_resp.SetString("oauthClientId", test_data::kClientId);
+ base::DictionaryValue* device_draft = nullptr;
+ EXPECT_TRUE(json->GetDictionary("deviceDraft", &device_draft));
+ device_draft = device_draft->DeepCopy();
+ device_draft->SetString("id", test_data::kCloudId);
+ device_draft->SetString("kind", "weave#device");
+ json_resp.Set("deviceDraft", device_draft);
+
+ callback.Run(ReplyWithJson(200, json_resp), nullptr);
+ })));
EXPECT_CALL(http_client_,
SendRequest(HttpClient::Method::kPost,
@@ -621,8 +621,8 @@ class DeviceRegistrationInfoUpdateCommandTest
}
})");
EXPECT_TRUE(component_manager_.LoadTraits(*json_traits, nullptr));
- EXPECT_TRUE(component_manager_.AddComponent("", "comp", {"robot"},
- nullptr));
+ EXPECT_TRUE(
+ component_manager_.AddComponent("", "comp", {"robot"}, nullptr));
command_url_ = dev_reg_->GetServiceURL("commands/1234");
@@ -689,14 +689,14 @@ TEST_F(DeviceRegistrationInfoUpdateCommandTest, Cancel) {
http_client_,
SendRequest(HttpClient::Method::kPatch, command_url_,
HttpClient::Headers{GetAuthHeader(), GetJsonHeader()}, _, _))
- .WillOnce(WithArgs<3, 4>(Invoke([](
- const std::string& data,
- const HttpClient::SendRequestCallback& callback) {
- EXPECT_JSON_EQ(R"({"state":"cancelled"})",
- *CreateDictionaryValue(data));
- base::DictionaryValue json;
- callback.Run(ReplyWithJson(200, json), nullptr);
- })));
+ .WillOnce(WithArgs<3, 4>(
+ Invoke([](const std::string& data,
+ const HttpClient::SendRequestCallback& callback) {
+ EXPECT_JSON_EQ(R"({"state":"cancelled"})",
+ *CreateDictionaryValue(data));
+ base::DictionaryValue json;
+ callback.Run(ReplyWithJson(200, json), nullptr);
+ })));
EXPECT_TRUE(command_->Cancel(nullptr));
}
diff --git a/src/mock_component_manager.h b/src/mock_component_manager.h
index e30b8b0..08c1e59 100644
--- a/src/mock_component_manager.h
+++ b/src/mock_component_manager.h
@@ -14,14 +14,15 @@ namespace weave {
class MockComponentManager : public ComponentManager {
public:
~MockComponentManager() override {}
- MOCK_METHOD2(LoadTraits, bool(const base::DictionaryValue& dict,
- ErrorPtr* error));
+ MOCK_METHOD2(LoadTraits,
+ bool(const base::DictionaryValue& dict, ErrorPtr* error));
MOCK_METHOD2(LoadTraits, bool(const std::string& json, ErrorPtr* error));
MOCK_METHOD1(AddTraitDefChangedCallback, void(const base::Closure& callback));
- MOCK_METHOD4(AddComponent, bool(const std::string& path,
- const std::string& name,
- const std::vector<std::string>& traits,
- ErrorPtr* error));
+ MOCK_METHOD4(AddComponent,
+ bool(const std::string& path,
+ const std::string& name,
+ const std::vector<std::string>& traits,
+ ErrorPtr* error));
MOCK_METHOD4(AddComponentArrayItem,
bool(const std::string& path,
const std::string& name,
@@ -53,14 +54,16 @@ class MockComponentManager : public ComponentManager {
MOCK_CONST_METHOD1(
FindCommandDefinition,
const base::DictionaryValue*(const std::string& command_name));
- MOCK_CONST_METHOD3(GetMinimalRole, bool(const std::string& command_name,
- UserRole* minimal_role,
- ErrorPtr* error));
+ MOCK_CONST_METHOD3(GetMinimalRole,
+ bool(const std::string& command_name,
+ UserRole* minimal_role,
+ ErrorPtr* error));
MOCK_CONST_METHOD0(GetTraits, const base::DictionaryValue&());
MOCK_CONST_METHOD0(GetComponents, const base::DictionaryValue&());
- MOCK_METHOD3(SetStateProperties, bool(const std::string& component_path,
- const base::DictionaryValue& dict,
- ErrorPtr* error));
+ MOCK_METHOD3(SetStateProperties,
+ bool(const std::string& component_path,
+ const base::DictionaryValue& dict,
+ ErrorPtr* error));
MOCK_METHOD3(SetStatePropertiesFromJson,
bool(const std::string& component_path,
const std::string& json,
@@ -69,17 +72,18 @@ class MockComponentManager : public ComponentManager {
const base::Value*(const std::string& component_path,
const std::string& name,
ErrorPtr* error));
- MOCK_METHOD4(SetStateProperty, bool(const std::string& component_path,
- const std::string& name,
- const base::Value& value,
- ErrorPtr* error));
+ MOCK_METHOD4(SetStateProperty,
+ bool(const std::string& component_path,
+ const std::string& name,
+ const base::Value& value,
+ ErrorPtr* error));
MOCK_METHOD1(AddStateChangedCallback, void(const base::Closure& callback));
MOCK_METHOD0(MockGetAndClearRecordedStateChanges, StateSnapshot&());
MOCK_METHOD1(NotifyStateUpdatedOnServer, void(UpdateID id));
MOCK_CONST_METHOD0(GetLastStateChangeId, UpdateID());
MOCK_METHOD1(MockAddServerStateUpdatedCallback,
base::CallbackList<void(UpdateID)>::Subscription*(
- const base::Callback<void(UpdateID)>& callback));
+ const base::Callback<void(UpdateID)>& callback));
MOCK_CONST_METHOD1(FindComponentWithTrait,
std::string(const std::string& trait));
MOCK_METHOD2(AddLegacyCommandDefinitions,
@@ -100,8 +104,8 @@ class MockComponentManager : public ComponentManager {
UserRole role,
std::string* id,
ErrorPtr* error) {
- return std::unique_ptr<CommandInstance>{MockParseCommandInstance(
- command, command_origin, role, id, error)};
+ return std::unique_ptr<CommandInstance>{
+ MockParseCommandInstance(command, command_origin, role, id, error)};
}
StateSnapshot GetAndClearRecordedStateChanges() override {
return std::move(MockGetAndClearRecordedStateChanges());
diff --git a/src/notification/notification_parser.cc b/src/notification/notification_parser.cc
index d7c4f48..69e7e7e 100644
--- a/src/notification/notification_parser.cc
+++ b/src/notification/notification_parser.cc
@@ -45,8 +45,7 @@ bool ParseNotificationJson(const base::DictionaryValue& notification,
CHECK(delegate);
std::string kind;
- if (!notification.GetString("kind", &kind) ||
- kind != "weave#notification") {
+ if (!notification.GetString("kind", &kind) || kind != "weave#notification") {
LOG(WARNING) << "Push notification should have 'kind' property set to "
"weave#notification";
return false;
diff --git a/src/notification/notification_parser_unittest.cc b/src/notification/notification_parser_unittest.cc
index c69f9dd..fd5f0a7 100644
--- a/src/notification/notification_parser_unittest.cc
+++ b/src/notification/notification_parser_unittest.cc
@@ -25,8 +25,9 @@ class MockNotificationDelegate : public NotificationDelegate {
MOCK_METHOD1(OnConnected, void(const std::string&));
MOCK_METHOD0(OnDisconnected, void());
MOCK_METHOD0(OnPermanentFailure, void());
- MOCK_METHOD2(OnCommandCreated, void(const base::DictionaryValue& command,
- const std::string& channel_name));
+ MOCK_METHOD2(OnCommandCreated,
+ void(const base::DictionaryValue& command,
+ const std::string& channel_name));
MOCK_METHOD1(OnDeviceDeleted, void(const std::string&));
};
diff --git a/src/notification/xmpp_iq_stanza_handler.h b/src/notification/xmpp_iq_stanza_handler.h
index 052e5d2..7259cff 100644
--- a/src/notification/xmpp_iq_stanza_handler.h
+++ b/src/notification/xmpp_iq_stanza_handler.h
@@ -11,8 +11,8 @@
#include <base/callback_forward.h>
#include <base/macros.h>
-#include <base/time/time.h>
#include <base/memory/weak_ptr.h>
+#include <base/time/time.h>
#include "src/notification/xmpp_stream_parser.h"
diff --git a/src/notification/xmpp_stream_parser_unittest.cc b/src/notification/xmpp_stream_parser_unittest.cc
index f6466fe..72ca7b2 100644
--- a/src/notification/xmpp_stream_parser_unittest.cc
+++ b/src/notification/xmpp_stream_parser_unittest.cc
@@ -4,9 +4,9 @@
#include "src/notification/xmpp_stream_parser.h"
+#include <gtest/gtest.h>
#include <memory>
#include <vector>
-#include <gtest/gtest.h>
#include "src/notification/xml_node.h"
diff --git a/src/privet/cloud_delegate.cc b/src/privet/cloud_delegate.cc
index 3c3f0bb..fdd8500 100644
--- a/src/privet/cloud_delegate.cc
+++ b/src/privet/cloud_delegate.cc
@@ -50,19 +50,18 @@ class CloudDelegateImpl : public CloudDelegate {
device_->AddGcdStateChangedCallback(base::Bind(
&CloudDelegateImpl::OnRegistrationChanged, weak_factory_.GetWeakPtr()));
- component_manager_->AddTraitDefChangedCallback(base::Bind(
- &CloudDelegateImpl::NotifyOnTraitDefsChanged,
- weak_factory_.GetWeakPtr()));
+ component_manager_->AddTraitDefChangedCallback(
+ base::Bind(&CloudDelegateImpl::NotifyOnTraitDefsChanged,
+ weak_factory_.GetWeakPtr()));
component_manager_->AddCommandAddedCallback(base::Bind(
&CloudDelegateImpl::OnCommandAdded, weak_factory_.GetWeakPtr()));
component_manager_->AddCommandRemovedCallback(base::Bind(
&CloudDelegateImpl::OnCommandRemoved, weak_factory_.GetWeakPtr()));
component_manager_->AddStateChangedCallback(base::Bind(
- &CloudDelegateImpl::NotifyOnStateChanged,
- weak_factory_.GetWeakPtr()));
- component_manager_->AddComponentTreeChangedCallback(base::Bind(
- &CloudDelegateImpl::NotifyOnComponentTreeChanged,
- weak_factory_.GetWeakPtr()));
+ &CloudDelegateImpl::NotifyOnStateChanged, weak_factory_.GetWeakPtr()));
+ component_manager_->AddComponentTreeChangedCallback(
+ base::Bind(&CloudDelegateImpl::NotifyOnComponentTreeChanged,
+ weak_factory_.GetWeakPtr()));
}
~CloudDelegateImpl() override = default;
@@ -128,9 +127,8 @@ class CloudDelegateImpl : public CloudDelegate {
setup_weak_factory_.InvalidateWeakPtrs();
backoff_entry_.Reset();
task_runner_->PostDelayedTask(
- FROM_HERE,
- base::Bind(&CloudDelegateImpl::CallManagerRegisterDevice,
- setup_weak_factory_.GetWeakPtr()),
+ FROM_HERE, base::Bind(&CloudDelegateImpl::CallManagerRegisterDevice,
+ setup_weak_factory_.GetWeakPtr()),
{});
// Return true because we initiated setup.
return true;
@@ -276,9 +274,9 @@ class CloudDelegateImpl : public CloudDelegate {
return;
}
- device_->RegisterDevice(
- ticket_id_, base::Bind(&CloudDelegateImpl::RegisterDeviceDone,
- setup_weak_factory_.GetWeakPtr()));
+ device_->RegisterDevice(ticket_id_,
+ base::Bind(&CloudDelegateImpl::RegisterDeviceDone,
+ setup_weak_factory_.GetWeakPtr()));
}
void RegisterDeviceDone(ErrorPtr error) {
@@ -286,9 +284,8 @@ class CloudDelegateImpl : public CloudDelegate {
// Registration failed. Retry with backoff.
backoff_entry_.InformOfRequest(false);
return task_runner_->PostDelayedTask(
- FROM_HERE,
- base::Bind(&CloudDelegateImpl::CallManagerRegisterDevice,
- setup_weak_factory_.GetWeakPtr()),
+ FROM_HERE, base::Bind(&CloudDelegateImpl::CallManagerRegisterDevice,
+ setup_weak_factory_.GetWeakPtr()),
backoff_entry_.GetTimeUntilRelease());
}
backoff_entry_.InformOfRequest(true);
@@ -369,8 +366,8 @@ std::unique_ptr<CloudDelegate> CloudDelegate::CreateDefault(
provider::TaskRunner* task_runner,
DeviceRegistrationInfo* device,
ComponentManager* component_manager) {
- return std::unique_ptr<CloudDelegateImpl>{new CloudDelegateImpl{
- task_runner, device, component_manager}};
+ return std::unique_ptr<CloudDelegateImpl>{
+ new CloudDelegateImpl{task_runner, device, component_manager}};
}
void CloudDelegate::NotifyOnDeviceInfoChanged() {
diff --git a/src/privet/cloud_delegate.h b/src/privet/cloud_delegate.h
index 4aa9bcb..9f053d8 100644
--- a/src/privet/cloud_delegate.h
+++ b/src/privet/cloud_delegate.h
@@ -105,9 +105,8 @@ class CloudDelegate {
virtual const base::DictionaryValue& GetComponents() const = 0;
// Finds a component at the given path. Return nullptr in case of an error.
- virtual const base::DictionaryValue* FindComponent(
- const std::string& path,
- ErrorPtr* error) const = 0;
+ virtual const base::DictionaryValue* FindComponent(const std::string& path,
+ ErrorPtr* error) const = 0;
// Returns dictionary with trait definitions.
virtual const base::DictionaryValue& GetTraits() const = 0;
diff --git a/src/privet/device_delegate.cc b/src/privet/device_delegate.cc
index 5722357..552cbe2 100644
--- a/src/privet/device_delegate.cc
+++ b/src/privet/device_delegate.cc
@@ -20,8 +20,10 @@ class DeviceDelegateImpl : public DeviceDelegate {
uint16_t http_port,
uint16_t https_port,
base::TimeDelta http_request_timeout)
- : task_runner_{task_runner}, http_request_timeout_{http_request_timeout},
- http_port_{http_port}, https_port_{https_port} {}
+ : task_runner_{task_runner},
+ http_request_timeout_{http_request_timeout},
+ http_port_{http_port},
+ https_port_{https_port} {}
~DeviceDelegateImpl() override = default;
std::pair<uint16_t, uint16_t> GetHttpEnpoint() const override {
@@ -59,9 +61,8 @@ std::unique_ptr<DeviceDelegate> DeviceDelegate::CreateDefault(
uint16_t http_port,
uint16_t https_port,
base::TimeDelta http_request_timeout) {
- return std::unique_ptr<DeviceDelegate>(
- new DeviceDelegateImpl(task_runner, http_port, https_port,
- http_request_timeout));
+ return std::unique_ptr<DeviceDelegate>(new DeviceDelegateImpl(
+ task_runner, http_port, https_port, http_request_timeout));
}
} // namespace privet
diff --git a/src/privet/device_ui_kind.cc b/src/privet/device_ui_kind.cc
index 8909bed..cc740e8 100644
--- a/src/privet/device_ui_kind.cc
+++ b/src/privet/device_ui_kind.cc
@@ -12,9 +12,9 @@ namespace weave {
namespace privet {
std::string GetDeviceUiKind(const std::string& manifest_id) {
-
// Map of device short id to ui device kind
static const std::unordered_map<std::string, std::string> device_kind_map = {
+ // clang-format off
{"AC", "accessPoint"},
{"AK", "aggregator"},
{"AM", "camera"},
@@ -28,7 +28,8 @@ std::string GetDeviceUiKind(const std::string& manifest_id) {
{"AL", "storage"},
{"AJ", "toy"},
{"AA", "vendor"},
- {"AN", "video"}
+ {"AN", "video"},
+ // clang-format on
};
CHECK_EQ(5u, manifest_id.size());
diff --git a/src/privet/mock_delegates.h b/src/privet/mock_delegates.h
index 9ae94a8..f671591 100644
--- a/src/privet/mock_delegates.h
+++ b/src/privet/mock_delegates.h
@@ -47,9 +47,10 @@ class MockDeviceDelegate : public DeviceDelegate {
MOCK_CONST_METHOD0(GetHttpEnpoint, IntPair());
MOCK_CONST_METHOD0(GetHttpsEnpoint, IntPair());
MOCK_CONST_METHOD0(GetHttpRequestTimeout, base::TimeDelta());
- MOCK_METHOD3(PostDelayedTask, void(const tracked_objects::Location&,
- const base::Closure&,
- base::TimeDelta));
+ MOCK_METHOD3(PostDelayedTask,
+ void(const tracked_objects::Location&,
+ const base::Closure&,
+ base::TimeDelta));
MockDeviceDelegate() {
EXPECT_CALL(*this, GetHttpEnpoint())
@@ -194,8 +195,8 @@ class MockCloudDelegate : public CloudDelegate {
EXPECT_CALL(*this, GetCloudId()).WillRepeatedly(Return("TestCloudId"));
test_dict_.Set("test", new base::DictionaryValue);
EXPECT_CALL(*this, GetLegacyState()).WillRepeatedly(ReturnRef(test_dict_));
- EXPECT_CALL(*this,
- GetLegacyCommandDef()).WillRepeatedly(ReturnRef(test_dict_));
+ EXPECT_CALL(*this, GetLegacyCommandDef())
+ .WillRepeatedly(ReturnRef(test_dict_));
EXPECT_CALL(*this, GetTraits()).WillRepeatedly(ReturnRef(test_dict_));
EXPECT_CALL(*this, GetComponents()).WillRepeatedly(ReturnRef(test_dict_));
EXPECT_CALL(*this, FindComponent(_, _)).Times(0);
diff --git a/src/privet/privet_handler.cc b/src/privet/privet_handler.cc
index b435435..377888f 100644
--- a/src/privet/privet_handler.cc
+++ b/src/privet/privet_handler.cc
@@ -392,7 +392,10 @@ PrivetHandler::PrivetHandler(CloudDelegate* cloud,
SecurityDelegate* security,
WifiDelegate* wifi,
base::Clock* clock)
- : cloud_(cloud), device_(device), security_(security), wifi_(wifi),
+ : cloud_(cloud),
+ device_(device),
+ security_(security),
+ wifi_(wifi),
clock_(clock ? clock : &default_clock_) {
CHECK(cloud_);
CHECK(device_);
@@ -1029,8 +1032,7 @@ void PrivetHandler::ReplyToUpdateRequest(
output.SetString(kStateFingerprintKey, std::to_string(state_fingerprint_));
output.SetString(kCommandsFingerprintKey,
std::to_string(traits_fingerprint_));
- output.SetString(kTraitsFingerprintKey,
- std::to_string(traits_fingerprint_));
+ output.SetString(kTraitsFingerprintKey, std::to_string(traits_fingerprint_));
output.SetString(kComponentsFingerprintKey,
std::to_string(components_fingerprint_));
callback.Run(http::kOk, output);
diff --git a/src/privet/privet_handler_unittest.cc b/src/privet/privet_handler_unittest.cc
index 20856f7..5274ba9 100644
--- a/src/privet/privet_handler_unittest.cc
+++ b/src/privet/privet_handler_unittest.cc
@@ -71,8 +71,8 @@ bool IsEqualError(const CodeWithReason& expected,
}
// Some error sections in response JSON objects contained debugging information
-// which is of no interest for this test. So, remove the debug info from the JSON
-// before running validation logic on it.
+// which is of no interest for this test. So, remove the debug info from the
+// JSON before running validation logic on it.
std::unique_ptr<base::DictionaryValue> StripDebugErrorDetails(
const std::string& path_to_error_object,
const base::DictionaryValue& value) {
@@ -97,8 +97,8 @@ class PrivetHandlerTest : public testing::Test {
.WillRepeatedly(Return(base::Time::FromTimeT(1410000001)));
auth_header_ = "Privet anonymous";
- handler_.reset(new PrivetHandler(&cloud_, &device_, &security_, &wifi_,
- &clock_));
+ handler_.reset(
+ new PrivetHandler(&cloud_, &device_, &security_, &wifi_, &clock_));
}
const base::DictionaryValue& HandleRequest(
@@ -129,8 +129,8 @@ class PrivetHandlerTest : public testing::Test {
int GetResponseCount() const { return response_count_; }
void SetNoWifiAndGcd() {
- handler_.reset(new PrivetHandler(&cloud_, &device_, &security_, nullptr,
- &clock_));
+ handler_.reset(
+ new PrivetHandler(&cloud_, &device_, &security_, nullptr, &clock_));
EXPECT_CALL(cloud_, GetCloudId()).WillRepeatedly(Return(""));
EXPECT_CALL(cloud_, GetConnectionState())
.WillRepeatedly(ReturnRef(gcd_disabled_state_));
@@ -339,9 +339,8 @@ TEST_F(PrivetHandlerTest, PairingConfirm) {
}
TEST_F(PrivetHandlerTest, PairingCancel) {
- EXPECT_JSON_EQ("{}",
- HandleRequest("/privet/v3/pairing/cancel",
- "{'sessionId': 'testSession'}"));
+ EXPECT_JSON_EQ("{}", HandleRequest("/privet/v3/pairing/cancel",
+ "{'sessionId': 'testSession'}"));
}
TEST_F(PrivetHandlerTest, AuthErrorNoType) {
@@ -459,9 +458,8 @@ TEST_F(PrivetHandlerSetupTest, StatusWifiError) {
}
})";
EXPECT_JSON_EQ(kExpected,
- *StripDebugErrorDetails("wifi",
- HandleRequest(
- "/privet/v3/setup/status", "{}")));
+ *StripDebugErrorDetails(
+ "wifi", HandleRequest("/privet/v3/setup/status", "{}")));
}
TEST_F(PrivetHandlerSetupTest, StatusGcd) {
@@ -490,9 +488,8 @@ TEST_F(PrivetHandlerSetupTest, StatusGcdError) {
}
})";
EXPECT_JSON_EQ(kExpected,
- *StripDebugErrorDetails("gcd",
- HandleRequest(
- "/privet/v3/setup/status", "{}")));
+ *StripDebugErrorDetails(
+ "gcd", HandleRequest("/privet/v3/setup/status", "{}")));
}
TEST_F(PrivetHandlerSetupTest, SetupNameDescriptionLocation) {
@@ -747,8 +744,7 @@ TEST_F(PrivetHandlerSetupTest, ComponentsWithFiltersAndPaths) {
const base::DictionaryValue* comp2 = nullptr;
ASSERT_TRUE(components.GetDictionary("comp1.components.comp2", &comp2));
- EXPECT_CALL(cloud_, FindComponent("comp1.comp2", _))
- .WillOnce(Return(comp2));
+ EXPECT_CALL(cloud_, FindComponent("comp1.comp2", _)).WillOnce(Return(comp2));
const char kExpected5[] = R"({
"components": {
@@ -763,9 +759,11 @@ TEST_F(PrivetHandlerSetupTest, ComponentsWithFiltersAndPaths) {
},
"fingerprint": "1"
})";
- EXPECT_JSON_EQ(kExpected5, HandleRequest(
- "/privet/v3/components",
- "{'path':'comp1.comp2', 'filter':['traits', 'components']}"));
+ EXPECT_JSON_EQ(
+ kExpected5,
+ HandleRequest(
+ "/privet/v3/components",
+ "{'path':'comp1.comp2', 'filter':['traits', 'components']}"));
auto error_handler = [](ErrorPtr* error) -> const base::DictionaryValue* {
Error::AddTo(error, FROM_HERE, errors::kDomain, "componentNotFound", "");
@@ -775,11 +773,9 @@ TEST_F(PrivetHandlerSetupTest, ComponentsWithFiltersAndPaths) {
.WillOnce(WithArgs<1>(Invoke(error_handler)));
EXPECT_PRED2(
- IsEqualError,
- CodeWithReason(500, "componentNotFound"),
- HandleRequest(
- "/privet/v3/components",
- "{'path':'comp7', 'filter':['traits', 'components']}"));
+ IsEqualError, CodeWithReason(500, "componentNotFound"),
+ HandleRequest("/privet/v3/components",
+ "{'path':'comp7', 'filter':['traits', 'components']}"));
}
TEST_F(PrivetHandlerSetupTest, CommandsExecute) {
diff --git a/src/privet/privet_manager.cc b/src/privet/privet_manager.cc
index 16c552e..c3f3885 100644
--- a/src/privet/privet_manager.cc
+++ b/src/privet/privet_manager.cc
@@ -58,8 +58,8 @@ void Manager::Start(Network* network,
device_ = DeviceDelegate::CreateDefault(
task_runner_, http_server->GetHttpPort(), http_server->GetHttpsPort(),
http_server->GetRequestTimeout());
- cloud_ = CloudDelegate::CreateDefault(task_runner_, device,
- component_manager);
+ cloud_ =
+ CloudDelegate::CreateDefault(task_runner_, device, component_manager);
cloud_observer_.Add(cloud_.get());
security_.reset(new SecurityManager(
diff --git a/src/privet/wifi_bootstrap_manager.cc b/src/privet/wifi_bootstrap_manager.cc
index 292622d..086e21c 100644
--- a/src/privet/wifi_bootstrap_manager.cc
+++ b/src/privet/wifi_bootstrap_manager.cc
@@ -12,8 +12,8 @@
#include <weave/provider/wifi.h>
#include "src/bind_lambda.h"
-#include "src/privet/constants.h"
#include "src/config.h"
+#include "src/privet/constants.h"
namespace weave {
namespace privet {
diff --git a/src/states/state_change_queue.h b/src/states/state_change_queue.h
index 3aef8d5..1539ffc 100644
--- a/src/states/state_change_queue.h
+++ b/src/states/state_change_queue.h
@@ -32,9 +32,8 @@ class StateChangeQueue {
public:
explicit StateChangeQueue(size_t max_queue_size);
- bool NotifyPropertiesUpdated(
- base::Time timestamp,
- const base::DictionaryValue& changed_properties);
+ bool NotifyPropertiesUpdated(base::Time timestamp,
+ const base::DictionaryValue& changed_properties);
std::vector<StateChange> GetAndClearRecordedStateChanges();
private:
diff --git a/src/states/state_change_queue_unittest.cc b/src/states/state_change_queue_unittest.cc
index 57cf490..7eeaa28 100644
--- a/src/states/state_change_queue_unittest.cc
+++ b/src/states/state_change_queue_unittest.cc
@@ -43,10 +43,10 @@ TEST_F(StateChangeQueueTest, UpdateMany) {
auto timestamp2 = timestamp1 + base::TimeDelta::FromSeconds(1);
const std::string state2 =
"{'prop': {'name1': 17, 'name2': 1.0, 'name3': false}}";
- ASSERT_TRUE(queue_->NotifyPropertiesUpdated(
- timestamp1, *CreateDictionaryValue(state1)));
- ASSERT_TRUE(queue_->NotifyPropertiesUpdated(
- timestamp2, *CreateDictionaryValue(state2)));
+ ASSERT_TRUE(queue_->NotifyPropertiesUpdated(timestamp1,
+ *CreateDictionaryValue(state1)));
+ ASSERT_TRUE(queue_->NotifyPropertiesUpdated(timestamp2,
+ *CreateDictionaryValue(state2)));
auto changes = queue_->GetAndClearRecordedStateChanges();
ASSERT_EQ(2u, changes.size());
@@ -111,8 +111,7 @@ TEST_F(StateChangeQueueTest, MaxQueueSize) {
EXPECT_EQ(start_time + time_delta1, changes[0].timestamp);
EXPECT_JSON_EQ(expected1, *changes[0].changed_properties);
- const std::string expected2 =
- "{'prop': {'name10': 10, 'name11': 11}}";
+ const std::string expected2 = "{'prop': {'name10': 10, 'name11': 11}}";
EXPECT_EQ(start_time + time_delta2, changes[1].timestamp);
EXPECT_JSON_EQ(expected2, *changes[1].changed_properties);
}
diff --git a/src/streams_unittest.cc b/src/streams_unittest.cc
index fba6ca5..2eae050 100644
--- a/src/streams_unittest.cc
+++ b/src/streams_unittest.cc
@@ -5,6 +5,7 @@
#include "src/streams.h"
#include <functional>
+
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <weave/provider/test/fake_task_runner.h>
diff --git a/src/string_utils.cc b/src/string_utils.cc
index d4386f0..1604903 100644
--- a/src/string_utils.cc
+++ b/src/string_utils.cc
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include <algorithm>
#include <string.h>
+#include <algorithm>
#include <utility>
#include <base/strings/string_util.h>
diff --git a/src/test/fake_stream.cc b/src/test/fake_stream.cc
index 1101779..42c5fe2 100644
--- a/src/test/fake_stream.cc
+++ b/src/test/fake_stream.cc
@@ -49,9 +49,8 @@ void FakeStream::Write(const void* buffer,
size_t size_to_write,
const WriteCallback& callback) {
size_t size = std::min(size_to_write, write_data_.size());
- EXPECT_EQ(
- write_data_.substr(0, size),
- std::string(reinterpret_cast<const char*>(buffer), size_to_write));
+ EXPECT_EQ(write_data_.substr(0, size),
+ std::string(reinterpret_cast<const char*>(buffer), size_to_write));
write_data_ = write_data_.substr(size);
task_runner_->PostDelayedTask(FROM_HERE, base::Bind(callback, nullptr),
base::TimeDelta::FromSeconds(0));
diff --git a/src/weave_unittest.cc b/src/weave_unittest.cc
index 24c6973..4d1f731 100644
--- a/src/weave_unittest.cc
+++ b/src/weave_unittest.cc
@@ -188,20 +188,20 @@ class WeaveTest : public ::testing::Test {
const UrlMatcher& url_matcher,
const std::string& json_response) {
EXPECT_CALL(http_client_, SendRequest(method, url_matcher, _, _, _))
- .WillOnce(WithArgs<4>(Invoke([json_response](
- const HttpClient::SendRequestCallback& callback) {
- std::unique_ptr<provider::test::MockHttpClientResponse> response{
- new StrictMock<provider::test::MockHttpClientResponse>};
- EXPECT_CALL(*response, GetStatusCode())
- .Times(AtLeast(1))
- .WillRepeatedly(Return(200));
- EXPECT_CALL(*response, GetContentType())
- .Times(AtLeast(1))
- .WillRepeatedly(Return("application/json; charset=utf-8"));
- EXPECT_CALL(*response, GetData())
- .WillRepeatedly(Return(json_response));
- callback.Run(std::move(response), nullptr);
- })));
+ .WillOnce(WithArgs<4>(Invoke(
+ [json_response](const HttpClient::SendRequestCallback& callback) {
+ std::unique_ptr<provider::test::MockHttpClientResponse> response{
+ new StrictMock<provider::test::MockHttpClientResponse>};
+ EXPECT_CALL(*response, GetStatusCode())
+ .Times(AtLeast(1))
+ .WillRepeatedly(Return(200));
+ EXPECT_CALL(*response, GetContentType())
+ .Times(AtLeast(1))
+ .WillRepeatedly(Return("application/json; charset=utf-8"));
+ EXPECT_CALL(*response, GetData())
+ .WillRepeatedly(Return(json_response));
+ callback.Run(std::move(response), nullptr);
+ })));
}
void InitConfigStore() {
@@ -281,23 +281,39 @@ class WeaveTest : public ::testing::Test {
&http_server_, &wifi_, &bluetooth_);
EXPECT_EQ((std::set<std::string>{
- "/privet/info", "/privet/v3/pairing/cancel",
- "/privet/v3/pairing/confirm", "/privet/v3/pairing/start"}),
+ // clang-format off
+ "/privet/info",
+ "/privet/v3/pairing/cancel",
+ "/privet/v3/pairing/confirm",
+ "/privet/v3/pairing/start",
+ // clang-format on
+ }),
GetKeys(http_handlers_));
EXPECT_EQ((std::set<std::string>{
- "/privet/info", "/privet/v3/auth",
- "/privet/v3/checkForUpdates", "/privet/v3/commandDefs",
- "/privet/v3/commands/cancel", "/privet/v3/commands/execute",
- "/privet/v3/commands/list", "/privet/v3/commands/status",
- "/privet/v3/components", "/privet/v3/pairing/cancel",
- "/privet/v3/pairing/confirm", "/privet/v3/pairing/start",
- "/privet/v3/setup/start", "/privet/v3/setup/status",
- "/privet/v3/state", "/privet/v3/traits"}),
+ // clang-format off
+ "/privet/info",
+ "/privet/v3/auth",
+ "/privet/v3/checkForUpdates",
+ "/privet/v3/commandDefs",
+ "/privet/v3/commands/cancel",
+ "/privet/v3/commands/execute",
+ "/privet/v3/commands/list",
+ "/privet/v3/commands/status",
+ "/privet/v3/components",
+ "/privet/v3/pairing/cancel",
+ "/privet/v3/pairing/confirm",
+ "/privet/v3/pairing/start",
+ "/privet/v3/setup/start",
+ "/privet/v3/setup/status",
+ "/privet/v3/state",
+ "/privet/v3/traits",
+ // clang-format on
+ }),
GetKeys(https_handlers_));
device_->AddTraitDefinitionsFromJson(kTraitDefs);
- EXPECT_TRUE(device_->AddComponent("myComponent", {"trait1", "trait2"},
- nullptr));
+ EXPECT_TRUE(
+ device_->AddComponent("myComponent", {"trait1", "trait2"}, nullptr));
EXPECT_TRUE(device_->SetStatePropertiesFromJson(
"myComponent", R"({"trait2": {"battery_level":44}})", nullptr));
@@ -358,8 +374,8 @@ TEST_F(WeaveTest, StartNoWifi) {
&network_, &dns_sd_, &http_server_, nullptr,
&bluetooth_);
device_->AddTraitDefinitionsFromJson(kTraitDefs);
- EXPECT_TRUE(device_->AddComponent("myComponent", {"trait1", "trait2"},
- nullptr));
+ EXPECT_TRUE(
+ device_->AddComponent("myComponent", {"trait1", "trait2"}, nullptr));
task_runner_.Run();
}