aboutsummaryrefslogtreecommitdiff
path: root/src/privet
diff options
context:
space:
mode:
authorVitaly Buka <vitalybuka@google.com>2015-12-15 14:46:47 -0800
committerVitaly Buka <vitalybuka@google.com>2015-12-16 01:32:53 +0000
commit34668e731bb194b443bc0e6029d6d3583f08de28 (patch)
tree977de929eeaf54e264d1693d1a392a161ebf52f5 /src/privet
parentc3bc82a29cdff05d67d3b583ca0bc25df96ab382 (diff)
downloadlibweave-34668e731bb194b443bc0e6029d6d3583f08de28.tar.gz
Reformat
Change-Id: Ia98499f9ada220151b24ecb8b60b02524d700bc4 Reviewed-on: https://weave-review.googlesource.com/1967 Reviewed-by: Vitaly Buka <vitalybuka@google.com>
Diffstat (limited to 'src/privet')
-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
9 files changed, 62 insertions, 65 deletions
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 {